Skip to content

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

Merged
merged 4 commits into from
Jun 26, 2018
Merged

Conversation

hasnainvirk
Copy link
Contributor

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.

@hasnainvirk
Copy link
Contributor Author

Please review @AnttiKauppila @kjbracey-arm

@hasnainvirk hasnainvirk changed the title Removing Removing software RX timeouts in RX chain Jun 20, 2018
@@ -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 ?

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?)

Copy link
Contributor Author

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.

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.

Copy link
Contributor Author

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 ?

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.

// 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) |

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.

Copy link
Contributor Author

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.

@@ -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**/)

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?

Copy link
Contributor Author

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.

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.

@hasnainvirk hasnainvirk changed the title Removing software RX timeouts in RX chain [DO NOT MERGE] Removing software RX timeouts in RX chain Jun 20, 2018
Hasnain Virk added 2 commits June 21, 2018 11:59
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.
@hasnainvirk
Copy link
Contributor Author

@kjbracey-arm Can you please review ?

@hasnainvirk hasnainvirk changed the title [DO NOT MERGE] Removing software RX timeouts in RX chain Removing software RX timeouts in RX chain Jun 26, 2018
@hasnainvirk
Copy link
Contributor Author

@AnttiKauppila Please review.

* @param timeout Reception timeout [ms]
*
*/
virtual void receive(uint32_t timeout);
MBED_DEPRECATED_SINCE("mbed-os-5.10", "receive(uint32_t) will be deprecated. "

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).

hasnainvirk pushed a commit to hasnainvirk/mbed-os that referenced this pull request Jun 26, 2018
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().
Hasnain Virk added 2 commits June 26, 2018 16:02
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.
@hasnainvirk
Copy link
Contributor Author

@kjbracey-arm Please review again.

@hasnainvirk hasnainvirk merged commit 1a5f2fc into master Jun 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants