From e38e1c1b18ae27889f046db1c67df8e3caf0b9f7 Mon Sep 17 00:00:00 2001 From: Peter Hoddie Date: Mon, 30 Dec 2019 12:53:28 -0800 Subject: [PATCH] move pin set-up out of ili9341Init --- modules/drivers/ili9341/modIli9341.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/modules/drivers/ili9341/modIli9341.c b/modules/drivers/ili9341/modIli9341.c index 461c3d9965..e3df2aed1d 100644 --- a/modules/drivers/ili9341/modIli9341.c +++ b/modules/drivers/ili9341/modIli9341.c @@ -207,7 +207,20 @@ void xs_ILI9341(xsMachine *the) sd->dispatch = (PixelsOutDispatch)&gPixelsOutDispatch; + SCREEN_CS_INIT; + SCREEN_DC_INIT; + modSPIInit(&sd->spiConfig); + +#ifdef MODDEF_ILI9341_RST_PIN + SCREEN_RST_INIT; +#endif + ili9341Init(sd); + +#ifdef MODDEF_ILI9341_BACKLIGHT_PIN + modGPIOInit(&sd->backlight, MODDEF_ILI9341_BACKLIGHT_PORT, MODDEF_ILI9341_BACKLIGHT_PIN, kModGPIOOutput); + modGPIOWrite(&sd->backlight, MODDEF_ILI9341_BACKLIGHT_OFF); +#endif } void xs_ILI9341_begin(xsMachine *the) @@ -453,21 +466,12 @@ void ili9341Init(spiDisplay sd) uint8_t data[16] __attribute__((aligned(4))); const uint8_t *cmds; - SCREEN_CS_INIT; - SCREEN_DC_INIT; - modSPIInit(&sd->spiConfig); - #ifdef MODDEF_ILI9341_RST_PIN - SCREEN_RST_INIT; SCREEN_RST_ACTIVE; modDelayMilliseconds(10); SCREEN_RST_DEACTIVE; modDelayMilliseconds(1); #endif -#ifdef MODDEF_ILI9341_BACKLIGHT_PIN - modGPIOInit(&sd->backlight, MODDEF_ILI9341_BACKLIGHT_PORT, MODDEF_ILI9341_BACKLIGHT_PIN, kModGPIOOutput); - modGPIOWrite(&sd->backlight, MODDEF_ILI9341_BACKLIGHT_OFF); -#endif cmds = gInit; while (true) {