aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-06-03 08:12:54 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-06-03 08:12:54 +0000
commitb8d35693b4c7b88a746abb646dde8a7e09cf7bd4 (patch)
tree27020148b51dcaeb79908184b4141ae4424e516d /os/hal
parent36129fd993c904b3430fb28ced6d03262a83a681 (diff)
downloadChibiOS-b8d35693b4c7b88a746abb646dde8a7e09cf7bd4.tar.gz
ChibiOS-b8d35693b4c7b88a746abb646dde8a7e09cf7bd4.tar.bz2
ChibiOS-b8d35693b4c7b88a746abb646dde8a7e09cf7bd4.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4257 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/platforms/STM32/OTGv1/stm32_otg.h2
-rw-r--r--os/hal/platforms/STM32/OTGv1/usb_lld.c19
2 files changed, 14 insertions, 7 deletions
diff --git a/os/hal/platforms/STM32/OTGv1/stm32_otg.h b/os/hal/platforms/STM32/OTGv1/stm32_otg.h
index 083f868a5..4c83a62eb 100644
--- a/os/hal/platforms/STM32/OTGv1/stm32_otg.h
+++ b/os/hal/platforms/STM32/OTGv1/stm32_otg.h
@@ -849,6 +849,8 @@ typedef struct {
*/
#define DOEPTSIZ_RXDPID_MASK (3U<<29) /**< Received data PID mask. */
#define DOEPTSIZ_RXDPID(n) ((n)<<29) /**< Received data PID value. */
+#define DOEPTSIZ_STUPCNT_MASK (3U<<29) /**< SETUP packet count mask. */
+#define DOEPTSIZ_STUPCNT(n) ((n)<<29) /**< SETUP packet count value. */
#define DOEPTSIZ_PKTCNT_MASK (0x3FFU<<19)/**< Packet count mask. */
#define DOEPTSIZ_PKTCNT(n) ((n)<<19) /**< Packet count value. */
#define DOEPTSIZ_XFRSIZ_MASK (0x7FFFFU<<0)/**< Transfer size mask. */
diff --git a/os/hal/platforms/STM32/OTGv1/usb_lld.c b/os/hal/platforms/STM32/OTGv1/usb_lld.c
index 0059f69dc..327fe17d3 100644
--- a/os/hal/platforms/STM32/OTGv1/usb_lld.c
+++ b/os/hal/platforms/STM32/OTGv1/usb_lld.c
@@ -767,11 +767,15 @@ void usb_lld_write_packet_buffer(USBDriver *usbp, usbep_t ep,
*/
void usb_lld_prepare_receive(USBDriver *usbp, usbep_t ep,
uint8_t *buf, size_t n) {
+ uint32_t pcnt;
+ USBOutEndpointState *osp = usbp->epc[ep]->out_state;
- (void)usbp;
- (void)ep;
- (void)buf;
- (void)n;
+ osp->rxbuf = buf;
+ osp->rxsize = n;
+ osp->rxcnt = 0;
+ 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);
}
/**
@@ -786,6 +790,7 @@ void usb_lld_prepare_receive(USBDriver *usbp, usbep_t ep,
*/
void usb_lld_prepare_transmit(USBDriver *usbp, usbep_t ep,
const uint8_t *buf, size_t n) {
+ uint32_t pcnt;
USBInEndpointState *isp = usbp->epc[ep]->in_state;
isp->txbuf = buf;
@@ -798,8 +803,7 @@ void usb_lld_prepare_transmit(USBDriver *usbp, usbep_t ep,
}
else {
/* Transfer initialization.*/
- uint32_t pcnt = (n + usbp->epc[ep]->in_maxsize - 1) /
- usbp->epc[ep]->in_maxsize;
+ pcnt = (n + usbp->epc[ep]->in_maxsize - 1) / usbp->epc[ep]->in_maxsize;
OTG->ie[ep].DIEPTSIZ = DIEPTSIZ_PKTCNT(pcnt) |
DIEPTSIZ_XFRSIZ(usbp->epc[ep]->in_state->txsize);
}
@@ -816,7 +820,8 @@ void usb_lld_prepare_transmit(USBDriver *usbp, usbep_t ep,
void usb_lld_start_out(USBDriver *usbp, usbep_t ep) {
(void)usbp;
- (void)ep;
+
+ OTG->oe[ep].DOEPCTL |= DOEPCTL_CNAK;
}
/**