refactor: use enum instead of #define: USBH_ENDPOINT_TYPE and USBH_SPEED

Signed-off-by: Amir Hammad <amir.hammad@hotmail.com>
This commit is contained in:
Amir Hammad 2016-07-08 23:20:16 +02:00
parent 27fe98f2d6
commit e61ed66174
7 changed files with 33 additions and 30 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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];

View file

@ -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;

View file

@ -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;