-
Notifications
You must be signed in to change notification settings - Fork 364
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
Implement low-power support in the LoRa stack #1670
Conversation
…r code to use the HFXO manager. Use of timers in the LoRa stack has been split into critical and non-critial timers. Non-critical timers (such as retry delays) are now implemented using the os_cputime functions. The os_cputime needs to be configured to use a lower power time in the BSP (such as is done by the BLE stack via the BLE_LP_CLOCK syscfg). Critical timers are only used to time the opening of the RX windows. These continue to use the hal_timer functions, but require that the user implements two callback functions (lora_low_power_enter and lora_low_power_exit) to turn the LORA_MAC_TIMER off and on. This is necessary as turning a timer on is a hardware-specific operation that may require that the caller pass in a custom configuration struct. This patch also modifies the nRF timer code to use the HFXO manager found in hw/mcu/nordic/nrf52xxx/src/nrf5x_clock.c. This allows multiple different timers to be turned on and off independently and manager will automatically turn the nRF HFXO on and off as required. This is necessary in order for the LoRa and BLE stacks to be able to run side by side.
…mrbekhit/lora_low_power
The SX1272 DIO3 IRQ is used during Carrier Detect (CAD). This is neither necessary for LoRa operation, nor used in the current driver. Therefore, by making this pin optional, an extra GPIO/IRQ can be freed for other tasks.
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.
LGTM
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 might have missed a commit but I do not see lora_low_power_exit() and enter().
This something I tried to discuss on the mailing list https://lists.apache.org/thread.html/48451519a2a6990dfa98dea84ee4cf8e6c8b407e9220f152e9ab49a2@%3Cdev.mynewt.apache.org%3E Basically, the hal_timer functions don't provide a way for libraries to turn a timer on in a hardware agnostic fashion. You have to call the hal_timer_init function with a hardware specific parameter. Therefore, I declared the callbacks lora_low_power_enter/exit() that need to be implemented by the user in order to turn the timer on and off. I'd like to find a better way of resolving this. |
…he#1670 (comment)). -Resolved minor formatting issues.
…mrbekhit/lora_low_power
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 I reviewed the rest of the changes and they seem fine. However, I think what needs to be done to this PR is to separate out the nrf5x changes from the rest of the changes. They should be in separate PR's and not tied together. Furthermore, the changes as made will change the behavior of the code for folks who are already using it (there is no wait to see if the HFXO settles). So I think any changes in that separate PR need to have the HFXO wait to settle.
And another comment. Not sure how to handle the lora enter low power. Quite a few of the drivers require a hw specific config and this is usually handled in the bsp or in the architecture specific portion of drivers. So handling that in the lora hw specific driver seems reasonable. |
…mrbekhit/lora_low_power
…se will be added to a separate pull request.
…an two: lora_bsp_enable_mac_timer. This is because the hal_timer functions already allow application code to disable timers in a hardware-agnostic fashion using the hal_timer_deinit function. The LoRa code now turns the timer off itself, but requires the BSP to implement lora_bsp_enable_mac_timer in order to turn the timer on.
…sp_enable_mac_timer function in order to allow CI to pass.
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.
Hi @wes3 as requested I've removed the HFXO changes to hal_system.c and hal_timer.c and will add these as a separate pull request. EDIT the new pull request can be found here.
I've made some changes to the low power callbacks - since the LoRa code can turn the timer off itself using hal_timer_deinit
, I've removed the lora_low_power_enter
callback function and renamed lora_low_power_exit
to lora_bsp_enable_mac_timer
. BSPs now only need to implement lora_bsp_enable_mac_timer
.
I've also modified the b-l072z-lrwan1 and telee02 BSPs to implement lora_bsp_enable_mac_timer
. Travis CI now builds find and this pull request passes all checks.
Hopefully this can now be merged.
@wes3 can you review this so we can merge? |
Reviewed the changes and merged. Sorry for the delay. |
* Implement low-power support in the LoRa stack and modify the nRF timer code to use the HFXO manager. Use of timers in the LoRa stack has been split into critical and non-critial timers. Non-critical timers (such as retry delays) are now implemented using the os_cputime functions. The os_cputime needs to be configured to use a lower power time in the BSP (such as is done by the BLE stack via the BLE_LP_CLOCK syscfg). Critical timers are only used to time the opening of the RX windows. These continue to use the hal_timer functions, but require that the user implements two callback functions (lora_low_power_enter and lora_low_power_exit) to turn the LORA_MAC_TIMER off and on. This is necessary as turning a timer on is a hardware-specific operation that may require that the caller pass in a custom configuration struct. This patch also modifies the nRF timer code to use the HFXO manager found in hw/mcu/nordic/nrf52xxx/src/nrf5x_clock.c. This allows multiple different timers to be turned on and off independently and manager will automatically turn the nRF HFXO on and off as required. This is necessary in order for the LoRa and BLE stacks to be able to run side by side. * Correct HFXO manager header files. * Correct calls to to HFXO manager. * Correct HFXO manager header. * Make SX1272 DIO3 IRQ optional. The SX1272 DIO3 IRQ is used during Carrier Detect (CAD). This is neither necessary for LoRa operation, nor used in the current driver. Therefore, by making this pin optional, an extra GPIO/IRQ can be freed for other tasks. * -Fixed a bug when calculating the delays for the TX retry timer (apache#1670 (comment)). -Resolved minor formatting issues. * -Reverted the HFXO changes in the hal_system and hal_timer files. These will be added to a separate pull request. * -Modified the low power callbacks so that there is only one rather than two: lora_bsp_enable_mac_timer. This is because the hal_timer functions already allow application code to disable timers in a hardware-agnostic fashion using the hal_timer_deinit function. The LoRa code now turns the timer off itself, but requires the BSP to implement lora_bsp_enable_mac_timer in order to turn the timer on. * -Modified the b-l072z-lrwan1 and telee02 BSPs to implement the lora_bsp_enable_mac_timer function in order to allow CI to pass.
* Implement low-power support in the LoRa stack and modify the nRF timer code to use the HFXO manager. Use of timers in the LoRa stack has been split into critical and non-critial timers. Non-critical timers (such as retry delays) are now implemented using the os_cputime functions. The os_cputime needs to be configured to use a lower power time in the BSP (such as is done by the BLE stack via the BLE_LP_CLOCK syscfg). Critical timers are only used to time the opening of the RX windows. These continue to use the hal_timer functions, but require that the user implements two callback functions (lora_low_power_enter and lora_low_power_exit) to turn the LORA_MAC_TIMER off and on. This is necessary as turning a timer on is a hardware-specific operation that may require that the caller pass in a custom configuration struct. This patch also modifies the nRF timer code to use the HFXO manager found in hw/mcu/nordic/nrf52xxx/src/nrf5x_clock.c. This allows multiple different timers to be turned on and off independently and manager will automatically turn the nRF HFXO on and off as required. This is necessary in order for the LoRa and BLE stacks to be able to run side by side. * Correct HFXO manager header files. * Correct calls to to HFXO manager. * Correct HFXO manager header. * Make SX1272 DIO3 IRQ optional. The SX1272 DIO3 IRQ is used during Carrier Detect (CAD). This is neither necessary for LoRa operation, nor used in the current driver. Therefore, by making this pin optional, an extra GPIO/IRQ can be freed for other tasks. * -Fixed a bug when calculating the delays for the TX retry timer (apache#1670 (comment)). -Resolved minor formatting issues. * -Reverted the HFXO changes in the hal_system and hal_timer files. These will be added to a separate pull request. * -Modified the low power callbacks so that there is only one rather than two: lora_bsp_enable_mac_timer. This is because the hal_timer functions already allow application code to disable timers in a hardware-agnostic fashion using the hal_timer_deinit function. The LoRa code now turns the timer off itself, but requires the BSP to implement lora_bsp_enable_mac_timer in order to turn the timer on. * -Modified the b-l072z-lrwan1 and telee02 BSPs to implement the lora_bsp_enable_mac_timer function in order to allow CI to pass.
* Implement low-power support in the LoRa stack and modify the nRF timer code to use the HFXO manager. Use of timers in the LoRa stack has been split into critical and non-critial timers. Non-critical timers (such as retry delays) are now implemented using the os_cputime functions. The os_cputime needs to be configured to use a lower power time in the BSP (such as is done by the BLE stack via the BLE_LP_CLOCK syscfg). Critical timers are only used to time the opening of the RX windows. These continue to use the hal_timer functions, but require that the user implements two callback functions (lora_low_power_enter and lora_low_power_exit) to turn the LORA_MAC_TIMER off and on. This is necessary as turning a timer on is a hardware-specific operation that may require that the caller pass in a custom configuration struct. This patch also modifies the nRF timer code to use the HFXO manager found in hw/mcu/nordic/nrf52xxx/src/nrf5x_clock.c. This allows multiple different timers to be turned on and off independently and manager will automatically turn the nRF HFXO on and off as required. This is necessary in order for the LoRa and BLE stacks to be able to run side by side. * Correct HFXO manager header files. * Correct calls to to HFXO manager. * Correct HFXO manager header. * Make SX1272 DIO3 IRQ optional. The SX1272 DIO3 IRQ is used during Carrier Detect (CAD). This is neither necessary for LoRa operation, nor used in the current driver. Therefore, by making this pin optional, an extra GPIO/IRQ can be freed for other tasks. * -Fixed a bug when calculating the delays for the TX retry timer (apache#1670 (comment)). -Resolved minor formatting issues. * -Reverted the HFXO changes in the hal_system and hal_timer files. These will be added to a separate pull request. * -Modified the low power callbacks so that there is only one rather than two: lora_bsp_enable_mac_timer. This is because the hal_timer functions already allow application code to disable timers in a hardware-agnostic fashion using the hal_timer_deinit function. The LoRa code now turns the timer off itself, but requires the BSP to implement lora_bsp_enable_mac_timer in order to turn the timer on. * -Modified the b-l072z-lrwan1 and telee02 BSPs to implement the lora_bsp_enable_mac_timer function in order to allow CI to pass.
Use of timers in the LoRa stack has been split into critical and non-critial timers. Non-critical timers (such as retry delays) are now implemented using the os_cputime functions. The
os_cputime needs to be configured to use a lower power time in the BSP (such as is done by the BLE stack via the BLE_LP_CLOCK syscfg). Critical timers are only used to time the opening of
the RX windows. These continue to use the hal_timer functions, but require that the user implements two callback functions (lora_low_power_enter and lora_low_power_exit) to turn the
LORA_MAC_TIMER off and on. This is necessary as turning a timer on is a hardware-specific operation that may require that the caller pass in a custom configuration struct.
This patch also modifies the nRF timer code to use the HFXO manager found in hw/mcu/nordic/nrf52xxx/src/nrf5x_clock.c. This allows multiple different timers to be turned on and offEDIT: As requested, this has now been removed and will be pushed as a separate pull request.independently and manager will automatically turn the nRF HFXO on and off as required. This is necessary in order for the LoRa and BLE stacks to be able to run side by side.