You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. /**
  2. * @file app.c
  3. * @author 1722451300@qq.com
  4. * @brief
  5. * @version 0.1
  6. * @date 2021-12-13
  7. *
  8. * @copyright Copyright (c) 2021
  9. *
  10. */
  11. #include "app.h"
  12. void peripheral_config(void)
  13. {
  14. /**
  15. * @brief
  16. *
  17. */
  18. sys_init();
  19. led_config();
  20. beep_config();
  21. lcd_uart_config();
  22. motor_uart_config();
  23. jerk_key_config();
  24. init_timer1_as_ticketustimer_in32M();
  25. }
  26. void start_up(void)
  27. {
  28. /**
  29. * @brief
  30. * @param led的引脚号
  31. */
  32. uint32_t num = 30 * 1000;
  33. int n = 4;
  34. while(n--)
  35. {
  36. sleep_ms(500);
  37. led_on;
  38. beep_off;
  39. sleep_ms(500);
  40. led_off;
  41. beep_on;
  42. }
  43. }
  44. //================================================================
  45. //================================================================
  46. //屏幕串口部分
  47. extern uint8_t g_lcd_rxbuf_isready;//lcd数据接收过程中为真,接收完成为假
  48. extern volatile char lcd_rxbuff[50] = {0};
  49. extern volatile int32_t lcd_count = 0;
  50. extern uint32_t g_process_recv_lcd_data_time = 0;
  51. void judge_recv_lcd_data_finish_main(uint32_t time)
  52. {
  53. /**
  54. * @brief LCD的数据完成
  55. */
  56. static uint32_t recv_lcd_data_time = 0;
  57. recv_lcd_data_time = time;
  58. if (hal_has_passedms(recv_lcd_data_time) > 10) {
  59. g_lcd_rxbuf_isready=false;
  60. recv_lcd_data_time = hal_get_ticket();
  61. send_cmd_to_lcd(lcd_rxbuff,lcd_count);//接收完成将数据发给电脑
  62. lcd_count=0;
  63. }
  64. }
  65. //================================================================
  66. //================================================================
  67. //电机串口部分
  68. extern uint8_t g_motor_rxbuf_isready;//lcd数据接收过程中为真,接收完成为假
  69. extern volatile char motor_rxbuff[50] = {0};
  70. extern volatile int32_t motor_count = 0;
  71. extern uint32_t g_process_recv_motor_data_time = 0;
  72. void judge_recv_motor_data_finish_main(uint32_t time)
  73. {
  74. /**
  75. * @brief motor的数据完成
  76. */
  77. static uint32_t recv_motor_data_time = 0;
  78. recv_motor_data_time = time;
  79. if (hal_has_passedms(recv_motor_data_time) > 10) {
  80. g_lcd_rxbuf_isready=false;
  81. recv_motor_data_time = hal_get_ticket();
  82. send_cmd_to_motor(motor_rxbuff,motor_count);//接收完成将数据发给电脑
  83. send_cmd_to_lcd(motor_rxbuff,motor_count);//接收完成将数据发给电脑
  84. motor_count=0;
  85. }
  86. }
  87. void main()
  88. {
  89. peripheral_config();//各种初始化包括ram清零
  90. while (1)
  91. {
  92. debug_light_ctrl_process_in_main_loop();//闪灯效果
  93. if(g_lcd_rxbuf_isready)//接收开始
  94. {
  95. judge_recv_lcd_data_finish_main(g_process_recv_lcd_data_time);
  96. }
  97. if(g_motor_rxbuf_isready)
  98. {
  99. judge_recv_motor_data_finish_main(g_process_recv_motor_data_time);
  100. }
  101. }
  102. }