task_handleData(81).c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. /**
  29. * @brief 数据处理任务
  30. * @param None
  31. * @note None
  32. * @retval None
  33. */
  34. void task_handle_data(void){
  35. // 检测是否正在升级固件
  36. if(s_ec800Date.hardwareUpdate == 1){
  37. osDelay(100);
  38. return;
  39. }
  40. // 陀螺仪故障处理 尝试重新连接
  41. gyroscope_fault_deal();
  42. // 判断车辆是否正在转弯 陀螺仪数据
  43. if (isTurning()) {
  44. printf("The vehicle is turning.\r\n");
  45. } else {
  46. printf("Vehicle not turning.\r\n");
  47. }
  48. osDelay(100);
  49. }