123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460 |
- /*==================================================================================================
- * Project : RTD AUTOSAR 4.4
- * Platform : CORTEXM
- * Peripheral : FLEXIO
- * Dependencies :
- *
- * Autosar Version : 4.4.0
- * Autosar Revision : ASR_REL_4_4_REV_0000
- * Autosar Conf.Variant :
- * SW Version : 1.0.0
- * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
- *
- * (c) Copyright 2020-2021 NXP Semiconductors
- * All Rights Reserved.
- *
- * NXP Confidential. This software is owned or controlled by NXP and may only be
- * used strictly in accordance with the applicable license terms. By expressly
- * accepting such terms or by downloading, installing, activating and/or otherwise
- * using the software, you are agreeing that you have read, and that you agree to
- * comply with and are bound by, such license terms. If you do not agree to be
- * bound by the applicable license terms, then you may not retain, install,
- * activate or otherwise use the software.
- ==================================================================================================*/
- #ifndef UART_H
- #define UART_H
- /**
- * @file
- *
- * @defgroup uart_driver UART Driver
- * @addtogroup uart_driver UART Driver
- * @{
- */
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- /*==================================================================================================
- * INCLUDE FILES
- * 1) system and project includes
- * 2) needed interfaces from external units
- * 3) internal and external interfaces from this unit
- ==================================================================================================*/
- #include "Mcal.h"
- #include "Uart_Cfg.h"
- #include "Uart_Defines.h"
- #include "Uart_Types.h"
- #include "Uart_Ipw.h"
- /*==================================================================================================
- * SOURCE FILE VERSION INFORMATION
- ==================================================================================================*/
- #define UART_MODULE_ID 255
- #define UART_AR_RELEASE_MAJOR_VERSION 4
- #define UART_AR_RELEASE_MINOR_VERSION 4
- #define UART_AR_RELEASE_REVISION_VERSION 0
- #define UART_SW_MAJOR_VERSION 1
- #define UART_SW_MINOR_VERSION 0
- #define UART_SW_PATCH_VERSION 0
- #define UART_VENDOR_ID 43
- /*==================================================================================================
- FILE VERSION CHECKS
- ==================================================================================================*/
- /*Checks against Uart_Defines.h */
- #if (UART_VENDOR_ID!= UART_DEFINES_VENDOR_ID_CFG)
- #error "Uart.h and Uart_Defines.h have different vendor ids"
- #endif
- #if ((UART_AR_RELEASE_MAJOR_VERSION != UART_DEFINES_AR_RELEASE_MAJOR_VERSION_CFG) || \
- (UART_AR_RELEASE_MINOR_VERSION != UART_DEFINES_AR_RELEASE_MINOR_VERSION_CFG) || \
- (UART_AR_RELEASE_REVISION_VERSION!= UART_DEFINES_AR_RELEASE_REVISION_VERSION_CFG))
- #error "AUTOSAR Version Numbers of Uart.h and Uart_Defines.h are different"
- #endif
- #if ((UART_SW_MAJOR_VERSION!= UART_DEFINES_SW_MAJOR_VERSION_CFG) || \
- (UART_SW_MINOR_VERSION!= UART_DEFINES_SW_MINOR_VERSION_CFG) || \
- (UART_SW_PATCH_VERSION!= UART_DEFINES_SW_PATCH_VERSION_CFG) \
- )
- #error "Software Version Numbers of Uart.h and Uart_Defines.h are different"
- #endif
- /*Checks against Uart_Ipw.h */
- #if (UART_VENDOR_ID!= UART_IPW_VENDOR_ID)
- #error "Uart.h and Uart_Ipw.h have different vendor ids"
- #endif
- #if ((UART_AR_RELEASE_MAJOR_VERSION != UART_IPW_AR_RELEASE_MAJOR_VERSION) || \
- (UART_AR_RELEASE_MINOR_VERSION != UART_IPW_AR_RELEASE_MINOR_VERSION) || \
- (UART_AR_RELEASE_REVISION_VERSION!= UART_IPW_AR_RELEASE_REVISION_VERSION))
- #error "AUTOSAR Version Numbers of Uart.h and Uart_Ipw.h are different"
- #endif
- #if ((UART_SW_MAJOR_VERSION!= UART_IPW_SW_MAJOR_VERSION) || \
- (UART_SW_MINOR_VERSION!= UART_IPW_SW_MINOR_VERSION) || \
- (UART_SW_PATCH_VERSION!= UART_IPW_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of Uart.h and Uart_Ipw.h are different"
- #endif
- /* Checks against Uart_Cfg.h */
- #if (UART_VENDOR_ID != UART_CFG_VENDOR_ID)
- #error "Uart.h and Uart_Cfg.h have different vendor ids"
- #endif
- #if ((UART_AR_RELEASE_MAJOR_VERSION != UART_CFG_AR_RELEASE_MAJOR_VERSION) || \
- (UART_AR_RELEASE_MINOR_VERSION != UART_CFG_AR_RELEASE_MINOR_VERSION) || \
- (UART_AR_RELEASE_REVISION_VERSION!= UART_CFG_AR_RELEASE_REVISION_VERSION))
- #error "AUTOSAR Version Numbers of Uart.h and Uart_Cfg.h are different"
- #endif
- #if ((UART_SW_MAJOR_VERSION!= UART_CFG_SW_MAJOR_VERSION) || \
- (UART_SW_MINOR_VERSION!= UART_CFG_SW_MINOR_VERSION) || \
- (UART_SW_PATCH_VERSION!= UART_CFG_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of Uart.h and Uart_Cfg.h are different"
- #endif
- /* Checks against Uart_Types.h */
- #if (UART_VENDOR_ID != UART_TYPES_VENDOR_ID)
- #error "Uart.h and Uart_Types.h have different vendor ids"
- #endif
- #if ((UART_AR_RELEASE_MAJOR_VERSION != UART_TYPES_AR_RELEASE_MAJOR_VERSION) || \
- (UART_AR_RELEASE_MINOR_VERSION != UART_TYPES_AR_RELEASE_MINOR_VERSION) || \
- (UART_AR_RELEASE_REVISION_VERSION!= UART_TYPES_AR_RELEASE_REVISION_VERSION))
- #error "AUTOSAR Version Numbers of Uart.h and Uart_Types.h are different"
- #endif
- #if ((UART_SW_MAJOR_VERSION!= UART_TYPES_SW_MAJOR_VERSION) || \
- (UART_SW_MINOR_VERSION!= UART_TYPES_SW_MINOR_VERSION) || \
- (UART_SW_PATCH_VERSION!= UART_TYPES_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of Uart.h and Uart_Types.h are different"
- #endif
- #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
- /* Checks against Mcal.h */
- #if ((UART_AR_RELEASE_MAJOR_VERSION != MCAL_AR_RELEASE_MAJOR_VERSION) || \
- (UART_AR_RELEASE_MINOR_VERSION != MCAL_AR_RELEASE_MINOR_VERSION))
- #error "AUTOSAR Version Numbers of Uart.h and Mcal.h are different"
- #endif
- #endif
- /*==================================================================================================
- * CONSTANTS
- ==================================================================================================*/
- /*==================================================================================================
- DEFINES AND MACROS
- ==================================================================================================*/
- /*==================================================================================================
- ENUMS
- ==================================================================================================*/
- /*==================================================================================================
- * STRUCTURES AND OTHER TYPEDEFS
- ==================================================================================================*/
- /*==================================================================================================
- GLOBAL VARIABLE DECLARATIONS
- ==================================================================================================*/
- #define UART_START_SEC_CONFIG_DATA_UNSPECIFIED
- /* @violates @ref Uart_h_REF_1 This violation is not fixed since the inclusion of Uart_MemMap.h is as per AUTOSAR requirement*/
- #include "Uart_MemMap.h"
- #if STD_OFF == UART_PRECOMPILE_SUPPORT
- UART_CONFIG_EXT
- #endif
- #define UART_STOP_SEC_CONFIG_DATA_UNSPECIFIED
- /* @violates @ref Uart_h_REF_1 This violation is not fixed since the inclusion of Uart_MemMap.h is as per AUTOSAR requirement*/
- #include "Uart_MemMap.h"
- /*==================================================================================================
- * FUNCTION PROTOTYPES
- ==================================================================================================*/
- #define UART_START_SEC_CODE
- #include "Uart_MemMap.h"
- /**
- * @brief Initializes the UART module.
- * @details This function performs software initialization of UART
- * driver. It shall configure the Uart hardware peripheral for each channel.
- *
- * @param[in] Config - Pointer to UART driver configuration set.
- *
- * @return void
- *
- * @pre -
- *
- *
- **/
- void Uart_Init(const Uart_ConfigType * Config);
- /**
- * @brief De-initializes the UART module.
- * @details This function performs software de-initialization of UART
- * driver.
- *
- * @param -
- *
- * @return void
- *
- * @pre -
- *
- *
- **/
- void Uart_Deinit(void);
- /**
- * @brief Configures the baud rate for the serial communication.
- * @details This function performs the setting of the communication baudrate provided in the parameter.
- *
- * @param[in] Channel - Uart channel to be addressed.
- * @param[in] Baudrate - Baudrate value to be set.
- *
- * @return Std_ReturnType.
- * @retval E_NOT_OK If the Uart Channel is not valid or
- * Uart driver is not initialized or
- * a transfer is on-going or
- * wrong core is addressed.
- *
- * @retval E_OK Successfull baudrate configuration.
- *
- *
- * @pre Uart_Init function must be called before this API.
- *
- *
- **/
- Std_ReturnType Uart_SetBaudrate(uint8 Channel, Uart_BaudrateType Baudrate);
- /**
- * @brief Retrieves the baud rate which is currently set for the serial communication.
- * @details This function returns via the second parameter the current serial baudrate.
- *
- * @param[in] Channel - Uart channel to be addressed.
- * @param[out] Baudrate - Pointer to a memory location where the baudrate value is returned.
- *
- * @return Std_ReturnType.
- * @retval E_NOT_OK If the Uart Channel is not valid or
- * Uart driver is not initialized or
- * a transfer is on-going or
- * wrong core is addressed or
- * a NULL_PTR pointer has been provided
- *
- * @retval E_OK Successfull baudrate retrieval.
- *
- *
- * @pre Uart_Init function must be called before this API. Otherwise a random value can be returned.
- *
- *
- **/
- Std_ReturnType Uart_GetBaudrate(uint8 Channel, uint32 *Baudrate);
- /**
- * @brief Configures a new buffer for continuous transfers.
- * @details This function can be called inside a notification callback and
- * offers the possibility to change the buffer in order to assure a
- * continuous asynchronous transfer.
- * @param[in] Channel - Uart channel to be addressed.
- * @param[in] Buffer - The new buffer provided.
- * @param[in] BufferSize - The size of the new buffer.
- * @param[in] Direction - This parameter indicates for which type of transmission is the buffer set. Its values are UART_SEND for
- * setting a buffer when the previous buffer is empty and there are more bytes to send and UART_RECEIVE to set
- * a new buffer when the previous buffer is full with received buffer and there is more data to be received.
- *
- * @return Std_ReturnType.
- * @retval E_NOT_OK If the Uart Channel is not valid or
- * Uart driver is not initialized or
- * Buffer is a NULL_PTR or
- * BufferSize is 0, meaning no space has been allocated for the buffer or
- * a wrong core has been accessed
- *
- * @retval E_OK Successfull buffer setting.
- *
- *
- * @pre Uart_Init function must be called before this API.
- *
- *
- **/
- Std_ReturnType Uart_SetBuffer(uint8 Channel, uint8* Buffer, uint32 BufferSize, Uart_DataDirectionType Direction);
- /**
- * @brief Starts a synchronous transfer of bytes.
- * @details This function starts sending a number of bytes in a synchronous manner.
- *
- * @param[in] Channel - Uart channel to be addressed.
- * @param[in] Buffer - The buffer which contains the bytes to be sent.
- * @param[in] BufferSize - The Buffer size.
- * @param[in] Timeout - The timeout in us.
- * @return Std_ReturnType.
- * @retval E_NOT_OK If the Uart Channel is not valid or
- * Uart driver is not initialized or
- * Buffer is a NULL_PTR or
- * BufferSize is 0, meaning no space has been allocated for the buffer or
- * a wrong core has been accessed or
- * a transfer is already on going on the requested channel or
- * timeout occured.
- *
- * @retval E_OK Successful transfer.
- *
- *
- * @pre Uart_Init function must be called before this API.
- *
- *
- **/
- Std_ReturnType Uart_SyncSend(uint8 Channel, const uint8* Buffer, uint32 BufferSize, uint32 Timeout);
- /**
- * @brief Starts a synchronous reception of bytes.
- * @details This function starts receiving a number of bytes in a synchronous manner.
- *
- * @param[in] Channel - Uart channel to be addressed.
- * @param[in] Buffer - The buffer where the bytes will be located.
- * @param[in] BufferSize - The Buffer size.
- * @param[in] Timeout - The timeout in us.
- *
- * @return Std_ReturnType.
- * @retval E_NOT_OK If the Uart Channel is not valid or
- * Uart driver is not initialized or
- * Buffer is a NULL_PTR or
- * BufferSize is 0, meaning no space has been allocated for the buffer or
- * a wrong core has been accessed or
- * a reception is already on going on the requested channel or
- * timeout occured.
- *
- * @retval E_OK Successful reception.
- *
- *
- * @pre Uart_Init function must be called before this API.
- *
- *
- **/
- Std_ReturnType Uart_SyncReceive(uint8 Channel, uint8* Buffer, uint32 BufferSize, uint32 Timeout);
- /**
- * @brief Aborts an on-going transfer.
- * @details This function aborts either a reception or a transmission depending on the last parameter.
- *
- * @param[in] Channel - Uart channel to be addressed.
- * @param[in] TransmissionType - Type of the transfer to be aborted. It can be either UART_SEND or UART_RECEIVE.
- *
- * @return Std_ReturnType.
- * @retval E_NOT_OK If the Uart Channel is not valid or
- * Uart driver is not initialized or
- * a wrong core has been accessed
- *
- * @retval E_OK Successful transfer aborted or in case no transfer was on going.
- *
- *
- * @pre Uart_Init function must be called before this API.
- *
- *
- **/
- Std_ReturnType Uart_Abort(uint8 Channel, Uart_DataDirectionType TransmissionType);
- /**
- * @brief Starts an asynchronous transfer(send) of bytes.
- * @details This function starts sending a number of bytes in an asynchronous manner. The transfer can be performed using
- * either DMA or interrupts depending on the transfer type configured on the addressed channel.
- *
- * @param[in] Channel - Uart channel to be addressed.
- * @param[in] Buffer - The buffer where the data to be sent is located.
- * @param[in] BufferSize - The Buffer size.
- *
- * @return Std_ReturnType.
- * @retval E_NOT_OK If the Uart Channel is not valid or
- * Uart driver is not initialized or
- * Buffer is a NULL_PTR or
- * BufferSize is 0, meaning no space has been allocated for the buffer or
- * a wrong core has been accessed or
- * a transfer(send) is already on going on the requested channel.
- *
- * @retval E_OK The transfer(send) started successfully.
- *
- *
- * @pre Uart_Init function must be called before this API.
- *
- *
- **/
- Std_ReturnType Uart_AsyncSend(uint8 Channel, const uint8* Buffer, uint32 BufferSize);
- /**
- * @brief Starts an asynchronous transfer(receive) of bytes.
- * @details This function starts receiving a number of bytes in an asynchronous manner. The transfer can be performed using
- * either DMA or interrupts depending on the transfer type configured on the addressed channel.
- *
- * @param[in] Channel - Uart channel to be addressed.
- * @param[in] Buffer - The buffer where the data to be received will located.
- * @param[in] BufferSize - The Buffer size.
- *
- * @return Std_ReturnType.
- * @retval E_NOT_OK If the Uart Channel is not valid or
- * Uart driver is not initialized or
- * Buffer is a NULL_PTR or
- * BufferSize is 0, meaning no space has been allocated for the buffer or
- * a wrong core has been accessed or
- * a transfer(receive) is already on going on the requested channel.
- *
- * @retval E_OK The transfer(receive) started successfully.
- *
- *
- * @pre Uart_Init function must be called before this API.
- *
- *
- **/
- Std_ReturnType Uart_AsyncReceive(uint8 Channel, uint8* Buffer, uint32 BufferSize);
- /**
- * @brief Returns the status of the previous transfer.
- * @details This function returns the status of the previous transfer.
- * If there is a transfer in progress, this function will also get the number of remaining bytes at the time the function was called.
- * @param[in] Channel - Uart channel to be addressed.
- * @param[out] BytesTransfered - A pointer where the number of remaining bytes will be written.
- * @param[in] TransferType - The type of trasfer in discussion (UART_SEND or UART_RECEIVE).
- *
- * @return Uart_StatusType.
- * @retval UART_STATUS_NO_ERROR - Operation has ended successfully.
- * @retval UART_STATUS_FRAMING_ERROR - Operation has had a framing error. This status is returned only if the TransferType parameter is RECEIVE.
- * @retval UART_STATUS_RX_OVERRUN_ERROR - Operation has had an overrun error. This status is returned only if the TransferType parameter is RECEIVE.
- * @retval UART_STATUS_PARITY_ERROR - Operation has had a parity error. This status is returned only if the TransferType parameter is RECEIVE.
- * @retval UART_STATUS_OPERATION_ONGOING - Operation has not finished at the moment of function call.
- * @retval UART_STATUS_ABORTED - Operation has been aborted.
- * @retval UART_STATUS_TIMEOUT - Operation has had timeout.
- *
- *
- * @pre Uart_Init function must be called before this API.
- *
- *
- **/
- Uart_StatusType Uart_GetStatus( uint8 Channel, uint32 *BytesTransfered, Uart_DataDirectionType TransferType);
- #if (UART_VERSION_INFO_API == STD_ON)
- /**
- * @brief Returns the version information of this module.
- * @details The version information includes:
- *
- * - Two bytes for the Vendor ID
- * - Two bytes for the Module ID
- * - One byte for the Instance ID
- * - Three bytes version number. The numbering shall be vendor
- * specific: it consists of:
- *
- * - The major, the minor and the patch version number of
- * the module;
- * - The AUTOSAR specification version number shall not
- * be included. The AUTOSAR specification version number is
- * checked during compile time and therefore not required
- * in this API.
- *
- * @param[in,out] VersionInfo Pointer for storing the version information
- * of this module.
- *
- * @return void.
- *
- *
- *
- *
- **/
- void Uart_GetVersionInfo (Std_VersionInfoType * VersionInfo);
- #endif /* (UART_VERSION_INFO_API == STD_ON) */
- #define UART_STOP_SEC_CODE
- #include "Uart_MemMap.h"
- #ifdef __cplusplus
- }
- #endif
- /** @} */
- #endif /* UART_H */
|