app_math.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. static uint8_t Halfhour_cnt =0;
  26. uint32_t sec = 0;
  27. static uint32_t cnt_b=0;
  28. uint32_t cnt = NRF_RTC0->COUNTER;
  29. if(cnt<cnt_b) cnt += 16777216;
  30. timeCNT += cnt - cnt_b;
  31. sec = (timeCNT)/32768;
  32. if(cnt >16777216)cnt_b = cnt - 16777216;
  33. else cnt_b = cnt;
  34. if(sec >=1800){//半小时
  35. if(1 != Halfhour_cnt){
  36. Halfhour_cnt =1;
  37. }
  38. }
  39. if(sec >= 3600){//一小时
  40. timeCNT =0;
  41. app_client_step_SetIsScan();
  42. Halfhour_cnt =0;
  43. DEBUG_LOG("timeCNT(%d)(%d)\n",timeCNT,sec);
  44. }
  45. }
  46. void app_math_Init(void)
  47. {
  48. Process_Start(1000,"math_Hour",app_math_Hour_process);
  49. }