一、题目介绍
按键输入:短按
模拟电压输出:ADC
LCD显示
PWM输出:PA6,PA7
二、usr.c
#include "usr.h"
#include "lcd.h"
#include "stdio.h"
#include "tim.h"
#include "adc.h"
/*value-------------------------------------------------*/
uint8_t menu = 0;
uint8_t mode = 0;
float V;
/*define------------------------------------------------*/
#define MENU_DATA 0
#define MENU_PARA 1
#define MODE_AUTO 0
#define MODE_MANU 1
/*define */
#define B4_Pin GPIO_PIN_0
#define B4_GPIO_Port GPIOA
#define B1_Pin GPIO_PIN_0
#define B1_GPIO_Port GPIOB
#define B2_Pin GPIO_PIN_1
#define B2_GPIO_Port GPIOB
#define B3_Pin GPIO_PIN_2
#define B3_GPIO_Port GPIOB
/*define */
#define KEY_LONG_TIME 200
#define KEY_SHORT_TIME 50
/*define */
#define PA7_BASE (500-1)
#define PA6_BASE (1000-1)
#define PA6_BUJIN 1000
#define PA7_BUJIN 500
struct keys key[4]={0,0,0,0};
float PA6_duty = 10;
float PA7_duty = 10;
//led
void led_set(uint8_t display)
{
HAL_GPIO_WritePin(GPIOC,GPIO_PIN_All,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOC,display<<8,GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_2,GPIO_PIN_RESET);
}
//display
void display_init(void)
{
LCD_Clear(Black);
LCD_SetBackColor(Black);
LC