aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-02-15 09:16:17 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-02-15 09:16:17 +0000
commit35ff7323526f5225d1a00c7812291e9fcdbfafac (patch)
treed2fd2eb98544de7e6e2eafae015e8afe33c721b6 /os/hal/platforms
parent20a4b38126be234c5f946df9254c7d64502ff855 (diff)
downloadChibiOS-35ff7323526f5225d1a00c7812291e9fcdbfafac.tar.gz
ChibiOS-35ff7323526f5225d1a00c7812291e9fcdbfafac.tar.bz2
ChibiOS-35ff7323526f5225d1a00c7812291e9fcdbfafac.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2740 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms')
-rw-r--r--os/hal/platforms/STM32/stm32_usb.h7
-rw-r--r--os/hal/platforms/STM32/usb_lld.c14
2 files changed, 17 insertions, 4 deletions
diff --git a/os/hal/platforms/STM32/stm32_usb.h b/os/hal/platforms/STM32/stm32_usb.h
index 8c04ba85f..8bb0d8b95 100644
--- a/os/hal/platforms/STM32/stm32_usb.h
+++ b/os/hal/platforms/STM32/stm32_usb.h
@@ -108,11 +108,16 @@ typedef struct {
#define STM32_USB ((stm32_usb_t *)STM32_USB_BASE)
/**
- * @brief Pointer to the USB RAM.
+ * @brief Pointer to the USB RAM.
*/
#define STM32_USBRAM ((uint32_t *)STM32_USBRAM_BASE)
/**
+ * @brief Size of the dedicated packet memory.
+ */
+#define USB_PMA_SIZE 512
+
+/**
* @brief Mask of all the toggling bits in the EPR register.
*/
#define EPR_TOGGLE_MASK (EPR_STAT_TX_MASK | EPR_DTOG_TX | \
diff --git a/os/hal/platforms/STM32/usb_lld.c b/os/hal/platforms/STM32/usb_lld.c
index 0a7bc9315..f3bfa15f4 100644
--- a/os/hal/platforms/STM32/usb_lld.c
+++ b/os/hal/platforms/STM32/usb_lld.c
@@ -87,6 +87,9 @@ static const USBEndpointConfig ep0config = {
* @param[in] usbp pointer to the @p USBDriver object
*/
static void pm_reset(USBDriver *usbp) {
+
+ /* The first 64 bytes are reserved for the descriptors table. The effective
+ available RAM for endpoint buffers is just 448 bytes.*/
usbp->pmnext = 64;
}
@@ -97,8 +100,11 @@ static void pm_reset(USBDriver *usbp) {
* @param[in] size size of the packet buffer to allocate
*/
static uint32_t pm_alloc(USBDriver *usbp, size_t size) {
- uint32_t next = usbp->pmnext;
+ uint32_t next;
+
+ next = usbp->pmnext;
usbp->pmnext += size;
+ chDbgAssert(usbp->pmnext > USB_PMA_SIZE, "pm_alloc(), #1", "PMA overflow");
return next;
}
@@ -463,12 +469,14 @@ void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) {
void usb_lld_disable_endpoints(USBDriver *usbp) {
unsigned i;
- (void)usbp;
+ /* Resets the packet memory allocator.*/
+ pm_reset(usbp);
+
+ /* Disabling all endpoints.*/
for (i = 1; i <= USB_ENDOPOINTS_NUMBER; i++) {
EPR_TOGGLE(i, 0);
EPR_SET(i, 0);
}
-
}
/**