/*!
* @file     CDD_Rtc.h
*
* @version  1.0.0
*
* @brief    The header of the register definitions of the RTC module.
*           This header file includes the register definitions of the RTC module.
* @attention
*
* Project Name      : AUTOSAR MCAL
*
* Platform          : Arm
*
* Autosar Standard  : Classic Platform 4.4.0
*
* Compiled Version  : G32A10xx_MCAL_1_0_0_15-Nov-25
*
* Copyright (C) 2026 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (Geehy Semiconductor Software License Agreement).
*
* The program is only for reference, which is distributed in the hope
* that it will be usefull and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the Geehy Semiconductor Software License Agreement for the governing permissions
* and limitations under the License.
*/

#ifndef CDD_RTC_H
#define CDD_RTC_H

#ifdef __cplusplus
extern "C"{
#endif  /* ifdef __cplusplus */

#include "Reg_eSys.h"
#include "Rtc_Cfg.h"
#include "Rtc_Types.h"
/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup RTC_Driver
  * @brief RTC driver modules
  @{
*/

/** @defgroup RTC_Macros
  @{
*/
/***********************************************************************************************************
                                    VENDOR ID & AUTOSAR VERSION INFO
************************************************************************************************************/
/** Module ID of this module, as defined in the BSW Module List. */
#define RTC_H_MODULE_ID                               0x00FFU
/** Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define RTC_H_VENDOR_ID                               0x00C1U
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */  
#define RTC_H_AR_RELEASE_MAJOR_VERSION                0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define RTC_H_AR_RELEASE_MINOR_VERSION                0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define RTC_H_AR_RELEASE_REVISION_VERSION             0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */  
#define RTC_H_SW_MAJOR_VERSION                        0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define RTC_H_SW_MINOR_VERSION                        0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define RTC_H_SW_PATCH_VERSION                        0x00U

/***********************************************************************************************************
                                      VERSION INFOMATION VERIFICATION
************************************************************************************************************/
#ifdef ENABLE_INTERMODULE_MCAL_CHECK
    /* Make sure the AUTOSAR major version number is the same between Rtc_Reg.h and Reg_eSys.h */
    #if (RTC_H_AR_RELEASE_MAJOR_VERSION != REG_ESYS_H_AR_RELEASE_MAJOR_VERSION)
        #error "AUTOSAR Major Version Number mismatch between Rtc_Reg.h and Reg_eSys.h"
    #endif
    /* Make sure the AUTOSAR minor version number is the same between Rtc_Reg.h and Reg_eSys.h */
    #if (RTC_H_AR_RELEASE_MINOR_VERSION != REG_ESYS_H_AR_RELEASE_MINOR_VERSION)
        #error "AUTOSAR Minor Version Number mismatch between Rtc_Reg.h and Reg_eSys.h"
    #endif
#endif

/*******************************************************************************
                        AUTOSAR API SERVICE IDS
*******************************************************************************/

/** Service ID for Rtc_Init */
#define SID_RTC_INIT                                ((uint8)0x00U)

/** Service ID for Rtc_DeInit */
#define SID_RTC_DEINIT                              ((uint8)0x01U)

/** Service ID for RTC_AlarmsConfig */
#define SID_RTC_ALARMSCONFIG                        ((uint8)0x02U)

/** Service ID for Rtc_EnableAlarm */
#define SID_RTC_ENABLEALARM                         ((uint8)0x03U)

/** Service ID for Rtc_DisableAlarm */
#define SID_RTC_DISABLEALARM                        ((uint8)0x04U)

/** Service ID for Rtc_GetVersionInfo */
#define SID_RTC_GET_VERSION_INFO                    ((uint8)0x05U)

/** Service ID for Rtc_EnableInit */
#define SID_RTC_ENABLEINIT                          ((uint8)0x06U)

/** Service ID for Rtc_DisableInit */
#define SID_RTC_DISABLEINIT                         ((uint8)0x07U)

/** Service ID for Rtc_WaitForSynchro */
#define SID_RTC_WAITFORSYNCHRO                      ((uint8)0x08U)

/** Service ID for Rtc_EnableBypassShadow */
#define SID_RTC_ENABLEBYPASSSHADOW                  ((uint8)0x09U)

/** Service ID for Rtc_DisableBypassShadow */
#define SID_RTC_DISABLEBYPASSSHADOW                 ((uint8)0x0AU)

/** Service ID for Rtc_ReadTime */
#define SID_RTC_READTIME                            ((uint8)0x0BU)

/** Service ID for Rtc_ReadSubSecond */
#define SID_RTC_READSUBSECOND                       ((uint8)0x0CU)

/** Service ID for Rtc_ConfigDate */
#define SID_RTC_CONFIGDATA                          ((uint8)0x0DU)

/** Service ID for Rtc_ReadDate */
#define SID_RTC_READDATE                            ((uint8)0x0EU)

/** Service ID for Rtc_ReadAlarm */
#define SID_RTC_READALARM                           ((uint8)0x0FU)

/** Service ID for Rtc_ConfigAlarmSubSecond */
#define SID_RTC_CONFIGALARMSUBSECOND                ((uint8)0x10U)

/** Service ID for Rtc_ReadAlarmSubSecond */
#define SID_RTC_READALARMSUBSECOND                  ((uint8)0x11U)

/** Service ID for Rtc_ConfigDayLightSaving */
#define SID_RTC_CONFIGDAYLIGHTSAVING                ((uint8)0x12U)

/** Service ID for Rtc_ReadStoreOperation */
#define SID_RTC_READSTOREOPERATION                  ((uint8)0x13U)

/** Service ID for Rtc_ConfigSmoothCalib */
#define SID_RTC_CONFIGSMOOTHCALIB                   ((uint8)0x14U)

/** Service ID for Rtc_ConfigSynchroShift */
#define SID_RTC_CONFIGSYNCHROSHIFT                  ((uint8)0x15U)

/** Service ID for Rtc_EnableInterrupt */
#define SID_RTC_ENABLEINTERRUPT                     ((uint8)0x16U)

/** Service ID for Rtc_DisableInterrupt */
#define SID_RTC_DISABLEINTERRUPT                    ((uint8)0x17U)

/** Service ID for Rtc_ReadIntFlag */
#define SID_RTC_READINTFLAG                         ((uint8)0x18U)

/** Service ID for Rtc_ReadStatusFlag */
#define SID_RTC_READSTATUSFLAG                      ((uint8)0x19U)

/** Service ID for Rtc_ClearStatusFlag */
#define SID_RTC_CLEARSTATUSFLAG                     ((uint8)0x1AU)

/*******************************************************************************
                                ERROR CODES
*******************************************************************************/
/** Development errors */
/** API service called with NULL pointer */
#define RTC_E_PARAM_POINTER           ((uint8)0x01U)
/** Module not initialized */
#define RTC_E_UNINIT                  ((uint8)0x02U)
/** Module is already initialized */
#define RTC_E_ALREADY_INITIALIZED     ((uint8)0x03U)

/**@} end of group RTC_Macros */

/***********************************************************************************************************
                                      ENUMERATION  DEFINITION
************************************************************************************************************/
/** @defgroup RTC_Enumerations
  @{
*/
typedef enum
{
    RTC_MODULE_STATE_IS_UNINIT = 0x00,
    RTC_MODULE_STATE_IS_IDLE   = 0x01

} Rtc_ModuleStateType;
/**@} end of group ADC_Enumerations */
/**********************************************************************************************************************
                                              FUNCTION DECLARATION
***********************************************************************************************************************/
/** @defgroup RTC_Fuctions
  @{
*/
FUNC(void, RTC_CODE) Rtc_Init(P2CONST(Rtc_ConfigType, AUTOMATIC, RTC_APPL_CONST) ConfigPtr);
FUNC(void, RTC_CODE) Rtc_DeInit(void);
FUNC(void, RTC_CODE) Rtc_AlarmsConfig(P2CONST(Rtc_ConfigType, AUTOMATIC, RTC_APPL_CONST) ConfigPtr);
FUNC(void, RTC_CODE) Rtc_EnableAlarm(void);
FUNC(void, RTC_CODE) Rtc_DisableAlarm(void);
FUNC(uint8, RTC_CODE) Rtc_EnableInit(void);
FUNC(void, RTC_CODE) Rtc_DisableInit(void);
FUNC(uint8, RTC_CODE) Rtc_WaitForSynchro(void);
FUNC(void, RTC_CODE) Rtc_EnableBypassShadow(void);
FUNC(void, RTC_CODE) Rtc_DisableBypassShadow(void);
FUNC(void, RTC_CODE) Rtc_ReadTime(VAR(Rtc_FormatType, AUTOMATIC) Format, P2VAR(Rtc_TimeType, AUTOMATIC, RTC_APPL_DATA) TimeStructPtr);
FUNC(uint32, RTC_CODE) Rtc_ReadSubSecond(void);
FUNC(uint8, RTC_CODE) Rtc_ConfigDate(VAR(Rtc_FormatType, AUTOMATIC) Format, P2CONST(Rtc_DateType, AUTOMATIC, RTC_APPL_DATA) DateStructPtr);
FUNC(void, RTC_CODE) Rtc_ReadDate(VAR(Rtc_FormatType, AUTOMATIC) Format, P2VAR(Rtc_DateType, AUTOMATIC, RTC_APPL_DATA) DateStructPtr);
FUNC(void, RTC_CODE) Rtc_ReadAlarm(VAR(Rtc_FormatType, AUTOMATIC) Format, P2VAR(Rtc_AlarmType, AUTOMATIC, RTC_APPL_DATA) AlarmStructPtr);
FUNC(void, RTC_CODE) Rtc_ConfigAlarmSubSecond(VAR(uint32, AUTOMATIC) Val, VAR(uint8, AUTOMATIC) Mask);
FUNC(void, RTC_CODE) Rtc_ConfigDayLightSaving(VAR(Rtc_DayLightSavingType, AUTOMATIC) Sav, VAR(Rtc_StoreOperationType, AUTOMATIC) Bit);
FUNC(uint32, RTC_CODE) Rtc_ReadStoreOperation(void);
FUNC(uint8, RTC_CODE) Rtc_ConfigSmoothCalib(VAR(Rtc_ScpType, AUTOMATIC) Period, VAR(Rtc_ScppType, AUTOMATIC) Bit, VAR(uint32, AUTOMATIC) Value);
FUNC(uint8, RTC_CODE) Rtc_ConfigSynchroShift(VAR(Rtc_ShiftAdd1sType, AUTOMATIC) Add1S, VAR(uint32, AUTOMATIC) SubFS);
FUNC(void, RTC_CODE) Rtc_EnableInterrupt(VAR(uint32, AUTOMATIC) Interrupt);
FUNC(void, RTC_CODE) Rtc_DisableInterrupt(VAR(uint32, AUTOMATIC) Interrupt);
FUNC(uint8, RTC_CODE) Rtc_ReadIntFlag(VAR(Rtc_IntFlagType, AUTOMATIC) Flag);
FUNC(uint8, RTC_CODE) Rtc_ReadStatusFlag(VAR(Rtc_FlagType, AUTOMATIC) Flag);
FUNC(void, RTC_CODE) Rtc_ClearStatusFlag(VAR(uint32, AUTOMATIC) Flag);
/** Optional application hook: invoked from Rtc_ProcessInterrupt before ALRF clear (default weak empty in CDD_Rtc.c). */
void Rtc_AlarmNotification(void);
FUNC(void, RTC_CODE) Rtc_ProcessInterrupt(void);
FUNC(uint32, RTC_CODE) Rtc_ReadAlarmSubSecond(void);
ISR(RTC_IRQHandler);

/**@} end of group RTC_Fuctions */
#ifdef __cplusplus
}
#endif  /* __cplusplus */
#endif  /* CDD_RTC_H */
/**@} end of group RTC_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */

