Uart_Types.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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_TYPES_H
  25. #define UART_TYPES_H
  26. /**
  27. * @file
  28. * @defgroup uart_driver UART Driver
  29. * @addtogroup uart_driver UART Driver
  30. * @{
  31. */
  32. #ifdef __cplusplus
  33. extern "C"
  34. {
  35. #endif
  36. /*==================================================================================================
  37. * INCLUDE FILES
  38. * 1) system and project includes
  39. * 2) needed interfaces from external units
  40. * 3) internal and external interfaces from this unit
  41. ==================================================================================================*/
  42. #include "Uart_Defines.h"
  43. #include "Uart_Ipw_Types.h"
  44. /*==================================================================================================
  45. * SOURCE FILE VERSION INFORMATION
  46. ==================================================================================================*/
  47. #define UART_TYPES_VENDOR_ID 43
  48. #define UART_TYPES_AR_RELEASE_MAJOR_VERSION 4
  49. #define UART_TYPES_AR_RELEASE_MINOR_VERSION 4
  50. #define UART_TYPES_AR_RELEASE_REVISION_VERSION 0
  51. #define UART_TYPES_SW_MAJOR_VERSION 1
  52. #define UART_TYPES_SW_MINOR_VERSION 0
  53. #define UART_TYPES_SW_PATCH_VERSION 0
  54. /*==================================================================================================
  55. * FILE VERSION CHECKS
  56. ==================================================================================================*/
  57. /*Checks against Uart_Defines.h */
  58. #if (UART_TYPES_VENDOR_ID != UART_DEFINES_VENDOR_ID_CFG)
  59. #error "Uart_Types.h and Uart_Defines.h have different vendor ids"
  60. #endif
  61. #if ((UART_TYPES_AR_RELEASE_MAJOR_VERSION != UART_DEFINES_AR_RELEASE_MAJOR_VERSION_CFG) || \
  62. (UART_TYPES_AR_RELEASE_MINOR_VERSION != UART_DEFINES_AR_RELEASE_MINOR_VERSION_CFG) || \
  63. (UART_TYPES_AR_RELEASE_REVISION_VERSION!= UART_DEFINES_AR_RELEASE_REVISION_VERSION_CFG))
  64. #error "AUTOSAR Version Numbers of Uart_Types.h and Uart_Defines.h are different"
  65. #endif
  66. #if ((UART_TYPES_SW_MAJOR_VERSION!= UART_DEFINES_SW_MAJOR_VERSION_CFG) || \
  67. (UART_TYPES_SW_MINOR_VERSION!= UART_DEFINES_SW_MINOR_VERSION_CFG) || \
  68. (UART_TYPES_SW_PATCH_VERSION!= UART_DEFINES_SW_PATCH_VERSION_CFG) \
  69. )
  70. #error "Software Version Numbers of Uart_Types.h and Uart_Defines.h are different"
  71. #endif
  72. /*Checks against Uart_Ipw_Types.h */
  73. #if (UART_TYPES_VENDOR_ID != UART_IPW_TYPES_VENDOR_ID)
  74. #error "Uart_Types.h and Uart_Ipw_Types.h have different vendor ids"
  75. #endif
  76. #if ((UART_TYPES_AR_RELEASE_MAJOR_VERSION != UART_IPW_TYPES_AR_RELEASE_MAJOR_VERSION) || \
  77. (UART_TYPES_AR_RELEASE_MINOR_VERSION != UART_IPW_TYPES_AR_RELEASE_MINOR_VERSION) || \
  78. (UART_TYPES_AR_RELEASE_REVISION_VERSION!= UART_IPW_TYPES_AR_RELEASE_REVISION_VERSION))
  79. #error "AUTOSAR Version Numbers of Uart_Types.h and Uart_Ipw_Types.h are different"
  80. #endif
  81. #if ((UART_TYPES_SW_MAJOR_VERSION!= UART_IPW_TYPES_SW_MAJOR_VERSION) || \
  82. (UART_TYPES_SW_MINOR_VERSION!= UART_IPW_TYPES_SW_MINOR_VERSION) || \
  83. (UART_TYPES_SW_PATCH_VERSION!= UART_IPW_TYPES_SW_PATCH_VERSION) \
  84. )
  85. #error "Software Version Numbers of Uart_Types.h and Uart_Ipw_Types.h are different"
  86. #endif
  87. /*==================================================================================================
  88. * CONSTANTS
  89. ==================================================================================================*/
  90. /*==================================================================================================
  91. * DEFINES AND MACROS
  92. ==================================================================================================*/
  93. /*==================================================================================================
  94. * ENUMS
  95. ==================================================================================================*/
  96. #if ((UART_DEV_ERROR_DETECT == STD_ON) || (UART_RUNTIME_ERROR_DETECT == STD_ON))
  97. /**
  98. * @brief Driver not initialized
  99. * @details Errors reported by Det_ReportError() and Det_ReportRuntimeError().
  100. *
  101. */
  102. #define UART_E_UNINIT ((uint8)0x01U)
  103. /**
  104. * @brief Invalid channel given as parameter
  105. * @details Errors reported by Det_ReportError() and Det_ReportRuntimeError().
  106. *
  107. */
  108. #define UART_E_INVALID_CHANNEL ((uint8)0x02U)
  109. /**
  110. * @brief Invalid channel given as parameter
  111. * @details Errors reported by Det_ReportError() and Det_ReportRuntimeError().
  112. *
  113. */
  114. #define UART_E_INVALID_POINTER ((uint8)0x03U)
  115. /**
  116. * @brief Driver already initialized
  117. * @details Errors reported by Det_ReportError() and Det_ReportRuntimeError().
  118. *
  119. */
  120. #define UART_E_ALREADY_INITIALIZED ((uint8)0x04U)
  121. /**
  122. * @brief Invalid coreid
  123. *
  124. */
  125. #define UART_E_PARAM_CONFIG ((uint8)0x05U)
  126. /**
  127. * @brief Channel is busy, therefore the service can not be executed
  128. * @details Errors reported by Det_ReportError() and Det_ReportRuntimeError().
  129. *
  130. */
  131. #define UART_E_CHANNEL_BUSY ((uint8)0x06U)
  132. /**
  133. * @brief Parameter has a wrong value
  134. * @details Errors reported by Det_ReportError() and Det_ReportRuntimeError().
  135. *
  136. */
  137. #define UART_E_INVALID_PARAMETER ((uint8)0x07U)
  138. /**
  139. * @brief Timeout occured
  140. * @details Errors reported by Det_ReportError() and Det_ReportRuntimeError().
  141. *
  142. */
  143. #define UART_E_TIMEOUT ((uint8)0x08U)
  144. /**
  145. * @brief Invalid pointer for init function parameter
  146. * @details Errors reported by Det_ReportError() and Det_ReportRuntimeError().
  147. *
  148. */
  149. #define UART_E_INIT_FAILED ((uint8)0x09U)
  150. /**< @brief API service ID for UART_Init() function
  151. * @details Parameters used when raising an error or exception.
  152. *
  153. */
  154. #define UART_INIT_ID ((uint8)0x00U)
  155. /**
  156. * @brief API service ID for UART_DeInit() function
  157. * @details Parameters used when raising an error or exception.
  158. *
  159. */
  160. #define UART_DEINIT_ID ((uint8)0x01U)
  161. /**
  162. * @brief API service ID for UART_SetBaudrate() function
  163. * @details Parameters used when raising an error or exception.
  164. *
  165. */
  166. #define UART_SETBAUDRATE_ID ((uint8)0x02U)
  167. /**
  168. * @brief API service ID for UART_GetBaudrate() function
  169. * @details Parameters used when raising an error or exception.
  170. *
  171. */
  172. #define UART_GETBAUDRATE_ID ((uint8)0x03U)
  173. /**
  174. * @brief API service ID for UART_SyncSend() function
  175. * @details Parameters used when raising an error or exception.
  176. *
  177. */
  178. #define UART_SYNCSEND_ID ((uint8)0x04U)
  179. /**
  180. * @brief API service ID for UART_AsyncReceive() function
  181. * @details Parameters used when raising an error or exception.
  182. *
  183. */
  184. #define UART_ASYNCSEND_ID ((uint8)0x05U)
  185. /**
  186. * @brief API service ID for UART_SyncReceive() function
  187. * @details Parameters used when raising an error or exception.
  188. *
  189. */
  190. #define UART_SYNCRECEIVE_ID ((uint8)0x06U)
  191. /**
  192. * @brief API service ID for UART_AsyncSend() function
  193. * @details Parameters used when raising an error or exception.
  194. *
  195. */
  196. #define UART_ASYNCRECEIVE_ID ((uint8)0x07U)
  197. /**
  198. * @brief API service ID for UART_Abort() function
  199. * @details Parameters used when raising an error or exception.
  200. *
  201. */
  202. #define UART_ABORT_ID ((uint8)0x08U)
  203. /**
  204. * @brief API service ID for UART_GetStatus() function
  205. * @details Parameters used when raising an error or exception.
  206. *
  207. */
  208. #define UART_GETSTATUS_ID ((uint8)0x09U)
  209. /**
  210. * @brief API service ID for Uart_GetVersionInfo() function
  211. * @details Parameters used when raising an error or exception.
  212. *
  213. */
  214. #define UART_VERSIONINFO_ID ((uint8)0x0AU)
  215. /**
  216. * @brief API service ID for UART_SetBuffer() function
  217. * @details Parameters used when raising an error or exception.
  218. *
  219. */
  220. #define UART_SETBUFFER_ID ((uint8)0x0BU)
  221. #endif /*EV_ERROR_DETECT == STD_ON) || (UART_RUNTIME_ERROR_DETECT == STD_ON)) */
  222. /**
  223. * @brief Driver initialization status.
  224. * @details This enum contains the values for the driver initialization status.
  225. */
  226. typedef enum
  227. {
  228. UART_DRV_UNINIT = 0U, /**< @brief Driver not initialized */
  229. UART_DRV_INIT , /**< @brief Driver ready */
  230. }
  231. Uart_DrvStatusType;
  232. /**
  233. * @brief The type operation of an Uart channel.
  234. */
  235. /* implements Uart_DataDirectionType_enum */
  236. typedef enum
  237. {
  238. UART_SEND = (uint8)0x00U, /**< @brief The sending operation */
  239. UART_RECEIVE = (uint8)0x01U /**< @brief The receiving operation */
  240. } Uart_DataDirectionType;
  241. /**
  242. * @brief Uart operation status type
  243. */
  244. typedef enum
  245. {
  246. UART_STATUS_NO_ERROR = 0x00, /**< @brief Uart operation is successfull */
  247. UART_STATUS_OPERATION_ONGOING = 0x01, /**< @brief Uart operation on going */
  248. UART_STATUS_ABORTED = 0x02, /**< @brief Uart operation aborted */
  249. UART_STATUS_FRAMING_ERROR = 0x03, /**< @brief Uart framing error */
  250. UART_STATUS_RX_OVERRUN_ERROR = 0x04, /**< @brief Uart overrun error */
  251. UART_STATUS_PARITY_ERROR = 0x05, /**< @brief Uart parity error */
  252. UART_STATUS_TIMEOUT = 0x06, /**< @brief Uart operation has timeout */
  253. UART_STATUS_NOISE_ERROR = 0x07, /**< @brief Uart noise error */
  254. UART_STATUS_DMA_ERROR = 0x08, /**< @brief Uart Dma Error error */
  255. } Uart_StatusType;
  256. /*==================================================================================================
  257. * STRUCTURES AND OTHER TYPEDEFS
  258. ==================================================================================================*/
  259. /**
  260. * @brief Uart channel configuration type structure.
  261. * @details This is the type of the external data structure containing
  262. * the overall initialization data for one Uart Channel.
  263. * A pointer to such a structure is provided to the Uart channel
  264. * initialization routine for configuration of the Uart hardware
  265. * channel.
  266. *
  267. *
  268. */
  269. /* implements Uart_ChannelConfigType_structure */
  270. typedef struct
  271. {
  272. uint8 UartChannelId; /**< @brief Uart channel configured */
  273. #if (UART_MULTICORE_SUPPORT == STD_ON)
  274. uint32 ChannelCoreId; /**< @brief Core id on which the Uart channel has been assigned */
  275. #endif
  276. uint32 ChannelClockFrequency; /**< @brief The clock frequency configured on the given channel */
  277. const Uart_Ipw_HwConfigType* UartChannelConfig; /**< @brief Pointer to a lower level channel configuration */
  278. } Uart_ChannelConfigType;
  279. /**
  280. * @brief Uart driver configuration type structure.
  281. * @details This is the type of the pointer to the external data
  282. * Uart Channels.
  283. * A pointer of such a structure is provided to the Uart driver
  284. * initialization routine for configuration of the Uart hardware
  285. * channel.
  286. *
  287. *
  288. *
  289. */
  290. /* implements Uart_ConfigType_structure */
  291. typedef struct
  292. {
  293. #if (UART_MULTICORE_SUPPORT == STD_ON)
  294. uint32 PartitionCoreId; /**< @brief Partition configured of the core */
  295. #endif
  296. /**
  297. * @brief Hardware channel.
  298. * @details Constant pointer of the constant external data
  299. * structure containing the overall initialization data
  300. * for all the configured Uart Channels.
  301. */
  302. const Uart_ChannelConfigType *Configs[UART_CH_MAX_CONFIG];
  303. } Uart_ConfigType;
  304. /*==================================================================================================
  305. * GLOBAL VARIABLE DECLARATIONS
  306. ==================================================================================================*/
  307. /*==================================================================================================
  308. * FUNCTION PROTOTYPES
  309. ==================================================================================================*/
  310. #ifdef __cplusplus
  311. }
  312. #endif
  313. /** @} */
  314. #endif /* UART_Types_H */