- scr_interface_create(SCREEN_IFACE_I2C , &iface_cfg, &iface_drv);
- interface_i2c->interface_drv.type = type;
- interface_i2c->interface_drv.write_cmd = i2c_lcd_write_cmd;
- interface_i2c->interface_drv.write_data = i2c_lcd_write_data;
- interface_i2c->interface_drv.write = i2c_lcd_write;
- interface_i2c->interface_drv.read = i2c_lcd_read;
- interface_i2c->interface_drv.bus_acquire = i2c_lcd_acquire;
- interface_i2c->interface_drv.bus_release = i2c_lcd_release;
配置lcd初始化参数时
- lcd_cfg.interface_drv = iface_drv
- esp_err_t lcd_ssd1306_init(const scr_controller_config_t *lcd_conf)
- {
- //////////////////////////////////////////////
- g_lcd_handle.interface_drv = lcd_conf->interface_drv; //这个时候传递给了 g_lcd_handle
- ///////////////////////////////////////////////////
- LCD_WRITE_CMD(0xAE); //--turn off oled panel
- ////////////////////////////////////////////////
static inline esp_err_t LCD_WRITE_CMD(uint8_t cmd)
{
return LCD_WRITE_COMMAND((uint8_t*)&cmd, 1);
}
在interface_drv_def.h文件中,把LCD_WRITE_CMD指向了LCD_WRITE_COMMAND
而LCD_WRITE_COMMAND 指向的是 g_lcd_handle.interface_drv->write_command
根据前面的参数我认为,LCD_WRITE_COMMAND 应该指向。 g_lcd_handle.interface_drv->write_cmd
write_command 前面根本就没有赋值,所以一调用就跑飞。(这个地方解释起来真是自己都觉得很绕,不知道是否说清楚了)
不知道我的理解是否正确。还是我理解存在问题,还请大家指点