1 /* Includes ------------------------------------------------------------------*/ 2 #include "air32f10x_otp.h" 3 4 /** @defgroup OTP 5 * @brief OTP driver modules 6 * @{ 7 */ 8 OTP_PowerOn(uint32_t Time)9void OTP_PowerOn(uint32_t Time) 10 { 11 RCC->RCC_SYSCFG_CONFIG = 0x01; 12 SYSCFG->SYSCFG_LOCK = 0xAB12DFCD; 13 if(Time > OTP_POWERON_TIME) 14 { 15 OTP->OTP_LDO =Time; 16 } 17 else 18 { 19 OTP->OTP_LDO = OTP_POWERON_TIME; 20 } 21 } 22 OTP_PowerOff(void)23void OTP_PowerOff(void) 24 { 25 SYSCFG->SYSCFG_LOCK = 0xAB12DFCD; 26 RCC->RCC_SYSCFG_CONFIG = 0x00; 27 } 28 OTP_SetTime(uint16_t Time)29void OTP_SetTime(uint16_t Time) 30 { 31 OTP->OTP_10ns |= Time; 32 } 33 OTP_WriteByte(uint8_t Addr,uint8_t Data)34void OTP_WriteByte(uint8_t Addr,uint8_t Data) 35 { 36 assert_param(IS_OTP_ADDRESS(Addr)); 37 38 OTP->OTP_WR = (Addr << 8) | Data; 39 OTP->OTP_CTRL = BIT(0); 40 while(OTP->OTP_CTRL & BIT(2)); 41 } 42 43