You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

326 lines
18 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f0xx_hal_smartcard_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of SMARTCARD HAL Extended module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F0xx_HAL_SMARTCARD_EX_H
  37. #define __STM32F0xx_HAL_SMARTCARD_EX_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. #if !defined(STM32F030x6) && !defined(STM32F030x8) && !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC)
  42. /* Includes ------------------------------------------------------------------*/
  43. #include "stm32f0xx_hal_def.h"
  44. /** @addtogroup STM32F0xx_HAL_Driver
  45. * @{
  46. */
  47. /** @addtogroup SMARTCARDEx
  48. * @{
  49. */
  50. /* Exported types ------------------------------------------------------------*/
  51. /* Exported constants --------------------------------------------------------*/
  52. /* Exported macros -----------------------------------------------------------*/
  53. /* Private macros ------------------------------------------------------------*/
  54. /** @defgroup SMARTCARDEx_Private_Macros SMARTCARD Extended Private Macros
  55. * @{
  56. */
  57. /** @brief Report the SMARTCARD clock source.
  58. * @param __HANDLE__ specifies the SMARTCARD Handle.
  59. * @param __CLOCKSOURCE__ output variable.
  60. * @retval the SMARTCARD clocking source, written in __CLOCKSOURCE__.
  61. */
  62. #if defined(STM32F031x6) || defined(STM32F038xx)
  63. #define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
  64. do { \
  65. switch(__HAL_RCC_GET_USART1_SOURCE()) \
  66. { \
  67. case RCC_USART1CLKSOURCE_PCLK1: \
  68. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  69. break; \
  70. case RCC_USART1CLKSOURCE_HSI: \
  71. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
  72. break; \
  73. case RCC_USART1CLKSOURCE_SYSCLK: \
  74. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
  75. break; \
  76. case RCC_USART1CLKSOURCE_LSE: \
  77. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
  78. break; \
  79. default: \
  80. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
  81. break; \
  82. } \
  83. } while(0)
  84. #elif defined (STM32F030x8) || \
  85. defined (STM32F042x6) || defined (STM32F048xx) || \
  86. defined (STM32F051x8) || defined (STM32F058xx)
  87. #define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
  88. do { \
  89. if((__HANDLE__)->Instance == USART1) \
  90. { \
  91. switch(__HAL_RCC_GET_USART1_SOURCE()) \
  92. { \
  93. case RCC_USART1CLKSOURCE_PCLK1: \
  94. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  95. break; \
  96. case RCC_USART1CLKSOURCE_HSI: \
  97. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
  98. break; \
  99. case RCC_USART1CLKSOURCE_SYSCLK: \
  100. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
  101. break; \
  102. case RCC_USART1CLKSOURCE_LSE: \
  103. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
  104. break; \
  105. default: \
  106. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
  107. break; \
  108. } \
  109. } \
  110. else if((__HANDLE__)->Instance == USART2) \
  111. { \
  112. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  113. } \
  114. else \
  115. { \
  116. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
  117. } \
  118. } while(0)
  119. #elif defined(STM32F071xB) || defined(STM32F072xB) || defined(STM32F078xx)
  120. #define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
  121. do { \
  122. if((__HANDLE__)->Instance == USART1) \
  123. { \
  124. switch(__HAL_RCC_GET_USART1_SOURCE()) \
  125. { \
  126. case RCC_USART1CLKSOURCE_PCLK1: \
  127. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  128. break; \
  129. case RCC_USART1CLKSOURCE_HSI: \
  130. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
  131. break; \
  132. case RCC_USART1CLKSOURCE_SYSCLK: \
  133. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
  134. break; \
  135. case RCC_USART1CLKSOURCE_LSE: \
  136. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
  137. break; \
  138. default: \
  139. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
  140. break; \
  141. } \
  142. } \
  143. else if((__HANDLE__)->Instance == USART2) \
  144. { \
  145. switch(__HAL_RCC_GET_USART2_SOURCE()) \
  146. { \
  147. case RCC_USART2CLKSOURCE_PCLK1: \
  148. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  149. break; \
  150. case RCC_USART2CLKSOURCE_HSI: \
  151. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
  152. break; \
  153. case RCC_USART2CLKSOURCE_SYSCLK: \
  154. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
  155. break; \
  156. case RCC_USART2CLKSOURCE_LSE: \
  157. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
  158. break; \
  159. default: \
  160. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
  161. break; \
  162. } \
  163. } \
  164. else if((__HANDLE__)->Instance == USART3) \
  165. { \
  166. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  167. } \
  168. else if((__HANDLE__)->Instance == USART4) \
  169. { \
  170. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  171. } \
  172. else \
  173. { \
  174. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
  175. } \
  176. } while(0)
  177. #elif defined(STM32F091xC) || defined(STM32F098xx)
  178. #define SMARTCARD_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
  179. do { \
  180. if((__HANDLE__)->Instance == USART1) \
  181. { \
  182. switch(__HAL_RCC_GET_USART1_SOURCE()) \
  183. { \
  184. case RCC_USART1CLKSOURCE_PCLK1: \
  185. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  186. break; \
  187. case RCC_USART1CLKSOURCE_HSI: \
  188. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
  189. break; \
  190. case RCC_USART1CLKSOURCE_SYSCLK: \
  191. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
  192. break; \
  193. case RCC_USART1CLKSOURCE_LSE: \
  194. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
  195. break; \
  196. default: \
  197. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
  198. break; \
  199. } \
  200. } \
  201. else if((__HANDLE__)->Instance == USART2) \
  202. { \
  203. switch(__HAL_RCC_GET_USART2_SOURCE()) \
  204. { \
  205. case RCC_USART2CLKSOURCE_PCLK1: \
  206. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  207. break; \
  208. case RCC_USART2CLKSOURCE_HSI: \
  209. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
  210. break; \
  211. case RCC_USART2CLKSOURCE_SYSCLK: \
  212. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
  213. break; \
  214. case RCC_USART2CLKSOURCE_LSE: \
  215. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
  216. break; \
  217. default: \
  218. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
  219. break; \
  220. } \
  221. } \
  222. else if((__HANDLE__)->Instance == USART3) \
  223. { \
  224. switch(__HAL_RCC_GET_USART3_SOURCE()) \
  225. { \
  226. case RCC_USART3CLKSOURCE_PCLK1: \
  227. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  228. break; \
  229. case RCC_USART3CLKSOURCE_HSI: \
  230. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_HSI; \
  231. break; \
  232. case RCC_USART3CLKSOURCE_SYSCLK: \
  233. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_SYSCLK; \
  234. break; \
  235. case RCC_USART3CLKSOURCE_LSE: \
  236. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_LSE; \
  237. break; \
  238. default: \
  239. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
  240. break; \
  241. } \
  242. } \
  243. else if((__HANDLE__)->Instance == USART4) \
  244. { \
  245. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  246. } \
  247. else if((__HANDLE__)->Instance == USART5) \
  248. { \
  249. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  250. } \
  251. else if((__HANDLE__)->Instance == USART6) \
  252. { \
  253. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  254. } \
  255. else if((__HANDLE__)->Instance == USART7) \
  256. { \
  257. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  258. } \
  259. else if((__HANDLE__)->Instance == USART8) \
  260. { \
  261. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_PCLK1; \
  262. } \
  263. else \
  264. { \
  265. (__CLOCKSOURCE__) = SMARTCARD_CLOCKSOURCE_UNDEFINED; \
  266. } \
  267. } while(0)
  268. #endif /* defined(STM32F031x6) || defined(STM32F038xx) */
  269. /**
  270. * @}
  271. */
  272. /* Exported functions --------------------------------------------------------*/
  273. /** @addtogroup SMARTCARDEx_Exported_Functions
  274. * @{
  275. */
  276. /* Initialization and de-initialization functions ****************************/
  277. /* IO operation methods *******************************************************/
  278. /** @addtogroup SMARTCARDEx_Exported_Functions_Group1
  279. * @{
  280. */
  281. /* Peripheral Control functions ***********************************************/
  282. void HAL_SMARTCARDEx_BlockLength_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint8_t BlockLength);
  283. void HAL_SMARTCARDEx_TimeOut_Config(SMARTCARD_HandleTypeDef *hsmartcard, uint32_t TimeOutValue);
  284. HAL_StatusTypeDef HAL_SMARTCARDEx_EnableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard);
  285. HAL_StatusTypeDef HAL_SMARTCARDEx_DisableReceiverTimeOut(SMARTCARD_HandleTypeDef *hsmartcard);
  286. /**
  287. * @}
  288. */
  289. /**
  290. * @}
  291. */
  292. /**
  293. * @}
  294. */
  295. /**
  296. * @}
  297. */
  298. #endif /* !defined(STM32F030x6) && !defined(STM32F030x8)&& !defined(STM32F070x6) && !defined(STM32F070xB) && !defined(STM32F030xC) */
  299. #ifdef __cplusplus
  300. }
  301. #endif
  302. #endif /* __STM32F0xx_HAL_SMARTCARD_EX_H */
  303. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/