STM32单片机- LCD1602显示屏输出实验
核心代码由kingsraywii提供,本文作者对其进行整合、更详细地注释和部分代码改进, 添加了芯片ID获取、字符串输出和printf重定向输出功能
注:使用普中科技开发板测试时,需要拔掉Boot1插口 接5V电压,重启
view plaincopyprint?
- /*******************************************************************************
-
-
- 软件功能: LCD1602实验(软件延时方式)
-
- *******************************************************************************/
- #include “stm32f10x.h”
- #include “delay.h”
- #include <stdio.h>
- /*
- 定义宏变量
- lcd_RS = data/command(H/L) 数据/命令操作
- .lcd_RW = read/write(H/L) 读写操作
- lcd_Enable 使能操作
- lcd_GPIO lcd1602接在了GPIOX口
- */
- //接口
- #define lcd_GPIO GPIOB
- #define lcd_busyflag GPIO_Pin_15 //DB7对应的口
- #define lcd_pin_RS GPIO_Pin_1
- #define lcd_pin_RW GPIO_Pin_2
- #define lcd_pin_Enable GPIO_Pin_0
- //状态
- #define lcd_DATA 1
- #define lcd_COMMAND 0
- #define lcd_READ 1
- #define lcd_WRITE 0
- //功能
- #define lcd_RS(n) n ? GPIO_SetBits(lcd_GPIO,lcd_pin_RS) : GPIO_ResetBits(lcd_GPIO,lcd_pin_RS)
- #define lcd_RW(n) n ? GPIO_SetBits(lcd_GPIO,lcd_pin_RW) : GPIO_ResetBits(lcd_GPIO,lcd_pin_RW)
- #define lcd_Enable(n) n ? GPIO_SetBits(lcd_GPIO,lcd_pin_Enable) : GPIO_ResetBits(lcd_GPIO,lcd_pin_Enable)
- void RCC_Configuration(void);
- void GPIO_Configuration(void);
- void Lcd_Write(u8 type,u8 buf);
- void Lcd_WriteString(u8 *buf);
- int Lcd_isbusy(void);
- void Lcd_Init(void);
- int fputc(int ch, FILE *f);
- void getSys_ID(void);
- /*************************************************
- 函数: