Code: Select all
void writeLCDCommand(uint8_t c)
{ palClearPad(GPIOA,8);
chSysLockFromIsr();
spiSelectI(&SPID2);
// size is data size and samples are the samples pointer
spiStartSendI(&SPID2, sizeof(c), &c);
chSysUnlockFromIsr();
}
void writeLCDData(uint8_t c)
{ palSetPad(GPIOA,8);
chSysLockFromIsr();
spiSelectI(&SPID2);
// size is data size and samples are the samples pointer
spiStartSendI(&SPID2, sizeof(c), &c);
chSysUnlockFromIsr();
}
They are identical other than what palSetPad is being set to. In my main function, I am setting up this port as follows:
Code: Select all
palSetPadMode(GPIOA, 8, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
Not sure if I need the second flag or not, but I also set up GPIOA 15 to control the _RST line of the LCD, and it works no problem.
When I run my code, here are two sections:
Code: Select all
// Software Reset
writeLCDCommand(ST7735_SWRESET);
chThdSleepMilliseconds(50);
writeLCDCommand(ST7735_SLPOUT);
chThdSleepMilliseconds(500);
writeLCDCommand(ST7735_COLMOD); // set color mode
writeLCDData(0x05); // 16-bit color
chThdSleepMilliseconds(10);
palSetPad(GPIOD, GPIOD_LED_RED); //Red
writeLCDCommand runs and passes through, originally I had the RED LED turn on after the first part of the code to make sure. However, in the second part writeLCDData does not return. If I comment out that line, it of course passes through and turns on the RED LED.
Clearly I am missing something here. Given how similar both commands are internally, I am at a loss.