/******************************************************************************* * File Name : amt630hv160_rtc.h * Author : Sim * Date First Issued : 03/06/2024 * Description : This file contains all the functions prototypes for the * RTC firmware library. ******************************************************************************** * History: * 03/06/2024: V0.1 *******************************************************************************/ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __AMT630HV160_RTC_H #define __AMT630HV160_RTC_H /* Includes ------------------------------------------------------------------*/ #include "amt630hv160_map.h" /* Exported types ------------------------------------------------------------*/ typedef enum { RTC_PowerOff, RTC_DelayWakeUp, RTC_Clk32KSel, RTC_WDTEn, RTC_ISOOff, RTC_SleepMode, RTC_ISOForce, RTC_PMC, RTC_RAML, RTC_GPIO, RTC_RAMH, RTC_PARA, RTC_CNT, } eRTCCmd; typedef enum { RTC_WDT_250MS, RTC_WDT_500MS, RTC_WDT_1S, RTC_WDT_2S, RTC_WDT_NOCHANGE, } eRTCWdtTmo; typedef enum { RTC_WAKEUP_GPIO1, RTC_WAKEUP_GPIO0, RTC_WAKEUP_CAN1, RTC_WAKEUP_CAN0, RTC_WAKEUP_ACC, RTC_WAKEUP_RTC, } eRTCWakeupSource; typedef enum { RTC_WAKEUP_FALLING, RTC_WAKEUP_RISING, RTC_WAKEUP_HIGHLEVEL, RTC_WAKEUP_LOWLEVEL, RTC_WAKEUP_NOCHANGE, } eRTCWakeupMode; /* * The struct used to pass data via the following ioctl. Similar to the * struct tm in , but it needs to be here so that the kernel * source is self contained, allowing cross-compiles, etc. etc. */ typedef struct rtc_time { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; } SystemTime_t; /* Exported constants --------------------------------------------------------*/ static inline int is_leap_year(unsigned int year) { return (!(year % 4) && (year % 100)) || !(year % 400); } #pragma section = "sleep_critical_data" /* Exported macro ------------------------------------------------------------*/ /* STATUS_REG */ #define RTC_STA_BUSY (1 << 2) #define RTC_STA_SLEEPMODE (1 << 3) #define RTC_STA_ISOFORCE (1 << 6) #define RTC_STA_GPIO0ACT (1 << 9) #define RTC_STA_GPIO1ACT (1 << 10) #define RTC_STA_CAN0ACT (1 << 11) #define RTC_STA_CAN1ACT (1 << 12) #define RTC_STA_ACCACT (1 << 13) #define RTC_STA_RTCACT (1 << 14) #define RTC_STA_GPIO0IN (1 << 15) #define IRAM_SLEEP_DATA_MAX_SIZE (0x2000 - 8) /* Exported functions ------------------------------------------------------- */ // Sleep and wake-up related int RTC_SendCmd(eRTCCmd cmd, int enable); int RTC_WriteReg(eRTCCmd cmd, vu32 *reg, u32 value); void RTC_SetWatchdog(eRTCWdtTmo tmo, int enable); void RTC_PowerDown(int fastboot); void RTC_CanStbOut(int id, int value); void RTC_SetWakeup(eRTCWakeupSource src, eRTCWakeupMode mode, int enable); void RTC_WakeupDetect(void); int RTC_SaveSleepData(void); int RTC_ReadSleepData(void); // Real-time clock related int rtc_time_init(void); int iGetLocalTime(SystemTime_t *tm); void vSetLocalTime(SystemTime_t *tm); uint32_t CpuGetLocalTime(void); void CpuSetLocalTime(uint32_t time); #endif /* __AMT630HV160_RTC_H */