diff options
author | Nick Brassel <nick@tzarc.org> | 2022-07-13 14:42:24 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-13 14:42:24 +1000 |
commit | dfff040433a2cabd4a1047bbeb9eb72b736bba2e (patch) | |
tree | df6d95fefbc4e9ce387e88a3515a3d68c8d71bfa /platforms | |
parent | f9724dfa67dc4651398a08589b38f873d1f594f2 (diff) | |
download | qmk_firmware-dfff040433a2cabd4a1047bbeb9eb72b736bba2e.tar.gz qmk_firmware-dfff040433a2cabd4a1047bbeb9eb72b736bba2e.zip |
Allow MCU-specific overrides for SPI flags. (#17650)
Diffstat (limited to 'platforms')
-rw-r--r-- | platforms/chibios/chibios_config.h | 15 | ||||
-rw-r--r-- | platforms/chibios/drivers/spi_master.c | 6 |
2 files changed, 18 insertions, 3 deletions
diff --git a/platforms/chibios/chibios_config.h b/platforms/chibios/chibios_config.h index c7a3a98fb0..8dcc23727f 100644 --- a/platforms/chibios/chibios_config.h +++ b/platforms/chibios/chibios_config.h @@ -84,6 +84,8 @@ # define PAL_OUTPUT_TYPE_PUSHPULL PAL_WB32_OTYPE_PUSHPULL # define PAL_OUTPUT_SPEED_HIGHEST PAL_WB32_OSPEED_HIGH # define PAL_PUPDR_FLOATING PAL_WB32_PUPDR_FLOATING + +# define SPI_SCK_FLAGS PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST | PAL_WB32_CURRENT_LEVEL3 # endif #endif @@ -121,3 +123,16 @@ #if !defined(REALTIME_COUNTER_CLOCK) # define REALTIME_COUNTER_CLOCK CPU_CLOCK #endif + +// SPI Fallbacks +#ifndef SPI_SCK_FLAGS +# define SPI_SCK_FLAGS PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST +#endif + +#ifndef SPI_MOSI_FLAGS +# define SPI_MOSI_FLAGS PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST +#endif + +#ifndef SPI_MISO_FLAGS +# define SPI_MISO_FLAGS PAL_MODE_ALTERNATE(SPI_MISO_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST +#endif diff --git a/platforms/chibios/drivers/spi_master.c b/platforms/chibios/drivers/spi_master.c index 223d8a403e..de308229ef 100644 --- a/platforms/chibios/drivers/spi_master.c +++ b/platforms/chibios/drivers/spi_master.c @@ -42,9 +42,9 @@ __attribute__((weak)) void spi_init(void) { palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), SPI_MOSI_PAL_MODE); palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), SPI_MISO_PAL_MODE); #else - palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST); - palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST); - palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_MODE_ALTERNATE(SPI_MISO_PAL_MODE) | PAL_OUTPUT_TYPE_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST); + palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), SPI_SCK_FLAGS); + palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), SPI_MOSI_FLAGS); + palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), SPI_MISO_FLAGS); #endif spiUnselect(&SPI_DRIVER); spiStop(&SPI_DRIVER); |