27 #if (HAL_USE_SERIAL_USB == TRUE) || defined(__DOXYGEN__) 45 {0x00, 0x96, 0x00, 0x00},
46 LC_STOP_1, LC_PARITY_NONE, 8
85 static size_t _write(
void *ip,
const uint8_t *bp,
size_t n) {
91 static size_t _read(
void *ip, uint8_t *bp,
size_t n) {
97 static msg_t _put(
void *ip, uint8_t b) {
102 static msg_t _get(
void *ip) {
117 static size_t _writet(
void *ip,
const uint8_t *bp,
size_t n,
123 static size_t _readt(
void *ip, uint8_t *bp,
size_t n,
129 static msg_t _ctl(
void *ip,
unsigned int operation,
void *arg) {
138 case CHN_CTL_INVALID:
142 #if defined(SDU_LLD_IMPLEMENTS_CTL) 146 unsigned int operation,
148 return sdu_lld_control(sdup, operation, arg);
158 _write, _read, _put, _get,
159 _putt, _gett, _writet, _readt,
170 (void) sdu_start_receive(sdup);
254 if (config->
int_in > 0U) {
257 sdup->config = config;
282 usbp->
in_params[sdup->config->bulk_in - 1U] = NULL;
283 usbp->
out_params[sdup->config->bulk_out - 1U] = NULL;
284 if (sdup->config->int_in > 0U) {
285 usbp->
in_params[sdup->config->int_in - 1U] = NULL;
351 (void) sdu_start_receive(sdup);
371 if ((usbp->
setup[0] & USB_RTYPE_TYPE_MASK) == USB_RTYPE_TYPE_CLASS) {
372 switch (usbp->
setup[1]) {
373 case CDC_GET_LINE_CODING:
376 case CDC_SET_LINE_CODING:
379 case CDC_SET_CONTROL_LINE_STATE:
498 sdup->config->bulk_out);
499 if (size > (
size_t)0) {
510 (void) sdu_start_receive(sdup);
545 return _ctl((
void *)usbp, operation, arg);
uint8_t * ibqGetEmptyBufferI(input_buffers_queue_t *ibqp)
Gets the next empty buffer from the queue.
static void ibnotify(io_buffers_queue_t *bqp)
Notification of empty buffer released into the input buffers queue.
uint8_t * obqGetFullBufferI(output_buffers_queue_t *obqp, size_t *sizep)
Gets the next filled buffer from the queue.
uint16_t in_maxsize
IN endpoint maximum packet size.
void obqReleaseEmptyBufferI(output_buffers_queue_t *obqp)
Releases the next filled buffer back in the queue.
const USBEndpointConfig * epc[USB_MAX_ENDPOINTS+1]
Active endpoints configurations.
uint8_t setup[8]
Setup packet buffer.
USBDriver * usbp
USB driver to use.
void sduWakeupHookI(SerialUSBDriver *sdup)
USB device wakeup handler.
void sduStop(SerialUSBDriver *sdup)
Stops the driver.
size_t txsize
Requested transmit transfer size.
#define usbGetReceiveStatusI(usbp, ep)
Returns the status of an OUT endpoint.
void sduConfigureHookI(SerialUSBDriver *sdup)
USB device configured handler.
void sduInterruptTransmitted(USBDriver *usbp, usbep_t ep)
Default data received callback.
void sduInit(void)
Serial Driver initialization.
#define bqSuspendI(bqp)
Puts the queue in suspended state.
static void osalSysLockFromISR(void)
Enters a critical zone from ISR context.
bool sduRequestsHook(USBDriver *usbp)
Default requests hook.
void sduDataTransmitted(USBDriver *usbp, usbep_t ep)
Default data transmitted callback.
void ibqResetI(input_buffers_queue_t *ibqp)
Resets an input buffers queue.
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
const struct SerialUSBDriverVMT * vmt
Virtual Methods Table.
void osalOsRescheduleS(void)
Checks if a reschedule is required and performs it.
Type of Line Coding structure.
static void osalEventObjectInit(event_source_t *esp)
Initializes an event source object.
Structure representing an USB driver.
usbep_t bulk_out
Bulk OUT endpoint used for incoming data transfer.
void * out_params[USB_MAX_ENDPOINTS]
Fields available to user, it can be used to associate an application-defined handler to an OUT endpoi...
void sduStart(SerialUSBDriver *sdup, const SerialUSBConfig *config)
Configures and starts the driver.
int32_t msg_t
Type of a message.
size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp, size_t n, sysinterval_t timeout)
Input queue read with timeout.
#define SERIAL_USB_BUFFERS_SIZE
Serial over USB buffers size.
#define usbGetDriverStateI(usbp)
Returns the driver state.
void sduSOFHookI(SerialUSBDriver *sdup)
SOF handler.
void ibqPostFullBufferI(input_buffers_queue_t *ibqp, size_t size)
Posts a new filled buffer to the queue.
size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp, size_t n, sysinterval_t timeout)
Output queue write with timeout.
void sduDataReceived(USBDriver *usbp, usbep_t ep)
Default data received callback.
bool obqTryFlushI(output_buffers_queue_t *obqp)
Flushes the current, partially filled, buffer to the queue.
#define usbGetTransmitStatusI(usbp, ep)
Returns the status of an IN endpoint.
void usbStartReceiveI(USBDriver *usbp, usbep_t ep, uint8_t *buf, size_t n)
Starts a receive transaction on an OUT endpoint.
void sduObjectInit(SerialUSBDriver *sdup)
Initializes a generic full duplex driver object.
void obqObjectInit(output_buffers_queue_t *obqp, bool suspended, uint8_t *bp, size_t size, size_t n, bqnotify_t onfy, void *link)
Initializes an output buffers queue object.
#define osalDbgCheck(c)
Function parameters check.
static void osalSysUnlockFromISR(void)
Leaves a critical zone from ISR context.
usbep_t bulk_in
Bulk IN endpoint used for outgoing data transfer.
#define CHN_CONNECTED
Connection happened.
uint32_t sysinterval_t
Type of system time interval.
usbep_t int_in
Interrupt IN endpoint used for notifications.
msg_t obqPutTimeout(output_buffers_queue_t *obqp, uint8_t b, sysinterval_t timeout)
Output queue write with timeout.
static void obnotify(io_buffers_queue_t *bqp)
Notification of filled buffer inserted into the output buffers queue.
Structure of a generic buffers queue.
void * in_params[USB_MAX_ENDPOINTS]
Fields available to user, it can be used to associate an application-defined handler to an IN endpoin...
static void osalSysLock(void)
Enters a critical zone from thread context.
#define bqResumeX(bqp)
Resumes normal queue operations.
msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, sysinterval_t timeout)
Input queue read with timeout.
void obqResetI(output_buffers_queue_t *obqp)
Resets an output buffers queue.
void sduSuspendHookI(SerialUSBDriver *sdup)
USB device suspend handler.
#define bqGetLinkX(bqp)
Returns the queue application-defined link.
Full duplex serial driver class.
#define chnAddFlagsI(ip, flags)
Adds status flags to the listeners's flags mask.
SerialDriver virtual methods table.
#define osalDbgAssert(c, remark)
Condition assertion.
#define CHN_OUTPUT_EMPTY
Output queue empty.
uint8_t usbep_t
Type of an endpoint identifier.
msg_t sduControl(USBDriver *usbp, unsigned int operation, void *arg)
Control operation on a serial USB port.
#define CHN_DISCONNECTED
Disconnection happened.
void usbStartTransmitI(USBDriver *usbp, usbep_t ep, const uint8_t *buf, size_t n)
Starts a transmit transaction on an IN endpoint.
#define CHN_INPUT_AVAILABLE
Data available in the input queue.
void ibqObjectInit(input_buffers_queue_t *ibqp, bool suspended, uint8_t *bp, size_t size, size_t n, bqnotify_t infy, void *link)
Initializes an input buffers queue object.
Serial over USB Driver configuration structure.
#define usbSetupTransfer(usbp, buf, n, endcb)
Request transfer setup.
USBInEndpointState * in_state
USBEndpointState associated to the IN endpoint.
#define SERIAL_USB_BUFFERS_NUMBER
Serial over USB number of buffers.
#define usbGetReceiveTransactionSizeX(usbp, ep)
Returns the exact size of a receive transaction.