为电源管理单独创建任务,增加中断监听电源事件
This commit is contained in:
parent
6481899d82
commit
10c3520006
@ -26,7 +26,7 @@ dependencies:
|
|||||||
espressif/esp_lvgl_port:
|
espressif/esp_lvgl_port:
|
||||||
dependencies: []
|
dependencies: []
|
||||||
source:
|
source:
|
||||||
path: /Users/yu/esp/esp32-off-Line-tools/components/espressif__esp_lvgl_port
|
path: D:\espressif\WorkSpace\esp32-off-Line-tools\components\espressif__esp_lvgl_port
|
||||||
type: local
|
type: local
|
||||||
version: 2.5.0
|
version: 2.5.0
|
||||||
espressif/esp_tinyusb:
|
espressif/esp_tinyusb:
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
static const char *TAG = "AXP20x";
|
static const char *TAG = "AXP20x";
|
||||||
|
|
||||||
static QueueHandle_t gpio_evt_queue = NULL;
|
extern "C" QueueHandle_t gpio_evt_queue = NULL;
|
||||||
|
|
||||||
static void IRAM_ATTR axp_isr_handler(void *arg)
|
static void IRAM_ATTR axp_isr_handler(void *arg)
|
||||||
{
|
{
|
||||||
@ -214,34 +214,59 @@ extern "C" void axp_info()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// extern "C" void app_main(void)
|
extern "C" void Axp_readIRQ()
|
||||||
|
{
|
||||||
|
axp.readIRQ();
|
||||||
|
}
|
||||||
|
extern "C" void Axp_clearIRQ()
|
||||||
|
{
|
||||||
|
axp.clearIRQ();
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" int Axp_PEKPress_IRQ()
|
||||||
|
{
|
||||||
|
|
||||||
|
// if(axp.isPEKLongtPressIRQ())
|
||||||
// {
|
// {
|
||||||
// ESP_ERROR_CHECK(i2c_master_init());
|
// return 2;
|
||||||
|
|
||||||
// axp_init();
|
|
||||||
|
|
||||||
// axp_info();
|
|
||||||
|
|
||||||
// axp_irq_init();
|
|
||||||
|
|
||||||
// axp_config();
|
|
||||||
|
|
||||||
// // //! Enable all irq channel
|
|
||||||
// axp.enableIRQ(AXP202_ALL_IRQ, true);
|
|
||||||
|
|
||||||
// axp.clearIRQ();
|
|
||||||
|
|
||||||
// uint32_t io_num;
|
|
||||||
// for (;;) {
|
|
||||||
|
|
||||||
// if (xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) {
|
|
||||||
// if (io_num == AXP_ISR_GPIO) {
|
|
||||||
// axp.readIRQ();
|
|
||||||
// if (axp.isPEKShortPressIRQ()) {
|
|
||||||
// ESP_LOGI(TAG, "AXP202 PEK key Click");
|
|
||||||
// }
|
|
||||||
// axp.clearIRQ();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
if(axp.isPEKShortPressIRQ())
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" void Axp202_task(void *pvParameter)
|
||||||
|
{
|
||||||
|
axp_init();
|
||||||
|
|
||||||
|
axp_info();
|
||||||
|
|
||||||
|
axp_irq_init();
|
||||||
|
|
||||||
|
axp_config();
|
||||||
|
|
||||||
|
axp.enableIRQ(AXP202_ALL_IRQ, true);
|
||||||
|
|
||||||
|
axp.clearIRQ();
|
||||||
|
uint32_t io_num;
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (xQueueReceive(gpio_evt_queue, &io_num, portMAX_DELAY)) {
|
||||||
|
if (io_num == AXP_ISR_GPIO) {
|
||||||
|
axp.readIRQ();
|
||||||
|
if (axp.isPEKLongtPressIRQ()) {
|
||||||
|
ESP_LOGI(TAG, "AXP202 PEK key Click");
|
||||||
|
}
|
||||||
|
axp.clearIRQ();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
axp.clearIRQ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|||||||
37
main/main.c
37
main/main.c
@ -71,10 +71,9 @@ Device_info_t off_line_tool;
|
|||||||
// EXT_RAM_BSS_ATTR Sys_config_t System_Config;
|
// EXT_RAM_BSS_ATTR Sys_config_t System_Config;
|
||||||
Sys_config_t System_Config;
|
Sys_config_t System_Config;
|
||||||
|
|
||||||
extern void axp_init(void);
|
extern void Axp202_task(void *pvParameter);
|
||||||
extern void axp_info();
|
|
||||||
extern void axp_config();
|
extern QueueHandle_t gpio_evt_queue;
|
||||||
extern void axp_irq_init();
|
|
||||||
|
|
||||||
void app_main(void)
|
void app_main(void)
|
||||||
{
|
{
|
||||||
@ -90,44 +89,22 @@ void app_main(void)
|
|||||||
xTaskCreate(&Gui_Task, "Gui_Task", 1024*30, NULL, 12, NULL);
|
xTaskCreate(&Gui_Task, "Gui_Task", 1024*30, NULL, 12, NULL);
|
||||||
init_spiffs();
|
init_spiffs();
|
||||||
list_files_in_spiffs("/spiffs",off_line_tool.directory, 10);
|
list_files_in_spiffs("/spiffs",off_line_tool.directory, 10);
|
||||||
ESP_LOGI(TAG, "Found file: %s, size: %ld bytes", off_line_tool.directory[0].name, off_line_tool.directory[0].size);
|
// ESP_LOGI(TAG, "Found file: %s, size: %ld bytes", off_line_tool.directory[0].name, off_line_tool.directory[0].size);
|
||||||
ESP_LOGI(TAG, "Found file: %s, size: %ld bytes", off_line_tool.directory[1].name, off_line_tool.directory[1].size);
|
// ESP_LOGI(TAG, "Found file: %s, size: %ld bytes", off_line_tool.directory[1].name, off_line_tool.directory[1].size);
|
||||||
ESPFlash_Init();
|
ESPFlash_Init();
|
||||||
stream_init(&uart_interface_data,1024*50);
|
stream_init(&uart_interface_data,1024*50);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "mem free:%ld",esp_get_free_heap_size());
|
ESP_LOGI(TAG, "mem free:%ld",esp_get_free_heap_size());
|
||||||
gpio_config_t config = {
|
|
||||||
.mode = GPIO_MODE_OUTPUT,
|
|
||||||
.pin_bit_mask = 1ULL << 8 | 1ULL << 7,
|
|
||||||
.pull_up_en = 1
|
|
||||||
};
|
|
||||||
gpio_config(&config);
|
|
||||||
gpio_set_level(8,0);
|
|
||||||
// gpio_set_level(18,1);
|
|
||||||
// gpio_config_t input_config = {
|
|
||||||
// .mode = GPIO_MODE_INPUT,
|
|
||||||
// .pin_bit_mask = 1ULL << 9 | 1ULL << 2,
|
|
||||||
// .pull_up_en = 1
|
|
||||||
// };
|
|
||||||
// gpio_config(&input_config);
|
|
||||||
// button_init_all();
|
|
||||||
ESP_ERROR_CHECK(i2c_master_init());
|
ESP_ERROR_CHECK(i2c_master_init());
|
||||||
|
|
||||||
axp_init();
|
|
||||||
|
|
||||||
axp_info();
|
|
||||||
|
|
||||||
// axp_irq_init();
|
|
||||||
|
|
||||||
axp_config();
|
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32C3
|
#if CONFIG_IDF_TARGET_ESP32C3
|
||||||
usb_serial2Uart(NULL);
|
usb_serial2Uart(NULL);
|
||||||
#endif
|
#endif
|
||||||
xTaskCreate(&Read_CMD_task, "Read_CMD_task", 1024*20, NULL, 14, NULL);
|
xTaskCreate(&Read_CMD_task, "Read_CMD_task", 1024*20, NULL, 14, NULL);
|
||||||
xTaskCreate(&usb_serial_task,"usb_serial_task",1024*10,NULL,22,NULL);
|
xTaskCreate(&usb_serial_task,"usb_serial_task",1024*10,NULL,22,NULL);
|
||||||
xTaskCreate(&Flasher_tool_task, "Flasher_tool_task", 1024*20, NULL, 10, NULL);
|
xTaskCreate(&Flasher_tool_task, "Flasher_tool_task", 1024*20, NULL, 10, NULL);
|
||||||
|
xTaskCreate(&Axp202_task,"Axp202_task",1024*5,NULL,8,NULL);
|
||||||
#if 0
|
#if 0
|
||||||
home_html.html_data = load_html2Ram(home_html);
|
home_html.html_data = load_html2Ram(home_html);
|
||||||
wifi_config_html.html_data = load_html2Ram(wifi_config_html);
|
wifi_config_html.html_data = load_html2Ram(wifi_config_html);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user