//***************************************************************************** // (C) Automotive Lighting China // // Automotive Lighting Reutlingen GmbH owns all the rights to this work. // This work shall not be copied, reproduced, used, modified, transferred // or its information shall not be disclosed without the prior written // authorization of Automotive Lighting China. //***************************************************************************** // ---------------------------------------------------------------------------- /// \file CddUartEng.h /// /// \author f24301c [mailto:walker.lv@marelli.com] /// /// \date 05.27.2024 /// /// \brief define CddUartEng private data struct and API /// // ---------------------------------------------------------------------------- #ifndef _CDD_UART_ENG_H_ #define _CDD_UART_ENG_H_ //============================================================================= // Includes //============================================================================= #include #include #include //#include //============================================================================= // Defines and Typedef //============================================================================= #if (UUE_UARTBUS_PROFILE == STD_ON) // define Uart Bus state typedef struct { uint32 transactionCount; // total transaction counter, no rewind if max reached uint32 errorCount; // transaction error counter, no rewind if max reached // any error: bus error, transaction error, etc. uint32 byteSent; // total Tx bytes, no rewind if max reached uint32 byteRecv; // total Rx bytes, no rewind if max reached uint32 tansactionTimeAccu; // accumulation of transaction time in unit time period (100ms) // for bandwidth computing // NOTENOTE: UUE_TRANSACTION_PROFILE must be ON uint16 bandwidthPermillage; // permillage of bus load during measure unit time. // NOTENOTE: measure unit time should be clarify, 100ms uint16 errorRatio; // error transaction ratio in one ten-thousandth } ChannelStistic_t; #endif // end of UUE_UARTBUS_PROFILE typedef enum { UartDriverMode_Interrupt, // using FIFO interrupt mode UartDriverMode_DMA, // using DMA mode for high speed lager PDU, not support yet NUMBER_OF_UARTDRIVERMODE, } UartDriverMode_t; // define UART flow control bit mapping // it is possible that Uart Read complete notification occurred before write complete notification in case // echo mode is on and no response expected from slave device(s) // use these bits to define expected flow (event) before start transaction, clear corresponding bit after event // occurred, and check if all flow (event) is completed (zero). if yes, we can start next transaction in queue, // else wait until deferred event occurred or timeout (retry). #define UARTENG_FLOWCONTROL_RDCOMP_OFFSET (0) #define UARTENG_FLOWCONTROL_WRCOMP_OFFSET (1) // define of Uart channel object typedef struct { BusState_t busState; // general communication bus state, not limit to UART maybe :) const UartDriverMode_t driverMode; // Uart driver mode #if (UUE_MULITCORE_SUPPORT == STD_ON) const uint8 coreId; // TBD: support multi-core, alway 0 for now #endif const uint8 echoMode; // depends on HW application. if Uart over CAN/LVDS, echoMode is on uint8 flowControl; // see comment lines above const UniUartHandle channelId; // index of configured Uart channel array in EB. MCAL using this index as // Uart interface first parameter // NOTENOTE: it is not HW handle const UniTimerHandle timerId; // timer id, uint8 (Gpt_ChannelType) is reference from TriCore MCAL, TBD UartCommParam_t commParam; // active bus communication parameter, re-init if new transaction require // different configuration StaticRingQueue_t* queue; // each channel has its' private queue, one and only uint8 sharedRxBuf[UUE_SHARE_BUFFER_LEN]; // internal general buffer for Rx. OPTIMIZED. assumption is only one // active transaction for one bus. it is UartEng's responsibility to // decode response PDU into protocol layer PDU buffer after bus level // verification. #if (UUE_UARTBUS_PROFILE == STD_ON) ChannelStistic_t* const statistic; #endif // end of UUE_UARTBUS_PROFILE } UartEngChannel_t; // define of the Engine typedef struct { UartEngChannel_t* channels; // an array to all configuration Uart channel instances const uint8* channelMap; // EB configured uart channel maps to UartEngChannel index uint8 numberOfChannels; // Uart channel number } UartEngine_t; //----------------------------------------------------------------------------- // Start declaration or definitions of functions //----------------------------------------------------------------------------- extern void Uart_WriteNotification(uint8 hwUnit, Uart_ErrorIdType errId); extern void Uart_ReadNotification(uint8 hwUnit, Uart_ErrorIdType errId); extern void Uart_GptTimerNotification(UniTimerHandle hwUnit); //----------------------------------------------------------------------------- // End declaration or definitions of functions //----------------------------------------------------------------------------- #endif // _CDD_UART_ENG_H_