Skip to content

Commit

Permalink
HT32: update spi driver
Browse files Browse the repository at this point in the history
  • Loading branch information
bwisn committed Sep 15, 2021
1 parent 9d103ca commit 37b6928
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 0 additions & 6 deletions platforms/chibios/drivers/spi_master.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,9 @@ __attribute__((weak)) void spi_init(void) {

chThdSleepMilliseconds(10);
#if defined(USE_GPIOV1)
# if defined(HT32)
palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_HT32_MODE_AF(SPI_SCK_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_HT32_MODE_AF(SPI_MOSI_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_HT32_MODE_AF(SPI_MISO_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL);
# else
palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), SPI_SCK_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);
# endif
#else
palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST);
palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL | PAL_OUTPUT_SPEED_HIGHEST);
Expand Down
8 changes: 7 additions & 1 deletion tmk_core/common/chibios/chibios_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@
# define USE_I2CV1_CONTRIB // for some reason a bunch of ChibiOS-Contrib boards only have clock_speed
# define USE_GPIOV1
# endif
#endif
#endif

#if defined(HT32)
# define PAL_MODE_ALTERNATE PAL_HT32_MODE_AF
# define PAL_OUTPUT_SPEED_HIGHEST 0
# define STM32_SYSCLK HT32_CK_SYS_FREQUENCY
#endif

0 comments on commit 37b6928

Please sign in to comment.