task_handleData.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* includes ----------------------------------------------------------*/
  2. #include "task_handleData.h"
  3. /* typedef -----------------------------------------------------------*/
  4. /* define ------------------------------------------------------------*/
  5. /* macro -------------------------------------------------------------*/
  6. /* variables ---------------------------------------------------------*/
  7. /* function prototypes -----------------------------------------------*/
  8. // 故障处理 尝试重新连接,并按照正常上传时间上传
  9. void gyroscope_fault_deal(void){
  10. uint8_t recBack = 0;
  11. if(BIT_CHECK(s_comData.Malfunction, gyroscope)){
  12. turnFlag = 0; // 按照正常上传时间上传
  13. recBack = atk_ms6050_init();
  14. if(recBack != 0){
  15. // printf("ATK-MS6050 init failed!\r\n");
  16. return;
  17. }
  18. // printf("ATK-MS6050 init\r\n");
  19. recBack = atk_ms6050_dmp_init();
  20. if(recBack != 0){
  21. // printf("ATK-MS6050 DMP init failed!\r\n");
  22. return;
  23. }
  24. // printf("ATK-MS6050 DMP init!\r\n");
  25. BIT_CLEAR(s_comData.Malfunction, gyroscope);
  26. }
  27. }
  28. void task_handleData_run_led(void){
  29. static uint8_t timesCnt = 0;
  30. if(timesCnt < task_handleData_times_1s){
  31. timesCnt++;
  32. }else{
  33. timesCnt = 0;
  34. LED_Y_TOGGLE();
  35. }
  36. }
  37. /**
  38. * @brief 数据处理任务
  39. * @param None
  40. * @note None
  41. * @retval None
  42. */
  43. void task_handle_data(void){
  44. task_handleData_run_led();
  45. // 检测是否正在升级固件
  46. if(s_ec800Date.hardwareUpdate == 1){
  47. osDelay(100);
  48. return;
  49. }
  50. // 陀螺仪故障处理 尝试重新连接
  51. gyroscope_fault_deal();
  52. // 判断车辆是否正在转弯 陀螺仪数据
  53. if (isTurning()) {
  54. // printf("The vehicle is turning.\r\n");
  55. } else {
  56. // printf("Vehicle not turning.\r\n");
  57. }
  58. osDelay(100);
  59. }