STM32配合cubeMX硬件I2C驱动0.96寸OLED

这篇具有很好参考价值的文章主要介绍了STM32配合cubeMX硬件I2C驱动0.96寸OLED。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

目录

一、简单介绍

1.1   OLED

1.2   I2C协议

二、实战

2.1 工程配置

2.2 测试工程

2.3 波形分析

三、驱动OLED

3.1 初始化代码

3.2 清屏函数

3.3 设置坐标函数

3.4 显示字符函数

3.5 显示字符串函数

3.6 显示图片函数

附录 驱动代码文件

oled.c

oled.h

f6x8.h


一、简单介绍

1.1   OLED

有机发光二极管(英语:Organic Light-Emitting Diode,缩写:OLED)又称有机电激发光显示(英语:Organic Electroluminescence Display,缩写:OELD)、有机发光半导体,OLED技术最早于1950年代和1960年代由法国人和美国人研制,其后由美国柯达及英国剑桥大学加以演进,日本SONY及韩国三星和LG等公司于21世纪开始量产,现在的市场都趋近于OLED但是在寿命上比LCD短。[来源请求]

OLED(有机发光二极管)与TFT-LCD(薄膜晶体管液晶显示器)为不同类型的产品,OLED具有自发光性、广视角、高对比、低耗电、高反应速率、全彩化及制程简单等优点,但相对的在大面板价格、技术选择性 、寿命、分辨率、色彩还原方面便无法与TFT-LCD匹敌,有机发光二极管显示器可分单色、多彩及全彩等种类,而其中以全彩制作技术最为困难。

OLED显示器依驱动方式的不同又可分为被动式(Passive Matrix,PMOLED)与主动式(Active Matrix,AMOLED)。

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

笔者使用的oled如上图,四针脚I2C协议,主控为SSD1306

规格为0.96寸,分辨率为128*64

1.2   I2C协议

I²CInter-Integrated Circuit)字面上的意思是集成电路之间,它其实是I²C Bus简称,所以中文应该叫集成电路总线,它是一种串行通信总线,使用多主从架构,由飞利浦公司在1980年代为了让主板、嵌入式系统或手机用以连接低速周边设备而发展。I²C的正确读法为“I平方C”("I-squared-C"),而“I二C”("I-two-C")则是另一种错误但被广泛使用的读法。自2006年10月1日起,使用I²C协议已经不需要支付专利费,但制造商仍然需要付费以获取I²C从属设备地址[1]。

I²C的参考设计使用一个7比特长度的地址空间但保留了16个地址,所以在一组总线最多可和112个节点通信[a]。常见的I²C总线依传输速率的不同而有不同的模式:标准模式(100 kbit/s)、低速模式(10 kbit/s),但时钟频率可被允许下降至零,这代表可以暂停通信。而新一代的I²C总线可以和更多的节点(支持10比特长度的地址空间)以更快的速率通信:快速模式(400 kbit/s)、快速+模式(1 Mbit/s)高速模式(3.4 Mbit/s)超高速模式(5 Mbit/s)。

i2c在容易线长导致信号质量不佳,速度越快能用的距离越短(一般约在10公分上下),上拉电阻用小一点可能有帮助。2c阻抗50,usb阻抗100在做信号转换时阻抗不匹配会造成信号极差

其通信过程如下

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

二、实战

2.1 工程配置

打开cubeMX进行配置

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

开启I2C1,设置速率为Fast Mode Plus,即快速+模式,初始化时钟等等

2.2 测试工程

打开生成的工程,添加测试代码

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

函数具体说明如下

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

2.3 波形分析

使用逻辑分析仪查看波形如下 

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

注意到在写完地址0x78后多了一个0,查看datasheet

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

当对器件进行写入时,最后一位为0

三、驱动OLED

知道HAL库对I2C的发送过程后,阅读ssd1306的datasheet,进行驱动的编写

使用器件需要对器件进行初始化,阅读手册进行配置即可

其间用到一条重要的函数即

void SSD1306_WriteByte(uint8_t dat,uint8_t cmd);

功能是通过I2C总线对ssd1306进行数据发送

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

阅读手册,在发送一个命令或数据时,要先发送控制字节,告知接下来发的是数据还是指令。因此函数实现如下

void SSD1306_WriteByte(uint8_t dat,uint8_t cmd)
{
	uint8_t buffer[2];
	buffer[0]=cmd;
	buffer[1]=dat;
	HAL_I2C_Master_Transmit(&hi2c1,0x78,buffer,2,0xffff);
}

HAL_I2C_Master_Transmit()函数一次发两个字节过去,第一个字节告知是数据还是指令,第二个字节为数据或指令。

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

 如果是数据则先发送0x40,如果是指令则先发送0x00.

使用这个函数对oled进行初始化配置函数的编写

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

主要指令内容集中在这几章,整个datasheet约60页,开头为目录和介绍,末尾是封装信息。

指令表中有基本指令,滚动指令,地址设置指令,硬件配置指令,时序及驱动指令

用到的为除滚动指令外的四个

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

 光看指令表会有些陌生,可以结合下面的描述来看

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

3.1 初始化代码

void OLED_Init()
{
	HAL_Delay(100);
	SSD1306_WriteByte(0xAE,OLED_CMD); //display off
	
	SSD1306_WriteByte(0x20,OLED_CMD); //Set Memory Addressing Mode   
	SSD1306_WriteByte(0x10,OLED_CMD); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
	
	SSD1306_WriteByte(0x00,OLED_CMD); //---set low column address
	SSD1306_WriteByte(0x10,OLED_CMD); //---set high column address
	
	SSD1306_WriteByte(0xB0,OLED_CMD); //Set Page Start Address for Page Addressing Mode,0-7
	SSD1306_WriteByte(0xC8,OLED_CMD); //Set COM Output Scan Direction

	SSD1306_WriteByte(0x40,OLED_CMD); //--set start line address
	
	SSD1306_WriteByte(0x81,OLED_CMD); //--set contrast control register
	SSD1306_WriteByte(0xff,OLED_CMD); //对比度设置
	
	SSD1306_WriteByte(0xA1,OLED_CMD); //--set segment re-map 0 to 127
	SSD1306_WriteByte(0xC8,OLED_CMD); //--set segment re-map 0 to 127
	
	SSD1306_WriteByte(0xA6,OLED_CMD); //--set normal display
	
	SSD1306_WriteByte(0xA8,OLED_CMD); //--set multiplex ratio(1 to 64)
	SSD1306_WriteByte(0x3F,OLED_CMD); //
	
	SSD1306_WriteByte(0xA4,OLED_CMD); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content
	
	SSD1306_WriteByte(0xD3,OLED_CMD); //-set display offset
	SSD1306_WriteByte(0x00,OLED_CMD); //-not offset
	
	SSD1306_WriteByte(0xD5,OLED_CMD); //--set display clock divide ratio/oscillator frequency
	SSD1306_WriteByte(0xF0,OLED_CMD); //--set divide ratio
	
	SSD1306_WriteByte(0xD9,OLED_CMD); //--set pre-charge period
	SSD1306_WriteByte(0x22,OLED_CMD); //
	
	SSD1306_WriteByte(0xDA,OLED_CMD); //--set com pins hardware configuration
	SSD1306_WriteByte(0x12,OLED_CMD);
	
	SSD1306_WriteByte(0xDB,OLED_CMD); //--set vcomh
	SSD1306_WriteByte(0x20,OLED_CMD); //0x20,0.77xVcc
	
	SSD1306_WriteByte(0x8D,OLED_CMD); //--set DC-DC enable
	SSD1306_WriteByte(0x14,OLED_CMD); //
	SSD1306_WriteByte(0xAF,OLED_CMD); //--turn on SSD1306 panel
}

 OLED_CMD使用宏定义,其值为0x00

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

根据描述,第一步先设置地址模式为页地址模式,注意这个指令是双字节的,意思是发送0x20后要继续发送一个指令联合起来进行设置。根据手册,第二个指令为 0x10

然后设置列地址起始位置,由于屏幕横向有128个像素点,就有128列,手册将地址设置分成高四位地址设置和低四位地址设置,用两个指令来完成,分别是0x00~0x0F控制低四位,0x10~0x1F控制高四位,手册中的例子为低地址指令0x03,高地址为0x10,则最终列起始地址为0x03即SEG3

重要的指令为页起始地址设置指令,就是上面的0x10~0x1f和0x00~0x0f,实际上前者不能为0x1f,因为只有128列,显然f*16=240>128

3.2 清屏函数

void OLED_Clear()
{
     uint8_t i,n;		    
	for(i=0;i<8;i++)  
	{  
		SSD1306_WriteByte (0xb0+i,OLED_CMD);    //设置页地址(0~7)
		SSD1306_WriteByte (0x00,OLED_CMD);      //设置显示位置—列低地址
		SSD1306_WriteByte (0x10,OLED_CMD);      //设置显示位置—列高地址   
		for(n=0;n<128;n++)
			SSD1306_WriteByte(0,OLED_DATA); //write 0x00;
	} //更新显示
}

外层循环8次,对应8个page,每个page由纵向8个像素,横向128列构成。设置页地址起始列为最左边即SEG0,将这128列都填充数据0x00,显示出来就是一片黑色

3.3 设置坐标函数

void OLED_Set_Pos(unsigned char x, unsigned char y) 
{ 	
	SSD1306_WriteByte(0xb0+y,OLED_CMD);						//page y
	SSD1306_WriteByte(((x&0xf0)>>4)|0x10,OLED_CMD);			//high 4 address
	SSD1306_WriteByte((x&0x0f),OLED_CMD); 					//low 4 address
} 

形参y设置page,范围为0到7,对应的指令为0xb0~0xb7。形参x设置起始页列地址,范围为0~127对应SEG0~SEG127。需要对x进行分块,分成高半字节和低半字节

编写主函数代码如下

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

 OLED在左上角显示字符A,高度为8像素,宽为6像素,图中6行发送数据的函数将字符A的6列一一发送过去,且OLED的列指针会自动加一,因此不必反复设置列指针位置 

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

 当然,写成下面这样也是可以的

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

这里会有一个疑问,就是这些数据是怎么得到的,总不会一个个去画吧。实际这是对A进行字体大小为8*6的取模得到的。网上有许多取模软件,一般会将ASCII码全部取出,并存放在一个数组中,需要用到时只需要发送对应行的数据

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

3.4 显示字符函数

void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size)
{      	
	unsigned char c=0,i=0;	
		c=chr-' ';//得到偏移后的值			
		if(x>Max_Column-1){x=0;y=y+2;}
		if(Char_Size ==16)
			{
				OLED_Set_Pos(x,y);	
				for(i=0;i<8;i++)
				SSD1306_WriteByte(F8X16[c*16+i],OLED_DATA);
				OLED_Set_Pos(x,y+1);
				for(i=0;i<8;i++)
				SSD1306_WriteByte(F8X16[c*16+i+8],OLED_DATA);
			}
		else 
			{	
				OLED_Set_Pos(x,y);
				for(i=0;i<6;i++)
				SSD1306_WriteByte(F6x8[c][i],OLED_DATA);
			}
}

这个字符显示函数只有高8和高16两种大小的字符显示功能,其中显示高度为16像素的字符时,涉及到两页,需要将y+1。先将上半部分的8列写入再将下半部分8列写入。但是想写高为12,14,20等等的字体需要用另一种方法

3.5 显示字符串函数

void OLED_ShowString(uint8_t x,uint8_t y,uint8_t *chr,uint8_t Char_Size)
{
	unsigned char j=0;
	while (chr[j]!='\0')
	{		OLED_ShowChar(x,y,chr[j],Char_Size);
			x+=8;
		if(x>120){x=0;y+=2;}
			j++;
	}
}

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

效果如下

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

如果想显示数字的话,使用sprintf函数进行转换为字符串,然后显示对应的字符串即可。

3.6 显示图片函数

这里以经典的PCtoLCD2002为例

取模设置如下

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

 参考手册页地址模式

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

选择低位在前,且为列行式,使用一维数组储存,右边格式前缀后缀稍作修改。

由于图片包含取模信息和图片的长度宽度,使用结构体进行定义 

typedef struct
{
	uint8_t xSize;
	uint8_t ySize;
	const unsigned char *p;
}BMP;

将这个声明放到oled.h中,因为oled.c有显示图片函数需要用到

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

 将取好的图片模和字模放到一个.h文件中

const unsigned char bmp_data[]=
{
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x80,0x80,0x60,0x40,0x80,0x80,0xC0,0xE0,
0xE0,0x40,0x20,0x10,0x50,0xB0,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1C,0x1F,0x09,0x18,0x18,0x10,0x10,0x01,0x1F,0x1F,0x1F,0x1F,0x09,0x01,0x11,0x15,
0x10,0x11,0x11,0x1F,0x1D,0x1C,0x1F,0x17,0x12,0x18,0x10,0x10,0x11,0x18,0x1F,0x1F
};

BMP bmp=
{
	32,	//宽像素
	13,	//高像素
	bmp_data
};

并将bmp用extern修饰

extern BMP bmp;

显示函数如下

void OLED_ShowPic(uint8_t x,uint8_t y,BMP bmp)
{
	uint8_t xsize=bmp.xSize;
	uint8_t ysize=bmp.ySize;
	OLED_Set_Pos(x,y);
	//如果像素高度不是8的倍数,则整除后加1补上
	if(ysize%8!=0)
		ysize=ysize+8;
	uint8_t i,j;
	for(i=0;i<ysize/8;i++)
	{
		OLED_Set_Pos(x,y+i);
		for(j=0;j<xsize;j++)
		SSD1306_WriteByte(*(bmp.p+i*xsize+j),OLED_DATA);
	}
}

主函数编写

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

 显示效果如下

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

附录 驱动代码文件

oled.c

#include "oled.h"
#include "f6x8.h"


void SSD1306_WriteByte(uint8_t dat,uint8_t cmd)
{
	uint8_t buffer[2];
	buffer[0]=cmd;
	buffer[1]=dat;
	HAL_I2C_Master_Transmit(&hi2c1,0x78,buffer,2,0xffff);
}

void OLED_Init()
{
	HAL_Delay(100);
	SSD1306_WriteByte(0xAE,OLED_CMD); //display off
	
	SSD1306_WriteByte(0x20,OLED_CMD); //Set Memory Addressing Mode   
	SSD1306_WriteByte(0x10,OLED_CMD); //00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
	
	SSD1306_WriteByte(0xB0,OLED_CMD); //Set Page Start Address for Page Addressing Mode,0-7
	
	SSD1306_WriteByte(0x00,OLED_CMD); //---set low column address
	SSD1306_WriteByte(0x10,OLED_CMD); //---set high column address
	
	SSD1306_WriteByte(0xC8,OLED_CMD); //Set COM Output Scan Direction

	SSD1306_WriteByte(0x40,OLED_CMD); //--set start line address
	
	SSD1306_WriteByte(0x81,OLED_CMD); //--set contrast control register
	SSD1306_WriteByte(0xff,OLED_CMD); //对比度设置
	
	SSD1306_WriteByte(0xA1,OLED_CMD); //--set segment re-map 0 to 127
	SSD1306_WriteByte(0xC8,OLED_CMD); //--set segment re-map 0 to 127
	
	SSD1306_WriteByte(0xA6,OLED_CMD); //--set normal display
	
	SSD1306_WriteByte(0xA8,OLED_CMD); //--set multiplex ratio(1 to 64)
	SSD1306_WriteByte(0x3F,OLED_CMD); //
	
	SSD1306_WriteByte(0xA4,OLED_CMD); //0xa4,Output follows RAM content;0xa5,Output ignores RAM content
	
	SSD1306_WriteByte(0xD3,OLED_CMD); //-set display offset
	SSD1306_WriteByte(0x00,OLED_CMD); //-not offset
	
	SSD1306_WriteByte(0xD5,OLED_CMD); //--set display clock divide ratio/oscillator frequency
	SSD1306_WriteByte(0xF0,OLED_CMD); //--set divide ratio
	
	SSD1306_WriteByte(0xD9,OLED_CMD); //--set pre-charge period
	SSD1306_WriteByte(0x22,OLED_CMD); //
	
	SSD1306_WriteByte(0xDA,OLED_CMD); //--set com pins hardware configuration
	SSD1306_WriteByte(0x12,OLED_CMD);
	
	SSD1306_WriteByte(0xDB,OLED_CMD); //--set vcomh
	SSD1306_WriteByte(0x20,OLED_CMD); //0x20,0.77xVcc
	
	SSD1306_WriteByte(0x8D,OLED_CMD); //--set DC-DC enable
	SSD1306_WriteByte(0x14,OLED_CMD); //
	SSD1306_WriteByte(0xAF,OLED_CMD); //--turn on SSD1306 panel
}
void OLED_Clear()
{
     uint8_t i,n;		    
	for(i=0;i<8;i++)  
	{  
		SSD1306_WriteByte (0xb0+i,OLED_CMD);    //设置页地址(0~7)
		SSD1306_WriteByte (0x00,OLED_CMD);      //设置显示位置—列低地址
		SSD1306_WriteByte (0x10,OLED_CMD);      //设置显示位置—列高地址   
		for(n=0;n<128;n++)
			SSD1306_WriteByte(0,OLED_DATA); //write 0x00;
	} //更新显示
}


void OLED_Set_Pos(unsigned char x, unsigned char y) 
{ 	
	SSD1306_WriteByte(0xb0+y,OLED_CMD);						//page y
	SSD1306_WriteByte(((x&0xf0)>>4)|0x10,OLED_CMD);			//high 4 address
	SSD1306_WriteByte((x&0x0f),OLED_CMD); 					//low 4 address
} 


void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size)
{      	
	unsigned char c=0,i=0;	
		c=chr-' ';//得到偏移后的值			
		if(x>Max_Column-1){x=0;y=y+2;}
		if(Char_Size ==16)
			{
				OLED_Set_Pos(x,y);	
				for(i=0;i<8;i++)
				SSD1306_WriteByte(F8X16[c*16+i],OLED_DATA);
				OLED_Set_Pos(x,y+1);
				for(i=0;i<8;i++)
				SSD1306_WriteByte(F8X16[c*16+i+8],OLED_DATA);
			}
		else 
			{	
				OLED_Set_Pos(x,y);
				for(i=0;i<6;i++)
				SSD1306_WriteByte(F6x8[c][i],OLED_DATA);
			}
}
void OLED_ShowString(uint8_t x,uint8_t y,uint8_t *chr,uint8_t Char_Size)
{
	unsigned char j=0;
	while (chr[j]!='\0')
	{		OLED_ShowChar(x,y,chr[j],Char_Size);
			x+=8;
		if(x>120){x=0;y+=2;}
			j++;
	}
}
void OLED_ShowPic(uint8_t x,uint8_t y,BMP bmp)
{
	uint8_t xsize=bmp.xSize;
	uint8_t ysize=bmp.ySize;
	OLED_Set_Pos(x,y);
	//如果像素高度不是8的倍数,则整除后加1补上
	if(ysize%8!=0)
		ysize=ysize+8;
	uint8_t i,j;
	for(i=0;i<ysize/8;i++)
	{
		OLED_Set_Pos(x,y+i);
		for(j=0;j<xsize;j++)
		SSD1306_WriteByte(*(bmp.p+i*xsize+j),OLED_DATA);
	}
}

oled.h

#ifndef OLED_H
#define OLED_H
#include "main.h"                  // Device header
#include "i2c.h"


#define OLED_CMD  0X00 //写命令
#define OLED_DATA 0X40 //写数据

#define SSD1306_I2C_ADDR         0x78
#define SSD1306_WIDTH            128
#define SSD1306_HEIGHT           6

#define SIZE 16
#define XLevelL		0x02
#define XLevelH		0x10
#define Max_Column	128
#define Max_Row		64
#define	Brightness	0xFF 
#define X_WIDTH 	128
#define Y_WIDTH 	64

typedef struct
{
	uint8_t xSize;
	uint8_t ySize;
	const unsigned char *p;
}BMP;


void OLED_Init();
void OLED_Clear();
void OLED_ShowChar(uint8_t x,uint8_t y,uint8_t chr,uint8_t Char_Size);
void OLED_ShowString(uint8_t x,uint8_t y,uint8_t *chr,uint8_t Char_Size);
void OLED_ShowPic(uint8_t x,uint8_t y,BMP bmp);
#endif

f6x8.h

#ifndef __OLEDFONT_H__
#define __OLEDFONT_H__   
#include "oled.h"


extern BMP bmp;

//常用ASCII表
//偏移量32
//ASCII字符集
//偏移量32
//大小:12*6
/************************************6*8的点阵************************************/
const unsigned char  F6x8[][6] =		
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp
0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,// !
0x00, 0x00, 0x07, 0x00, 0x07, 0x00,// "
0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,// #
0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,// $
0x00, 0x62, 0x64, 0x08, 0x13, 0x23,// %
0x00, 0x36, 0x49, 0x55, 0x22, 0x50,// &
0x00, 0x00, 0x05, 0x03, 0x00, 0x00,// '
0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,// (
0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,// )
0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,// *
0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,// +
0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,// ,
0x00, 0x08, 0x08, 0x08, 0x08, 0x08,// -
0x00, 0x00, 0x60, 0x60, 0x00, 0x00,// .
0x00, 0x20, 0x10, 0x08, 0x04, 0x02,// /
0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,// 1
0x00, 0x42, 0x61, 0x51, 0x49, 0x46,// 2
0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,// 3
0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,// 4
0x00, 0x27, 0x45, 0x45, 0x45, 0x39,// 5
0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
0x00, 0x01, 0x71, 0x09, 0x05, 0x03,// 7
0x00, 0x36, 0x49, 0x49, 0x49, 0x36,// 8
0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,// 9
0x00, 0x00, 0x36, 0x36, 0x00, 0x00,// :
0x00, 0x00, 0x56, 0x36, 0x00, 0x00,// ;
0x00, 0x08, 0x14, 0x22, 0x41, 0x00,// <
0x00, 0x14, 0x14, 0x14, 0x14, 0x14,// =
0x00, 0x00, 0x41, 0x22, 0x14, 0x08,// >
0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ?
0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @
0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A
0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B
0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C
0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D
0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E
0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F
0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G
0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H
0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I
0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J
0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K
0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L
0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M
0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N
0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O
0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P
0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R
0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S
0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T
0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U
0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V
0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W
0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X
0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y
0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z
0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [
0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55
0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ]
0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^
0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _
0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// '
0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a
0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b
0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c
0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d
0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e
0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f
0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g
0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h
0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i
0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j
0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k
0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l
0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m
0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n
0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o
0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p
0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q
0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r
0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s
0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t
0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u
0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v
0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w
0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x
0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y
0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z
0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines
};
/****************************************8*16的点阵************************************/
const unsigned char  F8X16[]=	  
{
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,// 0
  0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x33,0x30,0x00,0x00,0x00,//! 1
  0x00,0x10,0x0C,0x06,0x10,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//" 2
  0x40,0xC0,0x78,0x40,0xC0,0x78,0x40,0x00,0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,//# 3
  0x00,0x70,0x88,0xFC,0x08,0x30,0x00,0x00,0x00,0x18,0x20,0xFF,0x21,0x1E,0x00,0x00,//$ 4
  0xF0,0x08,0xF0,0x00,0xE0,0x18,0x00,0x00,0x00,0x21,0x1C,0x03,0x1E,0x21,0x1E,0x00,//% 5
  0x00,0xF0,0x08,0x88,0x70,0x00,0x00,0x00,0x1E,0x21,0x23,0x24,0x19,0x27,0x21,0x10,//& 6
  0x10,0x16,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//' 7
  0x00,0x00,0x00,0xE0,0x18,0x04,0x02,0x00,0x00,0x00,0x00,0x07,0x18,0x20,0x40,0x00,//( 8
  0x00,0x02,0x04,0x18,0xE0,0x00,0x00,0x00,0x00,0x40,0x20,0x18,0x07,0x00,0x00,0x00,//) 9
  0x40,0x40,0x80,0xF0,0x80,0x40,0x40,0x00,0x02,0x02,0x01,0x0F,0x01,0x02,0x02,0x00,//* 10
  0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x1F,0x01,0x01,0x01,0x00,//+ 11
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xB0,0x70,0x00,0x00,0x00,0x00,0x00,//, 12
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,0x01,0x01,//- 13
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,//. 14
  0x00,0x00,0x00,0x00,0x80,0x60,0x18,0x04,0x00,0x60,0x18,0x06,0x01,0x00,0x00,0x00,/// 15
  0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0 16
  0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1 17
  0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2 18
  0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3 19
  0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4 20
  0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5 21
  0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6 22
  0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7 23
  0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8 24
  0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9 25
  0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,//: 26
  0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x60,0x00,0x00,0x00,0x00,//; 27
  0x00,0x00,0x80,0x40,0x20,0x10,0x08,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x00,//< 28
  0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x00,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00,//= 29
  0x00,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x20,0x10,0x08,0x04,0x02,0x01,0x00,//> 30
  0x00,0x70,0x48,0x08,0x08,0x08,0xF0,0x00,0x00,0x00,0x00,0x30,0x36,0x01,0x00,0x00,//? 31
  0xC0,0x30,0xC8,0x28,0xE8,0x10,0xE0,0x00,0x07,0x18,0x27,0x24,0x23,0x14,0x0B,0x00,//@ 32
  0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 33
  0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 34
  0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 35
  0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 36
  0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 37
  0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 38
  0xC0,0x30,0x08,0x08,0x08,0x38,0x00,0x00,0x07,0x18,0x20,0x20,0x22,0x1E,0x02,0x00,//G 39
  0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x20,0x3F,0x21,0x01,0x01,0x21,0x3F,0x20,//H 40
  0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//I 41
  0x00,0x00,0x08,0x08,0xF8,0x08,0x08,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,0x00,//J 42
  0x08,0xF8,0x88,0xC0,0x28,0x18,0x08,0x00,0x20,0x3F,0x20,0x01,0x26,0x38,0x20,0x00,//K 43
  0x08,0xF8,0x08,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x20,0x30,0x00,//L 44
  0x08,0xF8,0xF8,0x00,0xF8,0xF8,0x08,0x00,0x20,0x3F,0x00,0x3F,0x00,0x3F,0x20,0x00,//M 45
  0x08,0xF8,0x30,0xC0,0x00,0x08,0xF8,0x08,0x20,0x3F,0x20,0x00,0x07,0x18,0x3F,0x00,//N 46
  0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,//O 47
  0x08,0xF8,0x08,0x08,0x08,0x08,0xF0,0x00,0x20,0x3F,0x21,0x01,0x01,0x01,0x00,0x00,//P 48
  0xE0,0x10,0x08,0x08,0x08,0x10,0xE0,0x00,0x0F,0x18,0x24,0x24,0x38,0x50,0x4F,0x00,//Q 49
  0x08,0xF8,0x88,0x88,0x88,0x88,0x70,0x00,0x20,0x3F,0x20,0x00,0x03,0x0C,0x30,0x20,//R 50
  0x00,0x70,0x88,0x08,0x08,0x08,0x38,0x00,0x00,0x38,0x20,0x21,0x21,0x22,0x1C,0x00,//S 51
  0x18,0x08,0x08,0xF8,0x08,0x08,0x18,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//T 52
  0x08,0xF8,0x08,0x00,0x00,0x08,0xF8,0x08,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//U 53
  0x08,0x78,0x88,0x00,0x00,0xC8,0x38,0x08,0x00,0x00,0x07,0x38,0x0E,0x01,0x00,0x00,//V 54
  0xF8,0x08,0x00,0xF8,0x00,0x08,0xF8,0x00,0x03,0x3C,0x07,0x00,0x07,0x3C,0x03,0x00,//W 55
  0x08,0x18,0x68,0x80,0x80,0x68,0x18,0x08,0x20,0x30,0x2C,0x03,0x03,0x2C,0x30,0x20,//X 56
  0x08,0x38,0xC8,0x00,0xC8,0x38,0x08,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x00,//Y 57
  0x10,0x08,0x08,0x08,0xC8,0x38,0x08,0x00,0x20,0x38,0x26,0x21,0x20,0x20,0x18,0x00,//Z 58
  0x00,0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x7F,0x40,0x40,0x40,0x00,//[ 59
  0x00,0x0C,0x30,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x06,0x38,0xC0,0x00,//\ 60
  0x00,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00,0x40,0x40,0x40,0x7F,0x00,0x00,0x00,//] 61
  0x00,0x00,0x04,0x02,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//^ 62
  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,//_ 63
  0x00,0x02,0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//` 64
  0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 65
  0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 66
  0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 67
  0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 68
  0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 69
  0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//f 70
  0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x6B,0x94,0x94,0x94,0x93,0x60,0x00,//g 71
  0x08,0xF8,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//h 72
  0x00,0x80,0x98,0x98,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//i 73
  0x00,0x00,0x00,0x80,0x98,0x98,0x00,0x00,0x00,0xC0,0x80,0x80,0x80,0x7F,0x00,0x00,//j 74
  0x08,0xF8,0x00,0x00,0x80,0x80,0x80,0x00,0x20,0x3F,0x24,0x02,0x2D,0x30,0x20,0x00,//k 75
  0x00,0x08,0x08,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//l 76
  0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x20,0x3F,0x20,0x00,0x3F,0x20,0x00,0x3F,//m 77
  0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x3F,0x21,0x00,0x00,0x20,0x3F,0x20,//n 78
  0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x20,0x20,0x20,0x20,0x1F,0x00,//o 79
  0x80,0x80,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0xFF,0xA1,0x20,0x20,0x11,0x0E,0x00,//p 80
  0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x0E,0x11,0x20,0x20,0xA0,0xFF,0x80,//q 81
  0x80,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x20,0x20,0x3F,0x21,0x20,0x00,0x01,0x00,//r 82
  0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x33,0x24,0x24,0x24,0x24,0x19,0x00,//s 83
  0x00,0x80,0x80,0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x1F,0x20,0x20,0x00,0x00,//t 84
  0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x1F,0x20,0x20,0x20,0x10,0x3F,0x20,//u 85
  0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x00,0x01,0x0E,0x30,0x08,0x06,0x01,0x00,//v 86
  0x80,0x80,0x00,0x80,0x00,0x80,0x80,0x80,0x0F,0x30,0x0C,0x03,0x0C,0x30,0x0F,0x00,//w 87
  0x00,0x80,0x80,0x00,0x80,0x80,0x80,0x00,0x00,0x20,0x31,0x2E,0x0E,0x31,0x20,0x00,//x 88
  0x80,0x80,0x80,0x00,0x00,0x80,0x80,0x80,0x80,0x81,0x8E,0x70,0x18,0x06,0x01,0x00,//y 89
  0x00,0x80,0x80,0x80,0x80,0x80,0x80,0x00,0x00,0x21,0x30,0x2C,0x22,0x21,0x30,0x00,//z 90
  0x00,0x00,0x00,0x00,0x80,0x7C,0x02,0x02,0x00,0x00,0x00,0x00,0x00,0x3F,0x40,0x40,//{ 91
  0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,//| 92
  0x00,0x02,0x02,0x7C,0x80,0x00,0x00,0x00,0x00,0x40,0x40,0x3F,0x00,0x00,0x00,0x00,//} 93
  0x00,0x06,0x01,0x01,0x02,0x02,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,//~ 94
};


const unsigned char bmp_data[]=
{
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x80,0x80,0x60,0x40,0x80,0x80,0xC0,0xE0,
0xE0,0x40,0x20,0x10,0x50,0xB0,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1C,0x1F,0x09,0x18,0x18,0x10,0x10,0x01,0x1F,0x1F,0x1F,0x1F,0x09,0x01,0x11,0x15,
0x10,0x11,0x11,0x1F,0x1D,0x1C,0x1F,0x17,0x12,0x18,0x10,0x10,0x11,0x18,0x1F,0x1F
};

BMP bmp=
{
	32,	//宽像素
	13,	//高像素
	bmp_data
};


#endif


使用时主函数只需要包含oled.h即可

i2c oled,STM32单片机,stm32,单片机,嵌入式硬件

工程分享链接:

链接:https://pan.baidu.com/s/1AfOpW1VWqa9YmE1eLtfwEg?pwd=2nac 
提取码:2nac文章来源地址https://www.toymoban.com/news/detail-714688.html

到了这里,关于STM32配合cubeMX硬件I2C驱动0.96寸OLED的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【STM32 CubeMX】I2C层次结构、I2C协议

    在STM32 CubeMX环境中,I2C(Inter-Integrated Circuit)是一种常用的串行通信协议,广泛应用于连接各种外设和传感器。理解I2C的层次结构、协议和硬件结构对于STM32微控制器的开发至关重要。通过STM32 CubeMX提供的图形化配置工具,我们能够更轻松地理解和配置I2C通信,同时深入了解

    2024年02月22日
    浏览(76)
  • STM32 HAL库 STM32CubeMX -- I2C(IIC)

    I2C 通讯协议(Inter - Integrated Circuit) 也就是IIC; 由Phiilps 公司开发的,它引脚少,硬件实现简单,可扩展性强,不需要USART、CAN 等通讯协议的外部收发设备。 I2C协议分为物理层和协议层。 物理层规定通讯系统中具有机械、电子功能部分的特性,确保原始数据在物理媒体的传输

    2023年04月16日
    浏览(49)
  • STM32硬件I2C通信外设

    本文主要介绍stm32自带的I2C通信外设,对比与软件模拟I2C,硬件I2C可以自动生成时序,时序的操作更加及时规范,可以实现更加高性能的IIC通信。 本文内容与I2C软件通信有诸多类似之处,I2C软件通信可见:https://blog.csdn.net/qq_53922901/article/details/136662006?spm=1001.2014.3001.5501 在8位指

    2024年04月08日
    浏览(95)
  • STM32基于CubeMX与HAL库的I2C应用

    1.1 物理层         I2C协议和摩托罗拉公司的SPI协议一样,是一种通讯协议。串行外围设备接口,是一种高速全双工的通信总线,是由 Phiilps 公司开发的。由于它引脚少,硬件实现简单,可扩展性强,不需要 USART、CAN 等通讯协议的外部收发设备,现在被广泛地使用在系统内

    2024年02月21日
    浏览(66)
  • 【STM32 CubeMX】I2C中断方式与DMA方式

    在STM32 CubeMX环境中,I2C(Inter-Integrated Circuit)通信协议的实现可以采用中断方式或DMA(Direct Memory Access)方式。中断方式通过触发中断来处理数据传输,而DMA方式则利用直接内存访问技术来实现数据传输,减轻了CPU的负担。在选择I2C通信方式时,开发者需要根据具体的应用需

    2024年02月20日
    浏览(39)
  • 【STM32】入门(七):I2C硬件控制方式

    之所以叫“I2C硬件控制方式”是与“软件控制方式”相对。I2C软件控制,就是写程序直接操作两个GPIO引脚,分别作为时钟线SCL和数据线SDA,按照I2C协议的时序要求,操作GPIO输入、输出、高电平、低电平。 听着就很复杂,好在STM32中有I2C的硬件实现,即通过简单的操作寄存器

    2023年04月08日
    浏览(46)
  • 【STM32CubeMX+HAL库】I2C详解+读写EEPROM

    在之前的标准库中,STM32的硬件IIC非常复杂,更重要的是它并不稳定,所以都不推荐使用。但是在我们的HAL库中,对硬件IIC做了全新的优化,使得之前软件IIC几百行代码,在HAL库中,只需要寥寥几行就可以完成 那么这篇文章将带你去感受下它的优异之处。 通过本篇博客您将

    2024年02月03日
    浏览(53)
  • STM32 HAL FreeRTOS 硬件I2C 使用

    因为某个项目想要颜色识别,去识别球的颜色,但是又不想多来个摄像头,所以想尝试一下颜色传感器的方案。但是经过尝试,HAL库生成的 FreeRTOS 硬件 I2C 读写一直在报错。 刚好手头上有九轴陀螺仪的例程代码。最后用FreeRTOS 硬件 I2C 读取数据。 这里提到了阻塞式 HAL 函数(

    2024年02月20日
    浏览(49)
  • STM32F407系列硬件I2C笔记

    STM32F407系列有3个硬件I2C: I2C1:该接口位于GPIOB引脚上,包括PB6(I2C1_SCL)和PB7(I2C1_SDA)。 I2C2:该接口位于GPIOB引脚上,包括PB10(I2C2_SCL)和PB11(I2C2_SDA)。 I2C3:该接口位于GPIOA和GPIOC引脚上,包括PA8(I2C3_SCL)和PC9(I2C3_SDA)。   硬件I2C的速度比软件I2C更快,硬件I2C通常可以

    2024年02月04日
    浏览(45)
  • 【STM32】STM32学习笔记-硬件I2C读写MPU6050(35)

    I2C(Inter-Integrated Circuit)总线是一种由NXP(原PHILIPS)公司开发的两线式串行总线,用于连接微控制器及其外围设备。多用于主控制器和从器件间的主从通信,在小数据量场合使用,传输距离短,任意时刻只能有一个主机等特性。 串行的 8 位双向数据传输位速率在标准模式下可

    2024年01月25日
    浏览(57)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包