void proj_init(void)
{
LOG_INFO(app_tag, "BLE Peripheral\r\n");
pmu_enable_charge(PMU_CHG_CUR_200mA,PMU_CHG_END_VOL_4_2,true);
pmu_set_charge_interrupt();
pmu_battery_full_monitor_en();
// Application layer initialization, can included bond manager init,
// advertising parameters init, scanning parameter init, GATT service adding, etc.
simple_peripheral_init();
}
__attribute__((section("ram_code"))) void pmu_set_charge_interrupt(void)
{
if(ool_read(PMU_REG_ANALOG_LAST_STATUS)&PMU_ACOK_LAST_STATUS)
{
pmu_charging_monitor_en(PMU_CHARGING_OUT);
co_printf("charge in\r\n");
}
else
{
pmu_charging_monitor_en(PMU_CHARGING_IN);
co_printf("charge out\r\n");
}
}
__attribute__((section("ram_code"))) void pmu_isr(void)
{
uint16_t state = pmu_get_isr_state();
if(state & PMU_CALI_INT_STATUS) {
/* restart calibration */
pmu_get_rc_clk(true);
pmu_calibration_restart(LP_RC_CALIB_LARGE_CNT);
LOG_INFO(NULL, "lp clock is %d.\r\n", pmu_get_rc_clk(false));
}
if(state & PMU_GPIO_XOR_INT_STATUS) {
uint32_t pin_value = ool_read32(PMU_REG_PORTA_LAST_STATUS);
// co_printf( "pmu gpio value is %08x.\r\n", pin_value);
pmu_gpio_isr(pin_value);
ool_write32(PMU_REG_PORTA_LAST_STATUS, pin_value);
}
#if ENABLE_SYSTEM_PROTECTION_IN_LVD == 1
if(state & PMU_LVD_FAST_INT_STATUS)
{
extern void system_lvd_protect_handle(void);
LOG_INFO(NULL,"LVD");
system_lvd_protect_handle();
}
#endif
if(state & PMU_QDEC_INT_STATUS)
{
pmu_Anti_shake_key_isr();
}
if(state & PMU_ACOK_INT_STATUS)
{
pmu_set_charge_interrupt();
}
LOG_INFO(NULL, "pmu_isr: %04x.\r\n", state);
pmu_clear_isr_state(state);
}
富芮坤 FR8000系列 充电管理配置
最新推荐文章于 2023-11-18 22:57:01 发布