码迷,mamicode.com
首页 > 其他好文 > 详细

ZigBee学习三 UART通信

时间:2017-01-26 15:42:49      阅读:315      评论:0      收藏:0      [点我收藏+]

标签:oca   hand   sig   esc   latency   this   events   make   char   

ZigBee学习三 UART通信

本实验只对coordinator.c文件进行改动就可以实现串口的收发。

修改coordinator.c文件

 

byte GenericApp_TransID; // This is the unique message ID (counter)

afAddrType_t GenericApp_DstAddr;

unsigned char uartbuf[128];
/*********************************************************************
* LOCAL FUNCTIONS
*/
static void GenericApp_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg );
static void GenericApp_HandleKeys( byte shift, byte keys );
static void GenericApp_MessageMSGCB( afIncomingMSGPacket_t *pckt );
static void GenericApp_SendTheMessage( void );

static void rxCB(uint8 port,uint8 event);

 

void GenericApp_Init( uint8 task_id )
{
  halUARTCfg_t uartConfig;
  GenericApp_TaskID = task_id;
  GenericApp_NwkState = DEV_INIT;
  GenericApp_TransID = 0;

  ... ...

  GenericApp_epDesc.simpleDesc= (SimpleDescriptionFormat_t *)&GenericApp_SimpleDesc;
  GenericApp_epDesc.latencyReq = noLatencyReqs;

  afRegister( &GenericApp_epDesc );

  uartConfig.configured   = TRUE;
  uartConfig.baudRate    = HAL_UART_BR_115200;
  uartConfig.flowControl    = FALSE;
  uartConfig.callBackFunc  = rxCB;

  //对串口进行初始化
  HalUARTOpen(0,&uartConfig);  //该函数将halUARTCfg_t类型的结构体变量作为参数,而halUARTCfg_t结构体变量包含了串口初始化相关的参数。

 

}

 

uint16 GenericApp_ProcessEvent( uint8 task_id, uint16 events )
{

  ... ...

}

static void rxCB(uint8 port,uint8 event)
{
  HalUARTRead(0,uartbuf,16);
  if(osal_memcmp(uartbuf,"www.wlwmaker.com",16))
  {
    HalUARTWrite(0,uartbuf,16);
  }
}

ZigBee学习三 UART通信

标签:oca   hand   sig   esc   latency   this   events   make   char   

原文地址:http://www.cnblogs.com/liushao/p/6351635.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!