drivers: ssd1306: Support GPIO reset function
If dts has reset-gpios information, reset it. Signed-off-by: Kwon Tae-young <tykwon@m2i.co.kr>
This commit is contained in:
parent
0122bacd2c
commit
e0a8990ea7
2 changed files with 22 additions and 0 deletions
|
@ -47,6 +47,7 @@ LOG_MODULE_REGISTER(ssd1306);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ssd1306_data {
|
struct ssd1306_data {
|
||||||
|
struct device *reset;
|
||||||
struct device *i2c;
|
struct device *i2c;
|
||||||
u8_t contrast;
|
u8_t contrast;
|
||||||
u8_t scan_mode;
|
u8_t scan_mode;
|
||||||
|
@ -366,6 +367,12 @@ static int ssd1306_init_device(struct device *dev)
|
||||||
SSD1306_SET_NORMAL_DISPLAY,
|
SSD1306_SET_NORMAL_DISPLAY,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef DT_SOLOMON_SSD1306FB_0_RESET_GPIOS_CONTROLLER
|
||||||
|
gpio_pin_write(driver->reset, DT_SOLOMON_SSD1306FB_0_RESET_GPIOS_PIN, 0);
|
||||||
|
k_sleep(SSD1306_RESET_DELAY);
|
||||||
|
gpio_pin_write(driver->reset, DT_SOLOMON_SSD1306FB_0_RESET_GPIOS_PIN, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Turn display off */
|
/* Turn display off */
|
||||||
if (ssd1306_reg_write(driver, SSD1306_CONTROL_LAST_BYTE_CMD,
|
if (ssd1306_reg_write(driver, SSD1306_CONTROL_LAST_BYTE_CMD,
|
||||||
SSD1306_DISPLAY_OFF)) {
|
SSD1306_DISPLAY_OFF)) {
|
||||||
|
@ -415,6 +422,18 @@ static int ssd1306_init(struct device *dev)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DT_SOLOMON_SSD1306FB_0_RESET_GPIOS_CONTROLLER
|
||||||
|
driver->reset = device_get_binding(DT_SOLOMON_SSD1306FB_0_RESET_GPIOS_CONTROLLER);
|
||||||
|
if (driver->reset == NULL) {
|
||||||
|
LOG_ERR("Failed to get pointer to %s device!",
|
||||||
|
DT_SOLOMON_SSD1306FB_0_RESET_GPIOS_CONTROLLER);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
gpio_pin_configure(driver->reset, DT_SOLOMON_SSD1306FB_0_RESET_GPIOS_PIN,
|
||||||
|
GPIO_DIR_OUT);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (ssd1306_init_device(dev)) {
|
if (ssd1306_init_device(dev)) {
|
||||||
LOG_ERR("Failed to initialize device!");
|
LOG_ERR("Failed to initialize device!");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
|
@ -106,4 +106,7 @@
|
||||||
#define SSD1306_READ_MODIFY_WRITE_START 0xe0
|
#define SSD1306_READ_MODIFY_WRITE_START 0xe0
|
||||||
#define SSD1306_READ_MODIFY_WRITE_END 0xee
|
#define SSD1306_READ_MODIFY_WRITE_END 0xee
|
||||||
|
|
||||||
|
/* time constants in ms */
|
||||||
|
#define SSD1306_RESET_DELAY 1
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue