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:
@@ -1,6 +1,10 @@
|
||||
#ifndef BLINKY_USB_CDC_TX_EVENT_H_
|
||||
#define BLINKY_USB_CDC_TX_EVENT_H_
|
||||
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <app_event_manager.h>
|
||||
#include <app_event_manager_profiler_tracer.h>
|
||||
|
||||
@@ -15,6 +19,23 @@ struct usb_cdc_tx_event {
|
||||
|
||||
APP_EVENT_TYPE_DYNDATA_DECLARE(usb_cdc_tx_event);
|
||||
|
||||
static inline int submit_usb_cdc_tx_event(const uint8_t *data, size_t len)
|
||||
{
|
||||
struct usb_cdc_tx_event *event;
|
||||
|
||||
if ((data == NULL) && (len > 0U)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
event = new_usb_cdc_tx_event(len);
|
||||
if (len > 0U) {
|
||||
memcpy(event->dyndata.data, data, len);
|
||||
}
|
||||
|
||||
APP_EVENT_SUBMIT(event);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user