72 lines
1.7 KiB
C
72 lines
1.7 KiB
C
|
|
#ifndef BLINKY_USB_CONTROL_EVENT_H_
|
||
|
|
#define BLINKY_USB_CONTROL_EVENT_H_
|
||
|
|
|
||
|
|
#include <stdbool.h>
|
||
|
|
#include <stdint.h>
|
||
|
|
|
||
|
|
#include <app_event_manager.h>
|
||
|
|
#include <app_event_manager_profiler_tracer.h>
|
||
|
|
#include <zephyr/device.h>
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
extern "C" {
|
||
|
|
#endif
|
||
|
|
|
||
|
|
enum usb_control_event_type {
|
||
|
|
USB_CONTROL_EVENT_CDC_LINE_STATE = 0,
|
||
|
|
USB_CONTROL_EVENT_CDC_LINE_CODING,
|
||
|
|
};
|
||
|
|
|
||
|
|
struct usb_control_event {
|
||
|
|
struct app_event_header header;
|
||
|
|
enum usb_control_event_type type;
|
||
|
|
const struct device *dev;
|
||
|
|
union {
|
||
|
|
struct {
|
||
|
|
bool dtr;
|
||
|
|
} cdc_line_state;
|
||
|
|
struct {
|
||
|
|
uint32_t baudrate;
|
||
|
|
uint8_t data_bits;
|
||
|
|
uint8_t stop_bits;
|
||
|
|
uint8_t parity;
|
||
|
|
uint8_t flow_ctrl;
|
||
|
|
} cdc_line_coding;
|
||
|
|
} data;
|
||
|
|
};
|
||
|
|
|
||
|
|
APP_EVENT_TYPE_DECLARE(usb_control_event);
|
||
|
|
|
||
|
|
static inline void submit_usb_control_cdc_line_state_event(
|
||
|
|
const struct device *dev, bool dtr)
|
||
|
|
{
|
||
|
|
struct usb_control_event *event = new_usb_control_event();
|
||
|
|
|
||
|
|
event->type = USB_CONTROL_EVENT_CDC_LINE_STATE;
|
||
|
|
event->dev = dev;
|
||
|
|
event->data.cdc_line_state.dtr = dtr;
|
||
|
|
APP_EVENT_SUBMIT(event);
|
||
|
|
}
|
||
|
|
|
||
|
|
static inline void submit_usb_control_cdc_line_coding_event(
|
||
|
|
const struct device *dev, uint32_t baudrate, uint8_t data_bits,
|
||
|
|
uint8_t stop_bits, uint8_t parity, uint8_t flow_ctrl)
|
||
|
|
{
|
||
|
|
struct usb_control_event *event = new_usb_control_event();
|
||
|
|
|
||
|
|
event->type = USB_CONTROL_EVENT_CDC_LINE_CODING;
|
||
|
|
event->dev = dev;
|
||
|
|
event->data.cdc_line_coding.baudrate = baudrate;
|
||
|
|
event->data.cdc_line_coding.data_bits = data_bits;
|
||
|
|
event->data.cdc_line_coding.stop_bits = stop_bits;
|
||
|
|
event->data.cdc_line_coding.parity = parity;
|
||
|
|
event->data.cdc_line_coding.flow_ctrl = flow_ctrl;
|
||
|
|
APP_EVENT_SUBMIT(event);
|
||
|
|
}
|
||
|
|
|
||
|
|
#ifdef __cplusplus
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
#endif /* BLINKY_USB_CONTROL_EVENT_H_ */
|