Update state after RESUME event.
Use LOG_INF for important events and log a
warning if the data is discarded.
Fixes#17488
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
move misc/byteorder.h to sys/byteorder.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move ring_buffer.h to sys/ring_buffer.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
move uart.h to drivers/uart.h and
create a shim for backward-compatibility.
No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.
Related to #16539
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
USBD_CFG_DATA_DEFINE macro has not consider that a class
could have more than one set of usb_cfg_data struct.
If a class has more than one set of usb_cfg_data
then they should be sorted the same way like by
USBD_DEVICE_DESCR_DEFINE macro.
Fixes: #16240
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Remove duplicated execution path for composite configuration, USB
device stack initialization is done inside stack for both cases.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
In order to unify the legacy and composite code, move the class and
vendor request handler buffer into the USB device code, just like in
composite mode. The option is renamed from USB_COMPOSITE_BUFFER_SIZE
into USB_REQUEST_BUFFER_SIZE and also replaces the USB_DFU_MAX_XFER_SIZE
and USB_HID_MAX_PAYLOAD_SIZE options.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Interface Association descriptor has to be used with Windows 7.
Add CONFIG_CDC_ACM_IAD option to force its usage, disabled by default.
Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
Use new method for defining USB CDC ACM devices using UTIL_LISTIFY and
device count from menuconfig.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Added bBreak, bRingSignal, bFraming, bParity and bOverRun
handling in cdc_acm_line_ctrl_set.
Reference: Chapter 6.5.4 of Universal Serial Bus Communications Class
Subclass Specification for PSTN Devices rev 1.2
Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
Merge cb_usb_status_composite and cb_usb_status and use common
forward_status_cb for both composite and normal devices.
Fixes#14882
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Use ringbuf library for handling RX CDC ACM path. Remove old code
artifacts handling specific hardware.
Fixes#14288
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Add new status callback with usb_cfg_data parameter to be able to
identify instance callback.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Add interface parameter to interface configuration callback to be able
to configure several instances of the same class.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This allows to place instances of the class one after another in the
linker section.
Fixes#12908
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Fixes bug below:
subsys/usb/class/cdc_acm.c:554:15: error: ‘dev_data’ undeclared (first
use in this function) k_work_init(&dev_data->cb_work,
cdc_acm_irq_callback_work_handler); ^~~~~~~~
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
The IRQ callback function of the USB CDC ACM driver can currently be
called from:
- the USB thread when a bulk in or a bulk out interrupt has been
triggered
- the thread calling cdc_acm_irq_rx_enable or cdc_acm_irq_tx_enable when
enabling the interrupt fires an irq (ie if there is data to read or if
there is no pending data to send)
This causes some issues with at least the shell uart backend, as the
IRQ callback function ends up being called twice concurrently in case a
USB driver sends the requested data almost instantaneously. This is the
case for example of the USB nRF driver which uses DMA. In turn this
cause ring_buf_item_get to be called concurrently, leading to data
corruption:
uart:~$ help
Please press the <Tab> button to see all available commandands.
You can also use the e <Tab> button to prompt or auto-coomplelete all
commands or its subcommands.
You can try toto call commands with <-h> or <--help> parameter for
more informatation.
uart:~$
Fix that by always calling the IRQ callback function through the system
work queue.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Commit e4c447aac3 ("usb: add SoF event") added support for calling the
status callback with the USB_DC_SOF value for each SoF when
CONFIG_USB_DEVICE_SOF is enabled. The CDC ACM driver saves the latest
received status and compares it USB_DC_CONFIGURED to decide if it can
send data to the host. This therefore doesn't work any more when the
status callback is called regulary with USB_DC_SOF.
Fix that by ignoring USB_DC_SOF when saving the latest received status.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
The CDC ACM driver has to emulate the TX and RX interrupts from the USB
ones. However it does not correctly emulate them as "TX buffer empty"
and "RX buffer not empty" interrupts.
For "TX buffer empty" interrupt:
- Reading the interrupt status should not clear the interrupt
- Enabling the interrupt should fire an interrupt if the TX buffer is
empty
- An interrupt should be triggered when the USB device get configured
For "RX buffer not empty" interrupt:
- Reading the interrupt status should not clear the interrupt
- Enabling the interrupt should fire an interrupt if the RX buffer is
not empty
This make the a console on the USB CDC ACM port usable for the shell
and the logs.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
poll_out function was returning the character that was sent. It
happens that it is always constant and the return of this functions is
never tested. Changing it to be a void function.
MISRA-C rule 17.7
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Start of Frame events can now be accessed from USB classes.
This will be useful when implementing idle rate functionality.
Signed-off-by: Marcin Szymczyk <Marcin.Szymczyk@nordicsemi.no>
Couple of findings which were revealed after changing
LOG_MODULE_REGISTER macro:
- missing semicolons after LOG_MODULE_REGISTER()
- missing LOG_LEVEL defines
- other
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
usb_dc_status_callback() parameters are interface or configuration
numbers and should be const.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Zephyr UART drivers offer very low-level functionality. Oftentimes,
it would be useful to provide higher-level wrappers around UART
device which would offer additional functionality. However, UART
driver irq callback routine receives just a pointer to (low-level)
UART device, and it's not possible to get to a wrapper structure
(without introducing expensive external mapping structures). This
is an indirect reason why the current UARt wrappers - uart_pipe,
console - are instantiated statically just for one underlying UART
device and cannot be reused for multiple devices.
Solve this by allowing to pass an arbitrary user data to irq
callback, set by new uart_irq_callback_user_data_set() function.
Existing uart_irq_callback_set() keeps setting a callback which
will receive pointer to the device.
While public API maintains compatibility, drivers themselves need
to be updated to support arbitrary user data storage/passing (as
legacy uart_irq_callback_set() functionality is now implemented in
terms of it).
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Remove all CONFIG_*_EP_ADDR options but keep the default
values for it, as they are necessary to find ep_addr in
usb_ep_cfg_data associated with bEndpointAddress in
interface descriptor.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Adapt functions for new composite interface.
Assign bInterfaceNumber and similar variables of a Interface
default values, these should be valid values for non-composite
configuration. For the case of the composite configuration,
these variables must be set by the interface configuration
function (interface_config) accordingly.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
This patch changes all class functions so that the endpoint
address will be retrieved from the usb_ep_cfg_data at runtime.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
This patch moves the descriptor parts to related class
and function drivers and extends the usb_fix_descriptor
function so that the wTotalLength and bNumInterfaces
are corrected before enumeration.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
As per uart_pipe.c, irq_is_pending should only return true if any
*unmasked* interrupts are pending.
The device_get_binding() code only checks devices that have an API.
Set the API at compile time so that other devices can refer to the CDC
ACM driver.
usb_write() may return EBUSY if the endpoint is full. Propagate this
for future use.
Signed-off-by: Michael Hope <mlhx@google.com>