1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include "app_power.h"
- #include "nrf_gpio.h"
- #include "usr_config.h"
- #include "bsp_time.h"
- #include "system.h"
- #include "hal_mt.h"
- #include "hal_battery.h"
- #include "app_charge.h"
- #include "hal_ble_client.h"
- #include "nrf_delay.h"
- #include "hal_flash.h"
- #include "bsp_wdt.h"
- #include "app_timer.h"
- #include "system.h"
- #include "bsp_pwm.h"
- #include "app_client_dataupdate.h"
- #include "hal_ble_uart0.h"
- #include "hal_led.h"
- #include "lsm6ds3tr_c.h"
- #include "hal_imu.h"
- #include "app_math.h"
- /********************** 变量区 *************************/
- /********************** 函数声明区 *************************/
- void PWR_Off(void)
- {
- UART0_unInit();
- LED_Close_Enforce();
- Battery_Enable(false);
-
- IMU_PowerOffProcess();
- nrf_gpio_pin_write(PIN_MT_EN,0);
- nrf_delay_ms(200);
- nrf_gpio_cfg_sense_input(PIN_CHARGING, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);//IO
- uint32_t err_code = sd_power_system_off();
- SEGGER_RTT_printf(0,"power off...BAT:%d,ERR:%d\n",GetBatteryPersent(),err_code);
- //APP_ERROR_CHECK(err_code);
- }
- static void PWR_Process(void)
- {
- #if WATCHDOG_ENANBLE
- feed_watchdog();
- #endif
- if(1 == (Battery_BatteryIs_0() && app_charge_Getstate()==BLE_Client_T_CHARGE_PULLOUT)){
- SEGGER_RTT_printf(0,"BatteryPersent:%d\n",GetBatteryPersent());
- SEGGER_RTT_printf(0,"power off...\n");
- //保存数据到flash
- Flash_SaveStep();
- Flash_SaveInfomation();
- MT_Run(1000);
- for(uint8_t temp = 0;temp < 10; temp++){
- app_client_DataUpdate_Send();
- nrf_delay_ms(100);
- }
- PWR_Off();
- }
- }
- void PWR_Init(void)
- {
- Process_Start(1000,"PWR_Process",PWR_Process);
- }
|