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
111 lines
2.8 KiB
/**
|
|
* @file app.c
|
|
* @author 1722451300@qq.com
|
|
* @brief
|
|
* @version 0.1
|
|
* @date 2021-12-13
|
|
*
|
|
* @copyright Copyright (c) 2021
|
|
*
|
|
*/
|
|
#include "app.h"
|
|
void peripheral_config(void)
|
|
{
|
|
/**
|
|
* @brief 外设初始化
|
|
*
|
|
*/
|
|
sys_init();
|
|
led_config();
|
|
beep_config();
|
|
lcd_uart_config();
|
|
motor_uart_config();
|
|
jerk_key_config();
|
|
init_timer1_as_ticketustimer_in32M();
|
|
}
|
|
|
|
void start_up(void)
|
|
{
|
|
/**
|
|
* @brief 开机灯闪烁三下,蜂鸣器响三下
|
|
* @param led的引脚号
|
|
*/
|
|
uint32_t num = 30 * 1000;
|
|
int n = 4;
|
|
while(n--)
|
|
{
|
|
sleep_ms(500);
|
|
led_on;
|
|
beep_off;
|
|
sleep_ms(500);
|
|
led_off;
|
|
beep_on;
|
|
}
|
|
}
|
|
|
|
//================================================================
|
|
//================================================================
|
|
//屏幕串口部分
|
|
extern uint8_t g_lcd_rxbuf_isready;//lcd数据接收过程中为真,接收完成为假
|
|
extern volatile char lcd_rxbuff[50] = {0};
|
|
extern volatile int32_t lcd_count = 0;
|
|
extern uint32_t g_process_recv_lcd_data_time = 0;
|
|
|
|
void judge_recv_lcd_data_finish_main(uint32_t time)
|
|
{
|
|
/**
|
|
* @brief 接收LCD的数据完成
|
|
*/
|
|
static uint32_t recv_lcd_data_time = 0;
|
|
recv_lcd_data_time = time;
|
|
if (hal_has_passedms(recv_lcd_data_time) > 10) {
|
|
g_lcd_rxbuf_isready=false;
|
|
recv_lcd_data_time = hal_get_ticket();
|
|
send_cmd_to_lcd(lcd_rxbuff,lcd_count);//接收完成将数据发给电脑
|
|
lcd_count=0;
|
|
}
|
|
|
|
}
|
|
//================================================================
|
|
//================================================================
|
|
//电机串口部分
|
|
extern uint8_t g_motor_rxbuf_isready;//lcd数据接收过程中为真,接收完成为假
|
|
extern volatile char motor_rxbuff[50] = {0};
|
|
extern volatile int32_t motor_count = 0;
|
|
extern uint32_t g_process_recv_motor_data_time = 0;
|
|
void judge_recv_motor_data_finish_main(uint32_t time)
|
|
{
|
|
/**
|
|
* @brief 接收motor的数据完成
|
|
*/
|
|
static uint32_t recv_motor_data_time = 0;
|
|
recv_motor_data_time = time;
|
|
if (hal_has_passedms(recv_motor_data_time) > 10) {
|
|
g_lcd_rxbuf_isready=false;
|
|
recv_motor_data_time = hal_get_ticket();
|
|
send_cmd_to_motor(motor_rxbuff,motor_count);//接收完成将数据发给电脑
|
|
send_cmd_to_lcd(motor_rxbuff,motor_count);//接收完成将数据发给电脑
|
|
motor_count=0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void main()
|
|
{
|
|
peripheral_config();//各种初始化包括ram清零
|
|
while (1)
|
|
{
|
|
debug_light_ctrl_process_in_main_loop();//闪灯效果
|
|
if(g_lcd_rxbuf_isready)//接收开始
|
|
{
|
|
judge_recv_lcd_data_finish_main(g_process_recv_lcd_data_time);
|
|
}
|
|
if(g_motor_rxbuf_isready)
|
|
{
|
|
judge_recv_motor_data_finish_main(g_process_recv_motor_data_time);
|
|
}
|
|
}
|
|
}
|
|
|