nrfx_usbd: Rename to nrf_usbd_common
Rename local usbd copy from nrfx_usbd to nrf_usbd_common and use it in both USB stacks. Renaming header to nrf_usbd_common.h allows breaking changes in exposed interface. Mark all doxygen comments as internal because local usbd copy should not be treated as public interface because we are under refactoring process that aims to arrive at native driver and therefore drop nrf_usbd_common in the future. Use Zephyr constructs directly instead of nrfx glue macros. No functional changes. Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
This commit is contained in:
parent
2010d4d599
commit
8db6919695
|
@ -5,3 +5,4 @@ add_subdirectory_ifdef(CONFIG_UHC_DRIVER uhc)
|
|||
add_subdirectory_ifdef(CONFIG_UVB uvb)
|
||||
add_subdirectory_ifdef(CONFIG_USB_BC12 bc12)
|
||||
add_subdirectory_ifdef(CONFIG_USB_DEVICE_DRIVER device)
|
||||
add_subdirectory(common)
|
||||
|
|
|
@ -8,3 +8,4 @@ source "drivers/usb/udc/Kconfig"
|
|||
source "drivers/usb/uhc/Kconfig"
|
||||
source "drivers/usb/uvb/Kconfig"
|
||||
source "drivers/usb/device/Kconfig"
|
||||
source "drivers/usb/common/Kconfig"
|
||||
|
|
3
drivers/usb/common/CMakeLists.txt
Normal file
3
drivers/usb/common/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
add_subdirectory_ifdef(CONFIG_HAS_NRFX nrf_usbd_common)
|
4
drivers/usb/common/Kconfig
Normal file
4
drivers/usb/common/Kconfig
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Copyright (c) 2023 Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
rsource "nrf_usbd_common/Kconfig"
|
10
drivers/usb/common/nrf_usbd_common/CMakeLists.txt
Normal file
10
drivers/usb/common/nrf_usbd_common/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
# Copyright (c) 2021 Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CONFIG_NRF_USBD_COMMON)
|
||||
zephyr_library()
|
||||
|
||||
zephyr_include_directories(.)
|
||||
|
||||
zephyr_library_sources(nrf_usbd_common.c)
|
||||
endif()
|
20
drivers/usb/common/nrf_usbd_common/Kconfig
Normal file
20
drivers/usb/common/nrf_usbd_common/Kconfig
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Copyright (c) 2016-2023 Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module = NRF_USBD_COMMON
|
||||
module-str = nRF USBD common
|
||||
source "subsys/logging/Kconfig.template.log_config"
|
||||
|
||||
config NRF_USBD_COMMON
|
||||
bool "USBD driver"
|
||||
depends on HAS_NRFX
|
||||
depends on $(dt_has_compat,$(DT_COMPAT_NORDIC_NRF_USBD))
|
||||
|
||||
config NRF_USBD_ISO_IN_ZLP
|
||||
bool "Send ZLP on ISO IN when not ready"
|
||||
depends on NRF_USBD_COMMON
|
||||
default y
|
||||
help
|
||||
Controls the response of the ISO IN endpoint to an IN token when no
|
||||
data is ready to be sent. When enabled, ZLP is sent when no data is
|
||||
ready. When disabled, no response is sent (bus timeout occurs).
|
File diff suppressed because it is too large
Load diff
|
@ -4,8 +4,12 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef NRFX_USBD_H__
|
||||
#define NRFX_USBD_H__
|
||||
/* This file is undergoing transition towards native Zephyr nrf USB driver. */
|
||||
|
||||
/** @cond INTERNAL_HIDDEN */
|
||||
|
||||
#ifndef NRF_USBD_COMMON_H__
|
||||
#define NRF_USBD_COMMON_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <hal/nrf_usbd.h>
|
||||
|
@ -15,7 +19,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/**
|
||||
* @defgroup nrfx_usbd USBD driver
|
||||
* @defgroup nrf_usbd_common USBD driver
|
||||
* @{
|
||||
* @ingroup nrf_usbd
|
||||
* @brief Universal Serial Bus Device (USBD) peripheral driver.
|
||||
|
@ -24,7 +28,7 @@ extern "C" {
|
|||
/**
|
||||
* @brief Number of bytes in the endpoint.
|
||||
*/
|
||||
#define NRFX_USBD_EPSIZE 64
|
||||
#define NRF_USBD_COMMON_EPSIZE 64
|
||||
|
||||
/**
|
||||
* @brief Number of bytes for isochronous endpoints.
|
||||
|
@ -35,14 +39,14 @@ extern "C" {
|
|||
* @sa nrf_usbd_isosplit_set
|
||||
* @sa nrf_usbd_isosplit_get
|
||||
*/
|
||||
#define NRFX_USBD_ISOSIZE 1023
|
||||
#define NRF_USBD_COMMON_ISOSIZE 1023
|
||||
|
||||
/**
|
||||
* @brief The size of internal feeder buffer.
|
||||
*
|
||||
* @sa nrfx_usbd_feeder_buffer_get
|
||||
* @sa nrf_usbd_common_feeder_buffer_get
|
||||
*/
|
||||
#define NRFX_USBD_FEEDER_BUFFER_SIZE NRFX_USBD_EPSIZE
|
||||
#define NRF_USBD_COMMON_FEEDER_BUFFER_SIZE NRF_USBD_COMMON_EPSIZE
|
||||
|
||||
/**
|
||||
* @name Macros for creating endpoint identifiers.
|
||||
|
@ -60,7 +64,7 @@ extern "C" {
|
|||
*
|
||||
* @return Endpoint identifier that connects endpoint number and endpoint direction.
|
||||
*/
|
||||
#define NRFX_USBD_EPIN(n) ((nrfx_usbd_ep_t)NRF_USBD_EPIN(n))
|
||||
#define NRF_USBD_COMMON_EPIN(n) ((nrf_usbd_common_ep_t)NRF_USBD_EPIN(n))
|
||||
/**
|
||||
* @brief Create identifier for OUT endpoint.
|
||||
*
|
||||
|
@ -70,7 +74,7 @@ extern "C" {
|
|||
*
|
||||
* @return Endpoint identifier that connects endpoint number and endpoint direction.
|
||||
*/
|
||||
#define NRFX_USBD_EPOUT(n) ((nrfx_usbd_ep_t)NRF_USBD_EPOUT(n))
|
||||
#define NRF_USBD_COMMON_EPOUT(n) ((nrf_usbd_common_ep_t)NRF_USBD_EPOUT(n))
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
@ -80,26 +84,26 @@ extern "C" {
|
|||
* This endpoint number is consistent with USB 2.0 specification.
|
||||
*/
|
||||
typedef enum {
|
||||
NRFX_USBD_EPOUT0 = NRF_USBD_EPOUT(0), /**< Endpoint OUT 0 */
|
||||
NRFX_USBD_EPOUT1 = NRF_USBD_EPOUT(1), /**< Endpoint OUT 1 */
|
||||
NRFX_USBD_EPOUT2 = NRF_USBD_EPOUT(2), /**< Endpoint OUT 2 */
|
||||
NRFX_USBD_EPOUT3 = NRF_USBD_EPOUT(3), /**< Endpoint OUT 3 */
|
||||
NRFX_USBD_EPOUT4 = NRF_USBD_EPOUT(4), /**< Endpoint OUT 4 */
|
||||
NRFX_USBD_EPOUT5 = NRF_USBD_EPOUT(5), /**< Endpoint OUT 5 */
|
||||
NRFX_USBD_EPOUT6 = NRF_USBD_EPOUT(6), /**< Endpoint OUT 6 */
|
||||
NRFX_USBD_EPOUT7 = NRF_USBD_EPOUT(7), /**< Endpoint OUT 7 */
|
||||
NRFX_USBD_EPOUT8 = NRF_USBD_EPOUT(8), /**< Endpoint OUT 8 */
|
||||
NRF_USBD_COMMON_EPOUT0 = NRF_USBD_EPOUT(0), /**< Endpoint OUT 0 */
|
||||
NRF_USBD_COMMON_EPOUT1 = NRF_USBD_EPOUT(1), /**< Endpoint OUT 1 */
|
||||
NRF_USBD_COMMON_EPOUT2 = NRF_USBD_EPOUT(2), /**< Endpoint OUT 2 */
|
||||
NRF_USBD_COMMON_EPOUT3 = NRF_USBD_EPOUT(3), /**< Endpoint OUT 3 */
|
||||
NRF_USBD_COMMON_EPOUT4 = NRF_USBD_EPOUT(4), /**< Endpoint OUT 4 */
|
||||
NRF_USBD_COMMON_EPOUT5 = NRF_USBD_EPOUT(5), /**< Endpoint OUT 5 */
|
||||
NRF_USBD_COMMON_EPOUT6 = NRF_USBD_EPOUT(6), /**< Endpoint OUT 6 */
|
||||
NRF_USBD_COMMON_EPOUT7 = NRF_USBD_EPOUT(7), /**< Endpoint OUT 7 */
|
||||
NRF_USBD_COMMON_EPOUT8 = NRF_USBD_EPOUT(8), /**< Endpoint OUT 8 */
|
||||
|
||||
NRFX_USBD_EPIN0 = NRF_USBD_EPIN(0), /**< Endpoint IN 0 */
|
||||
NRFX_USBD_EPIN1 = NRF_USBD_EPIN(1), /**< Endpoint IN 1 */
|
||||
NRFX_USBD_EPIN2 = NRF_USBD_EPIN(2), /**< Endpoint IN 2 */
|
||||
NRFX_USBD_EPIN3 = NRF_USBD_EPIN(3), /**< Endpoint IN 3 */
|
||||
NRFX_USBD_EPIN4 = NRF_USBD_EPIN(4), /**< Endpoint IN 4 */
|
||||
NRFX_USBD_EPIN5 = NRF_USBD_EPIN(5), /**< Endpoint IN 5 */
|
||||
NRFX_USBD_EPIN6 = NRF_USBD_EPIN(6), /**< Endpoint IN 6 */
|
||||
NRFX_USBD_EPIN7 = NRF_USBD_EPIN(7), /**< Endpoint IN 7 */
|
||||
NRFX_USBD_EPIN8 = NRF_USBD_EPIN(8), /**< Endpoint IN 8 */
|
||||
} nrfx_usbd_ep_t;
|
||||
NRF_USBD_COMMON_EPIN0 = NRF_USBD_EPIN(0), /**< Endpoint IN 0 */
|
||||
NRF_USBD_COMMON_EPIN1 = NRF_USBD_EPIN(1), /**< Endpoint IN 1 */
|
||||
NRF_USBD_COMMON_EPIN2 = NRF_USBD_EPIN(2), /**< Endpoint IN 2 */
|
||||
NRF_USBD_COMMON_EPIN3 = NRF_USBD_EPIN(3), /**< Endpoint IN 3 */
|
||||
NRF_USBD_COMMON_EPIN4 = NRF_USBD_EPIN(4), /**< Endpoint IN 4 */
|
||||
NRF_USBD_COMMON_EPIN5 = NRF_USBD_EPIN(5), /**< Endpoint IN 5 */
|
||||
NRF_USBD_COMMON_EPIN6 = NRF_USBD_EPIN(6), /**< Endpoint IN 6 */
|
||||
NRF_USBD_COMMON_EPIN7 = NRF_USBD_EPIN(7), /**< Endpoint IN 7 */
|
||||
NRF_USBD_COMMON_EPIN8 = NRF_USBD_EPIN(8), /**< Endpoint IN 8 */
|
||||
} nrf_usbd_common_ep_t;
|
||||
|
||||
/**
|
||||
* @brief Events generated by the driver.
|
||||
|
@ -107,15 +111,15 @@ typedef enum {
|
|||
* Enumeration of possible events that may be generated by the driver.
|
||||
*/
|
||||
typedef enum {
|
||||
NRFX_USBD_EVT_SOF, /**< Start Of Frame event on USB bus detected. */
|
||||
NRFX_USBD_EVT_RESET, /**< Reset condition on USB bus detected. */
|
||||
NRFX_USBD_EVT_SUSPEND, /**< This device should go to suspend mode now. */
|
||||
NRFX_USBD_EVT_RESUME, /**< This device should resume from suspend now. */
|
||||
NRF_USBD_COMMON_EVT_SOF, /**< Start Of Frame event on USB bus detected. */
|
||||
NRF_USBD_COMMON_EVT_RESET, /**< Reset condition on USB bus detected. */
|
||||
NRF_USBD_COMMON_EVT_SUSPEND, /**< This device should go to suspend mode now. */
|
||||
NRF_USBD_COMMON_EVT_RESUME, /**< This device should resume from suspend now. */
|
||||
/** Wakeup request - the USBD peripheral is ready to generate
|
||||
* WAKEUP signal after exiting low power mode.
|
||||
*/
|
||||
NRFX_USBD_EVT_WUREQ,
|
||||
NRFX_USBD_EVT_SETUP, /**< Setup frame received and decoded. */
|
||||
NRF_USBD_COMMON_EVT_WUREQ,
|
||||
NRF_USBD_COMMON_EVT_SETUP, /**< Setup frame received and decoded. */
|
||||
/** For Rx (OUT: Host->Device):
|
||||
* 1. The packet has been received but there is no buffer
|
||||
* prepared for transfer already.
|
||||
|
@ -125,21 +129,21 @@ typedef enum {
|
|||
* The last packet from requested transfer has been transferred
|
||||
* over USB bus and acknowledged.
|
||||
*/
|
||||
NRFX_USBD_EVT_EPTRANSFER,
|
||||
NRFX_USBD_EVT_CNT /**< Number of defined events. */
|
||||
} nrfx_usbd_event_type_t;
|
||||
NRF_USBD_COMMON_EVT_EPTRANSFER,
|
||||
NRF_USBD_COMMON_EVT_CNT /**< Number of defined events. */
|
||||
} nrf_usbd_common_event_type_t;
|
||||
|
||||
/**
|
||||
* @brief Endpoint status codes.
|
||||
*
|
||||
* Status codes that may be returned by @ref nrfx_usbd_ep_status_get or, except for
|
||||
* @ref NRFX_USBD_EP_BUSY, reported together with @ref NRFX_USBD_EVT_EPTRANSFER.
|
||||
* Status codes that may be returned by @ref nrf_usbd_common_ep_status_get or, except for
|
||||
* @ref NRF_USBD_COMMON_EP_BUSY, reported together with @ref NRF_USBD_COMMON_EVT_EPTRANSFER.
|
||||
*/
|
||||
typedef enum {
|
||||
/** No error occurred. */
|
||||
NRFX_USBD_EP_OK,
|
||||
NRF_USBD_COMMON_EP_OK,
|
||||
/** Data received, no buffer prepared already - waiting for configured transfer. */
|
||||
NRFX_USBD_EP_WAITING,
|
||||
NRF_USBD_COMMON_EP_WAITING,
|
||||
/** Received number of bytes cannot fit given buffer.
|
||||
* This error would also be returned when next_transfer function
|
||||
* has been defined but currently received data cannot fit completely
|
||||
|
@ -149,14 +153,14 @@ typedef enum {
|
|||
* When this error is reported - data is left inside endpoint
|
||||
* buffer. Clear endpoint or prepare new buffer and read it.
|
||||
*/
|
||||
NRFX_USBD_EP_OVERLOAD,
|
||||
NRF_USBD_COMMON_EP_OVERLOAD,
|
||||
/** EP0 transfer can be aborted when new setup comes.
|
||||
* Any other transfer can be aborted by USB reset or driver stopping.
|
||||
*/
|
||||
NRFX_USBD_EP_ABORTED,
|
||||
NRF_USBD_COMMON_EP_ABORTED,
|
||||
/** Transfer is in progress. */
|
||||
NRFX_USBD_EP_BUSY,
|
||||
} nrfx_usbd_ep_status_t;
|
||||
NRF_USBD_COMMON_EP_BUSY,
|
||||
} nrf_usbd_common_ep_status_t;
|
||||
|
||||
/**
|
||||
* @brief Event structure.
|
||||
|
@ -164,27 +168,27 @@ typedef enum {
|
|||
* Structure passed to event handler.
|
||||
*/
|
||||
typedef struct {
|
||||
nrfx_usbd_event_type_t type; /**< Event type. */
|
||||
nrf_usbd_common_event_type_t type; /**< Event type. */
|
||||
union {
|
||||
struct {
|
||||
uint16_t framecnt; /**< Current value of frame counter. */
|
||||
} sof; /**< Data available for @ref NRFX_USBD_EVT_SOF. */
|
||||
} sof; /**< Data available for @ref NRF_USBD_COMMON_EVT_SOF. */
|
||||
struct {
|
||||
nrfx_usbd_ep_t ep; /**< Endpoint number. */
|
||||
nrf_usbd_common_ep_t ep; /**< Endpoint number. */
|
||||
} isocrc; /**< Isochronouns channel endpoint number. */
|
||||
struct {
|
||||
nrfx_usbd_ep_t ep; /**< Endpoint number. */
|
||||
nrfx_usbd_ep_status_t status; /**< Status for the endpoint. */
|
||||
nrf_usbd_common_ep_t ep; /**< Endpoint number. */
|
||||
nrf_usbd_common_ep_status_t status; /**< Status for the endpoint. */
|
||||
} eptransfer; /**< Endpoint transfer status. */
|
||||
} data; /**< Union to store event data. */
|
||||
} nrfx_usbd_evt_t;
|
||||
} nrf_usbd_common_evt_t;
|
||||
|
||||
/**
|
||||
* @brief USBD event callback function type.
|
||||
*
|
||||
* @param[in] p_event Event information structure.
|
||||
*/
|
||||
typedef void (*nrfx_usbd_event_handler_t)(nrfx_usbd_evt_t const *p_event);
|
||||
typedef void (*nrf_usbd_common_event_handler_t)(nrf_usbd_common_evt_t const *p_event);
|
||||
|
||||
/**
|
||||
* @brief Universal data pointer.
|
||||
|
@ -195,7 +199,7 @@ typedef union {
|
|||
void const *tx; /*!< Constant TX buffer pointer. */
|
||||
void *rx; /*!< Writable RX buffer pointer. */
|
||||
uint32_t addr; /*!< Numeric value used internally by the driver. */
|
||||
} nrfx_usbd_data_ptr_t;
|
||||
} nrf_usbd_common_data_ptr_t;
|
||||
|
||||
/**
|
||||
* @brief Structure to be filled with information about the next transfer.
|
||||
|
@ -205,9 +209,11 @@ typedef union {
|
|||
* can never be higher than the endpoint size.
|
||||
*/
|
||||
typedef struct {
|
||||
nrfx_usbd_data_ptr_t p_data; /*!< Union with available data pointers used by the driver. */
|
||||
size_t size; /*!< Size of the requested transfer. */
|
||||
} nrfx_usbd_ep_transfer_t;
|
||||
/** Union with available data pointers used by the driver. */
|
||||
nrf_usbd_common_data_ptr_t p_data;
|
||||
/** Size of the requested transfer. */
|
||||
size_t size;
|
||||
} nrf_usbd_common_ep_transfer_t;
|
||||
|
||||
/**
|
||||
* @brief Flags for the current transfer.
|
||||
|
@ -215,8 +221,8 @@ typedef struct {
|
|||
* Flags configured for the transfer that can be merged using the bitwise 'or' operator (|).
|
||||
*/
|
||||
typedef enum {
|
||||
NRFX_USBD_TRANSFER_ZLP_FLAG = 1U << 0, /*!< Add a zero-length packet. */
|
||||
} nrfx_usbd_transfer_flags_t;
|
||||
NRF_USBD_COMMON_TRANSFER_ZLP_FLAG = 1U << 0, /*!< Add a zero-length packet. */
|
||||
} nrf_usbd_common_transfer_flags_t;
|
||||
|
||||
/**
|
||||
* @brief Total transfer configuration.
|
||||
|
@ -225,11 +231,13 @@ typedef enum {
|
|||
* It is used by internal built-in feeders and consumers.
|
||||
*/
|
||||
typedef struct {
|
||||
nrfx_usbd_data_ptr_t p_data; /*!< Union with available data pointers used by the driver. */
|
||||
size_t size; /*!< Total size of the requested transfer. */
|
||||
uint32_t flags; /*!< Transfer flags. */
|
||||
/**< Use the @ref nrfx_usbd_transfer_flags_t values. */
|
||||
} nrfx_usbd_transfer_t;
|
||||
/** Union with available data pointers used by the driver. */
|
||||
nrf_usbd_common_data_ptr_t p_data;
|
||||
/** Total size of the requested transfer. */
|
||||
size_t size;
|
||||
/*!< Transfer flags. Use the @ref nrf_usbd_common_transfer_flags_t values. */
|
||||
uint32_t flags;
|
||||
} nrf_usbd_common_transfer_t;
|
||||
|
||||
/**
|
||||
* @brief Auxiliary macro for declaring IN transfer description with optional flags.
|
||||
|
@ -239,23 +247,23 @@ typedef struct {
|
|||
* @param name Instance name.
|
||||
* @param tx_buff Buffer to transfer.
|
||||
* @param tx_size Transfer size.
|
||||
* @param tx_flags Flags for the transfer (see @ref nrfx_usbd_transfer_flags_t).
|
||||
* @param tx_flags Flags for the transfer (see @ref nrf_usbd_common_transfer_flags_t).
|
||||
*
|
||||
* @return Configured variable with total transfer description.
|
||||
*/
|
||||
#define NRFX_USBD_TRANSFER_IN(name, tx_buff, tx_size, tx_flags) \
|
||||
const nrfx_usbd_transfer_t name = { \
|
||||
#define NRF_USBD_COMMON_TRANSFER_IN(name, tx_buff, tx_size, tx_flags) \
|
||||
const nrf_usbd_common_transfer_t name = { \
|
||||
.p_data = {.tx = (tx_buff)}, .size = (tx_size), .flags = (tx_flags)}
|
||||
|
||||
/**
|
||||
* @brief Helper macro for declaring OUT transfer item (@ref nrfx_usbd_transfer_t).
|
||||
* @brief Helper macro for declaring OUT transfer item (@ref nrf_usbd_common_transfer_t).
|
||||
*
|
||||
* @param name Instance name.
|
||||
* @param rx_buff Buffer to transfer.
|
||||
* @param rx_size Transfer size.
|
||||
*/
|
||||
#define NRFX_USBD_TRANSFER_OUT(name, rx_buff, rx_size) \
|
||||
const nrfx_usbd_transfer_t name = { \
|
||||
#define NRF_USBD_COMMON_TRANSFER_OUT(name, rx_buff, rx_size) \
|
||||
const nrf_usbd_common_transfer_t name = { \
|
||||
.p_data = {.rx = (rx_buff)}, .size = (rx_size), .flags = 0}
|
||||
|
||||
/**
|
||||
|
@ -271,7 +279,7 @@ typedef struct {
|
|||
* - Flash transfers are not automatically supported- you must copy them to the RAM buffer before.
|
||||
*
|
||||
* @note
|
||||
* This function may use @ref nrfx_usbd_feeder_buffer_get to gain a temporary buffer
|
||||
* This function may use @ref nrf_usbd_common_feeder_buffer_get to gain a temporary buffer
|
||||
* that can be used to prepare transfer.
|
||||
*
|
||||
* @param[out] p_next Structure with the data for the next transfer to be filled.
|
||||
|
@ -284,7 +292,7 @@ typedef struct {
|
|||
* @retval true There is more data to be prepared and when the current transfer
|
||||
* finishes, the feeder function is expected to be called again.
|
||||
*/
|
||||
typedef bool (*nrfx_usbd_feeder_t)(nrfx_usbd_ep_transfer_t *p_next, void *p_context,
|
||||
typedef bool (*nrf_usbd_common_feeder_t)(nrf_usbd_common_ep_transfer_t *p_next, void *p_context,
|
||||
size_t ep_size);
|
||||
|
||||
/**
|
||||
|
@ -295,7 +303,7 @@ typedef bool (*nrfx_usbd_feeder_t)(nrfx_usbd_ep_transfer_t *p_next, void *p_cont
|
|||
* RX (Host->Device) endpoint transfer.
|
||||
*
|
||||
* The transfer must provide a buffer big enough to fit the whole data from the endpoint.
|
||||
* Otherwise, the NRFX_USBD_EP_OVERLOAD event is generated.
|
||||
* Otherwise, the NRF_USBD_COMMON_EP_OVERLOAD event is generated.
|
||||
*
|
||||
* @param[out] p_next Structure with the data for the next transfer to be filled.
|
||||
* Required only if the function returns true.
|
||||
|
@ -308,7 +316,7 @@ typedef bool (*nrfx_usbd_feeder_t)(nrfx_usbd_ep_transfer_t *p_next, void *p_cont
|
|||
* @retval true There is more data to be prepared and when current transfer
|
||||
* finishes, the feeder function is expected to be called again.
|
||||
*/
|
||||
typedef bool (*nrfx_usbd_consumer_t)(nrfx_usbd_ep_transfer_t *p_next, void *p_context,
|
||||
typedef bool (*nrf_usbd_common_consumer_t)(nrf_usbd_common_ep_transfer_t *p_next, void *p_context,
|
||||
size_t ep_size, size_t data_size);
|
||||
|
||||
/**
|
||||
|
@ -317,9 +325,9 @@ typedef bool (*nrfx_usbd_consumer_t)(nrfx_usbd_ep_transfer_t *p_next, void *p_co
|
|||
* Union with feeder and consumer function pointer.
|
||||
*/
|
||||
typedef union {
|
||||
nrfx_usbd_feeder_t feeder; /*!< Feeder function pointer. */
|
||||
nrfx_usbd_consumer_t consumer; /*!< Consumer function pointer. */
|
||||
} nrfx_usbd_handler_t;
|
||||
nrf_usbd_common_feeder_t feeder; /*!< Feeder function pointer. */
|
||||
nrf_usbd_common_consumer_t consumer; /*!< Consumer function pointer. */
|
||||
} nrf_usbd_common_handler_t;
|
||||
|
||||
/**
|
||||
* @brief USBD transfer descriptor.
|
||||
|
@ -328,9 +336,11 @@ typedef union {
|
|||
* IN or OUT type of the transfer.
|
||||
*/
|
||||
typedef struct {
|
||||
nrfx_usbd_handler_t handler; /*!< Handler for the current transfer, function pointer. */
|
||||
void *p_context; /*!< Context for the transfer handler. */
|
||||
} nrfx_usbd_handler_desc_t;
|
||||
/** Handler for the current transfer, function pointer. */
|
||||
nrf_usbd_common_handler_t handler;
|
||||
/** Context for the transfer handler. */
|
||||
void *p_context;
|
||||
} nrf_usbd_common_handler_desc_t;
|
||||
|
||||
/**
|
||||
* @brief Setup packet structure.
|
||||
|
@ -343,7 +353,7 @@ typedef struct {
|
|||
uint16_t wValue; /*!< byte 2, 3 */
|
||||
uint16_t wIndex; /*!< byte 4, 5 */
|
||||
uint16_t wLength; /*!< byte 6, 7 */
|
||||
} nrfx_usbd_setup_t;
|
||||
} nrf_usbd_common_setup_t;
|
||||
|
||||
/**
|
||||
* @brief Driver initialization.
|
||||
|
@ -353,12 +363,12 @@ typedef struct {
|
|||
* @retval NRFX_SUCCESS Initialization successful.
|
||||
* @retval NRFX_ERROR_INVALID_STATE Driver was already initialized.
|
||||
*/
|
||||
nrfx_err_t nrfx_usbd_init(nrfx_usbd_event_handler_t event_handler);
|
||||
nrfx_err_t nrf_usbd_common_init(nrf_usbd_common_event_handler_t event_handler);
|
||||
|
||||
/**
|
||||
* @brief Driver deinitialization.
|
||||
*/
|
||||
void nrfx_usbd_uninit(void);
|
||||
void nrf_usbd_common_uninit(void);
|
||||
|
||||
/**
|
||||
* @brief Enable the USBD port.
|
||||
|
@ -368,15 +378,15 @@ void nrfx_usbd_uninit(void);
|
|||
* Enabled USBD peripheral would request HFCLK.
|
||||
* This function does not enable external oscillator, so if it is not enabled by other part of the
|
||||
* program after enabling USBD driver HFINT would be used for the USBD peripheral.
|
||||
* It is perfectly fine until USBD is started. See @ref nrfx_usbd_start.
|
||||
* It is perfectly fine until USBD is started. See @ref nrf_usbd_common_start.
|
||||
*
|
||||
* In normal situation this function should be called in reaction to USBDETECTED
|
||||
* event from POWER peripheral.
|
||||
*
|
||||
* Interrupts and USB pins pull-up would stay disabled until @ref nrfx_usbd_start
|
||||
* Interrupts and USB pins pull-up would stay disabled until @ref nrf_usbd_common_start
|
||||
* function is called.
|
||||
*/
|
||||
void nrfx_usbd_enable(void);
|
||||
void nrf_usbd_common_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable the USBD port.
|
||||
|
@ -385,7 +395,7 @@ void nrfx_usbd_enable(void);
|
|||
* No events would be detected or processed by the driver.
|
||||
* Clock for the peripheral would be disconnected.
|
||||
*/
|
||||
void nrfx_usbd_disable(void);
|
||||
void nrf_usbd_common_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Start USB functionality.
|
||||
|
@ -409,7 +419,7 @@ void nrfx_usbd_disable(void);
|
|||
* In other case any isochronous endpoint would stay busy
|
||||
* after first transmission.
|
||||
*/
|
||||
void nrfx_usbd_start(bool enable_sof);
|
||||
void nrf_usbd_common_start(bool enable_sof);
|
||||
|
||||
/**
|
||||
* @brief Stop USB functionality.
|
||||
|
@ -420,9 +430,9 @@ void nrfx_usbd_start(bool enable_sof);
|
|||
*
|
||||
* @note
|
||||
* This function can also be used to logically disconnect USB from the HOST that
|
||||
* would force it to enumerate device after calling @ref nrfx_usbd_start.
|
||||
* would force it to enumerate device after calling @ref nrf_usbd_common_start.
|
||||
*/
|
||||
void nrfx_usbd_stop(void);
|
||||
void nrf_usbd_common_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Check if driver is initialized.
|
||||
|
@ -430,7 +440,7 @@ void nrfx_usbd_stop(void);
|
|||
* @retval false Driver is not initialized.
|
||||
* @retval true Driver is initialized.
|
||||
*/
|
||||
bool nrfx_usbd_is_initialized(void);
|
||||
bool nrf_usbd_common_is_initialized(void);
|
||||
|
||||
/**
|
||||
* @brief Check if driver is enabled.
|
||||
|
@ -438,7 +448,7 @@ bool nrfx_usbd_is_initialized(void);
|
|||
* @retval false Driver is disabled.
|
||||
* @retval true Driver is enabled.
|
||||
*/
|
||||
bool nrfx_usbd_is_enabled(void);
|
||||
bool nrf_usbd_common_is_enabled(void);
|
||||
|
||||
/**
|
||||
* @brief Check if driver is started.
|
||||
|
@ -447,13 +457,13 @@ bool nrfx_usbd_is_enabled(void);
|
|||
* @retval true Driver is started (fully functional).
|
||||
* @note The USBD peripheral interrupt state is checked.
|
||||
*/
|
||||
bool nrfx_usbd_is_started(void);
|
||||
bool nrf_usbd_common_is_started(void);
|
||||
|
||||
/**
|
||||
* @brief Suspend USBD operation.
|
||||
*
|
||||
* The USBD peripheral is forced to go into the low power mode.
|
||||
* The function has to be called in the reaction to @ref NRFX_USBD_EVT_SUSPEND event
|
||||
* The function has to be called in the reaction to @ref NRF_USBD_COMMON_EVT_SUSPEND event
|
||||
* when the firmware is ready.
|
||||
*
|
||||
* After successful call of this function most of the USBD registers would be unavailable.
|
||||
|
@ -463,7 +473,7 @@ bool nrfx_usbd_is_started(void);
|
|||
* @retval true USBD peripheral successfully suspended.
|
||||
* @retval false USBD peripheral was not suspended due to resume detection.
|
||||
*/
|
||||
bool nrfx_usbd_suspend(void);
|
||||
bool nrf_usbd_common_suspend(void);
|
||||
|
||||
/**
|
||||
* @brief Start wake up procedure.
|
||||
|
@ -474,19 +484,19 @@ bool nrfx_usbd_suspend(void);
|
|||
* The hardware starts measuring time when wake up is possible.
|
||||
* This may take 0-5 ms depending on how long the SUSPEND state was kept on the USB line.
|
||||
|
||||
* When NRFX_USBD_EVT_WUREQ event is generated it means that Wake Up signaling has just been
|
||||
* When NRF_USBD_COMMON_EVT_WUREQ event is generated it means that Wake Up signaling has just been
|
||||
* started on the USB lines.
|
||||
*
|
||||
* @note Do not expect only @ref NRFX_USBD_EVT_WUREQ event.
|
||||
* There always may appear @ref NRFX_USBD_EVT_RESUME event.
|
||||
* @note NRFX_USBD_EVT_WUREQ event means that Remote WakeUp signal
|
||||
* @note Do not expect only @ref NRF_USBD_COMMON_EVT_WUREQ event.
|
||||
* There always may appear @ref NRF_USBD_COMMON_EVT_RESUME event.
|
||||
* @note NRF_USBD_COMMON_EVT_WUREQ event means that Remote WakeUp signal
|
||||
* has just begun to be generated.
|
||||
* This may take up to 20 ms for the bus to become active.
|
||||
*
|
||||
* @retval true WakeUp procedure started.
|
||||
* @retval false No WakeUp procedure started - bus is already active.
|
||||
*/
|
||||
bool nrfx_usbd_wakeup_req(void);
|
||||
bool nrf_usbd_common_wakeup_req(void);
|
||||
|
||||
/**
|
||||
* @brief Check if USBD is in SUSPEND mode.
|
||||
|
@ -496,7 +506,7 @@ bool nrfx_usbd_wakeup_req(void);
|
|||
* @retval true USBD peripheral is suspended.
|
||||
* @retval false USBD peripheral is active.
|
||||
*/
|
||||
bool nrfx_usbd_suspend_check(void);
|
||||
bool nrf_usbd_common_suspend_check(void);
|
||||
|
||||
/**
|
||||
* @brief Enable only interrupts that should be processed in SUSPEND mode.
|
||||
|
@ -508,19 +518,19 @@ bool nrfx_usbd_suspend_check(void);
|
|||
* Use this function to suspend interrupt processing that may require stable HFCLK until the
|
||||
* clock is enabled.
|
||||
*
|
||||
* @sa nrfx_usbd_active_irq_config
|
||||
* @sa nrf_usbd_common_active_irq_config
|
||||
*/
|
||||
void nrfx_usbd_suspend_irq_config(void);
|
||||
void nrf_usbd_common_suspend_irq_config(void);
|
||||
|
||||
/**
|
||||
* @brief Default active interrupt configuration.
|
||||
*
|
||||
* Default interrupt configuration.
|
||||
* Use in a pair with @ref nrfx_usbd_active_irq_config.
|
||||
* Use in a pair with @ref nrf_usbd_common_active_irq_config.
|
||||
*
|
||||
* @sa nrfx_usbd_suspend_irq_config
|
||||
* @sa nrf_usbd_common_suspend_irq_config
|
||||
*/
|
||||
void nrfx_usbd_active_irq_config(void);
|
||||
void nrf_usbd_common_active_irq_config(void);
|
||||
|
||||
/**
|
||||
* @brief Check the bus state.
|
||||
|
@ -532,12 +542,12 @@ void nrfx_usbd_active_irq_config(void);
|
|||
* @retval true USBD bus is suspended.
|
||||
* @retval false USBD bus is active.
|
||||
*/
|
||||
bool nrfx_usbd_bus_suspend_check(void);
|
||||
bool nrf_usbd_common_bus_suspend_check(void);
|
||||
|
||||
/**
|
||||
* @brief Force the bus state to active
|
||||
*/
|
||||
void nrfx_usbd_force_bus_wakeup(void);
|
||||
void nrf_usbd_common_force_bus_wakeup(void);
|
||||
|
||||
/**
|
||||
* @brief Configure packet size that should be supported by the endpoint.
|
||||
|
@ -549,10 +559,11 @@ void nrfx_usbd_force_bus_wakeup(void);
|
|||
* @param[in] ep Endpoint number.
|
||||
* @param[in] size Required maximum packet size.
|
||||
*
|
||||
* @note Endpoint size is always set to @ref NRFX_USBD_EPSIZE or @ref NRFX_USBD_ISOSIZE / 2
|
||||
* when @ref nrfx_usbd_ep_enable function is called.
|
||||
* @note Endpoint size is always set to @ref NRF_USBD_COMMON_EPSIZE
|
||||
* or @ref NRF_USBD_COMMON_ISOSIZE / 2
|
||||
* when @ref nrf_usbd_common_ep_enable function is called.
|
||||
*/
|
||||
void nrfx_usbd_ep_max_packet_size_set(nrfx_usbd_ep_t ep, uint16_t size);
|
||||
void nrf_usbd_common_ep_max_packet_size_set(nrf_usbd_common_ep_t ep, uint16_t size);
|
||||
|
||||
/**
|
||||
* @brief Get configured endpoint packet size.
|
||||
|
@ -563,7 +574,7 @@ void nrfx_usbd_ep_max_packet_size_set(nrfx_usbd_ep_t ep, uint16_t size);
|
|||
*
|
||||
* @return Maximum pocket size configured on selected endpoint.
|
||||
*/
|
||||
uint16_t nrfx_usbd_ep_max_packet_size_get(nrfx_usbd_ep_t ep);
|
||||
uint16_t nrf_usbd_common_ep_max_packet_size_get(nrf_usbd_common_ep_t ep);
|
||||
|
||||
/**
|
||||
* @brief Check if the selected endpoint is enabled.
|
||||
|
@ -573,7 +584,7 @@ uint16_t nrfx_usbd_ep_max_packet_size_get(nrfx_usbd_ep_t ep);
|
|||
* @retval true Endpoint is enabled.
|
||||
* @retval false Endpoint is disabled.
|
||||
*/
|
||||
bool nrfx_usbd_ep_enable_check(nrfx_usbd_ep_t ep);
|
||||
bool nrf_usbd_common_ep_enable_check(nrf_usbd_common_ep_t ep);
|
||||
|
||||
/**
|
||||
* @brief Enable selected endpoint.
|
||||
|
@ -585,9 +596,9 @@ bool nrfx_usbd_ep_enable_check(nrfx_usbd_ep_t ep);
|
|||
* @note
|
||||
* Max packet size is set to endpoint default maximum value.
|
||||
*
|
||||
* @sa nrfx_usbd_ep_max_packet_size_set
|
||||
* @sa nrf_usbd_common_ep_max_packet_size_set
|
||||
*/
|
||||
void nrfx_usbd_ep_enable(nrfx_usbd_ep_t ep);
|
||||
void nrf_usbd_common_ep_enable(nrf_usbd_common_ep_t ep);
|
||||
|
||||
/**
|
||||
* @brief Disable selected endpoint.
|
||||
|
@ -596,14 +607,14 @@ void nrfx_usbd_ep_enable(nrfx_usbd_ep_t ep);
|
|||
*
|
||||
* @param[in] ep Endpoint number to disable.
|
||||
*/
|
||||
void nrfx_usbd_ep_disable(nrfx_usbd_ep_t ep);
|
||||
void nrf_usbd_common_ep_disable(nrf_usbd_common_ep_t ep);
|
||||
|
||||
/**
|
||||
* @brief Disable all endpoints except for EP0.
|
||||
*
|
||||
* Disable all endpoints that can be disabled in USB device while it is still active.
|
||||
*/
|
||||
void nrfx_usbd_ep_default_config(void);
|
||||
void nrf_usbd_common_ep_default_config(void);
|
||||
|
||||
/**
|
||||
* @brief Start sending data over endpoint.
|
||||
|
@ -613,7 +624,7 @@ void nrfx_usbd_ep_default_config(void);
|
|||
* for transmission is prepared.
|
||||
*
|
||||
* @note Data buffer pointed by p_data have to be kept active till
|
||||
* @ref NRFX_USBD_EVT_EPTRANSFER event is generated.
|
||||
* @ref NRF_USBD_COMMON_EVT_EPTRANSFER event is generated.
|
||||
*
|
||||
* @param[in] ep Endpoint number.
|
||||
* For IN endpoint sending would be initiated.
|
||||
|
@ -624,7 +635,8 @@ void nrfx_usbd_ep_default_config(void);
|
|||
* @retval NRFX_ERROR_BUSY Selected endpoint is pending.
|
||||
* @retval NRFX_ERROR_INVALID_ADDR Unexpected transfer on EPIN0 or EPOUT0.
|
||||
*/
|
||||
nrfx_err_t nrfx_usbd_ep_transfer(nrfx_usbd_ep_t ep, nrfx_usbd_transfer_t const *p_transfer);
|
||||
nrfx_err_t nrf_usbd_common_ep_transfer(nrf_usbd_common_ep_t ep,
|
||||
nrf_usbd_common_transfer_t const *p_transfer);
|
||||
|
||||
/**
|
||||
* @brief Start sending data over the endpoint using the transfer handler function.
|
||||
|
@ -643,8 +655,8 @@ nrfx_err_t nrfx_usbd_ep_transfer(nrfx_usbd_ep_t ep, nrfx_usbd_transfer_t const *
|
|||
* @retval NRFX_ERROR_BUSY Selected endpoint is pending.
|
||||
* @retval NRFX_ERROR_INVALID_ADDR Unexpected transfer on EPIN0 or EPOUT0.
|
||||
*/
|
||||
nrfx_err_t nrfx_usbd_ep_handled_transfer(nrfx_usbd_ep_t ep,
|
||||
nrfx_usbd_handler_desc_t const *p_handler);
|
||||
nrfx_err_t nrf_usbd_common_ep_handled_transfer(nrf_usbd_common_ep_t ep,
|
||||
nrf_usbd_common_handler_desc_t const *p_handler);
|
||||
|
||||
/**
|
||||
* @brief Get the temporary buffer to be used by the feeder.
|
||||
|
@ -653,19 +665,19 @@ nrfx_err_t nrfx_usbd_ep_handled_transfer(nrfx_usbd_ep_t ep,
|
|||
* when the transfer is finished.
|
||||
* Use it for transfer preparation.
|
||||
*
|
||||
* May be used inside the feeder configured in @ref nrfx_usbd_ep_handled_transfer.
|
||||
* May be used inside the feeder configured in @ref nrf_usbd_common_ep_handled_transfer.
|
||||
*
|
||||
* @return Pointer to the buffer that can be used temporarily.
|
||||
*
|
||||
* @sa NRFX_USBD_FEEDER_BUFFER_SIZE
|
||||
* @sa NRF_USBD_COMMON_FEEDER_BUFFER_SIZE
|
||||
*/
|
||||
void *nrfx_usbd_feeder_buffer_get(void);
|
||||
void *nrf_usbd_common_feeder_buffer_get(void);
|
||||
|
||||
/**
|
||||
* @brief Get the information about last finished or current transfer.
|
||||
*
|
||||
* Function returns the status of the last buffer set for transfer on selected endpoint.
|
||||
* The status considers last buffer set by @ref nrfx_usbd_ep_transfer function or
|
||||
* The status considers last buffer set by @ref nrf_usbd_common_ep_transfer function or
|
||||
* by transfer callback function.
|
||||
*
|
||||
* @param[in] ep Endpoint number.
|
||||
|
@ -673,9 +685,9 @@ void *nrfx_usbd_feeder_buffer_get(void);
|
|||
*
|
||||
* @return Endpoint status.
|
||||
*
|
||||
* @sa nrfx_usbd_ep_status_t
|
||||
* @sa nrf_usbd_common_ep_status_t
|
||||
*/
|
||||
nrfx_usbd_ep_status_t nrfx_usbd_ep_status_get(nrfx_usbd_ep_t ep, size_t *p_size);
|
||||
nrf_usbd_common_ep_status_t nrf_usbd_common_ep_status_get(nrf_usbd_common_ep_t ep, size_t *p_size);
|
||||
|
||||
/**
|
||||
* @brief Get number of received bytes.
|
||||
|
@ -687,7 +699,7 @@ nrfx_usbd_ep_status_t nrfx_usbd_ep_status_get(nrfx_usbd_ep_t ep, size_t *p_size)
|
|||
*
|
||||
* @return Number of received bytes.
|
||||
*/
|
||||
size_t nrfx_usbd_epout_size_get(nrfx_usbd_ep_t ep);
|
||||
size_t nrf_usbd_common_epout_size_get(nrf_usbd_common_ep_t ep);
|
||||
|
||||
/**
|
||||
* @brief Check if endpoint buffer is ready or is under USB IP control.
|
||||
|
@ -701,7 +713,7 @@ size_t nrfx_usbd_epout_size_get(nrfx_usbd_ep_t ep);
|
|||
* and the endpoint does not have any data.
|
||||
* When endpoint is not busy:
|
||||
* - OUT (TX) endpoint: New data can be uploaded.
|
||||
* - IN (RX) endpoint: New data can be downloaded using @ref nrfx_usbd_ep_transfer
|
||||
* - IN (RX) endpoint: New data can be downloaded using @ref nrf_usbd_common_ep_transfer
|
||||
* function.
|
||||
*
|
||||
* @param[in] ep Endpoint number.
|
||||
|
@ -709,7 +721,7 @@ size_t nrfx_usbd_epout_size_get(nrfx_usbd_ep_t ep);
|
|||
* @retval false Endpoint is not busy.
|
||||
* @retval true Endpoint is busy.
|
||||
*/
|
||||
bool nrfx_usbd_ep_is_busy(nrfx_usbd_ep_t ep);
|
||||
bool nrf_usbd_common_ep_is_busy(nrf_usbd_common_ep_t ep);
|
||||
|
||||
/**
|
||||
* @brief Stall endpoint
|
||||
|
@ -717,12 +729,12 @@ bool nrfx_usbd_ep_is_busy(nrfx_usbd_ep_t ep);
|
|||
* Stall endpoit to send error information during next transfer request from
|
||||
* the host.
|
||||
*
|
||||
* @note To stall endpoint it is safer to use @ref nrfx_usbd_setup_stall
|
||||
* @note To stall endpoint it is safer to use @ref nrf_usbd_common_setup_stall
|
||||
* @note Stalled endpoint would not be cleared when DMA transfer finishes.
|
||||
*
|
||||
* @param[in] ep Endpoint number to stall.
|
||||
*/
|
||||
void nrfx_usbd_ep_stall(nrfx_usbd_ep_t ep);
|
||||
void nrf_usbd_common_ep_stall(nrf_usbd_common_ep_t ep);
|
||||
|
||||
/**
|
||||
* @brief Clear stall flag on endpoint.
|
||||
|
@ -737,7 +749,7 @@ void nrfx_usbd_ep_stall(nrfx_usbd_ep_t ep);
|
|||
*
|
||||
* @param[in] ep Endpoint number.
|
||||
*/
|
||||
void nrfx_usbd_ep_stall_clear(nrfx_usbd_ep_t ep);
|
||||
void nrf_usbd_common_ep_stall_clear(nrf_usbd_common_ep_t ep);
|
||||
|
||||
/**
|
||||
* @brief Check if endpoint is stalled.
|
||||
|
@ -749,14 +761,14 @@ void nrfx_usbd_ep_stall_clear(nrfx_usbd_ep_t ep);
|
|||
* @retval false Endpoint is not stalled.
|
||||
* @retval true Endpoint is stalled.
|
||||
*/
|
||||
bool nrfx_usbd_ep_stall_check(nrfx_usbd_ep_t ep);
|
||||
bool nrf_usbd_common_ep_stall_check(nrf_usbd_common_ep_t ep);
|
||||
|
||||
/**
|
||||
* @brief Clear current endpoint data toggle.
|
||||
*
|
||||
* @param[in] ep Endpoint number to clear.
|
||||
*/
|
||||
void nrfx_usbd_ep_dtoggle_clear(nrfx_usbd_ep_t ep);
|
||||
void nrf_usbd_common_ep_dtoggle_clear(nrf_usbd_common_ep_t ep);
|
||||
|
||||
/**
|
||||
* @brief Get parsed setup data.
|
||||
|
@ -766,7 +778,7 @@ void nrfx_usbd_ep_dtoggle_clear(nrfx_usbd_ep_t ep);
|
|||
* @param[out] p_setup Pointer to data structure that would be filled by
|
||||
* parsed data.
|
||||
*/
|
||||
void nrfx_usbd_setup_get(nrfx_usbd_setup_t *p_setup);
|
||||
void nrf_usbd_common_setup_get(nrf_usbd_common_setup_t *p_setup);
|
||||
|
||||
/**
|
||||
* @brief Clear the control endpoint for packet reception during DATA stage.
|
||||
|
@ -774,9 +786,9 @@ void nrfx_usbd_setup_get(nrfx_usbd_setup_t *p_setup);
|
|||
* This function may be called if any more data in control write transfer is expected.
|
||||
* Clears only OUT endpoint to be able to take another OUT data token.
|
||||
* It does not allow STATUS stage.
|
||||
* @sa nrfx_usbd_setup_clear
|
||||
* @sa nrf_usbd_common_setup_clear
|
||||
*/
|
||||
void nrfx_usbd_setup_data_clear(void);
|
||||
void nrf_usbd_common_setup_data_clear(void);
|
||||
|
||||
/**
|
||||
* @brief Clear setup endpoint.
|
||||
|
@ -784,45 +796,47 @@ void nrfx_usbd_setup_data_clear(void);
|
|||
* This function acknowledges setup when SETUP command was received and processed.
|
||||
* It has to be called if no data respond for the SETUP command is sent.
|
||||
*/
|
||||
void nrfx_usbd_setup_clear(void);
|
||||
void nrf_usbd_common_setup_clear(void);
|
||||
|
||||
/**
|
||||
* @brief Stall setup endpoint.
|
||||
*
|
||||
* Mark an error on setup endpoint.
|
||||
*/
|
||||
void nrfx_usbd_setup_stall(void);
|
||||
void nrf_usbd_common_setup_stall(void);
|
||||
|
||||
/**
|
||||
* @brief Abort pending transfer on selected endpoint.
|
||||
*
|
||||
* @param[in] ep Endpoint number.
|
||||
*/
|
||||
void nrfx_usbd_ep_abort(nrfx_usbd_ep_t ep);
|
||||
void nrf_usbd_common_ep_abort(nrf_usbd_common_ep_t ep);
|
||||
|
||||
/**
|
||||
* @brief Get the information about expected transfer SETUP data direction.
|
||||
*
|
||||
* Function returns the information about last expected transfer direction.
|
||||
*
|
||||
* @retval NRFX_USBD_EPOUT0 Expecting OUT (Host->Device) direction or no data.
|
||||
* @retval NRFX_USBD_EPIN0 Expecting IN (Device->Host) direction.
|
||||
* @retval NRF_USBD_COMMON_EPOUT0 Expecting OUT (Host->Device) direction or no data.
|
||||
* @retval NRF_USBD_COMMON_EPIN0 Expecting IN (Device->Host) direction.
|
||||
*/
|
||||
nrfx_usbd_ep_t nrfx_usbd_last_setup_dir_get(void);
|
||||
nrf_usbd_common_ep_t nrf_usbd_common_last_setup_dir_get(void);
|
||||
|
||||
/**
|
||||
* @brief Drop transfer on OUT endpoint.
|
||||
*
|
||||
* @param[in] ep OUT endpoint ID.
|
||||
*/
|
||||
void nrfx_usbd_transfer_out_drop(nrfx_usbd_ep_t ep);
|
||||
void nrf_usbd_common_transfer_out_drop(nrf_usbd_common_ep_t ep);
|
||||
|
||||
/** @} */
|
||||
|
||||
void nrfx_usbd_irq_handler(void);
|
||||
void nrf_usbd_common_irq_handler(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NRFX_USBD_H__ */
|
||||
#endif /* NRF_USBD_COMMON_H__ */
|
||||
|
||||
/** @endcond */
|
64
drivers/usb/common/nrf_usbd_common/nrf_usbd_common_errata.h
Normal file
64
drivers/usb/common/nrf_usbd_common/nrf_usbd_common_errata.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2016 - 2023, Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* This file is undergoing transition towards native Zephyr nrf USB driver. */
|
||||
|
||||
/** @cond INTERNAL_HIDDEN */
|
||||
|
||||
#ifndef NRF_USBD_COMMON_ERRATA_H__
|
||||
#define NRF_USBD_COMMON_ERRATA_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <nrf_erratas.h>
|
||||
|
||||
#ifndef NRF_USBD_COMMON_ERRATA_ENABLE
|
||||
/**
|
||||
* @brief The constant that informs if errata should be enabled at all.
|
||||
*
|
||||
* If this constant is set to 0, all the Errata bug fixes will be automatically disabled.
|
||||
*/
|
||||
#define NRF_USBD_COMMON_ERRATA_ENABLE 1
|
||||
#endif
|
||||
|
||||
/* Errata: ISO double buffering not functional. **/
|
||||
static inline bool nrf_usbd_common_errata_166(void)
|
||||
{
|
||||
return NRF_USBD_COMMON_ERRATA_ENABLE && nrf52_errata_166();
|
||||
}
|
||||
|
||||
/* Errata: USBD might not reach its active state. **/
|
||||
static inline bool nrf_usbd_common_errata_171(void)
|
||||
{
|
||||
return NRF_USBD_COMMON_ERRATA_ENABLE && nrf52_errata_171();
|
||||
}
|
||||
|
||||
/* Errata: USB cannot be enabled. **/
|
||||
static inline bool nrf_usbd_common_errata_187(void)
|
||||
{
|
||||
return NRF_USBD_COMMON_ERRATA_ENABLE && nrf52_errata_187();
|
||||
}
|
||||
|
||||
/* Errata: USBD cannot receive tasks during DMA. **/
|
||||
static inline bool nrf_usbd_common_errata_199(void)
|
||||
{
|
||||
return NRF_USBD_COMMON_ERRATA_ENABLE && nrf52_errata_199();
|
||||
}
|
||||
|
||||
/* Errata: Device remains in SUSPEND too long. */
|
||||
static inline bool nrf_usbd_common_errata_211(void)
|
||||
{
|
||||
return NRF_USBD_COMMON_ERRATA_ENABLE && nrf52_errata_211();
|
||||
}
|
||||
|
||||
/* Errata: Unexpected behavior after reset. **/
|
||||
static inline bool nrf_usbd_common_errata_223(void)
|
||||
{
|
||||
return NRF_USBD_COMMON_ERRATA_ENABLE && nrf52_errata_223();
|
||||
}
|
||||
|
||||
#endif /* NRF_USBD_COMMON_ERRATA_H__ */
|
||||
|
||||
/** @endcond */
|
|
@ -104,7 +104,7 @@ config USB_NRFX
|
|||
bool "Nordic Semiconductor USB Device Controller Driver"
|
||||
default y
|
||||
depends on DT_HAS_NORDIC_NRF_USBD_ENABLED
|
||||
select NRFX_USBD
|
||||
select NRF_USBD_COMMON
|
||||
select NRFX_POWER
|
||||
imply USB_DEVICE_REMOTE_WAKEUP
|
||||
help
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
#include <zephyr/usb/usb_device.h>
|
||||
#include <zephyr/drivers/clock_control.h>
|
||||
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
|
||||
#include <nrfx_usbd.h>
|
||||
#include <nrf_usbd_common.h>
|
||||
#include <hal/nrf_usbd.h>
|
||||
#include <nrfx_power.h>
|
||||
|
||||
|
||||
|
@ -288,12 +289,12 @@ static inline bool dev_ready(void)
|
|||
return get_usbd_ctx()->ready;
|
||||
}
|
||||
|
||||
static inline nrfx_usbd_ep_t ep_addr_to_nrfx(uint8_t ep)
|
||||
static inline nrf_usbd_common_ep_t ep_addr_to_nrfx(uint8_t ep)
|
||||
{
|
||||
return (nrfx_usbd_ep_t)ep;
|
||||
return (nrf_usbd_common_ep_t)ep;
|
||||
}
|
||||
|
||||
static inline uint8_t nrfx_addr_to_ep(nrfx_usbd_ep_t ep)
|
||||
static inline uint8_t nrfx_addr_to_ep(nrf_usbd_common_ep_t ep)
|
||||
{
|
||||
return (uint8_t)ep;
|
||||
}
|
||||
|
@ -559,7 +560,7 @@ static void usbd_enable_endpoints(struct nrf_usbd_ctx *ctx)
|
|||
__ASSERT_NO_MSG(ep_ctx);
|
||||
|
||||
if (ep_ctx->cfg.en) {
|
||||
nrfx_usbd_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
|
||||
nrf_usbd_common_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -568,7 +569,7 @@ static void usbd_enable_endpoints(struct nrf_usbd_ctx *ctx)
|
|||
__ASSERT_NO_MSG(ep_ctx);
|
||||
|
||||
if (ep_ctx->cfg.en) {
|
||||
nrfx_usbd_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
|
||||
nrf_usbd_common_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -577,7 +578,7 @@ static void usbd_enable_endpoints(struct nrf_usbd_ctx *ctx)
|
|||
__ASSERT_NO_MSG(ep_ctx);
|
||||
|
||||
if (ep_ctx->cfg.en) {
|
||||
nrfx_usbd_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
|
||||
nrf_usbd_common_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,7 +587,7 @@ static void usbd_enable_endpoints(struct nrf_usbd_ctx *ctx)
|
|||
__ASSERT_NO_MSG(ep_ctx);
|
||||
|
||||
if (ep_ctx->cfg.en) {
|
||||
nrfx_usbd_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
|
||||
nrf_usbd_common_ep_enable(ep_addr_to_nrfx(ep_ctx->cfg.addr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -606,7 +607,7 @@ static void ep_ctx_reset(struct nrf_usbd_ep_ctx *ep_ctx)
|
|||
|
||||
/* Abort ongoing write operation. */
|
||||
if (ep_ctx->write_in_progress) {
|
||||
nrfx_usbd_ep_abort(ep_addr_to_nrfx(ep_ctx->cfg.addr));
|
||||
nrf_usbd_common_ep_abort(ep_addr_to_nrfx(ep_ctx->cfg.addr));
|
||||
}
|
||||
|
||||
ep_ctx->read_complete = true;
|
||||
|
@ -673,9 +674,9 @@ static inline void usbd_work_process_pwr_events(struct usbd_pwr_event *pwr_evt)
|
|||
|
||||
switch (pwr_evt->state) {
|
||||
case USBD_ATTACHED:
|
||||
if (!nrfx_usbd_is_enabled()) {
|
||||
if (!nrf_usbd_common_is_enabled()) {
|
||||
LOG_DBG("USB detected");
|
||||
nrfx_usbd_enable();
|
||||
nrf_usbd_common_enable();
|
||||
err = hfxo_start(ctx);
|
||||
__ASSERT_NO_MSG(err >= 0);
|
||||
}
|
||||
|
@ -687,7 +688,7 @@ static inline void usbd_work_process_pwr_events(struct usbd_pwr_event *pwr_evt)
|
|||
|
||||
case USBD_POWERED:
|
||||
usbd_enable_endpoints(ctx);
|
||||
nrfx_usbd_start(IS_ENABLED(CONFIG_USB_DEVICE_SOF));
|
||||
nrf_usbd_common_start(IS_ENABLED(CONFIG_USB_DEVICE_SOF));
|
||||
ctx->ready = true;
|
||||
|
||||
LOG_DBG("USB Powered");
|
||||
|
@ -699,7 +700,7 @@ static inline void usbd_work_process_pwr_events(struct usbd_pwr_event *pwr_evt)
|
|||
|
||||
case USBD_DETACHED:
|
||||
ctx->ready = false;
|
||||
nrfx_usbd_disable();
|
||||
nrf_usbd_common_disable();
|
||||
err = hfxo_stop(ctx);
|
||||
__ASSERT_NO_MSG(err >= 0);
|
||||
|
||||
|
@ -712,7 +713,7 @@ static inline void usbd_work_process_pwr_events(struct usbd_pwr_event *pwr_evt)
|
|||
|
||||
case USBD_SUSPENDED:
|
||||
if (dev_ready()) {
|
||||
nrfx_usbd_suspend();
|
||||
nrf_usbd_common_suspend();
|
||||
LOG_DBG("USB Suspend state");
|
||||
|
||||
if (ctx->status_cb) {
|
||||
|
@ -771,7 +772,7 @@ static inline void usbd_work_process_setup(struct nrf_usbd_ep_ctx *ep_ctx)
|
|||
if (usb_reqtype_is_to_device(usbd_setup) && usbd_setup->wLength) {
|
||||
ctx->ctrl_read_len = usbd_setup->wLength;
|
||||
/* Allow data chunk on EP0 OUT */
|
||||
nrfx_usbd_setup_data_clear();
|
||||
nrf_usbd_common_setup_data_clear();
|
||||
} else {
|
||||
ctx->ctrl_read_len = 0U;
|
||||
}
|
||||
|
@ -791,9 +792,9 @@ static inline void usbd_work_process_recvreq(struct nrf_usbd_ctx *ctx,
|
|||
ep_ctx->read_complete = false;
|
||||
|
||||
k_mutex_lock(&ctx->drv_lock, K_FOREVER);
|
||||
NRFX_USBD_TRANSFER_OUT(transfer, ep_ctx->buf.data,
|
||||
ep_ctx->cfg.max_sz);
|
||||
nrfx_err_t err = nrfx_usbd_ep_transfer(
|
||||
NRF_USBD_COMMON_TRANSFER_OUT(transfer, ep_ctx->buf.data,
|
||||
ep_ctx->cfg.max_sz);
|
||||
nrfx_err_t err = nrf_usbd_common_ep_transfer(
|
||||
ep_addr_to_nrfx(ep_ctx->cfg.addr), &transfer);
|
||||
if (err != NRFX_SUCCESS) {
|
||||
LOG_ERR("nRF USBD transfer error (OUT): 0x%02x", err);
|
||||
|
@ -831,7 +832,7 @@ static inline void usbd_work_process_ep_events(struct usbd_ep_event *ep_evt)
|
|||
* no ZLP required.
|
||||
*/
|
||||
k_mutex_lock(&ctx->drv_lock, K_FOREVER);
|
||||
nrfx_usbd_setup_clear();
|
||||
nrf_usbd_common_setup_clear();
|
||||
k_mutex_unlock(&ctx->drv_lock);
|
||||
}
|
||||
ep_ctx->cfg.cb(ep_ctx->cfg.addr,
|
||||
|
@ -842,14 +843,14 @@ static inline void usbd_work_process_ep_events(struct usbd_ep_event *ep_evt)
|
|||
}
|
||||
}
|
||||
|
||||
static void usbd_event_transfer_ctrl(nrfx_usbd_evt_t const *const p_event)
|
||||
static void usbd_event_transfer_ctrl(nrf_usbd_common_evt_t const *const p_event)
|
||||
{
|
||||
struct nrf_usbd_ep_ctx *ep_ctx =
|
||||
endpoint_ctx(p_event->data.eptransfer.ep);
|
||||
|
||||
if (NRF_USBD_EPIN_CHECK(p_event->data.eptransfer.ep)) {
|
||||
switch (p_event->data.eptransfer.status) {
|
||||
case NRFX_USBD_EP_OK: {
|
||||
case NRF_USBD_COMMON_EP_OK: {
|
||||
struct usbd_event *ev = usbd_evt_alloc();
|
||||
|
||||
if (!ev) {
|
||||
|
@ -867,7 +868,7 @@ static void usbd_event_transfer_ctrl(nrfx_usbd_evt_t const *const p_event)
|
|||
}
|
||||
break;
|
||||
|
||||
case NRFX_USBD_EP_ABORTED: {
|
||||
case NRF_USBD_COMMON_EP_ABORTED: {
|
||||
LOG_DBG("Endpoint 0x%02x write aborted",
|
||||
p_event->data.eptransfer.ep);
|
||||
}
|
||||
|
@ -882,7 +883,7 @@ static void usbd_event_transfer_ctrl(nrfx_usbd_evt_t const *const p_event)
|
|||
}
|
||||
} else {
|
||||
switch (p_event->data.eptransfer.status) {
|
||||
case NRFX_USBD_EP_WAITING: {
|
||||
case NRF_USBD_COMMON_EP_WAITING: {
|
||||
struct usbd_event *ev = usbd_evt_alloc();
|
||||
|
||||
if (!ev) {
|
||||
|
@ -901,23 +902,23 @@ static void usbd_event_transfer_ctrl(nrfx_usbd_evt_t const *const p_event)
|
|||
}
|
||||
break;
|
||||
|
||||
case NRFX_USBD_EP_OK: {
|
||||
case NRF_USBD_COMMON_EP_OK: {
|
||||
struct nrf_usbd_ctx *ctx = get_usbd_ctx();
|
||||
struct usbd_event *ev = usbd_evt_alloc();
|
||||
|
||||
if (!ev) {
|
||||
return;
|
||||
}
|
||||
nrfx_usbd_ep_status_t err_code;
|
||||
nrf_usbd_common_ep_status_t err_code;
|
||||
|
||||
ev->evt_type = USBD_EVT_EP;
|
||||
ev->evt.ep_evt.evt_type = EP_EVT_RECV_COMPLETE;
|
||||
ev->evt.ep_evt.ep = ep_ctx;
|
||||
|
||||
err_code = nrfx_usbd_ep_status_get(
|
||||
err_code = nrf_usbd_common_ep_status_get(
|
||||
p_event->data.eptransfer.ep, &ep_ctx->buf.len);
|
||||
|
||||
if (err_code != NRFX_USBD_EP_OK) {
|
||||
if (err_code != NRF_USBD_COMMON_EP_OK) {
|
||||
LOG_ERR("_ep_status_get failed! Code: %d",
|
||||
err_code);
|
||||
__ASSERT_NO_MSG(0);
|
||||
|
@ -927,7 +928,7 @@ static void usbd_event_transfer_ctrl(nrfx_usbd_evt_t const *const p_event)
|
|||
if (ctx->ctrl_read_len > ep_ctx->buf.len) {
|
||||
ctx->ctrl_read_len -= ep_ctx->buf.len;
|
||||
/* Allow next data chunk on EP0 OUT */
|
||||
nrfx_usbd_setup_data_clear();
|
||||
nrf_usbd_common_setup_data_clear();
|
||||
} else {
|
||||
ctx->ctrl_read_len = 0U;
|
||||
}
|
||||
|
@ -947,14 +948,14 @@ static void usbd_event_transfer_ctrl(nrfx_usbd_evt_t const *const p_event)
|
|||
}
|
||||
}
|
||||
|
||||
static void usbd_event_transfer_data(nrfx_usbd_evt_t const *const p_event)
|
||||
static void usbd_event_transfer_data(nrf_usbd_common_evt_t const *const p_event)
|
||||
{
|
||||
struct nrf_usbd_ep_ctx *ep_ctx =
|
||||
endpoint_ctx(p_event->data.eptransfer.ep);
|
||||
|
||||
if (NRF_USBD_EPIN_CHECK(p_event->data.eptransfer.ep)) {
|
||||
switch (p_event->data.eptransfer.status) {
|
||||
case NRFX_USBD_EP_OK: {
|
||||
case NRF_USBD_COMMON_EP_OK: {
|
||||
struct usbd_event *ev = usbd_evt_alloc();
|
||||
|
||||
if (!ev) {
|
||||
|
@ -973,7 +974,7 @@ static void usbd_event_transfer_data(nrfx_usbd_evt_t const *const p_event)
|
|||
}
|
||||
break;
|
||||
|
||||
case NRFX_USBD_EP_ABORTED: {
|
||||
case NRF_USBD_COMMON_EP_ABORTED: {
|
||||
LOG_DBG("Endpoint 0x%02x write aborted",
|
||||
p_event->data.eptransfer.ep);
|
||||
}
|
||||
|
@ -989,7 +990,7 @@ static void usbd_event_transfer_data(nrfx_usbd_evt_t const *const p_event)
|
|||
|
||||
} else {
|
||||
switch (p_event->data.eptransfer.status) {
|
||||
case NRFX_USBD_EP_WAITING: {
|
||||
case NRF_USBD_COMMON_EP_WAITING: {
|
||||
struct usbd_event *ev = usbd_evt_alloc();
|
||||
|
||||
if (!ev) {
|
||||
|
@ -1009,7 +1010,7 @@ static void usbd_event_transfer_data(nrfx_usbd_evt_t const *const p_event)
|
|||
}
|
||||
break;
|
||||
|
||||
case NRFX_USBD_EP_OK: {
|
||||
case NRF_USBD_COMMON_EP_OK: {
|
||||
struct usbd_event *ev = usbd_evt_alloc();
|
||||
|
||||
if (!ev) {
|
||||
|
@ -1045,42 +1046,42 @@ static void usbd_event_transfer_data(nrfx_usbd_evt_t const *const p_event)
|
|||
/**
|
||||
* @brief nRFx USBD driver event handler function.
|
||||
*/
|
||||
static void usbd_event_handler(nrfx_usbd_evt_t const *const p_event)
|
||||
static void usbd_event_handler(nrf_usbd_common_evt_t const *const p_event)
|
||||
{
|
||||
struct usbd_event evt = {0};
|
||||
bool put_evt = false;
|
||||
|
||||
switch (p_event->type) {
|
||||
case NRFX_USBD_EVT_SUSPEND:
|
||||
case NRF_USBD_COMMON_EVT_SUSPEND:
|
||||
LOG_DBG("SUSPEND state detected");
|
||||
evt.evt_type = USBD_EVT_POWER;
|
||||
evt.evt.pwr_evt.state = USBD_SUSPENDED;
|
||||
put_evt = true;
|
||||
break;
|
||||
case NRFX_USBD_EVT_RESUME:
|
||||
case NRF_USBD_COMMON_EVT_RESUME:
|
||||
LOG_DBG("RESUMING from suspend");
|
||||
evt.evt_type = USBD_EVT_POWER;
|
||||
evt.evt.pwr_evt.state = USBD_RESUMED;
|
||||
put_evt = true;
|
||||
break;
|
||||
case NRFX_USBD_EVT_WUREQ:
|
||||
case NRF_USBD_COMMON_EVT_WUREQ:
|
||||
LOG_DBG("RemoteWU initiated");
|
||||
evt.evt_type = USBD_EVT_POWER;
|
||||
evt.evt.pwr_evt.state = USBD_RESUMED;
|
||||
put_evt = true;
|
||||
break;
|
||||
case NRFX_USBD_EVT_RESET:
|
||||
case NRF_USBD_COMMON_EVT_RESET:
|
||||
evt.evt_type = USBD_EVT_RESET;
|
||||
put_evt = true;
|
||||
break;
|
||||
case NRFX_USBD_EVT_SOF:
|
||||
case NRF_USBD_COMMON_EVT_SOF:
|
||||
if (IS_ENABLED(CONFIG_USB_DEVICE_SOF)) {
|
||||
evt.evt_type = USBD_EVT_SOF;
|
||||
put_evt = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case NRFX_USBD_EVT_EPTRANSFER: {
|
||||
case NRF_USBD_COMMON_EVT_EPTRANSFER: {
|
||||
struct nrf_usbd_ep_ctx *ep_ctx;
|
||||
|
||||
ep_ctx = endpoint_ctx(p_event->data.eptransfer.ep);
|
||||
|
@ -1101,10 +1102,10 @@ static void usbd_event_handler(nrfx_usbd_evt_t const *const p_event)
|
|||
break;
|
||||
}
|
||||
|
||||
case NRFX_USBD_EVT_SETUP: {
|
||||
nrfx_usbd_setup_t drv_setup;
|
||||
case NRF_USBD_COMMON_EVT_SETUP: {
|
||||
nrf_usbd_common_setup_t drv_setup;
|
||||
|
||||
nrfx_usbd_setup_get(&drv_setup);
|
||||
nrf_usbd_common_setup_get(&drv_setup);
|
||||
if ((drv_setup.bRequest != USB_SREQ_SET_ADDRESS)
|
||||
|| (USB_REQTYPE_GET_TYPE(drv_setup.bmRequestType)
|
||||
!= USB_REQTYPE_TYPE_STANDARD)) {
|
||||
|
@ -1147,8 +1148,8 @@ static inline void usbd_reinit(void)
|
|||
nrfx_err_t err;
|
||||
|
||||
nrfx_power_usbevt_disable();
|
||||
nrfx_usbd_disable();
|
||||
nrfx_usbd_uninit();
|
||||
nrf_usbd_common_disable();
|
||||
nrf_usbd_common_uninit();
|
||||
|
||||
usbd_evt_flush();
|
||||
|
||||
|
@ -1156,7 +1157,7 @@ static inline void usbd_reinit(void)
|
|||
__ASSERT_NO_MSG(ret == 0);
|
||||
|
||||
nrfx_power_usbevt_enable();
|
||||
err = nrfx_usbd_init(usbd_event_handler);
|
||||
err = nrf_usbd_common_init(usbd_event_handler);
|
||||
|
||||
if (err != NRFX_SUCCESS) {
|
||||
LOG_DBG("nRF USBD driver reinit failed. Code: %d", err);
|
||||
|
@ -1177,7 +1178,7 @@ static void usbd_sof_trigger_iso_read(void)
|
|||
struct usbd_event *ev;
|
||||
struct nrf_usbd_ep_ctx *ep_ctx;
|
||||
|
||||
ep_ctx = endpoint_ctx(NRFX_USBD_EPOUT8);
|
||||
ep_ctx = endpoint_ctx(NRF_USBD_COMMON_EPOUT8);
|
||||
if (!ep_ctx) {
|
||||
LOG_ERR("There is no ISO ep");
|
||||
return;
|
||||
|
@ -1281,7 +1282,7 @@ int usb_dc_attach(void)
|
|||
(CLOCK_CONTROL_NRF_SUBSYS_HF)));
|
||||
|
||||
IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
|
||||
nrfx_isr, nrfx_usbd_irq_handler, 0);
|
||||
nrfx_isr, nrf_usbd_common_irq_handler, 0);
|
||||
|
||||
nrfx_power_usbevt_enable();
|
||||
|
||||
|
@ -1316,8 +1317,8 @@ int usb_dc_detach(void)
|
|||
|
||||
usbd_evt_flush();
|
||||
|
||||
if (nrfx_usbd_is_enabled()) {
|
||||
nrfx_usbd_disable();
|
||||
if (nrf_usbd_common_is_enabled()) {
|
||||
nrf_usbd_common_disable();
|
||||
}
|
||||
|
||||
(void)hfxo_stop(ctx);
|
||||
|
@ -1440,8 +1441,8 @@ int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data *const ep_cfg)
|
|||
}
|
||||
}
|
||||
|
||||
nrfx_usbd_ep_max_packet_size_set(ep_addr_to_nrfx(ep_cfg->ep_addr),
|
||||
ep_cfg->ep_mps);
|
||||
nrf_usbd_common_ep_max_packet_size_set(ep_addr_to_nrfx(ep_cfg->ep_addr),
|
||||
ep_cfg->ep_mps);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1461,11 +1462,11 @@ int usb_dc_ep_set_stall(const uint8_t ep)
|
|||
|
||||
switch (ep_ctx->cfg.type) {
|
||||
case USB_DC_EP_CONTROL:
|
||||
nrfx_usbd_setup_stall();
|
||||
nrf_usbd_common_setup_stall();
|
||||
break;
|
||||
case USB_DC_EP_BULK:
|
||||
case USB_DC_EP_INTERRUPT:
|
||||
nrfx_usbd_ep_stall(ep_addr_to_nrfx(ep));
|
||||
nrf_usbd_common_ep_stall(ep_addr_to_nrfx(ep));
|
||||
break;
|
||||
case USB_DC_EP_ISOCHRONOUS:
|
||||
LOG_ERR("STALL unsupported on ISO endpoint");
|
||||
|
@ -1499,8 +1500,8 @@ int usb_dc_ep_clear_stall(const uint8_t ep)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
nrfx_usbd_ep_dtoggle_clear(ep_addr_to_nrfx(ep));
|
||||
nrfx_usbd_ep_stall_clear(ep_addr_to_nrfx(ep));
|
||||
nrf_usbd_common_ep_dtoggle_clear(ep_addr_to_nrfx(ep));
|
||||
nrf_usbd_common_ep_stall_clear(ep_addr_to_nrfx(ep));
|
||||
LOG_DBG("Unstall on EP 0x%02x", ep);
|
||||
|
||||
return 0;
|
||||
|
@ -1528,7 +1529,7 @@ int usb_dc_ep_is_stalled(const uint8_t ep, uint8_t *const stalled)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
*stalled = (uint8_t) nrfx_usbd_ep_stall_check(ep_addr_to_nrfx(ep));
|
||||
*stalled = (uint8_t) nrf_usbd_common_ep_stall_check(ep_addr_to_nrfx(ep));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1550,11 +1551,11 @@ int usb_dc_ep_enable(const uint8_t ep)
|
|||
/* ISO transactions for full-speed device do not support
|
||||
* toggle sequencing and should only send DATA0 PID.
|
||||
*/
|
||||
nrfx_usbd_ep_dtoggle_clear(ep_addr_to_nrfx(ep));
|
||||
nrf_usbd_common_ep_dtoggle_clear(ep_addr_to_nrfx(ep));
|
||||
/** Endpoint is enabled on SetInterface request.
|
||||
* This should also clear EP's halt status.
|
||||
*/
|
||||
nrfx_usbd_ep_stall_clear(ep_addr_to_nrfx(ep));
|
||||
nrf_usbd_common_ep_stall_clear(ep_addr_to_nrfx(ep));
|
||||
}
|
||||
if (ep_ctx->cfg.en) {
|
||||
return -EALREADY;
|
||||
|
@ -1566,7 +1567,7 @@ int usb_dc_ep_enable(const uint8_t ep)
|
|||
|
||||
/* Defer the endpoint enable if USBD is not ready yet. */
|
||||
if (dev_ready()) {
|
||||
nrfx_usbd_ep_enable(ep_addr_to_nrfx(ep));
|
||||
nrf_usbd_common_ep_enable(ep_addr_to_nrfx(ep));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1587,8 +1588,8 @@ int usb_dc_ep_disable(const uint8_t ep)
|
|||
|
||||
LOG_DBG("EP disable: 0x%02x", ep);
|
||||
|
||||
nrfx_usbd_ep_disable(ep_addr_to_nrfx(ep));
|
||||
/* Clear write_in_progress as nrfx_usbd_ep_disable()
|
||||
nrf_usbd_common_ep_disable(ep_addr_to_nrfx(ep));
|
||||
/* Clear write_in_progress as nrf_usbd_common_ep_disable()
|
||||
* terminates endpoint transaction.
|
||||
*/
|
||||
ep_ctx->write_in_progress = false;
|
||||
|
@ -1614,7 +1615,7 @@ int usb_dc_ep_flush(const uint8_t ep)
|
|||
ep_ctx->buf.len = 0U;
|
||||
ep_ctx->buf.curr = ep_ctx->buf.data;
|
||||
|
||||
nrfx_usbd_transfer_out_drop(ep_addr_to_nrfx(ep));
|
||||
nrf_usbd_common_transfer_out_drop(ep_addr_to_nrfx(ep));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1682,15 +1683,15 @@ int usb_dc_ep_write(const uint8_t ep, const uint8_t *const data,
|
|||
* and perform appropriate action.
|
||||
*/
|
||||
if ((ep_ctx->cfg.type == USB_DC_EP_CONTROL)
|
||||
&& (nrfx_usbd_last_setup_dir_get() != ep)) {
|
||||
nrfx_usbd_setup_clear();
|
||||
&& (nrf_usbd_common_last_setup_dir_get() != ep)) {
|
||||
nrf_usbd_common_setup_clear();
|
||||
k_mutex_unlock(&ctx->drv_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ep_ctx->write_in_progress = true;
|
||||
NRFX_USBD_TRANSFER_IN(transfer, data, data_len, 0);
|
||||
nrfx_err_t err = nrfx_usbd_ep_transfer(ep_addr_to_nrfx(ep), &transfer);
|
||||
NRF_USBD_COMMON_TRANSFER_IN(transfer, data, data_len, 0);
|
||||
nrfx_err_t err = nrf_usbd_common_ep_transfer(ep_addr_to_nrfx(ep), &transfer);
|
||||
|
||||
if (err != NRFX_SUCCESS) {
|
||||
ep_ctx->write_in_progress = false;
|
||||
|
@ -1870,7 +1871,7 @@ int usb_dc_ep_mps(const uint8_t ep)
|
|||
|
||||
int usb_dc_wakeup_request(void)
|
||||
{
|
||||
bool res = nrfx_usbd_wakeup_req();
|
||||
bool res = nrf_usbd_common_wakeup_req();
|
||||
|
||||
if (!res) {
|
||||
return -EAGAIN;
|
||||
|
@ -1906,7 +1907,7 @@ static int usb_init(void)
|
|||
.handler = usb_dc_power_event_handler
|
||||
};
|
||||
|
||||
err = nrfx_usbd_init(usbd_event_handler);
|
||||
err = nrf_usbd_common_init(usbd_event_handler);
|
||||
if (err != NRFX_SUCCESS) {
|
||||
LOG_DBG("nRF USBD driver init failed. Code: %d", (uint32_t)err);
|
||||
return -EIO;
|
||||
|
|
|
@ -5,7 +5,7 @@ config UDC_NRF
|
|||
bool "Nordic Semiconductor USB device controller driver"
|
||||
default y
|
||||
depends on DT_HAS_NORDIC_NRF_USBD_ENABLED
|
||||
select NRFX_USBD
|
||||
select NRF_USBD_COMMON
|
||||
select NRFX_POWER
|
||||
help
|
||||
nRF USB device controller driver.
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
#include <zephyr/drivers/clock_control.h>
|
||||
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
|
||||
|
||||
#include <nrfx_usbd.h>
|
||||
#include <nrf_usbd_common.h>
|
||||
#include <hal/nrf_usbd.h>
|
||||
#include <nrfx_power.h>
|
||||
#include "udc_common.h"
|
||||
|
||||
|
@ -47,7 +48,7 @@ enum udc_nrf_event_type {
|
|||
struct udc_nrf_evt {
|
||||
enum udc_nrf_event_type type;
|
||||
union {
|
||||
nrfx_usbd_evt_t hal_evt;
|
||||
nrf_usbd_common_evt_t hal_evt;
|
||||
uint8_t ep;
|
||||
};
|
||||
};
|
||||
|
@ -82,10 +83,10 @@ static struct onoff_client hfxo_cli;
|
|||
|
||||
static void udc_nrf_clear_control_out(const struct device *dev)
|
||||
{
|
||||
if (nrfx_usbd_last_setup_dir_get() == USB_CONTROL_EP_OUT &&
|
||||
if (nrf_usbd_common_last_setup_dir_get() == USB_CONTROL_EP_OUT &&
|
||||
udc_nrf_setup_rcvd) {
|
||||
/* Allow data chunk on EP0 OUT */
|
||||
nrfx_usbd_setup_data_clear();
|
||||
nrf_usbd_common_setup_data_clear();
|
||||
udc_nrf_setup_rcvd = false;
|
||||
LOG_INF("Allow data OUT");
|
||||
}
|
||||
|
@ -101,15 +102,15 @@ static void udc_event_xfer_in_next(const struct device *dev, const uint8_t ep)
|
|||
|
||||
buf = udc_buf_peek(dev, ep);
|
||||
if (buf != NULL) {
|
||||
nrfx_usbd_transfer_t xfer = {
|
||||
nrf_usbd_common_transfer_t xfer = {
|
||||
.p_data = {.tx = buf->data},
|
||||
.size = buf->len,
|
||||
.flags = udc_ep_buf_has_zlp(buf) ?
|
||||
NRFX_USBD_TRANSFER_ZLP_FLAG : 0,
|
||||
NRF_USBD_COMMON_TRANSFER_ZLP_FLAG : 0,
|
||||
};
|
||||
nrfx_err_t err;
|
||||
|
||||
err = nrfx_usbd_ep_transfer(ep, &xfer);
|
||||
err = nrf_usbd_common_ep_transfer(ep, &xfer);
|
||||
if (err != NRFX_SUCCESS) {
|
||||
LOG_ERR("ep 0x%02x nrfx error: %x", ep, err);
|
||||
/* REVISE: remove from endpoint queue? ASSERT? */
|
||||
|
@ -141,7 +142,7 @@ static void udc_event_xfer_ctrl_in(const struct device *dev,
|
|||
/* Update to next stage of control transfer */
|
||||
udc_ctrl_update_stage(dev, buf);
|
||||
|
||||
nrfx_usbd_setup_clear();
|
||||
nrf_usbd_common_setup_clear();
|
||||
}
|
||||
|
||||
static void udc_event_fake_status_in(const struct device *dev)
|
||||
|
@ -159,13 +160,13 @@ static void udc_event_fake_status_in(const struct device *dev)
|
|||
}
|
||||
|
||||
static void udc_event_xfer_in(const struct device *dev,
|
||||
nrfx_usbd_evt_t const *const event)
|
||||
nrf_usbd_common_evt_t const *const event)
|
||||
{
|
||||
uint8_t ep = event->data.eptransfer.ep;
|
||||
struct net_buf *buf;
|
||||
|
||||
switch (event->data.eptransfer.status) {
|
||||
case NRFX_USBD_EP_OK:
|
||||
case NRF_USBD_COMMON_EP_OK:
|
||||
buf = udc_buf_get(dev, ep);
|
||||
if (buf == NULL) {
|
||||
LOG_ERR("ep 0x%02x queue is empty", ep);
|
||||
|
@ -181,7 +182,7 @@ static void udc_event_xfer_in(const struct device *dev,
|
|||
udc_submit_ep_event(dev, buf, 0);
|
||||
break;
|
||||
|
||||
case NRFX_USBD_EP_ABORTED:
|
||||
case NRF_USBD_COMMON_EP_ABORTED:
|
||||
LOG_WRN("aborted IN ep 0x%02x", ep);
|
||||
buf = udc_buf_get_all(dev, ep);
|
||||
|
||||
|
@ -228,14 +229,14 @@ static void udc_event_xfer_out_next(const struct device *dev, const uint8_t ep)
|
|||
|
||||
buf = udc_buf_peek(dev, ep);
|
||||
if (buf != NULL) {
|
||||
nrfx_usbd_transfer_t xfer = {
|
||||
nrf_usbd_common_transfer_t xfer = {
|
||||
.p_data = {.rx = buf->data},
|
||||
.size = buf->size,
|
||||
.flags = 0,
|
||||
};
|
||||
nrfx_err_t err;
|
||||
|
||||
err = nrfx_usbd_ep_transfer(ep, &xfer);
|
||||
err = nrf_usbd_common_ep_transfer(ep, &xfer);
|
||||
if (err != NRFX_SUCCESS) {
|
||||
LOG_ERR("ep 0x%02x nrfx error: %x", ep, err);
|
||||
/* REVISE: remove from endpoint queue? ASSERT? */
|
||||
|
@ -249,24 +250,24 @@ static void udc_event_xfer_out_next(const struct device *dev, const uint8_t ep)
|
|||
}
|
||||
|
||||
static void udc_event_xfer_out(const struct device *dev,
|
||||
nrfx_usbd_evt_t const *const event)
|
||||
nrf_usbd_common_evt_t const *const event)
|
||||
{
|
||||
uint8_t ep = event->data.eptransfer.ep;
|
||||
nrfx_usbd_ep_status_t err_code;
|
||||
nrf_usbd_common_ep_status_t err_code;
|
||||
struct net_buf *buf;
|
||||
size_t len;
|
||||
|
||||
switch (event->data.eptransfer.status) {
|
||||
case NRFX_USBD_EP_WAITING:
|
||||
case NRF_USBD_COMMON_EP_WAITING:
|
||||
/*
|
||||
* There is nothing to do here, new transfer
|
||||
* will be tried in both cases later.
|
||||
*/
|
||||
break;
|
||||
|
||||
case NRFX_USBD_EP_OK:
|
||||
err_code = nrfx_usbd_ep_status_get(ep, &len);
|
||||
if (err_code != NRFX_USBD_EP_OK) {
|
||||
case NRF_USBD_COMMON_EP_OK:
|
||||
err_code = nrf_usbd_common_ep_status_get(ep, &len);
|
||||
if (err_code != NRF_USBD_COMMON_EP_OK) {
|
||||
LOG_ERR("OUT transfer failed %d", err_code);
|
||||
}
|
||||
|
||||
|
@ -325,8 +326,8 @@ static int udc_event_xfer_setup(const struct device *dev)
|
|||
}
|
||||
|
||||
udc_ep_buf_set_setup(buf);
|
||||
nrfx_usbd_setup_get((nrfx_usbd_setup_t *)buf->data);
|
||||
net_buf_add(buf, sizeof(nrfx_usbd_setup_t));
|
||||
nrf_usbd_common_setup_get((nrf_usbd_common_setup_t *)buf->data);
|
||||
net_buf_add(buf, sizeof(nrf_usbd_common_setup_t));
|
||||
udc_nrf_setup_rcvd = true;
|
||||
|
||||
/* Update to next stage of control transfer */
|
||||
|
@ -366,7 +367,7 @@ static void udc_nrf_thread(void *p1, void *p2, void *p3)
|
|||
case UDC_NRF_EVT_HAL:
|
||||
ep = evt.hal_evt.data.eptransfer.ep;
|
||||
switch (evt.hal_evt.type) {
|
||||
case NRFX_USBD_EVT_EPTRANSFER:
|
||||
case NRF_USBD_COMMON_EVT_EPTRANSFER:
|
||||
start_xfer = true;
|
||||
if (USB_EP_DIR_IS_IN(ep)) {
|
||||
udc_event_xfer_in(dev, &evt.hal_evt);
|
||||
|
@ -374,7 +375,7 @@ static void udc_nrf_thread(void *p1, void *p2, void *p3)
|
|||
udc_event_xfer_out(dev, &evt.hal_evt);
|
||||
}
|
||||
break;
|
||||
case NRFX_USBD_EVT_SETUP:
|
||||
case NRF_USBD_COMMON_EVT_SETUP:
|
||||
udc_event_xfer_setup(dev);
|
||||
break;
|
||||
default:
|
||||
|
@ -419,33 +420,33 @@ static void udc_sof_check_iso_out(const struct device *dev)
|
|||
}
|
||||
}
|
||||
|
||||
static void usbd_event_handler(nrfx_usbd_evt_t const *const hal_evt)
|
||||
static void usbd_event_handler(nrf_usbd_common_evt_t const *const hal_evt)
|
||||
{
|
||||
switch (hal_evt->type) {
|
||||
case NRFX_USBD_EVT_SUSPEND:
|
||||
case NRF_USBD_COMMON_EVT_SUSPEND:
|
||||
LOG_INF("SUSPEND state detected");
|
||||
nrfx_usbd_suspend();
|
||||
nrf_usbd_common_suspend();
|
||||
udc_set_suspended(udc_nrf_dev, true);
|
||||
udc_submit_event(udc_nrf_dev, UDC_EVT_SUSPEND, 0);
|
||||
break;
|
||||
case NRFX_USBD_EVT_RESUME:
|
||||
case NRF_USBD_COMMON_EVT_RESUME:
|
||||
LOG_INF("RESUMING from suspend");
|
||||
udc_set_suspended(udc_nrf_dev, false);
|
||||
udc_submit_event(udc_nrf_dev, UDC_EVT_RESUME, 0);
|
||||
break;
|
||||
case NRFX_USBD_EVT_WUREQ:
|
||||
case NRF_USBD_COMMON_EVT_WUREQ:
|
||||
LOG_INF("Remote wakeup initiated");
|
||||
break;
|
||||
case NRFX_USBD_EVT_RESET:
|
||||
case NRF_USBD_COMMON_EVT_RESET:
|
||||
LOG_INF("Reset");
|
||||
udc_submit_event(udc_nrf_dev, UDC_EVT_RESET, 0);
|
||||
break;
|
||||
case NRFX_USBD_EVT_SOF:
|
||||
case NRF_USBD_COMMON_EVT_SOF:
|
||||
udc_submit_event(udc_nrf_dev, UDC_EVT_SOF, 0);
|
||||
udc_sof_check_iso_out(udc_nrf_dev);
|
||||
break;
|
||||
case NRFX_USBD_EVT_EPTRANSFER:
|
||||
case NRFX_USBD_EVT_SETUP: {
|
||||
case NRF_USBD_COMMON_EVT_EPTRANSFER:
|
||||
case NRF_USBD_COMMON_EVT_SETUP: {
|
||||
struct udc_nrf_evt evt = {
|
||||
.type = UDC_NRF_EVT_HAL,
|
||||
.hal_evt = *hal_evt,
|
||||
|
@ -471,7 +472,7 @@ static void udc_nrf_power_handler(nrfx_power_usb_evt_t pwr_evt)
|
|||
case NRFX_POWER_USB_EVT_READY:
|
||||
LOG_INF("POWER event ready");
|
||||
udc_submit_event(udc_nrf_dev, UDC_EVT_VBUS_READY, 0);
|
||||
nrfx_usbd_start(true);
|
||||
nrf_usbd_common_start(true);
|
||||
break;
|
||||
case NRFX_POWER_USB_EVT_REMOVED:
|
||||
LOG_INF("POWER event removed");
|
||||
|
@ -489,7 +490,7 @@ static void udc_nrf_fake_status_in(const struct device *dev)
|
|||
.ep = USB_CONTROL_EP_IN,
|
||||
};
|
||||
|
||||
if (nrfx_usbd_last_setup_dir_get() == USB_CONTROL_EP_OUT) {
|
||||
if (nrf_usbd_common_last_setup_dir_get() == USB_CONTROL_EP_OUT) {
|
||||
/* Let controller perform status IN stage */
|
||||
k_msgq_put(&drv_msgq, &evt, K_NO_WAIT);
|
||||
}
|
||||
|
@ -519,9 +520,9 @@ static int udc_nrf_ep_enqueue(const struct device *dev,
|
|||
static int udc_nrf_ep_dequeue(const struct device *dev,
|
||||
struct udc_ep_config *cfg)
|
||||
{
|
||||
bool busy = nrfx_usbd_ep_is_busy(cfg->addr);
|
||||
bool busy = nrf_usbd_common_ep_is_busy(cfg->addr);
|
||||
|
||||
nrfx_usbd_ep_abort(cfg->addr);
|
||||
nrf_usbd_common_ep_abort(cfg->addr);
|
||||
if (USB_EP_DIR_IS_OUT(cfg->addr) || !busy) {
|
||||
struct net_buf *buf;
|
||||
|
||||
|
@ -550,14 +551,14 @@ static int udc_nrf_ep_enable(const struct device *dev,
|
|||
|
||||
__ASSERT_NO_MSG(cfg);
|
||||
mps = (cfg->mps == 0) ? cfg->caps.mps : cfg->mps;
|
||||
nrfx_usbd_ep_max_packet_size_set(cfg->addr, mps);
|
||||
nrfx_usbd_ep_enable(cfg->addr);
|
||||
nrf_usbd_common_ep_max_packet_size_set(cfg->addr, mps);
|
||||
nrf_usbd_common_ep_enable(cfg->addr);
|
||||
if (!NRF_USBD_EPISO_CHECK(cfg->addr)) {
|
||||
/* ISO transactions for full-speed device do not support
|
||||
* toggle sequencing and should only send DATA0 PID.
|
||||
*/
|
||||
nrfx_usbd_ep_dtoggle_clear(cfg->addr);
|
||||
nrfx_usbd_ep_stall_clear(cfg->addr);
|
||||
nrf_usbd_common_ep_dtoggle_clear(cfg->addr);
|
||||
nrf_usbd_common_ep_stall_clear(cfg->addr);
|
||||
}
|
||||
|
||||
LOG_DBG("Enable ep 0x%02x", cfg->addr);
|
||||
|
@ -569,7 +570,7 @@ static int udc_nrf_ep_disable(const struct device *dev,
|
|||
struct udc_ep_config *cfg)
|
||||
{
|
||||
__ASSERT_NO_MSG(cfg);
|
||||
nrfx_usbd_ep_disable(cfg->addr);
|
||||
nrf_usbd_common_ep_disable(cfg->addr);
|
||||
LOG_DBG("Disable ep 0x%02x", cfg->addr);
|
||||
|
||||
return 0;
|
||||
|
@ -582,9 +583,9 @@ static int udc_nrf_ep_set_halt(const struct device *dev,
|
|||
|
||||
if (cfg->addr == USB_CONTROL_EP_OUT ||
|
||||
cfg->addr == USB_CONTROL_EP_IN) {
|
||||
nrfx_usbd_setup_stall();
|
||||
nrf_usbd_common_setup_stall();
|
||||
} else {
|
||||
nrfx_usbd_ep_stall(cfg->addr);
|
||||
nrf_usbd_common_ep_stall(cfg->addr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -595,8 +596,8 @@ static int udc_nrf_ep_clear_halt(const struct device *dev,
|
|||
{
|
||||
LOG_DBG("Clear halt ep 0x%02x", cfg->addr);
|
||||
|
||||
nrfx_usbd_ep_dtoggle_clear(cfg->addr);
|
||||
nrfx_usbd_ep_stall_clear(cfg->addr);
|
||||
nrf_usbd_common_ep_dtoggle_clear(cfg->addr);
|
||||
nrf_usbd_common_ep_stall_clear(cfg->addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -616,7 +617,7 @@ static int udc_nrf_set_address(const struct device *dev, const uint8_t addr)
|
|||
|
||||
static int udc_nrf_host_wakeup(const struct device *dev)
|
||||
{
|
||||
bool res = nrfx_usbd_wakeup_req();
|
||||
bool res = nrf_usbd_common_wakeup_req();
|
||||
|
||||
LOG_DBG("Host wakeup request");
|
||||
if (!res) {
|
||||
|
@ -630,7 +631,7 @@ static int udc_nrf_enable(const struct device *dev)
|
|||
{
|
||||
int ret;
|
||||
|
||||
nrfx_usbd_enable();
|
||||
nrf_usbd_common_enable();
|
||||
|
||||
sys_notify_init_spinwait(&hfxo_cli.notify);
|
||||
ret = onoff_request(hfxo_mgr, &hfxo_cli);
|
||||
|
@ -646,7 +647,7 @@ static int udc_nrf_disable(const struct device *dev)
|
|||
{
|
||||
int ret;
|
||||
|
||||
nrfx_usbd_disable();
|
||||
nrf_usbd_common_disable();
|
||||
|
||||
ret = onoff_cancel_or_release(hfxo_mgr, &hfxo_cli);
|
||||
if (ret < 0) {
|
||||
|
@ -675,12 +676,12 @@ static int udc_nrf_init(const struct device *dev)
|
|||
#endif
|
||||
|
||||
IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
|
||||
nrfx_isr, nrfx_usbd_irq_handler, 0);
|
||||
nrfx_isr, nrf_usbd_common_irq_handler, 0);
|
||||
|
||||
(void)nrfx_power_init(&cfg->pwr);
|
||||
nrfx_power_usbevt_init(&cfg->evt);
|
||||
|
||||
ret = nrfx_usbd_init(usbd_event_handler);
|
||||
ret = nrf_usbd_common_init(usbd_event_handler);
|
||||
if (ret != NRFX_SUCCESS) {
|
||||
LOG_ERR("nRF USBD driver initialization failed");
|
||||
return -EIO;
|
||||
|
@ -719,7 +720,7 @@ static int udc_nrf_shutdown(const struct device *dev)
|
|||
}
|
||||
|
||||
nrfx_power_usbevt_disable();
|
||||
nrfx_usbd_uninit();
|
||||
nrf_usbd_common_uninit();
|
||||
nrfx_power_usbevt_uninit();
|
||||
#ifdef CONFIG_HAS_HW_NRF_USBREG
|
||||
irq_disable(USBREGULATOR_IRQn);
|
||||
|
@ -748,14 +749,14 @@ static int udc_nrf_driver_init(const struct device *dev)
|
|||
ep_cfg_out[i].caps.out = 1;
|
||||
if (i == 0) {
|
||||
ep_cfg_out[i].caps.control = 1;
|
||||
ep_cfg_out[i].caps.mps = NRFX_USBD_EPSIZE;
|
||||
ep_cfg_out[i].caps.mps = NRF_USBD_COMMON_EPSIZE;
|
||||
} else if (i < (CFG_EPOUT_CNT + 1)) {
|
||||
ep_cfg_out[i].caps.bulk = 1;
|
||||
ep_cfg_out[i].caps.interrupt = 1;
|
||||
ep_cfg_out[i].caps.mps = NRFX_USBD_EPSIZE;
|
||||
ep_cfg_out[i].caps.mps = NRF_USBD_COMMON_EPSIZE;
|
||||
} else {
|
||||
ep_cfg_out[i].caps.iso = 1;
|
||||
ep_cfg_out[i].caps.mps = NRFX_USBD_ISOSIZE / 2;
|
||||
ep_cfg_out[i].caps.mps = NRF_USBD_COMMON_ISOSIZE / 2;
|
||||
}
|
||||
|
||||
ep_cfg_out[i].addr = USB_EP_DIR_OUT | i;
|
||||
|
@ -770,14 +771,14 @@ static int udc_nrf_driver_init(const struct device *dev)
|
|||
ep_cfg_in[i].caps.in = 1;
|
||||
if (i == 0) {
|
||||
ep_cfg_in[i].caps.control = 1;
|
||||
ep_cfg_in[i].caps.mps = NRFX_USBD_EPSIZE;
|
||||
ep_cfg_in[i].caps.mps = NRF_USBD_COMMON_EPSIZE;
|
||||
} else if (i < (CFG_EPIN_CNT + 1)) {
|
||||
ep_cfg_in[i].caps.bulk = 1;
|
||||
ep_cfg_in[i].caps.interrupt = 1;
|
||||
ep_cfg_in[i].caps.mps = NRFX_USBD_EPSIZE;
|
||||
ep_cfg_in[i].caps.mps = NRF_USBD_COMMON_EPSIZE;
|
||||
} else {
|
||||
ep_cfg_in[i].caps.iso = 1;
|
||||
ep_cfg_in[i].caps.mps = NRFX_USBD_ISOSIZE / 2;
|
||||
ep_cfg_in[i].caps.mps = NRF_USBD_COMMON_ISOSIZE / 2;
|
||||
}
|
||||
|
||||
ep_cfg_in[i].addr = USB_EP_DIR_IN | i;
|
||||
|
|
|
@ -104,7 +104,6 @@ zephyr_library_sources_ifdef(CONFIG_NRFX_TWIM ${SRC_DIR}/nrfx_twim.c)
|
|||
zephyr_library_sources_ifdef(CONFIG_NRFX_TWIS ${SRC_DIR}/nrfx_twis.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_NRFX_UART ${SRC_DIR}/nrfx_uart.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_NRFX_UARTE ${SRC_DIR}/nrfx_uarte.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_NRFX_USBD ${SRC_DIR}/nrfx_usbd.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_NRFX_USBREG ${SRC_DIR}/nrfx_usbreg.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_NRFX_WDT ${SRC_DIR}/nrfx_wdt.c)
|
||||
|
||||
|
|
|
@ -519,19 +519,6 @@ config NRFX_UARTE3
|
|||
depends on $(dt_nodelabel_has_compat,uart3,$(DT_COMPAT_NORDIC_NRF_UARTE))
|
||||
select NRFX_UARTE
|
||||
|
||||
config NRFX_USBD
|
||||
bool "USBD driver"
|
||||
depends on $(dt_has_compat,$(DT_COMPAT_NORDIC_NRF_USBD))
|
||||
|
||||
config NRFX_USBD_ISO_IN_ZLP
|
||||
bool "Send ZLP on ISO IN when not ready"
|
||||
depends on NRFX_USBD
|
||||
default y
|
||||
help
|
||||
Controls the response of the ISO IN endpoint to an IN token when no
|
||||
data is ready to be sent. When enabled, ZLP is sent when no data is
|
||||
ready. When disabled, no response is sent (bus timeout occurs).
|
||||
|
||||
config NRFX_USBREG
|
||||
bool "USBREG driver"
|
||||
depends on $(dt_has_compat,$(DT_COMPAT_NORDIC_NRF_USBREG))
|
||||
|
|
|
@ -132,10 +132,6 @@ config NRFX_UARTE_LOG
|
|||
bool "UARTE driver logging"
|
||||
depends on NRFX_UARTE
|
||||
|
||||
config NRFX_USBD_LOG
|
||||
bool "USBD driver logging"
|
||||
depends on NRFX_USBD
|
||||
|
||||
config NRFX_USBREG_LOG
|
||||
bool "USBREG driver logging"
|
||||
depends on NRFX_USBREG
|
||||
|
|
|
@ -546,17 +546,6 @@
|
|||
#define NRFX_UARTE3_ENABLED 1
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NRFX_USBD
|
||||
#define NRFX_USBD_ENABLED 1
|
||||
#endif
|
||||
#ifdef CONFIG_NRFX_USBD_LOG
|
||||
#define NRFX_USBD_CONFIG_LOG_ENABLED 1
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NRFX_USBD_ISO_IN_ZLP
|
||||
#define NRFX_USBD_CONFIG_ISO_IN_ZLP 1
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NRFX_USBREG
|
||||
#define NRFX_USBREG_ENABLED 1
|
||||
#endif
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2016 - 2023, Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef NRFX_USBD_ERRATA_H__
|
||||
#define NRFX_USBD_ERRATA_H__
|
||||
|
||||
#include <nrfx.h>
|
||||
#include <nrf_erratas.h>
|
||||
|
||||
#ifndef NRFX_USBD_ERRATA_ENABLE
|
||||
/**
|
||||
* @brief The constant that informs if errata should be enabled at all.
|
||||
*
|
||||
* If this constant is set to 0, all the Errata bug fixes will be automatically disabled.
|
||||
*/
|
||||
#define NRFX_USBD_ERRATA_ENABLE 1
|
||||
#endif
|
||||
|
||||
/* Errata: ISO double buffering not functional. **/
|
||||
static inline bool nrfx_usbd_errata_166(void)
|
||||
{
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_166();
|
||||
}
|
||||
|
||||
/* Errata: USBD might not reach its active state. **/
|
||||
static inline bool nrfx_usbd_errata_171(void)
|
||||
{
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_171();
|
||||
}
|
||||
|
||||
/* Errata: USB cannot be enabled. **/
|
||||
static inline bool nrfx_usbd_errata_187(void)
|
||||
{
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_187();
|
||||
}
|
||||
|
||||
/* Errata: USBD cannot receive tasks during DMA. **/
|
||||
static inline bool nrfx_usbd_errata_199(void)
|
||||
{
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_199();
|
||||
}
|
||||
|
||||
/* Errata: Device remains in SUSPEND too long. */
|
||||
static inline bool nrfx_usbd_errata_211(void)
|
||||
{
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_211();
|
||||
}
|
||||
|
||||
/* Errata: Unexpected behavior after reset. **/
|
||||
static inline bool nrfx_usbd_errata_223(void)
|
||||
{
|
||||
return NRFX_USBD_ERRATA_ENABLE && nrf52_errata_223();
|
||||
}
|
||||
|
||||
#endif /* NRFX_USBD_ERRATA_H__ */
|
|
@ -97,7 +97,7 @@ config USB_NUMOF_EP_WRITE_RETRIES
|
|||
|
||||
config USB_DEVICE_SOF
|
||||
bool "Start of Frame processing in events"
|
||||
default y if (USB_DEVICE_AUDIO && NRFX_USBD)
|
||||
default y if (USB_DEVICE_AUDIO && NRF_USBD_COMMON)
|
||||
|
||||
config USB_DEVICE_BOS
|
||||
bool "USB Binary Device Object Store (BOS)"
|
||||
|
|
Loading…
Reference in a new issue