You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2019/03/18 11:29:04 UTC
[GitHub] [mynewt-core] amrbekhit commented on a change in pull request
#1670: Implement low-power support in the LoRa stack and modify the nRF
timer code to use the HFXO manager.
amrbekhit commented on a change in pull request #1670: Implement low-power support in the LoRa stack and modify the nRF timer code to use the HFXO manager.
URL: https://github.com/apache/mynewt-core/pull/1670#discussion_r266397071
##########
File path: hw/drivers/lora/src/utilities.c
##########
@@ -17,25 +17,19 @@
* under the License.
*/
-#include <stdlib.h>
+#include <stdint.h>
-#include "os/mynewt.h"
-#include "lora/utilities.h"
+#include "os/os.h"
uint32_t
timer_get_current_time(void)
{
- return hal_timer_read(MYNEWT_VAL(LORA_MAC_TIMER_NUM));
+ /* Convert the OS time ticks to seconds, and then to us*/
+ return os_cputime_ticks_to_usecs(os_cputime_get32());
Review comment:
As you say, in the original implementation, `timer_get_current_time` directly returned the raw timer value. However, the timer value was hard-coded to run at 1MHz, giving a 1us time per tick.
https://github.com/apache/mynewt-core/blob/b886f237076f8206ffc1c8f0b451ae61abd023b4/net/lora/node/src/mac/LoRaMac.c#L50
The code also runs on the assumption that the timer_get_current_time value returns a number of us. This can be seen, for example, in the definition of `LORA_JOIN_REQ_RAND_DELAY`, which is in milliseconds:
https://github.com/apache/mynewt-core/blob/f5769ec3e2caf365e5a1036a300fe943a6feb67c/net/lora/node/syscfg.yml#L78
It is then used here (note the hard-coded multiplication by 1000, to convert it to us):
https://github.com/apache/mynewt-core/blob/b886f237076f8206ffc1c8f0b451ae61abd023b4/net/lora/node/src/mac/LoRaMac.c#L726
As such, my modifications to the timer_xxx functions maintain the us time unit.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services