nrfusb.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Koen Zandberg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef NRFUSB_H
23 #define NRFUSB_H
24 
25 #include <stdint.h>
26 #include <stddef.h>
27 #include "periph/usbdev.h"
28 #include "cpu.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
37 #define NRF_USB_NUM_PERIPH 1
38 
42 #define NRF_USB_BUF_SPACE USBDEV_EP_BUF_SPACE
43 
47 #define NRF_USB_NUM_EP USBDEV_NUM_ENDPOINTS
48 
52 typedef enum {
59 
63 typedef struct {
67  NRF_USBD_Type *device;
68  size_t used;
70  uint8_t buffer[NRF_USB_BUF_SPACE];
72 } nrfusb_t;
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 #endif /* NRFUSB_H */
78 
NRF_USB_BUF_SPACE
#define NRF_USB_BUF_SPACE
USB endpoint buffer space.
Definition: nrfusb.h:42
nrfusb_t::usbdev
usbdev_t usbdev
Inherited usbdev struct
Definition: nrfusb.h:64
usbdev.h
Definitions low-level USB driver interface.
usbdev
usbdev device descriptor
Definition: usbdev.h:217
nrfusb_t
nrf usb peripheral device context
Definition: nrfusb.h:63
NRFUSB_SETUP_ACKOUT
@ NRFUSB_SETUP_ACKOUT
Expecting an ACK on the out endpoint.
Definition: nrfusb.h:56
usbdev_ep
usbdev endpoint descriptor
Definition: usbdev.h:229
NRFUSB_SETUP_READY
@ NRFUSB_SETUP_READY
Ready for a new setup request
Definition: nrfusb.h:53
NRFUSB_SETUP_WRITE
@ NRFUSB_SETUP_WRITE
Write request received
Definition: nrfusb.h:55
NRFUSB_SETUP_ACKIN
@ NRFUSB_SETUP_ACKIN
Expecting an ACK on the in endpoint
Definition: nrfusb.h:57
NRFUSB_SETUP_READ
@ NRFUSB_SETUP_READ
Read request received
Definition: nrfusb.h:54
nrfusb_t::device
NRF_USBD_Type * device
Ptr to the device registers
Definition: nrfusb.h:67
nrfusb_t::used
size_t used
Number of bytes from the buffer that are used
Definition: nrfusb.h:68
NRF_USB_NUM_EP
#define NRF_USB_NUM_EP
Number of USB IN and OUT endpoints.
Definition: nrfusb.h:47
nrfusb_setup_state_t
nrfusb_setup_state_t
nrfusb setup packet state tracker for endpoint 0 handling
Definition: nrfusb.h:52
nrfusb_t::sstate
nrfusb_setup_state_t sstate
Setup request state machine
Definition: nrfusb.h:71