65 #if defined( __GNUC__ )
67 #include <util/delay.h>
82 #include "sicslowmac.h"
89 #ifndef AUTO_CRC_PADDING
90 #define AUTO_CRC_PADDING 0
100 static uint8_t tx_frame_buffer[130];
126 memset(&flen, 0,
sizeof(field_length_t));
130 flen.dest_pid_len = 2;
133 flen.src_pid_len = 2;
141 flen.src_pid_len = 0;
146 flen.dest_addr_len = 2;
149 flen.dest_addr_len = 8;
156 flen.src_addr_len = 2;
159 flen.src_addr_len = 8;
168 flen.aux_sec_len = 5;
171 flen.aux_sec_len = 6;
174 flen.aux_sec_len = 10;
177 flen.aux_sec_len = 14;
188 tx_frame_buffer[index++] = p->
seq;
190 if (flen.dest_pid_len == 2){
191 *(uint16_t *)&tx_frame_buffer[index] = p->
dest_pid;
195 switch (flen.dest_addr_len){
209 if (flen.src_pid_len == 2){
210 *(uint16_t *)&tx_frame_buffer[index] = p->
src_pid;
214 switch (flen.src_addr_len){
228 if (flen.aux_sec_len){
229 memcpy((
char *)&tx_frame_buffer[index],
232 index += flen.aux_sec_len;
235 memcpy((
char *)&tx_frame_buffer[index],
241 frame_result->
length = index + AUTO_CRC_PADDING;
242 frame_result->
frame = tx_frame_buffer;
259 uint8_t *p = rx_frame->
data;
261 static uint8_t frame_dropped = 0;
267 if (!frame_dropped) {
268 event_object_t event;
269 event.event = MAC_EVENT_DROPPED;
279 pf->fcf = (
fcf_t *)p;
285 pf->payload_length = 0;
291 pf->dest_pid = (uint16_t *)p;
297 pf->dest_addr = (
addr_t *)p;
310 pf->src_pid = (uint16_t *)p;
313 pf->src_pid = pf->dest_pid;
316 pf->src_addr = (
addr_t *)p;
326 pf->payload_length = rx_frame->
length - (p - (uint8_t*)&rx_frame->
data) - 2;
331 pf->lqi = rx_frame->
lqi;
332 pf->fcs = rx_frame->
crc;
335 event_object_t event;
336 event.event = MAC_EVENT_RX;
337 event.data = (uint8_t*)pf;