1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Fix coding conventions in sys/transceiver/transceiver.c

This commit is contained in:
Martin Lenders 2014-01-31 14:36:09 +01:00 committed by Martin Lenders
parent 049838841a
commit 1e4badf85a

View File

@ -86,10 +86,10 @@ static volatile uint8_t rx_buffer_pos = 0;
static volatile uint8_t transceiver_buffer_pos = 0; static volatile uint8_t transceiver_buffer_pos = 0;
#ifdef MODULE_CC110X #ifdef MODULE_CC110X
void *cc1100_payload; void *cc1100_payload;
int cc1100_payload_size; int cc1100_payload_size;
packet_info_t *cc1100_packet_info; packet_info_t *cc1100_packet_info;
uint8_t cc1100_pkt[CC1100_MAX_DATA_LENGTH]; uint8_t cc1100_pkt[CC1100_MAX_DATA_LENGTH];
#endif #endif
@ -158,6 +158,7 @@ void transceiver_init(transceiver_type_t t)
reg[i].transceivers = TRANSCEIVER_NONE; reg[i].transceivers = TRANSCEIVER_NONE;
reg[i].pid = 0; reg[i].pid = 0;
} }
/* check if a non defined bit is set */ /* check if a non defined bit is set */
if (t & ~(TRANSCEIVER_CC1100 | TRANSCEIVER_CC2420 | TRANSCEIVER_MC1322X | TRANSCEIVER_NATIVE | TRANSCEIVER_AT86RF231)) { if (t & ~(TRANSCEIVER_CC1100 | TRANSCEIVER_CC2420 | TRANSCEIVER_MC1322X | TRANSCEIVER_NATIVE | TRANSCEIVER_AT86RF231)) {
puts("Invalid transceiver type"); puts("Invalid transceiver type");
@ -175,11 +176,13 @@ int transceiver_start(void)
if (transceiver_pid < 0) { if (transceiver_pid < 0) {
puts("Error creating transceiver thread"); puts("Error creating transceiver thread");
} }
#ifdef MODULE_CC110X_NG #ifdef MODULE_CC110X_NG
else if (transceivers & TRANSCEIVER_CC1100) { else if (transceivers & TRANSCEIVER_CC1100) {
DEBUG("transceiver: Transceiver started for CC1100\n"); DEBUG("transceiver: Transceiver started for CC1100\n");
cc110x_init(transceiver_pid); cc110x_init(transceiver_pid);
} }
#endif #endif
#ifdef MODULE_CC110X #ifdef MODULE_CC110X
else if (transceivers & TRANSCEIVER_CC1100) { else if (transceivers & TRANSCEIVER_CC1100) {
@ -187,28 +190,33 @@ int transceiver_start(void)
cc1100_init(); cc1100_init();
cc1100_set_packet_monitor(cc1100_packet_monitor); cc1100_set_packet_monitor(cc1100_packet_monitor);
} }
#endif #endif
#ifdef MODULE_CC2420 #ifdef MODULE_CC2420
else if(transceivers & TRANSCEIVER_CC2420) { else if (transceivers & TRANSCEIVER_CC2420) {
DEBUG("transceiver: Transceiver started for CC2420\n"); DEBUG("transceiver: Transceiver started for CC2420\n");
cc2420_init(transceiver_pid); cc2420_init(transceiver_pid);
} }
#endif #endif
#ifdef MODULE_AT86RF231 #ifdef MODULE_AT86RF231
else if(transceivers & TRANSCEIVER_AT86RF231) { else if (transceivers & TRANSCEIVER_AT86RF231) {
DEBUG("transceiver: Transceiver started for AT86RF231\n"); DEBUG("transceiver: Transceiver started for AT86RF231\n");
at86rf231_init(transceiver_pid); at86rf231_init(transceiver_pid);
} }
#endif #endif
#ifdef MODULE_MC1322X #ifdef MODULE_MC1322X
else if (transceivers & TRANSCEIVER_MC1322X) { else if (transceivers & TRANSCEIVER_MC1322X) {
maca_init(); maca_init();
} }
#endif #endif
#ifdef MODULE_NATIVENET #ifdef MODULE_NATIVENET
else if (transceivers & TRANSCEIVER_NATIVE) { else if (transceivers & TRANSCEIVER_NATIVE) {
nativenet_init(transceiver_pid); nativenet_init(transceiver_pid);
} }
#endif #endif
return transceiver_pid; return transceiver_pid;
} }
@ -220,8 +228,8 @@ uint8_t transceiver_register(transceiver_type_t t, int pid)
/* find pid in registered threads or first unused space */ /* find pid in registered threads or first unused space */
for (i = 0; ((i < TRANSCEIVER_MAX_REGISTERED) && for (i = 0; ((i < TRANSCEIVER_MAX_REGISTERED) &&
(reg[i].pid != pid) && (reg[i].pid != pid) &&
(reg[i].transceivers != TRANSCEIVER_NONE)); i++); (reg[i].transceivers != TRANSCEIVER_NONE)); i++);
if (i >= TRANSCEIVER_MAX_REGISTERED) { if (i >= TRANSCEIVER_MAX_REGISTERED) {
return ENOMEM; return ENOMEM;
@ -256,7 +264,7 @@ void run(void)
cmd = (transceiver_command_t *) m.content.ptr; cmd = (transceiver_command_t *) m.content.ptr;
DEBUG("transceiver: Transceiver: Message received, type: %02X\n", m.type); DEBUG("transceiver: Transceiver: Message received, type: %02X\n", m.type);
switch(m.type) { switch (m.type) {
case RCV_PKT_CC1020: case RCV_PKT_CC1020:
case RCV_PKT_CC1100: case RCV_PKT_CC1100:
case RCV_PKT_CC2420: case RCV_PKT_CC2420:
@ -265,6 +273,7 @@ void run(void)
case RCV_PKT_AT86RF231: case RCV_PKT_AT86RF231:
receive_packet(m.type, m.content.value); receive_packet(m.type, m.content.value);
break; break;
case SND_PKT: case SND_PKT:
response = send_packet(cmd->transceivers, cmd->data); response = send_packet(cmd->transceivers, cmd->data);
m.content.value = response; m.content.value = response;
@ -302,17 +311,20 @@ void run(void)
case SWITCH_RX: case SWITCH_RX:
switch_to_rx(cmd->transceivers); switch_to_rx(cmd->transceivers);
break; break;
case GET_PAN: case GET_PAN:
*((int32_t *) cmd->data) = get_pan(cmd->transceivers); *((int32_t *) cmd->data) = get_pan(cmd->transceivers);
msg_reply(&m, &m); msg_reply(&m, &m);
break; break;
case SET_PAN: case SET_PAN:
*((int32_t *) cmd->data) = set_pan(cmd->transceivers, cmd->data); *((int32_t *) cmd->data) = set_pan(cmd->transceivers, cmd->data);
msg_reply(&m, &m); msg_reply(&m, &m);
break; break;
#ifdef DBG_IGNORE #ifdef DBG_IGNORE
case DBG_IGN: case DBG_IGN:
*((int16_t*) cmd->data) = ignore_add(cmd->transceivers, cmd->data); *((int16_t *) cmd->data) = ignore_add(cmd->transceivers, cmd->data);
msg_reply(&m, &m); msg_reply(&m, &m);
break; break;
#endif #endif
@ -341,7 +353,7 @@ static void receive_packet(uint16_t type, uint8_t pos)
DEBUG("Packet received\n"); DEBUG("Packet received\n");
switch(type) { switch (type) {
case RCV_PKT_CC1020: case RCV_PKT_CC1020:
t = TRANSCEIVER_CC1020; t = TRANSCEIVER_CC1020;
break; break;
@ -349,18 +361,23 @@ static void receive_packet(uint16_t type, uint8_t pos)
case RCV_PKT_CC1100: case RCV_PKT_CC1100:
t = TRANSCEIVER_CC1100; t = TRANSCEIVER_CC1100;
break; break;
case RCV_PKT_CC2420: case RCV_PKT_CC2420:
t = TRANSCEIVER_CC2420; t = TRANSCEIVER_CC2420;
break; break;
case RCV_PKT_MC1322X: case RCV_PKT_MC1322X:
t = TRANSCEIVER_MC1322X; t = TRANSCEIVER_MC1322X;
break; break;
case RCV_PKT_NATIVE:
t = TRANSCEIVER_NATIVE; case RCV_PKT_NATIVE:
break; t = TRANSCEIVER_NATIVE;
break;
case RCV_PKT_AT86RF231: case RCV_PKT_AT86RF231:
t = TRANSCEIVER_AT86RF231; t = TRANSCEIVER_AT86RF231;
break; break;
default: default:
t = TRANSCEIVER_NONE; t = TRANSCEIVER_NONE;
break; break;
@ -427,14 +444,18 @@ static void receive_packet(uint16_t type, uint8_t pos)
puts("Invalid transceiver type"); puts("Invalid transceiver type");
return; return;
} }
#ifdef DBG_IGNORE #ifdef DBG_IGNORE
for (uint8_t i = 0; (i < MAX_IGNORED_ADDR) && (ignored_addr[i]); i++) { for (uint8_t i = 0; (i < MAX_IGNORED_ADDR) && (ignored_addr[i]); i++) {
DEBUG("check if source (%u) is ignored -> %u\n", trans_p->src, ignored_addr[i]); DEBUG("check if source (%u) is ignored -> %u\n", trans_p->src, ignored_addr[i]);
if (trans_p->src == ignored_addr[i]) { if (trans_p->src == ignored_addr[i]) {
DEBUG("ignored packet from %" PRIu16 "\n", trans_p->src); DEBUG("ignored packet from %" PRIu16 "\n", trans_p->src);
return; return;
} }
} }
#endif #endif
} }
@ -444,7 +465,7 @@ static void receive_packet(uint16_t type, uint8_t pos)
while (reg[i].transceivers != TRANSCEIVER_NONE) { while (reg[i].transceivers != TRANSCEIVER_NONE) {
if (reg[i].transceivers & t) { if (reg[i].transceivers & t) {
m.content.ptr = (char *) & (transceiver_buffer[transceiver_buffer_pos]); m.content.ptr = (char *) &(transceiver_buffer[transceiver_buffer_pos]);
DEBUG("transceiver: Notify thread %i\n", reg[i].pid); DEBUG("transceiver: Notify thread %i\n", reg[i].pid);
if (msg_send(&m, reg[i].pid, false) && (m.type != ENOBUFFER)) { if (msg_send(&m, reg[i].pid, false) && (m.type != ENOBUFFER)) {
@ -474,10 +495,10 @@ static void receive_cc110x_packet(radio_packet_t *trans_p)
trans_p->rssi = cc110x_rx_buffer[rx_buffer_pos].rssi; trans_p->rssi = cc110x_rx_buffer[rx_buffer_pos].rssi;
trans_p->lqi = cc110x_rx_buffer[rx_buffer_pos].lqi; trans_p->lqi = cc110x_rx_buffer[rx_buffer_pos].lqi;
trans_p->length = p.length - CC1100_HEADER_LENGTH; trans_p->length = p.length - CC1100_HEADER_LENGTH;
memcpy((void *)&(data_buffer[transceiver_buffer_pos * PAYLOAD_SIZE]), p.data, CC1100_MAX_DATA_LENGTH); memcpy((void *) &(data_buffer[transceiver_buffer_pos * PAYLOAD_SIZE]), p.data, CC1100_MAX_DATA_LENGTH);
eINT(); eINT();
trans_p->data = (uint8_t *)&(data_buffer[transceiver_buffer_pos * CC1100_MAX_DATA_LENGTH]); trans_p->data = (uint8_t *) &(data_buffer[transceiver_buffer_pos * CC1100_MAX_DATA_LENGTH]);
DEBUG("transceiver: Packet %p (%p) was from %hu to %hu, size: %u\n", trans_p, trans_p->data, trans_p->src, trans_p->dst, trans_p->length); DEBUG("transceiver: Packet %p (%p) was from %hu to %hu, size: %u\n", trans_p, trans_p->data, trans_p->src, trans_p->dst, trans_p->length);
} }
#endif #endif
@ -491,16 +512,17 @@ void receive_cc1100_packet(radio_packet_t *trans_p)
trans_p->rssi = cc1100_packet_info->rssi; trans_p->rssi = cc1100_packet_info->rssi;
trans_p->lqi = cc1100_packet_info->lqi; trans_p->lqi = cc1100_packet_info->lqi;
trans_p->length = cc1100_payload_size; trans_p->length = cc1100_payload_size;
memcpy((void *)&(data_buffer[transceiver_buffer_pos * PAYLOAD_SIZE]), cc1100_payload, CC1100_MAX_DATA_LENGTH); memcpy((void *) &(data_buffer[transceiver_buffer_pos * PAYLOAD_SIZE]), cc1100_payload, CC1100_MAX_DATA_LENGTH);
eINT(); eINT();
trans_p->data = (uint8_t *)&(data_buffer[transceiver_buffer_pos * CC1100_MAX_DATA_LENGTH]); trans_p->data = (uint8_t *) &(data_buffer[transceiver_buffer_pos * CC1100_MAX_DATA_LENGTH]);
} }
#endif #endif
#ifdef MODULE_CC2420 #ifdef MODULE_CC2420
void receive_cc2420_packet(radio_packet_t *trans_p) { void receive_cc2420_packet(radio_packet_t *trans_p)
{
DEBUG("transceiver: Handling CC2420 packet\n"); DEBUG("transceiver: Handling CC2420 packet\n");
dINT(); dINT();
cc2420_packet_t p = cc2420_rx_buffer[rx_buffer_pos]; cc2420_packet_t p = cc2420_rx_buffer[rx_buffer_pos];
@ -519,23 +541,25 @@ void receive_cc2420_packet(radio_packet_t *trans_p) {
#endif #endif
#ifdef MODULE_MC1322X #ifdef MODULE_MC1322X
void receive_mc1322x_packet(radio_packet_t *trans_p) { void receive_mc1322x_packet(radio_packet_t *trans_p)
maca_packet_t* maca_pkt; {
maca_packet_t *maca_pkt;
dINT(); dINT();
maca_pkt = maca_get_rx_packet (); maca_pkt = maca_get_rx_packet();
trans_p->lqi = maca_pkt->lqi; trans_p->lqi = maca_pkt->lqi;
trans_p->length = maca_pkt->length; trans_p->length = maca_pkt->length;
memcpy((void*) &(data_buffer[transceiver_buffer_pos * PAYLOAD_SIZE]), maca_pkt->data, MACA_MAX_PAYLOAD_SIZE); memcpy((void *) &(data_buffer[transceiver_buffer_pos * PAYLOAD_SIZE]), maca_pkt->data, MACA_MAX_PAYLOAD_SIZE);
maca_free_packet( maca_pkt ); maca_free_packet(maca_pkt);
eINT(); eINT();
trans_p->data = (uint8_t*) &(data_buffer[transceiver_buffer_pos * MACA_MAX_PAYLOAD_SIZE]); trans_p->data = (uint8_t *) &(data_buffer[transceiver_buffer_pos * MACA_MAX_PAYLOAD_SIZE]);
} }
#endif #endif
#ifdef MODULE_NATIVENET #ifdef MODULE_NATIVENET
void receive_nativenet_packet(radio_packet_t *trans_p) { void receive_nativenet_packet(radio_packet_t *trans_p)
{
unsigned state; unsigned state;
radio_packet_t *p = &_nativenet_rx_buffer[rx_buffer_pos].packet; radio_packet_t *p = &_nativenet_rx_buffer[rx_buffer_pos].packet;
@ -546,7 +570,7 @@ void receive_nativenet_packet(radio_packet_t *trans_p) {
memcpy(trans_p, p, sizeof(radio_packet_t)); memcpy(trans_p, p, sizeof(radio_packet_t));
memcpy(&(data_buffer[transceiver_buffer_pos * PAYLOAD_SIZE]), p->data, p->length); memcpy(&(data_buffer[transceiver_buffer_pos * PAYLOAD_SIZE]), p->data, p->length);
trans_p->data = (uint8_t*) &(data_buffer[transceiver_buffer_pos * PAYLOAD_SIZE]); trans_p->data = (uint8_t *) &(data_buffer[transceiver_buffer_pos * PAYLOAD_SIZE]);
DEBUG("Packet %p was from %" PRIu16 " to %" PRIu16 ", size: %" PRIu8 "\n", trans_p, trans_p->src, trans_p->dst, trans_p->length); DEBUG("Packet %p was from %" PRIu16 " to %" PRIu16 ", size: %" PRIu8 "\n", trans_p, trans_p->src, trans_p->dst, trans_p->length);
@ -556,7 +580,8 @@ void receive_nativenet_packet(radio_packet_t *trans_p) {
#endif #endif
#ifdef MODULE_AT86RF231 #ifdef MODULE_AT86RF231
void receive_at86rf231_packet(radio_packet_t *trans_p) { void receive_at86rf231_packet(radio_packet_t *trans_p)
{
DEBUG("Handling AT86RF231 packet\n"); DEBUG("Handling AT86RF231 packet\n");
dINT(); dINT();
at86rf231_packet_t p = at86rf231_rx_buffer[rx_buffer_pos]; at86rf231_packet_t p = at86rf231_rx_buffer[rx_buffer_pos];
@ -591,7 +616,7 @@ static int8_t send_packet(transceiver_type_t t, void *pkt)
cc110x_packet_t cc110x_pkt; cc110x_packet_t cc110x_pkt;
#endif #endif
#ifdef MODULE_MC1322X #ifdef MODULE_MC1322X
maca_packet_t* maca_pkt = maca_get_free_packet(); maca_packet_t *maca_pkt = maca_get_free_packet();
#endif #endif
#ifdef MODULE_CC2420 #ifdef MODULE_CC2420
@ -603,6 +628,7 @@ static int8_t send_packet(transceiver_type_t t, void *pkt)
#endif #endif
DEBUG("transceiver: Send packet to %" PRIu16 "\n", p.dst); DEBUG("transceiver: Send packet to %" PRIu16 "\n", p.dst);
switch (t) { switch (t) {
case TRANSCEIVER_CC1100: case TRANSCEIVER_CC1100:
#ifdef MODULE_CC110X_NG #ifdef MODULE_CC110X_NG
@ -621,6 +647,7 @@ static int8_t send_packet(transceiver_type_t t, void *pkt)
#endif #endif
break; break;
#ifdef MODULE_CC2420 #ifdef MODULE_CC2420
case TRANSCEIVER_CC2420: case TRANSCEIVER_CC2420:
cc2420_pkt.frame.payload_len = p.length; cc2420_pkt.frame.payload_len = p.length;
cc2420_pkt.frame.dest_addr[1] = (uint8_t)(p.dst >> 8); cc2420_pkt.frame.dest_addr[1] = (uint8_t)(p.dst >> 8);
@ -640,7 +667,7 @@ static int8_t send_packet(transceiver_type_t t, void *pkt)
case TRANSCEIVER_MC1322X: case TRANSCEIVER_MC1322X:
maca_pkt->length = p.length; maca_pkt->length = p.length;
memcpy(maca_pkt->data, p.data, p.length); memcpy(maca_pkt->data, p.data, p.length);
maca_set_tx_packet( maca_pkt ); maca_set_tx_packet(maca_pkt);
res = 1; res = 1;
break; break;
#endif #endif
@ -665,6 +692,7 @@ static int8_t send_packet(transceiver_type_t t, void *pkt)
res = at86rf231_send(&at86rf231_pkt); res = at86rf231_send(&at86rf231_pkt);
break; break;
#endif #endif
default: default:
puts("Unknown transceiver"); puts("Unknown transceiver");
break; break;
@ -686,7 +714,7 @@ static int32_t set_channel(transceiver_type_t t, void *channel)
{ {
uint8_t c = *((uint8_t *)channel); uint8_t c = *((uint8_t *)channel);
switch(t) { switch (t) {
case TRANSCEIVER_CC1100: case TRANSCEIVER_CC1100:
#ifdef MODULE_CC110X_NG #ifdef MODULE_CC110X_NG
return cc110x_set_channel(c); return cc110x_set_channel(c);
@ -696,22 +724,27 @@ static int32_t set_channel(transceiver_type_t t, void *channel)
return -1; return -1;
#endif #endif
#ifdef MODULE_CC2420 #ifdef MODULE_CC2420
case TRANSCEIVER_CC2420: case TRANSCEIVER_CC2420:
return cc2420_set_channel(c); return cc2420_set_channel(c);
#endif #endif
#ifdef MODULE_MC1322X #ifdef MODULE_MC1322X
case TRANSCEIVER_MC1322X: case TRANSCEIVER_MC1322X:
maca_set_channel(c); maca_set_channel(c);
return c; ///< TODO: should be changed! implement get channel return c; ///< TODO: should be changed!implement get channel
#endif #endif
#ifdef MODULE_NATIVENET #ifdef MODULE_NATIVENET
case TRANSCEIVER_NATIVE: case TRANSCEIVER_NATIVE:
return nativenet_set_channel(c); return nativenet_set_channel(c);
#endif #endif
#ifdef MODULE_AT86RF231 #ifdef MODULE_AT86RF231
case TRANSCEIVER_AT86RF231: case TRANSCEIVER_AT86RF231:
return at86rf231_set_channel(c); return at86rf231_set_channel(c);
#endif #endif
default: default:
return -1; return -1;
} }
@ -726,7 +759,7 @@ static int32_t set_channel(transceiver_type_t t, void *channel)
*/ */
static int32_t get_channel(transceiver_type_t t) static int32_t get_channel(transceiver_type_t t)
{ {
switch(t) { switch (t) {
case TRANSCEIVER_CC1100: case TRANSCEIVER_CC1100:
#ifdef MODULE_CC110X_NG #ifdef MODULE_CC110X_NG
return cc110x_get_channel(); return cc110x_get_channel();
@ -736,22 +769,27 @@ static int32_t get_channel(transceiver_type_t t)
return -1; return -1;
#endif #endif
#ifdef MODULE_CC2420 #ifdef MODULE_CC2420
case TRANSCEIVER_CC2420: case TRANSCEIVER_CC2420:
return cc2420_get_channel(); return cc2420_get_channel();
#endif #endif
#ifdef MODULE_MC1322X #ifdef MODULE_MC1322X
case TRANSCEIVER_MC1322X: case TRANSCEIVER_MC1322X:
///< TODO:implement return maca_get_channel(); ///< TODO:implement return maca_get_channel();
return -1; return -1;
#endif #endif
#ifdef MODULE_NATIVENET #ifdef MODULE_NATIVENET
case TRANSCEIVER_NATIVE: case TRANSCEIVER_NATIVE:
return nativenet_get_channel(); return nativenet_get_channel();
#endif #endif
#ifdef MODULE_AT86RF231 #ifdef MODULE_AT86RF231
case TRANSCEIVER_AT86RF231: case TRANSCEIVER_AT86RF231:
return at86rf231_get_channel(); return at86rf231_get_channel();
#endif #endif
default: default:
return -1; return -1;
} }
@ -766,25 +804,32 @@ static int32_t get_channel(transceiver_type_t t)
* *
* @return The pan AFTER calling the set command, -1 on error * @return The pan AFTER calling the set command, -1 on error
*/ */
static int32_t set_pan(transceiver_type_t t, void *pan) { static int32_t set_pan(transceiver_type_t t, void *pan)
uint16_t c = *((uint16_t*) pan); {
uint16_t c = *((uint16_t *) pan);
switch (t) { switch (t) {
#ifdef MODULE_CC2420 #ifdef MODULE_CC2420
case TRANSCEIVER_CC2420: case TRANSCEIVER_CC2420:
return cc2420_set_pan(c); return cc2420_set_pan(c);
#endif #endif
#ifdef MODULE_NATIVENET #ifdef MODULE_NATIVENET
case TRANSCEIVER_NATIVE: case TRANSCEIVER_NATIVE:
return nativenet_set_pan(c); return nativenet_set_pan(c);
#endif #endif
#ifdef MODULE_AT86RF231 #ifdef MODULE_AT86RF231
case TRANSCEIVER_AT86RF231: case TRANSCEIVER_AT86RF231:
return at86rf231_set_pan(c); return at86rf231_set_pan(c);
#endif #endif
#ifdef MODULE_MC1322X #ifdef MODULE_MC1322X
case TRANSCEIVER_MC1322X: case TRANSCEIVER_MC1322X:
return maca_set_pan(c); return maca_set_pan(c);
#endif #endif
default: default:
/* get rid of compiler warning about unused variable */ /* get rid of compiler warning about unused variable */
(void) c; (void) c;
@ -799,24 +844,30 @@ static int32_t set_pan(transceiver_type_t t, void *pan) {
* *
* @return The current pan of the transceiver, -1 on error * @return The current pan of the transceiver, -1 on error
*/ */
static int32_t get_pan(transceiver_type_t t) { static int32_t get_pan(transceiver_type_t t)
{
switch (t) { switch (t) {
#ifdef MODULE_CC2420 #ifdef MODULE_CC2420
case TRANSCEIVER_CC2420: case TRANSCEIVER_CC2420:
return cc2420_get_pan(); return cc2420_get_pan();
#endif #endif
#ifdef MODULE_NATIVENET #ifdef MODULE_NATIVENET
case TRANSCEIVER_NATIVE: case TRANSCEIVER_NATIVE:
return nativenet_get_pan(); return nativenet_get_pan();
#endif #endif
#ifdef MODULE_AT86RF231 #ifdef MODULE_AT86RF231
case TRANSCEIVER_AT86RF231: case TRANSCEIVER_AT86RF231:
return at86rf231_get_pan(); return at86rf231_get_pan();
#endif #endif
#ifdef MODULE_MC1322X #ifdef MODULE_MC1322X
case TRANSCEIVER_MC1322X: case TRANSCEIVER_MC1322X:
return maca_get_pan(); return maca_get_pan();
#endif #endif
default: default:
return -1; return -1;
} }
@ -833,7 +884,7 @@ static int32_t get_pan(transceiver_type_t t) {
*/ */
static radio_address_t get_address(transceiver_type_t t) static radio_address_t get_address(transceiver_type_t t)
{ {
switch(t) { switch (t) {
case TRANSCEIVER_CC1100: case TRANSCEIVER_CC1100:
#ifdef MODULE_CC110X_NG #ifdef MODULE_CC110X_NG
return cc110x_get_address(); return cc110x_get_address();
@ -843,21 +894,26 @@ static radio_address_t get_address(transceiver_type_t t)
return 0; /* XXX see TODO above */ return 0; /* XXX see TODO above */
#endif #endif
#ifdef MODULE_CC2420 #ifdef MODULE_CC2420
case TRANSCEIVER_CC2420: case TRANSCEIVER_CC2420:
return cc2420_get_address(); return cc2420_get_address();
#endif #endif
#ifdef MODULE_MC1322X #ifdef MODULE_MC1322X
case TRANSCEIVER_MC1322X: case TRANSCEIVER_MC1322X:
return maca_get_address(); return maca_get_address();
#endif #endif
#ifdef MODULE_NATIVENET #ifdef MODULE_NATIVENET
case TRANSCEIVER_NATIVE: case TRANSCEIVER_NATIVE:
return nativenet_get_address(); return nativenet_get_address();
#endif #endif
#ifdef MODULE_AT86RF231 #ifdef MODULE_AT86RF231
case TRANSCEIVER_AT86RF231: case TRANSCEIVER_AT86RF231:
return at86rf231_get_address(); return at86rf231_get_address();
#endif #endif
default: default:
return 0; /* XXX see TODO above */ return 0; /* XXX see TODO above */
} }
@ -877,7 +933,7 @@ static radio_address_t set_address(transceiver_type_t t, void *address)
{ {
radio_address_t addr = *((radio_address_t *)address); radio_address_t addr = *((radio_address_t *)address);
switch(t) { switch (t) {
case TRANSCEIVER_CC1100: case TRANSCEIVER_CC1100:
#ifdef MODULE_CC110X_NG #ifdef MODULE_CC110X_NG
return cc110x_set_address(addr); return cc110x_set_address(addr);
@ -887,21 +943,26 @@ static radio_address_t set_address(transceiver_type_t t, void *address)
return 0; /* XXX see TODO above */ return 0; /* XXX see TODO above */
#endif #endif
#ifdef MODULE_CC2420 #ifdef MODULE_CC2420
case TRANSCEIVER_CC2420: case TRANSCEIVER_CC2420:
return cc2420_set_address(addr); return cc2420_set_address(addr);
#endif #endif
#ifdef MODULE_MC1322X #ifdef MODULE_MC1322X
case TRANSCEIVER_MC1322X: case TRANSCEIVER_MC1322X:
return maca_set_address(addr); return maca_set_address(addr);
#endif #endif
#ifdef MODULE_NATIVENET #ifdef MODULE_NATIVENET
case TRANSCEIVER_NATIVE: case TRANSCEIVER_NATIVE:
return nativenet_set_address(addr); return nativenet_set_address(addr);
#endif #endif
#ifdef MODULE_AT86RF231 #ifdef MODULE_AT86RF231
case TRANSCEIVER_AT86RF231: case TRANSCEIVER_AT86RF231:
return at86rf231_set_address(addr); return at86rf231_set_address(addr);
#endif #endif
default: default:
return 0; /* XXX see TODO above */ return 0; /* XXX see TODO above */
} }
@ -917,26 +978,31 @@ static void set_monitor(transceiver_type_t t, void *mode)
{ {
(void) mode; (void) mode;
switch(t) { switch (t) {
#ifdef MODULE_CC110X_NG #ifdef MODULE_CC110X_NG
case TRANSCEIVER_CC1100: case TRANSCEIVER_CC1100:
cc110x_set_monitor(*((uint8_t *)mode)); cc110x_set_monitor(*((uint8_t *)mode));
break; break;
#endif #endif
#ifdef MODULE_CC2420 #ifdef MODULE_CC2420
case TRANSCEIVER_CC2420: case TRANSCEIVER_CC2420:
cc2420_set_monitor(*((uint8_t*) mode)); cc2420_set_monitor(*((uint8_t *) mode));
break; break;
#endif #endif
#ifdef MODULE_NATIVENET #ifdef MODULE_NATIVENET
case TRANSCEIVER_NATIVE: case TRANSCEIVER_NATIVE:
nativenet_set_monitor(*((uint8_t*) mode)); nativenet_set_monitor(*((uint8_t *) mode));
break; break;
#endif #endif
#ifdef MODULE_AT86RF231 #ifdef MODULE_AT86RF231
case TRANSCEIVER_AT86RF231: case TRANSCEIVER_AT86RF231:
at86rf231_set_monitor(*((uint8_t*) mode)); at86rf231_set_monitor(*((uint8_t *) mode));
#endif #endif
default: default:
break; break;
} }
@ -957,22 +1023,26 @@ void cc1100_packet_monitor(void *payload, int payload_size, protocol_t protocol,
/*------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------*/
static void powerdown(transceiver_type_t t) static void powerdown(transceiver_type_t t)
{ {
switch(t) { switch (t) {
#ifdef MODULE_CC110X_NG #ifdef MODULE_CC110X_NG
case TRANSCEIVER_CC1100: case TRANSCEIVER_CC1100:
cc110x_switch_to_pwd(); cc110x_switch_to_pwd();
break; break;
#endif #endif
#ifdef MODULE_MC1322X #ifdef MODULE_MC1322X
case TRANSCEIVER_MC1322X: case TRANSCEIVER_MC1322X:
maca_off(); maca_off();
break; break;
#endif #endif
#ifdef MODULE_NATIVENET #ifdef MODULE_NATIVENET
case TRANSCEIVER_NATIVE: case TRANSCEIVER_NATIVE:
nativenet_powerdown(); nativenet_powerdown();
break; break;
#endif #endif
default: default:
break; break;
} }
@ -981,27 +1051,32 @@ static void powerdown(transceiver_type_t t)
/*------------------------------------------------------------------------------------*/ /*------------------------------------------------------------------------------------*/
static void switch_to_rx(transceiver_type_t t) static void switch_to_rx(transceiver_type_t t)
{ {
switch(t) { switch (t) {
#ifdef MODULE_CC110X_NG #ifdef MODULE_CC110X_NG
case TRANSCEIVER_CC1100: case TRANSCEIVER_CC1100:
cc110x_switch_to_rx(); cc110x_switch_to_rx();
break; break;
#endif #endif
#ifdef MODULE_CC2420 #ifdef MODULE_CC2420
case TRANSCEIVER_CC2420: case TRANSCEIVER_CC2420:
cc2420_switch_to_rx(); cc2420_switch_to_rx();
break; break;
#endif #endif
#ifdef MODULE_NATIVENET #ifdef MODULE_NATIVENET
case TRANSCEIVER_NATIVE: case TRANSCEIVER_NATIVE:
nativenet_switch_to_rx(); nativenet_switch_to_rx();
break; break;
#endif #endif
#ifdef MODULE_AT86RF231 #ifdef MODULE_AT86RF231
case TRANSCEIVER_AT86RF231: case TRANSCEIVER_AT86RF231:
at86rf231_switch_to_rx(); at86rf231_switch_to_rx();
#endif #endif
default: default:
break; break;
} }
@ -1020,6 +1095,7 @@ static int16_t ignore_add(transceiver_type_t transceiver, void *address)
return i; return i;
} }
} }
return -1; return -1;
} }
#endif #endif