[讨论] SimpliciTI协议栈移植

donsbin   2016-3-17 15:58 楼主
移植到ST单片机上运行,射频芯片为CC1101~
目前调试一直不能通信,代码用的是ST官方。接收中断根本进不去,节点也不能入网~
千古情怀何寄!

回复评论 (3)

上代码

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

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

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

  66. }
千古情怀何寄!
点赞  2016-3-17 18:08
只能一点点查外设的配置了
SPI  GDOx IRQ 这些硬件
电工
点赞  2016-3-18 12:27
协议栈的功耗有点大,而且上电进行入网的过程是堵塞的~时间也比较长 不知道怎么解决!
千古情怀何寄!
点赞  2016-3-22 20:50
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复