drivers: ssd16xx: convert to new GPIO API
Convert SSD16XX sensor driver to new GPIO API. Signed-off-by: Johann Fischer <j.fischer@phytec.de>
This commit is contained in:
parent
8399224271
commit
2748a23c61
7 changed files with 46 additions and 28 deletions
|
@ -67,9 +67,9 @@
|
|||
height = <120>;
|
||||
pp-width-bits = <8>;
|
||||
pp-height-bits = <8>;
|
||||
reset-gpios = <&gpio0 15 0>;
|
||||
dc-gpios = <&gpio0 16 0>;
|
||||
busy-gpios = <&gpio0 14 0>;
|
||||
reset-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
|
||||
dc-gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
|
||||
busy-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
|
||||
gdv = [10 0a];
|
||||
sdv = [19];
|
||||
vcom = <0xa8>;
|
||||
|
|
|
@ -43,9 +43,9 @@
|
|||
height = <120>;
|
||||
pp-width-bits = <8>;
|
||||
pp-height-bits = <16>;
|
||||
reset-gpios = <&gpio0 15 0>;
|
||||
dc-gpios = <&gpio0 16 0>;
|
||||
busy-gpios = <&gpio0 14 0>;
|
||||
reset-gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
|
||||
dc-gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
|
||||
busy-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
|
||||
gdv = [15];
|
||||
sdv = [41 a8 32];
|
||||
vcom = <0x26>;
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
height = <120>;
|
||||
pp-width-bits = <8>;
|
||||
pp-height-bits = <8>;
|
||||
dc-gpios = <&arduino_header 15 0>; /* D9 */
|
||||
reset-gpios = <&arduino_header 14 0>; /* D8 */
|
||||
busy-gpios = <&arduino_header 13 0>; /* D7 */
|
||||
dc-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */
|
||||
reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>; /* D8 */
|
||||
busy-gpios = <&arduino_header 13 GPIO_ACTIVE_HIGH>; /* D7 */
|
||||
gdv = [10 0a];
|
||||
sdv = [19];
|
||||
vcom = <0xa8>;
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
height = <120>;
|
||||
pp-width-bits = <8>;
|
||||
pp-height-bits = <16>;
|
||||
dc-gpios = <&arduino_header 15 0>; /* D9 */
|
||||
reset-gpios = <&arduino_header 14 0>; /* D8 */
|
||||
busy-gpios = <&arduino_header 13 0>; /* D7 */
|
||||
dc-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */
|
||||
reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>; /* D8 */
|
||||
busy-gpios = <&arduino_header 13 GPIO_ACTIVE_HIGH>; /* D7 */
|
||||
gdv = [15];
|
||||
sdv = [41 a8 32];
|
||||
vcom = <0x26>;
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
height = <128>;
|
||||
pp-width-bits = <16>;
|
||||
pp-height-bits = <16>;
|
||||
dc-gpios = <&arduino_header 15 0>; /* D9 */
|
||||
reset-gpios = <&arduino_header 14 0>; /* D8 */
|
||||
busy-gpios = <&arduino_header 13 0>; /* D7 */
|
||||
dc-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */
|
||||
reset-gpios = <&arduino_header 14 GPIO_ACTIVE_LOW>; /* D8 */
|
||||
busy-gpios = <&arduino_header 13 GPIO_ACTIVE_HIGH>; /* D7 */
|
||||
gdv = [16];
|
||||
sdv = [0a];
|
||||
vcom = <0xa8>;
|
||||
|
|
|
@ -26,6 +26,7 @@ LOG_MODULE_REGISTER(ssd16xx);
|
|||
#define SSD16XX_SPI_FREQ DT_INST_0_SOLOMON_SSD16XXFB_SPI_MAX_FREQUENCY
|
||||
#define SSD16XX_BUS_NAME DT_INST_0_SOLOMON_SSD16XXFB_BUS_NAME
|
||||
#define SSD16XX_DC_PIN DT_INST_0_SOLOMON_SSD16XXFB_DC_GPIOS_PIN
|
||||
#define SSD16XX_DC_FLAGS DT_INST_0_SOLOMON_SSD16XXFB_DC_GPIOS_FLAGS
|
||||
#define SSD16XX_DC_CNTRL DT_INST_0_SOLOMON_SSD16XXFB_DC_GPIOS_CONTROLLER
|
||||
#define SSD16XX_CS_PIN DT_INST_0_SOLOMON_SSD16XXFB_CS_GPIOS_PIN
|
||||
#if defined(DT_INST_0_SOLOMON_SSD16XXFB_CS_GPIOS_CONTROLLER)
|
||||
|
@ -33,8 +34,10 @@ LOG_MODULE_REGISTER(ssd16xx);
|
|||
#endif
|
||||
#define SSD16XX_BUSY_PIN DT_INST_0_SOLOMON_SSD16XXFB_BUSY_GPIOS_PIN
|
||||
#define SSD16XX_BUSY_CNTRL DT_INST_0_SOLOMON_SSD16XXFB_BUSY_GPIOS_CONTROLLER
|
||||
#define SSD16XX_BUSY_FLAGS DT_INST_0_SOLOMON_SSD16XXFB_BUSY_GPIOS_FLAGS
|
||||
#define SSD16XX_RESET_PIN DT_INST_0_SOLOMON_SSD16XXFB_RESET_GPIOS_PIN
|
||||
#define SSD16XX_RESET_CNTRL DT_INST_0_SOLOMON_SSD16XXFB_RESET_GPIOS_CONTROLLER
|
||||
#define SSD16XX_RESET_FLAGS DT_INST_0_SOLOMON_SSD16XXFB_RESET_GPIOS_FLAGS
|
||||
|
||||
#define EPD_PANEL_WIDTH DT_INST_0_SOLOMON_SSD16XXFB_WIDTH
|
||||
#define EPD_PANEL_HEIGHT DT_INST_0_SOLOMON_SSD16XXFB_HEIGHT
|
||||
|
@ -85,7 +88,7 @@ static inline int ssd16xx_write_cmd(struct ssd16xx_data *driver,
|
|||
struct spi_buf buf = {.buf = &cmd, .len = sizeof(cmd)};
|
||||
struct spi_buf_set buf_set = {.buffers = &buf, .count = 1};
|
||||
|
||||
gpio_pin_write(driver->dc, SSD16XX_DC_PIN, 0);
|
||||
gpio_pin_set(driver->dc, SSD16XX_DC_PIN, 1);
|
||||
err = spi_write(driver->spi_dev, &driver->spi_config, &buf_set);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
|
@ -94,7 +97,7 @@ static inline int ssd16xx_write_cmd(struct ssd16xx_data *driver,
|
|||
if (data != NULL) {
|
||||
buf.buf = data;
|
||||
buf.len = len;
|
||||
gpio_pin_write(driver->dc, SSD16XX_DC_PIN, 1);
|
||||
gpio_pin_set(driver->dc, SSD16XX_DC_PIN, 0);
|
||||
err = spi_write(driver->spi_dev, &driver->spi_config, &buf_set);
|
||||
if (err < 0) {
|
||||
return err;
|
||||
|
@ -106,12 +109,12 @@ static inline int ssd16xx_write_cmd(struct ssd16xx_data *driver,
|
|||
|
||||
static inline void ssd16xx_busy_wait(struct ssd16xx_data *driver)
|
||||
{
|
||||
u32_t val = 0U;
|
||||
int pin = gpio_pin_get(driver->busy, SSD16XX_BUSY_PIN);
|
||||
|
||||
gpio_pin_read(driver->busy, SSD16XX_BUSY_PIN, &val);
|
||||
while (val) {
|
||||
while (pin > 0) {
|
||||
__ASSERT(pin >= 0, "Failed to get pin level");
|
||||
k_sleep(SSD16XX_BUSY_DELAY);
|
||||
gpio_pin_read(driver->busy, SSD16XX_BUSY_PIN, &val);
|
||||
pin = gpio_pin_get(driver->busy, SSD16XX_BUSY_PIN);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -413,7 +416,7 @@ static int ssd16xx_clear_and_write_buffer(struct device *dev, u8_t ram_cmd,
|
|||
return err;
|
||||
}
|
||||
|
||||
gpio_pin_write(driver->dc, SSD16XX_DC_PIN, 0);
|
||||
gpio_pin_set(driver->dc, SSD16XX_DC_PIN, 1);
|
||||
|
||||
sbuf.buf = &ram_cmd;
|
||||
sbuf.len = 1;
|
||||
|
@ -422,7 +425,7 @@ static int ssd16xx_clear_and_write_buffer(struct device *dev, u8_t ram_cmd,
|
|||
return err;
|
||||
}
|
||||
|
||||
gpio_pin_write(driver->dc, SSD16XX_DC_PIN, 1);
|
||||
gpio_pin_set(driver->dc, SSD16XX_DC_PIN, 0);
|
||||
|
||||
memset(clear_page, 0xff, sizeof(clear_page));
|
||||
sbuf.buf = clear_page;
|
||||
|
@ -450,9 +453,9 @@ static int ssd16xx_controller_init(struct device *dev)
|
|||
|
||||
LOG_DBG("");
|
||||
|
||||
gpio_pin_write(driver->reset, SSD16XX_RESET_PIN, 0);
|
||||
gpio_pin_set(driver->reset, SSD16XX_RESET_PIN, 1);
|
||||
k_sleep(SSD16XX_RESET_DELAY);
|
||||
gpio_pin_write(driver->reset, SSD16XX_RESET_PIN, 1);
|
||||
gpio_pin_set(driver->reset, SSD16XX_RESET_PIN, 0);
|
||||
k_sleep(SSD16XX_RESET_DELAY);
|
||||
ssd16xx_busy_wait(driver);
|
||||
|
||||
|
@ -571,7 +574,7 @@ static int ssd16xx_init(struct device *dev)
|
|||
}
|
||||
|
||||
gpio_pin_configure(driver->reset, SSD16XX_RESET_PIN,
|
||||
GPIO_DIR_OUT);
|
||||
GPIO_OUTPUT_INACTIVE | SSD16XX_RESET_FLAGS);
|
||||
|
||||
driver->dc = device_get_binding(SSD16XX_DC_CNTRL);
|
||||
if (driver->dc == NULL) {
|
||||
|
@ -580,7 +583,7 @@ static int ssd16xx_init(struct device *dev)
|
|||
}
|
||||
|
||||
gpio_pin_configure(driver->dc, SSD16XX_DC_PIN,
|
||||
GPIO_DIR_OUT);
|
||||
GPIO_OUTPUT_INACTIVE | SSD16XX_DC_FLAGS);
|
||||
|
||||
driver->busy = device_get_binding(SSD16XX_BUSY_CNTRL);
|
||||
if (driver->busy == NULL) {
|
||||
|
@ -589,7 +592,7 @@ static int ssd16xx_init(struct device *dev)
|
|||
}
|
||||
|
||||
gpio_pin_configure(driver->busy, SSD16XX_BUSY_PIN,
|
||||
GPIO_DIR_IN);
|
||||
GPIO_INPUT | SSD16XX_BUSY_FLAGS);
|
||||
|
||||
#if defined(SSD16XX_CS_CNTRL)
|
||||
driver->cs_ctrl.gpio_dev = device_get_binding(SSD16XX_CS_CNTRL);
|
||||
|
|
|
@ -61,14 +61,29 @@ properties:
|
|||
reset-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: RESET pin.
|
||||
|
||||
The RESET pin of SSD16XX is active low.
|
||||
If connected directly the MCU pin should be configured
|
||||
as active low.
|
||||
|
||||
dc-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: DC pin.
|
||||
|
||||
The DC pin of SSD16XX is active low (transmission command byte).
|
||||
If connected directly the MCU pin should be configured
|
||||
as active low.
|
||||
|
||||
busy-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: BUSY pin.
|
||||
|
||||
The BUSY pin of SSD16XX is active high.
|
||||
If connected directly the MCU pin should be configured
|
||||
as active high.
|
||||
|
||||
lut-initial:
|
||||
type: uint8-array
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue