feat(events): 添加事件提交函数到各个头文件中

为多个事件头文件添加了静态内联提交函数,包括:
- bat_state_event: 添加submit_bat_state_event函数
- ble_serial_rx_event: 添加submit_ble_serial_rx_event函数
- ble_serial_tx_event: 添加submit_ble_serial_tx_event函数
- cdc_proto_tx_event: 添加submit_cdc_proto_tx_event函数
- datetime_event: 添加submit_datetime_event函数
- encoder_event: 添加submit_encoder_event函数
- function_bitmap_update_event: 添加submit_function_bitmap_update_event函数
- hid_led_event: 添加submit_hid_led_event函数
- hid_report_sent_event: 添加submit_hid_report_sent_event函数
- hid_transport_state_event: 添加submit_hid_transport_state_event函数
- hid_tx_report_event: 添加submit_hid_tx_report_event函数
- key_function_event: 添加submit_key_function_event函数
- keyboard_hid_report_event: 添加submit_keyboard_hid_report_event函数
- led_strip_en_event: 添加submit_led_strip_en_event函数
- mode_switch_event: 添加submit_mode_switch_event函数
- set_protocol_event: 添加submit_set_protocol_event函数
- theme_rgb_update_event: 添加submit_theme_rgb_update_event函数
- time_sync_event: 添加submit_time_sync_event函数
- usb_cdc_rx_event: 添加submit_usb_cdc_rx_event函数
- usb_cdc_tx_event: 添加submit_usb_cdc_tx_event函数
- usb_device_state_event: 添加submit_usb_device_state_event函数
- usb_function_ready_event: 添加submit_usb_function_ready_event函数
- usb_prepare_event: 添加submit_usb_prepare_event函数

这些函数提供了一致的事件提交接口,简化了事件创建和提交过程。
This commit is contained in:
2026-04-14 16:42:04 +08:00
parent c342a8d3f0
commit 78a6dc212d
37 changed files with 485 additions and 624 deletions

View File

@@ -1,6 +1,10 @@
#ifndef BLINKY_HID_TX_REPORT_EVENT_H_
#define BLINKY_HID_TX_REPORT_EVENT_H_
#include <errno.h>
#include <stddef.h>
#include <string.h>
#include <app_event_manager.h>
#include <app_event_manager_profiler_tracer.h>
@@ -21,6 +25,31 @@ struct hid_tx_report_event {
APP_EVENT_TYPE_DYNDATA_DECLARE(hid_tx_report_event);
static inline int submit_hid_tx_report_event(enum hid_transport transport,
enum keyboard_report_type report_type,
enum keyboard_protocol_mode protocol_mode,
uint16_t sequence,
const uint8_t *data, size_t size)
{
struct hid_tx_report_event *event;
if ((data == NULL) && (size > 0U)) {
return -EINVAL;
}
event = new_hid_tx_report_event(size);
event->transport = transport;
event->report_type = report_type;
event->protocol_mode = protocol_mode;
event->sequence = sequence;
if (size > 0U) {
memcpy(event->dyndata.data, data, size);
}
APP_EVENT_SUBMIT(event);
return 0;
}
#ifdef __cplusplus
}
#endif