summaryrefslogtreecommitdiffstats
path: root/keyboards/ergodox/infinity
diff options
context:
space:
mode:
authorFred Sundvik <fsundvik@gmail.com>2017-04-07 10:51:53 +0300
committerFred Sundvik <fsundvik@gmail.com>2017-04-09 18:34:59 +0300
commit3994fb1e79615af849aa03378293831f59c9b259 (patch)
tree7b874c44eb948bfeb0904a4d74272b3495d71cb1 /keyboards/ergodox/infinity
parentb7041d06aef4dcf2f2a47504a699e538cfb1d9ac (diff)
Yet another try to fix the LCD corruption
It turns out that the ChibiOS K20 SPI driver doesn't handle the chip select, so it needs to be done manually. Acquiring the bus is not enough since the pin was in the wrong mode. This is now fixed. Also increase the frequency of the SPI from around 200kHz to nearly 20 Mhz.
Diffstat (limited to 'keyboards/ergodox/infinity')
-rw-r--r--keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/board_ST7565.h44
1 files changed, 22 insertions, 22 deletions
diff --git a/keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/board_ST7565.h b/keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/board_ST7565.h
index c2092b5e8d..e8c17e6e33 100644
--- a/keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/board_ST7565.h
+++ b/keyboards/ergodox/infinity/drivers/gdisp/st7565ergodox/board_ST7565.h
@@ -45,15 +45,28 @@ static const SPIConfig spi1config = {
.sspad=ST7565_SS_PIN,
// SPI initialization data.
.tar0 =
- SPIx_CTARn_FMSZ(7)
- | SPIx_CTARn_ASC(7)
- | SPIx_CTARn_DT(7)
- | SPIx_CTARn_CSSCK(7)
- | SPIx_CTARn_PBR(0)
- | SPIx_CTARn_BR(7)
- //SPI_CR1_BR_0
+ SPIx_CTARn_FMSZ(7) // Frame size = 8 bytes
+ | SPIx_CTARn_ASC(1) // After SCK Delay Scaler (min 50 ns) = 55.56ns
+ | SPIx_CTARn_DT(0) // Delay After Transfer Scaler (no minimum)= 27.78ns
+ | SPIx_CTARn_CSSCK(0) // PCS to SCK Delay Scaler (min 20 ns) = 27.78ns
+ | SPIx_CTARn_PBR(0) // Baud Rate Prescaler = 2
+ | SPIx_CTARn_BR(0) // Baud rate (min 50ns) = 55.56ns
};
+static GFXINLINE void acquire_bus(GDisplay *g) {
+ (void) g;
+ // Only the LCD is using the SPI bus, so no need to acquire
+ // spiAcquireBus(&SPID1);
+ spiSelect(&SPID1);
+}
+
+static GFXINLINE void release_bus(GDisplay *g) {
+ (void) g;
+ // Only the LCD is using the SPI bus, so no need to release
+ //spiReleaseBus(&SPID1);
+ spiUnselect(&SPID1);
+}
+
static GFXINLINE void init_board(GDisplay *g) {
(void) g;
palSetPadModeNamed(A0, PAL_MODE_OUTPUT_PUSHPULL);
@@ -62,10 +75,11 @@ static GFXINLINE void init_board(GDisplay *g) {
palSetPad(ST7565_GPIOPORT, ST7565_RST_PIN);
palSetPadModeRaw(MOSI, ST7565_SPI_MODE);
palSetPadModeRaw(SLCK, ST7565_SPI_MODE);
- palSetPadModeRaw(SS, ST7565_SPI_MODE);
+ palSetPadModeRaw(SS, PAL_MODE_OUTPUT_PUSHPULL);
spiInit();
spiStart(&SPID1, &spi1config);
+ release_bus(g);
}
static GFXINLINE void post_init_board(GDisplay *g) {
@@ -82,20 +96,6 @@ static GFXINLINE void setpin_reset(GDisplay *g, bool_t state) {
}
}
-static GFXINLINE void acquire_bus(GDisplay *g) {
- (void) g;
- // Only the LCD is using the SPI bus, so no need to acquire
- // spiAcquireBus(&SPID1);
- spiSelect(&SPID1);
-}
-
-static GFXINLINE void release_bus(GDisplay *g) {
- (void) g;
- // Only the LCD is using the SPI bus, so no need to release
- //spiReleaseBus(&SPID1);
- spiUnselect(&SPID1);
-}
-
static GFXINLINE void enter_data_mode(GDisplay *g) {
palSetPad(ST7565_GPIOPORT, ST7565_A0_PIN);
}