Uart_Ipw.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : FLEXIO
  5. * Dependencies :
  6. *
  7. * Autosar Version : 4.4.0
  8. * Autosar Revision : ASR_REL_4_4_REV_0000
  9. * Autosar Conf.Variant :
  10. * SW Version : 1.0.0
  11. * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
  12. *
  13. * (c) Copyright 2020-2021 NXP Semiconductors
  14. * All Rights Reserved.
  15. *
  16. * NXP Confidential. This software is owned or controlled by NXP and may only be
  17. * used strictly in accordance with the applicable license terms. By expressly
  18. * accepting such terms or by downloading, installing, activating and/or otherwise
  19. * using the software, you are agreeing that you have read, and that you agree to
  20. * comply with and are bound by, such license terms. If you do not agree to be
  21. * bound by the applicable license terms, then you may not retain, install,
  22. * activate or otherwise use the software.
  23. ==================================================================================================*/
  24. #ifndef UART_IPW_H
  25. #define UART_IPW_H
  26. /**
  27. * @file
  28. * @internal
  29. * @addtogroup UART_IPW_DRIVER
  30. * @{
  31. */
  32. #ifdef __cplusplus
  33. extern "C"{
  34. #endif
  35. /*==================================================================================================
  36. * INCLUDE FILES
  37. * 1) system and project includes
  38. * 2) needed interfaces from external units
  39. * 3) internal and external interfaces from this unit
  40. ==================================================================================================*/
  41. #include "Uart_Ipw_Types.h"
  42. #include "Uart_Defines.h"
  43. #include "Uart_Types.h"
  44. /*==================================================================================================
  45. * SOURCE FILE VERSION INFORMATION
  46. ==================================================================================================*/
  47. #define UART_IPW_VENDOR_ID 43
  48. #define UART_IPW_AR_RELEASE_MAJOR_VERSION 4
  49. #define UART_IPW_AR_RELEASE_MINOR_VERSION 4
  50. #define UART_IPW_AR_RELEASE_REVISION_VERSION 0
  51. #define UART_IPW_SW_MAJOR_VERSION 1
  52. #define UART_IPW_SW_MINOR_VERSION 0
  53. #define UART_IPW_SW_PATCH_VERSION 0
  54. /*==================================================================================================
  55. * FILE VERSION CHECKS
  56. ==================================================================================================*/
  57. /*Checks against Uart_Ipw_Types.h */
  58. #if (UART_IPW_VENDOR_ID!= UART_IPW_TYPES_VENDOR_ID)
  59. #error "Uart_Ipw.h and Uart_Ipw_Types.h have different vendor ids"
  60. #endif
  61. #if ((UART_IPW_AR_RELEASE_MAJOR_VERSION != UART_IPW_TYPES_AR_RELEASE_MAJOR_VERSION) || \
  62. (UART_IPW_AR_RELEASE_MINOR_VERSION != UART_IPW_TYPES_AR_RELEASE_MINOR_VERSION) || \
  63. (UART_IPW_AR_RELEASE_REVISION_VERSION!= UART_IPW_TYPES_AR_RELEASE_REVISION_VERSION))
  64. #error "AUTOSAR Version Numbers of Uart_Ipw.h and Uart_Ipw_Types.h are different"
  65. #endif
  66. #if ((UART_IPW_SW_MAJOR_VERSION!= UART_IPW_TYPES_SW_MAJOR_VERSION) || \
  67. (UART_IPW_SW_MINOR_VERSION!= UART_IPW_TYPES_SW_MINOR_VERSION) || \
  68. (UART_IPW_SW_PATCH_VERSION!= UART_IPW_TYPES_SW_PATCH_VERSION) \
  69. )
  70. #error "Software Version Numbers of Uart_Ipw.h and Uart_Ipw_Types.h are different"
  71. #endif
  72. /*Checks against Uart_Types.h */
  73. #if (UART_IPW_VENDOR_ID!= UART_TYPES_VENDOR_ID)
  74. #error "Uart_Ipw.h and Uart_Types.h have different vendor ids"
  75. #endif
  76. #if ((UART_IPW_AR_RELEASE_MAJOR_VERSION != UART_TYPES_AR_RELEASE_MAJOR_VERSION) || \
  77. (UART_IPW_AR_RELEASE_MINOR_VERSION != UART_TYPES_AR_RELEASE_MINOR_VERSION) || \
  78. (UART_IPW_AR_RELEASE_REVISION_VERSION!= UART_TYPES_AR_RELEASE_REVISION_VERSION))
  79. #error "AUTOSAR Version Numbers of Uart_Ipw.h and Uart_Types.h are different"
  80. #endif
  81. #if ((UART_IPW_SW_MAJOR_VERSION!= UART_TYPES_SW_MAJOR_VERSION) || \
  82. (UART_IPW_SW_MINOR_VERSION!= UART_TYPES_SW_MINOR_VERSION) || \
  83. (UART_IPW_SW_PATCH_VERSION!= UART_TYPES_SW_PATCH_VERSION) \
  84. )
  85. #error "Software Version Numbers of Uart_Ipw.h and Uart_Types.h are different"
  86. #endif
  87. /* Checks against Uart_Defines.h */
  88. #if (UART_IPW_VENDOR_ID != UART_DEFINES_VENDOR_ID_CFG)
  89. #error "Uart_Ipw.h and Uart_Defines.h have different vendor ids"
  90. #endif
  91. #if (( UART_IPW_AR_RELEASE_MAJOR_VERSION != UART_DEFINES_AR_RELEASE_MAJOR_VERSION_CFG) || \
  92. ( UART_IPW_AR_RELEASE_MINOR_VERSION != UART_DEFINES_AR_RELEASE_MINOR_VERSION_CFG) || \
  93. ( UART_IPW_AR_RELEASE_REVISION_VERSION != UART_DEFINES_AR_RELEASE_REVISION_VERSION_CFG))
  94. #error "AutoSar Version Numbers of Uart_Ipw.h and Uart_Defines.h are different"
  95. #endif
  96. /* Check if current file and Uart_Defines.h header file are of the same Software version */
  97. #if (( UART_IPW_SW_MAJOR_VERSION != UART_DEFINES_SW_MAJOR_VERSION_CFG) || \
  98. ( UART_IPW_SW_MINOR_VERSION != UART_DEFINES_SW_MINOR_VERSION_CFG) || \
  99. ( UART_IPW_SW_PATCH_VERSION != UART_DEFINES_SW_PATCH_VERSION_CFG) )
  100. #error "Software Version Numbers of Uart_Ipw.h and Uart_Defines.h are different"
  101. #endif
  102. /*==================================================================================================
  103. * CONSTANTS
  104. ==================================================================================================*/
  105. /*==================================================================================================
  106. * DEFINES AND MACROS
  107. ==================================================================================================*/
  108. /*==================================================================================================
  109. * ENUMS
  110. ==================================================================================================*/
  111. /*==================================================================================================
  112. * STRUCTURES AND OTHER TYPEDEFS
  113. ==================================================================================================*/
  114. /*==================================================================================================
  115. * GLOBAL VARIABLE DECLARATIONS
  116. ==================================================================================================*/
  117. /*==================================================================================================
  118. * FUNCTION PROTOTYPES
  119. ==================================================================================================*/
  120. #define UART_START_SEC_CODE
  121. #include "Uart_MemMap.h"
  122. /**
  123. * @internal
  124. * @brief Initialize an Uart channel.
  125. * @details This function calls a LLD function initializes all hardware registers needed to
  126. * start the Uart functionality on the selected channel.
  127. *
  128. * @param [in] Channel Uart channel to be initialized.
  129. * [in] Config Configuration pointer containing hardware specific settings.
  130. *
  131. * @return void.
  132. *
  133. */
  134. void Uart_Ipw_Init(uint8 Channel, const Uart_Ipw_HwConfigType* Config);
  135. /**
  136. * @internal
  137. * @brief De-initialize an Uart channel.
  138. * @details This function calls a LLD function de-initializes an Uart Hw instance and resets the current
  139. information regarding the current channel
  140. *
  141. * @param[in] Channel Uart channel to be de-initialized.
  142. *
  143. * @return void.
  144. *
  145. */
  146. void Uart_Ipw_Deinit(uint8 Channel);
  147. /**
  148. * @internal
  149. * @brief Retrieves the baudrate value configured for the current channel.
  150. * @details This function calls a LLD function returns the baudrate value configured for the given channel
  151. * via a pointer parameter provided by user.
  152. *
  153. * @param[in] Channel Uart channel where the baudrate shall be configured
  154. * @param[out] BaudrateValue The pointer which will contain the baudrate value.
  155. *
  156. * @return void
  157. *
  158. */
  159. void Uart_Ipw_GetBaudrate(uint8 Channel, uint32* BaudrateValue);
  160. /**
  161. * @internal
  162. * @brief Set a baudrate value for the current channel.
  163. * @details This function calls a LLD function which sets a baudrate value for a given channel,
  164. *
  165. * @param[in] Channel Uart channel where the baudrate shall be configured
  166. * @param[in] BaudRateValue The baudrate value to be configured.
  167. * @param[in] ClockFrequency The clock frequency set for the Uart module.
  168. *
  169. * @return E_OK: Baud rate successfully configured
  170. * E_NOT_OK: Baud rate wasn't successfully configured
  171. *
  172. */
  173. Std_ReturnType Uart_Ipw_SetBaudrate(uint8 Channel, Uart_BaudrateType BaudRateValue, uint32 ClockFrequency);
  174. /**
  175. * @internal
  176. * @brief Aborts an on-going reception.
  177. * @details This function calls a LLD function which ends a reception earlier.
  178. *
  179. * @param[in] Channel Uart channel where the reception shall be ended.
  180. *
  181. * @return E_OK: The reception ended successfully
  182. * E_NOT_OK: The reception didn't end successfully
  183. *
  184. */
  185. Std_ReturnType Uart_Ipw_AbortReceivingData(uint8 Channel);
  186. /**
  187. * @internal
  188. * @brief Aborts an on-going transmission.
  189. * @details This function calls a LLD function which ends a transfer earlier.
  190. *
  191. * @param[in] Channel Uart channel where the transmission shall be ended.
  192. *
  193. * @return E_OK: The transfer ended successfully
  194. * E_NOT_OK: The transfer didn't end successfully
  195. *
  196. */
  197. Std_ReturnType Uart_Ipw_AbortSendingData(uint8 Channel);
  198. /**
  199. * @internal
  200. * @brief Sets a tx buffer.
  201. * @details This function calls a LLD function which sets a buffer for continuos transmission.
  202. *
  203. * @param[in] Channel Uart channel where to set the buffer.
  204. *
  205. * @return void
  206. */
  207. void Uart_Ipw_SetTxBuffer(uint8 Channel, const uint8 *Buffer, uint32 BufferSize);
  208. /**
  209. * @internal
  210. * @brief Sets a rx buffer.
  211. * @details This function calls a LLD function which sets a buffer for continuos reception.
  212. *
  213. * @param[in] Channel Uart channel where to set the buffer.
  214. *
  215. * @return void
  216. */
  217. void Uart_Ipw_SetRxBuffer(uint8 Channel, uint8 *Buffer, uint32 BufferSize);
  218. /**
  219. * @internal
  220. * @brief Sends a buffer synchronously.
  221. * @details This function calls a LLD function which sends BufferSize bytes using polling method.
  222. *
  223. * @param[in] Channel Uart channel used for transmission.
  224. * @param[in] Buffer Buffer to send.
  225. * @param[in] BufferSize The number of bytes to send.
  226. * @param[in] Timeout The timeout value in us.
  227. *
  228. *
  229. * @return E_OK: Tranmission ended successfully
  230. * UART_STATUS_TIMEOUT: Tranmission has timeout
  231. */
  232. Std_ReturnType Uart_Ipw_SyncSend(uint8 Channel, const uint8* Buffer, uint32 BufferSize, uint32 Timeout);
  233. /**
  234. * @internal
  235. * @brief Receives a buffer synchronously.
  236. * @details This function calls a LLD function which receives BufferSize bytes using polling method.
  237. *
  238. * @param[in] Channel Uart channel used for reception.
  239. * @param[in] Buffer Buffer to receive.
  240. * @param[in] BufferSize The number of bytes to receive.
  241. * @param[in] Timeout The timeout value in us.
  242. *
  243. *
  244. * @return E_OK: Reception ended successfully
  245. * E_NOT_OK: Reception didn't end successfully
  246. * UART_STATUS_TIMEOUT: Reception has timeout
  247. */
  248. Std_ReturnType Uart_Ipw_SyncReceive(uint8 Channel, uint8* Buffer, uint32 BufferSize, uint32 Timeout);
  249. /**
  250. * @internal
  251. * @brief Receives a buffer asynchronously.
  252. * @details This function calls a LLD function which receives BufferSize bytes using an asynchornous method.
  253. *
  254. * @param[in] Channel Uart channel used for reception.
  255. * @param[in] Buffer Buffer to receive.
  256. * @param[in] BufferSize The number of bytes to receive.
  257. *
  258. *
  259. * @return E_OK: Reception started successfully
  260. E_NOT_OK: Reception didn't start successfully
  261. */
  262. Std_ReturnType Uart_Ipw_AsyncReceive(uint8 Channel, uint8 *Buffer, uint32 BufferSize);
  263. /**
  264. * @internal
  265. * @brief Sends a buffer asynchronously.
  266. * @details This function calls a LLD function which sends BufferSize bytes using an asynchornous method.
  267. *
  268. * @param[in] Channel Uart channel used for transmission.
  269. * @param[in] Buffer Buffer to send.
  270. * @param[in] BufferSize The number of bytes to send.
  271. *
  272. *
  273. * @return E_OK: Transmission started successfully
  274. E_NOT_OK: Transmission didn't start successfully
  275. */
  276. Std_ReturnType Uart_Ipw_AsyncSend(uint8 Channel, const uint8 *Buffer, uint32 BufferSize);
  277. /**
  278. * @internal
  279. * @brief Retrieves the status of the previous transfer.
  280. * @details This function calls a LLD function which retrieves the status of the previous transfer
  281. * and the number of the remaining bytes to send.
  282. *
  283. * @param[in] Channel Uart channel.
  284. * @param[out] BytesRemaining The pointer where to write the number of remaining bytes
  285. *
  286. *
  287. * @return UART_NO_ERR0R: The previous transfer ended successfully
  288. UART_STATUS_OPERATION_ONGOING The transfer is still on going
  289. UART_STATUS_ABORTED The previous transfer was aborted
  290. UART_STATUS_TIMEOUT The previous transfer was timeout
  291. */
  292. Uart_StatusType Uart_Ipw_GetTransmitStatus(uint8 Channel, uint32 *BytesRemaining);
  293. /**
  294. * @internal
  295. * @brief Retrieves the status of the previous reception.
  296. * @details This function calls a LLD function which retrieves the status of the previous reception
  297. * and the number of the remaining bytes to receive.
  298. *
  299. * @param[in] Channel Uart channel.
  300. * @param[out] BytesRemaining The pointer where to write the number of remaining bytes
  301. *
  302. *
  303. * @return UART_NO_ERR0R: The previous transfer ended successfully
  304. UART_STATUS_OPERATION_ONGOING The reception is still on going
  305. UART_STATUS_ABORTED The previous reception was aborted
  306. UART_STATUS_FRAMING_ERROR Uart framing error
  307. UART_STATUS_RX_OVERRUN_ERROR Uart overrun error
  308. UART_STATUS_PARITY_ERROR Uart overrun error
  309. UART_STATUS_TIMEOUT Uart operation has timeout
  310. */
  311. Uart_StatusType Uart_Ipw_GetReceiveStatus(uint8 Channel, uint32 *BytesRemaining);
  312. #define UART_STOP_SEC_CODE
  313. #include "Uart_MemMap.h"
  314. #ifdef __cplusplus
  315. }
  316. #endif
  317. /** @} */
  318. #endif /*UART_IPW_H*/