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.

85 lines
1.7 KiB

  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. extern volatile char lcd_rxbuff[50] = {0};
  45. extern volatile int32_t lcd_count = 0;
  46. extern uint8_t g_lcd_rxbuf_isready;//lcd数据接收过程中为真,接收完成为假
  47. uint32_t judge_recv_lcd_data_finish_main(uint8_t time)
  48. {
  49. /**
  50. * @brief LCD的数据完成
  51. */
  52. static uint32_t recv_lcd_data_time = 0;
  53. recv_lcd_data_time = time;
  54. if(recv_lcd_data_time=0)
  55. {
  56. recv_lcd_data_time = hal_get_ticket();
  57. return recv_lcd_data_time;
  58. }
  59. else if (hal_has_passedms(recv_lcd_data_time) > 10) {
  60. g_lcd_rxbuf_isready=false;
  61. recv_lcd_data_time = hal_get_ticket();
  62. send_cmd_to_lcd(lcd_rxbuff,lcd_count);//接收完成将数据发给电脑
  63. lcd_count=0;
  64. return 0;
  65. }
  66. }
  67. void main()
  68. {
  69. peripheral_config();//各种初始化包括ram清零
  70. uint8_t record_last_time=0;
  71. while (1)
  72. {
  73. debug_light_ctrl_process_in_main_loop();//闪灯效果
  74. if(g_lcd_rxbuf_isready)//接收开始
  75. {
  76. record_last_time = judge_recv_lcd_data_finish_main(record_last_time);
  77. }
  78. }
  79. }