File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,16 +65,31 @@ class ESP32Board : public mesh::MainBoard {
6565 return ; // Not supported
6666#endif
6767
68- gpio_intr_disable (( gpio_num_t ) wakeupPin); // To disable ISR for LoRa
68+ // To configure GPIO wakeup
6969 esp_sleep_enable_gpio_wakeup ();
7070 gpio_wakeup_enable ((gpio_num_t ) wakeupPin, GPIO_INTR_HIGH_LEVEL ); // To wake up when receiving a LoRa packet
7171
72+ // To configure timer wakeup
7273 if (secs > 0 ) {
73- esp_sleep_enable_timer_wakeup (secs * 1000000 ); // To wake up periodically to do scheduled jobs
74+ esp_sleep_enable_timer_wakeup (secs * 1000000ULL ); // To wake up periodically to do scheduled jobs
7475 }
7576
76- esp_light_sleep_start (); // CPU enters light sleep
77- gpio_intr_enable ((gpio_num_t ) wakeupPin); // Wakeup. Let ISR to handle LoRa packet as normal
77+ // To disable CPU interrupt servicing
78+ noInterrupts ();
79+
80+ // MCU to enter light sleep
81+ esp_light_sleep_start ();
82+ Serial.println (esp_sleep_get_wakeup_cause ());
83+
84+ // To avoid ISR flood during wakeup due to HIGH LEVEL interrupt
85+ #if defined(ESP32) && defined(RADIO_SX1276) && defined(P_LORA_DIO_0) // SX1276
86+ gpio_set_intr_type ((gpio_num_t )P_LORA_DIO_0 , GPIO_INTR_POSEDGE );
87+ #elif defined(ESP32) && defined(P_LORA_DIO_1) // SX1262
88+ gpio_set_intr_type ((gpio_num_t )P_LORA_DIO_1 , GPIO_INTR_POSEDGE );
89+ #endif
90+
91+ // To disable CPU interrupt servicing
92+ interrupts ();
7893 }
7994
8095 void sleep (uint32_t secs) override {
Original file line number Diff line number Diff line change @@ -22,13 +22,6 @@ static
2222void setFlag (void ) {
2323 // we sent a packet, set the flag
2424 state |= STATE_INT_READY ;
25-
26- // To avoid ISR flood during wakeup due to HIGH LEVEL interrupt
27- #if defined(ESP32) && defined(RADIO_SX1276) && defined(P_LORA_DIO_0) // SX1276
28- gpio_set_intr_type ((gpio_num_t )P_LORA_DIO_0 , GPIO_INTR_POSEDGE );
29- #elif defined(ESP32) && defined(P_LORA_DIO_1) // SX1262
30- gpio_set_intr_type ((gpio_num_t )P_LORA_DIO_1 , GPIO_INTR_POSEDGE );
31- #endif
3225}
3326
3427void RadioLibWrapper::begin () {
You can’t perform that action at this time.
0 commit comments