e4ac072ea9
* IDF 5.3 support * IDF 5.3 * IDF 5.3 toolchains remove dynamic toolchains support, currently only older incompatible are possible to fetch. * Fix owner of * ULP compability for IDF 5.3 * remove debug print * Fix bootloader offset code retrieve * Update esp32-c6-devkitc-1.json * use espressif Arduino branch `release/v3.1.x` * Update README.md * Update README.md * Fix compile issue with managed components * use latest Arduino 3.1.0 libs * fetch Arduino libs dl URL from manifest json * fetch Arduino libs dl URL from manifest json * Update README.md * Fix IDF 5.3 ULP compile * Use espressif Arduino branch release/v3.1.x * Update platform.py * better handling of complex Macros from cmake model * IDF 5.3.1 release * fix handling of cc fragments * unchanged IDF 5.3.1 * ULP has now a cmake build script * add arduino/idf examples * fix used platform * prepare LP ULP support * enable bootloader components build * ULP LP support * add missing P4 * add P4 * change some if checks * Update README.md * remove wrong left over code * add ULP LP example / update Matter example * fix path * add zigbee examples * disable zigbee examples needs merge of the open zigbee Arduino PR * esptool.py v4.8.0 * add cmake_utilities for C2 * add auto select "espidf" when pio var "custom_sdkconfig" is set * IDF v5.3.1.240924 * Update main.py * matter example currently broken * Update platformio.ini * Update platformio.ini * Update platformio.ini * Update platformio.ini * Update examples.yml * IDF v5.3.1.241016 * Update Zigbee_On_Off_Light.ino * Update Zigbee_On_Off_Switch.ino * Update examples.yml * Update platformio.ini * Update platformio.ini * Update examples.yml * esptool.py v4.8.1.1 s2 s3 usb jtag reset fix * Update platform.py * Update gdb 14.2.0+20240403 * fix owner for gdb * Update IDF v5.3.1.241024 * Update adafruit_matrixportal_esp32s3.json * Use compatible h2zero NimBLE git commit * Update Zigbee_On_Off_Light.ino * Update Zigbee_On_Off_Switch.ino * fix custom partiton table offset calculation * Update README.md * Create esp32-p4.json * add P4 to blink example * Update Zigbee_On_Off_Switch.ino * Update Zigbee_On_Off_Light.ino * Update sdkconfig.defaults * add P4 to LP example * Create esp32-p4-evboard.json * IDF 5.3.2 release * prep for "pioarduino-build.py" script * add missing import os * fix not defined var * Update Zigbee_On_Off_Switch.ino * esptool.py v4.8.5 * Update Zigbee_On_Off_Light.ino * add Hybrid Compile (#73) * Update README.md * set Arduino compile option `UPDATE_NOCRYPT` in example Tasmota * Update C2 Hybrid compile skeleton * Update IDF v5.3.2.241210 * Revert to IDF 5.3.2 * Update pioarduino IDF 5.2 * Update release_zips.yml
65 lines
2.0 KiB
C
65 lines
2.0 KiB
C
/*
|
|
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
|
*
|
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
|
*/
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "sdkconfig.h"
|
|
#include "ulp_lp_core.h"
|
|
#include "ulp_lp_core_utils.h"
|
|
#include "ulp_lp_core_gpio.h"
|
|
#include "ulp_lp_core_interrupts.h"
|
|
#include "ulp_lp_core_print.h"
|
|
#include "riscv/csr.h"
|
|
|
|
#define DEBOUNCE_INTERVAL_CYCLES 10 // 10 cycles is about 0.625 us at 16 MHz
|
|
|
|
#define SIMULATED_PULSE_FREQUENCY_HZ 2
|
|
#define SIMULATED_PULSE_DELAY_US (1000000 / SIMULATED_PULSE_FREQUENCY_HZ) / 2
|
|
|
|
uint32_t pulse_count;
|
|
static uint32_t last_trigger_time_cycles;
|
|
|
|
void LP_CORE_ISR_ATTR ulp_lp_core_lp_io_intr_handler(void)
|
|
{
|
|
ulp_lp_core_gpio_clear_intr_status();
|
|
uint32_t trigger_time_cycles = RV_READ_CSR(mcycle);
|
|
/* Do some simple debouncing, do not count spurious pulses */
|
|
if (trigger_time_cycles - last_trigger_time_cycles > DEBOUNCE_INTERVAL_CYCLES) {
|
|
pulse_count++;
|
|
last_trigger_time_cycles = trigger_time_cycles;
|
|
}
|
|
|
|
if (pulse_count % CONFIG_EXAMPLE_PULSE_COUNT_WAKEUP_LIMIT == 0) {
|
|
lp_core_printf("Pulse count: %d, wake-up main CPU\n", pulse_count);
|
|
ulp_lp_core_wakeup_main_processor();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int main (void)
|
|
{
|
|
lp_core_printf("LP Core pulse counter started\n");
|
|
ulp_lp_core_intr_enable();
|
|
ulp_lp_core_gpio_intr_enable(CONFIG_EXAMPLE_PULSE_COUNT_PIN, LP_IO_INTR_POSEDGE);
|
|
|
|
while(1) {
|
|
|
|
#if CONFIG_EXAMPLE_PULSE_COUNT_SIMULATE
|
|
/* No external device connected to generate pulses, we simulate them ourselves instead */
|
|
ulp_lp_core_delay_us(SIMULATED_PULSE_DELAY_US);
|
|
ulp_lp_core_gpio_set_level(CONFIG_EXAMPLE_PULSE_COUNT_PIN, 1);
|
|
ulp_lp_core_delay_us(SIMULATED_PULSE_DELAY_US);
|
|
ulp_lp_core_gpio_set_level(CONFIG_EXAMPLE_PULSE_COUNT_PIN, 0);
|
|
#else
|
|
/* Put CPU into a wait state to reduce power consumption while waiting for pulses */
|
|
ulp_lp_core_wait_for_intr();
|
|
#endif //CONFIG_EXAMPLE_PULSE_COUNT_SIMULATE
|
|
}
|
|
|
|
return 0;
|
|
}
|