/*!
* @file     Rtc_Hw.h
*
* @version  1.0.0
*
* @brief    This file contains all the functions prototypes for the RTC firmware library.
*           
* @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 RTC_HW_H
#define RTC_HW_H

#ifdef __cplusplus
extern "C" {
#endif

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

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

/** @defgroup RTC_Macros
  @{
*/
/**************************************************************************
                      MACROS  DEFINITION
**************************************************************************/
/** Macros description */
#define RTC_INITMODE_TIMEOUT      ((uint32_t) 0x00004000)
#define RTC_SYNCHRO_TIMEOUT       ((uint32_t) 0x00008000)
#define RTC_RECALPF_TIMEOUT       ((uint32_t) 0x00001000)
#define RTC_SHPF_TIMEOUT          ((uint32_t) 0x00001000)

#define RTC_CTRL_INT              ((uint32_t) 0x0000D000)
#define RTC_TAFCFG_INT            ((uint32_t) 0x00000004)
#define RTC_CTRL_INT              ((uint32_t) 0x0000D000)
#define RTC_TAFCFG_INT            ((uint32_t) 0x00000004)

#define RTC_MONTH_JANUARY         ((uint8_t)0x01)
#define RTC_MONTH_FEBRUARY        ((uint8_t)0x02)
#define RTC_MONTH_MARCH           ((uint8_t)0x03)
#define RTC_MONTH_APRIL           ((uint8_t)0x04)
#define RTC_MONTH_MAY             ((uint8_t)0x05)
#define RTC_MONTH_JUNE            ((uint8_t)0x06)
#define RTC_MONTH_JULY            ((uint8_t)0x07)
#define RTC_MONTH_AUGUST          ((uint8_t)0x08)
#define RTC_MONTH_SEPTEMBER       ((uint8_t)0x09)
#define RTC_MONTH_OCTOBER         ((uint8_t)0x0A)
#define RTC_MONTH_NOVEMBER        ((uint8_t)0x0B)
#define RTC_MONTH_DECEMBER        ((uint8_t)0x0C)

#define RTC_WEEKDAY_MONDAY        ((uint8_t)0x01)
#define RTC_WEEKDAY_TUESDAY       ((uint8_t)0x02)
#define RTC_WEEKDAY_WEDNESDAY     ((uint8_t)0x03)
#define RTC_WEEKDAY_THURSDAY      ((uint8_t)0x04)
#define RTC_WEEKDAY_FRIDAY        ((uint8_t)0x05)
#define RTC_WEEKDAY_SATURDAY      ((uint8_t)0x06)
#define RTC_WEEKDAY_SUNDAY        ((uint8_t)0x07)

/**@} end of group RTC_Macros */
/**************************************************************************
                    FUNCTION DECLARATION
**************************************************************************/
/** @defgroup RTC_Fuctions
  @{
*/
/** Initialization and Configuration functions */
FUNC(uint8, RTC_CODE) Rtc_Hw_Reset(void);

FUNC(uint8, RTC_CODE) Rtc_Hw_Config(P2CONST(Rtc_TimeInitType, AUTOMATIC, RTC_APPL_CONST) Struct );
FUNC(void, RTC_CODE) Rtc_Hw_EnableWriteProtection(void);
FUNC(void, RTC_CODE) Rtc_Hw_DisableWriteProtection(void);

FUNC(uint8, RTC_CODE) Rtc_Hw_EnableInit(void);
FUNC(void, RTC_CODE) Rtc_Hw_DisableInit(void);

FUNC(uint8, RTC_CODE) Rtc_Hw_WaitForSynchro(void);

FUNC(void, RTC_CODE) Rtc_Hw_EnableBypassShadow(void);
FUNC(void, RTC_CODE) Rtc_Hw_DisableBypassShadow(void);

/** Time and Date configuration functions */
FUNC(uint8, RTC_CODE) Rtc_Hw_ConfigTime(VAR(Rtc_FormatType, AUTOMATIC) Format, P2VAR(Rtc_TimeType, AUTOMATIC, RTC_APPL_DATA) TimeStruct);

FUNC(void, RTC_CODE) Rtc_Hw_ReadTime(VAR(Rtc_FormatType, AUTOMATIC) Format, P2VAR(Rtc_TimeType, AUTOMATIC, RTC_APPL_DATA) TimeStruct);
FUNC(uint32, RTC_CODE) Rtc_Hw_ReadSubSecond(void);
FUNC(uint8, RTC_CODE) Rtc_Hw_ConfigDate(VAR(Rtc_FormatType, AUTOMATIC) Format, P2CONST(Rtc_DateType, AUTOMATIC, RTC_APPL_CONST) DateStruct);

FUNC(void, RTC_CODE) Rtc_Hw_ConfigDateStructInit(P2VAR(Rtc_DateType, AUTOMATIC, RTC_APPL_DATA) DateStruct);
FUNC(void, RTC_CODE) Rtc_Hw_ReadDate(VAR(Rtc_FormatType, AUTOMATIC) Format, P2VAR(Rtc_DateType, AUTOMATIC, RTC_APPL_DATA) DateStruct);
    
/** Alarms (ALRMA A) configuration functions  */
FUNC(void, RTC_CODE) Rtc_Hw_ConfigAlarm(VAR(Rtc_FormatType, AUTOMATIC) Format, P2VAR(Rtc_AlarmType, AUTOMATIC, RTC_APPL_DATA) AlarmStruct);

FUNC(void, RTC_CODE) Rtc_Hw_ReadAlarm(VAR(Rtc_FormatType, AUTOMATIC) Format, P2VAR(Rtc_AlarmType, AUTOMATIC, RTC_APPL_DATA) AlarmStruct);
    
FUNC(void, RTC_CODE) Rtc_Hw_EnableAlarm(void);
FUNC(uint8, RTC_CODE) Rtc_Hw_DisableAlarm(void);
FUNC(void, RTC_CODE) Rtc_Hw_ConfigAlarmSubSecond(VAR(uint32, AUTOMATIC) Val, VAR(uint8, AUTOMATIC) Mask);

FUNC(uint32, RTC_CODE) Rtc_Hw_ReadAlarmSubSecond(void);

/** Daylight Saving configuration functions */
FUNC(void, RTC_CODE) Rtc_Hw_ConfigDayLightSaving(VAR(Rtc_DayLightSavingType, AUTOMATIC) Sav, VAR(Rtc_StoreOperationType, AUTOMATIC) Bit);

FUNC(uint32, RTC_CODE) Rtc_Hw_ReadStoreOperation(void);

FUNC(uint8, RTC_CODE) Rtc_Hw_ConfigSmoothCalib(VAR(Rtc_ScpType, AUTOMATIC) Period, VAR(Rtc_ScppType, AUTOMATIC) Bit, VAR(uint32, AUTOMATIC) Value);

/** RTC Shift control synchonisation functions */
FUNC(uint8, RTC_CODE) Rtc_Hw_ConfigSynchroShift(VAR(Rtc_ShiftAdd1sType, AUTOMATIC) Add1S, VAR(uint32, AUTOMATIC) SubFS);

/** Interrupts and flags management functions */
FUNC(void, RTC_CODE) Rtc_Hw_EnableInterrupt(VAR(uint32, AUTOMATIC) Interrupt);
FUNC(void, RTC_CODE) Rtc_Hw_DisableInterrupt(VAR(uint32, AUTOMATIC) Interrupt);
FUNC(uint8, RTC_CODE) Rtc_Hw_ReadStatusFlag(VAR(Rtc_FlagType, AUTOMATIC) Flag);
FUNC(void, RTC_CODE) Rtc_Hw_ClearStatusFlag(VAR(uint32, AUTOMATIC) flag);
FUNC(uint8, RTC_CODE) Rtc_Hw_ReadIntFlag(VAR(Rtc_IntFlagType, AUTOMATIC) Flag);

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

#endif /* RTC_HW_H */
/**@} end of group RTC_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */

