The example shows, how a frame is transmitted in TX_ARET mode. Within this mode, CCA is done automatically. Additionally the example illustrates, how the fram data can be directly manipulated in the SRAM (see IRQ service routine).
#include "board.h"
#include "transceiver.h"
#include "ioutil.h"
#include "xmpl.h"
static volatile bool tx_in_progress;
static volatile uint8_t tx_cnt, fail_cnt;
#define SEQ_OFFSET (2)
#define TX_FAIL_OFFSET (7)
#define TX_SRAM_OFFSET (1)
int main(void)
{
uint8_t txfrm[] = {0x21,0x08,
42,
(PANID & 0xff), (PANID >> 8),
(SHORT_ADDR & 0xff), (SHORT_ADDR >> 8),
42,
'h','e','l','l','o',' ','u','r','a','c','o','l','i','!',
'X','X'
};
ERR_CHECK(TRX_OFF!=rval);
#if defined(TRX_IRQ_TRX_END)
#elif defined(TRX_IRQ_TX_END)
#else
# error "Unknown IRQ bits"
#endif
tx_cnt = 0;
tx_in_progress = false;
while(1)
{
WAIT500MS();
if (tx_in_progress == false)
{
txfrm[SEQ_OFFSET] = tx_cnt;
txfrm[TX_FAIL_OFFSET] = fail_cnt;
tx_in_progress = true;
}
}
}
#if defined(TRX_IF_RFA1)
ISR(TRX24_TX_END_vect)
{
tx_in_progress = false;
if (trac_status != TRAC_SUCCESS)
{
fail_cnt++;
}
else
{
tx_cnt ++;
}
}
#else
ISR(TRX_IRQ_vect)
{
if (irq_cause & TRX_IRQ_TRX_END)
{
tx_in_progress = false;
if (trac_status != TRAC_SUCCESS)
{
fail_cnt++;
}
else
{
tx_cnt ++;
}
}
}
#endif