app_math.c 1021 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "app_math.h"
  2. #include "bsp_time.h"
  3. #include "system.h"
  4. #include "math.h"
  5. #include "ble_comm.h"
  6. #include "app_flash.h"
  7. #include "detect_zero_vel.h"
  8. #include "tool.h"
  9. #include "app_switchimu.h"
  10. #include "detect_step_by_mag.h"
  11. #include "pdrStatus.h"
  12. #include "detect_step_by_mag.h"
  13. #include "app_client_step.h"
  14. #include "hal_mt.h"
  15. #include "hal_led.h"
  16. #include "bll_imu.h"
  17. #include "app_game.h"
  18. static uint32_t timeCNT = 0;
  19. //校准时间
  20. void app_math_calit_time(uint8_t appminute){
  21. timeCNT = (appminute)*60*32768;
  22. }
  23. //一小时计时
  24. static void app_math_Hour_process(void){
  25. uint32_t sec = 0;
  26. static uint32_t cnt_b=0;
  27. uint32_t cnt = NRF_RTC0->COUNTER;
  28. if(cnt<cnt_b) cnt += 16777216;
  29. timeCNT += cnt - cnt_b;
  30. sec = (timeCNT)/32768;
  31. if(cnt >16777216)cnt_b = cnt - 16777216;
  32. else cnt_b = cnt;
  33. if(sec >= 3600){//一小时
  34. timeCNT =0;
  35. app_client_step_SetIsScan();
  36. DEBUG_LOG("timeCNT(%d)(%d)\n",timeCNT,sec);
  37. }
  38. }
  39. void app_math_Init(void)
  40. {
  41. Process_Start(1000,"math_Hour",app_math_Hour_process);
  42. }