The code is as follows, if you have a strong reading ability, just look at the code, and it can be used after testing.
Link: https://pan.baidu.com/s/1IRkNfHerEdfChoULzhUsQw?pwd=8888
Extraction code: 8888
1. Hardware IIC
see configuration
Core code:
you are.c
HAL_StatusTypeDef OLED_WR_Byte(u8 dat,u8 mode)
{
HAL_StatusTypeDef i;
if(mode)
{
i=HAL_I2C_Mem_Write(&hi2c1 ,0x78,0x40,I2C_MEMADD_SIZE_8BIT,&dat,1,0x100);
}
else
{
i=HAL_I2C_Mem_Write(&hi2c1 ,0x78,0x00,I2C_MEMADD_SIZE_8BIT,&dat,1,0x100);
}
return i;
}
void OLED_Refresh(void)
{
u8 i=0,n;
for(i=0;i<8;i++)
{
OLED_WR_Byte(0xb0+i,OLED_CMD);
OLED_WR_Byte(0x00,OLED_CMD);
OLED_WR_Byte(0x10,OLED_CMD);
for(n=0;n<128;n++)
{
OLED_WR_Byte(OLED_GRAM[n][i],OLED_DATA);
}
}
}
Other parts are the same as the software IIC.
2. DS1302 clock, DHT11 temperature and humidity
(It is relatively simple to see the source code)