mbed(SerialHalfDuplex入り)

Fork of mbed by mbed official

Committer:
yusuke_kyo
Date:
Wed Apr 08 08:04:18 2015 +0000
Revision:
98:01a414ca7d6d
Parent:
86:04dd9b1680ae
remove SerialHalfDuplex.h

Who changed what in which revision?

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