git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2740 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
20a4b38126
commit
35ff732352
|
@ -108,10 +108,15 @@ typedef struct {
|
||||||
#define STM32_USB ((stm32_usb_t *)STM32_USB_BASE)
|
#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)
|
#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.
|
* @brief Mask of all the toggling bits in the EPR register.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -87,6 +87,9 @@ static const USBEndpointConfig ep0config = {
|
||||||
* @param[in] usbp pointer to the @p USBDriver object
|
* @param[in] usbp pointer to the @p USBDriver object
|
||||||
*/
|
*/
|
||||||
static void pm_reset(USBDriver *usbp) {
|
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;
|
usbp->pmnext = 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +100,11 @@ static void pm_reset(USBDriver *usbp) {
|
||||||
* @param[in] size size of the packet buffer to allocate
|
* @param[in] size size of the packet buffer to allocate
|
||||||
*/
|
*/
|
||||||
static uint32_t pm_alloc(USBDriver *usbp, size_t size) {
|
static uint32_t pm_alloc(USBDriver *usbp, size_t size) {
|
||||||
uint32_t next = usbp->pmnext;
|
uint32_t next;
|
||||||
|
|
||||||
|
next = usbp->pmnext;
|
||||||
usbp->pmnext += size;
|
usbp->pmnext += size;
|
||||||
|
chDbgAssert(usbp->pmnext > USB_PMA_SIZE, "pm_alloc(), #1", "PMA overflow");
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,12 +469,14 @@ void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) {
|
||||||
void usb_lld_disable_endpoints(USBDriver *usbp) {
|
void usb_lld_disable_endpoints(USBDriver *usbp) {
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
(void)usbp;
|
/* Resets the packet memory allocator.*/
|
||||||
|
pm_reset(usbp);
|
||||||
|
|
||||||
|
/* Disabling all endpoints.*/
|
||||||
for (i = 1; i <= USB_ENDOPOINTS_NUMBER; i++) {
|
for (i = 1; i <= USB_ENDOPOINTS_NUMBER; i++) {
|
||||||
EPR_TOGGLE(i, 0);
|
EPR_TOGGLE(i, 0);
|
||||||
EPR_SET(i, 0);
|
EPR_SET(i, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -335,6 +335,8 @@ void usbDisableEndpointsI(USBDriver *usbp) {
|
||||||
chDbgAssert(usbp->state == USB_SELECTED,
|
chDbgAssert(usbp->state == USB_SELECTED,
|
||||||
"usbDisableEndpointsI(), #1", "invalid state");
|
"usbDisableEndpointsI(), #1", "invalid state");
|
||||||
|
|
||||||
|
usbp->transmitting &= ~1;
|
||||||
|
usbp->receiving &= ~1;
|
||||||
for (i = 1; i <= USB_MAX_ENDPOINTS; i++)
|
for (i = 1; i <= USB_MAX_ENDPOINTS; i++)
|
||||||
usbp->epc[i] = NULL;
|
usbp->epc[i] = NULL;
|
||||||
|
|
||||||
|
@ -399,7 +401,7 @@ size_t usbWritePacketI(USBDriver *usbp, usbep_t ep,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Starts a receive operation on an OUT endpoint.
|
* @brief Starts a receive transaction on an OUT endpoint.
|
||||||
* @pre In order to use this function he endpoint must have been
|
* @pre In order to use this function he endpoint must have been
|
||||||
* initialized in transaction mode.
|
* initialized in transaction mode.
|
||||||
* @post The endpoint callback is invoked when the transfer has been
|
* @post The endpoint callback is invoked when the transfer has been
|
||||||
|
@ -410,8 +412,8 @@ size_t usbWritePacketI(USBDriver *usbp, usbep_t ep,
|
||||||
* @param[out] buf buffer where to copy the received data
|
* @param[out] buf buffer where to copy the received data
|
||||||
* @param[in] n maximum number of bytes to copy
|
* @param[in] n maximum number of bytes to copy
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval FALSE Operation complete.
|
* @retval FALSE Operation started successfully.
|
||||||
* @retval TRUE Endpoint busy receiving.
|
* @retval TRUE Endpoint busy, operation not started.
|
||||||
*
|
*
|
||||||
* @iclass
|
* @iclass
|
||||||
*/
|
*/
|
||||||
|
@ -427,7 +429,7 @@ bool_t usbStartReceiveI(USBDriver *usbp, usbep_t ep,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Starts a transmit operation on an IN endpoint.
|
* @brief Starts a transmit transaction on an IN endpoint.
|
||||||
* @pre In order to use this function he endpoint must have been
|
* @pre In order to use this function he endpoint must have been
|
||||||
* initialized in transaction mode.
|
* initialized in transaction mode.
|
||||||
* @post The endpoint callback is invoked when the transfer has been
|
* @post The endpoint callback is invoked when the transfer has been
|
||||||
|
@ -438,8 +440,8 @@ bool_t usbStartReceiveI(USBDriver *usbp, usbep_t ep,
|
||||||
* @param[in] buf buffer where to fetch the data to be transmitted
|
* @param[in] buf buffer where to fetch the data to be transmitted
|
||||||
* @param[in] n maximum number of bytes to copy
|
* @param[in] n maximum number of bytes to copy
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval FALSE Operation complete.
|
* @retval FALSE Operation started successfully.
|
||||||
* @retval TRUE Endpoint busy transmitting.
|
* @retval TRUE Endpoint busy, operation not started.
|
||||||
*
|
*
|
||||||
* @iclass
|
* @iclass
|
||||||
*/
|
*/
|
||||||
|
@ -461,7 +463,7 @@ bool_t usbStartTransmitI(USBDriver *usbp, usbep_t ep,
|
||||||
* @param[in] ep endpoint number
|
* @param[in] ep endpoint number
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval FALSE Endpoint stalled.
|
* @retval FALSE Endpoint stalled.
|
||||||
* @retval TRUE The endpoint was within a transaction, not stalled.
|
* @retval TRUE Endpoint busy, not stalled.
|
||||||
*
|
*
|
||||||
* @iclass
|
* @iclass
|
||||||
*/
|
*/
|
||||||
|
@ -481,7 +483,7 @@ bool_t usbStallReceiveI(USBDriver *usbp, usbep_t ep) {
|
||||||
* @param[in] ep endpoint number
|
* @param[in] ep endpoint number
|
||||||
* @return The operation status.
|
* @return The operation status.
|
||||||
* @retval FALSE Endpoint stalled.
|
* @retval FALSE Endpoint stalled.
|
||||||
* @retval TRUE The endpoint was within a transaction, not stalled.
|
* @retval TRUE Endpoint busy, not stalled.
|
||||||
*
|
*
|
||||||
* @iclass
|
* @iclass
|
||||||
*/
|
*/
|
||||||
|
@ -510,6 +512,8 @@ void _usb_reset(USBDriver *usbp) {
|
||||||
usbp->status = 0;
|
usbp->status = 0;
|
||||||
usbp->address = 0;
|
usbp->address = 0;
|
||||||
usbp->configuration = 0;
|
usbp->configuration = 0;
|
||||||
|
usbp->transmitting = 0;
|
||||||
|
usbp->receiving = 0;
|
||||||
|
|
||||||
/* Invalidates all endpoints into the USBDriver structure.*/
|
/* Invalidates all endpoints into the USBDriver structure.*/
|
||||||
for (i = 0; i <= USB_MAX_ENDPOINTS; i++)
|
for (i = 0; i <= USB_MAX_ENDPOINTS; i++)
|
||||||
|
|
Loading…
Reference in New Issue