Allow MCU-specific overrides for SPI flags. (#17650)
parent
f9724dfa67
commit
dfff040433
|
@ -84,6 +84,8 @@
|
||||||
# define PAL_OUTPUT_TYPE_PUSHPULL PAL_WB32_OTYPE_PUSHPULL
|
# define PAL_OUTPUT_TYPE_PUSHPULL PAL_WB32_OTYPE_PUSHPULL
|
||||||
# define PAL_OUTPUT_SPEED_HIGHEST PAL_WB32_OSPEED_HIGH
|
# define PAL_OUTPUT_SPEED_HIGHEST PAL_WB32_OSPEED_HIGH
|
||||||
# define PAL_PUPDR_FLOATING PAL_WB32_PUPDR_FLOATING
|
# 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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -121,3 +123,16 @@
|
||||||
#if !defined(REALTIME_COUNTER_CLOCK)
|
#if !defined(REALTIME_COUNTER_CLOCK)
|
||||||
# define REALTIME_COUNTER_CLOCK CPU_CLOCK
|
# define REALTIME_COUNTER_CLOCK CPU_CLOCK
|
||||||
#endif
|
#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
|
||||||
|
|
|
@ -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_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);
|
palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), SPI_MISO_PAL_MODE);
|
||||||
#else
|
#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_SCK_PIN), PAL_PAD(SPI_SCK_PIN), SPI_SCK_FLAGS);
|
||||||
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_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), SPI_MOSI_FLAGS);
|
||||||
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_MISO_PIN), PAL_PAD(SPI_MISO_PIN), SPI_MISO_FLAGS);
|
||||||
#endif
|
#endif
|
||||||
spiUnselect(&SPI_DRIVER);
|
spiUnselect(&SPI_DRIVER);
|
||||||
spiStop(&SPI_DRIVER);
|
spiStop(&SPI_DRIVER);
|
||||||
|
|
Loading…
Reference in New Issue