Skip to content

Commit

Permalink
move pin set-up out of ili9341Init
Browse files Browse the repository at this point in the history
  • Loading branch information
phoddie committed Dec 30, 2019
1 parent e723e0f commit e38e1c1
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions modules/drivers/ili9341/modIli9341.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e38e1c1

Please sign in to comment.