
MC1322x SMAC Software Architecture
MC1322x SMAC Reference Manual, Rev. 1.7
2-8
Freescale Semiconductor
u8BufSize
Depending on the type of message this field means: the length of the buffer to be
transmitted; the maximum bytes to receive, at the end of the reception this field
stores the number of bytes received; the channel where the ED must be assessed.
cbDataIndication
A pointer to the function that will be called when a message is completed, it can
be NULL
Usage
This data type is used by an application as follows:
1. The application declares as many message_t global variables as messages are required. For
example, the application can declare one for TX and one for RX
2. The application creates one data buffer for each message using the smac_pdu_size macro; for
example if the TX message will have 18 bytes of data the buffer would be declared as uint8_t
data[smac_pdu_size(18)];
3. The application initiates the message using the MSG_INIT macro. This macro is used as follow:
MSG_INIT([the message], [pointer to the data buffer], [callback pointer]); MSG_INIT is defined
in RadioManagement.h as:
#define MSG_INIT(msg, buff, cb) \
do { \
msg.pu8Buffer = (smac_pdu_t *)(buff); \
msg.cbDataIndication = cb; \
} while(0)
4. The application initializes the system, including the radio - MLMERadioInit() -.
5. The application requests a message transmission using the MCPSDataRequest function, or a
reception message using MLMERXEnableRequest function.
6. The application must call the process_radio_msg function periodically to process the messages.
Sample code is shown in the following section.
2.6
Generic Application Code Example
This section provides a sample generic application code snippet. For details about a specific function see
Chapter 3, MC1322x SMAC Primitives
.
void a_simple_rx_callback_fn (void)
{
...
}
...
message_t a_TX_msg;
message_t a_RX_msg;
...
uint8_t dataTX[smac_pdu_size(TX SIZE)];
uint8_t dataRX[smac_pdu_size(RX SIZE)];
...
uint8_t main()