ZhenDangBo2024/ZDB2024/user/Src/user_main.c
2024-11-18 10:44:27 +08:00

60 lines
1.2 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* user_main.c
*
* Created on: Jun 24, 2024
* Author: 10425
*/
#include "user.h"
void user_main(void)
{
user_init();
HAL_UART_DMAStop(&huart3);//复位DMA //串口DMA接受
HAL_UART_Receive_DMA(&huart3,(uint8_t *)RxBuff,sizeof(RxBuff));
HAL_DAC_Start(&hdac, DAC_CHANNEL_1);
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adcBuff,ADCBUFF_LEN);
// HAL_TIM_PWM_Stop(&htim3,TIM_CHANNEL_2);
HAL_Delay(2500); //上电延时2s
LCD_setChar(0x0005, (uint8_t*)"ns",2);
LCD_setFont(0x0020,coder_mode);
LCD_setFont(0x0030,3);
LCD_setInt(0x0001,voltage);
LCD_setInt(0x0002,Pulse_To_Time(pulse));
LCD_setInt(0x0003,frequency);
LCD_setLine(lineData, 125);
bsp_StartAutoTimer(0, 500);
bsp_ClearKey();
while(1)
{
if(bsp_CheckTimer(0))
{
HAL_GPIO_TogglePin(LED_GPIO_Port,LED_Pin);
}
if(bsp_CheckTimer(1)) //在PWM_Start_Once()中开启
{
for(uint8_t i =0;i<128;i++)
{
lineData[i] = 0;
}
LCD_setLine(lineData, 125);
draw_flag =0;
}
if(bsp_CheckTimer(2)) //编码器处理,在HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)中开启
{
coder_slave();
}
//串口接收数据处理
key_slave(); //按键处理
uart_slave(); //串口处理
}
}