git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4277 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2012-06-16 06:22:39 +00:00
parent 2b1173e292
commit 166d6bf8b5
38 changed files with 348 additions and 218 deletions

View File

@ -200,5 +200,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -207,5 +207,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -207,5 +207,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -186,6 +186,30 @@ static uint32_t otg_ram_alloc(USBDriver *usbp, size_t size) {
"otg_fifo_alloc(), #1", "FIFO memory overflow");
return next;
}
/**
* @brief Prepares for a receive transaction on an OUT endpoint.
* @post The endpoint is ready for @p usbStartReceiveI().
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @param[in] n maximum number of bytes to copy
*
* @special
*/
static void otg_prepare_receive(USBDriver *usbp, usbep_t ep, size_t n) {
uint32_t pcnt;
USBOutEndpointState *osp = usbp->epc[ep]->out_state;
osp->rxsize = n;
osp->rxcnt = 0;
/* Transfer initialization.*/
pcnt = (n + usbp->epc[ep]->out_maxsize - 1) / usbp->epc[ep]->out_maxsize;
OTG->oe[ep].DOEPTSIZ = DOEPTSIZ_STUPCNT(3) | DOEPTSIZ_PKTCNT(pcnt) |
DOEPTSIZ_XFRSIZ(usbp->epc[ep]->out_maxsize);
}
/**
* @brief Prepares for a transmit transaction on an IN endpoint.
* @post The endpoint is ready for @p usbStartTransmitI().
@ -218,29 +242,6 @@ static void otg_prepare_transmit(USBDriver *usbp, usbep_t ep, size_t n) {
}
}
/**
* @brief Prepares for a receive transaction on an OUT endpoint.
* @post The endpoint is ready for @p usbStartReceiveI().
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @param[in] n maximum number of bytes to copy
*
* @special
*/
static void otg_prepare_receive(USBDriver *usbp, usbep_t ep, size_t n) {
uint32_t pcnt;
USBOutEndpointState *osp = usbp->epc[ep]->out_state;
osp->rxsize = n;
osp->rxcnt = 0;
/* Transfer initialization.*/
pcnt = (n + usbp->epc[ep]->out_maxsize - 1) / usbp->epc[ep]->out_maxsize;
OTG->oe[ep].DOEPTSIZ = DOEPTSIZ_STUPCNT(3) | DOEPTSIZ_PKTCNT(pcnt) |
DOEPTSIZ_XFRSIZ(usbp->epc[ep]->out_maxsize);
}
/**
* @brief Pushes a series of words into a FIFO.
*
@ -666,7 +667,7 @@ void usb_lld_init(void) {
/**
* @brief Configures and activates the USB peripheral.
* @note Starting the ORG cell can be a slow operation carried out with
* @note Starting the OTG cell can be a slow operation carried out with
* interrupts disabled, perform it before starting time-critical
* operations.
*
@ -901,11 +902,16 @@ void usb_lld_disable_endpoints(USBDriver *usbp) {
* @notapi
*/
usbepstatus_t usb_lld_get_status_out(USBDriver *usbp, usbep_t ep) {
uint32_t ctl;
(void)usbp;
(void)ep;
return 0;
ctl = OTG->oe[ep].DOEPCTL;
if (!(ctl & DOEPCTL_USBAEP))
return EP_STATUS_DISABLED;
if (ctl & DOEPCTL_STALL)
return EP_STATUS_STALLED;
return EP_STATUS_ACTIVE;
}
/**
@ -921,11 +927,16 @@ usbepstatus_t usb_lld_get_status_out(USBDriver *usbp, usbep_t ep) {
* @notapi
*/
usbepstatus_t usb_lld_get_status_in(USBDriver *usbp, usbep_t ep) {
uint32_t ctl;
(void)usbp;
(void)ep;
return 0;
ctl = OTG->ie[ep].DIEPCTL;
if (!(ctl & DIEPCTL_USBAEP))
return EP_STATUS_DISABLED;
if (ctl & DIEPCTL_STALL)
return EP_STATUS_STALLED;
return EP_STATUS_ACTIVE;
}
/**

View File

@ -64,7 +64,7 @@
* @brief OTG1 interrupt priority level setting.
*/
#if !defined(STM32_USB_OTG1_IRQ_PRIORITY) || defined(__DOXYGEN__)
#define STM32_USB_OTG1_IRQ_PRIORITY 6
#define STM32_USB_OTG1_IRQ_PRIORITY 14
#endif
/**

View File

@ -64,18 +64,24 @@ static union {
USBOutEndpointState out;
} ep0_state;
/**
* @brief Buffer for the EP0 setup packets.
*/
static uint8_t ep0setup_buffer[8];
/**
* @brief EP0 initialization structure.
*/
static const USBEndpointConfig ep0config = {
USB_EP_MODE_TYPE_CTRL | USB_EP_MODE_TRANSACTION,
USB_EP_MODE_TYPE_CTRL,
_usb_ep0setup,
_usb_ep0in,
_usb_ep0out,
0x40,
0x40,
&ep0_state.in,
&ep0_state.out
&ep0_state.out,
ep0setup_buffer
};
/*===========================================================================*/
@ -109,6 +115,117 @@ static uint32_t pm_alloc(USBDriver *usbp, size_t size) {
return next;
}
/**
* @brief Reads from a dedicated packet buffer.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @param[out] buf buffer where to copy the packet data
* @param[in] n maximum number of bytes to copy. This value must
* not exceed the maximum packet size for this endpoint.
* @return The received packet size regardless the specified
* @p n parameter.
* @retval 0 Zero size packet received.
*
* @notapi
*/
static size_t usb_read_packet_buffer(USBDriver *usbp, usbep_t ep,
uint8_t *buf, size_t n) {
uint32_t *pmap;
stm32_usb_descriptor_t *udp;
size_t count;
(void)usbp;
udp = USB_GET_DESCRIPTOR(ep);
pmap = USB_ADDR2PTR(udp->RXADDR0);
count = (size_t)udp->RXCOUNT0 & RXCOUNT_COUNT_MASK;
if (n > count)
n = count;
n = (n + 1) / 2;
while (n > 0) {
*(uint16_t *)buf = (uint16_t)*pmap++;
buf += 2;
n--;
}
return count;
}
/**
* @brief Writes to a dedicated packet buffer.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @param[in] buf buffer where to fetch the packet data
* @param[in] n maximum number of bytes to copy. This value must
* not exceed the maximum packet size for this endpoint.
*
* @notapi
*/
static void usb_write_packet_buffer(USBDriver *usbp, usbep_t ep,
const uint8_t *buf, size_t n) {
uint32_t *pmap;
stm32_usb_descriptor_t *udp;
(void)usbp;
udp = USB_GET_DESCRIPTOR(ep);
pmap = USB_ADDR2PTR(udp->TXADDR0);
udp->TXCOUNT0 = (uint16_t)n;
n = (n + 1) / 2;
while (n > 0) {
*pmap++ = *(uint16_t *)buf;
buf += 2;
n--;
}
}
/**
* @brief Prepares for a receive transaction on an OUT endpoint.
* @post The endpoint is ready for @p usbStartReceiveI().
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @param[in] n maximum number of bytes to copy
*
* @special
*/
static void usb_prepare_receive(USBDriver *usbp, usbep_t ep, size_t n) {
USBOutEndpointState *osp = usbp->epc[ep]->out_state;
osp->rxsize = n;
osp->rxcnt = 0;
/* Transfer initialization.*/
if (osp->rxsize == 0) /* Special case for zero sized packets.*/
osp->rxpkts = 1;
else
osp->rxpkts = (uint16_t)((n + usbp->epc[ep]->out_maxsize - 1) /
usbp->epc[ep]->out_maxsize);
}
/**
* @brief Prepares for a transmit transaction on an IN endpoint.
* @post The endpoint is ready for @p usbStartTransmitI().
* @note The transmit transaction size is equal to the data contained
* in the queue.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @param[in] n maximum number of bytes to copy
*
* @special
*/
static void usb_prepare_transmit(USBDriver *usbp, usbep_t ep, size_t n) {
USBInEndpointState *isp = usbp->epc[ep]->in_state;
isp->txsize = n;
isp->txcnt = 0;
/* Transfer initialization.*/
if (n > (size_t)usbp->epc[ep]->in_maxsize)
n = (size_t)usbp->epc[ep]->in_maxsize;
usb_write_packet_buffer(usbp, ep, isp->mode.linear.txbuf, n);
}
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
@ -189,29 +306,24 @@ CH_IRQ_HANDLER(Vector90) {
if (epr & EPR_CTR_TX) {
/* IN endpoint, transmission.*/
EPR_CLEAR_CTR_TX(ep);
if (epcp->ep_mode & USB_EP_MODE_PACKET) {
/* Packet mode, just invokes the callback.*/
_usb_isr_invoke_in_cb(usbp, ep);
n = (size_t)USB_GET_DESCRIPTOR(ep)->TXCOUNT0;
epcp->in_state->mode.linear.txbuf += n;
epcp->in_state->txcnt += n;
epcp->in_state->txsize -= n;
if (epcp->in_state->txsize > 0) {
/* Transfer not completed, there are more packets to send.*/
if (epcp->in_state->txsize > epcp->in_maxsize)
n = epcp->in_maxsize;
else
n = epcp->in_state->txsize;
usb_write_packet_buffer(usbp, ep,
epcp->in_state->mode.linear.txbuf, n);
usb_lld_start_in(usbp, ep);
}
else {
/* Transaction mode.*/
n = (size_t)USB_GET_DESCRIPTOR(ep)->TXCOUNT0;
epcp->in_state->txbuf += n;
epcp->in_state->txcnt += n;
epcp->in_state->txsize -= n;
if (epcp->in_state->txsize > 0) {
/* Transfer not completed, there are more packets to send.*/
if (epcp->in_state->txsize > epcp->in_maxsize)
n = epcp->in_maxsize;
else
n = epcp->in_state->txsize;
usb_lld_write_packet_buffer(usbp, ep, epcp->in_state->txbuf, n);
usb_lld_start_in(usbp, ep);
}
else {
/* Transfer completed, invokes the callback.*/
_usb_isr_invoke_in_cb(usbp, ep);
}
/* Transfer completed, invokes the callback.*/
_usb_isr_invoke_in_cb(usbp, ep);
}
}
if (epr & EPR_CTR_RX) {
@ -222,20 +334,15 @@ CH_IRQ_HANDLER(Vector90) {
specific callback.*/
_usb_isr_invoke_setup_cb(usbp, ep);
}
else if (epcp->ep_mode & USB_EP_MODE_PACKET) {
/* Packet mode, just invokes the callback.*/
_usb_isr_invoke_out_cb(usbp, ep);
}
else {
/* Transaction mode.*/
n = usb_lld_read_packet_buffer(usbp, ep,
epcp->out_state->rxbuf,
n = usb_read_packet_buffer(usbp, ep,
epcp->out_state->mode.linear.rxbuf,
epcp->out_state->rxsize);
usb_lld_start_out(usbp, ep);
epcp->out_state->rxbuf += n;
epcp->out_state->rxcnt += n;
epcp->out_state->rxsize -= n;
epcp->out_state->rxpkts -= 1;
epcp->out_state->mode.linear.rxbuf += n;
epcp->out_state->rxcnt += n;
epcp->out_state->rxsize -= n;
epcp->out_state->rxpkts -= 1;
if (epcp->out_state->rxpkts > 0) {
/* Transfer not completed, there are more packets to receive.*/
EPR_SET_STAT_RX(ep, EPR_STAT_RX_VALID);
@ -393,20 +500,13 @@ void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) {
epr = EPR_EP_TYPE_CONTROL;
}
/* IN endpoint settings, always in NAK mode initially.*/
/* IN endpoint initially in NAK mode.*/
if (epcp->in_cb != NULL)
epr |= EPR_STAT_TX_NAK;
/* OUT endpoint settings. If the endpoint is in packet mode then it must
start ready to accept data else it must start in NAK mode.*/
if (epcp->out_cb != NULL) {
if (epcp->ep_mode & USB_EP_MODE_PACKET) {
usbp->receiving |= (1 << ep);
epr |= EPR_STAT_RX_VALID;
}
else
epr |= EPR_STAT_RX_NAK;
}
/* OUT endpoint initially in NAK mode.*/
if (epcp->out_cb != NULL)
epr |= EPR_STAT_RX_NAK;
/* EPxR register setup.*/
EPR_SET(ep, epr | ep);
@ -523,75 +623,6 @@ void usb_lld_read_setup(USBDriver *usbp, usbep_t ep, uint8_t *buf) {
}
}
/**
* @brief Reads from a dedicated packet buffer.
* @pre In order to use this function he endpoint must have been
* initialized in packet mode.
* @note This function can be invoked both in thread and IRQ context.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @param[out] buf buffer where to copy the packet data
* @param[in] n maximum number of bytes to copy. This value must
* not exceed the maximum packet size for this endpoint.
* @return The received packet size regardless the specified
* @p n parameter.
* @retval 0 Zero size packet received.
*
* @notapi
*/
size_t usb_lld_read_packet_buffer(USBDriver *usbp, usbep_t ep,
uint8_t *buf, size_t n) {
uint32_t *pmap;
stm32_usb_descriptor_t *udp;
size_t count;
(void)usbp;
udp = USB_GET_DESCRIPTOR(ep);
pmap = USB_ADDR2PTR(udp->RXADDR0);
count = (size_t)udp->RXCOUNT0 & RXCOUNT_COUNT_MASK;
if (n > count)
n = count;
n = (n + 1) / 2;
while (n > 0) {
*(uint16_t *)buf = (uint16_t)*pmap++;
buf += 2;
n--;
}
return count;
}
/**
* @brief Writes to a dedicated packet buffer.
* @pre In order to use this function he endpoint must have been
* initialized in packet mode.
* @note This function can be invoked both in thread and IRQ context.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @param[in] buf buffer where to fetch the packet data
* @param[in] n maximum number of bytes to copy. This value must
* not exceed the maximum packet size for this endpoint.
*
* @notapi
*/
void usb_lld_write_packet_buffer(USBDriver *usbp, usbep_t ep,
const uint8_t *buf, size_t n) {
uint32_t *pmap;
stm32_usb_descriptor_t *udp;
(void)usbp;
udp = USB_GET_DESCRIPTOR(ep);
pmap = USB_ADDR2PTR(udp->TXADDR0);
udp->TXCOUNT0 = (uint16_t)n;
n = (n + 1) / 2;
while (n > 0) {
*pmap++ = *(uint16_t *)buf;
buf += 2;
n--;
}
}
/**
* @brief Prepares for a receive operation.
*
@ -606,14 +637,9 @@ void usb_lld_prepare_receive(USBDriver *usbp, usbep_t ep,
uint8_t *buf, size_t n) {
USBOutEndpointState *osp = usbp->epc[ep]->out_state;
osp->rxbuf = buf;
osp->rxsize = n;
osp->rxcnt = 0;
if (osp->rxsize == 0) /* Special case for zero sized packets.*/
osp->rxpkts = 1;
else
osp->rxpkts = (uint16_t)((n + usbp->epc[ep]->out_maxsize - 1) /
usbp->epc[ep]->out_maxsize);
osp->rxqueued = FALSE;
osp->mode.linear.rxbuf = buf;
usb_prepare_receive(usbp, ep, n);
}
/**
@ -630,12 +656,55 @@ void usb_lld_prepare_transmit(USBDriver *usbp, usbep_t ep,
const uint8_t *buf, size_t n) {
USBInEndpointState *isp = usbp->epc[ep]->in_state;
isp->txbuf = buf;
isp->txsize = n;
isp->txcnt = 0;
if (n > (size_t)usbp->epc[ep]->in_maxsize)
n = (size_t)usbp->epc[ep]->in_maxsize;
usb_lld_write_packet_buffer(usbp, ep, buf, n);
isp->txqueued = FALSE;
isp->mode.linear.txbuf = buf;
usb_prepare_transmit(usbp, ep, n);
}
/**
* @brief Prepares for a receive transaction on an OUT endpoint.
* @post The endpoint is ready for @p usbStartReceiveI().
* @note The receive transaction size is equal to the space in the queue
* rounded to the lower multiple of a packet size. Make sure there
* is room for at least one packet in the queue before starting
* the receive operation.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @param[in] iq input queue to be filled with incoming data
* @param[in] n maximum number of bytes to copy
*
* @special
*/
void usb_lld_prepare_queued_receive(USBDriver *usbp, usbep_t ep,
InputQueue *iq, size_t n) {
USBOutEndpointState *osp = usbp->epc[ep]->out_state;
osp->rxqueued = TRUE;
osp->mode.queue.rxqueue = iq;
usb_prepare_receive(usbp, ep, n);
}
/**
* @brief Prepares for a transmit transaction on an IN endpoint.
* @post The endpoint is ready for @p usbStartTransmitI().
* @note The transmit transaction size is equal to the data contained
* in the queue.
*
* @param[in] usbp pointer to the @p USBDriver object
* @param[in] ep endpoint number
* @param[in] oq output queue to be fetched for outgoing data
* @param[in] n maximum number of bytes to copy
*
* @special
*/
void usb_lld_prepare_queued_transmit(USBDriver *usbp, usbep_t ep,
OutputQueue *oq, size_t n) {
USBInEndpointState *isp = usbp->epc[ep]->in_state;
isp->txqueued = TRUE;
isp->mode.queue.txqueue = oq;
usb_prepare_transmit(usbp, ep, n);
}
/**

View File

@ -71,7 +71,7 @@
* @brief USB1 interrupt priority level setting.
*/
#if !defined(STM32_USB_USB1_HP_IRQ_PRIORITY) || defined(__DOXYGEN__)
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#endif
/**
@ -102,13 +102,13 @@
/*===========================================================================*/
/**
* @brief Type of an endpoint state structure.
* @brief Type of an IN endpoint state structure.
*/
typedef struct {
/**
* @brief Pointer to the transmission buffer.
* @brief Buffer mode, queue or linear.
*/
const uint8_t *txbuf;
bool_t txqueued;
/**
* @brief Requested transmit transfer size.
*/
@ -117,20 +117,31 @@ typedef struct {
* @brief Transmitted bytes so far.
*/
size_t txcnt;
union {
struct {
/**
* @brief Pointer to the transmission linear buffer.
*/
const uint8_t *txbuf;
} linear;
struct {
/**
* @brief Pointer to the output queue.
*/
OutputQueue *txqueue;
} queue;
/* End of the mandatory fields.*/
} mode;
} USBInEndpointState;
/**
* @brief Type of an endpoint state structure.
* @brief Type of an OUT endpoint state structure.
*/
typedef struct {
/**
* @brief Number of packets to receive.
* @brief Buffer mode, queue or linear.
*/
uint16_t rxpkts;
/**
* @brief Pointer to the receive buffer.
*/
uint8_t *rxbuf;
bool_t rxqueued;
/**
* @brief Requested receive transfer size.
*/
@ -139,6 +150,25 @@ typedef struct {
* @brief Received bytes so far.
*/
size_t rxcnt;
union {
struct {
/**
* @brief Pointer to the receive linear buffer.
*/
uint8_t *rxbuf;
} linear;
struct {
/**
* @brief Pointer to the input queue.
*/
InputQueue *rxqueue;
} queue;
} mode;
/* End of the mandatory fields.*/
/**
* @brief Number of packets to receive.
*/
uint16_t rxpkts;
} USBOutEndpointState;
/**
@ -187,19 +217,21 @@ typedef struct {
uint16_t out_maxsize;
/**
* @brief @p USBEndpointState associated to the IN endpoint.
* @details This structure maintains the state of the IN endpoint when
* the endpoint is not in packet mode. Endpoints configured in
* packet mode must set this field to @p NULL.
* @details This structure maintains the state of the IN endpoint.
*/
USBInEndpointState *in_state;
/**
* @brief @p USBEndpointState associated to the OUT endpoint.
* @details This structure maintains the state of the OUT endpoint when
* the endpoint is not in packet mode. Endpoints configured in
* packet mode must set this field to @p NULL.
* @details This structure maintains the state of the OUT endpoint.
*/
USBOutEndpointState *out_state;
/* End of the mandatory fields.*/
/**
* @brief Pointer to a buffer for setup packets.
* @details Setup packets require a dedicated 8-bytes buffer, set this
* field to @p NULL for non-control endpoints.
*/
uint8_t *setup_buf;
} USBEndpointConfig;
/**
@ -375,14 +407,14 @@ extern "C" {
usbepstatus_t usb_lld_get_status_in(USBDriver *usbp, usbep_t ep);
usbepstatus_t usb_lld_get_status_out(USBDriver *usbp, usbep_t ep);
void usb_lld_read_setup(USBDriver *usbp, usbep_t ep, uint8_t *buf);
size_t usb_lld_read_packet_buffer(USBDriver *usbp, usbep_t ep,
uint8_t *buf, size_t n);
void usb_lld_write_packet_buffer(USBDriver *usbp, usbep_t ep,
const uint8_t *buf, size_t n);
void usb_lld_prepare_receive(USBDriver *usbp, usbep_t ep,
uint8_t *buf, size_t n);
void usb_lld_prepare_transmit(USBDriver *usbp, usbep_t ep,
const uint8_t *buf, size_t n);
void usb_lld_prepare_queued_receive(USBDriver *usbp, usbep_t ep,
InputQueue *iq, size_t n);
void usb_lld_prepare_queued_transmit(USBDriver *usbp, usbep_t ep,
OutputQueue *oq, size_t n);
void usb_lld_start_out(USBDriver *usbp, usbep_t ep);
void usb_lld_start_in(USBDriver *usbp, usbep_t ep);
void usb_lld_stall_out(USBDriver *usbp, usbep_t ep);

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -207,5 +207,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -225,45 +225,63 @@ static const USBDescriptor *get_descriptor(USBDriver *usbp,
return NULL;
}
/**
* @brief IN EP1 state.
*/
static USBInEndpointState ep1instate;
/**
* @brief EP1 initialization structure (IN only).
*/
static const USBEndpointConfig ep1config = {
USB_EP_MODE_TYPE_BULK | USB_EP_MODE_PACKET,
USB_EP_MODE_TYPE_BULK,
NULL,
sduDataTransmitted,
NULL,
0x0040,
0x0000,
&ep1instate,
NULL,
NULL
};
/**
* @brief OUT EP2 state.
*/
USBOutEndpointState ep2outstate;
/**
* @brief EP2 initialization structure (IN only).
*/
static const USBEndpointConfig ep2config = {
USB_EP_MODE_TYPE_INTR | USB_EP_MODE_PACKET,
USB_EP_MODE_TYPE_INTR,
NULL,
sduInterruptTransmitted,
NULL,
0x0010,
0x0000,
NULL,
&ep2outstate,
NULL
};
/**
* @brief OUT EP3 state.
*/
USBOutEndpointState ep3outstate;
/**
* @brief EP3 initialization structure (OUT only).
*/
static const USBEndpointConfig ep3config = {
USB_EP_MODE_TYPE_BULK | USB_EP_MODE_PACKET,
USB_EP_MODE_TYPE_BULK,
NULL,
NULL,
sduDataReceived,
0x0000,
0x0040,
NULL,
&ep3outstate,
NULL
};

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -202,5 +202,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -246,9 +246,9 @@ static const USBEndpointConfig ep1config = {
};
/**
* @brief OUT EP1 state.
* @brief OUT EP2 state.
*/
USBOutEndpointState ep1outstate;
USBOutEndpointState ep2outstate;
/**
* @brief EP2 initialization structure (IN only).
@ -261,14 +261,14 @@ static const USBEndpointConfig ep2config = {
0x0010,
0x0000,
NULL,
&ep1outstate,
&ep2outstate,
NULL
};
/**
* @brief OUT EP2 state.
*/
USBOutEndpointState ep2outstate;
USBOutEndpointState ep3outstate;
/**
* @brief EP3 initialization structure (OUT only).
@ -281,7 +281,7 @@ static const USBEndpointConfig ep3config = {
0x0000,
0x0040,
NULL,
&ep2outstate,
&ep3outstate,
NULL
};

View File

@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14

View File

@ -185,5 +185,5 @@
*/
#define STM32_USB_USE_USB1 TRUE
#define STM32_USB_LOW_POWER_ON_SUSPEND FALSE
#define STM32_USB_USB1_HP_IRQ_PRIORITY 6
#define STM32_USB_USB1_HP_IRQ_PRIORITY 13
#define STM32_USB_USB1_LP_IRQ_PRIORITY 14