-
Notifications
You must be signed in to change notification settings - Fork 25
Removing software RX timeouts in RX chain #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Please review @AnttiKauppila @kjbracey-arm |
SX1272/SX1272_LoRaRadio.cpp
Outdated
@@ -904,6 +896,11 @@ void SX1272_LoRaRadio::receive(uint32_t timeout) | |||
RF_RXCONFIG_AGCAUTO_ON | | |||
RF_RXCONFIG_RXTRIGER_PREAMBLEDETECT); | |||
|
|||
write_to_register(REG_RXTIMEOUT2, _rf_settings.fsk.rx_single_timeout <= 255 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If going to have any special code for this range check, it should produce some sort of diagnostic. The system will fail if you need a timeout bigger than 255 and you can't provide it.
Either the condition won't happen, so it's not worth having the range check, or it might, in which case you want to print something while limping on with a not-big-enough-but-best-we-can-do timeout.
(Probably once only - would be nice if there was a tr_error_once macro. Feature request?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RX_TIMEOUT is being used for FSK only and with recommended error cushion of 10ms, number of bytes are never going to be more than 255. 100ms value for error cushion is not recommended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if it's never going to be more than 255, you don't need the check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, just my paranoia .. The types chosen by original developers are weird. I want to have the test, may be I am being a bit too defensive here :) but you taught me that, didn't you ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paranoia is justified I think here, but this particular "quietly saturate" reaction if they really are out to get you isn't helpful.
SX1272/SX1272_LoRaRadio.cpp
Outdated
// We can have a snapshot of RSSI here as at this point it | ||
// should be more smoothed out. | ||
_rf_settings.fsk_packet_handler.rssi_value = -(read_register(REG_RSSIVALUE) >> 1); | ||
_rf_settings.fsk_packet_handler.afc_value = (int32_t)(double)(((uint16_t)read_register(REG_AFCMSB) << 8) | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally you should be trying to reduce or totally eliminate use of floating point, if you're aiming at low-end devices. At least use float
rather than double
given that a lot of chips we're on have single-precision hardware only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I will change everything with float precision. Good point.
SX1276/SX1276_LoRaRadio.cpp
Outdated
@@ -848,29 +844,24 @@ void SX1276_LoRaRadio::standby( void ) | |||
* and finally a DIO0 interrupt let's the state machine know that a packet is | |||
* ready to be read from the FIFO | |||
*/ | |||
void SX1276_LoRaRadio::receive(uint32_t timeout) | |||
void SX1276_LoRaRadio::receive(uint32_t /**timeout**/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this make it a Doxygen comment? Is that deliberate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this makes a doxygen comment. But it is deliberate. I just wanted to emphasis that this parameter is not being used. We will deprecate the APIs in a separate commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you aren't consciously doing something for Doxygen, then probably best not to use the special /**
Doxygen syntax. Then we won't have to worry about how it will interpret it.
Both in FSK and LoRa mode, we do not rely on software timers anymore. This makes our timing precise and enables us to consume less power. It also gives us flexibility which we need for future deep sleep venture as Mbed OS timeout class may lock the sleep manager if not using low power timers.
We shouldn't use double precision as most of te embedded processors may not support it.
12368dd
to
7325b3e
Compare
@kjbracey-arm Can you please review ? |
@AnttiKauppila Please review. |
SX1276/SX1276_LoRaRadio.h
Outdated
* @param timeout Reception timeout [ms] | ||
* | ||
*/ | ||
virtual void receive(uint32_t timeout); | ||
MBED_DEPRECATED_SINCE("mbed-os-5.10", "receive(uint32_t) will be deprecated. " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't warn about deprecation in the future. It's either deprecated or it isn't. This is saying "I'm telling you that I'm going to tell you that you shouldn't use this in the future, but I'm not telling you not to use it now", which doesn't make a lot of sense.
Anyway, a deprecation notice isn't appropriate for this outside-mbed OS driver implementation. It has to provide the current method, which is receive(timeout)
, but is providing receive()
ready for some future version of LoRaRadio
. (Which I still think could arrive by 5.10, once all drivers are updated).
receive(uint32_t) API in the LoRaRadio class (base class for the radio drivers) should not take any argument as we decided to take hardware timers for RX timeout interrupts instead of software timers. It is being refactored to receive(void). This is an API change, but as it is not an application interface, we will not put a deprecation notice. Only user of this API is our stack (LoRaPHY layer) which has been updated accordingly. Actual driver comes out of the tree and a PR is open there to update the drivers: ARMmbed/mbed-semtech-lora-rf-drivers#22 In addition to this an internal API belonging to LoRaPHY class is refactored. set_rx_window(parameters) is refactored to handle_receive(void) which is more consistent with handle_send().
We are deprecating receive(uint32_t) API in favour of receive(void) API because we are ditching software timeout timers in the driver for RX chain.
Rx timeout in symbols cannot become more than 255 as the preamble length is fixed. For diagonostics purposes we add an MBED_ASSERT.
ea21131
to
bccd3fc
Compare
@kjbracey-arm Please review again. |
Both in FSK and LoRa mode, we do not rely on software timers anymore.
This makes our timing precise and enables us to consume less power.
It also gives us flexibility which we need for future deep sleep
venture as Mbed OS timeout class may lock the sleep manager if not using
low power timers.