File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
ports/nordic/common-hal/alarm/pin Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -123,11 +123,16 @@ void alarm_pin_pinalarm_reset(void) {
123123static void configure_pins_for_sleep (void ) {
124124 _pinhandler_gpiote_count = 0 ;
125125
126+ int n_pin_alarms = __builtin_popcountll (high_alarms ) + __builtin_popcountll (low_alarms );
127+ const int MAX_N_PIN_ALARMS_FOR_SENSE_FEATURE = 2 ;
128+
126129 nrfx_gpiote_in_config_t cfg = {
127130 .sense = NRF_GPIOTE_POLARITY_TOGGLE ,
128131 .pull = NRF_GPIO_PIN_PULLUP ,
129132 .is_watcher = false,
130- .hi_accuracy = true,
133+ // hi_accuracy = False reduces sleep current by a factor of ~10x by using the SENSE feature,
134+ // but only works if not more than MAX_N_PIN_ALARMS_FOR_SENSE_FEATURE pin alarms are used.
135+ .hi_accuracy = (n_pin_alarms > MAX_N_PIN_ALARMS_FOR_SENSE_FEATURE ),
131136 .skip_gpio_setup = false
132137 };
133138 for (size_t i = 0 ; i < 64 ; ++ i ) {
You can’t perform that action at this time.
0 commit comments