微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > 射频无线通信设计 > SimpliciTI协议栈移植

SimpliciTI协议栈移植

时间:10-02 整理:3721RD 点击:
移植到ST单片机上运行,射频芯片为CC1101
目前调试一直不能通信,代码用的是ST官方。接收中断根本进不去,节点也不能入网

上代码


  1. int main (void)
  2. {
  3. bspIState_t intState;
  4. smplStatus_t smplSta = SMPL_NO_LINK;

  5. BSP_Init(); //初始化外围接口
  6. disableInterrupts();
  7. smplSta = SMPL_Init(sCB);//初始化协议栈
  8. /* green and red LEDs on solid to indicate waiting for a Join. */
  9. if (!BSP_LED1_IS_ON())
  10. {
  11. toggleLED(1);
  12. }
  13. Send_String(" AP Device Start!!\r\n");
  14. enableInterrupts();
  15. /* main work loop */
  16. while (1)
  17. {
  18. /* Wait for the Join semaphore to be set by the receipt of a Join frame from a
  19. * device that supports an End Device.
  20. *
  21. * An external method could be used as well. A button press could be connected
  22. * to an ISR and the ISR could set a semaphore that is checked by a function
  23. * call here, or a command shell running in support of a serial connection
  24. * could set a semaphore that is checked by a function call.
  25. */
  26. if (sJoinSem && (sNumCurrentPeers < NUM_CONNECTIONS))//新设备入网
  27. {
  28. toggleLED(1);
  29. toggleLED(2);
  30. /* listen for a new connection */
  31. while (1)
  32. {
  33. if (SMPL_SUCCESS == SMPL_LinkListen(&sLID[sNumCurrentPeers]))//监听ED发起的连接
  34. {
  35. break;
  36. }
  37. /* Implement fail-to-link policy here. otherwise, listen again. */
  38. }

  39. sNumCurrentPeers++;
  40. BSP_ENTER_CRITICAL_SECTION(intState);//临界保护
  41. sJoinSem--;
  42. BSP_EXIT_CRITICAL_SECTION(intState);
  43. }

  44. /* Have we received a frame on one of the ED connections?
  45. * No critical section -- it doesn't really matter much if we miss a poll
  46. */
  47. if (sPeerFrameSem) //通信数据
  48. {
  49. uint8_t msg[MAX_APP_PAYLOAD], len, i;
  50. toggleLED(1);
  51. toggleLED(2);
  52. /* process all frames waiting */
  53. for (i=0; i<sNumCurrentPeers; ++i)//核对数据帧对应的LINKID
  54. {
  55. if (SMPL_SUCCESS == SMPL_Receive(sLID[i], msg, &len))//接收数据 sLID - LINK ID
  56. {
  57. processMessage(sLID[i], msg, len); //处理
  58. BSP_ENTER_CRITICAL_SECTION(intState);
  59. sPeerFrameSem--;
  60. BSP_EXIT_CRITICAL_SECTION(intState);
  61. }
  62. }
  63. }
  64. }

  65. }

复制代码

只能一点点查外设的配置了
SPI GDOx IRQ 这些硬件

协议栈的功耗有点大,而且上电进行入网的过程是堵塞的时间也比较长 不知道怎么解决!

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top