2026-04-11 17:15:11 +08:00
|
|
|
#ifndef BLINKY_USB_CDC_RX_EVENT_H_
|
|
|
|
|
#define BLINKY_USB_CDC_RX_EVENT_H_
|
|
|
|
|
|
2026-04-14 16:42:04 +08:00
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2026-04-11 17:15:11 +08:00
|
|
|
#include <app_event_manager.h>
|
|
|
|
|
#include <app_event_manager_profiler_tracer.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
struct usb_cdc_rx_event {
|
|
|
|
|
struct app_event_header header;
|
|
|
|
|
struct event_dyndata dyndata;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
APP_EVENT_TYPE_DYNDATA_DECLARE(usb_cdc_rx_event);
|
|
|
|
|
|
2026-04-14 16:42:04 +08:00
|
|
|
static inline int submit_usb_cdc_rx_event(const uint8_t *data, size_t len)
|
|
|
|
|
{
|
|
|
|
|
struct usb_cdc_rx_event *event;
|
|
|
|
|
|
|
|
|
|
if ((data == NULL) && (len > 0U)) {
|
|
|
|
|
return -EINVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
event = new_usb_cdc_rx_event(len);
|
|
|
|
|
if (len > 0U) {
|
|
|
|
|
memcpy(event->dyndata.data, data, len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
APP_EVENT_SUBMIT(event);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-11 17:15:11 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* BLINKY_USB_CDC_RX_EVENT_H_ */
|