30 #define RADIO_MAX_PACKET_SIZE (RADIO_QUEUE_PAYLOAD_SIZE)
32 #define RADIO_QUEUE_PACKET_LENGTH_OFFSET 0
52 #define RX_PACKET_COUNT 3
53 static volatile uint8 XDATA radioQueueRxPacket[RX_PACKET_COUNT][1 + RADIO_MAX_PACKET_SIZE + 2];
54 static volatile uint8 DATA radioQueueRxMainLoopIndex = 0;
55 static volatile uint8 DATA radioQueueRxInterruptIndex = 0;
58 #define TX_PACKET_COUNT 16
59 static volatile uint8 XDATA radioQueueTxPacket[TX_PACKET_COUNT][1 + RADIO_MAX_PACKET_SIZE];
60 static volatile uint8 DATA radioQueueTxMainLoopIndex = 0;
61 static volatile uint8 DATA radioQueueTxInterruptIndex = 0;
71 PKTLEN = RADIO_MAX_PACKET_SIZE;
80 static uint8 randomTxDelay()
90 return (radioQueueTxInterruptIndex - radioQueueTxMainLoopIndex - 1) & (TX_PACKET_COUNT - 1);
95 return (radioQueueTxMainLoopIndex - radioQueueTxInterruptIndex) & (TX_PACKET_COUNT - 1);
105 return radioQueueTxPacket[radioQueueTxMainLoopIndex];
111 if (radioQueueTxMainLoopIndex == TX_PACKET_COUNT - 1)
113 radioQueueTxMainLoopIndex = 0;
117 radioQueueTxMainLoopIndex++;
129 if (radioQueueRxMainLoopIndex == radioQueueRxInterruptIndex)
133 return radioQueueRxPacket[radioQueueRxMainLoopIndex];
138 if (radioQueueRxMainLoopIndex == RX_PACKET_COUNT - 1)
140 radioQueueRxMainLoopIndex = 0;
144 radioQueueRxMainLoopIndex++;
150 static void takeInitiative()
152 if (radioQueueTxInterruptIndex != radioQueueTxMainLoopIndex)
155 radioMacTx(radioQueueTxPacket[radioQueueTxInterruptIndex]);
159 radioMacRx(radioQueueRxPacket[radioQueueRxInterruptIndex], 0);
173 if (radioQueueTxInterruptIndex == TX_PACKET_COUNT - 1)
175 radioQueueTxInterruptIndex = 0;
179 radioQueueTxInterruptIndex++;
183 radioMacRx(radioQueueRxPacket[radioQueueRxInterruptIndex], randomTxDelay());
188 uint8 XDATA * currentRxPacket = radioQueueRxPacket[radioQueueRxInterruptIndex];
192 if (radioQueueTxInterruptIndex != radioQueueTxMainLoopIndex)
203 if (currentRxPacket[RADIO_QUEUE_PACKET_LENGTH_OFFSET] > 0)
207 uint8 nextradioQueueRxInterruptIndex;
210 if (radioQueueRxInterruptIndex == RX_PACKET_COUNT - 1)
212 nextradioQueueRxInterruptIndex = 0;
216 nextradioQueueRxInterruptIndex = radioQueueRxInterruptIndex + 1;
219 if (nextradioQueueRxInterruptIndex != radioQueueRxMainLoopIndex)
222 radioQueueRxInterruptIndex = nextradioQueueRxInterruptIndex;
void radioMacStrobe(void)
BIT radioQueueAllowCrcErrors
void radioMacTx(uint8 XDATA *packet)
#define RADIO_MAC_EVENT_RX
uint8 XDATA * radioQueueRxCurrentPacket(void)
#define RADIO_MAC_EVENT_STROBE
#define RADIO_MAC_EVENT_RX_TIMEOUT
void radioMacEventHandler(uint8 event)
uint8 XDATA * radioQueueTxCurrentPacket(void)
void radioMacRx(uint8 XDATA *packet, uint8 timeout)
void randomSeedFromSerialNumber(void)
#define RADIO_MAC_EVENT_TX
int32 CODE param_radio_channel
void radioQueueTxSendPacket(void)
uint8 radioQueueTxQueued(void)
uint8 radioQueueTxAvailable(void)
void radioQueueInit(void)
void radioQueueRxDoneWithPacket(void)