mbed library sources

Dependents:   Marvino mbot

Fork of mbed-src by mbed official

Committer:
jaerts
Date:
Tue Dec 22 13:22:16 2015 +0000
Revision:
637:ed69428d4850
Parent:
610:813dcc80987e
Add very shady LPC1768 CAN Filter implementation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 610:813dcc80987e 1 /**
mbed_official 610:813dcc80987e 2 ******************************************************************************
mbed_official 610:813dcc80987e 3 * @file stm32l4xx_hal_hcd.h
mbed_official 610:813dcc80987e 4 * @author MCD Application Team
mbed_official 610:813dcc80987e 5 * @version V1.0.0
mbed_official 610:813dcc80987e 6 * @date 26-June-2015
mbed_official 610:813dcc80987e 7 * @brief Header file of HCD HAL module.
mbed_official 610:813dcc80987e 8 ******************************************************************************
mbed_official 610:813dcc80987e 9 * @attention
mbed_official 610:813dcc80987e 10 *
mbed_official 610:813dcc80987e 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
mbed_official 610:813dcc80987e 12 *
mbed_official 610:813dcc80987e 13 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 610:813dcc80987e 14 * are permitted provided that the following conditions are met:
mbed_official 610:813dcc80987e 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 610:813dcc80987e 16 * this list of conditions and the following disclaimer.
mbed_official 610:813dcc80987e 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 610:813dcc80987e 18 * this list of conditions and the following disclaimer in the documentation
mbed_official 610:813dcc80987e 19 * and/or other materials provided with the distribution.
mbed_official 610:813dcc80987e 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 610:813dcc80987e 21 * may be used to endorse or promote products derived from this software
mbed_official 610:813dcc80987e 22 * without specific prior written permission.
mbed_official 610:813dcc80987e 23 *
mbed_official 610:813dcc80987e 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 610:813dcc80987e 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 610:813dcc80987e 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 610:813dcc80987e 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 610:813dcc80987e 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 610:813dcc80987e 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 610:813dcc80987e 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 610:813dcc80987e 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 610:813dcc80987e 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 610:813dcc80987e 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 610:813dcc80987e 34 *
mbed_official 610:813dcc80987e 35 ******************************************************************************
mbed_official 610:813dcc80987e 36 */
mbed_official 610:813dcc80987e 37
mbed_official 610:813dcc80987e 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 610:813dcc80987e 39 #ifndef __STM32L4xx_HAL_HCD_H
mbed_official 610:813dcc80987e 40 #define __STM32L4xx_HAL_HCD_H
mbed_official 610:813dcc80987e 41
mbed_official 610:813dcc80987e 42 #ifdef __cplusplus
mbed_official 610:813dcc80987e 43 extern "C" {
mbed_official 610:813dcc80987e 44 #endif
mbed_official 610:813dcc80987e 45
mbed_official 610:813dcc80987e 46 #if defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)
mbed_official 610:813dcc80987e 47
mbed_official 610:813dcc80987e 48 /* Includes ------------------------------------------------------------------*/
mbed_official 610:813dcc80987e 49 #include "stm32l4xx_ll_usb.h"
mbed_official 610:813dcc80987e 50
mbed_official 610:813dcc80987e 51 /** @addtogroup STM32L4xx_HAL_Driver
mbed_official 610:813dcc80987e 52 * @{
mbed_official 610:813dcc80987e 53 */
mbed_official 610:813dcc80987e 54
mbed_official 610:813dcc80987e 55 /** @addtogroup HCD
mbed_official 610:813dcc80987e 56 * @{
mbed_official 610:813dcc80987e 57 */
mbed_official 610:813dcc80987e 58
mbed_official 610:813dcc80987e 59 /* Exported types ------------------------------------------------------------*/
mbed_official 610:813dcc80987e 60 /** @defgroup HCD_Exported_Types HCD Exported Types
mbed_official 610:813dcc80987e 61 * @{
mbed_official 610:813dcc80987e 62 */
mbed_official 610:813dcc80987e 63
mbed_official 610:813dcc80987e 64 /** @defgroup HCD_Exported_Types_Group1 HCD State Structure definition
mbed_official 610:813dcc80987e 65 * @{
mbed_official 610:813dcc80987e 66 */
mbed_official 610:813dcc80987e 67 typedef enum
mbed_official 610:813dcc80987e 68 {
mbed_official 610:813dcc80987e 69 HAL_HCD_STATE_RESET = 0x00,
mbed_official 610:813dcc80987e 70 HAL_HCD_STATE_READY = 0x01,
mbed_official 610:813dcc80987e 71 HAL_HCD_STATE_ERROR = 0x02,
mbed_official 610:813dcc80987e 72 HAL_HCD_STATE_BUSY = 0x03,
mbed_official 610:813dcc80987e 73 HAL_HCD_STATE_TIMEOUT = 0x04
mbed_official 610:813dcc80987e 74 } HCD_StateTypeDef;
mbed_official 610:813dcc80987e 75
mbed_official 610:813dcc80987e 76 typedef USB_OTG_GlobalTypeDef HCD_TypeDef;
mbed_official 610:813dcc80987e 77 typedef USB_OTG_CfgTypeDef HCD_InitTypeDef;
mbed_official 610:813dcc80987e 78 typedef USB_OTG_HCTypeDef HCD_HCTypeDef ;
mbed_official 610:813dcc80987e 79 typedef USB_OTG_URBStateTypeDef HCD_URBStateTypeDef ;
mbed_official 610:813dcc80987e 80 typedef USB_OTG_HCStateTypeDef HCD_HCStateTypeDef ;
mbed_official 610:813dcc80987e 81 /**
mbed_official 610:813dcc80987e 82 * @}
mbed_official 610:813dcc80987e 83 */
mbed_official 610:813dcc80987e 84
mbed_official 610:813dcc80987e 85 /** @defgroup HCD_Exported_Types_Group2 HCD Handle Structure definition
mbed_official 610:813dcc80987e 86 * @{
mbed_official 610:813dcc80987e 87 */
mbed_official 610:813dcc80987e 88 typedef struct
mbed_official 610:813dcc80987e 89 {
mbed_official 610:813dcc80987e 90 HCD_TypeDef *Instance; /*!< Register base address */
mbed_official 610:813dcc80987e 91 HCD_InitTypeDef Init; /*!< HCD required parameters */
mbed_official 610:813dcc80987e 92 HCD_HCTypeDef hc[15]; /*!< Host channels parameters */
mbed_official 610:813dcc80987e 93 HAL_LockTypeDef Lock; /*!< HCD peripheral status */
mbed_official 610:813dcc80987e 94 __IO HCD_StateTypeDef State; /*!< HCD communication state */
mbed_official 610:813dcc80987e 95 void *pData; /*!< Pointer Stack Handler */
mbed_official 610:813dcc80987e 96
mbed_official 610:813dcc80987e 97 } HCD_HandleTypeDef;
mbed_official 610:813dcc80987e 98 /**
mbed_official 610:813dcc80987e 99 * @}
mbed_official 610:813dcc80987e 100 */
mbed_official 610:813dcc80987e 101
mbed_official 610:813dcc80987e 102 /**
mbed_official 610:813dcc80987e 103 * @}
mbed_official 610:813dcc80987e 104 */
mbed_official 610:813dcc80987e 105
mbed_official 610:813dcc80987e 106 /* Exported constants --------------------------------------------------------*/
mbed_official 610:813dcc80987e 107 /** @defgroup HCD_Exported_Constants HCD Exported Constants
mbed_official 610:813dcc80987e 108 * @{
mbed_official 610:813dcc80987e 109 */
mbed_official 610:813dcc80987e 110
mbed_official 610:813dcc80987e 111 /** @defgroup HCD_Speed HCD Speed
mbed_official 610:813dcc80987e 112 * @{
mbed_official 610:813dcc80987e 113 */
mbed_official 610:813dcc80987e 114 #define HCD_SPEED_HIGH 0
mbed_official 610:813dcc80987e 115 #define HCD_SPEED_LOW 2
mbed_official 610:813dcc80987e 116 #define HCD_SPEED_FULL 3
mbed_official 610:813dcc80987e 117 /**
mbed_official 610:813dcc80987e 118 * @}
mbed_official 610:813dcc80987e 119 */
mbed_official 610:813dcc80987e 120
mbed_official 610:813dcc80987e 121 /** @defgroup HCD_PHY_Module HCD PHY Module
mbed_official 610:813dcc80987e 122 * @{
mbed_official 610:813dcc80987e 123 */
mbed_official 610:813dcc80987e 124 #define HCD_PHY_EMBEDDED 1
mbed_official 610:813dcc80987e 125 /**
mbed_official 610:813dcc80987e 126 * @}
mbed_official 610:813dcc80987e 127 */
mbed_official 610:813dcc80987e 128
mbed_official 610:813dcc80987e 129 /**
mbed_official 610:813dcc80987e 130 * @}
mbed_official 610:813dcc80987e 131 */
mbed_official 610:813dcc80987e 132
mbed_official 610:813dcc80987e 133 /* Exported macro ------------------------------------------------------------*/
mbed_official 610:813dcc80987e 134 /** @defgroup HCD_Exported_Macros HCD Exported Macros
mbed_official 610:813dcc80987e 135 * @brief macros to handle interrupts and specific clock configurations
mbed_official 610:813dcc80987e 136 * @{
mbed_official 610:813dcc80987e 137 */
mbed_official 610:813dcc80987e 138 #define __HAL_HCD_ENABLE(__HANDLE__) USB_EnableGlobalInt ((__HANDLE__)->Instance)
mbed_official 610:813dcc80987e 139 #define __HAL_HCD_DISABLE(__HANDLE__) USB_DisableGlobalInt ((__HANDLE__)->Instance)
mbed_official 610:813dcc80987e 140
mbed_official 610:813dcc80987e 141 #define __HAL_HCD_GET_FLAG(__HANDLE__, __INTERRUPT__) ((USB_ReadInterrupts((__HANDLE__)->Instance) & (__INTERRUPT__)) == (__INTERRUPT__))
mbed_official 610:813dcc80987e 142 #define __HAL_HCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->GINTSTS) = (__INTERRUPT__))
mbed_official 610:813dcc80987e 143 #define __HAL_HCD_IS_INVALID_INTERRUPT(__HANDLE__) (USB_ReadInterrupts((__HANDLE__)->Instance) == 0)
mbed_official 610:813dcc80987e 144
mbed_official 610:813dcc80987e 145 #define __HAL_HCD_CLEAR_HC_INT(chnum, __INTERRUPT__) (USBx_HC(chnum)->HCINT = (__INTERRUPT__))
mbed_official 610:813dcc80987e 146 #define __HAL_HCD_MASK_HALT_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK &= ~USB_OTG_HCINTMSK_CHHM)
mbed_official 610:813dcc80987e 147 #define __HAL_HCD_UNMASK_HALT_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK |= USB_OTG_HCINTMSK_CHHM)
mbed_official 610:813dcc80987e 148 #define __HAL_HCD_MASK_ACK_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK &= ~USB_OTG_HCINTMSK_ACKM)
mbed_official 610:813dcc80987e 149 #define __HAL_HCD_UNMASK_ACK_HC_INT(chnum) (USBx_HC(chnum)->HCINTMSK |= USB_OTG_HCINTMSK_ACKM)
mbed_official 610:813dcc80987e 150 /**
mbed_official 610:813dcc80987e 151 * @}
mbed_official 610:813dcc80987e 152 */
mbed_official 610:813dcc80987e 153
mbed_official 610:813dcc80987e 154 /* Exported functions --------------------------------------------------------*/
mbed_official 610:813dcc80987e 155 /** @addtogroup HCD_Exported_Functions HCD Exported Functions
mbed_official 610:813dcc80987e 156 * @{
mbed_official 610:813dcc80987e 157 */
mbed_official 610:813dcc80987e 158
mbed_official 610:813dcc80987e 159 /* Initialization/de-initialization functions ********************************/
mbed_official 610:813dcc80987e 160 /** @addtogroup HCD_Exported_Functions_Group1 Initialization and de-initialization functions
mbed_official 610:813dcc80987e 161 * @{
mbed_official 610:813dcc80987e 162 */
mbed_official 610:813dcc80987e 163 HAL_StatusTypeDef HAL_HCD_Init(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 164 HAL_StatusTypeDef HAL_HCD_DeInit (HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 165 HAL_StatusTypeDef HAL_HCD_HC_Init(HCD_HandleTypeDef *hhcd,
mbed_official 610:813dcc80987e 166 uint8_t ch_num,
mbed_official 610:813dcc80987e 167 uint8_t epnum,
mbed_official 610:813dcc80987e 168 uint8_t dev_address,
mbed_official 610:813dcc80987e 169 uint8_t speed,
mbed_official 610:813dcc80987e 170 uint8_t ep_type,
mbed_official 610:813dcc80987e 171 uint16_t mps);
mbed_official 610:813dcc80987e 172
mbed_official 610:813dcc80987e 173 HAL_StatusTypeDef HAL_HCD_HC_Halt(HCD_HandleTypeDef *hhcd,
mbed_official 610:813dcc80987e 174 uint8_t ch_num);
mbed_official 610:813dcc80987e 175
mbed_official 610:813dcc80987e 176 void HAL_HCD_MspInit(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 177 void HAL_HCD_MspDeInit(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 178 /**
mbed_official 610:813dcc80987e 179 * @}
mbed_official 610:813dcc80987e 180 */
mbed_official 610:813dcc80987e 181
mbed_official 610:813dcc80987e 182 /* I/O operation functions ***************************************************/
mbed_official 610:813dcc80987e 183 /** @addtogroup HCD_Exported_Functions_Group2 Input and Output operation functions
mbed_official 610:813dcc80987e 184 * @{
mbed_official 610:813dcc80987e 185 */
mbed_official 610:813dcc80987e 186 HAL_StatusTypeDef HAL_HCD_HC_SubmitRequest(HCD_HandleTypeDef *hhcd,
mbed_official 610:813dcc80987e 187 uint8_t pipe,
mbed_official 610:813dcc80987e 188 uint8_t direction ,
mbed_official 610:813dcc80987e 189 uint8_t ep_type,
mbed_official 610:813dcc80987e 190 uint8_t token,
mbed_official 610:813dcc80987e 191 uint8_t* pbuff,
mbed_official 610:813dcc80987e 192 uint16_t length,
mbed_official 610:813dcc80987e 193 uint8_t do_ping);
mbed_official 610:813dcc80987e 194
mbed_official 610:813dcc80987e 195 /* Non-Blocking mode: Interrupt */
mbed_official 610:813dcc80987e 196 void HAL_HCD_IRQHandler(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 197 void HAL_HCD_SOF_Callback(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 198 void HAL_HCD_Connect_Callback(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 199 void HAL_HCD_Disconnect_Callback(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 200 void HAL_HCD_HC_NotifyURBChange_Callback(HCD_HandleTypeDef *hhcd,
mbed_official 610:813dcc80987e 201 uint8_t chnum,
mbed_official 610:813dcc80987e 202 HCD_URBStateTypeDef urb_state);
mbed_official 610:813dcc80987e 203 /**
mbed_official 610:813dcc80987e 204 * @}
mbed_official 610:813dcc80987e 205 */
mbed_official 610:813dcc80987e 206
mbed_official 610:813dcc80987e 207 /* Peripheral Control functions **********************************************/
mbed_official 610:813dcc80987e 208 /** @addtogroup HCD_Exported_Functions_Group3 Peripheral Control functions
mbed_official 610:813dcc80987e 209 * @{
mbed_official 610:813dcc80987e 210 */
mbed_official 610:813dcc80987e 211 HAL_StatusTypeDef HAL_HCD_ResetPort(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 212 HAL_StatusTypeDef HAL_HCD_Start(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 213 HAL_StatusTypeDef HAL_HCD_Stop(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 214 /**
mbed_official 610:813dcc80987e 215 * @}
mbed_official 610:813dcc80987e 216 */
mbed_official 610:813dcc80987e 217
mbed_official 610:813dcc80987e 218 /* Peripheral State functions ************************************************/
mbed_official 610:813dcc80987e 219 /** @addtogroup HCD_Exported_Functions_Group4 Peripheral State functions
mbed_official 610:813dcc80987e 220 * @{
mbed_official 610:813dcc80987e 221 */
mbed_official 610:813dcc80987e 222 HCD_StateTypeDef HAL_HCD_GetState(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 223 HCD_URBStateTypeDef HAL_HCD_HC_GetURBState(HCD_HandleTypeDef *hhcd, uint8_t chnum);
mbed_official 610:813dcc80987e 224 uint32_t HAL_HCD_HC_GetXferCount(HCD_HandleTypeDef *hhcd, uint8_t chnum);
mbed_official 610:813dcc80987e 225 HCD_HCStateTypeDef HAL_HCD_HC_GetState(HCD_HandleTypeDef *hhcd, uint8_t chnum);
mbed_official 610:813dcc80987e 226 uint32_t HAL_HCD_GetCurrentFrame(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 227 uint32_t HAL_HCD_GetCurrentSpeed(HCD_HandleTypeDef *hhcd);
mbed_official 610:813dcc80987e 228 /**
mbed_official 610:813dcc80987e 229 * @}
mbed_official 610:813dcc80987e 230 */
mbed_official 610:813dcc80987e 231
mbed_official 610:813dcc80987e 232 /**
mbed_official 610:813dcc80987e 233 * @}
mbed_official 610:813dcc80987e 234 */
mbed_official 610:813dcc80987e 235
mbed_official 610:813dcc80987e 236 /* Private macros ------------------------------------------------------------*/
mbed_official 610:813dcc80987e 237 /** @defgroup HCD_Private_Macros HCD Private Macros
mbed_official 610:813dcc80987e 238 * @{
mbed_official 610:813dcc80987e 239 */
mbed_official 610:813dcc80987e 240
mbed_official 610:813dcc80987e 241 /**
mbed_official 610:813dcc80987e 242 * @}
mbed_official 610:813dcc80987e 243 */
mbed_official 610:813dcc80987e 244
mbed_official 610:813dcc80987e 245 /**
mbed_official 610:813dcc80987e 246 * @}
mbed_official 610:813dcc80987e 247 */
mbed_official 610:813dcc80987e 248
mbed_official 610:813dcc80987e 249 /**
mbed_official 610:813dcc80987e 250 * @}
mbed_official 610:813dcc80987e 251 */
mbed_official 610:813dcc80987e 252
mbed_official 610:813dcc80987e 253 #endif /* STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx */
mbed_official 610:813dcc80987e 254
mbed_official 610:813dcc80987e 255 #ifdef __cplusplus
mbed_official 610:813dcc80987e 256 }
mbed_official 610:813dcc80987e 257 #endif
mbed_official 610:813dcc80987e 258
mbed_official 610:813dcc80987e 259 #endif /* __STM32L4xx_HAL_HCD_H */
mbed_official 610:813dcc80987e 260
mbed_official 610:813dcc80987e 261 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/