From 9662d58fb67b5c11f68f79d091c83280b7903dd3 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Fri, 18 Aug 2017 13:35:28 +0000 Subject: Some renaming work for clearness. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10449 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/hal_usb.h | 14 +++++++------- os/hal/src/hal_usb.c | 47 ++++++++++++++++++++++++----------------------- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/os/hal/include/hal_usb.h b/os/hal/include/hal_usb.h index 71fa42498..63fa9e25d 100644 --- a/os/hal/include/hal_usb.h +++ b/os/hal/include/hal_usb.h @@ -285,13 +285,13 @@ typedef enum { * @brief Type of an endpoint zero state machine states. */ typedef enum { - USB_EP0_WAITING_SETUP, /**< Waiting for SETUP data. */ - USB_EP0_TX, /**< Transmitting. */ - USB_EP0_WAITING_TX0, /**< Waiting transmit 0. */ - USB_EP0_WAITING_STS, /**< Waiting status. */ - USB_EP0_RX, /**< Receiving. */ - USB_EP0_SENDING_STS, /**< Sending status. */ - USB_EP0_ERROR /**< Error, EP0 stalled. */ + USB_EP0_STP_WAITING = 0, /**< Waiting for SETUP data. */ + USB_EP0_IN_TX = 1, /**< Transmitting. */ + USB_EP0_IN_WAITING_TX0 = 2, /**< Waiting transmit 0. */ + USB_EP0_IN_SENDING_STS = 3, /**< Sending status. */ + USB_EP0_OUT_WAITING_STS = 4, /**< Waiting status. */ + USB_EP0_OUT_RX = 5, /**< Receiving. */ + USB_EP0_ERROR = 6 /**< Error, EP0 stalled. */ } usbep0state_t; /** diff --git a/os/hal/src/hal_usb.c b/os/hal/src/hal_usb.c index 813c2a597..e58055714 100644 --- a/os/hal/src/hal_usb.c +++ b/os/hal/src/hal_usb.c @@ -671,7 +671,7 @@ void _usb_reset(USBDriver *usbp) { } /* EP0 state machine initialization.*/ - usbp->ep0state = USB_EP0_WAITING_SETUP; + usbp->ep0state = USB_EP0_STP_WAITING; /* Low level reset.*/ usb_lld_reset(usbp); @@ -751,7 +751,8 @@ void _usb_wakeup(USBDriver *usbp) { void _usb_ep0setup(USBDriver *usbp, usbep_t ep) { size_t max; - usbp->ep0state = USB_EP0_WAITING_SETUP; + osalDbgAssert(usbp->ep0state == USB_EP0_STP_WAITING, "not in setup state"); + usbReadSetup(usbp, ep, usbp->setup); /* First verify if the application has an handler installed for this @@ -794,7 +795,7 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) { /* IN phase.*/ if (usbp->ep0n != 0U) { /* Starts the transmit phase.*/ - usbp->ep0state = USB_EP0_TX; + usbp->ep0state = USB_EP0_IN_TX; osalSysLockFromISR(); usbStartTransmitI(usbp, 0, usbp->ep0next, usbp->ep0n); osalSysUnlockFromISR(); @@ -802,7 +803,7 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) { else { /* No transmission phase, directly receiving the zero sized status packet.*/ - usbp->ep0state = USB_EP0_WAITING_STS; + usbp->ep0state = USB_EP0_OUT_WAITING_STS; #if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW) osalSysLockFromISR(); usbStartReceiveI(usbp, 0, NULL, 0); @@ -816,7 +817,7 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) { /* OUT phase.*/ if (usbp->ep0n != 0U) { /* Starts the receive phase.*/ - usbp->ep0state = USB_EP0_RX; + usbp->ep0state = USB_EP0_OUT_RX; osalSysLockFromISR(); usbStartReceiveI(usbp, 0, usbp->ep0next, usbp->ep0n); osalSysUnlockFromISR(); @@ -824,7 +825,7 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) { else { /* No receive phase, directly sending the zero sized status packet.*/ - usbp->ep0state = USB_EP0_SENDING_STS; + usbp->ep0state = USB_EP0_IN_SENDING_STS; #if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW) osalSysLockFromISR(); usbStartTransmitI(usbp, 0, NULL, 0); @@ -851,7 +852,7 @@ void _usb_ep0in(USBDriver *usbp, usbep_t ep) { (void)ep; switch (usbp->ep0state) { - case USB_EP0_TX: + case USB_EP0_IN_TX: max = (size_t)get_hword(&usbp->setup[6]); /* If the transmitted size is less than the requested size and it is a multiple of the maximum packet size then a zero size packet must be @@ -861,13 +862,13 @@ void _usb_ep0in(USBDriver *usbp, usbep_t ep) { osalSysLockFromISR(); usbStartTransmitI(usbp, 0, NULL, 0); osalSysUnlockFromISR(); - usbp->ep0state = USB_EP0_WAITING_TX0; + usbp->ep0state = USB_EP0_IN_WAITING_TX0; return; } /* Falls into, it is intentional.*/ - case USB_EP0_WAITING_TX0: + case USB_EP0_IN_WAITING_TX0: /* Transmit phase over, receiving the zero sized status packet.*/ - usbp->ep0state = USB_EP0_WAITING_STS; + usbp->ep0state = USB_EP0_OUT_WAITING_STS; #if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW) osalSysLockFromISR(); usbStartReceiveI(usbp, 0, NULL, 0); @@ -876,16 +877,16 @@ void _usb_ep0in(USBDriver *usbp, usbep_t ep) { usb_lld_end_setup(usbp, ep); #endif return; - case USB_EP0_SENDING_STS: + case USB_EP0_IN_SENDING_STS: /* Status packet sent, invoking the callback if defined.*/ if (usbp->ep0endcb != NULL) { usbp->ep0endcb(usbp); } - usbp->ep0state = USB_EP0_WAITING_SETUP; + usbp->ep0state = USB_EP0_STP_WAITING; return; - case USB_EP0_WAITING_SETUP: - case USB_EP0_WAITING_STS: - case USB_EP0_RX: + case USB_EP0_STP_WAITING: + case USB_EP0_OUT_WAITING_STS: + case USB_EP0_OUT_RX: /* All the above are invalid states in the IN phase.*/ osalDbgAssert(false, "EP0 state machine error"); /* Falling through is intentional.*/ @@ -917,9 +918,9 @@ void _usb_ep0out(USBDriver *usbp, usbep_t ep) { (void)ep; switch (usbp->ep0state) { - case USB_EP0_RX: + case USB_EP0_OUT_RX: /* Receive phase over, sending the zero sized status packet.*/ - usbp->ep0state = USB_EP0_SENDING_STS; + usbp->ep0state = USB_EP0_IN_SENDING_STS; #if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW) osalSysLockFromISR(); usbStartTransmitI(usbp, 0, NULL, 0); @@ -928,7 +929,7 @@ void _usb_ep0out(USBDriver *usbp, usbep_t ep) { usb_lld_end_setup(usbp, ep); #endif return; - case USB_EP0_WAITING_STS: + case USB_EP0_OUT_WAITING_STS: /* Status packet received, it must be zero sized, invoking the callback if defined.*/ #if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW) @@ -939,12 +940,12 @@ void _usb_ep0out(USBDriver *usbp, usbep_t ep) { if (usbp->ep0endcb != NULL) { usbp->ep0endcb(usbp); } - usbp->ep0state = USB_EP0_WAITING_SETUP; + usbp->ep0state = USB_EP0_STP_WAITING; return; - case USB_EP0_WAITING_SETUP: - case USB_EP0_TX: - case USB_EP0_WAITING_TX0: - case USB_EP0_SENDING_STS: + case USB_EP0_STP_WAITING: + case USB_EP0_IN_TX: + case USB_EP0_IN_WAITING_TX0: + case USB_EP0_IN_SENDING_STS: /* All the above are invalid states in the IN phase.*/ osalDbgAssert(false, "EP0 state machine error"); /* Falling through is intentional.*/ -- cgit v1.2.3