以下是STM32F103C8T6通过OLED初始化的C代码示例,需要额外设置I2C总线。
``` #include "stm32f10x.h" #include "i2c.h"
#define OLED_I2C_ADDRESS 0x78
void OLED_Init(void) { uint8_t cmd[2];
I2C_Start();
I2C_WriteByte(OLED_I2C_ADDRESS<<1);
I2C_WriteByte(0x00);
I2C_WriteByte(0xAE);
I2C_Stop();
I2C_Start();
I2C_WriteByte(OLED_I2C_ADDRESS<<1);
I2C_WriteByte(0x00);