From: Cyprien Laplace Date: Sat, 24 Jun 2017 20:47:22 +0000 (-0400) Subject: oled: add support for SPI ssd130x displays X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=5b86e83be287bbe3efff8a8786c189b7552f9949;p=soft%2Flpc122x%2Fexamples oled: add support for SPI ssd130x displays For I2C displays, the bus_type needs to be added: + .bus_type = SSD130x_BUS_I2C, .address = DISPLAY_ADDR, .bus_num = I2C0, To use a SPI display: 1/ add the SSP include: #include "drivers/ssp.h" 2/ add the SPI pins to the init table: /* SPI : Display */ { LPC_SSP0_SCLK_PIO_0_14, LPC_IO_DIGITAL }, { LPC_SSP0_MISO_PIO_0_16, LPC_IO_DIGITAL }, { LPC_SSP0_MOSI_PIO_0_17, LPC_IO_DIGITAL }, 3/ update the oled_display conf: .bus_type = SSD130x_BUS_SPI, .bus_num = SSP_BUS_0, .gpio_dc = LPC_GPIO_0_0, .gpio_cs = LPC_GPIO_1_0, .gpio_rst = LPC_GPIO_0_31, 4/ initialize the SPI bus: ssp_master_on(SSP_BUS_0, LPC_SSP_FRAME_SPI, 8, 8*1000*1000); --- diff --git a/oled/main.c b/oled/main.c index c7debef..99da7c2 100644 --- a/oled/main.c +++ b/oled/main.c @@ -101,6 +101,7 @@ void fault_info(const char* name, uint32_t len) #define DISPLAY_ADDR 0x78 static uint8_t gddram[ 4 + GDDRAM_SIZE ]; struct oled_display display = { + .bus_type = SSD130x_BUS_I2C, .address = DISPLAY_ADDR, .bus_num = I2C0, .charge_pump = SSD130x_EXT_VCC, /* Alt is SSD130x_INTERNAL_PUMP */