SimpliciTI协议栈移植
时间:10-02
整理:3721RD
点击:
移植到ST单片机上运行,射频芯片为CC1101
目前调试一直不能通信,代码用的是ST官方。接收中断根本进不去,节点也不能入网
目前调试一直不能通信,代码用的是ST官方。接收中断根本进不去,节点也不能入网
上代码
- int main (void)
- {
- bspIState_t intState;
- smplStatus_t smplSta = SMPL_NO_LINK;
-
- BSP_Init(); //初始化外围接口
- disableInterrupts();
- smplSta = SMPL_Init(sCB);//初始化协议栈
- /* green and red LEDs on solid to indicate waiting for a Join. */
- if (!BSP_LED1_IS_ON())
- {
- toggleLED(1);
- }
- Send_String(" AP Device Start!!\r\n");
- enableInterrupts();
- /* main work loop */
- while (1)
- {
- /* Wait for the Join semaphore to be set by the receipt of a Join frame from a
- * device that supports an End Device.
- *
- * An external method could be used as well. A button press could be connected
- * to an ISR and the ISR could set a semaphore that is checked by a function
- * call here, or a command shell running in support of a serial connection
- * could set a semaphore that is checked by a function call.
- */
- if (sJoinSem && (sNumCurrentPeers < NUM_CONNECTIONS))//新设备入网
- {
- toggleLED(1);
- toggleLED(2);
- /* listen for a new connection */
- while (1)
- {
- if (SMPL_SUCCESS == SMPL_LinkListen(&sLID[sNumCurrentPeers]))//监听ED发起的连接
- {
- break;
- }
- /* Implement fail-to-link policy here. otherwise, listen again. */
- }
- sNumCurrentPeers++;
- BSP_ENTER_CRITICAL_SECTION(intState);//临界保护
- sJoinSem--;
- BSP_EXIT_CRITICAL_SECTION(intState);
- }
- /* Have we received a frame on one of the ED connections?
- * No critical section -- it doesn't really matter much if we miss a poll
- */
- if (sPeerFrameSem) //通信数据
- {
- uint8_t msg[MAX_APP_PAYLOAD], len, i;
- toggleLED(1);
- toggleLED(2);
- /* process all frames waiting */
- for (i=0; i<sNumCurrentPeers; ++i)//核对数据帧对应的LINKID
- {
- if (SMPL_SUCCESS == SMPL_Receive(sLID[i], msg, &len))//接收数据 sLID - LINK ID
- {
- processMessage(sLID[i], msg, len); //处理
- BSP_ENTER_CRITICAL_SECTION(intState);
- sPeerFrameSem--;
- BSP_EXIT_CRITICAL_SECTION(intState);
- }
- }
- }
- }
- }
只能一点点查外设的配置了
SPI GDOx IRQ 这些硬件
协议栈的功耗有点大,而且上电进行入网的过程是堵塞的时间也比较长 不知道怎么解决!