app_switchimu.c 833 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "app_switchimu.h"
  2. #include "usr_config.h"
  3. #include "bsp_time.h"
  4. #include "system.h"
  5. #include "hal_ble_client.h"
  6. #include "hal_ble_host.h"
  7. #include "hal_mt.h"
  8. #include "nrf_delay.h"
  9. #include "app_flash.h"
  10. static uint8_t switch_front_or_center_lsm = USED_FRONT_LSM;
  11. uint8_t app_switchimu_GetGameModeLsm(void)
  12. {
  13. return switch_front_or_center_lsm;
  14. }
  15. //½ÓÊÕÊÖ»úÃüÁî
  16. void cb_BLE_Client_R_SWITCH_IMU(void* handle)
  17. {
  18. BLE_Client_Rx_t* target = handle;
  19. uint8_t cmd = target->pDat[0];
  20. BLE_Host_Tx_Send(0,BLE_SWITCH_IMU,&cmd,1);
  21. nrf_delay_ms(500);
  22. NVIC_SystemReset(); //¸´Î»ÖØÆô
  23. mBackup.RestartCnt =0;
  24. if(Flash_SaveBackup() != ZONE_OP_SUCCESS)Except_TxError(EXCEPT_Power,"app restart save backup fail");
  25. }
  26. void app_switchimu_Init(void)
  27. {
  28. BLE_Client_Rx_Regist(BLE_SWITCH_IMU,cb_BLE_Client_R_SWITCH_IMU);
  29. }