Enable RX_START interrupt and read rssi at end of preamble when not using energy detect register
This commit is contained in:
parent
0a4a0ffb32
commit
c784e8bc46
3 changed files with 30 additions and 13 deletions
|
@ -98,6 +98,7 @@
|
||||||
* \see hal_get_system_time
|
* \see hal_get_system_time
|
||||||
*/
|
*/
|
||||||
static uint16_t hal_system_time = 0;
|
static uint16_t hal_system_time = 0;
|
||||||
|
volatile extern signed char rf230_last_rssi;
|
||||||
|
|
||||||
/*Flag section.*/
|
/*Flag section.*/
|
||||||
//static uint8_t volatile hal_bat_low_flag; /**< BAT_LOW flag. */
|
//static uint8_t volatile hal_bat_low_flag; /**< BAT_LOW flag. */
|
||||||
|
@ -751,6 +752,11 @@ HAL_RF230_ISR()
|
||||||
/*Handle the incomming interrupt. Prioritized.*/
|
/*Handle the incomming interrupt. Prioritized.*/
|
||||||
if ((interrupt_source & HAL_RX_START_MASK)){
|
if ((interrupt_source & HAL_RX_START_MASK)){
|
||||||
INTERRUPTDEBUG(10);
|
INTERRUPTDEBUG(10);
|
||||||
|
/* Save RSSI for this packet if not in extended mode, scaling to 1dB resolution (avoiding multiply) */
|
||||||
|
#if !RF230_CONF_AUTOACK
|
||||||
|
rf230_last_rssi = hal_subregister_read(SR_RSSI);
|
||||||
|
rf230_last_rssi = (rf230_last_rssi <<1) + rf230_last_rssi;
|
||||||
|
#endif
|
||||||
// if(rx_start_callback != NULL){
|
// if(rx_start_callback != NULL){
|
||||||
// /* Read Frame length and call rx_start callback. */
|
// /* Read Frame length and call rx_start callback. */
|
||||||
// HAL_SPI_TRANSFER_OPEN();
|
// HAL_SPI_TRANSFER_OPEN();
|
||||||
|
@ -779,14 +785,10 @@ HAL_RF230_ISR()
|
||||||
#ifdef RF230_MIN_RX_POWER
|
#ifdef RF230_MIN_RX_POWER
|
||||||
/* Discard packets weaker than the minimum if defined. This is for testing miniature meshes.*/
|
/* Discard packets weaker than the minimum if defined. This is for testing miniature meshes.*/
|
||||||
/* Save the rssi for printing in the main loop */
|
/* Save the rssi for printing in the main loop */
|
||||||
volatile extern signed char rf230_last_rssi;
|
|
||||||
#if RF230_CONF_AUTOACK
|
#if RF230_CONF_AUTOACK
|
||||||
rf230_last_rssi=hal_subregister_read(SR_ED_LEVEL);
|
rf230_last_rssi=hal_subregister_read(SR_ED_LEVEL);
|
||||||
if (rf230_last_rssi >= RF230_MIN_RX_POWER) {
|
|
||||||
#else
|
|
||||||
rf230_last_rssi=hal_subregister_read(SR_RSSI);
|
|
||||||
if (rf230_last_rssi >= RF230_MIN_RX_POWER/3) {
|
|
||||||
#endif
|
#endif
|
||||||
|
if (rf230_last_rssi >= RF230_MIN_RX_POWER) {
|
||||||
#endif
|
#endif
|
||||||
// hal_frame_read(&rxframe, NULL);
|
// hal_frame_read(&rxframe, NULL);
|
||||||
hal_frame_read(&rxframe);
|
hal_frame_read(&rxframe);
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* @(#)$Id: rf230bb.c,v 1.17 2010/12/05 17:28:29 dak664 Exp $
|
* @(#)$Id: rf230bb.c,v 1.18 2010/12/14 22:34:18 dak664 Exp $
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* This code is almost device independent and should be easy to port.
|
* This code is almost device independent and should be easy to port.
|
||||||
|
@ -106,7 +106,7 @@ struct timestamp {
|
||||||
#if JACKDAW
|
#if JACKDAW
|
||||||
#define RADIOALWAYSON 1
|
#define RADIOALWAYSON 1
|
||||||
#else
|
#else
|
||||||
#define RADIOALWAYSON 1
|
//#define RADIOALWAYSON 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
|
@ -415,7 +415,10 @@ rf230_set_promiscuous_mode(bool isPromiscuous) {
|
||||||
if(isPromiscuous) {
|
if(isPromiscuous) {
|
||||||
is_promiscuous = true;
|
is_promiscuous = true;
|
||||||
#if RF230_CONF_AUTOACK
|
#if RF230_CONF_AUTOACK
|
||||||
|
/* For now only do promiscuous in Macintosh build */
|
||||||
|
#if USB_CONF_MACINTOSH
|
||||||
radio_set_trx_state(RX_ON);
|
radio_set_trx_state(RX_ON);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
is_promiscuous = false;
|
is_promiscuous = false;
|
||||||
|
@ -463,7 +466,12 @@ on(void)
|
||||||
rf230_waitidle();
|
rf230_waitidle();
|
||||||
|
|
||||||
#if RF230_CONF_AUTOACK
|
#if RF230_CONF_AUTOACK
|
||||||
|
/* For now only do promiscuous on Mac build */
|
||||||
|
#if USB_CONF_MACINTOSH
|
||||||
radio_set_trx_state(is_promiscuous?RX_ON:RX_AACK_ON);
|
radio_set_trx_state(is_promiscuous?RX_ON:RX_AACK_ON);
|
||||||
|
#else
|
||||||
|
radio_set_trx_state(RX_AACK_ON);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
radio_set_trx_state(RX_ON);
|
radio_set_trx_state(RX_ON);
|
||||||
#endif
|
#endif
|
||||||
|
@ -563,7 +571,7 @@ rf230_init(void)
|
||||||
PRINTF("rf230: Version %u, ID %u\n",tvers,tmanu);
|
PRINTF("rf230: Version %u, ID %u\n",tvers,tmanu);
|
||||||
hal_register_write(RG_IRQ_MASK, RF230_SUPPORTED_INTERRUPT_MASK);
|
hal_register_write(RG_IRQ_MASK, RF230_SUPPORTED_INTERRUPT_MASK);
|
||||||
|
|
||||||
/* Set up number of automatic retries */
|
/* Set up number of automatic retries 0-15 (0 implies PLL_ON sends instead of the extended TX_ARET mode */
|
||||||
hal_subregister_write(SR_MAX_FRAME_RETRIES, RF230_CONF_AUTORETRIES );
|
hal_subregister_write(SR_MAX_FRAME_RETRIES, RF230_CONF_AUTORETRIES );
|
||||||
|
|
||||||
/* Use automatic CRC unless manual is specified */
|
/* Use automatic CRC unless manual is specified */
|
||||||
|
@ -1124,7 +1132,8 @@ if (RF230_receive_on) {
|
||||||
#if RF230_CONF_AUTOACK
|
#if RF230_CONF_AUTOACK
|
||||||
rf230_last_rssi = hal_subregister_read(SR_ED_LEVEL); //0-84 resolution 1 dB
|
rf230_last_rssi = hal_subregister_read(SR_ED_LEVEL); //0-84 resolution 1 dB
|
||||||
#else
|
#else
|
||||||
rf230_last_rssi = 3*hal_subregister_read(SR_RSSI); //0-28 resolution 3 dB
|
/* last_rssi will have been set at RX_START interrupt */
|
||||||
|
// rf230_last_rssi = 3*hal_subregister_read(SR_RSSI); //0-28 resolution 3 dB
|
||||||
#endif
|
#endif
|
||||||
#endif /* speed vs. generality */
|
#endif /* speed vs. generality */
|
||||||
|
|
||||||
|
@ -1202,6 +1211,7 @@ rf230_get_txpower(void)
|
||||||
}
|
}
|
||||||
return power;
|
return power;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
uint8_t
|
uint8_t
|
||||||
rf230_get_raw_rssi(void)
|
rf230_get_raw_rssi(void)
|
||||||
|
@ -1221,7 +1231,8 @@ rf230_get_raw_rssi(void)
|
||||||
if ((state==RX_AACK_ON) || (state==BUSY_RX_AACK)) {
|
if ((state==RX_AACK_ON) || (state==BUSY_RX_AACK)) {
|
||||||
rssi = hal_subregister_read(SR_ED_LEVEL); //0-84, resolution 1 dB
|
rssi = hal_subregister_read(SR_ED_LEVEL); //0-84, resolution 1 dB
|
||||||
} else {
|
} else {
|
||||||
rssi = 3*hal_subregister_read(SR_RSSI); //0-28, resolution 3 dB
|
rssi = hal_subregister_read(SR_RSSI); //0-28, resolution 3 dB
|
||||||
|
rssi = (rssi << 1) + rssi; //fast multiply by 3
|
||||||
}
|
}
|
||||||
|
|
||||||
if(radio_was_off) {
|
if(radio_was_off) {
|
||||||
|
@ -1229,6 +1240,7 @@ rf230_get_raw_rssi(void)
|
||||||
}
|
}
|
||||||
return rssi;
|
return rssi;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
rf230_cca(void)
|
rf230_cca(void)
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
* \file
|
* \file
|
||||||
* \brief This file contains radio driver code.
|
* \brief This file contains radio driver code.
|
||||||
*
|
*
|
||||||
* $Id: rf230bb.h,v 1.4 2010/12/03 20:42:01 dak664 Exp $
|
* $Id: rf230bb.h,v 1.5 2010/12/14 22:34:18 dak664 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef RADIO_H
|
#ifndef RADIO_H
|
||||||
|
@ -61,7 +61,10 @@
|
||||||
#define RF230_REVA ( 1 )
|
#define RF230_REVA ( 1 )
|
||||||
#define RF230_REVB ( 2 )
|
#define RF230_REVB ( 2 )
|
||||||
#define SUPPORTED_MANUFACTURER_ID ( 31 )
|
#define SUPPORTED_MANUFACTURER_ID ( 31 )
|
||||||
#define RF230_SUPPORTED_INTERRUPT_MASK ( 0x0C )
|
/* RF230 does not support RX_START interrupts in extended mode, but it seems harmless to always enable it. */
|
||||||
|
/* In non-extended mode this allows RX_START to sample the RF rssi at the end of the preamble */
|
||||||
|
//#define RF230_SUPPORTED_INTERRUPT_MASK ( 0x0C ) //disable RX_START
|
||||||
|
#define RF230_SUPPORTED_INTERRUPT_MASK ( 0x0F )
|
||||||
|
|
||||||
#define RF230_MIN_CHANNEL ( 11 )
|
#define RF230_MIN_CHANNEL ( 11 )
|
||||||
#define RF230_MAX_CHANNEL ( 26 )
|
#define RF230_MAX_CHANNEL ( 26 )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue