mirror of
https://github.com/peterantypas/maiana.git
synced 2025-06-02 15:50:14 -07:00
Checkpoint. Best RX performance possible with current architecture
This commit is contained in:
parent
8ab5a8b322
commit
34f7543b9d
@ -44,12 +44,12 @@ public:
|
|||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
VHFChannel channel();
|
VHFChannel channel();
|
||||||
virtual void startReceiving(VHFChannel channel);
|
virtual void startReceiving(VHFChannel channel, bool reconfigGPIOs);
|
||||||
virtual void onBitClock();
|
virtual void onBitClock();
|
||||||
virtual void timeSlotStarted(uint32_t slot);
|
virtual void timeSlotStarted(uint32_t slot);
|
||||||
void switchToChannel(VHFChannel channel);
|
void switchToChannel(VHFChannel channel);
|
||||||
protected:
|
protected:
|
||||||
void startListening(VHFChannel channel);
|
void startListening(VHFChannel channel, bool reconfigGPIOs);
|
||||||
bool addBit(uint8_t bit);
|
bool addBit(uint8_t bit);
|
||||||
void resetBitScanner();
|
void resetBitScanner();
|
||||||
uint8_t reportRSSI();
|
uint8_t reportRSSI();
|
||||||
|
@ -43,8 +43,8 @@ public:
|
|||||||
void timeSlotStarted(uint32_t slot);
|
void timeSlotStarted(uint32_t slot);
|
||||||
void assignTXPacket(TXPacket *p);
|
void assignTXPacket(TXPacket *p);
|
||||||
TXPacket *assignedTXPacket();
|
TXPacket *assignedTXPacket();
|
||||||
void startReceiving(VHFChannel channel);
|
void startReceiving(VHFChannel channel, bool reconfigGPIOs);
|
||||||
void startListening(VHFChannel channel);
|
void startListening(VHFChannel channel, bool reconfigGPIOs);
|
||||||
void transmitCW(VHFChannel channel);
|
void transmitCW(VHFChannel channel);
|
||||||
void processEvent(const Event &);
|
void processEvent(const Event &);
|
||||||
|
|
||||||
|
@ -82,10 +82,10 @@ void RadioManager::start()
|
|||||||
//DBG("Radio Manager starting\r\n");
|
//DBG("Radio Manager starting\r\n");
|
||||||
configureInterrupts();
|
configureInterrupts();
|
||||||
if ( mTransceiverIC )
|
if ( mTransceiverIC )
|
||||||
mTransceiverIC->startReceiving(CH_87);
|
mTransceiverIC->startReceiving(CH_87, true);
|
||||||
|
|
||||||
if ( mReceiverIC )
|
if ( mReceiverIC )
|
||||||
mReceiverIC->startReceiving(CH_88);
|
mReceiverIC->startReceiving(CH_88, true);
|
||||||
|
|
||||||
GPS::instance().setDelegate(this);
|
GPS::instance().setDelegate(this);
|
||||||
//DBG("Radio Manager started\r\n");
|
//DBG("Radio Manager started\r\n");
|
||||||
|
@ -63,10 +63,10 @@ bool Receiver::init()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::startReceiving(VHFChannel channel)
|
void Receiver::startReceiving(VHFChannel channel, bool reconfigGPIOs)
|
||||||
{
|
{
|
||||||
mChannel = channel;
|
mChannel = channel;
|
||||||
startListening(mChannel);
|
startListening(mChannel, reconfigGPIOs);
|
||||||
resetBitScanner();
|
resetBitScanner();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,11 +77,15 @@ void Receiver::switchToChannel(VHFChannel channel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This is a really, really long operation - over 320us !!!
|
// TODO: This is a really, really long operation - over 320us !!!
|
||||||
void Receiver::startListening(VHFChannel channel)
|
void Receiver::startListening(VHFChannel channel, bool reconfigGPIOs)
|
||||||
{
|
{
|
||||||
//bsp_signal_high();
|
if ( reconfigGPIOs )
|
||||||
|
{
|
||||||
|
// This takes about 140us
|
||||||
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;
|
||||||
@ -91,8 +95,12 @@ void Receiver::startListening(VHFChannel channel)
|
|||||||
options.next_state2 = 0;
|
options.next_state2 = 0;
|
||||||
options.next_state3 = 0;
|
options.next_state3 = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This can take up to 220us, that's 3 bit clocks!!!
|
||||||
|
*/
|
||||||
|
bsp_signal_high();
|
||||||
sendCmd (START_RX, &options, sizeof options, NULL, 0);
|
sendCmd (START_RX, &options, sizeof options, NULL, 0);
|
||||||
//bsp_signal_low();
|
bsp_signal_low();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Receiver::resetBitScanner()
|
void Receiver::resetBitScanner()
|
||||||
@ -107,6 +115,14 @@ void Receiver::resetBitScanner()
|
|||||||
mRXPacket->reset();
|
mRXPacket->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: Under a worst case scenario, this interrupt service method
|
||||||
|
* 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
|
||||||
|
* require ditching FreeRTOS in favor of "bare metal".
|
||||||
|
*/
|
||||||
|
|
||||||
void Receiver::onBitClock()
|
void Receiver::onBitClock()
|
||||||
{
|
{
|
||||||
// Don't waste time processing bits when the transceiver is transmitting
|
// Don't waste time processing bits when the transceiver is transmitting
|
||||||
@ -140,7 +156,7 @@ void Receiver::timeSlotStarted(uint32_t slot)
|
|||||||
if ( mSwitchAtNextSlot )
|
if ( mSwitchAtNextSlot )
|
||||||
{
|
{
|
||||||
mSwitchAtNextSlot = false;
|
mSwitchAtNextSlot = false;
|
||||||
startReceiving(mSwitchToChannel);
|
startReceiving(mSwitchToChannel, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +194,7 @@ void Receiver::processNRZIBit(uint8_t bit)
|
|||||||
if ( mRXPacket->size() >= MAX_AIS_RX_PACKET_SIZE )
|
if ( mRXPacket->size() >= MAX_AIS_RX_PACKET_SIZE )
|
||||||
{
|
{
|
||||||
// Start over
|
// Start over
|
||||||
startReceiving(mChannel);
|
startReceiving(mChannel, false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -186,7 +202,7 @@ void Receiver::processNRZIBit(uint8_t bit)
|
|||||||
if ( mOneBitCount >= 7 )
|
if ( mOneBitCount >= 7 )
|
||||||
{
|
{
|
||||||
// Bad packet!
|
// Bad packet!
|
||||||
startReceiving(mChannel);
|
startReceiving(mChannel, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +216,7 @@ void Receiver::processNRZIBit(uint8_t bit)
|
|||||||
{
|
{
|
||||||
mBitState = BIT_STATE_PREAMBLE_SYNC;
|
mBitState = BIT_STATE_PREAMBLE_SYNC;
|
||||||
pushPacket();
|
pushPacket();
|
||||||
startReceiving(mChannel);
|
startReceiving(mChannel, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,7 @@ void Transceiver::processEvent(const Event &e)
|
|||||||
|
|
||||||
void Transceiver::transmitCW(VHFChannel channel)
|
void Transceiver::transmitCW(VHFChannel channel)
|
||||||
{
|
{
|
||||||
startReceiving(channel);
|
startReceiving(channel, false);
|
||||||
configureGPIOsForTX(TX_POWER_LEVEL);
|
configureGPIOsForTX(TX_POWER_LEVEL);
|
||||||
SET_PROPERTY_PARAMS p;
|
SET_PROPERTY_PARAMS p;
|
||||||
p.Group = 0x20;
|
p.Group = 0x20;
|
||||||
@ -155,9 +155,9 @@ void Transceiver::configureGPIOsForTX(tx_power_level powerLevel)
|
|||||||
setTXPower(powerLevel);
|
setTXPower(powerLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transceiver::startListening(VHFChannel channel)
|
void Transceiver::startListening(VHFChannel channel, bool reconfigGPIOs)
|
||||||
{
|
{
|
||||||
Receiver::startListening(channel);
|
Receiver::startListening(channel, reconfigGPIOs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transceiver::assignTXPacket(TXPacket *p)
|
void Transceiver::assignTXPacket(TXPacket *p)
|
||||||
@ -231,7 +231,7 @@ void Transceiver::onBitClock()
|
|||||||
if ( mTXPacket->eof() )
|
if ( mTXPacket->eof() )
|
||||||
{
|
{
|
||||||
mLastTXTime = mUTC;
|
mLastTXTime = mUTC;
|
||||||
startReceiving(mChannel);
|
startReceiving(mChannel, true);
|
||||||
gRadioState = RADIO_RECEIVING;
|
gRadioState = RADIO_RECEIVING;
|
||||||
reportTXEvent();
|
reportTXEvent();
|
||||||
TXPacketPool::instance().deleteTXPacket(mTXPacket);
|
TXPacketPool::instance().deleteTXPacket(mTXPacket);
|
||||||
@ -267,7 +267,7 @@ void Transceiver::timeSlotStarted(uint32_t slot)
|
|||||||
|
|
||||||
// Switch channel if we have a transmission scheduled and we're not on the right channel
|
// Switch channel if we have a transmission scheduled and we're not on the right channel
|
||||||
if ( gRadioState == RADIO_RECEIVING && mTXPacket && mTXPacket->channel() != mChannel )
|
if ( gRadioState == RADIO_RECEIVING && mTXPacket && mTXPacket->channel() != mChannel )
|
||||||
startReceiving(mTXPacket->channel());
|
startReceiving(mTXPacket->channel(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transceiver::startTransmitting()
|
void Transceiver::startTransmitting()
|
||||||
@ -306,9 +306,9 @@ void Transceiver::startTransmitting()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transceiver::startReceiving(VHFChannel channel)
|
void Transceiver::startReceiving(VHFChannel channel, bool reconfigGPIOs)
|
||||||
{
|
{
|
||||||
Receiver::startReceiving(channel);
|
Receiver::startReceiving(channel, reconfigGPIOs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transceiver::configureGPIOsForRX()
|
void Transceiver::configureGPIOsForRX()
|
||||||
|
@ -477,7 +477,7 @@ uint32_t bsp_get_system_clock()
|
|||||||
uint8_t bsp_tx_spi_byte(uint8_t data)
|
uint8_t bsp_tx_spi_byte(uint8_t data)
|
||||||
{
|
{
|
||||||
uint8_t result = 0;
|
uint8_t result = 0;
|
||||||
HAL_SPI_TransmitReceive(&hspi1, &data, &result, 1, 10);
|
HAL_SPI_TransmitReceive(&hspi1, &data, &result, 1, 2);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user