Englishify some of the CH592 StdPeriphDriver

This commit is contained in:
true 2024-10-12 22:53:04 -07:00
parent 576026f771
commit b6582a599a
5 changed files with 127 additions and 114 deletions

View File

@ -15,9 +15,11 @@
/*********************************************************************
* @fn LClk32K_Select
*
* @brief 32K
* @brief 32K Low Frequency clock source select
*
* @param hc - 32K使用内部还是外部
* @param hc - Use internal or external 32K oscillator
* Clk32K_LSI - Internal
* Clk32K_LSE - External
*
* @return none
*/
@ -43,10 +45,10 @@ void LClk32K_Select(LClk32KTypeDef hc)
/*********************************************************************
* @fn LClk32K_Cfg
*
* @brief 32K
* @brief 32K Low Frequency clock power
*
* @param hc - 32K还是外部32K
* @param s -
* @param hc - Clock Selection
* @param s - Power ENABLE/DISABLE
*
* @return none
*/
@ -85,7 +87,7 @@ void LClk32K_Cfg(LClk32KTypeDef hc, FunctionalState s)
/*********************************************************************
* @fn HSECFG_Current
*
* @brief HSE晶体
* @brief HSE Bias Current configuration
*
* @param c - 75%,100%,125%,150%
*
@ -106,7 +108,7 @@ void HSECFG_Current(HSECurrentTypeDef c)
/*********************************************************************
* @fn HSECFG_Capacitance
*
* @brief HSE晶体
* @brief HSE Load Capacitor configuration
*
* @param c - refer to HSECapTypeDef
*
@ -127,7 +129,7 @@ void HSECFG_Capacitance(HSECapTypeDef c)
/*********************************************************************
* @fn LSECFG_Current
*
* @brief LSE晶体
* @brief LSE Bias Current configuration
*
* @param c - 70%,100%,140%,200%
*
@ -148,7 +150,7 @@ void LSECFG_Current(LSECurrentTypeDef c)
/*********************************************************************
* @fn LSECFG_Capacitance
*
* @brief LSE晶体
* @brief LSE Load Capacitor configuration
*
* @param c - refer to LSECapTypeDef
*
@ -169,11 +171,12 @@ void LSECFG_Capacitance(LSECapTypeDef c)
/*********************************************************************
* @fn Calibration_LSI
*
* @brief 32K时钟
* @brief Calibrate 32K LSI clock from HSE
*
* @param cali_Lv - Level_32 2.4ms 1000ppm (32M ) 1100ppm (60M )
* Level_64 4.4ms 800ppm (32M ) 1000ppm (60M )
* Level_128 8.4ms 600ppm (32M ) 800ppm (60M )
* @param cali_Lv - Calibration Level Selection
* Level_32 £º2.4ms 1000ppm (32M HSE), 1100ppm (60M HSE)
* Level_64 £º4.4ms 800ppm (32M HSE), 1000ppm (60M HSE)
* Level_128 £º8.4ms 600ppm (32M HSE), 800ppm (60M HSE)
*
* @return none
*/
@ -197,7 +200,7 @@ void Calibration_LSI(Cali_LevelTypeDef cali_Lv)
while(1)
{
// 粗调
// coarse adjustment
sys_safe_access_enable();
R8_OSC_CAL_CTRL &= ~RB_OSC_CNT_TOTAL;
R8_OSC_CAL_CTRL |= 1;
@ -253,7 +256,7 @@ void Calibration_LSI(Cali_LevelTypeDef cali_Lv)
sys_safe_access_disable();
}
// 细调
// fine adjustment
// 配置细调参数后丢弃2次捕获值软件行为上判断已有一次这里只留一次
sys_safe_access_enable();
R8_OSC_CAL_CTRL &= ~RB_OSC_CNT_TOTAL;
@ -354,14 +357,14 @@ void Calibration_LSI(Cali_LevelTypeDef cali_Lv)
/*********************************************************************
* @fn RTCInitTime
*
* @brief RTC时钟初始化当前时间
* @brief RTC Clock initialize with time and date
*
* @param y - MAX_Y = BEGYEAR + 44
* @param mon - MAX_MON = 12
* @param d - MAX_D = 31
* @param h - MAX_H = 23
* @param m - MAX_M = 59
* @param s - MAX_S = 59
* @param y - year, MAX_Y = BEGYEAR + 44
* @param mon - month, MAX_MON = 12
* @param d - day, MAX_D = 31
* @param h - hour, MAX_H = 23
* @param m - minute, MAX_M = 59
* @param s - second, MAX_S = 59
*
* @return none
*/
@ -420,14 +423,14 @@ void RTC_InitTime(uint16_t y, uint16_t mon, uint16_t d, uint16_t h, uint16_t m,
/*********************************************************************
* @fn RTC_GetTime
*
* @brief
* @brief Get the current time and date from RTC
*
* @param py - MAX_Y = BEGYEAR + 44
* @param pmon - MAX_MON = 12
* @param pd - MAX_D = 31
* @param ph - MAX_H = 23
* @param pm - MAX_M = 59
* @param ps - MAX_S = 59
* @param py - year, MAX_Y = BEGYEAR + 44
* @param pmon - month, MAX_MON = 12
* @param pd - day, MAX_D = 31
* @param ph - hour, MAX_H = 23
* @param pm - minute, MAX_M = 59
* @param ps - second, MAX_S = 59
*
* @return none
*/
@ -465,9 +468,9 @@ void RTC_GetTime(uint16_t *py, uint16_t *pmon, uint16_t *pd, uint16_t *ph, uint1
/*********************************************************************
* @fn RTC_SetCycle32k
*
* @brief LSE/LSI时钟RTC
* @brief Based on LSI/LSE clock, configure the number of cycles for RTC
*
* @param cyc - MAX_CYC = 0xA8BFFFFF = 2831155199
* @param cyc - cycle count, MAX_CYC = 0xA8BFFFFF = 2831155199
*
* @return none
*/
@ -489,11 +492,11 @@ void RTC_SetCycle32k(uint32_t cyc)
/*********************************************************************
* @fn RTC_GetCycle32k
*
* @brief LSE/LSI时钟RTC
* @brief Get the current number of cycles for RTC based on LSI/LSE clock
*
* @param none
*
* @return MAX_CYC = 0xA8BFFFFF = 2831155199
* @return cycle count, MAX_CYC = 0xA8BFFFFF = 2831155199
*/
uint32_t RTC_GetCycle32k(void)
{
@ -509,7 +512,7 @@ uint32_t RTC_GetCycle32k(void)
/*********************************************************************
* @fn RTC_TMRFunCfg
*
* @brief RTC定时模式配置32768Hz
* @brief RTC Timer configuration (timebase is fixed to 32768Hz)
*
* @param t - refer to RTC_TMRCycTypeDef
*
@ -528,7 +531,7 @@ void RTC_TMRFunCfg(RTC_TMRCycTypeDef t)
/*********************************************************************
* @fn RTC_TRIGFunCfg
*
* @brief RTC时间触发模式配置
* @brief RTC Timer Trigger configuration
*
* @param cyc - LSE/LSI时钟周期数
*
@ -580,11 +583,11 @@ void RTC_ModeFunDisable(RTC_MODETypeDef m)
/*********************************************************************
* @fn RTC_GetITFlag
*
* @brief RTC中断标志
* @brief Get RTC interrupt flags
*
* @param f - refer to RTC_EVENTTypeDef
*
* @return
* @return Interrupt flag status
*/
uint8_t RTC_GetITFlag(RTC_EVENTTypeDef f)
{
@ -601,7 +604,7 @@ uint8_t RTC_GetITFlag(RTC_EVENTTypeDef f)
/*********************************************************************
* @fn RTC_ClearITFlag
*
* @brief RTC中断标志
* @brief Clear RTC interrupt flags
*
* @param f - refer to RTC_EVENTTypeDef
*

View File

@ -10,6 +10,16 @@
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
*******************************************************************************/
/*
* true's notes:
*
* flash is practically undocumented.
*
* R8_FLASH_CTRL - 0x51 flash on, no waitstates?
* 0x51 flash on, unknown waitstates?
* 0x04 flash off
*/
#include "CH59x_common.h"
/* RESET_EN */
@ -56,7 +66,7 @@ void FLASH_ROM_READ(uint32_t StartAddr, void *Buffer, uint32_t len)
* @brief Configure User Option Byte.,
* (使使.S文件线)
*
* @param RESET_EN - 使
* @param RESET_EN - External reset pin enable
* @param BOOT_PIN - ENABLE-使boot脚-PB22,DISABLE-使boot脚-PB11
* @param UART_NO_KEY_EN - 使
* @param FLASHProt_Size - (4K)
@ -173,7 +183,7 @@ void UserOptionByte_Active(void)
*
* @param Buffer - Pointer to the buffer where data should be stored, Must be aligned to 4 bytes.
*
* @return 0-SUCCESS (!0)-FAILURE
* @return none
*/
void GET_UNIQUE_ID(uint8_t *Buffer)
{

View File

@ -15,10 +15,10 @@
/*********************************************************************
* @fn GPIOA_ModeCfg
*
* @brief GPIOA端口引脚模式配置
* @brief GPIOA Port Pin Mode configuration
*
* @param pin - PA0-PA15
* @param mode -
* @param mode - GPIO input / output mode
*
* @return none
*/
@ -62,10 +62,10 @@ void GPIOA_ModeCfg(uint32_t pin, GPIOModeTypeDef mode)
/*********************************************************************
* @fn GPIOB_ModeCfg
*
* @brief GPIOB端口引脚模式配置
* @brief GPIOB Port Pin Mode configuration
*
* @param pin - PB0-PB23
* @param mode -
* @param mode - GPIO input / output mode
*
* @return none
*/
@ -109,10 +109,10 @@ void GPIOB_ModeCfg(uint32_t pin, GPIOModeTypeDef mode)
/*********************************************************************
* @fn GPIOA_ITModeCfg
*
* @brief GPIOA引脚中断模式配置
* @brief GPIOA interrupt configuration
*
* @param pin - PA0-PA15
* @param mode -
* @param mode - Interrupt Trigger type (edge, level)
*
* @return none
*/
@ -120,22 +120,22 @@ void GPIOA_ITModeCfg(uint32_t pin, GPIOITModeTpDef mode)
{
switch(mode)
{
case GPIO_ITMode_LowLevel: // 低电平触发
case GPIO_ITMode_LowLevel:
R16_PA_INT_MODE &= ~pin;
R32_PA_CLR |= pin;
break;
case GPIO_ITMode_HighLevel: // 高电平触发
case GPIO_ITMode_HighLevel:
R16_PA_INT_MODE &= ~pin;
R32_PA_OUT |= pin;
break;
case GPIO_ITMode_FallEdge: // 下降沿触发
case GPIO_ITMode_FallEdge:
R16_PA_INT_MODE |= pin;
R32_PA_CLR |= pin;
break;
case GPIO_ITMode_RiseEdge: // 上升沿触发
case GPIO_ITMode_RiseEdge:
R16_PA_INT_MODE |= pin;
R32_PA_OUT |= pin;
break;
@ -150,10 +150,10 @@ void GPIOA_ITModeCfg(uint32_t pin, GPIOITModeTpDef mode)
/*********************************************************************
* @fn GPIOB_ITModeCfg
*
* @brief GPIOB引脚中断模式配置
* @brief GPIOB interrupt configuration
*
* @param pin - PB0-PB23
* @param mode -
* @param mode - Interrupt Trigger type (edge, level)
*
* @return none
*/
@ -162,22 +162,22 @@ void GPIOB_ITModeCfg(uint32_t pin, GPIOITModeTpDef mode)
uint32_t Pin = pin | ((pin & (GPIO_Pin_22 | GPIO_Pin_23)) >> 14);
switch(mode)
{
case GPIO_ITMode_LowLevel: // 低电平触发
case GPIO_ITMode_LowLevel:
R16_PB_INT_MODE &= ~Pin;
R32_PB_CLR |= pin;
break;
case GPIO_ITMode_HighLevel: // 高电平触发
case GPIO_ITMode_HighLevel:
R16_PB_INT_MODE &= ~Pin;
R32_PB_OUT |= pin;
break;
case GPIO_ITMode_FallEdge: // 下降沿触发
case GPIO_ITMode_FallEdge:
R16_PB_INT_MODE |= Pin;
R32_PB_CLR |= pin;
break;
case GPIO_ITMode_RiseEdge: // 上升沿触发
case GPIO_ITMode_RiseEdge:
R16_PB_INT_MODE |= Pin;
R32_PB_OUT |= pin;
break;
@ -192,17 +192,17 @@ void GPIOB_ITModeCfg(uint32_t pin, GPIOITModeTpDef mode)
/*********************************************************************
* @fn GPIOPinRemap
*
* @brief
* @brief GPIO Pin Peripheral Function Remapping
*
* @param s - 使
* @param s - Enable / Disable remap
* @param perph - RB_RF_ANT_SW_EN - RF antenna switch control output on PA4/PA5/PA12/PA13/PA14/PA15
* RB_PIN_U0_INV - RXD0/RXD0_/TXD0/TXD0_ invert input/output
* RB_PIN_INTX - INTX: INT24/INT25 PB8/PB9 -> INT24_/INT25_ PB22/PB23
* RB_PIN_MODEM - MODEM: PA6/PA7 -> PB12/PB13
* RB_PIN_I2C - I2C: PB14/PB15 -> PB14/PB15
* RB_PIN_I2C - I2C: PB14/PB15 -> PB14/PB15 (no remap possible)
* RB_PIN_PWMX - PWMX: PA12/PA13 -> PA6/PA7
* RB_PIN_SPI0 - SPI0: PA12/PA13/PA14/PA15 -> PB12/PB13/PB14/PB15
* RB_PIN_UART3 - UART3: PA4/PA5 -> PA4/PA5
* RB_PIN_UART3 - UART3: PA4/PA5 -> PA4/PA5 (no remap possible)
* RB_PIN_UART2 - UART2: PB22/PB23 -> PA6/PA7
* RB_PIN_UART1 - UART1: PA8/PA9 -> PB12/PB13
* RB_PIN_UART0 - UART0: PB4/PB7 -> PA15/PA14
@ -228,25 +228,25 @@ void GPIOPinRemap(FunctionalState s, uint16_t perph)
/*********************************************************************
* @fn GPIOAGPPCfg
*
* @brief GPIO引脚功能控制
* @brief GPIO Analog Pin Peripheral Function configuration
*
* @param s - ENABLE -
* DISABLE -
* @param perph - RB_PIN_ADC8_9_IE - ADC/TKEY 9/8
* RB_PIN_ADC6_7_IE - ADC/TKEY 7/6
* RB_PIN_ADC10_IE - ADC/TKEY 10
* RB_PIN_ADC11_IE - ADC/TKEY 11
* RB_PIN_USB2_DP_PU - USB2 U2D+
* @param s - ENABLE - Turn on analog, disable digital functions
* DISABLE - Turn off analog, enable digital functions
* @param perph - RB_PIN_ADC8_9_IE - ADC/TKEY 9/8
* RB_PIN_ADC6_7_IE - ADC/TKEY 7/6
* RB_PIN_ADC10_IE - ADC/TKEY 10
* RB_PIN_ADC11_IE - ADC/TKEY 11
* RB_PIN_USB2_DP_PU - USB2 U2D+ internal pullup
* RB_PIN_USB2_IE - USB2Òý½Å
* RB_PIN_USB_DP_PU - USB UD+
* RB_PIN_USB_DP_PU - USB UD+ internal pullup
* RB_PIN_USB_IE - USB Òý½Å
* RB_PIN_ADC0_IE - ADC/TKEY 0
* RB_PIN_ADC1_IE - ADC/TKEY 1
* RB_PIN_ADC12_IE - ADC/TKEY 12
* RB_PIN_ADC13_IE - ADC/TKEY 13
* RB_PIN_XT32K_IE - 32KHz晶振LSE引脚
* RB_PIN_ADC2_3_IE - ADC/TKEY 2/3
* RB_PIN_ADC4_5_IE - ADC/TKEY 4/5
* RB_PIN_ADC0_IE - ADC/TKEY 0
* RB_PIN_ADC1_IE - ADC/TKEY 1
* RB_PIN_ADC12_IE - ADC/TKEY 12
* RB_PIN_ADC13_IE - ADC/TKEY 13
* RB_PIN_XT32K_IE - 32KHz LSE
* RB_PIN_ADC2_3_IE - ADC/TKEY 2/3
* RB_PIN_ADC4_5_IE - ADC/TKEY 4/5
*
* @return none
*/

View File

@ -15,9 +15,9 @@
/*********************************************************************
* @fn PWR_DCDCCfg
*
* @brief DC/DC电源
* @brief Enable DC/DC converter, to reduce power consumption
*
* @param s - DCDC电源
* @param s - ENABLE or DISABLE the DC/DC converter
*
* @return none
*/
@ -30,7 +30,7 @@ void PWR_DCDCCfg(FunctionalState s)
{
adj &= ~RB_DCDC_CHARGE;
plan &= ~(RB_PWR_DCDC_EN | RB_PWR_DCDC_PRE); // 旁路 DC/DC
plan &= ~(RB_PWR_DCDC_EN | RB_PWR_DCDC_PRE); // bypass DC/DC
sys_safe_access_enable();
R16_AUX_POWER_ADJ = adj;
R16_POWER_PLAN = plan;
@ -88,10 +88,10 @@ void PWR_UnitModCfg(FunctionalState s, uint8_t unit)
/*********************************************************************
* @fn PWR_PeriphClkCfg
*
* @brief
* @brief Peripheral clock control
*
* @param s -
* @param perph - please refer to Peripher CLK control bit define
* @param s - ENABLE or DISABLE peripheral clock
* @param perph - please refer to Peripheral CLK control bit define
*
* @return none
*/
@ -182,9 +182,9 @@ void PWR_PeriphWakeUpCfg(FunctionalState s, uint8_t perph, WakeUP_ModeypeDef mod
/*********************************************************************
* @fn PowerMonitor
*
* @brief
* @brief Battery Monitoring
*
* @param s -
* @param s - ENABLE or DISABLE
* @param vl - refer to VolM_LevelypeDef
*
* @return none
@ -238,7 +238,7 @@ __HIGH_CODE
void LowPower_Idle(void)
{
FLASH_ROM_SW_RESET();
R8_FLASH_CTRL = 0x04; //flash关闭
R8_FLASH_CTRL = 0x04; // disable flash
PFIC->SCTLR &= ~(1 << 2); // sleep
__WFI();
@ -261,14 +261,14 @@ void LowPower_Halt(void)
uint8_t x32Kpw, x32Mpw;
FLASH_ROM_SW_RESET();
R8_FLASH_CTRL = 0x04; //flash关闭
R8_FLASH_CTRL = 0x04; // disable flash
x32Kpw = R8_XT32K_TUNE;
x32Mpw = R8_XT32M_TUNE;
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150%额定电流
x32Kpw = (x32Kpw & 0xfc) | 0x01; // LSE驱动电流降低到额定电流
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150% current
x32Kpw = (x32Kpw & 0xfc) | 0x01; // LSE drive current reduced to normal
sys_safe_access_enable();
R8_BAT_DET_CTRL = 0; // 关闭电压监控
R8_BAT_DET_CTRL = 0; // disable battery voltage monitoring
sys_safe_access_disable();
sys_safe_access_enable();
R8_XT32K_TUNE = x32Kpw;
@ -292,11 +292,11 @@ void LowPower_Halt(void)
* Description : -Sleep模式
80M时flash内代码退30us延迟
* Input : rm:
RB_PWR_RAM2K - 2K retention SRAM
RB_PWR_RAM24K - 24K main SRAM
RB_PWR_EXTEND - USB BLE
RB_PWR_XROM - FlashROM
NULL -
RB_PWR_RAM2K - 2K retention SRAM is powered
RB_PWR_RAM24K - 24K main SRAM is powered
RB_PWR_EXTEND - USB & BLE µ¥Ôª±£ÁôÇøÓò¹©µç
RB_PWR_XROM - FlashROM is powered
NULL - All above peripherals are powered off
* Return : None
*******************************************************************************/
__HIGH_CODE
@ -310,11 +310,11 @@ void LowPower_Sleep(uint16_t rm)
x32Kpw = R8_XT32K_TUNE;
x32Mpw = R8_XT32M_TUNE;
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150%额定电流
x32Kpw = (x32Kpw & 0xfc) | 0x01; // LSE驱动电流降低到额定电流
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150% current
x32Kpw = (x32Kpw & 0xfc) | 0x01; // LSE drive current reduced to normal
sys_safe_access_enable();
R8_BAT_DET_CTRL = 0; // 关闭电压监控
R8_BAT_DET_CTRL = 0; // disable battery voltage monitoring
sys_safe_access_disable();
sys_safe_access_enable();
R8_XT32K_TUNE = x32Kpw;
@ -379,11 +379,11 @@ void LowPower_Shutdown(uint16_t rm)
FLASH_ROM_SW_RESET();
x32Kpw = R8_XT32K_TUNE;
x32Mpw = R8_XT32M_TUNE;
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150%额定电流
x32Kpw = (x32Kpw & 0xfc) | 0x01; // LSE驱动电流降低到额定电流
x32Mpw = (x32Mpw & 0xfc) | 0x03; // 150% current
x32Kpw = (x32Kpw & 0xfc) | 0x01; // LSE drive current reduced to normal
sys_safe_access_enable();
R8_BAT_DET_CTRL = 0; // 关闭电压监控
R8_BAT_DET_CTRL = 0; // disable battery voltage monitoring
sys_safe_access_disable();
sys_safe_access_enable();
R8_XT32K_TUNE = x32Kpw;

View File

@ -15,9 +15,9 @@
/*********************************************************************
* @fn SetSysClock
*
* @brief
* @brief Configure main system clock
*
* @param sc - refer to SYS_CLKTypeDef
* @param sc - System clock source selection (refer to SYS_CLKTypeDef)
*
* @return none
*/
@ -70,7 +70,7 @@ void SetSysClock(SYS_CLKTypeDef sc)
/*********************************************************************
* @fn GetSysClock
*
* @brief
* @brief Get main system clock configuration
*
* @param none
*
@ -82,15 +82,15 @@ uint32_t GetSysClock(void)
rev = R32_CLK_SYS_CFG & 0xff;
if((rev & 0x40) == (0 << 6))
{ // 32M进行分频
{ // 32M HSE division
return (32000000 / (rev & 0x1f));
}
else if((rev & RB_CLK_SYS_MOD) == (1 << 6))
{ // PLL进行分频
{ // 480M PLL division
return (480000000 / (rev & 0x1f));
}
else
{ // 32K做主频
{ // 32KHz
return (32000);
}
}
@ -119,7 +119,7 @@ uint8_t SYS_GetInfoSta(SYS_InfoStaTypeDef i)
/*********************************************************************
* @fn SYS_ResetExecute
*
* @brief
* @brief Perform a software reset
*
* @param none
*
@ -137,9 +137,9 @@ void SYS_ResetExecute(void)
/*********************************************************************
* @fn SYS_DisableAllIrq
*
* @brief
* @brief Disable all interrupts, get current interrupt values
*
* @param pirqv -
* @param pirqv - Save old interrupt values
*
* @return none
*/
@ -153,9 +153,9 @@ void SYS_DisableAllIrq(uint32_t *pirqv)
/*********************************************************************
* @fn SYS_RecoverIrq
*
* @brief
* @brief Restore all interrupts from previously stored values
*
* @param irq_status -
* @param irq_status - Old interrupt values to restore
*
* @return none
*/
@ -168,11 +168,11 @@ void SYS_RecoverIrq(uint32_t irq_status)
/*********************************************************************
* @fn SYS_GetSysTickCnt
*
* @brief (SYSTICK)
* @brief Get the current SysTick count
*
* @param none
*
* @return
* @return Current SysTick count
*/
uint32_t SYS_GetSysTickCnt(void)
{
@ -255,7 +255,7 @@ void WWDG_ClearFlag(void)
/*********************************************************************
* @fn HardFault_Handler
*
* @brief
* @brief Resets with a power-on reset on a hardware error
*
* @param none
*