123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- /*
- 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 hal_usb_lld.c
- * @brief PLATFORM USB subsystem low level driver source.
- *
- * @addtogroup USB
- * @{
- */
- #include "hal.h"
- #if (HAL_USE_USB == TRUE) || defined(__DOXYGEN__)
- /*===========================================================================*/
- /* Driver local definitions. */
- /*===========================================================================*/
- /*===========================================================================*/
- /* Driver exported variables. */
- /*===========================================================================*/
- /**
- * @brief USB1 driver identifier.
- */
- #if (PLATFORM_USB_USE_USB1 == TRUE) || defined(__DOXYGEN__)
- USBDriver USBD1;
- #endif
- /*===========================================================================*/
- /* Driver local variables and types. */
- /*===========================================================================*/
- /**
- * @brief EP0 state.
- * @note It is an union because IN and OUT endpoints are never used at the
- * same time for EP0.
- */
- static union {
- /**
- * @brief IN EP0 state.
- */
- USBInEndpointState in;
- /**
- * @brief OUT EP0 state.
- */
- USBOutEndpointState out;
- } ep0_state;
- /**
- * @brief EP0 initialization structure.
- */
- static const USBEndpointConfig ep0config = {
- USB_EP_MODE_TYPE_CTRL,
- _usb_ep0setup,
- _usb_ep0in,
- _usb_ep0out,
- 0x40,
- 0x40,
- &ep0_state.in,
- &ep0_state.out
- };
- /*===========================================================================*/
- /* Driver local variables and types. */
- /*===========================================================================*/
- /*===========================================================================*/
- /* Driver local functions. */
- /*===========================================================================*/
- /*===========================================================================*/
- /* Driver interrupt handlers and threads. */
- /*===========================================================================*/
- /*===========================================================================*/
- /* Driver exported functions. */
- /*===========================================================================*/
- /**
- * @brief Low level USB driver initialization.
- *
- * @notapi
- */
- void usb_lld_init(void) {
- #if PLATFORM_USB_USE_USB1 == TRUE
- /* Driver initialization.*/
- usbObjectInit(&USBD1);
- #endif
- }
- /**
- * @brief Configures and activates the USB peripheral.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- *
- * @notapi
- */
- void usb_lld_start(USBDriver *usbp) {
- if (usbp->state == USB_STOP) {
- /* Enables the peripheral.*/
- #if PLATFORM_USB_USE_USB1 == TRUE
- if (&USBD1 == usbp) {
- }
- #endif
- }
- /* Configures the peripheral.*/
- }
- /**
- * @brief Deactivates the USB peripheral.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- *
- * @notapi
- */
- void usb_lld_stop(USBDriver *usbp) {
- if (usbp->state == USB_READY) {
- /* Resets the peripheral.*/
- /* Disables the peripheral.*/
- #if PLATFORM_USB_USE_USB1 == TRUE
- if (&USBD1 == usbp) {
- }
- #endif
- }
- }
- /**
- * @brief USB low level reset routine.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- *
- * @notapi
- */
- void usb_lld_reset(USBDriver *usbp) {
- /* Post reset initialization.*/
- /* EP0 initialization.*/
- usbp->epc[0] = &ep0config;
- usb_lld_init_endpoint(usbp, 0);
- }
- /**
- * @brief Sets the USB address.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- *
- * @notapi
- */
- void usb_lld_set_address(USBDriver *usbp) {
- (void)usbp;
- }
- /**
- * @brief Enables an endpoint.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- *
- * @notapi
- */
- void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) {
- (void)usbp;
- (void)ep;
- }
- /**
- * @brief Disables all the active endpoints except the endpoint zero.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- *
- * @notapi
- */
- void usb_lld_disable_endpoints(USBDriver *usbp) {
- (void)usbp;
- }
- /**
- * @brief Returns the status of an OUT endpoint.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- * @return The endpoint status.
- * @retval EP_STATUS_DISABLED The endpoint is not active.
- * @retval EP_STATUS_STALLED The endpoint is stalled.
- * @retval EP_STATUS_ACTIVE The endpoint is active.
- *
- * @notapi
- */
- usbepstatus_t usb_lld_get_status_out(USBDriver *usbp, usbep_t ep) {
- (void)usbp;
- (void)ep;
- return EP_STATUS_DISABLED;
- }
- /**
- * @brief Returns the status of an IN endpoint.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- * @return The endpoint status.
- * @retval EP_STATUS_DISABLED The endpoint is not active.
- * @retval EP_STATUS_STALLED The endpoint is stalled.
- * @retval EP_STATUS_ACTIVE The endpoint is active.
- *
- * @notapi
- */
- usbepstatus_t usb_lld_get_status_in(USBDriver *usbp, usbep_t ep) {
- (void)usbp;
- (void)ep;
- return EP_STATUS_DISABLED;
- }
- /**
- * @brief Reads a setup packet from the dedicated packet buffer.
- * @details This function must be invoked in the context of the @p setup_cb
- * callback in order to read the received setup packet.
- * @pre In order to use this function the endpoint must have been
- * initialized as a control endpoint.
- * @post The endpoint is ready to accept another packet.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- * @param[out] buf buffer where to copy the packet data
- *
- * @notapi
- */
- void usb_lld_read_setup(USBDriver *usbp, usbep_t ep, uint8_t *buf) {
- (void)usbp;
- (void)ep;
- (void)buf;
- }
- /**
- * @brief Prepares for a receive operation.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- *
- * @notapi
- */
- void usb_lld_prepare_receive(USBDriver *usbp, usbep_t ep) {
- (void)usbp;
- (void)ep;
- }
- /**
- * @brief Prepares for a transmit operation.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- *
- * @notapi
- */
- void usb_lld_prepare_transmit(USBDriver *usbp, usbep_t ep) {
- (void)usbp;
- (void)ep;
- }
- /**
- * @brief Starts a receive operation on an OUT endpoint.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- *
- * @notapi
- */
- void usb_lld_start_out(USBDriver *usbp, usbep_t ep) {
- (void)usbp;
- (void)ep;
- }
- /**
- * @brief Starts a transmit operation on an IN endpoint.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- *
- * @notapi
- */
- void usb_lld_start_in(USBDriver *usbp, usbep_t ep) {
- (void)usbp;
- (void)ep;
- }
- /**
- * @brief Brings an OUT endpoint in the stalled state.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- *
- * @notapi
- */
- void usb_lld_stall_out(USBDriver *usbp, usbep_t ep) {
- (void)usbp;
- (void)ep;
- }
- /**
- * @brief Brings an IN endpoint in the stalled state.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- *
- * @notapi
- */
- void usb_lld_stall_in(USBDriver *usbp, usbep_t ep) {
- (void)usbp;
- (void)ep;
- }
- /**
- * @brief Brings an OUT endpoint in the active state.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- *
- * @notapi
- */
- void usb_lld_clear_out(USBDriver *usbp, usbep_t ep) {
- (void)usbp;
- (void)ep;
- }
- /**
- * @brief Brings an IN endpoint in the active state.
- *
- * @param[in] usbp pointer to the @p USBDriver object
- * @param[in] ep endpoint number
- *
- * @notapi
- */
- void usb_lld_clear_in(USBDriver *usbp, usbep_t ep) {
- (void)usbp;
- (void)ep;
- }
- #endif /* HAL_USE_USB == TRUE */
- /** @} */
|