Skip to content
Permalink
Browse files

drivers: usb_dc_nrfx: use REQTYPE_GET_DIR and REQTYPE_GET_TYPE macros

Use REQTYPE_GET_DIR and REQTYPE_GET_TYPE macros from
USB subsystem instead of specially introduced.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
  • Loading branch information...
jfischer-phytec-iot authored and nashif committed Jul 3, 2019
1 parent a1d815e commit 04b91579aee71cbe97bb26507b8a3dd7ce897697
Showing with 5 additions and 16 deletions.
  1. +5 −16 drivers/usb/device/usb_dc_nrfx.c
@@ -29,17 +29,6 @@
#include <logging/log.h>
LOG_MODULE_REGISTER(usb_nrfx);

#define USB_BREQUEST_SETADDRESS 0x05
#define USB_BMREQUESTTYPE_DIR_POS 7uL
#define USB_BMREQUESTTYPE_DIR_MASK (1uL << USB_BMREQUESTTYPE_DIR_POS)
#define USB_BMREQUESTTYPE_DIR_HOSTTODEVICE_MASK 0uL
#define USB_BMREQUESTTYPE_DIR_DEVICETOHOST_MASK (1uL << USB_BMREQUESTTYPE_DIR_POS)
#define USB_BMREQUESTTYPE_TYPE_POS 5uL
#define USB_BMREQUESTTYPE_TYPE_MASK (3uL << USB_BMREQUESTTYPE_TYPE_POS)
#define USB_BMREQUESTTYPE_TYPE_STANDARD_MASK 0uL
#define USB_BMREQUESTTYPE_TYPE_CLASS_MASK (1uL << USB_BMREQUESTTYPE_TYPE_POS)
#define USB_BMREQUESTTYPE_TYPE_CLASS_VENDOR (2uL << USB_BMREQUESTTYPE_TYPE_POS)

#define MAX_EP_BUF_SZ 64UL
#define MAX_ISO_EP_BUF_SZ 1024UL

@@ -852,8 +841,8 @@ static inline void usbd_work_process_setup(struct nrf_usbd_ep_ctx *ep_ctx)

struct nrf_usbd_ctx *ctx = get_usbd_ctx();

if (((usbd_setup->bmRequestType & USB_BMREQUESTTYPE_DIR_MASK)
== USB_BMREQUESTTYPE_DIR_HOSTTODEVICE_MASK)
if ((REQTYPE_GET_DIR(usbd_setup->bmRequestType)
== REQTYPE_DIR_TO_DEVICE)
&& (usbd_setup->wLength)) {
struct nrf_usbd_ctx *ctx = get_usbd_ctx();

@@ -1175,9 +1164,9 @@ static void usbd_event_handler(nrfx_usbd_evt_t const *const p_event)
nrfx_usbd_setup_t drv_setup;

nrfx_usbd_setup_get(&drv_setup);
if ((drv_setup.bRequest != USB_BREQUEST_SETADDRESS)
|| ((drv_setup.bmRequestType & USB_BMREQUESTTYPE_TYPE_MASK)
!= USB_BMREQUESTTYPE_TYPE_STANDARD_MASK)) {
if ((drv_setup.bRequest != REQ_SET_ADDRESS)
|| (REQTYPE_GET_TYPE(drv_setup.bmRequestType)
!= REQTYPE_TYPE_STANDARD)) {
/* SetAddress is habdled by USBD hardware.
* No software action required.
*/

0 comments on commit 04b9157

Please sign in to comment.
You can’t perform that action at this time.