
MC1322x SMAC Software Architecture
MC1322x SMAC Reference Manual, Rev. 1.7
Freescale Semiconductor
2-9
{
...
/* Initiate the TX message */
MSG_INIT(a_TX_msg, &dataTX, NULL);
a_TX_msg.u8BufSize = TX_SIZE;
/* Initiate the RX message */
MSG_INIT(a_RX_msg, &dataRX, a_simple_rx_callback_fn);
a_RX_msg.u8BufSize = RX_SIZE;
...
/* Initiate Radio transceiver */
MLMERadioInit();
...
for(;;)
{
/* Process messages in the queue */
process_radio_msg();
...
/* Put in the queue a message to be transmitted */
if([Need to transmit a message]){
MCPSDataRequest(&a_TX_msg);
}
...
if([Need to receive a message]){
/* Put in the queue an RX message to put the transceiver in reception */
MLMERXEnableRequest(&a_RX_msg, TIME_OUT);
}
...
}
}
The following code snippets examples can be used for application development:
Validates if a TX message is complete:
((MSG_[Type of message]_ACTION_COMPLETE_SUCCESS == [message name].u8Status.msg_state) ||
(MSG_[Type of message]_ACTION_COMPLETE_FAIL == [message name].u8Status.msg_state))
This macro obtains the message type:
get_pmsg_type([pointer to the message])
This macro reads a message state:
get_pmsg_state([pointer to the message])
This macro reads a message buffer:
tx_pmsg_payload_buffer([Pointer to the message], [Position in the buffer])
This macro sets a message size:
set_pmsg_size([Pointer to the message], [Size in bytes])