mirror of
https://github.com/peterantypas/maiana.git
synced 2025-05-29 13:50:29 -07:00
Reduced RSSI sampling to improve RX yield
This commit is contained in:
parent
a565aaa16d
commit
dc421cd0ce
@ -24,8 +24,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include "CircularQueue.hpp"
|
#include "CircularQueue.hpp"
|
||||||
#include "Events.hpp"
|
#include "Events.hpp"
|
||||||
#include "FreeRTOS.h"
|
|
||||||
#include "queue.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -58,8 +56,6 @@ public:
|
|||||||
void dispatch();
|
void dispatch();
|
||||||
private:
|
private:
|
||||||
EventQueue();
|
EventQueue();
|
||||||
//QueueHandle_t mQueueHandle;
|
|
||||||
//StaticQueue_t mQueue;
|
|
||||||
CircularQueue<Event*> mISRQueue;
|
CircularQueue<Event*> mISRQueue;
|
||||||
CircularQueue<Event*> mTaskQueue;
|
CircularQueue<Event*> mTaskQueue;
|
||||||
map<EventConsumer *, uint32_t> mConsumers;
|
map<EventConsumer *, uint32_t> mConsumers;
|
||||||
|
@ -41,7 +41,8 @@ public:
|
|||||||
GPIO_TypeDef *dataPort,
|
GPIO_TypeDef *dataPort,
|
||||||
uint32_t dataPin,
|
uint32_t dataPin,
|
||||||
GPIO_TypeDef *clockPort,
|
GPIO_TypeDef *clockPort,
|
||||||
uint32_t clockPin);
|
uint32_t clockPin,
|
||||||
|
int chipId);
|
||||||
|
|
||||||
virtual ~RFIC();
|
virtual ~RFIC();
|
||||||
|
|
||||||
@ -71,6 +72,7 @@ protected:
|
|||||||
uint8_t mLastNRZIBit;
|
uint8_t mLastNRZIBit;
|
||||||
BitState mBitState;
|
BitState mBitState;
|
||||||
bool mSPIBusy;
|
bool mSPIBusy;
|
||||||
|
uint32_t mChipID;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* RFIC_HPP_ */
|
#endif /* RFIC_HPP_ */
|
||||||
|
@ -38,7 +38,8 @@ public:
|
|||||||
GPIO_TypeDef *dataPort,
|
GPIO_TypeDef *dataPort,
|
||||||
uint32_t dataPin,
|
uint32_t dataPin,
|
||||||
GPIO_TypeDef *clockPort,
|
GPIO_TypeDef *clockPort,
|
||||||
uint32_t clockPin);
|
uint32_t clockPin,
|
||||||
|
int chipId);
|
||||||
|
|
||||||
virtual ~Receiver();
|
virtual ~Receiver();
|
||||||
|
|
||||||
@ -68,6 +69,7 @@ protected:
|
|||||||
uint16_t mSlotBitNumber;
|
uint16_t mSlotBitNumber;
|
||||||
bool mSwitchAtNextSlot;
|
bool mSwitchAtNextSlot;
|
||||||
VHFChannel mSwitchToChannel;
|
VHFChannel mSwitchToChannel;
|
||||||
|
uint32_t mTimeSlot = 0xffffffff;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* RECEIVER_HPP_ */
|
#endif /* RECEIVER_HPP_ */
|
||||||
|
@ -36,7 +36,8 @@ public:
|
|||||||
GPIO_TypeDef *dataPort,
|
GPIO_TypeDef *dataPort,
|
||||||
uint32_t dataPin,
|
uint32_t dataPin,
|
||||||
GPIO_TypeDef *clockPort,
|
GPIO_TypeDef *clockPort,
|
||||||
uint32_t clockPin);
|
uint32_t clockPin,
|
||||||
|
int chipId);
|
||||||
|
|
||||||
|
|
||||||
void onBitClock();
|
void onBitClock();
|
||||||
|
@ -33,7 +33,8 @@ RFIC::RFIC(GPIO_TypeDef *sdnPort,
|
|||||||
GPIO_TypeDef *dataPort,
|
GPIO_TypeDef *dataPort,
|
||||||
uint32_t dataPin,
|
uint32_t dataPin,
|
||||||
GPIO_TypeDef *clockPort,
|
GPIO_TypeDef *clockPort,
|
||||||
uint32_t clockPin)
|
uint32_t clockPin,
|
||||||
|
int chipID)
|
||||||
{
|
{
|
||||||
mSDNP = sdnPort;
|
mSDNP = sdnPort;
|
||||||
mCSPort = csPort;
|
mCSPort = csPort;
|
||||||
@ -47,6 +48,7 @@ RFIC::RFIC(GPIO_TypeDef *sdnPort,
|
|||||||
|
|
||||||
//mRSSIAdjustment = 0;
|
//mRSSIAdjustment = 0;
|
||||||
mSPIBusy = false;
|
mSPIBusy = false;
|
||||||
|
mChipID = chipID;
|
||||||
|
|
||||||
if ( !isInitialized() )
|
if ( !isInitialized() )
|
||||||
powerOnReset();
|
powerOnReset();
|
||||||
@ -70,7 +72,7 @@ inline void RFIC::spiOff()
|
|||||||
bool RFIC::sendCmd(uint8_t cmd, void* params, uint8_t paramLen, void* result, uint8_t resultLen)
|
bool RFIC::sendCmd(uint8_t cmd, void* params, uint8_t paramLen, void* result, uint8_t resultLen)
|
||||||
{
|
{
|
||||||
mSPIBusy = true;
|
mSPIBusy = true;
|
||||||
|
//bsp_signal_high();
|
||||||
spiOn();
|
spiOn();
|
||||||
|
|
||||||
bsp_tx_spi_byte(cmd);
|
bsp_tx_spi_byte(cmd);
|
||||||
@ -81,10 +83,14 @@ bool RFIC::sendCmd(uint8_t cmd, void* params, uint8_t paramLen, void* result, ui
|
|||||||
bsp_tx_spi_byte(b[i]);
|
bsp_tx_spi_byte(b[i]);
|
||||||
}
|
}
|
||||||
spiOff();
|
spiOff();
|
||||||
|
//bsp_signal_low();
|
||||||
|
|
||||||
|
//bsp_signal_high();
|
||||||
while ( readSPIResponse(result, resultLen) == false)
|
while ( readSPIResponse(result, resultLen) == false)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
//bsp_signal_low();
|
||||||
|
|
||||||
mSPIBusy = false;
|
mSPIBusy = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ void RadioManager::init()
|
|||||||
mTransceiverIC = new Transceiver(SDN1_PORT, SDN1_PIN,
|
mTransceiverIC = new Transceiver(SDN1_PORT, SDN1_PIN,
|
||||||
CS1_PORT, CS1_PIN,
|
CS1_PORT, CS1_PIN,
|
||||||
TRX_IC_DATA_PORT, TRX_IC_DATA_PIN,
|
TRX_IC_DATA_PORT, TRX_IC_DATA_PIN,
|
||||||
TRX_IC_CLK_PORT, TRX_IC_CLK_PIN);
|
TRX_IC_CLK_PORT, TRX_IC_CLK_PIN, 0);
|
||||||
mTransceiverIC->init();
|
mTransceiverIC->init();
|
||||||
|
|
||||||
#ifndef TX_TEST_MODE
|
#ifndef TX_TEST_MODE
|
||||||
@ -64,7 +64,7 @@ void RadioManager::init()
|
|||||||
mReceiverIC = new Receiver(SDN2_PORT, SDN2_PIN,
|
mReceiverIC = new Receiver(SDN2_PORT, SDN2_PIN,
|
||||||
CS2_PORT, CS2_PIN,
|
CS2_PORT, CS2_PIN,
|
||||||
RX_IC_DATA_PORT, RX_IC_DATA_PIN,
|
RX_IC_DATA_PORT, RX_IC_DATA_PIN,
|
||||||
RX_IC_CLK_PORT, RX_IC_CLK_PIN);
|
RX_IC_CLK_PORT, RX_IC_CLK_PIN, 1);
|
||||||
mReceiverIC->init();
|
mReceiverIC->init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
|
|
||||||
Receiver::Receiver(GPIO_TypeDef *sdnPort, uint32_t sdnPin, GPIO_TypeDef *csPort, uint32_t csPin,
|
Receiver::Receiver(GPIO_TypeDef *sdnPort, uint32_t sdnPin, GPIO_TypeDef *csPort, uint32_t csPin,
|
||||||
GPIO_TypeDef *dataPort, uint32_t dataPin,
|
GPIO_TypeDef *dataPort, uint32_t dataPin,
|
||||||
GPIO_TypeDef *clockPort, uint32_t clockPin)
|
GPIO_TypeDef *clockPort, uint32_t clockPin, int chipId)
|
||||||
: RFIC(sdnPort, sdnPin, csPort, csPin, dataPort, dataPin, clockPort, clockPin)
|
: RFIC(sdnPort, sdnPin, csPort, csPin, dataPort, dataPin, clockPort, clockPin, chipId)
|
||||||
{
|
{
|
||||||
mSlotBitNumber = 0xffff;
|
mSlotBitNumber = 0xffff;
|
||||||
mSwitchAtNextSlot = false;
|
mSwitchAtNextSlot = false;
|
||||||
@ -85,7 +85,6 @@ void Receiver::startListening(VHFChannel channel, bool reconfigGPIOs)
|
|||||||
configureGPIOsForRX();
|
configureGPIOsForRX();
|
||||||
}
|
}
|
||||||
|
|
||||||
// This takes 180us
|
|
||||||
mChannel = channel;
|
mChannel = channel;
|
||||||
RX_OPTIONS options;
|
RX_OPTIONS options;
|
||||||
options.channel = AIS_CHANNELS[channel].ordinal;
|
options.channel = AIS_CHANNELS[channel].ordinal;
|
||||||
@ -119,8 +118,7 @@ void Receiver::resetBitScanner()
|
|||||||
* TODO: Under a worst case scenario, this interrupt service method
|
* TODO: Under a worst case scenario, this interrupt service method
|
||||||
* can take up to 320us to complete (that's 4 clock bits!!!)
|
* can take up to 320us to complete (that's 4 clock bits!!!)
|
||||||
*
|
*
|
||||||
* Re-architecting will be necessary to resolve this, and it will almost certainly
|
* Re-architecting will be necessary to resolve this.
|
||||||
* require ditching FreeRTOS in favor of "bare metal".
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Receiver::onBitClock()
|
void Receiver::onBitClock()
|
||||||
@ -133,7 +131,8 @@ void Receiver::onBitClock()
|
|||||||
|
|
||||||
uint8_t bit = HAL_GPIO_ReadPin(mDataPort, mDataPin);
|
uint8_t bit = HAL_GPIO_ReadPin(mDataPort, mDataPin);
|
||||||
processNRZIBit(bit);
|
processNRZIBit(bit);
|
||||||
if ( mSlotBitNumber != 0xffff && mSlotBitNumber++ == CCA_SLOT_BIT - 1 )
|
if ( mTimeSlot != 0xffffffff && mSlotBitNumber != 0xffff &&
|
||||||
|
mTimeSlot % 17 == mChipID && mSlotBitNumber++ == CCA_SLOT_BIT - 1 )
|
||||||
{
|
{
|
||||||
uint8_t rssi = reportRSSI();
|
uint8_t rssi = reportRSSI();
|
||||||
mRXPacket->setRSSI(rssi);
|
mRXPacket->setRSSI(rssi);
|
||||||
@ -149,6 +148,7 @@ void Receiver::timeSlotStarted(uint32_t slot)
|
|||||||
//DBG(" **** WTF??? Transmitting past slot boundary? **** \r\n");
|
//DBG(" **** WTF??? Transmitting past slot boundary? **** \r\n");
|
||||||
|
|
||||||
mSlotBitNumber = 0;
|
mSlotBitNumber = 0;
|
||||||
|
mTimeSlot = slot;
|
||||||
if ( mBitState == BIT_STATE_IN_PACKET )
|
if ( mBitState == BIT_STATE_IN_PACKET )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -284,9 +284,12 @@ void Receiver::pushPacket()
|
|||||||
|
|
||||||
uint8_t Receiver::reportRSSI()
|
uint8_t Receiver::reportRSSI()
|
||||||
{
|
{
|
||||||
|
bsp_signal_high();
|
||||||
uint8_t rssi = readRSSI();
|
uint8_t rssi = readRSSI();
|
||||||
|
bsp_signal_low();
|
||||||
char channel = AIS_CHANNELS[mChannel].designation;
|
char channel = AIS_CHANNELS[mChannel].designation;
|
||||||
NoiseFloorDetector::instance().report(channel, rssi);
|
NoiseFloorDetector::instance().report(channel, rssi);
|
||||||
|
|
||||||
return rssi;
|
return rssi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
|
|
||||||
Transceiver::Transceiver(GPIO_TypeDef *sdnPort, uint32_t sdnPin, GPIO_TypeDef *csPort,
|
Transceiver::Transceiver(GPIO_TypeDef *sdnPort, uint32_t sdnPin, GPIO_TypeDef *csPort,
|
||||||
uint32_t csPin, GPIO_TypeDef *dataPort, uint32_t dataPin,
|
uint32_t csPin, GPIO_TypeDef *dataPort, uint32_t dataPin,
|
||||||
GPIO_TypeDef *clockPort, uint32_t clockPin)
|
GPIO_TypeDef *clockPort, uint32_t clockPin, int chipId)
|
||||||
: Receiver(sdnPort, sdnPin, csPort, csPin, dataPort, dataPin, clockPort, clockPin)
|
: Receiver(sdnPort, sdnPin, csPort, csPin, dataPort, dataPin, clockPort, clockPin, chipId)
|
||||||
{
|
{
|
||||||
mTXPacket = NULL;
|
mTXPacket = NULL;
|
||||||
EventQueue::instance().addObserver(this, CLOCK_EVENT);
|
EventQueue::instance().addObserver(this, CLOCK_EVENT);
|
||||||
|
@ -184,7 +184,7 @@ void bsp_hw_init()
|
|||||||
|
|
||||||
HAL_TIM_Base_Init(&htim2);
|
HAL_TIM_Base_Init(&htim2);
|
||||||
|
|
||||||
HAL_NVIC_SetPriority(TIM2_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(TIM2_IRQn, 6, 0);
|
||||||
HAL_NVIC_EnableIRQ(TIM2_IRQn);
|
HAL_NVIC_EnableIRQ(TIM2_IRQn);
|
||||||
|
|
||||||
// I2C
|
// I2C
|
||||||
@ -220,11 +220,11 @@ void bsp_hw_init()
|
|||||||
|
|
||||||
|
|
||||||
// RF IC clock interrupts
|
// RF IC clock interrupts
|
||||||
HAL_NVIC_SetPriority(EXTI1_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(EXTI1_IRQn, 1, 0);
|
||||||
HAL_NVIC_EnableIRQ(EXTI1_IRQn);
|
HAL_NVIC_EnableIRQ(EXTI1_IRQn);
|
||||||
|
|
||||||
|
|
||||||
HAL_NVIC_SetPriority(EXTI3_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(EXTI3_IRQn, 1, 0);
|
||||||
HAL_NVIC_EnableIRQ(EXTI3_IRQn);
|
HAL_NVIC_EnableIRQ(EXTI3_IRQn);
|
||||||
|
|
||||||
// This is our HAL tick timer now
|
// This is our HAL tick timer now
|
||||||
@ -325,6 +325,10 @@ void HAL_MspInit(void)
|
|||||||
|
|
||||||
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
|
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some of these interrupts will be managed and configured in FreeRTOS
|
||||||
|
*/
|
||||||
|
|
||||||
/* System interrupt init*/
|
/* System interrupt init*/
|
||||||
/* MemoryManagement_IRQn interrupt configuration */
|
/* MemoryManagement_IRQn interrupt configuration */
|
||||||
HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
|
HAL_NVIC_SetPriority(MemoryManagement_IRQn, 0, 0);
|
||||||
@ -333,13 +337,13 @@ void HAL_MspInit(void)
|
|||||||
/* UsageFault_IRQn interrupt configuration */
|
/* UsageFault_IRQn interrupt configuration */
|
||||||
HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
|
HAL_NVIC_SetPriority(UsageFault_IRQn, 0, 0);
|
||||||
/* SVCall_IRQn interrupt configuration */
|
/* SVCall_IRQn interrupt configuration */
|
||||||
HAL_NVIC_SetPriority(SVCall_IRQn, 0, 0);
|
//HAL_NVIC_SetPriority(SVCall_IRQn, 2, 0);
|
||||||
/* DebugMonitor_IRQn interrupt configuration */
|
/* DebugMonitor_IRQn interrupt configuration */
|
||||||
HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
|
HAL_NVIC_SetPriority(DebugMonitor_IRQn, 0, 0);
|
||||||
/* PendSV_IRQn interrupt configuration */
|
/* PendSV_IRQn interrupt configuration */
|
||||||
HAL_NVIC_SetPriority(PendSV_IRQn, 0, 0);
|
//HAL_NVIC_SetPriority(PendSV_IRQn, 2, 0);
|
||||||
/* SysTick_IRQn interrupt configuration */
|
/* SysTick_IRQn interrupt configuration */
|
||||||
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
|
//HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
|
||||||
|
|
||||||
/* USER CODE BEGIN MspInit 1 */
|
/* USER CODE BEGIN MspInit 1 */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user