2013-03-15 16:14:09 +01:00
|
|
|
/**
|
|
|
|
* \addtogroup stm32w-cpu
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010, STMicroelectronics.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials provided
|
|
|
|
* with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote
|
|
|
|
* products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
|
|
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
|
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
2013-03-15 16:14:09 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* Machine dependent STM32W radio code.
|
|
|
|
* \author
|
|
|
|
* Salvatore Pitrulli
|
2012-03-20 16:15:51 +01:00
|
|
|
* Chi-Anh La la@imag.fr
|
2012-10-28 20:08:05 +01:00
|
|
|
* Simon Duquennoy <simonduq@sics.se>
|
2010-10-25 11:03:38 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include PLATFORM_HEADER
|
|
|
|
#include "hal/error.h"
|
|
|
|
#include "hal/hal.h"
|
|
|
|
|
|
|
|
#include "contiki.h"
|
|
|
|
|
|
|
|
#include "net/mac/frame802154.h"
|
|
|
|
|
|
|
|
#include "dev/stm32w-radio.h"
|
|
|
|
#include "net/netstack.h"
|
|
|
|
|
|
|
|
#include "net/packetbuf.h"
|
|
|
|
#include "net/rime/rimestats.h"
|
2012-10-28 20:08:05 +01:00
|
|
|
#include "sys/rtimer.h"
|
2010-10-25 11:03:38 +02:00
|
|
|
|
|
|
|
#define DEBUG 0
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
#include "dev/leds.h"
|
|
|
|
#define LED_ACTIVITY 0
|
|
|
|
|
2012-03-20 16:15:51 +01:00
|
|
|
#ifdef ST_CONF_RADIO_AUTOACK
|
|
|
|
#define ST_RADIO_AUTOACK ST_CONF_RADIO_AUTOACK
|
|
|
|
#else
|
|
|
|
#define ST_RADIO_AUTOACK 0
|
|
|
|
#endif /* ST_CONF_RADIO_AUTOACK */
|
|
|
|
|
2012-10-28 20:08:05 +01:00
|
|
|
#if RDC_CONF_DEBUG_LED
|
|
|
|
#define LED_RDC RDC_CONF_DEBUG_LED
|
|
|
|
#define LED_ACTIVITY 1
|
|
|
|
#else
|
|
|
|
#define LED_RDC 0
|
2013-03-15 16:14:09 +01:00
|
|
|
#endif /* RDC_CONF_DEBUG_LED */
|
2010-10-25 11:03:38 +02:00
|
|
|
|
|
|
|
#if DEBUG > 0
|
|
|
|
#include <stdio.h>
|
|
|
|
#define PRINTF(...) printf(__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define PRINTF(...) do {} while (0)
|
2013-03-15 16:14:09 +01:00
|
|
|
#endif /* DEBUG > 0 */
|
2010-10-25 11:03:38 +02:00
|
|
|
|
|
|
|
#if LED_ACTIVITY
|
|
|
|
#define LED_TX_ON() leds_on(LEDS_GREEN)
|
|
|
|
#define LED_TX_OFF() leds_off(LEDS_GREEN)
|
2013-03-15 16:14:09 +01:00
|
|
|
#define LED_RX_ON() do { \
|
2012-10-28 20:08:05 +01:00
|
|
|
if(LED_RDC == 0){ \
|
|
|
|
leds_on(LEDS_RED); \
|
|
|
|
} \
|
2013-03-15 16:14:09 +01:00
|
|
|
} while (0)
|
|
|
|
#define LED_RX_OFF() do { \
|
2012-10-28 20:08:05 +01:00
|
|
|
if(LED_RDC == 0){ \
|
2013-03-15 16:14:09 +01:00
|
|
|
leds_off(LEDS_RED); \
|
2012-10-28 20:08:05 +01:00
|
|
|
} \
|
2013-03-15 16:14:09 +01:00
|
|
|
} while (0)
|
|
|
|
#define LED_RDC_ON() do { \
|
2012-10-28 20:08:05 +01:00
|
|
|
if(LED_RDC == 1){ \
|
|
|
|
leds_on(LEDS_RED); \
|
|
|
|
} \
|
2013-03-15 16:14:09 +01:00
|
|
|
} while (0)
|
|
|
|
#define LED_RDC_OFF() do { \
|
2012-10-28 20:08:05 +01:00
|
|
|
if(LED_RDC == 1){ \
|
2013-03-15 16:14:09 +01:00
|
|
|
leds_off(LEDS_RED); \
|
2012-10-28 20:08:05 +01:00
|
|
|
} \
|
2013-03-15 16:14:09 +01:00
|
|
|
} while (0)
|
2010-10-25 11:03:38 +02:00
|
|
|
#else
|
|
|
|
#define LED_TX_ON()
|
|
|
|
#define LED_TX_OFF()
|
|
|
|
#define LED_RX_ON()
|
|
|
|
#define LED_RX_OFF()
|
2012-10-28 20:08:05 +01:00
|
|
|
#define LED_RDC_ON()
|
|
|
|
#define LED_RDC_OFF()
|
2013-03-15 16:14:09 +01:00
|
|
|
#endif /* LED_ACTIVITY */
|
2012-10-28 20:08:05 +01:00
|
|
|
|
|
|
|
#if RDC_CONF_HARDWARE_CSMA
|
|
|
|
#define MAC_RETRIES 0
|
2013-03-15 16:14:09 +01:00
|
|
|
#endif /* RDC_CONF_HARDWARE_CSMA */
|
2010-10-25 11:03:38 +02:00
|
|
|
|
|
|
|
#ifndef MAC_RETRIES
|
|
|
|
#define MAC_RETRIES 1
|
2013-03-15 16:14:09 +01:00
|
|
|
#endif /* MAC_RETRIES */
|
2010-10-25 11:03:38 +02:00
|
|
|
|
|
|
|
#if MAC_RETRIES
|
2013-03-15 16:14:09 +01:00
|
|
|
int8_t mac_retries_left;
|
|
|
|
#define INIT_RETRY_CNT() (mac_retries_left = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS))
|
|
|
|
#define DEC_RETRY_CNT() (mac_retries_left--)
|
|
|
|
#define RETRY_CNT_GTZ() (mac_retries_left > 0)
|
2010-10-25 11:03:38 +02:00
|
|
|
#else
|
2013-03-15 16:14:09 +01:00
|
|
|
#define INIT_RETRY_CNT()
|
|
|
|
#define DEC_RETRY_CNT()
|
|
|
|
#define RETRY_CNT_GTZ() 0
|
|
|
|
#endif /* MAC_RETRIES */
|
2010-10-25 11:03:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* If set to 1, a send() returns only after the packet has been transmitted.
|
|
|
|
This is necessary if you use the x-mac module, for example. */
|
|
|
|
#ifndef RADIO_WAIT_FOR_PACKET_SENT
|
|
|
|
#define RADIO_WAIT_FOR_PACKET_SENT 1
|
2013-03-15 16:14:09 +01:00
|
|
|
#endif /* RADIO_WAIT_FOR_PACKET_SENT */
|
2010-10-25 11:03:38 +02:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
#define TO_PREV_STATE() do { \
|
2010-10-25 11:03:38 +02:00
|
|
|
if(onoroff == OFF){ \
|
|
|
|
ST_RadioSleep(); \
|
|
|
|
ENERGEST_OFF(ENERGEST_TYPE_LISTEN); \
|
|
|
|
} \
|
2013-03-15 16:14:09 +01:00
|
|
|
} while(0)
|
2012-10-28 20:08:05 +01:00
|
|
|
#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
|
2013-03-15 16:14:09 +01:00
|
|
|
#else /* RDC_CONF_HARDWARE_CSMA */
|
2012-10-28 20:08:05 +01:00
|
|
|
#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
|
2013-03-15 16:14:09 +01:00
|
|
|
#endif /* RDC_CONF_HARDWARE_CSMA */
|
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
const RadioTransmitConfig radioTransmitConfig = {
|
2013-03-15 16:14:09 +01:00
|
|
|
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; */
|
2010-10-25 11:03:38 +02:00
|
|
|
};
|
|
|
|
|
2012-10-28 20:08:05 +01:00
|
|
|
#define MAC_RETRIES 0
|
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
/*
|
|
|
|
* The buffers which hold incoming data.
|
|
|
|
*/
|
|
|
|
#ifndef RADIO_RXBUFS
|
|
|
|
#define RADIO_RXBUFS 1
|
2013-03-15 16:14:09 +01:00
|
|
|
#endif /* RADIO_RXBUFS */
|
2010-10-25 11:03:38 +02:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
/* +1 because of the first byte, which will contain the length of the packet. */
|
|
|
|
static uint8_t stm32w_rxbufs[RADIO_RXBUFS][STM32W_MAX_PACKET_LEN + 1];
|
2010-10-25 11:03:38 +02:00
|
|
|
|
|
|
|
#if RADIO_RXBUFS > 1
|
2013-03-15 16:14:09 +01:00
|
|
|
static volatile int8_t first = -1, last = 0;
|
|
|
|
#else /* RADIO_RXBUFS > 1 */
|
|
|
|
static const int8_t first = 0, last = 0;
|
|
|
|
#endif /* RADIO_RXBUFS > 1 */
|
2010-10-25 11:03:38 +02:00
|
|
|
|
|
|
|
#if RADIO_RXBUFS > 1
|
2013-03-15 16:14:09 +01:00
|
|
|
#define CLEAN_RXBUFS() do{first = -1; last = 0;}while(0)
|
|
|
|
#define RXBUFS_EMPTY() (first == -1)
|
|
|
|
int
|
|
|
|
RXBUFS_FULL()
|
|
|
|
{
|
|
|
|
int8_t first_tmp = first;
|
|
|
|
return first_tmp == last;
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
|
|
|
#else /* RADIO_RXBUFS > 1 */
|
2013-03-15 16:14:09 +01:00
|
|
|
#define CLEAN_RXBUFS() (stm32w_rxbufs[0][0] = 0)
|
|
|
|
#define RXBUFS_EMPTY() (stm32w_rxbufs[0][0] == 0)
|
|
|
|
#define RXBUFS_FULL() (stm32w_rxbufs[0][0] != 0)
|
2010-10-25 11:03:38 +02:00
|
|
|
#endif /* RADIO_RXBUFS > 1 */
|
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
static uint8_t
|
|
|
|
__attribute__ ((aligned(2))) stm32w_txbuf[STM32W_MAX_PACKET_LEN + 1];
|
2010-10-25 11:03:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
#define CLEAN_TXBUF() (stm32w_txbuf[0] = 0)
|
|
|
|
#define TXBUF_EMPTY() (stm32w_txbuf[0] == 0)
|
|
|
|
#define CHECKSUM_LEN 2
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The transceiver state.
|
|
|
|
*/
|
|
|
|
#define ON 0
|
|
|
|
#define OFF 1
|
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
#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)
|
|
|
|
|
|
|
|
#define GET_LOCK() locked++
|
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
static volatile uint8_t onoroff = OFF;
|
|
|
|
static uint8_t receiving_packet = 0;
|
2013-03-15 16:14:09 +01:00
|
|
|
static int8_t last_rssi;
|
2010-10-25 11:03:38 +02:00
|
|
|
static volatile StStatus last_tx_status;
|
2012-10-28 20:08:05 +01:00
|
|
|
static uint8_t locked;
|
|
|
|
static volatile uint8_t is_transmit_ack;
|
2013-03-15 16:14:09 +01:00
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
RELEASE_LOCK(void)
|
|
|
|
{
|
|
|
|
if(locked > 0)
|
|
|
|
locked--;
|
|
|
|
}
|
2010-10-25 11:03:38 +02:00
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS(stm32w_radio_process, "STM32W radio driver");
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
static int stm32w_radio_init(void);
|
2013-03-15 16:14:09 +01:00
|
|
|
|
|
|
|
static int stm32w_radio_prepare(const void *payload,
|
|
|
|
unsigned short payload_len);
|
2010-10-25 11:03:38 +02:00
|
|
|
static int stm32w_radio_transmit(unsigned short payload_len);
|
2013-03-15 16:14:09 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
static int stm32w_radio_send(const void *data, unsigned short len);
|
2013-03-15 16:14:09 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
static int stm32w_radio_read(void *buf, unsigned short bufsize);
|
2013-03-15 16:14:09 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
static int stm32w_radio_channel_clear(void);
|
2013-03-15 16:14:09 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
static int stm32w_radio_receiving_packet(void);
|
2013-03-15 16:14:09 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
static int stm32w_radio_pending_packet(void);
|
2013-03-15 16:14:09 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
static int stm32w_radio_on(void);
|
2013-03-15 16:14:09 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
static int stm32w_radio_off(void);
|
|
|
|
|
|
|
|
static int add_to_rxbuf(uint8_t * src);
|
2013-03-15 16:14:09 +01:00
|
|
|
|
|
|
|
static int read_from_rxbuf(void *dest, unsigned short len);
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
const struct radio_driver stm32w_radio_driver = {
|
|
|
|
stm32w_radio_init,
|
|
|
|
stm32w_radio_prepare,
|
|
|
|
stm32w_radio_transmit,
|
|
|
|
stm32w_radio_send,
|
|
|
|
stm32w_radio_read,
|
|
|
|
stm32w_radio_channel_clear,
|
|
|
|
stm32w_radio_receiving_packet,
|
|
|
|
stm32w_radio_pending_packet,
|
|
|
|
stm32w_radio_on,
|
|
|
|
stm32w_radio_off,
|
|
|
|
};
|
2010-10-25 11:03:38 +02:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
stm32w_radio_init(void)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
2013-03-15 16:14:09 +01:00
|
|
|
/* A channel also needs to be set. */
|
2010-10-25 11:03:38 +02:00
|
|
|
ST_RadioSetChannel(RF_CHANNEL);
|
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
/* Initialize radio (analog section, digital baseband and MAC). */
|
|
|
|
/* Leave radio powered up in non-promiscuous rx mode. */
|
2010-10-25 11:03:38 +02:00
|
|
|
ST_RadioInit(ST_RADIO_POWER_MODE_OFF);
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
onoroff = OFF;
|
|
|
|
ST_RadioSetPanId(IEEE802154_PANID);
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
CLEAN_RXBUFS();
|
|
|
|
CLEAN_TXBUF();
|
2012-03-20 16:15:51 +01:00
|
|
|
|
2013-12-12 23:58:52 +01:00
|
|
|
#if ST_RADIO_AUTOACK && !(UIP_CONF_LL_802154 && LINKADDR_CONF_SIZE==8)
|
2012-03-20 16:15:51 +01:00
|
|
|
#error "Autoack and address filtering can only be used with EUI 64"
|
|
|
|
#endif
|
|
|
|
ST_RadioEnableAutoAck(ST_RADIO_AUTOACK);
|
|
|
|
ST_RadioEnableAddressFiltering(ST_RADIO_AUTOACK);
|
2012-10-28 20:08:05 +01:00
|
|
|
|
|
|
|
locked = 0;
|
2010-10-25 11:03:38 +02:00
|
|
|
process_start(&stm32w_radio_process, NULL);
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
void
|
|
|
|
stm32w_radio_set_promiscous(uint8_t on)
|
|
|
|
{
|
|
|
|
if(on) {
|
|
|
|
ST_RadioEnableAddressFiltering(0);
|
|
|
|
} else {
|
|
|
|
ST_RadioEnableAddressFiltering(ST_RADIO_AUTOACK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
int
|
|
|
|
stm32w_radio_set_channel(uint8_t channel)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
2013-03-15 16:14:09 +01:00
|
|
|
if (ST_RadioSetChannel(channel) == ST_SUCCESS) {
|
2010-10-25 11:03:38 +02:00
|
|
|
return 0;
|
2013-03-15 16:14:09 +01:00
|
|
|
} else {
|
2010-10-25 11:03:38 +02:00
|
|
|
return 1;
|
2013-03-15 16:14:09 +01:00
|
|
|
}
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
wait_for_tx(void)
|
|
|
|
{
|
2010-10-25 11:03:38 +02:00
|
|
|
struct timer t;
|
2013-03-15 16:14:09 +01:00
|
|
|
timer_set(&t, CLOCK_SECOND / 10);
|
|
|
|
while(!TXBUF_EMPTY()) {
|
|
|
|
if(timer_expired(&t)) {
|
2010-10-25 11:03:38 +02:00
|
|
|
PRINTF("stm32w: tx buffer full.\r\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
/* Put CPU in sleep mode. */
|
2013-03-15 16:14:09 +01:00
|
|
|
halSleepWithOptions(SLEEPMODE_IDLE, 0);
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
2012-10-28 20:08:05 +01:00
|
|
|
return 0;
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
stm32w_radio_prepare(const void *payload, unsigned short payload_len)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
2013-03-15 16:14:09 +01:00
|
|
|
if(payload_len > STM32W_MAX_PACKET_LEN) {
|
|
|
|
PRINTF("stm32w: payload length=%d is too long.\r\n", payload_len);
|
|
|
|
return RADIO_TX_ERR;
|
|
|
|
}
|
2010-10-25 11:03:38 +02:00
|
|
|
#if !RADIO_WAIT_FOR_PACKET_SENT
|
2013-03-15 16:14:09 +01:00
|
|
|
/*
|
|
|
|
* Check if the txbuf is empty. Wait for a finite time.
|
|
|
|
* This should not occur if we wait for the end of transmission in
|
|
|
|
* stm32w_radio_transmit().
|
|
|
|
*/
|
|
|
|
if(wait_for_tx()) {
|
|
|
|
PRINTF("stm32w: tx buffer full.\r\n");
|
|
|
|
return RADIO_TX_ERR;
|
|
|
|
}
|
2010-10-25 11:03:38 +02:00
|
|
|
#endif /* RADIO_WAIT_FOR_PACKET_SENT */
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
/*
|
|
|
|
* Copy to the txbuf.
|
|
|
|
* The first byte must be the packet length.
|
|
|
|
*/
|
|
|
|
CLEAN_TXBUF();
|
|
|
|
memcpy(stm32w_txbuf + 1, payload, payload_len);
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
return RADIO_TX_OK;
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
stm32w_radio_transmit(unsigned short payload_len)
|
2012-10-28 20:08:05 +01:00
|
|
|
{
|
2013-03-15 16:14:09 +01:00
|
|
|
stm32w_txbuf[0] = payload_len + CHECKSUM_LEN;
|
|
|
|
INIT_RETRY_CNT();
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
if(onoroff == OFF) {
|
|
|
|
PRINTF("stm32w: Radio is off, turning it on.\r\n");
|
|
|
|
ST_RadioWake();
|
|
|
|
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
|
|
|
}
|
2012-10-28 20:08:05 +01:00
|
|
|
#if RADIO_WAIT_FOR_PACKET_SENT
|
2013-03-15 16:14:09 +01:00
|
|
|
GET_LOCK();
|
2012-10-28 20:08:05 +01:00
|
|
|
#endif /* RADIO_WAIT_FOR_PACKET_SENT */
|
2013-03-15 16:14:09 +01:00
|
|
|
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);
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
#if DEBUG > 1
|
2013-03-15 16:14:09 +01:00
|
|
|
for(uint8_t c = 1; c <= stm32w_txbuf[0] - 2; c++) {
|
|
|
|
PRINTF("%x:", stm32w_txbuf[c]);
|
|
|
|
}
|
|
|
|
PRINTF("\r\n");
|
2012-10-28 20:08:05 +01:00
|
|
|
#endif
|
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
#if RADIO_WAIT_FOR_PACKET_SENT
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
if(wait_for_tx()) {
|
|
|
|
PRINTF("stm32w: unknown tx error.\r\n");
|
2010-10-25 11:03:38 +02:00
|
|
|
TO_PREV_STATE();
|
2012-10-28 20:08:05 +01:00
|
|
|
LED_TX_OFF();
|
|
|
|
RELEASE_LOCK();
|
2010-10-25 11:03:38 +02:00
|
|
|
return RADIO_TX_ERR;
|
2013-03-15 16:14:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LED_TX_OFF();
|
|
|
|
RELEASE_LOCK();
|
|
|
|
return RADIO_TX_ERR;
|
2012-10-28 20:08:05 +01:00
|
|
|
|
|
|
|
#else /* RADIO_WAIT_FOR_PACKET_SENT */
|
2013-03-15 16:14:09 +01:00
|
|
|
TO_PREV_STATE();
|
|
|
|
LED_TX_OFF();
|
|
|
|
return RADIO_TX_OK;
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
#endif /* RADIO_WAIT_FOR_PACKET_SENT */
|
2013-03-15 16:14:09 +01:00
|
|
|
}
|
2012-10-28 20:08:05 +01:00
|
|
|
|
|
|
|
#if RADIO_WAIT_FOR_PACKET_SENT
|
2013-03-15 16:14:09 +01:00
|
|
|
RELEASE_LOCK();
|
2012-10-28 20:08:05 +01:00
|
|
|
#endif /* RADIO_WAIT_FOR_PACKET_SENT */
|
2013-03-15 16:14:09 +01:00
|
|
|
TO_PREV_STATE();
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
PRINTF("stm32w: transmission never started.\r\n");
|
|
|
|
/* TODO: Do we have to retransmit? */
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
CLEAN_TXBUF();
|
|
|
|
LED_TX_OFF();
|
|
|
|
return RADIO_TX_ERR;
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
stm32w_radio_send(const void *payload, unsigned short payload_len)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
2013-03-15 16:14:09 +01:00
|
|
|
if (stm32w_radio_prepare(payload, payload_len) == RADIO_TX_ERR) {
|
2010-10-25 11:03:38 +02:00
|
|
|
return RADIO_TX_ERR;
|
2013-03-15 16:14:09 +01:00
|
|
|
}
|
2010-10-25 11:03:38 +02:00
|
|
|
return stm32w_radio_transmit(payload_len);
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
stm32w_radio_channel_clear(void)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
|
|
|
return ST_RadioChannelIsClear();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
stm32w_radio_receiving_packet(void)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
|
|
|
return receiving_packet;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
stm32w_radio_pending_packet(void)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
|
|
|
return !RXBUFS_EMPTY();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
stm32w_radio_off(void)
|
2012-10-28 20:08:05 +01:00
|
|
|
{
|
2010-10-25 11:03:38 +02:00
|
|
|
/* Any transmit or receive packets in progress are aborted.
|
|
|
|
* Waiting for end of transmission or reception have to be done.
|
|
|
|
*/
|
2013-03-15 16:14:09 +01:00
|
|
|
if(locked) {
|
|
|
|
PRINTF("stm32w: try to off while sending/receiving (lock=%u).\r\n",
|
|
|
|
locked);
|
2012-10-28 20:08:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* off only if there is no transmission or reception of packet. */
|
2013-03-15 16:14:09 +01:00
|
|
|
if(onoroff == ON && TXBUF_EMPTY() && !receiving_packet) {
|
2012-10-28 20:08:05 +01:00
|
|
|
LED_RDC_OFF();
|
2010-10-25 11:03:38 +02:00
|
|
|
ST_RadioSleep();
|
|
|
|
onoroff = OFF;
|
|
|
|
CLEAN_TXBUF();
|
2012-10-28 20:08:05 +01:00
|
|
|
CLEAN_RXBUFS();
|
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
ENERGEST_OFF(ENERGEST_TYPE_LISTEN);
|
|
|
|
}
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
stm32w_radio_on(void)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
2012-10-28 20:08:05 +01:00
|
|
|
PRINTF("stm32w: turn radio on\n");
|
2013-03-15 16:14:09 +01:00
|
|
|
if(onoroff == OFF) {
|
2012-10-28 20:08:05 +01:00
|
|
|
LED_RDC_ON();
|
2010-10-25 11:03:38 +02:00
|
|
|
ST_RadioWake();
|
|
|
|
onoroff = ON;
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
|
|
|
}
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
return 1;
|
|
|
|
}
|
2011-04-08 13:38:16 +02:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
int
|
|
|
|
stm32w_radio_is_on(void)
|
2011-04-08 13:38:16 +02:00
|
|
|
{
|
|
|
|
return onoroff == ON;
|
|
|
|
}
|
2010-10-25 11:03:38 +02:00
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
void
|
|
|
|
ST_RadioReceiveIsrCallback(uint8_t *packet,
|
|
|
|
boolean ackFramePendingSet,
|
|
|
|
uint32_t time, uint16_t errors, int8_t rssi)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
|
|
|
LED_RX_ON();
|
2012-10-28 20:08:05 +01:00
|
|
|
PRINTF("stm32w: incomming packet received\n");
|
2010-10-25 11:03:38 +02:00
|
|
|
receiving_packet = 0;
|
2013-03-15 16:14:09 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
/* Copy packet into the buffer. It is better to do this here. */
|
2013-03-15 16:14:09 +01:00
|
|
|
if(add_to_rxbuf(packet)) {
|
2010-10-25 11:03:38 +02:00
|
|
|
process_poll(&stm32w_radio_process);
|
|
|
|
last_rssi = rssi;
|
|
|
|
}
|
|
|
|
LED_RX_OFF();
|
2012-10-28 20:08:05 +01:00
|
|
|
GET_LOCK();
|
|
|
|
is_transmit_ack = 1;
|
|
|
|
/* Wait for sending ACK */
|
|
|
|
BUSYWAIT_UNTIL(!is_transmit_ack, RTIMER_SECOND / 1500);
|
|
|
|
RELEASE_LOCK();
|
|
|
|
}
|
2013-03-15 16:14:09 +01:00
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
ST_RadioTxAckIsrCallback(void)
|
2012-10-28 20:08:05 +01:00
|
|
|
{
|
2013-03-15 16:14:09 +01:00
|
|
|
/*
|
|
|
|
* This callback is for simplemac 1.1.0.
|
|
|
|
* Till now we block (RTIMER_SECOND / 1500)
|
|
|
|
* to prevent radio off during ACK transmission.
|
|
|
|
*/
|
2012-10-28 20:08:05 +01:00
|
|
|
is_transmit_ack = 0;
|
2013-03-15 16:14:09 +01:00
|
|
|
/* RELEASE_LOCK(); */
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
2013-03-15 16:14:09 +01:00
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
ST_RadioTransmitCompleteIsrCallback(StStatus status,
|
|
|
|
uint32_t txSyncTime, boolean framePending)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
2012-10-28 20:08:05 +01:00
|
|
|
ENERGEST_OFF(ENERGEST_TYPE_TRANSMIT);
|
2010-10-25 11:03:38 +02:00
|
|
|
ENERGEST_ON(ENERGEST_TYPE_LISTEN);
|
|
|
|
LED_TX_OFF();
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
last_tx_status = status;
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
if(status == ST_SUCCESS || status == ST_PHY_ACK_RECEIVED) {
|
|
|
|
CLEAN_TXBUF();
|
|
|
|
} else {
|
|
|
|
if(RETRY_CNT_GTZ()) {
|
|
|
|
|
|
|
|
/* 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 {
|
|
|
|
CLEAN_TXBUF();
|
|
|
|
LED_TX_OFF();
|
|
|
|
PRINTF("stm32w: retransmission failed.\r\n");
|
2012-10-28 20:08:05 +01:00
|
|
|
}
|
2013-03-15 16:14:09 +01:00
|
|
|
} else {
|
|
|
|
CLEAN_TXBUF();
|
|
|
|
}
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
/* Debug outputs. */
|
2013-03-15 16:14:09 +01:00
|
|
|
if(status == ST_SUCCESS || status == ST_PHY_ACK_RECEIVED) {
|
|
|
|
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");
|
|
|
|
} else if(status == ST_PHY_TX_CCA_FAIL) {
|
|
|
|
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");
|
|
|
|
} else {
|
|
|
|
PRINTF("stm32w: return status TX_END_INCOMPLETE\r\n");
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
|
|
|
}
|
2013-03-15 16:14:09 +01:00
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
boolean
|
|
|
|
ST_RadioDataPendingShortIdIsrCallback(uint16_t shortId)
|
|
|
|
{
|
2010-10-25 11:03:38 +02:00
|
|
|
receiving_packet = 1;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2013-03-15 16:14:09 +01:00
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
boolean
|
|
|
|
ST_RadioDataPendingLongIdIsrCallback(uint8_t * longId)
|
|
|
|
{
|
2010-10-25 11:03:38 +02:00
|
|
|
receiving_packet = 1;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
PROCESS_THREAD(stm32w_radio_process, ev, data)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
PROCESS_BEGIN();
|
|
|
|
PRINTF("stm32w_radio_process: started\r\n");
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
while(1) {
|
2012-10-28 20:08:05 +01:00
|
|
|
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL);
|
2010-10-25 11:03:38 +02:00
|
|
|
PRINTF("stm32w_radio_process: calling receiver callback\r\n");
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
#if DEBUG > 1
|
2013-03-15 16:14:09 +01:00
|
|
|
for(uint8_t c = 1; c <= RCVD_PACKET_LEN; c++) {
|
|
|
|
PRINTF("%x", stm32w_rxbuf[c]);
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
|
|
|
PRINTF("\r\n");
|
|
|
|
#endif
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2010-10-25 11:03:38 +02:00
|
|
|
packetbuf_clear();
|
|
|
|
len = stm32w_radio_read(packetbuf_dataptr(), PACKETBUF_SIZE);
|
|
|
|
if(len > 0) {
|
2012-10-28 20:08:05 +01:00
|
|
|
packetbuf_set_datalen(len);
|
2010-10-25 11:03:38 +02:00
|
|
|
NETSTACK_RDC.input();
|
|
|
|
}
|
2013-03-15 16:14:09 +01:00
|
|
|
if(!RXBUFS_EMPTY()) {
|
|
|
|
/*
|
|
|
|
* Some data packet still in rx buffer (this happens because process_poll
|
|
|
|
* doesn't queue requests), so stm32w_radio_process needs to be called
|
|
|
|
* again.
|
|
|
|
*/
|
2010-10-25 11:03:38 +02:00
|
|
|
process_poll(&stm32w_radio_process);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PROCESS_END();
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
stm32w_radio_read(void *buf, unsigned short bufsize)
|
2012-10-28 20:08:05 +01:00
|
|
|
{
|
2013-03-15 16:14:09 +01:00
|
|
|
return read_from_rxbuf(buf, bufsize);
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
void
|
|
|
|
ST_RadioOverflowIsrCallback(void)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
2012-10-28 20:08:05 +01:00
|
|
|
PRINTF("stm32w: radio overflow\r\n");
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
void
|
|
|
|
ST_RadioSfdSentIsrCallback(uint32_t sfdSentTime)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
void
|
|
|
|
ST_RadioMacTimerCompareIsrCallback(void)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
add_to_rxbuf(uint8_t *src)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
2013-03-15 16:14:09 +01:00
|
|
|
if(RXBUFS_FULL()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
memcpy(stm32w_rxbufs[last], src, src[0] + 1);
|
2010-10-25 11:03:38 +02:00
|
|
|
#if RADIO_RXBUFS > 1
|
2013-03-15 16:14:09 +01:00
|
|
|
last = (last + 1) % RADIO_RXBUFS;
|
|
|
|
if(first == -1) {
|
|
|
|
first = 0;
|
|
|
|
}
|
2010-10-25 11:03:38 +02:00
|
|
|
#endif
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
return 1;
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
static int
|
|
|
|
read_from_rxbuf(void *dest, unsigned short len)
|
2010-10-25 11:03:38 +02:00
|
|
|
{
|
2013-03-15 16:14:09 +01:00
|
|
|
if(RXBUFS_EMPTY()) { /* Buffers are all empty */
|
|
|
|
return 0;
|
|
|
|
}
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
if(stm32w_rxbufs[first][0] > len) { /* Too large packet for dest. */
|
|
|
|
len = 0;
|
|
|
|
} else {
|
|
|
|
len = stm32w_rxbufs[first][0];
|
|
|
|
memcpy(dest, stm32w_rxbufs[first] + 1, len);
|
|
|
|
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, last_rssi);
|
|
|
|
}
|
2012-10-28 20:08:05 +01:00
|
|
|
|
|
|
|
#if RADIO_RXBUFS > 1
|
2013-03-15 16:14:09 +01:00
|
|
|
ATOMIC(first = (first + 1) % RADIO_RXBUFS;
|
|
|
|
int first_tmp = first; if(first_tmp == last) {
|
|
|
|
CLEAN_RXBUFS();}
|
|
|
|
)
|
2010-10-25 11:03:38 +02:00
|
|
|
#else
|
2013-03-15 16:14:09 +01:00
|
|
|
CLEAN_RXBUFS();
|
2010-10-25 11:03:38 +02:00
|
|
|
#endif
|
2012-10-28 20:08:05 +01:00
|
|
|
|
2013-03-15 16:14:09 +01:00
|
|
|
return len;
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
2013-03-15 16:14:09 +01:00
|
|
|
short
|
|
|
|
last_packet_rssi()
|
|
|
|
{
|
|
|
|
return last_rssi;
|
2010-10-25 11:03:38 +02:00
|
|
|
}
|
2013-03-15 16:14:09 +01:00
|
|
|
/** @} */
|