Removed obsolete code.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12455 110e8d01-0319-4d1e-a829-52ad28d1bb01
This commit is contained in:
parent
9ff0ca5826
commit
559b4aa2d3
|
@ -394,17 +394,8 @@ static void otg_epin_handler(USBDriver *usbp, usbep_t ep) {
|
|||
}
|
||||
if ((epint & DIEPINT_TXFE) &&
|
||||
(otgp->DIEPEMPMSK & DIEPEMPMSK_INEPTXFEM(ep))) {
|
||||
#if 0
|
||||
/* The thread is made ready, it will be scheduled on ISR exit.*/
|
||||
osalSysLockFromISR();
|
||||
usbp->txpending |= (1 << ep);
|
||||
otgp->DIEPEMPMSK &= ~(1 << ep);
|
||||
osalThreadResumeI(&usbp->wait, MSG_OK);
|
||||
osalSysUnlockFromISR();
|
||||
#else
|
||||
/* TX FIFO empty or emptying.*/
|
||||
otg_txfifo_handler(usbp, ep);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -492,17 +483,8 @@ static void otg_isoc_in_failed_handler(USBDriver *usbp) {
|
|||
/* Prepare data for next frame */
|
||||
_usb_isr_invoke_in_cb(usbp, ep);
|
||||
|
||||
#if 0
|
||||
/* Pump out data for next frame */
|
||||
osalSysLockFromISR();
|
||||
otgp->DIEPEMPMSK &= ~(1 << ep);
|
||||
usbp->txpending |= (1 << ep);
|
||||
osalThreadResumeI(&usbp->wait, MSG_OK);
|
||||
osalSysUnlockFromISR();
|
||||
#else
|
||||
/* TX FIFO empty or emptying.*/
|
||||
otg_txfifo_handler(usbp, ep);
|
||||
#endif
|
||||
/* TX FIFO empty or emptying.*/
|
||||
otg_txfifo_handler(usbp, ep);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -550,10 +532,6 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) {
|
|||
|
||||
/* Reset interrupt handling.*/
|
||||
if (sts & GINTSTS_USBRST) {
|
||||
#if 0
|
||||
/* Resetting pending operations.*/
|
||||
usbp->txpending = 0;
|
||||
#endif
|
||||
/* Default reset action.*/
|
||||
_usb_reset(usbp);
|
||||
|
||||
|
@ -578,10 +556,6 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) {
|
|||
|
||||
/* Suspend handling.*/
|
||||
if (sts & GINTSTS_USBSUSP) {
|
||||
#if 0
|
||||
/* Resetting pending operations.*/
|
||||
usbp->txpending = 0;
|
||||
#endif
|
||||
/* Default suspend action.*/
|
||||
_usb_suspend(usbp);
|
||||
}
|
||||
|
@ -614,23 +588,11 @@ static void usb_lld_serve_interrupt(USBDriver *usbp) {
|
|||
otg_isoc_out_failed_handler(usbp);
|
||||
}
|
||||
|
||||
/* RX FIFO not empty handling.*/
|
||||
#if 0
|
||||
if (sts & GINTSTS_RXFLVL) {
|
||||
/* The interrupt is masked while the thread has control or it would
|
||||
be triggered again.*/
|
||||
osalSysLockFromISR();
|
||||
otgp->GINTMSK &= ~GINTMSK_RXFLVLM;
|
||||
osalThreadResumeI(&usbp->wait, MSG_OK);
|
||||
osalSysUnlockFromISR();
|
||||
}
|
||||
#else
|
||||
/* Performing the whole FIFO emptying in the ISR, it is advised to keep
|
||||
this IRQ at a very low priority level.*/
|
||||
if ((sts & GINTSTS_RXFLVL) != 0U) {
|
||||
otg_rxfifo_handler(usbp);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* IN/OUT endpoints event handling.*/
|
||||
src = otgp->DAINT;
|
||||
|
@ -746,52 +708,15 @@ void usb_lld_init(void) {
|
|||
/* Driver initialization.*/
|
||||
#if STM32_USB_USE_OTG1
|
||||
usbObjectInit(&USBD1);
|
||||
#if 0
|
||||
USBD1.wait = NULL;
|
||||
#endif
|
||||
USBD1.otg = OTG_FS;
|
||||
USBD1.otgparams = &fsparams;
|
||||
|
||||
#if 0
|
||||
#if defined(_CHIBIOS_RT_)
|
||||
USBD1.tr = NULL;
|
||||
/* Filling the thread working area here because the function
|
||||
@p chThdCreateI() does not do it.*/
|
||||
#if CH_DBG_FILL_THREADS
|
||||
{
|
||||
void *wsp = USBD1.wa_pump;
|
||||
_thread_memfill((uint8_t *)wsp,
|
||||
(uint8_t *)wsp + sizeof (USBD1.wa_pump),
|
||||
CH_DBG_STACK_FILL_VALUE);
|
||||
}
|
||||
#endif /* CH_DBG_FILL_THREADS */
|
||||
#endif /* defined(_CHIBIOS_RT_) */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if STM32_USB_USE_OTG2
|
||||
usbObjectInit(&USBD2);
|
||||
#if 0
|
||||
USBD2.wait = NULL;
|
||||
#endif
|
||||
USBD2.otg = OTG_HS;
|
||||
USBD2.otgparams = &hsparams;
|
||||
|
||||
#if 0
|
||||
#if defined(_CHIBIOS_RT_)
|
||||
USBD2.tr = NULL;
|
||||
/* Filling the thread working area here because the function
|
||||
@p chThdCreateI() does not do it.*/
|
||||
#if CH_DBG_FILL_THREADS
|
||||
{
|
||||
void *wsp = USBD2.wa_pump;
|
||||
_thread_memfill((uint8_t *)wsp,
|
||||
(uint8_t *)wsp + sizeof (USBD2.wa_pump),
|
||||
CH_DBG_STACK_FILL_VALUE);
|
||||
}
|
||||
#endif /* CH_DBG_FILL_THREADS */
|
||||
#endif /* defined(_CHIBIOS_RT_) */
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -876,10 +801,6 @@ void usb_lld_start(USBDriver *usbp) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* Clearing mask of TXFIFOs to be filled.*/
|
||||
usbp->txpending = 0;
|
||||
#endif
|
||||
/* PHY enabled.*/
|
||||
otgp->PCGCCTL = 0;
|
||||
|
||||
|
@ -929,24 +850,6 @@ void usb_lld_start(USBDriver *usbp) {
|
|||
/* Clears all pending IRQs, if any. */
|
||||
otgp->GINTSTS = 0xFFFFFFFF;
|
||||
|
||||
#if 0
|
||||
#if defined(_CHIBIOS_RT_)
|
||||
/* Creates the data pump thread. Note, it is created only once.*/
|
||||
if (usbp->tr == NULL) {
|
||||
thread_descriptor_t usbpump_descriptor = {
|
||||
"usb_pump",
|
||||
THD_WORKING_AREA_BASE(usbp->wa_pump),
|
||||
THD_WORKING_AREA_END(usbp->wa_pump),
|
||||
STM32_USB_OTG_THREAD_PRIO,
|
||||
usb_lld_pump,
|
||||
(void *)usbp
|
||||
};
|
||||
|
||||
usbp->tr = chThdCreateI(&usbpump_descriptor);
|
||||
chSchRescheduleS();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Global interrupts enable.*/
|
||||
otgp->GAHBCFG |= GAHBCFG_GINTMSK;
|
||||
}
|
||||
|
@ -969,9 +872,6 @@ void usb_lld_stop(USBDriver *usbp) {
|
|||
active.*/
|
||||
otg_disable_ep(usbp);
|
||||
|
||||
#if 0
|
||||
usbp->txpending = 0;
|
||||
#endif
|
||||
otgp->DAINTMSK = 0;
|
||||
otgp->GAHBCFG = 0;
|
||||
otgp->GCCFG = 0;
|
||||
|
@ -1350,73 +1250,6 @@ void usb_lld_clear_in(USBDriver *usbp, usbep_t ep) {
|
|||
usbp->otg->ie[ep].DIEPCTL &= ~DIEPCTL_STALL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* @brief USB data transfer loop.
|
||||
* @details This function must be executed by a system thread in order to
|
||||
* make the USB driver work.
|
||||
* @note The data copy part of the driver is implemented in this thread
|
||||
* in order to not perform heavy tasks within interrupt handlers.
|
||||
*
|
||||
* @param[in] p pointer to the @p USBDriver object
|
||||
*
|
||||
* @special
|
||||
*/
|
||||
void usb_lld_pump(void *p) {
|
||||
USBDriver *usbp = (USBDriver *)p;
|
||||
stm32_otg_t *otgp = usbp->otg;
|
||||
|
||||
osalSysLock();
|
||||
while (true) {
|
||||
usbep_t ep;
|
||||
uint32_t epmask;
|
||||
|
||||
/* Nothing to do, going to sleep.*/
|
||||
if ((usbp->state == USB_STOP) ||
|
||||
((usbp->txpending == 0) && !(otgp->GINTSTS & GINTSTS_RXFLVL))) {
|
||||
otgp->GINTMSK |= GINTMSK_RXFLVLM;
|
||||
osalThreadSuspendS(&usbp->wait);
|
||||
}
|
||||
osalSysUnlock();
|
||||
|
||||
/* Checks if there are TXFIFOs to be filled.*/
|
||||
for (ep = 0; ep <= usbp->otgparams->num_endpoints; ep++) {
|
||||
|
||||
/* Empties the RX FIFO.*/
|
||||
while (otgp->GINTSTS & GINTSTS_RXFLVL) {
|
||||
otg_rxfifo_handler(usbp);
|
||||
}
|
||||
|
||||
epmask = (1 << ep);
|
||||
if (usbp->txpending & epmask) {
|
||||
bool done;
|
||||
|
||||
osalSysLock();
|
||||
/* USB interrupts are globally *suspended* because the peripheral
|
||||
does not allow any interference during the TX FIFO filling
|
||||
operation.
|
||||
Synopsys document: DesignWare Cores USB 2.0 Hi-Speed On-The-Go (OTG)
|
||||
"The application has to finish writing one complete packet before
|
||||
switching to a different channel/endpoint FIFO. Violating this
|
||||
rule results in an error.".*/
|
||||
otgp->GAHBCFG &= ~GAHBCFG_GINTMSK;
|
||||
usbp->txpending &= ~epmask;
|
||||
osalSysUnlock();
|
||||
|
||||
done = otg_txfifo_handler(usbp, ep);
|
||||
|
||||
osalSysLock();
|
||||
otgp->GAHBCFG |= GAHBCFG_GINTMSK;
|
||||
if (!done)
|
||||
otgp->DIEPEMPMSK |= epmask;
|
||||
osalSysUnlock();
|
||||
}
|
||||
}
|
||||
osalSysLock();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HAL_USE_USB */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -109,20 +109,6 @@
|
|||
#define STM32_USE_USB_OTG2_HS TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Dedicated data pump threads priority.
|
||||
*/
|
||||
#if !defined(STM32_USB_OTG_THREAD_PRIO) || defined(__DOXYGEN__)
|
||||
#define STM32_USB_OTG_THREAD_PRIO LOWPRIO
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Dedicated data pump threads stack size.
|
||||
*/
|
||||
#if !defined(STM32_USB_OTG_THREAD_STACK_SIZE) || defined(__DOXYGEN__)
|
||||
#define STM32_USB_OTG_THREAD_STACK_SIZE 128
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Exception priority level during TXFIFOs operations.
|
||||
* @note Because an undocumented silicon behavior the operation of
|
||||
|
@ -518,26 +504,6 @@ struct USBDriver {
|
|||
* @brief Pointer to the next address in the packet memory.
|
||||
*/
|
||||
uint32_t pmnext;
|
||||
#if 0
|
||||
/**
|
||||
* @brief Mask of TXFIFOs to be filled by the pump thread.
|
||||
*/
|
||||
uint32_t txpending;
|
||||
/**
|
||||
* @brief Pointer to the thread when it is sleeping or @p NULL.
|
||||
*/
|
||||
thread_reference_t wait;
|
||||
#if defined(_CHIBIOS_RT_)
|
||||
/**
|
||||
* @brief Pointer to the thread.
|
||||
*/
|
||||
thread_reference_t tr;
|
||||
/**
|
||||
* @brief Working area for the dedicated data pump thread;
|
||||
*/
|
||||
THD_WORKING_AREA(wa_pump, STM32_USB_OTG_THREAD_STACK_SIZE);
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,628 +0,0 @@
|
|||
/*
|
||||
ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file OTGv1/hal_usb_lld.h
|
||||
* @brief STM32 USB subsystem low level driver header.
|
||||
*
|
||||
* @addtogroup USB
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef HAL_USB_LLD_H
|
||||
#define HAL_USB_LLD_H
|
||||
|
||||
#if HAL_USE_USB || defined(__DOXYGEN__)
|
||||
|
||||
#include "stm32_otg.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver constants. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Status stage handling method.
|
||||
*/
|
||||
#define USB_EP0_STATUS_STAGE USB_EP0_STATUS_STAGE_SW
|
||||
|
||||
/**
|
||||
* @brief The address can be changed immediately upon packet reception.
|
||||
*/
|
||||
#define USB_SET_ADDRESS_MODE USB_EARLY_SET_ADDRESS
|
||||
|
||||
/**
|
||||
* @brief Method for set address acknowledge.
|
||||
*/
|
||||
#define USB_SET_ADDRESS_ACK_HANDLING USB_SET_ADDRESS_ACK_SW
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver pre-compile time settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief OTG1 driver enable switch.
|
||||
* @details If set to @p TRUE the support for OTG_FS is included.
|
||||
* @note The default is @p FALSE
|
||||
*/
|
||||
#if !defined(STM32_USB_USE_OTG1) || defined(__DOXYGEN__)
|
||||
#define STM32_USB_USE_OTG1 FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief OTG2 driver enable switch.
|
||||
* @details If set to @p TRUE the support for OTG_HS is included.
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#if !defined(STM32_USB_USE_OTG2) || defined(__DOXYGEN__)
|
||||
#define STM32_USB_USE_OTG2 FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief OTG1 interrupt priority level setting.
|
||||
*/
|
||||
#if !defined(STM32_USB_OTG1_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||
#define STM32_USB_OTG1_IRQ_PRIORITY 14
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief OTG2 interrupt priority level setting.
|
||||
*/
|
||||
#if !defined(STM32_USB_OTG2_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||
#define STM32_USB_OTG2_IRQ_PRIORITY 14
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief OTG1 RX shared FIFO size.
|
||||
* @note Must be a multiple of 4.
|
||||
*/
|
||||
#if !defined(STM32_USB_OTG1_RX_FIFO_SIZE) || defined(__DOXYGEN__)
|
||||
#define STM32_USB_OTG1_RX_FIFO_SIZE 512
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief OTG2 RX shared FIFO size.
|
||||
* @note Must be a multiple of 4.
|
||||
*/
|
||||
#if !defined(STM32_USB_OTG2_RX_FIFO_SIZE) || defined(__DOXYGEN__)
|
||||
#define STM32_USB_OTG2_RX_FIFO_SIZE 1024
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enables HS mode on OTG2 else FS mode.
|
||||
* @note The default is @p TRUE.
|
||||
* @note Has effect only if @p BOARD_OTG2_USES_ULPI is defined.
|
||||
*/
|
||||
#if !defined(STM32_USE_USB_OTG2_HS) || defined(__DOXYGEN__)
|
||||
#define STM32_USE_USB_OTG2_HS TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Dedicated data pump threads priority.
|
||||
*/
|
||||
#if !defined(STM32_USB_OTG_THREAD_PRIO) || defined(__DOXYGEN__)
|
||||
#define STM32_USB_OTG_THREAD_PRIO LOWPRIO
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Dedicated data pump threads stack size.
|
||||
*/
|
||||
#if !defined(STM32_USB_OTG_THREAD_STACK_SIZE) || defined(__DOXYGEN__)
|
||||
#define STM32_USB_OTG_THREAD_STACK_SIZE 128
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Exception priority level during TXFIFOs operations.
|
||||
* @note Because an undocumented silicon behavior the operation of
|
||||
* copying a packet into a TXFIFO must not be interrupted by
|
||||
* any other operation on the OTG peripheral.
|
||||
* This parameter represents the priority mask during copy
|
||||
* operations. The default value only allows to call USB
|
||||
* functions from callbacks invoked from USB ISR handlers.
|
||||
* If you need to invoke USB functions from other handlers
|
||||
* then raise this priority mast to the same level of the
|
||||
* handler you need to use.
|
||||
* @note The value zero means disabled, when disabled calling USB
|
||||
* functions is only safe from thread level or from USB
|
||||
* callbacks.
|
||||
*/
|
||||
#if !defined(STM32_USB_OTGFIFO_FILL_BASEPRI) || defined(__DOXYGEN__)
|
||||
#define STM32_USB_OTGFIFO_FILL_BASEPRI 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Host wake-up procedure duration.
|
||||
*/
|
||||
#if !defined(USB_HOST_WAKEUP_DURATION) || defined(__DOXYGEN__)
|
||||
#define USB_HOST_WAKEUP_DURATION 2
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Derived constants and error checks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/* Registry checks.*/
|
||||
#if !defined(STM32_OTG_STEPPING)
|
||||
#error "STM32_OTG_STEPPING not defined in registry"
|
||||
#endif
|
||||
|
||||
#if (STM32_OTG_STEPPING < 1) || (STM32_OTG_STEPPING > 2)
|
||||
#error "unsupported STM32_OTG_STEPPING"
|
||||
#endif
|
||||
|
||||
#if !defined(STM32_HAS_OTG1) || !defined(STM32_HAS_OTG2)
|
||||
#error "STM32_HAS_OTGx not defined in registry"
|
||||
#endif
|
||||
|
||||
#if STM32_HAS_OTG1 && !defined(STM32_OTG1_ENDPOINTS)
|
||||
#error "STM32_OTG1_ENDPOINTS not defined in registry"
|
||||
#endif
|
||||
|
||||
#if STM32_HAS_OTG2 && !defined(STM32_OTG2_ENDPOINTS)
|
||||
#error "STM32_OTG2_ENDPOINTS not defined in registry"
|
||||
#endif
|
||||
|
||||
#if STM32_HAS_OTG1 && !defined(STM32_OTG1_FIFO_MEM_SIZE)
|
||||
#error "STM32_OTG1_FIFO_MEM_SIZE not defined in registry"
|
||||
#endif
|
||||
|
||||
#if STM32_HAS_OTG2 && !defined(STM32_OTG2_FIFO_MEM_SIZE)
|
||||
#error "STM32_OTG2_FIFO_MEM_SIZE not defined in registry"
|
||||
#endif
|
||||
|
||||
#if (STM32_USB_USE_OTG1 && !defined(STM32_OTG1_HANDLER)) || \
|
||||
(STM32_USB_USE_OTG2 && !defined(STM32_OTG2_HANDLER))
|
||||
#error "STM32_OTGx_HANDLER not defined in registry"
|
||||
#endif
|
||||
|
||||
#if (STM32_USB_USE_OTG1 && !defined(STM32_OTG1_NUMBER)) || \
|
||||
(STM32_USB_USE_OTG2 && !defined(STM32_OTG2_NUMBER))
|
||||
#error "STM32_OTGx_NUMBER not defined in registry"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Maximum endpoint address.
|
||||
*/
|
||||
#if (STM32_HAS_OTG2 && STM32_USB_USE_OTG2) || defined(__DOXYGEN__)
|
||||
#if (STM32_OTG1_ENDPOINTS < STM32_OTG2_ENDPOINTS) || defined(__DOXYGEN__)
|
||||
#define USB_MAX_ENDPOINTS STM32_OTG2_ENDPOINTS
|
||||
#else
|
||||
#define USB_MAX_ENDPOINTS STM32_OTG1_ENDPOINTS
|
||||
#endif
|
||||
#else
|
||||
#define USB_MAX_ENDPOINTS STM32_OTG1_ENDPOINTS
|
||||
#endif
|
||||
|
||||
#if STM32_USB_USE_OTG1 && !STM32_HAS_OTG1
|
||||
#error "OTG1 not present in the selected device"
|
||||
#endif
|
||||
|
||||
#if STM32_USB_USE_OTG2 && !STM32_HAS_OTG2
|
||||
#error "OTG2 not present in the selected device"
|
||||
#endif
|
||||
|
||||
#if !STM32_USB_USE_OTG1 && !STM32_USB_USE_OTG2
|
||||
#error "USB driver activated but no USB peripheral assigned"
|
||||
#endif
|
||||
|
||||
#if STM32_USB_USE_OTG1 && \
|
||||
!OSAL_IRQ_IS_VALID_PRIORITY(STM32_USB_OTG1_IRQ_PRIORITY)
|
||||
#error "Invalid IRQ priority assigned to OTG1"
|
||||
#endif
|
||||
|
||||
#if STM32_USB_USE_OTG2 && \
|
||||
!OSAL_IRQ_IS_VALID_PRIORITY(STM32_USB_OTG2_IRQ_PRIORITY)
|
||||
#error "Invalid IRQ priority assigned to OTG2"
|
||||
#endif
|
||||
|
||||
#if (STM32_USB_OTG1_RX_FIFO_SIZE & 3) != 0
|
||||
#error "OTG1 RX FIFO size must be a multiple of 4"
|
||||
#endif
|
||||
|
||||
#if (STM32_USB_OTG2_RX_FIFO_SIZE & 3) != 0
|
||||
#error "OTG2 RX FIFO size must be a multiple of 4"
|
||||
#endif
|
||||
|
||||
#if defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32F7XX)
|
||||
#define STM32_USBCLK STM32_PLL48CLK
|
||||
#elif defined(STM32F10X_CL)
|
||||
#define STM32_USBCLK STM32_OTGFSCLK
|
||||
#elif defined(STM32L4XX)
|
||||
#define STM32_USBCLK STM32_48CLK
|
||||
#else
|
||||
#error "unsupported STM32 platform for OTG functionality"
|
||||
#endif
|
||||
|
||||
#if STM32_USBCLK != 48000000
|
||||
#error "the USB OTG driver requires a 48MHz clock"
|
||||
#endif
|
||||
|
||||
#if (USB_HOST_WAKEUP_DURATION < 2) || (USB_HOST_WAKEUP_DURATION > 15)
|
||||
#error "invalid USB_HOST_WAKEUP_DURATION setting, it must be between 2 and 15"
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver data structures and types. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Peripheral-specific parameters block.
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t rx_fifo_size;
|
||||
uint32_t otg_ram_size;
|
||||
uint32_t num_endpoints;
|
||||
} stm32_otg_params_t;
|
||||
|
||||
/**
|
||||
* @brief Type of an IN endpoint state structure.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief Requested transmit transfer size.
|
||||
*/
|
||||
size_t txsize;
|
||||
/**
|
||||
* @brief Transmitted bytes so far.
|
||||
*/
|
||||
size_t txcnt;
|
||||
/**
|
||||
* @brief Pointer to the transmission linear buffer.
|
||||
*/
|
||||
const uint8_t *txbuf;
|
||||
#if (USB_USE_WAIT == TRUE) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Waiting thread.
|
||||
*/
|
||||
thread_reference_t thread;
|
||||
#endif
|
||||
/* End of the mandatory fields.*/
|
||||
/**
|
||||
* @brief Total transmit transfer size.
|
||||
*/
|
||||
size_t totsize;
|
||||
} USBInEndpointState;
|
||||
|
||||
/**
|
||||
* @brief Type of an OUT endpoint state structure.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief Requested receive transfer size.
|
||||
*/
|
||||
size_t rxsize;
|
||||
/**
|
||||
* @brief Received bytes so far.
|
||||
*/
|
||||
size_t rxcnt;
|
||||
/**
|
||||
* @brief Pointer to the receive linear buffer.
|
||||
*/
|
||||
uint8_t *rxbuf;
|
||||
#if (USB_USE_WAIT == TRUE) || defined(__DOXYGEN__)
|
||||
/**
|
||||
* @brief Waiting thread.
|
||||
*/
|
||||
thread_reference_t thread;
|
||||
#endif
|
||||
/* End of the mandatory fields.*/
|
||||
/**
|
||||
* @brief Total receive transfer size.
|
||||
*/
|
||||
size_t totsize;
|
||||
} USBOutEndpointState;
|
||||
|
||||
/**
|
||||
* @brief Type of an USB endpoint configuration structure.
|
||||
* @note Platform specific restrictions may apply to endpoints.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief Type and mode of the endpoint.
|
||||
*/
|
||||
uint32_t ep_mode;
|
||||
/**
|
||||
* @brief Setup packet notification callback.
|
||||
* @details This callback is invoked when a setup packet has been
|
||||
* received.
|
||||
* @post The application must immediately call @p usbReadPacket() in
|
||||
* order to access the received packet.
|
||||
* @note This field is only valid for @p USB_EP_MODE_TYPE_CTRL
|
||||
* endpoints, it should be set to @p NULL for other endpoint
|
||||
* types.
|
||||
*/
|
||||
usbepcallback_t setup_cb;
|
||||
/**
|
||||
* @brief IN endpoint notification callback.
|
||||
* @details This field must be set to @p NULL if callback is not required.
|
||||
*/
|
||||
usbepcallback_t in_cb;
|
||||
/**
|
||||
* @brief OUT endpoint notification callback.
|
||||
* @details This field must be set to @p NULL if callback is not required.
|
||||
*/
|
||||
usbepcallback_t out_cb;
|
||||
/**
|
||||
* @brief IN endpoint maximum packet size.
|
||||
* @details This field must be set to zero if the IN endpoint is not used.
|
||||
*/
|
||||
uint16_t in_maxsize;
|
||||
/**
|
||||
* @brief OUT endpoint maximum packet size.
|
||||
* @details This field must be set to zero if the OUT endpoint is not used.
|
||||
*/
|
||||
uint16_t out_maxsize;
|
||||
/**
|
||||
* @brief @p USBEndpointState associated to the IN endpoint.
|
||||
* @details This field must be set to @p NULL if the IN endpoint is not
|
||||
* used.
|
||||
*/
|
||||
USBInEndpointState *in_state;
|
||||
/**
|
||||
* @brief @p USBEndpointState associated to the OUT endpoint.
|
||||
* @details This field must be set to @p NULL if the OUT endpoint is not
|
||||
* used.
|
||||
*/
|
||||
USBOutEndpointState *out_state;
|
||||
/* End of the mandatory fields.*/
|
||||
/**
|
||||
* @brief Determines the space allocated for the TXFIFO as multiples of
|
||||
* the packet size (@p in_maxsize). Note that zero is interpreted
|
||||
* as one for simplicity and robustness.
|
||||
*/
|
||||
uint16_t in_multiplier;
|
||||
/**
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* @brief Type of an USB driver configuration structure.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* @brief USB events callback.
|
||||
* @details This callback is invoked when an USB driver event is registered.
|
||||
*/
|
||||
usbeventcb_t event_cb;
|
||||
/**
|
||||
* @brief Device GET_DESCRIPTOR request callback.
|
||||
* @note This callback is mandatory and cannot be set to @p NULL.
|
||||
*/
|
||||
usbgetdescriptor_t get_descriptor_cb;
|
||||
/**
|
||||
* @brief Requests hook callback.
|
||||
* @details This hook allows to be notified of standard requests or to
|
||||
* handle non standard requests.
|
||||
*/
|
||||
usbreqhandler_t requests_hook_cb;
|
||||
/**
|
||||
* @brief Start Of Frame callback.
|
||||
*/
|
||||
usbcallback_t sof_cb;
|
||||
/* End of the mandatory fields.*/
|
||||
} USBConfig;
|
||||
|
||||
/**
|
||||
* @brief Structure representing an USB driver.
|
||||
*/
|
||||
struct USBDriver {
|
||||
/**
|
||||
* @brief Driver state.
|
||||
*/
|
||||
usbstate_t state;
|
||||
/**
|
||||
* @brief Current configuration data.
|
||||
*/
|
||||
const USBConfig *config;
|
||||
/**
|
||||
* @brief Bit map of the transmitting IN endpoints.
|
||||
*/
|
||||
uint16_t transmitting;
|
||||
/**
|
||||
* @brief Bit map of the receiving OUT endpoints.
|
||||
*/
|
||||
uint16_t receiving;
|
||||
/**
|
||||
* @brief Active endpoints configurations.
|
||||
*/
|
||||
const USBEndpointConfig *epc[USB_MAX_ENDPOINTS + 1];
|
||||
/**
|
||||
* @brief Fields available to user, it can be used to associate an
|
||||
* application-defined handler to an IN endpoint.
|
||||
* @note The base index is one, the endpoint zero does not have a
|
||||
* reserved element in this array.
|
||||
*/
|
||||
void *in_params[USB_MAX_ENDPOINTS];
|
||||
/**
|
||||
* @brief Fields available to user, it can be used to associate an
|
||||
* application-defined handler to an OUT endpoint.
|
||||
* @note The base index is one, the endpoint zero does not have a
|
||||
* reserved element in this array.
|
||||
*/
|
||||
void *out_params[USB_MAX_ENDPOINTS];
|
||||
/**
|
||||
* @brief Endpoint 0 state.
|
||||
*/
|
||||
usbep0state_t ep0state;
|
||||
/**
|
||||
* @brief Next position in the buffer to be transferred through endpoint 0.
|
||||
*/
|
||||
uint8_t *ep0next;
|
||||
/**
|
||||
* @brief Number of bytes yet to be transferred through endpoint 0.
|
||||
*/
|
||||
size_t ep0n;
|
||||
/**
|
||||
* @brief Endpoint 0 end transaction callback.
|
||||
*/
|
||||
usbcallback_t ep0endcb;
|
||||
/**
|
||||
* @brief Setup packet buffer.
|
||||
*/
|
||||
uint8_t setup[8];
|
||||
/**
|
||||
* @brief Current USB device status.
|
||||
*/
|
||||
uint16_t status;
|
||||
/**
|
||||
* @brief Assigned USB address.
|
||||
*/
|
||||
uint8_t address;
|
||||
/**
|
||||
* @brief Current USB device configuration.
|
||||
*/
|
||||
uint8_t configuration;
|
||||
/**
|
||||
* @brief State of the driver when a suspend happened.
|
||||
*/
|
||||
usbstate_t saved_state;
|
||||
#if defined(USB_DRIVER_EXT_FIELDS)
|
||||
USB_DRIVER_EXT_FIELDS
|
||||
#endif
|
||||
/* End of the mandatory fields.*/
|
||||
/**
|
||||
* @brief Pointer to the OTG peripheral associated to this driver.
|
||||
*/
|
||||
stm32_otg_t *otg;
|
||||
/**
|
||||
* @brief Peripheral-specific parameters.
|
||||
*/
|
||||
const stm32_otg_params_t *otgparams;
|
||||
/**
|
||||
* @brief Pointer to the next address in the packet memory.
|
||||
*/
|
||||
uint32_t pmnext;
|
||||
#if 0
|
||||
/**
|
||||
* @brief Mask of TXFIFOs to be filled by the pump thread.
|
||||
*/
|
||||
uint32_t txpending;
|
||||
/**
|
||||
* @brief Pointer to the thread when it is sleeping or @p NULL.
|
||||
*/
|
||||
thread_reference_t wait;
|
||||
#if defined(_CHIBIOS_RT_)
|
||||
/**
|
||||
* @brief Pointer to the thread.
|
||||
*/
|
||||
thread_reference_t tr;
|
||||
/**
|
||||
* @brief Working area for the dedicated data pump thread;
|
||||
*/
|
||||
THD_WORKING_AREA(wa_pump, STM32_USB_OTG_THREAD_STACK_SIZE);
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver macros. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Returns the exact size of a receive transaction.
|
||||
* @details The received size can be different from the size specified in
|
||||
* @p usbStartReceiveI() because the last packet could have a size
|
||||
* different from the expected one.
|
||||
* @pre The OUT endpoint must have been configured in transaction mode
|
||||
* in order to use this function.
|
||||
*
|
||||
* @param[in] usbp pointer to the @p USBDriver object
|
||||
* @param[in] ep endpoint number
|
||||
* @return Received data size.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
#define usb_lld_get_transaction_size(usbp, ep) \
|
||||
((usbp)->epc[ep]->out_state->rxcnt)
|
||||
|
||||
/**
|
||||
* @brief Connects the USB device.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
#if (STM32_OTG_STEPPING == 1) || defined(__DOXYGEN__)
|
||||
#define usb_lld_connect_bus(usbp) ((usbp)->otg->GCCFG |= GCCFG_VBUSBSEN)
|
||||
#else
|
||||
#define usb_lld_connect_bus(usbp) ((usbp)->otg->DCTL &= ~DCTL_SDIS)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Disconnect the USB device.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
#if (STM32_OTG_STEPPING == 1) || defined(__DOXYGEN__)
|
||||
#define usb_lld_disconnect_bus(usbp) ((usbp)->otg->GCCFG &= ~GCCFG_VBUSBSEN)
|
||||
#else
|
||||
#define usb_lld_disconnect_bus(usbp) ((usbp)->otg->DCTL |= DCTL_SDIS)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Start of host wake-up procedure.
|
||||
*
|
||||
* @notapi
|
||||
*/
|
||||
#define usb_lld_wakeup_host(usbp) \
|
||||
do{ \
|
||||
(usbp)->otg->DCTL |= DCTL_RWUSIG; \
|
||||
osalThreadSleepMilliseconds(USB_HOST_WAKEUP_DURATION); \
|
||||
(usbp)->otg->DCTL &= ~DCTL_RWUSIG; \
|
||||
} while (false)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* External declarations. */
|
||||
/*===========================================================================*/
|
||||
|
||||
#if STM32_USB_USE_OTG1 && !defined(__DOXYGEN__)
|
||||
extern USBDriver USBD1;
|
||||
#endif
|
||||
|
||||
#if STM32_USB_USE_OTG2 && !defined(__DOXYGEN__)
|
||||
extern USBDriver USBD2;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void usb_lld_init(void);
|
||||
void usb_lld_start(USBDriver *usbp);
|
||||
void usb_lld_stop(USBDriver *usbp);
|
||||
void usb_lld_reset(USBDriver *usbp);
|
||||
void usb_lld_set_address(USBDriver *usbp);
|
||||
void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep);
|
||||
void usb_lld_disable_endpoints(USBDriver *usbp);
|
||||
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);
|
||||
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);
|
||||
void usb_lld_stall_in(USBDriver *usbp, usbep_t ep);
|
||||
void usb_lld_clear_out(USBDriver *usbp, usbep_t ep);
|
||||
void usb_lld_clear_in(USBDriver *usbp, usbep_t ep);
|
||||
void usb_lld_pump(void *p);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HAL_USE_USB */
|
||||
|
||||
#endif /* HAL_USB_LLD_H */
|
||||
|
||||
/** @} */
|
|
@ -33,7 +33,7 @@
|
|||
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="r2-(format)" val="4"/><content id="r3-(format)" val="4"/><content id="r6-(format)" val="4"/><content id="xPSR-(format)" val="4"/></contentList>"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="xPSR-(format)" val="4"/><content id="r6-(format)" val="4"/><content id="r3-(format)" val="4"/><content id="r2-(format)" val="4"/></contentList>"/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList> <memoryBlockExpressionItem> <expression text="0x58024400"/> </memoryBlockExpressionItem> </memoryBlockExpressionList> "/>
|
||||
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="${selected_resource_loc}"/>
|
||||
|
|
Loading…
Reference in New Issue