summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/driver/usbh_device_driver.h25
-rw-r--r--src/usbh_driver_ac_midi.c4
-rw-r--r--src/usbh_driver_gp_xbox.c2
-rw-r--r--src/usbh_driver_hid_mouse.c2
-rw-r--r--src/usbh_driver_hub.c2
-rw-r--r--src/usbh_hubbed.c4
-rw-r--r--src/usbh_lld_stm32f4.c24
7 files changed, 33 insertions, 30 deletions
diff --git a/include/driver/usbh_device_driver.h b/include/driver/usbh_device_driver.h
index 137b39b..3a4fbe3 100644
--- a/include/driver/usbh_device_driver.h
+++ b/include/driver/usbh_device_driver.h
@@ -30,15 +30,18 @@
BEGIN_DECLS
-#define USBH_EPTYP_CONTROL (0)
-#define USBH_EPTYP_ISOCHRONOUS (1)
-#define USBH_EPTYP_BULK (2)
-#define USBH_EPTYP_INTERRUPT (3)
-
-#define USBH_SPEED_FULL (0)
-#define USBH_SPEED_LOW (1)
-#define USBH_SPEED_HIGH (2)
+enum USBH_ENDPOINT_TYPE {
+ USBH_ENDPOINT_TYPE_CONTROL = 0,
+ USBH_ENDPOINT_TYPE_ISOCHRONOUS = 1,
+ USBH_ENDPOINT_TYPE_BULK = 2,
+ USBH_ENDPOINT_TYPE_INTERRUPT = 3,
+};
+enum USBH_SPEED {
+ USBH_SPEED_FULL = 0,
+ USBH_SPEED_LOW = 1,
+ USBH_SPEED_HIGH = 2,
+};
enum USBH_PACKET_CALLBACK_STATUS {
USBH_PACKET_CALLBACK_STATUS_OK = 0,
@@ -56,7 +59,7 @@ enum USBH_POLL_STATUS {
struct _usbh_device {
uint16_t packet_size_max0;
int8_t address;
- uint8_t speed; // (USBH_SPEED_*)
+ enum USBH_SPEED speed; // (USBH_SPEED_*)
uint8_t state; // for enumeration purposes
uint8_t toggle0;
const usbh_dev_driver_t *drv;
@@ -80,7 +83,7 @@ struct _usbh_packet {
uint8_t endpoint_type; // Endpoint type (see USBH_EPTYP_*)
uint8_t endpoint_address; // Endpoint number 0..15
uint16_t endpoint_size_max; // Max packet size for an endpoint
- uint8_t speed; // (USBH_SPEED_*)
+ enum USBH_SPEED speed; // (USBH_SPEED_*)
uint8_t *toggle;
usbh_packet_callback_t callback;
void *callback_arg;
@@ -92,9 +95,9 @@ struct _usbh_driver {
void (*write)(void *drvdata, const usbh_packet_t *packet);
void (*read)(void *drvdata, usbh_packet_t *packet);
enum USBH_POLL_STATUS (*poll)(void *drvdata, uint32_t time_curr_us);
- uint8_t (*root_speed)(void *drvdata);
// Pointer to Low-level driver data
+ enum USBH_SPEED (*root_speed)(void *drvdata);
void *driver_data;
};
typedef struct _usbh_driver usbh_driver_t;
diff --git a/src/usbh_driver_ac_midi.c b/src/usbh_driver_ac_midi.c
index 65c7617..c5403d2 100644
--- a/src/usbh_driver_ac_midi.c
+++ b/src/usbh_driver_ac_midi.c
@@ -246,7 +246,7 @@ static void read_midi_in(void *drvdata, const uint8_t nextstate)
packet.datalen = midi->endpoint_in_maxpacketsize;
packet.endpoint_address = midi->endpoint_in_address;
packet.endpoint_size_max = midi->endpoint_in_maxpacketsize;
- packet.endpoint_type = USBH_EPTYP_BULK;
+ packet.endpoint_type = USBH_ENDPOINT_TYPE_BULK;
packet.speed = midi->usbh_device->speed;
packet.callback = event;
packet.callback_arg = midi->usbh_device;
@@ -367,7 +367,7 @@ void usbh_midi_write(uint8_t device_id, const void *data, uint32_t length, midi_
midi->write_packet.address = dev->address;
midi->write_packet.endpoint_address = midi->endpoint_out_address;
midi->write_packet.endpoint_size_max = midi->endpoint_out_maxpacketsize;
- midi->write_packet.endpoint_type = USBH_EPTYP_BULK;
+ midi->write_packet.endpoint_type = USBH_ENDPOINT_TYPE_BULK;
midi->write_packet.speed = dev->speed;
midi->write_packet.callback = write_callback;
midi->write_packet.callback_arg = midi->usbh_device;
diff --git a/src/usbh_driver_gp_xbox.c b/src/usbh_driver_gp_xbox.c
index ae478ad..d8bb1b2 100644
--- a/src/usbh_driver_gp_xbox.c
+++ b/src/usbh_driver_gp_xbox.c
@@ -330,7 +330,7 @@ static void read_gp_xbox_in(gp_xbox_device_t *gp_xbox)
packet.datalen = gp_xbox->endpoint_in_maxpacketsize;
packet.endpoint_address = gp_xbox->endpoint_in_address;
packet.endpoint_size_max = gp_xbox->endpoint_in_maxpacketsize;
- packet.endpoint_type = USBH_EPTYP_INTERRUPT;
+ packet.endpoint_type = USBH_ENDPOINT_TYPE_INTERRUPT;
packet.speed = gp_xbox->usbh_device->speed;
packet.callback = event;
packet.callback_arg = gp_xbox->usbh_device;
diff --git a/src/usbh_driver_hid_mouse.c b/src/usbh_driver_hid_mouse.c
index 56278ef..8324999 100644
--- a/src/usbh_driver_hid_mouse.c
+++ b/src/usbh_driver_hid_mouse.c
@@ -218,7 +218,7 @@ static void read_mouse_in(void *drvdata)
packet.datalen = mouse->endpoint_in_maxpacketsize;
packet.endpoint_address = mouse->endpoint_in_address;
packet.endpoint_size_max = mouse->endpoint_in_maxpacketsize;
- packet.endpoint_type = USBH_EPTYP_INTERRUPT;
+ packet.endpoint_type = USBH_ENDPOINT_TYPE_INTERRUPT;
packet.speed = mouse->usbh_device->speed;
packet.callback = event;
packet.callback_arg = mouse->usbh_device;
diff --git a/src/usbh_driver_hub.c b/src/usbh_driver_hub.c
index 305a8f3..eaaf896 100644
--- a/src/usbh_driver_hub.c
+++ b/src/usbh_driver_hub.c
@@ -751,7 +751,7 @@ static void read_ep1(void *drvdata)
packet.datalen = hub->endpoint_in_maxpacketsize;
packet.endpoint_address = hub->endpoint_in_address;
packet.endpoint_size_max = hub->endpoint_in_maxpacketsize;
- packet.endpoint_type = USBH_EPTYP_INTERRUPT;
+ packet.endpoint_type = USBH_ENDPOINT_TYPE_INTERRUPT;
packet.speed = hub->device[0]->speed;
packet.callback = event;
packet.callback_arg = hub->device[0];
diff --git a/src/usbh_hubbed.c b/src/usbh_hubbed.c
index 7391232..b631263 100644
--- a/src/usbh_hubbed.c
+++ b/src/usbh_hubbed.c
@@ -207,7 +207,7 @@ void device_xfer_control_write(void *data, uint16_t datalen, usbh_packet_callbac
packet.address = dev->address;
packet.endpoint_address = 0;
packet.endpoint_size_max = dev->packet_size_max0;
- packet.endpoint_type = USBH_EPTYP_CONTROL;
+ packet.endpoint_type = USBH_ENDPOINT_TYPE_CONTROL;
packet.speed = dev->speed;
packet.callback = callback;
packet.callback_arg = dev;
@@ -226,7 +226,7 @@ void device_xfer_control_read(void *data, uint16_t datalen, usbh_packet_callback
packet.address = dev->address;
packet.endpoint_address = 0;
packet.endpoint_size_max = dev->packet_size_max0;
- packet.endpoint_type = USBH_EPTYP_CONTROL;
+ packet.endpoint_type = USBH_ENDPOINT_TYPE_CONTROL;
packet.speed = dev->speed;
packet.callback = callback;
packet.callback_arg = dev;
diff --git a/src/usbh_lld_stm32f4.c b/src/usbh_lld_stm32f4.c
index 49f6cc2..271943a 100644
--- a/src/usbh_lld_stm32f4.c
+++ b/src/usbh_lld_stm32f4.c
@@ -153,18 +153,18 @@ static void stm32f4_usbh_port_channel_setup(
// TODO: maybe to function
switch (eptyp) {
- case USBH_EPTYP_CONTROL:
+ case USBH_ENDPOINT_TYPE_CONTROL:
eptyp = OTG_HCCHAR_EPTYP_CONTROL;
break;
- case USBH_EPTYP_BULK:
+ case USBH_ENDPOINT_TYPE_BULK:
eptyp = OTG_HCCHAR_EPTYP_BULK;
break;
- case USBH_EPTYP_INTERRUPT:
+ case USBH_ENDPOINT_TYPE_INTERRUPT:
// Use bulk transfer also for interrupt, since no difference is on protocol layer
// Except different behaviour of the core
eptyp = OTG_HCCHAR_EPTYP_BULK;
break;
- case USBH_EPTYP_ISOCHRONOUS:
+ case USBH_ENDPOINT_TYPE_ISOCHRONOUS:
eptyp = OTG_HCCHAR_EPTYP_ISOCHRONOUS;
break;
default:
@@ -260,16 +260,16 @@ static void write(void *drvdata, const usbh_packet_t *packet)
channels[channel].packet = *packet;
uint32_t dpid;
- if (packet->endpoint_type == USBH_EPTYP_CONTROL) {
+ if (packet->endpoint_type == USBH_ENDPOINT_TYPE_CONTROL) {
dpid = OTG_HCTSIZ_DPID_MDATA;
packet->toggle[0] = 0;
- } else if(packet->endpoint_type == USBH_EPTYP_INTERRUPT) {
+ } else if(packet->endpoint_type == USBH_ENDPOINT_TYPE_INTERRUPT) {
if (packet->toggle[0]) {
dpid = OTG_HCTSIZ_DPID_DATA1;
} else {
dpid = OTG_HCTSIZ_DPID_DATA0;
}
- } else if (packet->endpoint_type == USBH_EPTYP_BULK) {
+ } else if (packet->endpoint_type == USBH_ENDPOINT_TYPE_BULK) {
if (packet->toggle[0]) {
dpid = OTG_HCTSIZ_DPID_DATA1;
} else {
@@ -295,8 +295,8 @@ static void write(void *drvdata, const usbh_packet_t *packet)
OTG_HCCHAR_EPDIR_OUT,
packet->endpoint_size_max);
- if (packet->endpoint_type == USBH_EPTYP_CONTROL ||
- packet->endpoint_type == USBH_EPTYP_BULK) {
+ if (packet->endpoint_type == USBH_ENDPOINT_TYPE_CONTROL ||
+ packet->endpoint_type == USBH_ENDPOINT_TYPE_BULK) {
volatile uint32_t *fifo = &REBASE_CH(OTG_FIFO, channel) + RX_FIFO_SIZE;
const uint32_t * buf32 = packet->data;
@@ -517,7 +517,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_ACK) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_ACK;
LOG_PRINTF("ACK");
- if (eptyp == USBH_EPTYP_CONTROL) {
+ if (eptyp == USBH_ENDPOINT_TYPE_CONTROL) {
channels[channel].packet.toggle[0] = 1;
} else {
channels[channel].packet.toggle[0] ^= 1;
@@ -597,7 +597,7 @@ static enum USBH_POLL_STATUS poll_run(usbh_lld_stm32f4_driver_data_t *dev)
if (hcint & OTG_HCINT_NAK) {
REBASE_CH(OTG_HCINT, channel) = OTG_HCINT_NAK;
- if (eptyp == USBH_EPTYP_CONTROL) {
+ if (eptyp == USBH_ENDPOINT_TYPE_CONTROL) {
LOG_PRINTF("NAK");
}
@@ -972,7 +972,7 @@ static void channels_init(void *drvdata)
* Get speed of connected device
*
*/
-static uint8_t root_speed(void *drvdata)
+static enum USBH_SPEED root_speed(void *drvdata)
{
usbh_lld_stm32f4_driver_data_t *dev = drvdata;
(void)dev;