123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- /********************** Í·Îļþ *************************/
- #include "usr.h"
- #include "hal_imu.h"
- #include "hal_step.h"
- #include "system.h"
- #include "bsp_time.h"
- #include "hal_ble_client.h"
- #include "hal_flash.h"
- #include "hal_mag.h"
- #include "hal_RealStep.h"
- #include "hal_attitude.h"
- #include "detect_step_by_mag.h"
- static uint8_t isLoader =0;
- static uint16_t load_cal =0;
- uint8_t get_isLoader(void)
- {
- return isLoader;
- }
- #if DEBUG_STEP
- extern uint16_t realStepAdd_R,mag_sqrt;
- void hal_step_matlib_Test(void)
- {
- static uint8_t buf[24] ={0};
- uint8_t L =0;
- buf[L++] = (uint8_t)(mFlash.mStep.stepCur[0]>>8);
- buf[L++] = (uint8_t)(mFlash.mStep.stepCur[0]>>0);
- buf[L++] = (uint8_t)(mag_sqrt>>8);
- buf[L++] = (uint8_t)(mag_sqrt);
- buf[L++] = (uint8_t)(realStepAdd_R>>8);
- buf[L++] = (uint8_t)(realStepAdd_R>>0);
- BLE_Client_Tx_Send(0,BLE_Client_T_REALTIMESTEP,buf,L);
- }
- #endif
- static void hal_step_process(void){
- if(hal_Realstep_GetState())return;
- if(1 == detect_step_by_mag(hal_Mag_GetXYZ(Mag_Front))){
- mFlash.mStep.stepCur[0]++;
- if(0 == isLoader){
- isLoader =1;
- SEGGER_RTT_printf(0,"isLoader:%d\r\n",isLoader);
- }
- load_cal =0;
- // SEGGER_RTT_printf(0,">>>>>>>>current step:%d\r\n",mFlash.mStep.stepCur[0]);
- }else if(isLoader == 1){
- load_cal++;
- if(load_cal >= (60000/50)){
- isLoader =0;
- load_cal =0;
- SEGGER_RTT_printf(0,"isLoader:%d\r\n",isLoader);
- }
- }
- #if DEBUG_STEP
- hal_step_matlib_Test()£»
- #endif
- }
- //static void hal_stepSaveTest_process(void){
- // mFlash.mStep.stepCur[0]++;
- // SEGGER_RTT_printf(0,"hal step Save one minute:step %d\r\n",mFlash.mStep.stepCur[0]);
- //}
- void hal_step_init(void){
- Process_Start(50,"hal_step_process",hal_step_process);
- //if(mFlash.isHost)Process_Start(10000,"hal_stepSaveTest",hal_stepSaveTest_process);
- }
|