Created
October 10, 2024 17:31
-
-
Save mattgaidica/27514c781d1c4e156d32c48929d91037 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ulp_insn_t ulp_program[] = { | |
// Label to loop back to | |
M_LABEL(1), | |
// Read GPIO18 state (bit 28) via RTC_GPIO_IN_REG | |
I_RD_REG(RTC_GPIO_IN_REG, RTC_GPIO_INDEX + RTC_GPIO_IN_NEXT_S, RTC_GPIO_INDEX + RTC_GPIO_IN_NEXT_S), | |
// Check if GPIO18 is low (R0 < 1). If low, wake up the CPU. | |
M_BL(2, 1), // If R0 < 1 (i.e., if GPIO18 is low, branch to wakeup) | |
// Loop back to the start (label 1) if GPIO18 is not low | |
M_BX(1), // Unconditional branch back to label 1 | |
// Label 2: Wake up the main CPU | |
M_LABEL(2), | |
// Wake up the main CPU | |
I_WAKE(), // Wake up the main CPU | |
I_HALT(), // Halt the ULP program after waking the CPU | |
}; | |
// make sure to include esp_sleep_enable_ulp_wakeup(); to allow ULP to wakeup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment