From 713c2e597466b7d8db1fab5fcc3c23b20315ecf9 Mon Sep 17 00:00:00 2001 From: George Oikonomou Date: Sun, 28 Oct 2012 19:08:05 +0000 Subject: [PATCH] DOS EOL and indentation fixes (core/ apps/ cpu/) - Removed some DOS EOLs - Changed some tabs to spaces - Removed some trailing whitespaces Part of Pull Request #6 --- apps/collect-view/collect-view-z1.c | 68 ++--- core/net/mac/contikimac.c | 2 +- core/net/mac/lpp.c | 28 +- core/net/mac/xmac.c | 40 +-- cpu/stm32w108/dev/stm32w-radio.c | 384 ++++++++++++++-------------- cpu/stm32w108/rtimer-arch.h | 10 +- 6 files changed, 266 insertions(+), 266 deletions(-) diff --git a/apps/collect-view/collect-view-z1.c b/apps/collect-view/collect-view-z1.c index 03f972f80..124ae00d5 100644 --- a/apps/collect-view/collect-view-z1.c +++ b/apps/collect-view/collect-view-z1.c @@ -1,34 +1,34 @@ -#include "collect-view.h" -#include "dev/cc2420.h" -#include "dev/leds.h" -#include "dev/i2cmaster.h" -#include "dev/tmp102.h" - -#include "collect-view-z1.h" - -/*---------------------------------------------------------------------------*/ -static uint16_t -get_temp() -{ - /* XXX Fix me: check /examples/z1/test-tmp102.c for correct conversion */ - return (uint16_t)tmp102_read_temp_raw(); -} -/*---------------------------------------------------------------------------*/ -void -collect_view_arch_read_sensors(struct collect_view_data_msg *msg) -{ - static int initialized = 0; - - if(!initialized) { - tmp102_init(); - initialized = 1; - } - - msg->sensors[BATTERY_VOLTAGE_SENSOR] = 0; - msg->sensors[BATTERY_INDICATOR] = 0; - msg->sensors[LIGHT1_SENSOR] = 0; - msg->sensors[LIGHT2_SENSOR] = 0; - msg->sensors[TEMP_SENSOR] = get_temp(); - msg->sensors[HUMIDITY_SENSOR] = 0; -} -/*---------------------------------------------------------------------------*/ +#include "collect-view.h" +#include "dev/cc2420.h" +#include "dev/leds.h" +#include "dev/i2cmaster.h" +#include "dev/tmp102.h" + +#include "collect-view-z1.h" + +/*---------------------------------------------------------------------------*/ +static uint16_t +get_temp() +{ + /* XXX Fix me: check /examples/z1/test-tmp102.c for correct conversion */ + return (uint16_t)tmp102_read_temp_raw(); +} +/*---------------------------------------------------------------------------*/ +void +collect_view_arch_read_sensors(struct collect_view_data_msg *msg) +{ + static int initialized = 0; + + if(!initialized) { + tmp102_init(); + initialized = 1; + } + + msg->sensors[BATTERY_VOLTAGE_SENSOR] = 0; + msg->sensors[BATTERY_INDICATOR] = 0; + msg->sensors[LIGHT1_SENSOR] = 0; + msg->sensors[LIGHT2_SENSOR] = 0; + msg->sensors[TEMP_SENSOR] = get_temp(); + msg->sensors[HUMIDITY_SENSOR] = 0; +} +/*---------------------------------------------------------------------------*/ diff --git a/core/net/mac/contikimac.c b/core/net/mac/contikimac.c index ded95cada..08cc5119f 100644 --- a/core/net/mac/contikimac.c +++ b/core/net/mac/contikimac.c @@ -736,7 +736,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_ len = 0; - + { rtimer_clock_t wt; rtimer_clock_t txtime; diff --git a/core/net/mac/lpp.c b/core/net/mac/lpp.c index 54e2b9649..2b1545685 100644 --- a/core/net/mac/lpp.c +++ b/core/net/mac/lpp.c @@ -780,7 +780,7 @@ input_packet(void) { struct lpp_hdr hdr; clock_time_t reception_time; - int ret; + int ret; reception_time = clock_time(); @@ -845,7 +845,7 @@ input_packet(void) if(i->broadcast_flag == BROADCAST_FLAG_NONE || i->broadcast_flag == BROADCAST_FLAG_SEND) { i->num_transmissions = 1; - ret = NETSTACK_RADIO.send(queuebuf_dataptr(i->packet), + ret = NETSTACK_RADIO.send(queuebuf_dataptr(i->packet), queuebuf_datalen(i->packet)); sent = 1; PRINTF("%d.%d: got a probe from %d.%d, sent packet to %d.%d\n", @@ -860,7 +860,7 @@ input_packet(void) } #else /* WITH_PENDING_BROADCAST */ i->num_transmissions = 1; - ret = NETSTACK_RADIO.send(queuebuf_dataptr(i->packet), + ret = NETSTACK_RADIO.send(queuebuf_dataptr(i->packet), queuebuf_datalen(i->packet)); PRINTF("%d.%d: got a probe from %d.%d, sent packet to %d.%d\n", rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], @@ -879,23 +879,23 @@ input_packet(void) neighbors, and are dequeued by the dutycycling function instead, after the appropriate time. */ if(!rimeaddr_cmp(receiver, &rimeaddr_null)) { -#if RDC_CONF_HARDWARE_ACK - - if(ret == RADIO_TX_OK) { - remove_queued_packet(i, 1); - } else { - remove_queued_packet(i, 0); - } -#else +#if RDC_CONF_HARDWARE_ACK + + if(ret == RADIO_TX_OK) { + remove_queued_packet(i, 1); + } else { + remove_queued_packet(i, 0); + } +#else if(detect_ack()) { remove_queued_packet(i, 1); } else { remove_queued_packet(i, 0); } -#endif /* RDC_CONF_HARDWARE_ACK */ - - +#endif /* RDC_CONF_HARDWARE_ACK */ + + #if WITH_PROBE_AFTER_TRANSMISSION /* Send a probe packet to catch any reply from the other node. */ restart_dutycycle(PROBE_AFTER_TRANSMISSION_TIME); diff --git a/core/net/mac/xmac.c b/core/net/mac/xmac.c index 279981c71..71027ad69 100644 --- a/core/net/mac/xmac.c +++ b/core/net/mac/xmac.c @@ -454,7 +454,7 @@ send_packet(void) rtimer_clock_t t; rtimer_clock_t encounter_time = 0; int strobes; - int ret; + int ret; #if 0 struct xmac_hdr *hdr; #endif @@ -641,11 +641,11 @@ send_packet(void) if(is_broadcast) { #if WITH_STROBE_BROADCAST - ret = NETSTACK_RADIO.send(strobe, strobe_len); + ret = NETSTACK_RADIO.send(strobe, strobe_len); #else /* restore the packet to send */ queuebuf_to_packetbuf(packet); - ret = NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen()); + ret = NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen()); #endif off(); } else { @@ -653,7 +653,7 @@ send_packet(void) rtimer_clock_t wt; #endif on(); - ret = NETSTACK_RADIO.send(strobe, strobe_len); + ret = NETSTACK_RADIO.send(strobe, strobe_len); #if 0 /* Turn off the radio for a while to let the other side respond. We don't need to keep our radio on when we know @@ -662,20 +662,20 @@ send_packet(void) wt = RTIMER_NOW(); while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + WAIT_TIME_BEFORE_STROBE_ACK)); #endif /* 0 */ -#if RDC_CONF_HARDWARE_ACK - if(ret == RADIO_TX_OK) { - got_strobe_ack = 1; - } else { - off(); - } -#else +#if RDC_CONF_HARDWARE_ACK + if(ret == RADIO_TX_OK) { + got_strobe_ack = 1; + } else { + off(); + } +#else if(detect_ack()) { got_strobe_ack = 1; } else { off(); } -#endif /* RDC_CONF_HARDWARE_ACK */ - +#endif /* RDC_CONF_HARDWARE_ACK */ + } } } @@ -702,18 +702,18 @@ send_packet(void) /* Send the data packet. */ if((is_broadcast || got_strobe_ack || is_streaming) && collisions == 0) { - ret = NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen()); + ret = NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen()); if(!is_broadcast) { -#if RDC_CONF_HARDWARE_ACK - if(ret == RADIO_TX_OK) { - got_ack = 1; - } -#else +#if RDC_CONF_HARDWARE_ACK + if(ret == RADIO_TX_OK) { + got_ack = 1; + } +#else if(detect_ack()) { got_ack = 1; } -#endif /* RDC_CONF_HARDWARE_ACK */ +#endif /* RDC_CONF_HARDWARE_ACK */ } } off(); diff --git a/cpu/stm32w108/dev/stm32w-radio.c b/cpu/stm32w108/dev/stm32w-radio.c index 667ea8738..8962e0324 100644 --- a/cpu/stm32w108/dev/stm32w-radio.c +++ b/cpu/stm32w108/dev/stm32w-radio.c @@ -37,7 +37,7 @@ * \author * Salvatore Pitrulli * Chi-Anh La la@imag.fr -* Simon Duquennoy +* Simon Duquennoy */ /*---------------------------------------------------------------------------*/ @@ -54,10 +54,10 @@ #include "net/packetbuf.h" #include "net/rime/rimestats.h" -#include "sys/rtimer.h" +#include "sys/rtimer.h" #define DEBUG 0 - + #include "dev/leds.h" #define LED_ACTIVITY 0 @@ -67,13 +67,13 @@ #define ST_RADIO_AUTOACK 0 #endif /* ST_CONF_RADIO_AUTOACK */ -#if RDC_CONF_DEBUG_LED -#define LED_RDC RDC_CONF_DEBUG_LED -#define LED_ACTIVITY 1 -#else -#define LED_RDC 0 -#endif - +#if RDC_CONF_DEBUG_LED +#define LED_RDC RDC_CONF_DEBUG_LED +#define LED_ACTIVITY 1 +#else +#define LED_RDC 0 +#endif + #if DEBUG > 0 #include @@ -85,37 +85,37 @@ #if LED_ACTIVITY #define LED_TX_ON() leds_on(LEDS_GREEN) #define LED_TX_OFF() leds_off(LEDS_GREEN) -#define LED_RX_ON() { \ - if(LED_RDC == 0){ \ - leds_on(LEDS_RED); \ - } \ - } -#define LED_RX_OFF() { \ - if(LED_RDC == 0){ \ - leds_off(LEDS_RED); \ - } \ - } -#define LED_RDC_ON() { \ - if(LED_RDC == 1){ \ - leds_on(LEDS_RED); \ - } \ - } -#define LED_RDC_OFF() { \ - if(LED_RDC == 1){ \ - leds_off(LEDS_RED); \ - } \ - } +#define LED_RX_ON() { \ + if(LED_RDC == 0){ \ + leds_on(LEDS_RED); \ + } \ + } +#define LED_RX_OFF() { \ + if(LED_RDC == 0){ \ + leds_off(LEDS_RED); \ + } \ + } +#define LED_RDC_ON() { \ + if(LED_RDC == 1){ \ + leds_on(LEDS_RED); \ + } \ + } +#define LED_RDC_OFF() { \ + if(LED_RDC == 1){ \ + leds_off(LEDS_RED); \ + } \ + } #else #define LED_TX_ON() #define LED_TX_OFF() #define LED_RX_ON() #define LED_RX_OFF() -#define LED_RDC_ON() -#define LED_RDC_OFF() -#endif - -#if RDC_CONF_HARDWARE_CSMA -#define MAC_RETRIES 0 +#define LED_RDC_ON() +#define LED_RDC_OFF() +#endif + +#if RDC_CONF_HARDWARE_CSMA +#define MAC_RETRIES 0 #endif #ifndef MAC_RETRIES @@ -151,28 +151,28 @@ ENERGEST_OFF(ENERGEST_TYPE_LISTEN); \ } \ } -#if RDC_CONF_HARDWARE_CSMA -#define ST_RADIO_CHECK_CCA FALSE -#define ST_RADIO_CCA_ATTEMPT_MAX 0 -#define ST_BACKOFF_EXP_MIN 0 -#define ST_BACKOFF_EXP_MAX 0 -#else -#define ST_RADIO_CHECK_CCA TRUE -#define ST_RADIO_CCA_ATTEMPT_MAX 4 -#define ST_BACKOFF_EXP_MIN 2 -#define ST_BACKOFF_EXP_MAX 6 -#endif +#if RDC_CONF_HARDWARE_CSMA +#define ST_RADIO_CHECK_CCA FALSE +#define ST_RADIO_CCA_ATTEMPT_MAX 0 +#define ST_BACKOFF_EXP_MIN 0 +#define ST_BACKOFF_EXP_MAX 0 +#else +#define ST_RADIO_CHECK_CCA TRUE +#define ST_RADIO_CCA_ATTEMPT_MAX 4 +#define ST_BACKOFF_EXP_MIN 2 +#define ST_BACKOFF_EXP_MAX 6 +#endif const RadioTransmitConfig radioTransmitConfig = { - TRUE, // waitForAck; - ST_RADIO_CHECK_CCA, // checkCca; // Set to FALSE with low-power MACs. - ST_RADIO_CCA_ATTEMPT_MAX, // ccaAttemptMax; - ST_BACKOFF_EXP_MIN, // backoffExponentMin; - ST_BACKOFF_EXP_MAX, // backoffExponentMax; - TRUE // appendCrc; + TRUE, // waitForAck; + ST_RADIO_CHECK_CCA, // checkCca; // Set to FALSE with low-power MACs. + ST_RADIO_CCA_ATTEMPT_MAX, // ccaAttemptMax; + ST_BACKOFF_EXP_MIN, // backoffExponentMin; + ST_BACKOFF_EXP_MAX, // backoffExponentMax; + TRUE // appendCrc; }; -#define MAC_RETRIES 0 - +#define MAC_RETRIES 0 + /* * The buffers which hold incoming data. */ @@ -223,20 +223,20 @@ static uint8_t receiving_packet = 0; static s8 last_rssi; static volatile StStatus last_tx_status; -#define BUSYWAIT_UNTIL(cond, max_time) \ - do { \ - rtimer_clock_t t0; \ - t0 = RTIMER_NOW(); \ - while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + (max_time))); \ - } while(0) - -static uint8_t locked; -#define GET_LOCK() locked++ -static void RELEASE_LOCK(void) { - if(locked>0) - locked--; -} -static volatile uint8_t is_transmit_ack; +#define BUSYWAIT_UNTIL(cond, max_time) \ + do { \ + rtimer_clock_t t0; \ + t0 = RTIMER_NOW(); \ + while(!(cond) && RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + (max_time))); \ + } while(0) + +static uint8_t locked; +#define GET_LOCK() locked++ +static void RELEASE_LOCK(void) { + if(locked>0) + locked--; +} +static volatile uint8_t is_transmit_ack; /*---------------------------------------------------------------------------*/ PROCESS(stm32w_radio_process, "STM32W radio driver"); /*---------------------------------------------------------------------------*/ @@ -278,10 +278,10 @@ static int stm32w_radio_init(void) // Initialize radio (analog section, digital baseband and MAC). // Leave radio powered up in non-promiscuous rx mode. ST_RadioInit(ST_RADIO_POWER_MODE_OFF); - + onoroff = OFF; ST_RadioSetPanId(IEEE802154_PANID); - + CLEAN_RXBUFS(); CLEAN_TXBUF(); @@ -290,10 +290,10 @@ static int stm32w_radio_init(void) #endif ST_RadioEnableAutoAck(ST_RADIO_AUTOACK); ST_RadioEnableAddressFiltering(ST_RADIO_AUTOACK); - - locked = 0; + + locked = 0; process_start(&stm32w_radio_process, NULL); - + return 0; } /*---------------------------------------------------------------------------*/ @@ -306,9 +306,9 @@ int stm32w_radio_set_channel(uint8_t channel) } /*---------------------------------------------------------------------------*/ static int wait_for_tx(void){ - + struct timer t; - + timer_set(&t, CLOCK_SECOND/10); while(!TXBUF_EMPTY()){ if(timer_expired(&t)){ @@ -318,7 +318,7 @@ static int wait_for_tx(void){ /* Put CPU in sleep mode. */ halSleepWithOptions(SLEEPMODE_IDLE,0); } - return 0; + return 0; } /*---------------------------------------------------------------------------*/ static int stm32w_radio_prepare(const void *payload, unsigned short payload_len) @@ -327,7 +327,7 @@ static int stm32w_radio_prepare(const void *payload, unsigned short payload_len) PRINTF("stm32w: payload length=%d is too long.\r\n", payload_len); return RADIO_TX_ERR; } - + #if !RADIO_WAIT_FOR_PACKET_SENT /* Check if the txbuf is empty. * Wait for a finite time. @@ -338,102 +338,102 @@ static int stm32w_radio_prepare(const void *payload, unsigned short payload_len) return RADIO_TX_ERR; } #endif /* RADIO_WAIT_FOR_PACKET_SENT */ - - /* Copy to the txbuf. + + /* Copy to the txbuf. * The first byte must be the packet length. */ - CLEAN_TXBUF(); + CLEAN_TXBUF(); memcpy(stm32w_txbuf + 1, payload, payload_len); - + return RADIO_TX_OK; - + } /*---------------------------------------------------------------------------*/ static int stm32w_radio_transmit(unsigned short payload_len) -{ +{ stm32w_txbuf[0] = payload_len + CHECKSUM_LEN; - + INIT_RETRY_CNT(); - + if(onoroff == OFF){ PRINTF("stm32w: Radio is off, turning it on.\r\n"); ST_RadioWake(); ENERGEST_ON(ENERGEST_TYPE_LISTEN); } - -#if RADIO_WAIT_FOR_PACKET_SENT - GET_LOCK(); -#endif /* RADIO_WAIT_FOR_PACKET_SENT */ - last_tx_status = -1; + +#if RADIO_WAIT_FOR_PACKET_SENT + GET_LOCK(); +#endif /* RADIO_WAIT_FOR_PACKET_SENT */ + last_tx_status = -1; LED_TX_ON(); if(ST_RadioTransmit(stm32w_txbuf)==ST_SUCCESS){ - + ENERGEST_OFF(ENERGEST_TYPE_LISTEN); ENERGEST_ON(ENERGEST_TYPE_TRANSMIT); - + PRINTF("stm32w: sending %d bytes\r\n", payload_len); - + #if DEBUG > 1 for(uint8_t c=1; c <= stm32w_txbuf[0]-2; c++){ PRINTF("%x:",stm32w_txbuf[c]); } PRINTF("\r\n"); -#endif - +#endif + #if RADIO_WAIT_FOR_PACKET_SENT - + if(wait_for_tx()){ PRINTF("stm32w: unknown tx error.\r\n"); TO_PREV_STATE(); LED_TX_OFF(); - RELEASE_LOCK(); + RELEASE_LOCK(); return RADIO_TX_ERR; } TO_PREV_STATE(); - if(last_tx_status == ST_SUCCESS || last_tx_status == ST_PHY_ACK_RECEIVED || last_tx_status == ST_MAC_NO_ACK_RECEIVED){ - RELEASE_LOCK(); - if(last_tx_status == ST_PHY_ACK_RECEIVED){ - return RADIO_TX_OK; /* ACK status */ - } - else if (last_tx_status == ST_MAC_NO_ACK_RECEIVED || last_tx_status == ST_SUCCESS){ - return RADIO_TX_NOACK; - } + if(last_tx_status == ST_SUCCESS || last_tx_status == ST_PHY_ACK_RECEIVED || last_tx_status == ST_MAC_NO_ACK_RECEIVED){ + RELEASE_LOCK(); + if(last_tx_status == ST_PHY_ACK_RECEIVED){ + return RADIO_TX_OK; /* ACK status */ + } + else if (last_tx_status == ST_MAC_NO_ACK_RECEIVED || last_tx_status == ST_SUCCESS){ + return RADIO_TX_NOACK; + } } - LED_TX_OFF(); - RELEASE_LOCK(); + LED_TX_OFF(); + RELEASE_LOCK(); return RADIO_TX_ERR; - -#else /* RADIO_WAIT_FOR_PACKET_SENT */ - + +#else /* RADIO_WAIT_FOR_PACKET_SENT */ + TO_PREV_STATE(); LED_TX_OFF(); - return RADIO_TX_OK; - + return RADIO_TX_OK; + #endif /* RADIO_WAIT_FOR_PACKET_SENT */ - + } - -#if RADIO_WAIT_FOR_PACKET_SENT - RELEASE_LOCK(); -#endif /* RADIO_WAIT_FOR_PACKET_SENT */ + +#if RADIO_WAIT_FOR_PACKET_SENT + RELEASE_LOCK(); +#endif /* RADIO_WAIT_FOR_PACKET_SENT */ TO_PREV_STATE(); - + PRINTF("stm32w: transmission never started.\r\n"); /* TODO: Do we have to retransmit? */ - + CLEAN_TXBUF(); - LED_TX_OFF(); + LED_TX_OFF(); return RADIO_TX_ERR; - + } /*---------------------------------------------------------------------------*/ static int stm32w_radio_send(const void *payload, unsigned short payload_len) { if(stm32w_radio_prepare(payload, payload_len) == RADIO_TX_ERR) return RADIO_TX_ERR; - + return stm32w_radio_transmit(payload_len); - + } /*---------------------------------------------------------------------------*/ static int stm32w_radio_channel_clear(void) @@ -452,40 +452,40 @@ static int stm32w_radio_pending_packet(void) } /*---------------------------------------------------------------------------*/ static int stm32w_radio_off(void) -{ +{ /* Any transmit or receive packets in progress are aborted. * Waiting for end of transmission or reception have to be done. */ - if(locked) - { - PRINTF("stm32w: try to off while sending/receiving (lock=%u).\r\n", locked); - return 0; - } - /* off only if there is no transmission or reception of packet. */ - if(onoroff == ON && TXBUF_EMPTY() && !receiving_packet){ - LED_RDC_OFF(); + if(locked) + { + PRINTF("stm32w: try to off while sending/receiving (lock=%u).\r\n", locked); + return 0; + } + /* off only if there is no transmission or reception of packet. */ + if(onoroff == ON && TXBUF_EMPTY() && !receiving_packet){ + LED_RDC_OFF(); ST_RadioSleep(); onoroff = OFF; CLEAN_TXBUF(); - CLEAN_RXBUFS(); - + CLEAN_RXBUFS(); + ENERGEST_OFF(ENERGEST_TYPE_LISTEN); } - + return 1; } /*---------------------------------------------------------------------------*/ static int stm32w_radio_on(void) { - PRINTF("stm32w: turn radio on\n"); + PRINTF("stm32w: turn radio on\n"); if(onoroff == OFF){ - LED_RDC_ON(); + LED_RDC_ON(); ST_RadioWake(); onoroff = ON; - + ENERGEST_ON(ENERGEST_TYPE_LISTEN); } - + return 1; } /*---------------------------------------------------------------------------*/ @@ -503,7 +503,7 @@ void ST_RadioReceiveIsrCallback(u8 *packet, s8 rssi) { LED_RX_ON(); - PRINTF("stm32w: incomming packet received\n"); + PRINTF("stm32w: incomming packet received\n"); receiving_packet = 0; /* Copy packet into the buffer. It is better to do this here. */ if(add_to_rxbuf(packet)){ @@ -511,21 +511,21 @@ void ST_RadioReceiveIsrCallback(u8 *packet, last_rssi = rssi; } LED_RX_OFF(); - GET_LOCK(); - is_transmit_ack = 1; - /* Wait for sending ACK */ - BUSYWAIT_UNTIL(!is_transmit_ack, RTIMER_SECOND / 1500); - RELEASE_LOCK(); - -} - -void ST_RadioTxAckIsrCallback (void) -{ - /* This callback is for simplemac 1.1.0. - Till now we block (RTIMER_SECOND / 1500) - to prevent radio off during ACK transmission */ - is_transmit_ack = 0; - //RELEASE_LOCK(); + GET_LOCK(); + is_transmit_ack = 1; + /* Wait for sending ACK */ + BUSYWAIT_UNTIL(!is_transmit_ack, RTIMER_SECOND / 1500); + RELEASE_LOCK(); + +} + +void ST_RadioTxAckIsrCallback (void) +{ + /* This callback is for simplemac 1.1.0. + Till now we block (RTIMER_SECOND / 1500) + to prevent radio off during ACK transmission */ + is_transmit_ack = 0; + //RELEASE_LOCK(); } @@ -534,12 +534,12 @@ void ST_RadioTransmitCompleteIsrCallback(StStatus status, boolean framePending) { - ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); + ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT); ENERGEST_ON(ENERGEST_TYPE_LISTEN); LED_TX_OFF(); - + last_tx_status = status; - + if(status == ST_SUCCESS || status == ST_PHY_ACK_RECEIVED){ CLEAN_TXBUF(); } @@ -549,12 +549,12 @@ void ST_RadioTransmitCompleteIsrCallback(StStatus status, // Retransmission LED_TX_ON(); if(ST_RadioTransmit(stm32w_txbuf)==ST_SUCCESS){ - + ENERGEST_OFF(ENERGEST_TYPE_LISTEN); ENERGEST_ON(ENERGEST_TYPE_TRANSMIT); - + PRINTF("stm32w: retransmission.\r\n"); - + DEC_RETRY_CNT(); } else { @@ -565,24 +565,24 @@ void ST_RadioTransmitCompleteIsrCallback(StStatus status, } else { CLEAN_TXBUF(); - } + } } - + /* Debug outputs. */ if(status == ST_SUCCESS || status == ST_PHY_ACK_RECEIVED){ - PRINTF("stm32w: return status TX_END\r\n"); + PRINTF("stm32w: return status TX_END\r\n"); } else if (status == ST_MAC_NO_ACK_RECEIVED){ - PRINTF("stm32w: return status TX_END_NOACK\r\n"); + PRINTF("stm32w: return status TX_END_NOACK\r\n"); } else if (status == ST_PHY_TX_CCA_FAIL){ - PRINTF("stm32w: return status TX_END_CCA_FAIL\r\n"); + PRINTF("stm32w: return status TX_END_CCA_FAIL\r\n"); } else if(status == ST_PHY_TX_UNDERFLOW){ - PRINTF("stm32w: return status TX_END_UNDERFLOW\r\n"); + PRINTF("stm32w: return status TX_END_UNDERFLOW\r\n"); } else { - PRINTF("stm32w: return status TX_END_INCOMPLETE\r\n"); + PRINTF("stm32w: return status TX_END_INCOMPLETE\r\n"); } } @@ -600,28 +600,28 @@ boolean ST_RadioDataPendingLongIdIsrCallback(int8u* longId) { PROCESS_THREAD(stm32w_radio_process, ev, data) { int len; - + PROCESS_BEGIN(); PRINTF("stm32w_radio_process: started\r\n"); - + while(1) { - - PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL); - + + PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL); + PRINTF("stm32w_radio_process: calling receiver callback\r\n"); - + #if DEBUG > 1 for(uint8_t c=1; c <= RCVD_PACKET_LEN; c++){ PRINTF("%x",stm32w_rxbuf[c]); } PRINTF("\r\n"); #endif - + packetbuf_clear(); len = stm32w_radio_read(packetbuf_dataptr(), PACKETBUF_SIZE); if(len > 0) { - packetbuf_set_datalen(len); + packetbuf_set_datalen(len); NETSTACK_RDC.input(); } if(!RXBUFS_EMPTY()){ @@ -635,14 +635,14 @@ PROCESS_THREAD(stm32w_radio_process, ev, data) } /*---------------------------------------------------------------------------*/ static int stm32w_radio_read(void *buf, unsigned short bufsize) -{ - return read_from_rxbuf(buf,bufsize); +{ + return read_from_rxbuf(buf,bufsize); } /*---------------------------------------------------------------------------*/ void ST_RadioOverflowIsrCallback(void) { - PRINTF("stm32w: radio overflow\r\n"); + PRINTF("stm32w: radio overflow\r\n"); } /*---------------------------------------------------------------------------*/ void ST_RadioSfdSentIsrCallback(u32 sfdSentTime) @@ -657,36 +657,36 @@ static int add_to_rxbuf(uint8_t * src) { if(RXBUFS_FULL()){ return 0; - } - + } + memcpy(stm32w_rxbufs[last], src, src[0] + 1); #if RADIO_RXBUFS > 1 - last = (last + 1) % RADIO_RXBUFS; + last = (last + 1) % RADIO_RXBUFS; if(first == -1){ first = 0; } #endif - + return 1; } /*---------------------------------------------------------------------------*/ static int read_from_rxbuf(void * dest, unsigned short len) { - + if(RXBUFS_EMPTY()){ // Buffers are all empty return 0; - } - + } + if(stm32w_rxbufs[first][0] > len){ // Too large packet for dest. len = 0; } - else { - len = stm32w_rxbufs[first][0]; + else { + len = stm32w_rxbufs[first][0]; memcpy(dest,stm32w_rxbufs[first]+1,len); packetbuf_set_attr(PACKETBUF_ATTR_RSSI, last_rssi); } - -#if RADIO_RXBUFS > 1 + +#if RADIO_RXBUFS > 1 ATOMIC( first = (first + 1) % RADIO_RXBUFS; int first_tmp = first; @@ -697,7 +697,7 @@ static int read_from_rxbuf(void * dest, unsigned short len) #else CLEAN_RXBUFS(); #endif - + return len; } /*---------------------------------------------------------------------------*/ diff --git a/cpu/stm32w108/rtimer-arch.h b/cpu/stm32w108/rtimer-arch.h index b8c15561b..f7606cd46 100644 --- a/cpu/stm32w108/rtimer-arch.h +++ b/cpu/stm32w108/rtimer-arch.h @@ -45,12 +45,12 @@ #include "sys/clock.h" -//#define RT_RESOLUTION RES_85US -#ifdef RT_CONF_RESOLUTION -#define RT_RESOLUTION RT_CONF_RESOLUTION -#else +//#define RT_RESOLUTION RES_85US +#ifdef RT_CONF_RESOLUTION +#define RT_RESOLUTION RT_CONF_RESOLUTION +#else #define RT_RESOLUTION RES_171US -#endif +#endif #define RES_341US 0 #define RES_171US 1