Flexio_Uart_Ip.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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 FLEXIO_UART_IP_H
  25. #define FLEXIO_UART_IP_H
  26. /**
  27. * @file
  28. * @defgroup flexio_uart_ip Flexio UART IPL
  29. * @addtogroup flexio_uart_ip Flexio UART IPL
  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 "Flexio_Uart_Ip_Cfg.h"
  42. #include "Mcal.h"
  43. /*==================================================================================================
  44. * SOURCE FILE VERSION INFORMATION
  45. ==================================================================================================*/
  46. #define FLEXIO_UART_IP_VENDOR_ID 43
  47. #define FLEXIO_UART_IP_AR_RELEASE_MAJOR_VERSION 4
  48. #define FLEXIO_UART_IP_AR_RELEASE_MINOR_VERSION 4
  49. #define FLEXIO_UART_IP_AR_RELEASE_REVISION_VERSION 0
  50. #define FLEXIO_UART_IP_SW_MAJOR_VERSION 1
  51. #define FLEXIO_UART_IP_SW_MINOR_VERSION 0
  52. #define FLEXIO_UART_IP_SW_PATCH_VERSION 0
  53. /*==================================================================================================
  54. * FILE VERSION CHECKS
  55. ==================================================================================================*/
  56. /* Checks against Flexio_Uart_Ip_Cfg.h */
  57. #if (FLEXIO_UART_IP_VENDOR_ID != FLEXIO_UART_IP_CFG_VENDOR_ID)
  58. #error "Flexio_Uart_Ip.h and Flexio_Uart_Ip_Cfg.h have different vendor ids"
  59. #endif
  60. #if ((FLEXIO_UART_IP_AR_RELEASE_MAJOR_VERSION != FLEXIO_UART_IP_CFG_AR_RELEASE_MAJOR_VERSION) || \
  61. (FLEXIO_UART_IP_AR_RELEASE_MINOR_VERSION != FLEXIO_UART_IP_CFG_AR_RELEASE_MINOR_VERSION) || \
  62. (FLEXIO_UART_IP_AR_RELEASE_REVISION_VERSION != FLEXIO_UART_IP_CFG_AR_RELEASE_REVISION_VERSION))
  63. #error "AUTOSAR Version Numbers of Flexio_Uart_Ip.h and Flexio_Uart_Ip_Cfg.h are different"
  64. #endif
  65. #if ((FLEXIO_UART_IP_SW_MAJOR_VERSION != FLEXIO_UART_IP_CFG_SW_MAJOR_VERSION) || \
  66. (FLEXIO_UART_IP_SW_MINOR_VERSION != FLEXIO_UART_IP_CFG_SW_MINOR_VERSION) || \
  67. (FLEXIO_UART_IP_SW_PATCH_VERSION != FLEXIO_UART_IP_CFG_SW_PATCH_VERSION))
  68. #error "Software Version Numbers of Flexio_Uart_Ip.h and Flexio_Uart_Ip_Cfg.h are different"
  69. #endif
  70. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  71. /* Checks against Mcal.h */
  72. #if ((FLEXIO_UART_IP_AR_RELEASE_MAJOR_VERSION != MCAL_AR_RELEASE_MAJOR_VERSION) || \
  73. (FLEXIO_UART_IP_AR_RELEASE_MINOR_VERSION != MCAL_AR_RELEASE_MINOR_VERSION))
  74. #error "AUTOSAR Version Numbers of Flexio_Uart_Ip.h and Mcal.h are different"
  75. #endif
  76. #endif
  77. #if (FLEXIO_UART_IP_IS_USING == STD_ON)
  78. /*==================================================================================================
  79. * CONSTANTS
  80. ==================================================================================================*/
  81. #define UART_START_SEC_CONFIG_DATA_UNSPECIFIED
  82. #include "Uart_MemMap.h"
  83. /* Calling the external Configuration symbols defined by FlexIO_Uart_Ip_Cfg.h */
  84. FLEXIO_UART_IP_CONFIG_EXT
  85. #define UART_STOP_SEC_CONFIG_DATA_UNSPECIFIED
  86. #include "Uart_MemMap.h"
  87. /*==================================================================================================
  88. * DEFINES AND MACROS
  89. ==================================================================================================*/
  90. /*==================================================================================================
  91. * ENUMS
  92. ==================================================================================================*/
  93. /*==================================================================================================
  94. * STRUCTURES AND OTHER TYPEDEFS
  95. ==================================================================================================*/
  96. /*==================================================================================================
  97. * GLOBAL VARIABLE DECLARATIONS
  98. ==================================================================================================*/
  99. /*==================================================================================================
  100. * FUNCTION PROTOTYPES
  101. ==================================================================================================*/
  102. #define UART_START_SEC_CODE
  103. #include "Uart_MemMap.h"
  104. /*!
  105. * @brief Initializes an Flexio UART operation channel.
  106. *
  107. * The caller provides memory for the driver state structures during initialization.
  108. * The user must select the Flexio UART clock source in the application to initialize the Flexio UART.
  109. *
  110. * @param Channel FLEXIO peripheral channel number
  111. * @param UserConfig Pointer to the Flexio over Uart user configuration structure.
  112. * @return void
  113. */
  114. void Flexio_Uart_Ip_Init(const uint8 Channel,
  115. const Flexio_Uart_Ip_UserConfigType * UserConfig);
  116. /*!
  117. * @brief Shuts down the Flexio UART by disabling interrupts and transmitter/receiver.
  118. *
  119. * @param Channel FLEXIO peripheral channel number
  120. * @return void
  121. */
  122. void Flexio_Uart_Ip_Deinit(const uint8 Channel);
  123. /*!
  124. * @brief Returns the Flexio UART baud rate.
  125. *
  126. * This function returns the Flexio UART configured baud rate.
  127. *
  128. * @param Channel FLEXIO peripheral channel number
  129. * @param[out] BaudRate Pointer to location where the baudrate value will be provided
  130. */
  131. void Flexio_Uart_Ip_GetBaudRate(const uint8 Channel, uint32 * BaudRate);
  132. /*!
  133. * @brief Configures the Flexio Uart baud rate.
  134. *
  135. * This function configures the Flexio Uart baud rate.
  136. * In some Flexio Uart channels the user must disable the transmitter/receiver
  137. * before calling this function.
  138. * Generally, this may be applied to all Flexio Uarts to ensure safe operation.
  139. *
  140. * @param Channel Flexio Uart channel number.
  141. * @param DesiredBaudrate Flexio Uart desired baud rate.
  142. * @param ClockFrequency Clock Frequency of Flexio Uart channel.
  143. * @return FLEXIO_UART_IP_STATUS_BUSY if called during an on-going transfer, FLEXIO_UART_IP_STATUS_SUCCESS otherwise
  144. */
  145. Flexio_Uart_Ip_StatusType Flexio_Uart_Ip_SetBaudRate(const uint8 Channel,
  146. const Flexio_Uart_Ip_BaudrateType DesiredBaudrate,
  147. const uint32 ClockFrequency);
  148. /*!
  149. * @brief Perform a Asynchronous UART transmission
  150. *
  151. * This function sends a block of data and returns immediately.
  152. * The rest of the transmission is handled by the interrupt service routine (if the driver
  153. * is initialized in interrupt mode)
  154. *
  155. * @param Channel FLEXIO peripheral channel number
  156. * @param TxBuff pointer to the data to be transferred
  157. * @param TxSize length in bytes of the data to be transferred
  158. * @return Error or success status returned by API
  159. */
  160. Flexio_Uart_Ip_StatusType Flexio_Uart_Ip_AsyncSend(const uint8 Channel,
  161. const uint8 * TxBuff,
  162. const uint32 TxSize);
  163. /*!
  164. * @brief Transfer multiple bytes of data using polling method.
  165. * @param Channel FLEXIO peripheral channel number
  166. * @param TxBuff pointer to the data to be transferred
  167. * @param TxSize length in bytes of the data to be transferred
  168. * @param Timeout value in microseconds.
  169. * @return Error or success status returned by API
  170. */
  171. Flexio_Uart_Ip_StatusType Flexio_Uart_Ip_SyncSend(const uint8 Channel,
  172. const uint8 * TxBuff,
  173. const uint32 TxSize,
  174. const uint32 Timeout);
  175. /*!
  176. * @brief Perform a Asynchronous UART reception
  177. *
  178. * This function receives a block of data and returns immediately.
  179. * The rest of the transmission is handled by the interrupt service routine (if the driver
  180. * is initialized in interrupt mode) or by the Flexio_Uart_Ip_GetStatus() function (if
  181. * the driver is initialized in polling mode).
  182. *
  183. * @param Channel FLEXIO peripheral channel number
  184. * @param RxBuff source buffer containing 8-bit data chars to receive
  185. * @param RxSize the number of bytes to receive
  186. * @return Error or success status returned by API
  187. */
  188. Flexio_Uart_Ip_StatusType Flexio_Uart_Ip_AsyncReceive(const uint8 Channel,
  189. uint8 * RxBuff,
  190. const uint32 RxSize);
  191. /*!
  192. * @brief Receive multiple bytes of data using polling method.
  193. *
  194. * This function receives a block of data and returns immediately.
  195. * The rest of the transmission is handled by the Flexio_Uart_Ip_GetStatus() function to initialized in polling mode.
  196. *
  197. * @param Channel FLEXIO peripheral channel number
  198. * @param RxBuff buffer pointer where the bytes will be received
  199. * @param RxSize size of data need to be sent in unit of byte
  200. * @param Timeout timeout value in microsecond
  201. * @return Error or success status returned by API
  202. */
  203. Flexio_Uart_Ip_StatusType Flexio_Uart_Ip_SyncReceive(const uint8 Channel,
  204. uint8 * RxBuff,
  205. const uint32 RxSize,
  206. const uint32 Timeout);
  207. /*FUNCTION**********************************************************************
  208. *
  209. * Function Name : Flexio_Uart_Ip_GetStatus
  210. * Description : Get the status of the current non-blocking UART transaction
  211. * Implements : Flexio_Uart_Ip_GetStatus_Activity
  212. *
  213. *END**************************************************************************/
  214. Flexio_Uart_Ip_StatusType Flexio_Uart_Ip_GetStatus(const uint8 Channel, uint32 *BytesRemaining);
  215. /*FUNCTION**********************************************************************
  216. *
  217. * Function Name : Flexio_Uart_Ip_CompleteSendUsingDma
  218. * Description : Finish up a transmit by completing the process of sending
  219. * data and disabling the DMA requests. This is a callback for DMA major loop
  220. * completion, so it must match the DMA callback signature.
  221. *
  222. *END**************************************************************************/
  223. void Flexio_Uart_Ip_CompleteSendUsingDma(uint8 Channel);
  224. /**
  225. * @internal
  226. * @brief : Finish up a receive by completing the process of receiving data
  227. * and disabling the DMA requests. This is a part of callback for DMA major loop
  228. * completion, so it must match the DMA callback signature.
  229. * @param Channel Flexio channel number
  230. * @return void
  231. */
  232. void Flexio_Uart_Ip_CompleteReceiveUsingDma(uint8 Channel);
  233. /*FUNCTION**********************************************************************
  234. *
  235. * Function Name : Flexio_Uart_Ip_AbortTransferData
  236. * Description : This function terminates an non-blocking FLEXIO transmission
  237. * early. During a non-blocking FLEXIO transmission, the user has the option to
  238. * terminate the transmission early if the transmission is still in progress.
  239. *
  240. * Implements : Flexio_Uart_Ip_AbortTransferData_Activity
  241. *END**************************************************************************/
  242. Flexio_Uart_Ip_StatusType Flexio_Uart_Ip_AbortTransferData(const uint8 Channel);
  243. /*!
  244. * @brief Sets the internal driver reference to the tx buffer.
  245. *
  246. * This function can be called from the tx callback to provide the driver
  247. * with a new buffer, for continuous transmission.
  248. *
  249. * @param Channel Flexio Uart channel number
  250. * @param TxData source buffer containing 8-bit data chars to send
  251. * @param TxSize the number of bytes to send
  252. * @return FLEXIO_UART_IP_STATUS_SUCCESS
  253. */
  254. Flexio_Uart_Ip_StatusType Flexio_Uart_Ip_SetTxBuffer(const uint8 Channel,
  255. const uint8 * TxData,
  256. const uint32 TxSize);
  257. /*!
  258. * @brief Sets the internal driver reference to the rx buffer.
  259. *
  260. * This function can be called from the rx callback to provide the driver
  261. * with a new buffer, for continuous reception.
  262. *
  263. * @param Channel FLEXIO channel number
  264. * @param RxData destination buffer containing 8-bit data chars to receive
  265. * @param RxSize the number of bytes to receive
  266. * @return FLEXIO_UART_IP_STATUS_SUCCESS
  267. */
  268. Flexio_Uart_Ip_StatusType Flexio_Uart_Ip_SetRxBuffer(const uint8 Channel,
  269. uint8 * RxData,
  270. const uint32 RxSize);
  271. #define UART_STOP_SEC_CODE
  272. #include "Uart_MemMap.h"
  273. #endif /* (FLEXIO_UART_IP_IS_USING == STD_ON) */
  274. #if defined(__cplusplus)
  275. }
  276. #endif
  277. /*! @}*/
  278. #endif /* FLEXIO_UART_IP_H */