64 lines
1.9 KiB
C
64 lines
1.9 KiB
C
/*
|
|
* SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "driver/gpio.h"
|
|
|
|
/*
|
|
* 控制面内部事件总线的数据契约:输入驱动只负责生成“发生了什么”,系统事件任务再决定
|
|
* “应该做什么”。这种拆分避免在 GPIO 中断或按键扫描任务里直接执行联网、播放、旋转等
|
|
* 可能阻塞的业务动作。这里的结构体会按值放入 FreeRTOS 队列,因此字段必须保持轻量,
|
|
* 不得加入需要跨任务管理生命周期的裸指针。
|
|
*/
|
|
typedef enum {
|
|
CONTROL_PLANE_EVENT_FAMILY_KEY = 0,
|
|
CONTROL_PLANE_EVENT_FAMILY_WIFI,
|
|
CONTROL_PLANE_EVENT_FAMILY_MULTIMODAL,
|
|
CONTROL_PLANE_EVENT_FAMILY_LCD,
|
|
CONTROL_PLANE_EVENT_FAMILY_DIRECTION,
|
|
CONTROL_PLANE_EVENT_FAMILY_CALIBRATION,
|
|
CONTROL_PLANE_EVENT_FAMILY_RUNTIME,
|
|
} control_plane_event_family_t;
|
|
|
|
typedef enum {
|
|
CONTROL_PLANE_KEY_ID_PTT = 0,
|
|
CONTROL_PLANE_KEY_ID_SW1,
|
|
CONTROL_PLANE_KEY_ID_SW2,
|
|
CONTROL_PLANE_KEY_ID_RESET,
|
|
} control_plane_key_id_t;
|
|
|
|
typedef enum {
|
|
CONTROL_PLANE_KEY_EVENT_PRESSED = 0,
|
|
CONTROL_PLANE_KEY_EVENT_RELEASED,
|
|
CONTROL_PLANE_KEY_EVENT_SHORT_PRESS,
|
|
CONTROL_PLANE_KEY_EVENT_LONG_PRESS_START,
|
|
CONTROL_PLANE_KEY_EVENT_LONG_PRESS_RELEASE,
|
|
CONTROL_PLANE_KEY_EVENT_DOUBLE_CLICK,
|
|
CONTROL_PLANE_KEY_EVENT_REPEAT,
|
|
CONTROL_PLANE_KEY_EVENT_CANCELLED,
|
|
} control_plane_key_event_type_t;
|
|
|
|
typedef struct {
|
|
control_plane_key_id_t key_id;
|
|
control_plane_key_event_type_t type;
|
|
gpio_num_t gpio_num;
|
|
int level;
|
|
int64_t timestamp_ms;
|
|
uint32_t press_duration_ms;
|
|
uint32_t click_count;
|
|
} control_plane_key_event_t;
|
|
|
|
typedef struct {
|
|
control_plane_event_family_t family;
|
|
int64_t timestamp_ms;
|
|
union {
|
|
control_plane_key_event_t key;
|
|
} data;
|
|
} control_plane_system_event_t;
|