123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487 |
- /*==================================================================================================
- * Project : RTD AUTOSAR 4.4
- * Platform : CORTEXM
- * Peripheral : Ftm_Srtc_Lptmr_LPit
- * Dependencies : none
- *
- * 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.
- ==================================================================================================*/
- /**
- * @file Gpt.c
- * @implements Gpt.c_Artifact
- * @addtogroup gpt Gpt 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 "OsIf.h"
- #include "Gpt.h"
- #include "Gpt_Irq.h"
- #include "Gpt_Ipw.h"
- #include "Det.h"
- /*==================================================================================================
- * SOURCE FILE VERSION INFORMATION
- ==================================================================================================*/
- #define GPT_VENDOR_ID_C 43
- #define GPT_AR_RELEASE_MAJOR_VERSION_C 4
- #define GPT_AR_RELEASE_MINOR_VERSION_C 4
- #define GPT_AR_RELEASE_REVISION_VERSION_C 0
- #define GPT_SW_MAJOR_VERSION_C 1
- #define GPT_SW_MINOR_VERSION_C 0
- #define GPT_SW_PATCH_VERSION_C 0
- /*==================================================================================================
- * FILE VERSION CHECKS
- ==================================================================================================*/
- /* Check if source file and GPT header file are of the same vendor */
- #if (GPT_VENDOR_ID_C != GPT_VENDOR_ID)
- #error "Gpt.c and Gpt.h have different vendor ids"
- #endif
- /* Check if source file and GPT header file are of the same Autosar version */
- #if ((GPT_AR_RELEASE_MAJOR_VERSION_C != GPT_AR_RELEASE_MAJOR_VERSION) || \
- (GPT_AR_RELEASE_MINOR_VERSION_C != GPT_AR_RELEASE_MINOR_VERSION) || \
- (GPT_AR_RELEASE_REVISION_VERSION_C != GPT_AR_RELEASE_REVISION_VERSION) \
- )
- #error "AutoSar Version Numbers of Gpt.c and Gpt.h are different"
- #endif
- /* Check if source file and GPT header file are of the same Software version */
- #if ((GPT_SW_MAJOR_VERSION_C != GPT_SW_MAJOR_VERSION) || \
- (GPT_SW_MINOR_VERSION_C != GPT_SW_MINOR_VERSION) || \
- (GPT_SW_PATCH_VERSION_C != GPT_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of Gpt.c and Gpt.h are different"
- #endif
- #if (GPT_VENDOR_ID_C != GPT_IPW_VENDOR_ID)
- #error "Gpt.c and Gpt_Ipw.h have different vendor ids"
- #endif
- /* Check if source file and GPT Ipw header file are of the same Autosar version */
- #if ((GPT_AR_RELEASE_MAJOR_VERSION_C != GPT_IPW_AR_RELEASE_MAJOR_VERSION) || \
- (GPT_AR_RELEASE_MINOR_VERSION_C != GPT_IPW_AR_RELEASE_MINOR_VERSION) || \
- (GPT_AR_RELEASE_REVISION_VERSION_C != GPT_IPW_AR_RELEASE_REVISION_VERSION) \
- )
- #error "AutoSar Version Numbers of Gpt.c and Gpt_Ipw.h are different"
- #endif
- /* Check if source file and GPT Ipw header file are of the same Software version */
- #if ((GPT_SW_MAJOR_VERSION_C != GPT_IPW_SW_MAJOR_VERSION) || \
- (GPT_SW_MINOR_VERSION_C != GPT_IPW_SW_MINOR_VERSION) || \
- (GPT_SW_PATCH_VERSION_C != GPT_IPW_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of Gpt.c and Gpt_Ipw.h are different"
- #endif
- /* Check if source file and GPT header file are of the same vendor */
- #if (GPT_VENDOR_ID_C != GPT_IRQ_VENDOR_ID)
- #error "Gpt.c and Gpt_Irq.h have different vendor ids"
- #endif
- /* Check if source file and GPT header file are of the same Autosar version */
- #if ((GPT_AR_RELEASE_MAJOR_VERSION_C != GPT_IRQ_AR_RELEASE_MAJOR_VERSION) || \
- (GPT_AR_RELEASE_MINOR_VERSION_C != GPT_IRQ_AR_RELEASE_MINOR_VERSION) || \
- (GPT_AR_RELEASE_REVISION_VERSION_C != GPT_IRQ_AR_RELEASE_REVISION_VERSION)\
- )
- #error "AutoSar Version Numbers of Gpt.c and Gpt_Irq.h are different"
- #endif
- /* Check if source file and GPT header file are of the same Software version */
- #if ((GPT_SW_MAJOR_VERSION_C != GPT_IRQ_SW_MAJOR_VERSION) || \
- (GPT_SW_MINOR_VERSION_C != GPT_IRQ_SW_MINOR_VERSION) || \
- (GPT_SW_PATCH_VERSION_C != GPT_IRQ_SW_PATCH_VERSION) \
- )
- #error "Software Version Numbers of Gpt.c and Gpt_Irq.h are different"
- #endif
- /* Check if source file and DET header file are of the same version */
- #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
- #if ((GPT_AR_RELEASE_MAJOR_VERSION_C != DET_AR_RELEASE_MAJOR_VERSION) || \
- (GPT_AR_RELEASE_MINOR_VERSION_C != DET_AR_RELEASE_MINOR_VERSION) \
- )
- #error "AutoSar Version Numbers of Gpt.c and Det.h are different"
- #endif
- /* Check if this source file and OsIf.h file are of the same Autosar version */
- #if ((GPT_AR_RELEASE_MAJOR_VERSION_C != OSIF_AR_RELEASE_MAJOR_VERSION) || \
- (GPT_AR_RELEASE_MINOR_VERSION_C != OSIF_AR_RELEASE_MINOR_VERSION))
- #error "AutoSar Version Numbers of Gpt.c and OsIf.h are different"
- #endif
- #endif
- /*==================================================================================================
- * LOCAL TYPEDEFS (STRUCTURES, UNIONS, ENUMS)
- ==================================================================================================*/
- /**
- * @brief This enumeration type allows the selection of channel status type.
- * @details This enumeration specifies the return type of Gpt_ChannelStatusType
- *
- * @implements
- */
- typedef enum
- {
- GPT_STATUS_UNINITIALIZED = 0, /**< @brief GPT channel status - uninitialized */
- GPT_STATUS_INITIALIZED = 1, /**< @brief GPT channel status - initialized */
- GPT_STATUS_STOPPED = 2, /**< @brief GPT channel status - stopped */
- GPT_STATUS_EXPIRED = 3, /**< @brief GPT channel status - expired */
- GPT_STATUS_RUNNING = 4 /**< @brief GPT channel status - running */
- } Gpt_ChannelStatusType;
- /**
- * @brief Gpt runtime status type - this is the type of the data structure including the
- * runtime status informations of a channel.
- * @details It contains the information like GPT channel runtime status, Channel has notification enabled at runtime,
- * Channel has wakeup enabled at runtime,Channel executed wakeup.
- * @implements
- */
- typedef struct
- {
- Gpt_ChannelStatusType eChannelStatus; /**< @brief GPT channel runtime status */
- #if (GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON) /**< @brief GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON */
- boolean bNotificationEnabled; /**< @brief GPT channel has notification enabled at runtime */
- #endif
- /** @brief (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON) && (GPT_REPORT_WAKEUP_SOURCE == STD_ON) */
- #if((GPT_WAKEUP_FUNCTIONALITY_API == STD_ON) && (GPT_REPORT_WAKEUP_SOURCE == STD_ON))
- boolean bWakeupEnabled; /**< @brief GPT channel has wakeup enabled at runtime*/
- boolean bWakeupGenerated; /**< @brief GPT channel executed wakeup */
- #endif
- } Gpt_ChannelInfoType;
- /*==================================================================================================
- * LOCAL MACROS
- ==================================================================================================*/
- #if (GPT_MULTICORE_ENABLED == STD_ON)
- #define Gpt_GetCoreID() (uint32)OsIf_GetCoreID()
- #else
- #define Gpt_GetCoreID() ((uint32)0UL)
- #endif
- /*==================================================================================================
- * LOCAL CONSTANTS
- ==================================================================================================*/
- /*==================================================================================================
- * LOCAL VARIABLES
- ==================================================================================================*/
- #define GPT_START_SEC_VAR_INIT_UNSPECIFIED
- #include "Gpt_MemMap.h"
- /**
- * @brief Global variable used for indicating the current GPT driver mode.
- */
- static volatile Gpt_ModeType Gpt_eMode = GPT_MODE_NORMAL;
- #define GPT_STOP_SEC_VAR_INIT_UNSPECIFIED
- #include "Gpt_MemMap.h"
- #define GPT_START_SEC_VAR_CLEARED_UNSPECIFIED
- #include "Gpt_MemMap.h"
- /**
- * @brief Global variable (pointer) used for storing the GPT driver configuration data.
- */
- #if (GPT_MULTICORE_ENABLED == STD_ON)
- const Gpt_ConfigType *Gpt_pConfig[GPT_MAX_PARTITIONS];
- #else
- const Gpt_ConfigType *Gpt_pConfig[1U];
- #endif
- /**
- * @brief Global array variable used to store runtime internal context of each logic channel.
- */
- static Gpt_ChannelInfoType Gpt_aChannelInfo[GPT_HW_CHANNEL_NUM];
- /**
- * @brief Global array variable used to store for each channel the time value when it is
- * stopped
- */
- static volatile Gpt_ValueType Gpt_aStopTime[GPT_HW_CHANNEL_NUM];
- #define GPT_STOP_SEC_VAR_CLEARED_UNSPECIFIED
- #include "Gpt_MemMap.h"
- /*==================================================================================================
- * GLOBAL CONSTANTS
- ==================================================================================================*/
- /*==================================================================================================
- * GLOBAL VARIABLES
- ==================================================================================================*/
- /*==================================================================================================
- * LOCAL FUNCTION PROTOTYPES
- ==================================================================================================*/
- #define GPT_START_SEC_CODE
- #include "Gpt_MemMap.h"
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- static inline Std_ReturnType Gpt_ValidateChannelCall
- (
- uint8 u8ServiceId,
- Gpt_ChannelType channel,
- uint32 coreID
- );
- #endif
- #if(GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- static inline Std_ReturnType Gpt_ValidateGlobalCall
- (
- uint8 u8ServiceId,
- uint32 coreID
- );
- #endif
- #if ((GPT_VALIDATE_PARAM == STD_ON) && (GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON))
- static inline Std_ReturnType Gpt_ValidateChannelNotification
- (
- uint8 u8ServiceId,
- Gpt_ChannelType channel,
- uint32 coreID
- );
- #endif
- #if ((GPT_VALIDATE_PARAM == STD_ON) && (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON) && (GPT_REPORT_WAKEUP_SOURCE == STD_ON))
- static inline Std_ReturnType Gpt_ValidateChannelWakeup
- (
- uint8 u8ServiceId,
- Gpt_ChannelType channel,
- uint32 coreID
- );
- #endif
- #if (GPT_VALIDATE_STATE == STD_ON)
- static inline Std_ReturnType Gpt_ValidateChannelStatus
- (
- uint8 u8ServiceId,
- Gpt_ChannelType channel,
- uint32 coreID
- );
- #endif
- #if ((GPT_VALIDATE_PARAM == STD_ON) && (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON) && (GPT_REPORT_WAKEUP_SOURCE == STD_ON))
- static inline Std_ReturnType Gpt_ValidateParamMode(Gpt_ModeType eMode);
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- static inline Std_ReturnType Gpt_ValidateParamValue
- (
- uint8 u8ServiceId,
- Gpt_ChannelType channel,
- Gpt_ValueType value,
- uint32 coreID
- );
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- static inline Std_ReturnType Gpt_ValidateParamPtrInit
- (
- const Gpt_ConfigType * configPtr
- );
- #endif
- #if (GPT_SET_CLOCK_MODE == STD_ON) && (GPT_VALIDATE_PARAM == STD_ON)
- static inline Std_ReturnType Gpt_ValidateParamSetClockMode
- (
- Gpt_ClockModeType eClkMode
- );
- #endif
- #if(GPT_PREDEFTIMER_FUNCTIONALITY_API == STD_ON)
- #if (GPT_VALIDATE_PARAM == STD_ON)
- static inline Std_ReturnType Gpt_ValidateParamTypePredefTimer
- (
- Gpt_PredefTimerType u32PredefTimer,
- uint32 coreID
- );
- static inline Std_ReturnType Gpt_ValidatePointerGetPredefTimer
- (
- const uint32 * ParamPtr
- );
- #endif
- #if (GPT_VALIDATE_STATE == STD_ON)
- static inline Std_ReturnType Gpt_ValidateMode
- (
- uint8 u8ServiceId
- );
- #endif
- #endif
- static inline Gpt_ChannelType Gpt_ConvertChannelIndexToChannel(Gpt_ChannelType ChannelIndex,
- uint32 coreID
- );
- /*==================================================================================================
- * LOCAL FUNCTIONS
- ==================================================================================================*/
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- /**
- * @brief This function validates the call for a specific channel
- * @details This service is a non re entrant function on channel used for validating the calls
- * for functions that use one channel
- *
- * @param[in] Channel Numeric identifier of the GPT channel
- * @param[in] u8ServiceId The service id of the caller function
- * @return The validity of the function call
- * @returnValue E_OK The function call is valid
- * @returnValue E_NOT_OK The function call is invalid
- *
- * @pre Gpt_Init must be called before.
- * @implements Gpt_ValidateChannelCall_Activity
- *
- * */
- static inline Std_ReturnType Gpt_ValidateChannelCall
- (
- uint8 u8ServiceId,
- Gpt_ChannelType channel,
- uint32 coreID
- )
- {
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- /* If driver is not initialized report error */
- if (NULL_PTR == Gpt_pConfig[coreID])
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_UNINIT\
- );
- }
- else
- {
- if (GPT_HW_CHANNEL_NUM <= channel)
- {
- /* Check if the configured channel is out of range */
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_PARAM_CHANNEL\
- );
- }
- else
- {
- /* Check if the channel is used on the current core */
- if (255U != (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel])
- {
- returnValue = (Std_ReturnType)E_OK;
- }
- else
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_PARAM_CONFIG\
- );
- }
- }
- }
- return returnValue;
- }
- #endif
- #if(GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- /**
- * @brief This function validates the global call
- * @details This service is a non re-entrant function used for validating the calls for functions
- * that uses all the channels - Gpt_Init, Gpt_DeInit, Gpt_SetMode.
- *
- * @param[in] u8ServiceId The service id of the caller function
- *
- * @return The validity of the function call
- * @returnValue E_OK The function call is valid
- * @returnValue E_NOT_OK The function call is invalid
- *
- * @pre Gpt_Init must be called before.
- * @implements Gpt_ValidateGlobalCall_Activity
- * */
- static inline Std_ReturnType Gpt_ValidateGlobalCall
- (
- uint8 u8ServiceId,
- uint32 coreID
- )
- {
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- /* If caller is the initialization function, error */
- if (NULL_PTR == Gpt_pConfig[coreID])
- {
- /* If caller is the initialization function, OK */
- if (GPT_INIT_ID == u8ServiceId)
- {
- returnValue = (Std_ReturnType)E_OK;
- }
- else
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_UNINIT\
- );
- }
- }
- else
- {
- if (GPT_INIT_ID == u8ServiceId)
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_ALREADY_INITIALIZED\
- );
- }
- else
- {
- returnValue = (Std_ReturnType)E_OK;
- }
- }
- return returnValue;
- }
- #endif
- #if ((GPT_VALIDATE_PARAM == STD_ON) && (GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON))
- /**
- * @brief This function validate the channel notification capability for a
- * specific channel.
- * @details Validate the notification handler of a GPT channel.
- * In order to be valid, the notification handler should not be
- * NULL_PTR. In case it is NULL_PTR, the function will report an error to
- * DET or SERR, depending on the environment the driver is run in.
- * @param[in] u8ServiceId The service id of the caller function
- * @param[in] channel Numeric identifier of the GPT channel
- *
- * @return The validity of the function call
- * @returnValue E_OK The function call is valid
- * @returnValue E_NOT_OK The function call is invalid
- *
- * @pre The driver needs to be initialized and GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON.
- * @implements Gpt_ValidateChannelNotification_Activity
- *
- * */
- static inline Std_ReturnType Gpt_ValidateChannelNotification
- (
- uint8 u8ServiceId,
- Gpt_ChannelType channel,
- uint32 coreID
- )
- {
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- uint8 ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- if (NULL_PTR == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_pfNotification)
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_PARAM_CHANNEL\
- );
- }
- else
- {
- returnValue = (Std_ReturnType)E_OK;
- }
- return returnValue;
- }
- #endif
- #if ((GPT_VALIDATE_PARAM == STD_ON) && (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON) && (GPT_REPORT_WAKEUP_SOURCE == STD_ON))
- /**
- * @brief This function validate the channel wakeup capability for a specific channel.
- * @details Function validate the channel wakeup capability for a specific channel.
- * In case Gpt_bEnableWakeup is FALSE, the function will report an error to
- * DET or SERR, depending on the environment the driver is run in.
- * @param[in] u8ServiceId The service id of the caller function
- * @param[in] channel Numeric identifier of the GPT channel
- *
- * @return The validity of the function call
- * @returnValue E_OK The function call is valid
- * @returnValue E_NOT_OK The function call is invalid
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_ValidateChannelWakeup_Activity
- *
- * */
- static inline Std_ReturnType Gpt_ValidateChannelWakeup
- (
- uint8 u8ServiceId,
- Gpt_ChannelType channel,
- uint32 coreID
- )
- {
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- uint8 ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- if (FALSE == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_bEnableWakeup)
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_PARAM_CHANNEL\
- );
- }
- else
- {
- returnValue = (Std_ReturnType)E_OK;
- }
- return returnValue;
- }
- #endif
- /**
- * @brief This function validate the channel status related to the caller function
- * and to a specific channel.
- * @details Function validate the channel status for a specific channel.
- * In case disabled wakeup channel in sleep mode ((bWakeupEnabled == False) && (GPT_MODE_SLEEP == Gpt_eMode)),
- * In case channel status (GPT_STATUS_RUNNING != eChannelStatus) && GPT_CHANGE_NEXT_TIMEOUT_VALUE == STD_ON
- * In case channel status (GPT_STATUS_RUNNING == eChannelStatus)
- * In case channel mode (GPT_CH_MODE_ONESHOT == eChannelMode) && GPT_CHANGE_NEXT_TIMEOUT_VALUE == STD_ON
- * the function will report an error to DET or SERR, depending on the environment the driver is run in.
- * @param[in] u8ServiceId The service id of the caller function
- * @param[in] channel Numeric identifier of the GPT channel
- *
- * @return The validity of the function call
- * @returnValue E_OK The function call is valid
- * @returnValue E_NOT_OK The function call is invalid
- *
- * @pre The driver needs to be initialized.
- * @implements
- * */
- static inline Std_ReturnType Gpt_ValidateChannelStatus
- (
- uint8 u8ServiceId,
- Gpt_ChannelType channel,
- uint32 coreID
- )
- {
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- #if ((GPT_CHANGE_NEXT_TIMEOUT_VALUE == STD_ON) && (GPT_VALIDATE_STATE == STD_ON))
- uint8 ChannelIndex;
- #endif
- #if ((GPT_WAKEUP_FUNCTIONALITY_API == STD_ON) && (GPT_VALIDATE_STATE == STD_ON))
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_ON)
- /* Do not start a not enabled wakeup channel in sleep mode */
- if ((GPT_MODE_SLEEP == Gpt_eMode) && (FALSE == Gpt_aChannelInfo[channel].bWakeupEnabled) && (GPT_STARTTIMER_ID == u8ServiceId))
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_INVALID_CALL\
- );
- }
- else
- {
- #endif
- #endif /* (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON) && (GPT_VALIDATE_STATE == STD_ON) */
- #if (GPT_VALIDATE_STATE == STD_OFF)
- (void) coreID;
- #endif
- #if (GPT_CHANGE_NEXT_TIMEOUT_VALUE == STD_ON)
- #if (GPT_VALIDATE_STATE == STD_ON)
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- if ((GPT_CHANGE_NEXT_TIMEOUT_VALUE_ID == u8ServiceId) && \
- (GPT_STATUS_RUNNING != Gpt_aChannelInfo[channel].eChannelStatus)
- )
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_INVALID_CALL\
- );
- }
- else if ((GPT_CHANGE_NEXT_TIMEOUT_VALUE_ID == u8ServiceId) && \
- (GPT_CH_MODE_ONESHOT == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_eChannelMode)
- )
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_PARAM_CHANNEL\
- );
- }
- else
- #endif /* (GPT_VALIDATE_STATE == STD_ON) */
- if ((GPT_CHANGE_NEXT_TIMEOUT_VALUE_ID != u8ServiceId) && \
- (GPT_STATUS_RUNNING == Gpt_aChannelInfo[channel].eChannelStatus)
- )
- {
- (void)Det_ReportRuntimeError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_BUSY\
- );
- }
- else
- {
- #else
- if (GPT_STATUS_RUNNING == Gpt_aChannelInfo[channel].eChannelStatus)
- {
- (void)Det_ReportRuntimeError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_BUSY\
- );
- }
- else
- {
- #endif
- returnValue = (Std_ReturnType)E_OK;
- #if (GPT_CHANGE_NEXT_TIMEOUT_VALUE == STD_OFF)
- }
- #endif
- #if (GPT_CHANGE_NEXT_TIMEOUT_VALUE == STD_ON)
- }
- #endif
- #if ((GPT_WAKEUP_FUNCTIONALITY_API == STD_ON)&& (GPT_VALIDATE_STATE == STD_ON))
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_ON)
- }
- #endif
- #endif
- #if ((GPT_VALIDATE_STATE == STD_OFF)||(GPT_CHANGE_NEXT_TIMEOUT_VALUE == STD_OFF))
- /*variable coreID is not used in this case - this should be commented*/
- (void) coreID;
- #endif
- return returnValue;
- }
- #if ((GPT_VALIDATE_PARAM == STD_ON) && (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON) && (GPT_REPORT_WAKEUP_SOURCE == STD_ON))
- /**
- * @brief This function validate the mode that will be set in the driver.
- * @details Validate the mode that will be set in the driver.
- * In case (GPT_MODE_SLEEP != eMode) && (GPT_MODE_NORMAL != eMode)
- * the function will report an error to DET or SERR, depending on the environment the driver is run in.
- * @param[in] eMode Specifies the operation mode
- *
- * @return The validity of the function call
- * @returnValue E_OK The function call is valid
- * @returnValue E_NOT_OK The function call is invalid
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_ValidateParamMode_Activity
- * */
- static inline Std_ReturnType Gpt_ValidateParamMode(Gpt_ModeType eMode)
- {
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- if((GPT_MODE_SLEEP != eMode) && (GPT_MODE_NORMAL != eMode))
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)GPT_SETMODE_ID,\
- (uint8)GPT_E_PARAM_MODE\
- );
- }
- else
- {
- returnValue = (Std_ReturnType)E_OK;
- }
- return returnValue;
- }
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- /**
- * @brief This function validate the time value parameter related to a specific GPT channel.
- * @details Function validate the time value parameter related to a specific GPT channel.
- * In case ((Gpt_ValueType)0 == value) || (value > Gpt_uChannelTickValueMax)
- * the function will report an error to DET or SERR, depending on the environment the driver is run in.
- * @param[in] u8ServiceId The service id of the caller function
- * @param[in] value The time value which is verified
- * @param[in] channel Numeric identifier of the GPT channel
- *
- * @return The validity of the function call
- * @returnValue E_OK The function call is valid
- * @returnValue E_NOT_OK The function call is invalid
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_ValidateParamValue_Activity
- *
- * */
- static inline Std_ReturnType Gpt_ValidateParamValue
- (
- uint8 u8ServiceId,
- Gpt_ChannelType channel,
- Gpt_ValueType value,
- uint32 coreID
- )
- {
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- uint8 ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- if ((value > (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_uChannelTickValueMax) || \
- ((Gpt_ValueType)0 == value )
- )
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- u8ServiceId,\
- (uint8)GPT_E_PARAM_VALUE\
- );
- }
- else
- {
- returnValue = (Std_ReturnType)E_OK;
- }
- return returnValue;
- }
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- /**
- * @brief This function validate the initialization pointer.
- * @details Validate the initialization pointer.
- * In case NULL_PTR == configPtr and (GPT_PRECOMPILE_SUPPORT == STD_OFF)
- * In case NULL_PTR != configPtr and (GPT_PRECOMPILE_SUPPORT == STD_ON)
- * The function will report an error to DET or SERR, depending on the environment the driver is run in.
- * @param[in] configPtr Pointer to a selected configuration structure.
- *
- * @return The validity of the function call
- * @returnValue E_OK The function call is valid
- * @returnValue E_NOT_OK The function call is invalid
- *
- * @pre The data structure including the configuration set required for initializing the GPT driver.
- * @implements Gpt_ValidateParamPtrInit_Activity
- *
- * */
- static inline Std_ReturnType Gpt_ValidateParamPtrInit
- (
- const Gpt_ConfigType * configPtr
- )
- {
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- #if (GPT_PRECOMPILE_SUPPORT == STD_OFF)
- #if (GPT_DEV_ERROR_DETECT == STD_ON)
- if (NULL_PTR == configPtr)
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)GPT_INIT_ID,\
- (uint8)GPT_E_INIT_FAILED \
- );
- }
- else
- {
- returnValue = (Std_ReturnType)E_OK;
- }
- #endif
- #elif (GPT_PRECOMPILE_SUPPORT == STD_ON)
- #if (GPT_DEV_ERROR_DETECT == STD_ON)
- if (NULL_PTR != configPtr)
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)GPT_INIT_ID,\
- (uint8)GPT_E_INIT_FAILED \
- );
- }
- else
- {
- returnValue=(Std_ReturnType)E_OK;
- }
- #endif
- #endif
- return returnValue;
- }
- #endif
- #if (GPT_SET_CLOCK_MODE == STD_ON) && (GPT_VALIDATE_PARAM == STD_ON)
- /**
- * @brief This function validates the eClkMode parameter.
- * @details Validate the function ValidateParamSetClockMode.
- * In case (GPT_CLOCKMODE_NORMAL != eClkMode) && (GPT_CLOCKMODE_ALTERNATE != eClkMode)
- * The function will report an error to DET or SERR, depending on the environment the driver is run in.
- * @param[in] eClkMode prescaler setting ( NORMAL or ALTERNATE )
- *
- * @return The validity of the function call
- * @returnValue E_OK The function call is valid
- * @returnValue E_NOT_OK The function call is invalid
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_ValidateParamSetClockMode_Activity
- *
- * */
- static inline Std_ReturnType Gpt_ValidateParamSetClockMode
- (
- Gpt_ClockModeType eClkMode
- )
- {
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- if((GPT_CLOCKMODE_NORMAL != eClkMode) && (GPT_CLOCKMODE_ALTERNATE != eClkMode))
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)GPT_SET_CLOCK_MODE_ID,\
- (uint8)GPT_E_PARAM_CLOCK_MODE\
- );
- }
- else
- {
- returnValue=(Std_ReturnType)E_OK;
- }
- return returnValue;
- }
- #endif
- #if((GPT_PREDEFTIMER_FUNCTIONALITY_API == STD_ON) && (GPT_VALIDATE_PARAM == STD_ON))
- /**
- * @brief This function validates parameter of PredefTimer
- * @details Validate the function Gpt_ValidateParamTypePredefTimer.
- * In case (Gpt_PredefTimerType != u32PredefTimer)
- * In case pointer to the GPT channel predeftimer configuration == NULL_PTR
- * The function will report an error to DET or SERR, depending on the environment the driver is run in.
- *
- * @param[in] u32PredefTimer Parameter of PredefTimer functionality
- * @return The validity of the function call
- * @returnValue E_OK The function call is valid
- * @returnValue E_NOT_OK The function call is invalid
- *
- * @pre The driver needs to be initialized.
- *
- * @implements Gpt_ValidateParamTypePredefTimer_Activity
- *
- **/
- static inline Std_ReturnType Gpt_ValidateParamTypePredefTimer
- (
- Gpt_PredefTimerType u32PredefTimer,
- uint32 coreID
- )
- {
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- Gpt_ChannelType channel;
- if ((u32PredefTimer != GPT_PREDEF_TIMER_1US_16BIT) && \
- (u32PredefTimer != GPT_PREDEF_TIMER_1US_24BIT) && \
- (u32PredefTimer != GPT_PREDEF_TIMER_1US_32BIT) && \
- (u32PredefTimer != GPT_PREDEF_TIMER_100US_32BIT))
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)GPT_GET_PREDEF_TIMERVALUE_ID,\
- (uint8)GPT_E_PARAM_PREDEF_TIMER\
- );
- }
- else
- {
- channel = (Gpt_ChannelType)u32PredefTimer;
- if(NULL_PTR == ((Gpt_pConfig[coreID]->Gpt_pChannelPredefConfigType)[channel]))
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)GPT_GET_PREDEF_TIMERVALUE_ID,\
- (uint8)GPT_E_PARAM_PREDEF_TIMER\
- );
- }
- else
- {
- returnValue = (Std_ReturnType)E_OK;
- }
- }
- return returnValue;
- }
- /**
- * @brief This function validate the Pointer GetPredefTimer.
- * @details Validate the function Gpt_ValidatePointerGetPredefTimer.
- * In case (NULL_PTR == ParamPtr)
- * The function will report an error to DET or SERR, depending on the environment the driver is run in.
- * @param[in] ParamPtr Pointer to a selected configuration structure.
- * @return The validity of the function call
- * @returnValue E_OK The function call is valid
- * @returnValue E_NOT_OK The function call is invalid
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_ValidatePointerGetPredefTimer_Activity
- *
- **/
- static inline Std_ReturnType Gpt_ValidatePointerGetPredefTimer
- (
- const uint32 * ParamPtr
- )
- {
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- if(NULL_PTR == ParamPtr)
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)GPT_GET_PREDEF_TIMERVALUE_ID,\
- (uint8)GPT_E_PARAM_POINTER\
- );
- }
- else
- {
- returnValue = (Std_ReturnType)E_OK;
- }
- return returnValue;
- }
- #endif
- #if (GPT_PREDEFTIMER_FUNCTIONALITY_API == STD_ON)
- /**
- * @brief This function validate the initialization mode.
- * @details Validate the function Gpt_ValidateMode.
- * In case (GPT_MODE_SLEEP == Gpt_eMode)
- * The function will report an error to DET or SERR, depending on the environment the driver is run in.
- * @param[in] u8ServiceId The service id of the caller function.
- *
- * @return The validity of the function call.
- * @returnValue E_OK The function call is valid.
- * @returnValue E_NOT_OK The function call is invalid.
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_ValidateMode_Activity
- *
- **/
- static inline Std_ReturnType Gpt_ValidateMode
- (
- uint8 u8ServiceId
- )
- {
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- if (GPT_MODE_SLEEP == Gpt_eMode)
- {
- (void)Det_ReportRuntimeError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)u8ServiceId,\
- (uint8)GPT_E_MODE\
- );
- }
- else
- {
- returnValue = (Std_ReturnType)E_OK;
- }
- return returnValue;
- }
- #endif
- /**
- * @brief This function get the channel number corresponding to the index of channel
- *
- * @param[in] ChannelIndex Channel Index of the Gpt channel
- * @param[in] coreID The number of current core ID
- *
- * @return The channel number corresponds to the channel in the core
- * @pre Gpt_Init must be called before.
- *
- *
- * */
- static inline Gpt_ChannelType Gpt_ConvertChannelIndexToChannel(Gpt_ChannelType ChannelIndex,
- uint32 coreID
- )
- {
- Gpt_ChannelType Channel = GPT_HW_CHANNEL_NUM;
- for (Channel = 0U; Channel < GPT_HW_CHANNEL_NUM; Channel++)
- {
- if(ChannelIndex == (*Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap)[Channel])
- {
- break;
- }
- }
- return Channel;
- }
- /*==================================================================================================
- * GLOBAL FUNCTIONS
- ==================================================================================================*/
- /*================================================================================================*/
- #if (GPT_VERSION_INFO_API == STD_ON)
- /**
- * @brief This function returns the version information of this module.
- * @details This service returns the version information of this module. The version information
- * includes:
- * - Module Id
- * - Vendor Id
- * - Vendor specific version numbers
- * If source code for caller and callee of this function is available this function should
- * be realized as a macro. The macro should be defined in the modules header file.
- * @param[out] VersionInfoPtr - pointer to location to store version info
- *
- * @return void
- * @api
- *
- * @pre Gpt_Init must be called before.
- * @implements Gpt_GetVersionInfo_Activity
- */
- void Gpt_GetVersionInfo
- (
- Std_VersionInfoType * VersionInfoPtr
- )
- {
- #if (GPT_DEV_ERROR_DETECT == STD_ON)
- if (NULL_PTR == VersionInfoPtr)
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)GPT_GETVERSIONINFO_ID,\
- (uint8)GPT_E_PARAM_POINTER\
- );
- }
- else
- #endif
- {
- VersionInfoPtr->vendorID = (uint16)GPT_VENDOR_ID;
- VersionInfoPtr->moduleID = (uint16)GPT_MODULE_ID;
- VersionInfoPtr->sw_major_version = (uint8)GPT_SW_MAJOR_VERSION;
- VersionInfoPtr->sw_minor_version = (uint8)GPT_SW_MINOR_VERSION;
- VersionInfoPtr->sw_patch_version = (uint8)GPT_SW_PATCH_VERSION;
- }
- }
- #endif
- /*================================================================================================*/
- /**
- * @brief GPT driver initialization function.
- * @details This service is a non reentrant function used for driver initialization.
- * The Initialization function shall initialize all relevant registers of
- * the configured hardware with the values of the structure referenced by the parameter ConfigPtr.
- * All time units used within the API services of the GPT driver shall be of the unit ticks.
- * This function shall only initialize the configured resources. Resources that are
- * not configured in the configuration file shall not be touched.
- * The following rules regarding initialization of controller registers shall apply
- * to the GPT Driver implementation:
- * [1] If the hardware allows for only one usage of the register, the driver
- * module implementing that functionality is responsible for initializing the register
- * [2] If the register can affect several hardware modules and if it is an IO register it
- * shall be initialized by the PORT driver
- * [3] If the register can affect several hardware modules and if it is not an IO register
- * it shall be initialized by the MCU driver
- * [4] One-time writable registers that require initialization directly after reset shall be
- * initialized by the startup code
- * [5] All other registers shall be initialized by the startup code
- *
- * @param[in] configPtr Pointer to a selected configuration structure
- *
- * @return void
- * @api
- *
- * @pre The data structure including the configuration set required for initializing the GPT driver..
- * @implements Gpt_Init_Activity
- */
- void Gpt_Init(const Gpt_ConfigType * configPtr)
- {
- uint32 coreID;
- Gpt_ChannelType ChannelIndex;
- Gpt_ChannelType channel;
- coreID = (uint32)Gpt_GetCoreID();
- #if (GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- /*Validate the calling context*/
- if((Std_ReturnType)E_OK == Gpt_ValidateGlobalCall(GPT_INIT_ID, coreID))
- {
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- /*Validate configuration pointer parameter.*/
- if((Std_ReturnType)E_OK == Gpt_ValidateParamPtrInit(configPtr))
- {
- #endif
- #if (GPT_PRECOMPILE_SUPPORT == STD_ON)
- #if(GPT_MULTICORE_ENABLED == STD_ON)
- Gpt_pConfig[coreID] = Gpt_Config[coreID];
- #else
- Gpt_pConfig[coreID] = &Gpt_Config;
- #endif
- (void)configPtr;
- #else
- Gpt_pConfig[coreID] = configPtr;
- #endif
- #if(GPT_PREDEFTIMER_FUNCTIONALITY_API == STD_ON)
- /*Initialize and Start Predef Timers.*/
- Gpt_Ipw_StartPredefTimer(Gpt_pConfig[coreID]);
- #endif
- Gpt_Ipw_InitInstances(Gpt_pConfig[coreID]);
- /*Initialize for each channel the runtime status informations.*/
- for (ChannelIndex = 0U; ChannelIndex < Gpt_pConfig[coreID]->channelCount; ChannelIndex++)
- {
- channel = Gpt_ConvertChannelIndexToChannel(ChannelIndex, coreID);
- #if (GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON)
- /*Disable notification*/
- Gpt_aChannelInfo[channel].bNotificationEnabled = FALSE;
- #endif
- #if ((GPT_WAKEUP_FUNCTIONALITY_API == STD_ON) && (GPT_REPORT_WAKEUP_SOURCE == STD_ON))
- /*Disable wakeup*/
- Gpt_aChannelInfo[channel].bWakeupEnabled = FALSE;
- /*Clear wakeup generation status*/
- Gpt_aChannelInfo[channel].bWakeupGenerated = FALSE;
- #endif
- /* Initialize the running information of the channel*/
- Gpt_aChannelInfo[channel].eChannelStatus = GPT_STATUS_INITIALIZED;
- Gpt_aStopTime[channel] = 0U;
- /*Initialize hardware timer channel.*/
- Gpt_Ipw_Init(((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig));
- }
- /*Set the driver to normal mode*/
- Gpt_eMode = GPT_MODE_NORMAL;
- #if (GPT_VALIDATE_PARAM == STD_ON)
- }
- #endif
- #if (GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- }
- #endif
- return;
- }
- /*================================================================================================*/
- #if (GPT_DEINIT_API == STD_ON)
- /**
- * @brief GPT driver de-initialization function.
- * @details Service for de initializing all hardware timer channels to their power on reset state.
- * The state of the peripheral after DeInit shall be the same as after power on
- * reset.
- * The service influences only the peripherals, which are allocated by static
- * configuration and the runtime configuration set passed by the previous call of Gpt_Init()
- * The driver needs to be initialized before calling Gpt_DeInit(). Otherwise, the
- * function Gpt_DeInit shall raise the development error GPT_E_UNINIT and leave the desired
- * de initialization functionality without any action.
- *
- * @api
- * @return void
- *
- * @implements Gpt_DeInit_Activity
- */
- void Gpt_DeInit(void)
- {
- Gpt_ChannelType channel;
- Gpt_ChannelType ChannelIndex;
- Std_ReturnType allChannelStatus = (Std_ReturnType)E_OK;
- uint32 coreID;
- coreID = (uint32)Gpt_GetCoreID();
- #if (GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- /*Validate if the calling context is valid*/
- if((Std_ReturnType)E_OK == Gpt_ValidateGlobalCall(GPT_DEINIT_ID, coreID))
- {
- #endif
- /* Initialize for each channel the runtime status informations.*/
- for (ChannelIndex = 0U; ChannelIndex < Gpt_pConfig[coreID]->channelCount; ChannelIndex++)
- {
- channel = Gpt_ConvertChannelIndexToChannel(ChannelIndex, coreID);
- /*Check if the channel is not running.*/
- if((Std_ReturnType)E_NOT_OK == Gpt_ValidateChannelStatus(GPT_DEINIT_ID, channel, coreID))
- {
- allChannelStatus = (Std_ReturnType)E_NOT_OK;
- break;
- }
- }
- if((Std_ReturnType)E_OK == allChannelStatus)
- {
- for (ChannelIndex = 0U; ChannelIndex < Gpt_pConfig[coreID]->channelCount; ChannelIndex++)
- {
- channel = Gpt_ConvertChannelIndexToChannel(ChannelIndex, coreID);
- #if (GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON)
- /*Disable notification*/
- Gpt_aChannelInfo[channel].bNotificationEnabled = FALSE;
- #endif
- #if ((GPT_WAKEUP_FUNCTIONALITY_API == STD_ON) && (GPT_REPORT_WAKEUP_SOURCE == STD_ON))
- /*Disable wakeup*/
- Gpt_aChannelInfo[channel].bWakeupEnabled = FALSE;
- /*Clear wakeup generation status*/
- Gpt_aChannelInfo[channel].bWakeupGenerated = FALSE;
- #endif
- /* De initialize the running information of the channel*/
- Gpt_aChannelInfo[channel].eChannelStatus = GPT_STATUS_UNINITIALIZED;
- Gpt_aStopTime[channel] = 0U;
- /*Initialize hardware timer channel.*/
- Gpt_Ipw_DeInit
- (
- ((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)
- );
- }
- #if(GPT_PREDEFTIMER_FUNCTIONALITY_API == STD_ON)
- /* Deinitialize and stop Predef timers.*/
- Gpt_Ipw_StopPredefTimer(Gpt_pConfig[coreID]);
- #endif
- /* Writing NULL to configuration pointer is mandatory because that variable
- is used to test the initialization of the driver */
- Gpt_pConfig[coreID] = NULL_PTR;
- }
- #if (GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- }
- #endif
- return;
- }
- #endif
- /*================================================================================================*/
- #if (GPT_TIME_ELAPSED_API == STD_ON)
- /**
- * @brief GPT driver function for fetching the elapsed timer value.
- * @details Service for querying the time already elapsed.
- * In one shot mode, this is the value relative to the point in time, the channel has been
- * started with Gpt_StartTimer (calculated by the normal operation function by subtracting
- * the current minus the initial timer value and returning the absolute value).
- * In continuous mode, the function returns the timer value relative to the last timeout or
- * the start of the channel.
- * All time units used within the API services of the GPT driver shall be of the unit ticks.
- * Usage of re-entrant capability is only allowed if the callers take care that
- * there is no simultaneous usage of the same channel.
- * To get times out of register values it is necessary to know the oscillator frequency, pre
- * prescalers and so on. Since these settings are made in MCU and(or) in other modules it is
- * not possible to calculate such times. Hence the conversions between time and ticks shall
- * be part of an upper layer.
- * The driver needs to be initialized before calling Gpt_GetTimeElapsed(). Otherwise, the
- * function shall raise the development error GPT_E_UNINIT and return 0.
- *
- * @param[in] channel - channel id
- *
- * @return Gpt_ValueType - Elapsed Time in number of ticks
- *
- * @api
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_GetTimeElapsed_Activity
- */
- Gpt_ValueType Gpt_GetTimeElapsed(Gpt_ChannelType channel)
- {
- static Gpt_HwChannelInfoType returnHwChannelInfo;
- uint32 coreID;
- uint8 ChannelIndex;
- Gpt_ValueType returnValue = (Gpt_ValueType)0;
- returnHwChannelInfo.bChannelRollover =FALSE;
- returnHwChannelInfo.uTargetTime =(Gpt_ValueType)0;
- coreID = (uint32)Gpt_GetCoreID();
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelCall(GPT_TIMEELAPSED_ID, channel, coreID))
- {
- #endif
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- /*Gpt_Ipw_GetTimeElapsed() shall be called first, because the occurred ISRs can change
- the logical channel state between the checking of logical channel state and timestamp
- retrieval*/
- returnValue = Gpt_Ipw_GetTimeElapsed((((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)), &returnHwChannelInfo);
- /*Check the channel status*/
- switch(Gpt_aChannelInfo[channel].eChannelStatus)
- {
- case GPT_STATUS_RUNNING:
- {
- /*Check if channel counter has already rollover*/
- if ((TRUE == returnHwChannelInfo.bChannelRollover) && \
- (GPT_CH_MODE_ONESHOT == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_eChannelMode)
- )
- {
- /*The timer has already expired.The hardware timer status is not yet
- synchronized with the logical timer status*/
- returnValue = returnHwChannelInfo.uTargetTime;
- }
- }
- break;
- case GPT_STATUS_INITIALIZED:
- {
- returnValue = (Gpt_ValueType)0;
- }
- break;
- case GPT_STATUS_STOPPED:
- {
- /*Return elapsed time at the when the channel was stopped*/
- returnValue = Gpt_aStopTime[channel];
- }
- break;
- case GPT_STATUS_EXPIRED:
- {
- returnValue = returnHwChannelInfo.uTargetTime;
- }
- break;
- default:
- /*Only the above four channel states are allowed when this function is called*/
- break;
- }
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- }
- #endif
- return (returnValue);
- }
- #endif
- /*================================================================================================*/
- #if (GPT_TIME_REMAINING_API == STD_ON)
- /**
- * @brief GPT driver function for fetching the remaining timer value.
- * @details This function returns the timer value remaining until the next timeout period will
- * expire (calculated by the normal operation function by subtracting the timeout minus
- * the current timer value and returning the absolute value)
- * All time units used within the API services of the GPT driver shall be of the unit ticks.
- * Usage of re-entrant capability is only allowed if the callers take care that there is no
- * simultaneous usage of the same channel.
- * To get times out of register values it is necessary to know the oscillator frequency,
- * pre-scalers and so on. Since these settings are made in MCU and(or) in other modules it is
- * not possible to calculate such times. Hence the conversions between time and ticks shall
- * be part of an upper layer.
- * The driver needs to be initialized before calling Gpt_GetTimeRemaining(). Otherwise, the
- * function shall raise the development error GPT_E_UNINIT and return 0.
- *
- *
- * @param[in] channel - channel id
- *
- * @return Gpt_ValueType - Returns the time remaining until the target time is reached in number of ticks.
- *
- * @api
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_GetTimeRemaining_Activity
- */
- Gpt_ValueType Gpt_GetTimeRemaining(Gpt_ChannelType channel)
- {
- uint32 coreID;
- uint8 ChannelIndex;
- static Gpt_HwChannelInfoType returnHwChannelInfo;
- Gpt_ValueType returnValue = (Gpt_ValueType)0;
- returnHwChannelInfo.bChannelRollover =FALSE;
- returnHwChannelInfo.uTargetTime =(Gpt_ValueType)0;
- coreID = (uint32)Gpt_GetCoreID();
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelCall(GPT_TIMEREMAINING_ID, channel, coreID))
- {
- #endif
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- /* Calculate the remaining time from the elapsed time*/
- /* Gpt_Ipw_GetTimeElapsed() shall be called first, because the occurred ISRs can
- change the logical channel state between the checking of logical channel state
- and timestamps retrieval*/
- returnValue = Gpt_Ipw_GetTimeElapsed((((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)), &returnHwChannelInfo);
- /*Check the channel status*/
- switch(Gpt_aChannelInfo[channel].eChannelStatus)
- {
- case GPT_STATUS_RUNNING:
- {
- /*Check if channel counter has already roll-over*/
- if((TRUE == returnHwChannelInfo.bChannelRollover) && \
- (GPT_CH_MODE_ONESHOT == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_eChannelMode)
- )
- {
- /*The timer has already expired.The hardware timer status is not yet
- synchronized with the logical timer status*/
- returnValue = (Gpt_ValueType)0;
- }
- else
- {
- /*Calculate remaining time from elapsed time*/
- returnValue = returnHwChannelInfo.uTargetTime - returnValue;
- }
- }
- break;
- case GPT_STATUS_INITIALIZED:
- {
- returnValue = (Gpt_ValueType)0;
- }
- break;
- case GPT_STATUS_STOPPED:
- {
- returnValue = returnHwChannelInfo.uTargetTime-Gpt_aStopTime[channel];
- }
- break;
- case GPT_STATUS_EXPIRED:
- {
- returnValue = (Gpt_ValueType)0;
- }
- break;
- default:
- /*Only the above four channel states are allowed when this function is called*/
- break;
- }
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- }
- #endif
- return(returnValue);
- }
- #endif
- /*================================================================================================*/
- /**
- * @brief GPT driver function for starting a timer channel.
- * @details The function Gpt_StartTimer shall start the selected timer channel with a defined
- * time-out period.
- * The function Gpt_StartTimer shall invoke the configured notification for that channel
- * (see also GPT292) after the time-out period referenced via the parameter value (if
- * enabled).
- * All time units used within the API services of the GPT driver shall be of the unit ticks.
- * In production mode no error is generated. The rational is that it adds no
- * additional functionality to the driver. In this case the timer will be restarted with the
- * time-out value, given as a parameter to the service.
- * Usage of re-entrant capability is only allowed if the callers take care that
- * there is no simultaneous usage of the same channel.
- * To get times out of register values it is necessary to know the oscillator
- * frequency, pre-scalers and so on. Since these settings are made in MCU and(or) in other
- * modules it is not possible to calculate such times. Hence the conversions between time
- * and ticks shall be part of an upper layer.
- * The driver needs to be initialized before calling Gpt_StartTimer(). Otherwise, the
- * function Gpt_StartTimer shall raise the development error GPT_E_UNINIT.
- *
- * @param[in] channel channel id
- * @param[in] value time-out period (in number of ticks) after a notification or a
- * wakeup event shall occur
- *
- * @api
- * @return void
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_StartTimer_Activity
- */
- void Gpt_StartTimer
- (
- Gpt_ChannelType channel,
- Gpt_ValueType value
- )
- {
- uint32 coreID;
- uint8 ChannelIndex;
- Std_ReturnType returnValue;
- coreID = (uint32)Gpt_GetCoreID();
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelCall(GPT_STARTTIMER_ID, channel, coreID))
- {
- #endif
- if ((Std_ReturnType)E_OK == Gpt_ValidateChannelStatus(GPT_STARTTIMER_ID, channel, coreID))
- {
- #if (GPT_VALIDATE_PARAM == STD_ON)
- if ((Std_ReturnType)E_OK == Gpt_ValidateParamValue(GPT_STARTTIMER_ID, channel, value, coreID))
- {
- #endif
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- /*Enable hardware interrupts for the one-shot mode to set the status of channel*/
- if (GPT_CH_MODE_ONESHOT == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_eChannelMode)
- {
- Gpt_Ipw_EnableInterrupt
- (
- ((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)
- );
- }
- /* Change GPT channel status.Channel status change shall be made before to start
- the hardware in order to not change the channel status from EXPIRED to RUNNING*/
- Gpt_aChannelInfo[channel].eChannelStatus = GPT_STATUS_RUNNING;
- /* Call low level API */
- returnValue = Gpt_Ipw_StartTimer(((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig),value);
- if((Std_ReturnType)E_OK != returnValue)
- {
- (void)Det_ReportRuntimeError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)GPT_STARTTIMER_ID,\
- (uint8)GPT_E_TIMEOUT\
- );
- }
- #if (GPT_VALIDATE_PARAM == STD_ON)
- }
- #endif
- }
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- }
- #endif
- return;
- }
- /*================================================================================================*/
- /**
- * @brief GPT driver function for stopping a timer channel.
- * @details Service for stopping the selected timer channel
- * Stopping a timer channel, not been started before will not return a development error
- * Timer channels configured in one shot mode are stopped automatically, when the
- * time-out period has expired.
- * Usage of re-entrant capability is only allowed if the callers take care that
- * there is no simultaneous usage of the same channel.
- * The driver needs to be initialized before calling Gpt_StopTimer(). Otherwise,
- * the function shall raise the development error GPT_E_UNINIT.
- *
- * @param[in] channel channel id
- * @return void
- *
- * @api
- *
- * @pre The driver needs to be initialized. Gpt_StartTimer must be called before.
- * @implements Gpt_StopTimer_Activity
- */
- void Gpt_StopTimer(Gpt_ChannelType channel)
- {
- uint32 coreID;
- uint8 ChannelIndex;
- static Gpt_HwChannelInfoType returnHwChannelInfo;
- Gpt_ValueType uElapsedTime;
- returnHwChannelInfo.bChannelRollover =FALSE;
- returnHwChannelInfo.uTargetTime =(Gpt_ValueType)0;
- coreID = (uint32)Gpt_GetCoreID();
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelCall(GPT_STOPTIMER_ID, channel, coreID))
- {
- #endif
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- /*Gpt_Ipw_GetTimeElapsed() shall be called first, because the occurred ISRs can change
- the logical channel state between the checking of logical channel state and timestamps
- retrieval*/
- /* Get the elapsed time for later use by other API calls*/
- uElapsedTime = Gpt_Ipw_GetTimeElapsed((((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)), &returnHwChannelInfo);
- /*Check the logical channel status*/
- if (GPT_STATUS_RUNNING == Gpt_aChannelInfo[channel].eChannelStatus)
- {
- /* Call low level stop timer */
- Gpt_Ipw_StopTimer(((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig));
- if ((TRUE == returnHwChannelInfo.bChannelRollover) && \
- (GPT_CH_MODE_ONESHOT == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_eChannelMode)
- )
- {
- /*This action could be executed only when the function is called during a critical
- section implemented by disabling all interrupts*/
- /*Set channel status to EXPIRED*/
- Gpt_aChannelInfo[channel].eChannelStatus = GPT_STATUS_EXPIRED;
- }
- else
- {
- /* Store the stopping time for later use by other API calls*/
- Gpt_aStopTime[channel] = uElapsedTime;
- /* Set GPT channel status to stopped*/
- Gpt_aChannelInfo[channel].eChannelStatus = GPT_STATUS_STOPPED;
- }
- }
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- }
- #endif
- return;
- }
- /*================================================================================================*/
- #if (GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON)
- /**
- * @brief GPT driver function for enabling the notification for a timer channel.
- * @details Service for enabling the notification for a channel during runtime.
- * This function can be called, while the timer is already running.
- * Usage of re-entrant capability is only allowed if the callers take care that
- * there is no simultaneous usage of the same channel.
- * The driver needs to be initialized before calling Gpt_EnableNotification(). Otherwise,
- * the function Gpt_EnableNotification shall raise the development error GPT_E_UNINIT.
- *
- * @param[in] channel channel id
- * @return void
- * @api
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_EnableNotification_Activity
- */
- void Gpt_EnableNotification(Gpt_ChannelType channel)
- {
- uint32 coreID;
- uint8 ChannelIndex;
- coreID = (uint32)Gpt_GetCoreID();
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelCall(GPT_ENABLENOTIFICATION_ID, channel, coreID))
- {
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- if ((Std_ReturnType)E_OK == Gpt_ValidateChannelNotification(GPT_ENABLENOTIFICATION_ID, channel, coreID))
- {
- #endif
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- /* Set the enable notification attribute */
- Gpt_aChannelInfo[channel].bNotificationEnabled = TRUE;
- if (GPT_MODE_NORMAL == Gpt_eMode)
- {
- /*Enable hardware interrupts*/
- Gpt_Ipw_EnableInterrupt
- (
- ((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)
- );
- }
- #if (GPT_VALIDATE_PARAM == STD_ON)
- }
- #endif
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- }
- #endif
- return;
- }
- #endif
- /*================================================================================================*/
- #if (GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON)
- /**
- * @brief GPT driver function for disabling the notification for a timer channel.
- * @details Service for disabling the notification for a channel during runtime.
- * This function can be called, while the timer is already running
- * When disabled, no notification will be sent. When re-enabled again, the user
- * will not be notified of events, occurred while notifications have been disabled.
- * Usage of re-entrant capability is only allowed if the callers take care that
- * there is no simultaneous usage of the same channel.
- * The driver needs to be initialized before calling Gpt_DisableNotification().
- * Otherwise, the function shall raise the development error GPT_E_UNINIT.
- *
- * @param[in] channel channel id
- * @return void
- * @api
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_DisableNotification_Activity
- */
- void Gpt_DisableNotification(Gpt_ChannelType channel)
- {
- uint32 coreID;
- uint8 ChannelIndex;
- coreID = (uint32)Gpt_GetCoreID();
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelCall(GPT_DISABLENOTIFICATION_ID, channel, coreID))
- {
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- if ((Std_ReturnType)E_OK == Gpt_ValidateChannelNotification(GPT_DISABLENOTIFICATION_ID, channel, coreID))
- {
- #endif
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- /* Set the enable notification attribute */
- Gpt_aChannelInfo[channel].bNotificationEnabled = FALSE;
- /* Disable hardware interrupts if the channel is not running in the ONE-SHUT mode.
- This is needed because the channel state is updated by ISR for ONE-SHOT mode */
- if ((GPT_MODE_NORMAL == Gpt_eMode) && \
- ((GPT_CH_MODE_CONTINUOUS == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_eChannelMode) \
- || (GPT_STATUS_RUNNING != Gpt_aChannelInfo[channel].eChannelStatus)
- )
- )
- {
- /*Disable hardware interrupts*/
- Gpt_Ipw_DisableInterrupt
- (
- ((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)
- );
- }
- #if (GPT_VALIDATE_PARAM == STD_ON)
- }
- #endif
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- }
- #endif
- return;
- }
- #endif
- /*================================================================================================*/
- #if (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON)
- /**
- * @brief GPT driver function for setting the operation mode.
- * @details Service for GPT mode selection. This service shall set the operation mode to the given
- * mode parameter .
- * When sleep mode is requested, the ECU State Manager calls Gpt_SetMode with mode
- * parameter "GPT_MODE_SLEEP" and prepares the GPT for sleep mode. The MCU Driver is then
- * putting the controller into SLEEP mode
- * The driver needs to be initialized before calling Gpt_SetMode(). Otherwise, the
- * function Gpt_SetMode shall raise the development error GPT_E_UNINIT.
- *
- * @param[in] eMode operation mode
- * - GPT_MODE_NORMAL: Normal operation mode of the GPT driver.
- * - GPT_MODE_SLEEP: Sleep mode of the GPT driver (wakeup capable)
- * @return void
- * @api
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_SetMode_Activity
- */
- void Gpt_SetMode(Gpt_ModeType eMode)
- {
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_ON)
- uint32 coreID = (uint32)Gpt_GetCoreID();
- #endif
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_OFF)
- (void)eMode;
- #endif
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_ON)
- static Gpt_HwChannelInfoType returnHwChannelInfo;
- Gpt_ValueType uElapsedTime = 0U;
- Gpt_ChannelType ChannelIndex;
- Gpt_ChannelType channel;
- returnHwChannelInfo.bChannelRollover =FALSE;
- returnHwChannelInfo.uTargetTime =(Gpt_ValueType)0;
- #if (GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- /*Validate the driver calling context*/
- if((Std_ReturnType)E_OK == Gpt_ValidateGlobalCall(GPT_SETMODE_ID, coreID))
- {
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateParamMode(eMode))
- {
- #endif
- /*Implements the behaviour for the sleep mode*/
- if(GPT_MODE_SLEEP == eMode)
- {
- for (ChannelIndex = 0U; ChannelIndex < Gpt_pConfig[coreID]->channelCount; ChannelIndex++)
- {
- channel = Gpt_ConvertChannelIndexToChannel(ChannelIndex, coreID);
- /* Check for wakeup enabled channel*/
- if (TRUE == Gpt_aChannelInfo[channel].bWakeupEnabled)
- {
- /*Enable hardware interrupts*/
- Gpt_Ipw_EnableInterrupt(((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig));
- }
- /* Disable interrupts and stop the channel*/
- else
- {
- /*Disable hardware interrupts*/
- Gpt_Ipw_DisableInterrupt(((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig));
- /*Gpt_Ipw_GetTimeElapsed() shall be called first, because the occurred ISRs
- can change the logical channel state between the checking of logical channel
- state and timestamp retrieval*/
- /* Get the elapsed time for later use by other API calls*/
- uElapsedTime = Gpt_Ipw_GetTimeElapsed((((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)), &returnHwChannelInfo);
- /*Stop the running timer*/
- if (GPT_STATUS_RUNNING == Gpt_aChannelInfo[channel].eChannelStatus)
- {
- if ((TRUE == returnHwChannelInfo.bChannelRollover) && \
- (GPT_CH_MODE_ONESHOT == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_eChannelMode)
- )
- {
- /*This action could be executed only when the function is called
- during a critical section implemented by disabling all interrupts*/
- /*Set the channel status to EXPIRED*/
- Gpt_aChannelInfo[channel].eChannelStatus = GPT_STATUS_EXPIRED;
- }
- else
- {
- /* Store the stopping time for later use by other API calls*/
- Gpt_aStopTime[channel] = uElapsedTime;
- /* Set the channel status to STOPPED*/
- Gpt_aChannelInfo[channel].eChannelStatus = GPT_STATUS_STOPPED;
- }
- /* Call low level stop timer */
- Gpt_Ipw_StopTimer
- (
- ((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)
- );
- }
- }
- }
- #if(GPT_PREDEFTIMER_FUNCTIONALITY_API == STD_ON)
- /* Deinitialize and Stop Predef Timers. */
- Gpt_Ipw_StopPredefTimer(Gpt_pConfig[coreID]);
- #endif
- /*Set the driver mode to sleep */
- Gpt_eMode = GPT_MODE_SLEEP;
- }
- else if (GPT_MODE_NORMAL == eMode)
- {
- #if(GPT_PREDEFTIMER_FUNCTIONALITY_API == STD_ON)
- if ((Gpt_ModeType)GPT_MODE_SLEEP == Gpt_eMode)
- {
- /* Start for each predef timer status informations. */
- Gpt_Ipw_StartPredefTimer(Gpt_pConfig[coreID]);
- }
- #endif
- /*Implements the behavior for normal mode*/
- for (ChannelIndex = 0U; ChannelIndex < Gpt_pConfig[coreID]->channelCount; ChannelIndex++)
- {
- channel = Gpt_ConvertChannelIndexToChannel(ChannelIndex, coreID);
- #if (GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON)
- if (TRUE == Gpt_aChannelInfo[channel].bNotificationEnabled)
- {
- /*Enable hardware interrupts*/
- Gpt_Ipw_EnableInterrupt
- (
- ((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)
- );
- }
- else
- {
- #endif
- /* Disable hardware interrupts if the channel is not running in the ONE-SHUT mode.
- This is needed because the channel state is updated by ISR for ONE-SHOT mode */
- if((GPT_STATUS_RUNNING != Gpt_aChannelInfo[channel].eChannelStatus) || \
- (GPT_CH_MODE_CONTINUOUS == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_eChannelMode)
- )
- {
- /*Disable hardware interrupts*/
- Gpt_Ipw_DisableInterrupt
- (
- ((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)
- );
- }
- #if (GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON)
- }
- #endif
- }
- /*Set the driver mode to normal mode*/
- Gpt_eMode = GPT_MODE_NORMAL;
- }
- else
- {
- /* This else clause is required due to MISRA rules */
- }
- #if (GPT_VALIDATE_PARAM == STD_ON)
- }
- #endif
- #if (GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- }
- #endif
- #endif /*GPT_REPORT_WAKEUP_SOURCE*/
- return;
- }
- #endif
- /*================================================================================================*/
- #if (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON)
- /**
- * @brief GPT driver function for disabling the wakeup interrupt invocation for a timer channel.
- * @details This service shall disable the wakeup interrupt invocation of a single GPT
- * channel.
- * Usage of re-entrant capability is only allowed if the callers take care that
- * there is no simultaneous usage of the same channel.
- * The driver needs to be initialized before calling Gpt_DisableWakeup(). Otherwise, the
- * function Gpt_DisableWakeup shall raise the development error GPT_E_UNINIT.
- *
- * @param[in] channel channel id
- * @return void
- * @api
- *
- * @pre The driver needs to be initialized.
- * @implements Gpt_DisableWakeup_Activity
- */
- void Gpt_DisableWakeup(Gpt_ChannelType channel)
- {
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_ON)
- uint32 coreID = (uint32)Gpt_GetCoreID();
- uint8 ChannelIndex;
- #endif
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_OFF)
- (void)channel;
- #endif
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_ON)
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelCall(GPT_DISABLEWAKEUP_ID, channel, coreID))
- {
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelWakeup(GPT_DISABLEWAKEUP_ID, channel, coreID))
- {
- #endif
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- /* Set the enable wakeup attribute */
- Gpt_aChannelInfo[channel].bWakeupEnabled = FALSE;
- /* Disable hardware interrupts if the channel is not running in the ONE-SHUT mode.
- This is needed because the channel state is updated by ISR for ONE-SHOT mode */
- if ((GPT_MODE_SLEEP == Gpt_eMode) && \
- ((GPT_CH_MODE_CONTINUOUS == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_eChannelMode)
- || (GPT_STATUS_RUNNING != Gpt_aChannelInfo[channel].eChannelStatus)
- )
- )
- {
- /*Disable hardware interrupts*/
- Gpt_Ipw_DisableInterrupt
- (
- ((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)
- );
- }
- #if (GPT_VALIDATE_PARAM == STD_ON)
- }
- #endif
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- }
- #endif
- #endif /*GPT_REPORT_WAKEUP_SOURCE*/
- return;
- }
- #endif
- /*================================================================================================*/
- #if (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON)
- /**
- * @brief GPT driver function for enabling the wakeup interrupt invocation for a timer channel.
- * @details This service shall re-enable the wakeup interrupt invocation of a single GPT
- * channel.
- * If supported by hardware and enabled, an internal hardware timer can serve as a
- * wakeup source
- * Usage of re-entrant capability is only allowed if the callers take care that
- * there is no simultaneous usage of the same channel.
- *
- * @param[in] channel channel id
- * @return void
- * @api
- *
- * @pre The driver needs to be initialized. The channel must be configured as wakeup capable.
- * @implements Gpt_EnableWakeup_Activity
- */
- void Gpt_EnableWakeup(Gpt_ChannelType channel)
- {
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_ON)
- uint32 coreID = (uint32)Gpt_GetCoreID();
- uint8 ChannelIndex;
- #endif
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_OFF)
- (void)channel;
- #endif
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_ON)
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelCall(GPT_ENABLEWAKEUP_ID, channel, coreID))
- {
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelWakeup(GPT_ENABLEWAKEUP_ID, channel, coreID))
- {
- #endif
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- /* Functionality implementation */
- /* Set the enable wakeup attribute */
- Gpt_aChannelInfo[channel].bWakeupEnabled = TRUE;
- if (GPT_MODE_SLEEP == Gpt_eMode)
- {
- /*Enable hardware interrupts*/
- Gpt_Ipw_EnableInterrupt
- (
- ((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig)
- );
- }
- #if (GPT_VALIDATE_PARAM == STD_ON)
- }
- #endif
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- }
- #endif
- #endif /*GPT_REPORT_WAKEUP_SOURCE*/
- return;
- }
- #endif
- /*================================================================================================*/
- #if (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON)
- /**
- * @brief GPT driver function for checking if a wakeup capable GPT channel is the source for a
- * wakeup event.
- * @details Checks if a wakeup capable GPT channel is the source for a wakeup event and calls the ECU
- * state manager service EcuM_SetWakeupEvent in case of a valid GPT channel wakeup event.
- * The driver needs to be initialized before calling Gpt_CheckWakeup(). Otherwise, the
- * function Gpt_CheckWakeup shall raise the development error GPT_E_UNINIT.
- *
- * @param[in] wakeupSource wakeup source
- * @return void
- * @api
- *
- * @pre The driver needs to be initialized. The channel must be configured as wakeup capable.
- * @implements Gpt_CheckWakeup_Activity
- */
- void Gpt_CheckWakeup(EcuM_WakeupSourceType wakeupSource)
- {
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_ON)
- uint32 coreID = (uint32)Gpt_GetCoreID();
- #endif
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_OFF)
- (void) wakeupSource;
- #endif
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_ON)
- Gpt_ChannelType channel;
- uint32 ChannelIndex;
- #if (GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- /*Validate the driver calling context*/
- if((Std_ReturnType)E_OK == Gpt_ValidateGlobalCall(GPT_CHECKWAKEUP_ID, coreID))
- {
- #endif
- for (ChannelIndex = 0U; ChannelIndex < Gpt_pConfig[coreID]->channelCount; ChannelIndex++)
- {
- channel = Gpt_ConvertChannelIndexToChannel(ChannelIndex, coreID);
- if ((((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_uWakeupSource) == wakeupSource) && \
- (TRUE == Gpt_aChannelInfo[channel].bWakeupGenerated)
- )
- {
- /*Reset the wakeup flag */
- Gpt_aChannelInfo[channel].bWakeupGenerated = FALSE;
- /* Calling EcuM_SetWakeupEvent and exit*/
- EcuM_SetWakeupEvent(wakeupSource);
- break;
- }
- } /*for*/
- #if (GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- }
- #endif
- #endif /* GPT_REPORT_WAKEUP_SOURCE */
- return;
- }
- #endif /* GPT_WAKEUP_FUNCTIONALITY_API */
- /*================================================================================================*/
- /**
- * @brief Gpt common handler to implements generic part of the ISR.
- * @details Generic function used by all interrupt service routines to call notification
- * functions and wakeup the EcuM
- *
- * @param[in] channel logic channel number
- * @return void
- * @pre The driver needs to be initialized.
- * @implements Gpt_ProcessCommonInterrupt_Activity
- */
- void Gpt_ProcessCommonInterrupt(uint8 channel)
- {
- uint32 coreID;
- uint8 ChannelIndex;
- coreID = (uint32)Gpt_GetCoreID();
- if (Gpt_pConfig[coreID] != NULL_PTR)
- {
- /* Extract the logical channel from the hardware to logic map table */
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- /*Stop the timer for one-shot mode*/
- if (GPT_CH_MODE_ONESHOT == (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_eChannelMode)
- {
- /*Stop channel*/
- Gpt_Ipw_StopTimer(((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig));
- /* Change the channel status to expired */
- Gpt_aChannelInfo[channel].eChannelStatus = GPT_STATUS_EXPIRED;
- }
- #if (GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON)
- if ((GPT_MODE_NORMAL == Gpt_eMode) && (TRUE == Gpt_aChannelInfo[channel].bNotificationEnabled))
- {
- (*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_pfNotification();
- }
- #endif
- #if (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON)
- #if (GPT_REPORT_WAKEUP_SOURCE == STD_ON)
- if ((GPT_MODE_SLEEP == Gpt_eMode) && (TRUE == Gpt_aChannelInfo[channel].bWakeupEnabled))
- {
- Gpt_aChannelInfo[channel].bWakeupGenerated =TRUE;
- EcuM_CheckWakeup((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_uWakeupSource);
- }
- #endif
- #endif
- }
- return;
- }
- /*================================================================================================*/
- #if (GPT_CHANGE_NEXT_TIMEOUT_VALUE == STD_ON)
- /**
- * @brief The function changes the time out period value of the requested running channel.
- * @details The function changes the time out period (in number of ticks) of the channel is
- * running which will be used after the first compare matching.
- * This is a non-autosar function.
- * @param[in] channel channel id
- * @param[in] value time out period (in number of ticks) after a notification shall occur
- * @return void
- * @pre Gpt_Init and Gpt_StartTimer must be called before.
- * @implements
- */
- void Gpt_ChangeNextTimeoutValue(Gpt_ChannelType channel, Gpt_ValueType value)
- {
- uint32 coreID;
- uint8 ChannelIndex;
- #if (GPT_DEV_ERROR_DETECT == STD_ON)
- Std_ReturnType returnValue;
- #endif
- coreID = (uint32)Gpt_GetCoreID();
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelCall(GPT_CHANGE_NEXT_TIMEOUT_VALUE_ID, channel, coreID))
- {
- #endif
- if ((Std_ReturnType)E_OK == Gpt_ValidateChannelStatus(GPT_CHANGE_NEXT_TIMEOUT_VALUE_ID, channel, coreID))
- {
- #if (GPT_VALIDATE_PARAM == STD_ON)
- if ((Std_ReturnType)E_OK == Gpt_ValidateParamValue(GPT_CHANGE_NEXT_TIMEOUT_VALUE_ID, channel, value, coreID))
- {
- #endif
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- #if (GPT_DEV_ERROR_DETECT == STD_ON)
- /* Call low level API */
- returnValue = Gpt_Ipw_ChangeNextTimeoutValue(((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig), value);
- if((Std_ReturnType)E_OK != returnValue)
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)GPT_CHANGE_NEXT_TIMEOUT_VALUE_ID,\
- (uint8)GPT_E_PARAM_CHANNEL\
- );
- }
- #else
- /* Call low level API */
- (void)Gpt_Ipw_ChangeNextTimeoutValue(((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig), value);
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- }
- #endif
- }
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- }
- #endif
- return;
- }
- #endif /* GPT_CHANGE_NEXT_TIMEOUT_VALUE == STD_ON */
- /*================================================================================================*/
- #if (GPT_CHAIN_MODE == STD_ON)
- /**
- * @brief The function enables the chain functionality for timer.
- * @details The function enables the chain functionality for timer. Timer will be chained with timer n-1.
- Channel 0 cannot be chained.
- * This is a non-autosar function.
- * @param[in] channel channel id
- * @return void
- * @pre Gpt_Init must be called before.
- *
- * @implements Gpt_Channel_EnableChainMode_Activity
- */
- void Gpt_Channel_EnableChainMode(Gpt_ChannelType channel)
- {
- uint32 coreID;
- uint8 ChannelIndex;
- #if (GPT_DEV_ERROR_DETECT == STD_ON)
- Std_ReturnType returnValue;
- #endif
- coreID = (uint32)Gpt_GetCoreID();
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelCall(GPT_ENABLE_CHAIN_MODE_ID, channel, coreID))
- {
- #endif
- if ((Std_ReturnType)E_OK == Gpt_ValidateChannelStatus(GPT_ENABLE_CHAIN_MODE_ID, channel, coreID))
- {
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- #if (GPT_DEV_ERROR_DETECT == STD_ON)
- /* Call low level API */
- returnValue = Gpt_Ipw_EnableChainMode(((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig));
- if((Std_ReturnType)E_OK != returnValue)
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)GPT_ENABLE_CHAIN_MODE_ID,\
- (uint8)GPT_E_PARAM_CHANNEL\
- );
- }
- #else
- /*Call low level API.*/
- (void)Gpt_Ipw_EnableChainMode(((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig));
- #endif
- }
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- }
- #endif
- }
- #endif /*GPT_CHAIN_MODE == STD_ON*/
- /*================================================================================================*/
- #if (GPT_CHAIN_MODE == STD_ON)
- /**
- * @brief The function disables the chain functionality for timer.
- * @details The function disables the chain functionality for timer. Timer will not be chained with timer n-1.
- Channel 0 cannot be chained or unchained.
- * This is a non-autosar function.
- * @param[in] channel channel id
- * @return void
- * @pre Gpt_Init must be called before.
- *
- * @implements Gpt_Channel_DisableChainMode_Activity
- */
- void Gpt_Channel_DisableChainMode(Gpt_ChannelType channel)
- {
- uint32 coreID;
- uint8 ChannelIndex;
- #if (GPT_DEV_ERROR_DETECT == STD_ON)
- Std_ReturnType returnValue;
- #endif
- coreID = (uint32)Gpt_GetCoreID();
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- if((Std_ReturnType)E_OK == Gpt_ValidateChannelCall(GPT_DISABLE_CHAIN_MODE_ID, channel, coreID))
- {
- #endif
- if ((Std_ReturnType)E_OK == Gpt_ValidateChannelStatus(GPT_DISABLE_CHAIN_MODE_ID, channel, coreID))
- {
- ChannelIndex = (*(Gpt_pConfig[coreID]->u8GptChannelIdToIndexMap))[channel];
- #if (GPT_DEV_ERROR_DETECT == STD_ON)
- /* Call low level API */
- returnValue = Gpt_Ipw_DisableChainMode(((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig));
- if((Std_ReturnType)E_OK != returnValue)
- {
- (void)Det_ReportError\
- (\
- (uint16)GPT_MODULE_ID,\
- (uint8)GPT_INSTANCE_ID,\
- (uint8)GPT_DISABLE_CHAIN_MODE_ID,\
- (uint8)GPT_E_PARAM_CHANNEL\
- );
- }
- #else
- /*Call low level API.*/
- (void)Gpt_Ipw_DisableChainMode(((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig));
- #endif
- }
- #if (GPT_VALIDATE_CHANNEL_CALL == STD_ON)
- }
- #endif
- }
- #endif /*GPT_CHAIN_MODE == STD_ON*/
- /*================================================================================================*/
- #if (GPT_SET_CLOCK_MODE == STD_ON)
- /**
- * @brief This function changes the channel pre scaler.
- * @details This function sets all channels pre scalers based on the input mode.
- *
- * @param[in] eClkMode prescaler setting ( NORMAL or ALTERNATE )
- * @return void
- * @pre Gpt_Init must be called before.
- *
- * @implements Gpt_SetClockMode_Activity
- */
- void Gpt_SetClockMode(Gpt_ClockModeType eClkMode)
- {
- uint32 coreID = (uint32)Gpt_GetCoreID();
- Gpt_ChannelType ChannelIndex;
- #if (GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- Std_ReturnType returnValue;
- returnValue = Gpt_ValidateGlobalCall(GPT_SET_CLOCK_MODE_ID, coreID);
- if((Std_ReturnType)E_OK == returnValue)
- {
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- if ((Std_ReturnType)E_OK == Gpt_ValidateParamSetClockMode(eClkMode))
- {
- #endif
- for (ChannelIndex = 0U; ChannelIndex < Gpt_pConfig[coreID]->instanceCount; ChannelIndex++)
- {
- Gpt_Ipw_SetClockModeInStance
- (
- (&((*(Gpt_pConfig[coreID]->Gpt_Ipw_HwInstanceConfig))[ChannelIndex])), eClkMode
- );
- }
- #if (GPT_HW_CHANNEL_USED == STD_ON)
- for (ChannelIndex = 0U; ChannelIndex < Gpt_pConfig[coreID]->channelCount; ChannelIndex++)
- {
- Gpt_Ipw_SetClockModeChannel
- (
- ((*(Gpt_pConfig[coreID]->Gpt_pChannelConfig))[ChannelIndex].Gpt_Ipw_HwChannelConfig),eClkMode
- );
- }
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- }
- #endif
- #if (GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- }
- #endif
- }
- #endif /* GPT_SET_CLOCK_MODE */
- #if(GPT_PREDEFTIMER_FUNCTIONALITY_API == STD_ON)
- /*================================================================================================*/
- /**
- * @brief Provides the current value of the given predefined free-running timer
- * @details This function provides the current value of the given predefined free-running timer.
- *
- * @param[in] PredefTimer: Gpt_PredefTimerType ( GPT_PREDEF_TIMER_1US_16BIT,
- * GPT_PREDEF_TIMER_1US_24BIT,
- * GPT_PREDEF_TIMER_1US_32BIT
- * GPT_PREDEF_TIMER_100US_32BIT)
- * @param[out] TimeValuePtr: Pointer to time value destination data in RAM
- * @pre Gpt_Init must be called before.
- * @return returnValue - E_OK: no error has been detected.
- * - E_NOT_OK: aborted due to errors.
- *
- * @implements Gpt_GetPredefTimerValue_Activity
- */
- Std_ReturnType Gpt_GetPredefTimerValue
- (
- Gpt_PredefTimerType PredefTimer,
- uint32 * TimeValuePtr
- )
- {
- uint32 coreID;
- Std_ReturnType returnValue = (Std_ReturnType)E_NOT_OK;
- Gpt_ChannelType channel;
- coreID = (uint32)Gpt_GetCoreID();
- #if (GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- returnValue = Gpt_ValidateGlobalCall(GPT_GET_PREDEF_TIMERVALUE_ID, coreID);
- if((Std_ReturnType)E_OK == returnValue)
- {
- #endif
- #if (GPT_VALIDATE_PARAM == STD_ON)
- returnValue = Gpt_ValidatePointerGetPredefTimer(TimeValuePtr);
- if((Std_ReturnType)E_OK == returnValue)
- {
- returnValue = Gpt_ValidateParamTypePredefTimer(PredefTimer, coreID);
- if((Std_ReturnType)E_OK == returnValue)
- {
- #endif
- returnValue = Gpt_ValidateMode(GPT_GET_PREDEF_TIMERVALUE_ID);
- if((Std_ReturnType)E_OK ==returnValue)
- {
- channel = (Gpt_ChannelType)PredefTimer;
- Gpt_Ipw_GetPredefTimerValue((Gpt_pConfig[coreID]->Gpt_pChannelPredefConfigType)[channel], PredefTimer, TimeValuePtr);
- }
- else
- {
- *TimeValuePtr = 0U;
- }
- #if (GPT_VALIDATE_PARAM == STD_ON)
- }
- else
- {
- *TimeValuePtr = 0U;
- }
- }
- else
- {
- /* This else clause is required due to MISRA rules */
- }
- #endif
- #if (GPT_VALIDATE_GLOBAL_CALL == STD_ON)
- }
- #endif
- return returnValue;
- }
- #endif
- #define GPT_STOP_SEC_CODE
- #include "Gpt_MemMap.h"
- #ifdef __cplusplus
- }
- #endif /* GPT_C */
- /** @} */
|