Proteus仿真文件STM32HAL库实现驱动液晶屏1602。
主程序见下载文件。
链接:https://pan.baidu.com/s/1BhK04lDWKyHS7S1BVD_OlQ
提取码:imrd
#ifndef __pgpio_H
#define __pgpio_H
#include "main.h"
#include "gpio.h"
#define LCD1602_RS0 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10,GPIO_PIN_RESET);//0x00000004 //低电平 PB.15
#define LCD1602_RW0 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9,GPIO_PIN_RESET);//0x00000010 //低电平 PB.14
#define LCD1602_EN0 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8,GPIO_PIN_RESET);//0x00000040 //低电平 PB.13
//============================端口位设置/清除寄存器=========================================//
#define LCD1602_RS1 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10,GPIO_PIN_SET);//0x00000004 //高电平 PB.15
#define LCD1602_RW1 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_9,GPIO_PIN_SET);//0x00000010 //高电平 PB.14
#define LCD1602_EN1 HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8,GPIO_PIN_SET); //0x00000040 //高电平 PB.13
#define lcd_data_port GPIOA->ODR//数据端口 PA0-PA7
void lcd_char_write(unsigned int x_pos,unsigned int y_pos,unsigned char lcd_dat);
void lcd_system_reset(void);
void lcd_command_write( unsigned char command);
void lcd_busy_wait(void);
void lcd_delay( unsigned char ms);
void GPIO_InitStructReadtempCmd(void);
#endif
/**
******************************************************************************
* File Name : gpio.c
* Description : This file provides code for the configuration
* of all used GPIO pins.
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "gpio.h"
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/*----------------------------------------------------------------------------*/
/* Configure GPIO */
/*----------------------------------------------------------------------------*/
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/** Configure pins
*/
void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9, GPIO_PIN_RESET);
/*Configure GPIO pins : PA0 PA1 PA2 PA3
PA4 PA5 PA6 PA7 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : PB10 PB7 PB8 PB9 */
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/