/* ****************************************************************************** * * @file system.h * @brief system module * @ic sy8837/8 * * @version 1.0 * @date 2024/11/01 09:59:40 * @author Alex Xu * * Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd. * All Rights Reserved * * History: * Revision Date Author Desc * 1.0.0 2024/11/01 Alex build this file ****************************************************************************** */ #ifndef __SYSTEM_H__ #define __SYSTEM_H__ /*_____ I N C L U D E S ____________________________________________________*/ #include "define.h" /******************************************************************************\ Macro definitions \******************************************************************************/ /* Boost/Hall/Key/VBUS状态寄存器 - CHIP_STA0 */ #define BOOST_BATUV_Pos (7U) #define BOOST_BATUV_Pos_Msk (0x1U << BOOST_BATUV_Pos) #define BOOST_BATUV BOOST_BATUV_Pos_Msk #define BOOST_SHORT_Pos (6U) #define BOOST_SHORT_Pos_Msk (0x1U << BOOST_SHORT_Pos) #define BOOST_SHORT BOOST_SHORT_Pos_Msk #define HALL_STATOK_Pos (4U) #define HALL_STATOK_Pos_Msk (0x1U << HALL_STATOK_Pos) #define HALL_STATOK HALL_STATOK_Pos_Msk #define HALL_STAT_Pos (3U) #define HALL_STAT_Pos_Msk (0x1U << HALL_STAT_Pos) #define HALL_STAT HALL_STAT_Pos_Msk #define HALL_PRE_Pos (2U) #define HALL_PRE_Pos_Msk (0x1U << HALL_PRE_Pos) #define HALL_PRE HALL_PRE_Pos_Msk #define KEY_STAT_Pos (1U) #define KEY_STAT_Pos_Msk (0x1U << KEY_STAT_Pos) #define KEY_STAT KEY_STAT_Pos_Msk #define VIN_PRESENT_Pos (0U) #define VIN_PRESENT_Pos_Msk (0x1U << VIN_PRESENT_Pos) #define VIN_PRESENT VIN_PRESENT_Pos_Msk /* Abnormal Interrupt Flag Register-IRQ_FLAG0 */ #define DIE_TO_Pos (6U) #define DIE_TO_Pos_Msk (0x1U << DIE_TO_Pos) #define DIE_TO DIE_TO_Pos_Msk #define VBUS_OverVol_Pos (5U) #define VBUS_OverVol_Pos_Msk (0x1U << VBUS_OverVol_Pos) #define VBUS_OverVol VBUS_OverVol_Pos_Msk #define BAT_Low_Pos (4U) #define BAT_Low_Pos_Msk (0x1U << BAT_Low_Pos) #define BAT_Low BAT_Low_Pos_Msk #define VOR_OutPut_Short_Pos (3U) #define VOR_OutPut_Short_Pos_Msk (0x1U << VOR_OutPut_Short_Pos) #define VOR_OutPut_Short VOR_OutPut_Short_Pos_Msk #define VOL_OutPut_Short_Pos (2U) #define VOL_OutPut_Short_Pos_Msk (0x1U << VOL_OutPut_Short_Pos) #define VOL_OutPut_Short VOL_OutPut_Short_Pos_Msk #define Boost_UVLO_Pos (1U) #define Boost_UVLO_Pos_Msk (0x1U << Boost_UVLO_Pos) #define Boost_UVLO Boost_UVLO_Pos_Msk #define Boost_OutPut_Short_Pos (0U) #define Boost_OutPut_Short_Pos_Msk (0x1U << Boost_OutPut_Short_Pos) #define Boost_OutPut_Short Boost_OutPut_Short_Pos_Msk /* Charger Interrupt Flag Register-IRQ_FALG9 */ #define VIN_DPM_Pos (7U) #define VIN_DPM_Pos_Msk (0x1U << VIN_DPM_Pos) #define VIN_DPM VIN_DPM_Pos_Msk #define Temp_Loop_Pos (6U) #define Temp_Loop_Pos_Msk (0x1U << Temp_Loop_Pos) #define Temp_Loop Temp_Loop_Pos_Msk #define BAT_OverVol_Pos (5U) #define BAT_OverVol_Pos_Msk (0x1U << BAT_OverVol_Pos) #define BAT_OverVol BAT_OverVol_Pos_Msk #define CHG_Complete_Pos (4U) #define CHG_Complete_Pos_Msk (0x1U << CHG_Complete_Pos) #define CHG_Complete CHG_Complete_Pos_Msk #define CHG_FastChgTmr_Pos (3U) #define CHG_FastChgTmr_Pos_Msk (0x1U << CHG_FastChgTmr_Pos) #define CHG_FastChgTmr CHG_FastChgTmr_Pos_Msk #define CHG_TricleChgTmr_Pos (2U) #define CHG_TricleChgTmr_Pos_Msk (0x1U << CHG_TricleChgTmr_Pos) #define CHG_TricleChgTmr CHG_TricleChgTmr_Pos_Msk #define VBUS_PG_NEG_Pos (1U) #define VBUS_PG_NEG_Pos_Msk (0x1U << VBUS_PG_NEG_Pos) #define VBUS_PG_NEG VBUS_PG_NEG_Pos_Msk #define VBUS_PG_POS_Pos (0U) #define VBUS_PG_POS_Pos_Msk (0x1U << VBUS_PG_POS_Pos) #define VBUS_PG_POS VBUS_PG_POS_Pos_Msk /* VBUS/HALL and ADC Data Ready Interrupt Flag Register-IRQ_FLAG10 */ #define VBUS_PLUG_OUT_Pos (7U) #define VBUS_PLUG_OUT_Pos_Msk (0x1U << VBUS_PLUG_OUT_Pos) #define VBUS_PLUG_OUT VBUS_PLUG_OUT_Pos_Msk #define VBUS_PLUG_IN_Pos (6U) #define VBUS_PLUG_IN_Pos_Msk (0x1U << VBUS_PLUG_IN_Pos) #define VBUS_PLUG_IN VBUS_PLUG_IN_Pos_Msk #define HALL_NEG_Pos (3U) #define HALL_NEG_Pos_Msk (0x1U << HALL_NEG_Pos) #define HALL_NEG HALL_NEG_Pos_Msk #define HALL_POS_Pos (2U) #define HALL_POS_Pos_Msk (0x1U << HALL_POS_Pos) #define HALL_POS HALL_POS_Pos_Msk #define Standby_Tmr_WkUp_Pos (1U) #define Standby_Tmr_WkUp_Msk (0x1U << Standby_Tmr_WkUp_Pos) #define Standby_Tmr_WkUp Standby_Tmr_WkUp_Msk #define ADC_Data_Ready_Pos (0U) #define ADC_Data_Ready_Msk (0x1U << ADC_Data_Ready_Pos) #define ADC_Data_Ready ADC_Data_Ready_Msk /* Boost/Hall/Key/VBUS Wakeup Flag - WKUP_FLAG0 */ #define TMR_WK_FLAG_Pos (3U) #define TMR_WK_FLAG_Pos_Msk (0x1U << TMR_WK_FLAG_Pos) #define TMR_WK_FLAG TMR_WK_FLAG_Pos_Msk #define HALL_WK_FLAG_Pos (2U) #define HALL_WK_FLAG_Pos_Msk (0x1U << HALL_WK_FLAG_Pos) #define HALL_WK_FLAG HALL_WK_FLAG_Pos_Msk #define KEY_WK_FLAG_Pos (1U) #define KEY_WK_FLAG_Pos_Msk (0x1U << KEY_WK_FLAG_Pos) #define KEY_WK_FLAG KEY_WK_FLAG_Pos_Msk #define VIN_PRESENT_WK_FLAG_Pos (0U) #define VIN_PRESENT_WK_FLAG_Pos_Msk (0x1U << VIN_PRESENT_WK_FLAG_Pos) #define VIN_PRESENT_WK_FLAG VIN_PRESENT_WK_FLAG_Pos_Msk /* Standby 定时唤醒控制寄存器--STB_TIM_CTL */ #define EN_FORCE_LOSC_Pos (7U) #define EN_FORCE_LOSC_Pos_Msk (0x1U << EN_FORCE_LOSC_Pos) #define EN_FORCE_LOSC EN_FORCE_LOSC_Pos_Msk #define STB_TMR_EN_Pos (2U) #define STB_TMR_EN_Pos_Msk (0x1U << STB_TMR_EN_Pos) #define STB_TMR_EN STB_TMR_EN_Pos_Msk #define STB_TMR_SET_2S (0U) #define STB_TMR_SET_4S (1U) #define STB_TMR_SET_8S (2U) #define STB_TMR_SET_16S (3U) /* 系统分频,分频比为:N = 2^n。 */ #define CLK_DIV_0 (0U) #define CLK_DIV_2 (1U) #define CLK_DIV_4 (2U) #define CLK_DIV_8 (3U) #define CLK_DIV_16 (4U) #define CLK_DIV_32 (5U) #define CLK_DIV_64 (6U) #define CLK_DIV_128 (7U) /*中断号计算方式:中断向量 = 中断号 * 8 + 3*/ #define Interrupt_Vector_IE0 0 //0x03,SY8836 IE0 use for wakeup #define Interrupt_Vector_TF0 1 //0x0B,Timer 0 Overflow #define Interrupt_Vector_IE1 2 //0x13 #define Interrupt_Vector_TF1 3 //0x1B,Timer 1 Overflow #define Interrupt_Vector_RI_TI 4 //0x23,Serial Port0 Interrupt #define Interrupt_Vector_TF2 5 //0x2B #define Interrupt_Vector_IE7 8 //0x43,External Interrupt 7 / PWM #define Interrupt_Vector_IE2 9 //0x4B,External Interrupt 2 #define Interrupt_Vector_IE3 10 //0x53,External Interrupt 3 #define Interrupt_Vector_IE4 11 //0x5B,External Interrupt 4 #define Interrupt_Vector_IE5 12 //0x63,External Interrupt 5 #define Interrupt_Vector_IE6 13 //0x6B,External Interrupt 6 / ADC中断 #define Interrupt_Vector_RI1_TI1 16 //0x83,Serial Port1 Interrupt #define Interrupt_Vector_IE8 17 //0x8B,Serial Port2 Interrupt /******************************************************************************\ Variables definitions \******************************************************************************/ /******************************************************************************\ Functions definitions \******************************************************************************/ extern void System_Init(void); extern void Sys_Clk_Adjust(uint8_t Clk_Div); #endif