hal_step.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /********************** Í·Îļþ *************************/
  2. #include "usr.h"
  3. #include "hal_imu.h"
  4. #include "hal_step.h"
  5. #include "system.h"
  6. #include "bsp_time.h"
  7. #include "hal_ble_client.h"
  8. #include "hal_flash.h"
  9. #include "detect_step_by_mag.h"
  10. #if DEBUG_STEP
  11. extern uint16_t realStepAdd_R,mag_sqrt;
  12. void hal_step_matlib_Test(void)
  13. {
  14. static uint8_t buf[24] ={0};
  15. uint8_t L =0;
  16. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[0]>>8);
  17. buf[L++] = (uint8_t)(mFlash.mStep.stepCur[0]>>0);
  18. buf[L++] = (uint8_t)(mag_sqrt>>8);
  19. buf[L++] = (uint8_t)(mag_sqrt);
  20. buf[L++] = (uint8_t)(realStepAdd_R>>8);
  21. buf[L++] = (uint8_t)(realStepAdd_R>>0);
  22. BLE_Client_Tx_Send(0,BLE_Client_T_REALTIMESTEP,buf,L);
  23. }
  24. #endif
  25. static void hal_step_process(void){
  26. if(hal_Realstep_GetState())return;
  27. if(1 == detect_step_by_mag(hal_Mag_GetXYZ(Mag_Front))){
  28. mFlash.mStep.stepCur[0]++;
  29. // SEGGER_RTT_printf(0,">>>>>>>>current step:%d\r\n",mFlash.mStep.stepCur[0]);
  30. }else if(isLoader == 1){
  31. load_cal++;
  32. if(load_cal >= (60000/50)){
  33. isLoader =0;
  34. load_cal =0;
  35. SEGGER_RTT_printf(0,"isLoader:%d\r\n",isLoader);
  36. }
  37. }
  38. #if DEBUG_STEP
  39. hal_step_matlib_Test()£»
  40. #endif
  41. }
  42. //static void hal_stepSaveTest_process(void){
  43. // mFlash.mStep.stepCur[0]++;
  44. // SEGGER_RTT_printf(0,"hal step Save one minute:step %d\r\n",mFlash.mStep.stepCur[0]);
  45. //}
  46. void hal_step_init(void){
  47. Process_Start(50,"hal_step_process",hal_step_process);
  48. //if(mFlash.isHost)Process_Start(10000,"hal_stepSaveTest",hal_stepSaveTest_process);
  49. }