STM32F407的LCD1602液晶显示程序

这段代码是针对STM32微控制器的LCD1602显示器的驱动程序实现,包括初始化函数、字符和字符串显示函数以及数值显示函数。通过设置GPIO引脚控制RS、RW、E及数据线的高低电平来与LCD1602进行通信。

LCD1602.H


#ifndef __LCD1602_H
#define __LCD1602_H

#include"sys.h"
#include "stm32f4xx.h" 

//unsigned char message[20];
//unsigned char message2[20];

#define  LCD1602_Timer_GPIOD RCC_AHB1Periph_GPIOD
#define  LCD1602_GPIOD GPIOD
#define  LCD1602_RS   GPIO_Pin_8
#define  LCD1602_RW   GPIO_Pin_9
#define  LCD1602_E    GPIO_Pin_10
#define  LCD1602_IO   GPIO_Pin_0 |  GPIO_Pin_1 |  GPIO_Pin_2 |  GPIO_Pin_3 |  GPIO_Pin_4 |  GPIO_Pin_5 |  GPIO_Pin_6 |  GPIO_Pin_7

#define LCD1602_D0 GPIO_Pin_0
#define LCD1602_D1 GPIO_Pin_1
#define LCD1602_D2 GPIO_Pin_2
#define LCD1602_D3 GPIO_Pin_3
#define LCD1602_D4 GPIO_Pin_4
#define LCD1602_D5 GPIO_Pin_5
#define LCD1602_D6 GPIO_Pin_6
#define LCD1602_D7 GPIO_Pin_7

#define  LCD1602_I0_SET() GPIO_SetBits(LCD1602_GPIOD, LCD1602_IO)

#define  LCD1602_RS_SET()   GPIO_SetBits(LCD1602_GPIOD,LCD1602_RS)
#define  LCD1602_RS_RESET() GPIO_ResetBits(LCD1602_GPIOD,LCD1602_RS)

#define  LCD1602_RW_SET()   GPIO_SetBits(LCD1602_GPIOD,LCD1602_RW)
#define  LCD1602_RW_RESET() GPIO_ResetBits(LCD1602_GPIOD,LCD1602_RW)

#define  LCD1602_E_SET()   GPIO_SetBits(LCD1602_GPIOD,LCD1602_E)
#define  LCD1602_E_RESET() GPIO_ResetBits(LCD1602_GPIOD,LCD1602_E)

#define  LCD1602_D0_SET()   GPIO_SetBits(LCD1602_GPIOD,LCD1602_D0)
#define  LCD1602_D0_RESET() GPIO_ResetBits(LCD1602_GPIOD,LCD1602_D0)

#define  LCD1602_D1_SET()   GPIO_SetBits(LCD1602_GPIOD,LCD1602_D1)
#define  LCD1602_D1_RESET() GPIO_ResetBits(LCD1602_GPIOD,LCD1602_D1)

#define  LCD1602_D2_SET()   GPIO_SetBits(LCD1602_GPIOD,LCD1602_D2)
#define  LCD1602_D2_RESET() G
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值