mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-12-26 11:13:16 +03:00
Nimble: Reduce BLE power usage
This configures Nimble to enable the HFCLOCK and other Bluetooth peripherals only when needed, but 1500 us in advance. This time is recommended by the Mynewt docs.
This commit is contained in:
parent
9b92861753
commit
118adb96cf
@ -780,6 +780,7 @@ add_definitions(-DNRF52 -DNRF52832 -DNRF52832_XXAA -DNRF52_PAN_74 -DNRF52_PAN_64
|
||||
add_definitions(-DFREERTOS)
|
||||
add_definitions(-D__STACK_SIZE=1024)
|
||||
add_definitions(-D__HEAP_SIZE=4096)
|
||||
add_definitions(-DMYNEWT_VAL_BLE_LL_RFMGMT_ENABLE_TIME=1500)
|
||||
|
||||
# Note: Only use this for debugging
|
||||
# Derive the low frequency clock from the main clock (SYNT)
|
||||
|
@ -37,6 +37,8 @@ extern "C" {
|
||||
|
||||
#define BLE_NPL_TIME_FOREVER portMAX_DELAY
|
||||
|
||||
extern volatile int ble_npl_in_critical;
|
||||
|
||||
/* This should be compatible with TickType_t */
|
||||
typedef uint32_t ble_npl_time_t;
|
||||
typedef int32_t ble_npl_stime_t;
|
||||
@ -282,14 +284,22 @@ static inline uint32_t
|
||||
ble_npl_hw_enter_critical(void)
|
||||
{
|
||||
//vPortEnterCritical();
|
||||
++ble_npl_in_critical;
|
||||
return npl_freertos_hw_enter_critical();
|
||||
}
|
||||
|
||||
static inline void
|
||||
ble_npl_hw_exit_critical(uint32_t ctx)
|
||||
{
|
||||
--ble_npl_in_critical;
|
||||
npl_freertos_hw_exit_critical(ctx);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
ble_npl_hw_is_in_critical(void)
|
||||
{
|
||||
// Do the same as RIOT and keep track of the critical state manually
|
||||
return (ble_npl_in_critical > 0);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -22,6 +22,8 @@
|
||||
#include <string.h>
|
||||
#include "nimble/nimble_npl.h"
|
||||
|
||||
volatile int ble_npl_in_critical = 0;
|
||||
|
||||
static inline bool
|
||||
in_isr(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user