/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_RTC_Init();
MX_USART2_UART_Init();
MX_TIM2_Init();
MX_TIM3_Init();
/* USER CODE BEGIN 2 */
DelayInit();
GpioInit();
LCD_ST7920_Init();
LED_35V_CTL_L;//LCD受3.5v电源芯片控(使能)
LCDClrDisplay();
USART2_BUF_INIT(&rxbuf_struct);
LOW_PWR_Init(LOW_PWR_COUNTDOWN);//1min
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
//不断获取新的Time和Date
HAL_RTC_GetTime(&hrtc, &Time, RTC_FORMAT_BIN);
HAL_RTC_GetDate(&hrtc, &Date, RTC_FORMAT_BIN);
if(!low_pwr_struct.low_pwr_flag)//当不在休眠模式的时候才输出和显示
{
/* Display date Format : yy/mm/dd */
printf("DATE: %02d/%02d/%02d\r\nWEEKDAY: %02d\r\n",2000 + Date.Year, Date.Month, Date.Date,Date.WeekDay);
/* Display time Format : hh:mm:ss */
printf("TIME: %02d:%02d:%02d\r\n",Time.Hours, Time.Minutes, Time.Seconds);
printf("\r\n");
LCD_Display();
}
LED_TOGGLE();
// USART2_BUF_DEINIT(rxbuf_struct);
}
/* USER CODE END 3 */
}
USART2串口配置
//usart.h
/* USER CODE BEGIN Includes */
#include "sys.h"
#include "stdio.h"
/* USER CODE END Includes */
extern UART_HandleTypeDef huart2;
/* USER CODE BEGIN Private defines */
#define USART2_BUF_SIZE 20
typede