Some renaming work for clearness.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10449 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
62f078360f
commit
9662d58fb6
|
@ -285,13 +285,13 @@ typedef enum {
|
||||||
* @brief Type of an endpoint zero state machine states.
|
* @brief Type of an endpoint zero state machine states.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
USB_EP0_WAITING_SETUP, /**< Waiting for SETUP data. */
|
USB_EP0_STP_WAITING = 0, /**< Waiting for SETUP data. */
|
||||||
USB_EP0_TX, /**< Transmitting. */
|
USB_EP0_IN_TX = 1, /**< Transmitting. */
|
||||||
USB_EP0_WAITING_TX0, /**< Waiting transmit 0. */
|
USB_EP0_IN_WAITING_TX0 = 2, /**< Waiting transmit 0. */
|
||||||
USB_EP0_WAITING_STS, /**< Waiting status. */
|
USB_EP0_IN_SENDING_STS = 3, /**< Sending status. */
|
||||||
USB_EP0_RX, /**< Receiving. */
|
USB_EP0_OUT_WAITING_STS = 4, /**< Waiting status. */
|
||||||
USB_EP0_SENDING_STS, /**< Sending status. */
|
USB_EP0_OUT_RX = 5, /**< Receiving. */
|
||||||
USB_EP0_ERROR /**< Error, EP0 stalled. */
|
USB_EP0_ERROR = 6 /**< Error, EP0 stalled. */
|
||||||
} usbep0state_t;
|
} usbep0state_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -671,7 +671,7 @@ void _usb_reset(USBDriver *usbp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EP0 state machine initialization.*/
|
/* EP0 state machine initialization.*/
|
||||||
usbp->ep0state = USB_EP0_WAITING_SETUP;
|
usbp->ep0state = USB_EP0_STP_WAITING;
|
||||||
|
|
||||||
/* Low level reset.*/
|
/* Low level reset.*/
|
||||||
usb_lld_reset(usbp);
|
usb_lld_reset(usbp);
|
||||||
|
@ -751,7 +751,8 @@ void _usb_wakeup(USBDriver *usbp) {
|
||||||
void _usb_ep0setup(USBDriver *usbp, usbep_t ep) {
|
void _usb_ep0setup(USBDriver *usbp, usbep_t ep) {
|
||||||
size_t max;
|
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);
|
usbReadSetup(usbp, ep, usbp->setup);
|
||||||
|
|
||||||
/* First verify if the application has an handler installed for this
|
/* 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.*/
|
/* IN phase.*/
|
||||||
if (usbp->ep0n != 0U) {
|
if (usbp->ep0n != 0U) {
|
||||||
/* Starts the transmit phase.*/
|
/* Starts the transmit phase.*/
|
||||||
usbp->ep0state = USB_EP0_TX;
|
usbp->ep0state = USB_EP0_IN_TX;
|
||||||
osalSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
usbStartTransmitI(usbp, 0, usbp->ep0next, usbp->ep0n);
|
usbStartTransmitI(usbp, 0, usbp->ep0next, usbp->ep0n);
|
||||||
osalSysUnlockFromISR();
|
osalSysUnlockFromISR();
|
||||||
|
@ -802,7 +803,7 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) {
|
||||||
else {
|
else {
|
||||||
/* No transmission phase, directly receiving the zero sized status
|
/* No transmission phase, directly receiving the zero sized status
|
||||||
packet.*/
|
packet.*/
|
||||||
usbp->ep0state = USB_EP0_WAITING_STS;
|
usbp->ep0state = USB_EP0_OUT_WAITING_STS;
|
||||||
#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
|
#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
|
||||||
osalSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
usbStartReceiveI(usbp, 0, NULL, 0);
|
usbStartReceiveI(usbp, 0, NULL, 0);
|
||||||
|
@ -816,7 +817,7 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) {
|
||||||
/* OUT phase.*/
|
/* OUT phase.*/
|
||||||
if (usbp->ep0n != 0U) {
|
if (usbp->ep0n != 0U) {
|
||||||
/* Starts the receive phase.*/
|
/* Starts the receive phase.*/
|
||||||
usbp->ep0state = USB_EP0_RX;
|
usbp->ep0state = USB_EP0_OUT_RX;
|
||||||
osalSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
usbStartReceiveI(usbp, 0, usbp->ep0next, usbp->ep0n);
|
usbStartReceiveI(usbp, 0, usbp->ep0next, usbp->ep0n);
|
||||||
osalSysUnlockFromISR();
|
osalSysUnlockFromISR();
|
||||||
|
@ -824,7 +825,7 @@ void _usb_ep0setup(USBDriver *usbp, usbep_t ep) {
|
||||||
else {
|
else {
|
||||||
/* No receive phase, directly sending the zero sized status
|
/* No receive phase, directly sending the zero sized status
|
||||||
packet.*/
|
packet.*/
|
||||||
usbp->ep0state = USB_EP0_SENDING_STS;
|
usbp->ep0state = USB_EP0_IN_SENDING_STS;
|
||||||
#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
|
#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
|
||||||
osalSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
usbStartTransmitI(usbp, 0, NULL, 0);
|
usbStartTransmitI(usbp, 0, NULL, 0);
|
||||||
|
@ -851,7 +852,7 @@ void _usb_ep0in(USBDriver *usbp, usbep_t ep) {
|
||||||
|
|
||||||
(void)ep;
|
(void)ep;
|
||||||
switch (usbp->ep0state) {
|
switch (usbp->ep0state) {
|
||||||
case USB_EP0_TX:
|
case USB_EP0_IN_TX:
|
||||||
max = (size_t)get_hword(&usbp->setup[6]);
|
max = (size_t)get_hword(&usbp->setup[6]);
|
||||||
/* If the transmitted size is less than the requested size and it is a
|
/* 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
|
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();
|
osalSysLockFromISR();
|
||||||
usbStartTransmitI(usbp, 0, NULL, 0);
|
usbStartTransmitI(usbp, 0, NULL, 0);
|
||||||
osalSysUnlockFromISR();
|
osalSysUnlockFromISR();
|
||||||
usbp->ep0state = USB_EP0_WAITING_TX0;
|
usbp->ep0state = USB_EP0_IN_WAITING_TX0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Falls into, it is intentional.*/
|
/* 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.*/
|
/* 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)
|
#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
|
||||||
osalSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
usbStartReceiveI(usbp, 0, NULL, 0);
|
usbStartReceiveI(usbp, 0, NULL, 0);
|
||||||
|
@ -876,16 +877,16 @@ void _usb_ep0in(USBDriver *usbp, usbep_t ep) {
|
||||||
usb_lld_end_setup(usbp, ep);
|
usb_lld_end_setup(usbp, ep);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
case USB_EP0_SENDING_STS:
|
case USB_EP0_IN_SENDING_STS:
|
||||||
/* Status packet sent, invoking the callback if defined.*/
|
/* Status packet sent, invoking the callback if defined.*/
|
||||||
if (usbp->ep0endcb != NULL) {
|
if (usbp->ep0endcb != NULL) {
|
||||||
usbp->ep0endcb(usbp);
|
usbp->ep0endcb(usbp);
|
||||||
}
|
}
|
||||||
usbp->ep0state = USB_EP0_WAITING_SETUP;
|
usbp->ep0state = USB_EP0_STP_WAITING;
|
||||||
return;
|
return;
|
||||||
case USB_EP0_WAITING_SETUP:
|
case USB_EP0_STP_WAITING:
|
||||||
case USB_EP0_WAITING_STS:
|
case USB_EP0_OUT_WAITING_STS:
|
||||||
case USB_EP0_RX:
|
case USB_EP0_OUT_RX:
|
||||||
/* All the above are invalid states in the IN phase.*/
|
/* All the above are invalid states in the IN phase.*/
|
||||||
osalDbgAssert(false, "EP0 state machine error");
|
osalDbgAssert(false, "EP0 state machine error");
|
||||||
/* Falling through is intentional.*/
|
/* Falling through is intentional.*/
|
||||||
|
@ -917,9 +918,9 @@ void _usb_ep0out(USBDriver *usbp, usbep_t ep) {
|
||||||
|
|
||||||
(void)ep;
|
(void)ep;
|
||||||
switch (usbp->ep0state) {
|
switch (usbp->ep0state) {
|
||||||
case USB_EP0_RX:
|
case USB_EP0_OUT_RX:
|
||||||
/* Receive phase over, sending the zero sized status packet.*/
|
/* 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)
|
#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
|
||||||
osalSysLockFromISR();
|
osalSysLockFromISR();
|
||||||
usbStartTransmitI(usbp, 0, NULL, 0);
|
usbStartTransmitI(usbp, 0, NULL, 0);
|
||||||
|
@ -928,7 +929,7 @@ void _usb_ep0out(USBDriver *usbp, usbep_t ep) {
|
||||||
usb_lld_end_setup(usbp, ep);
|
usb_lld_end_setup(usbp, ep);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
case USB_EP0_WAITING_STS:
|
case USB_EP0_OUT_WAITING_STS:
|
||||||
/* Status packet received, it must be zero sized, invoking the callback
|
/* Status packet received, it must be zero sized, invoking the callback
|
||||||
if defined.*/
|
if defined.*/
|
||||||
#if (USB_EP0_STATUS_STAGE == USB_EP0_STATUS_STAGE_SW)
|
#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) {
|
if (usbp->ep0endcb != NULL) {
|
||||||
usbp->ep0endcb(usbp);
|
usbp->ep0endcb(usbp);
|
||||||
}
|
}
|
||||||
usbp->ep0state = USB_EP0_WAITING_SETUP;
|
usbp->ep0state = USB_EP0_STP_WAITING;
|
||||||
return;
|
return;
|
||||||
case USB_EP0_WAITING_SETUP:
|
case USB_EP0_STP_WAITING:
|
||||||
case USB_EP0_TX:
|
case USB_EP0_IN_TX:
|
||||||
case USB_EP0_WAITING_TX0:
|
case USB_EP0_IN_WAITING_TX0:
|
||||||
case USB_EP0_SENDING_STS:
|
case USB_EP0_IN_SENDING_STS:
|
||||||
/* All the above are invalid states in the IN phase.*/
|
/* All the above are invalid states in the IN phase.*/
|
||||||
osalDbgAssert(false, "EP0 state machine error");
|
osalDbgAssert(false, "EP0 state machine error");
|
||||||
/* Falling through is intentional.*/
|
/* Falling through is intentional.*/
|
||||||
|
|
Loading…
Reference in New Issue