diff options
author | bwisn <56162793+bwisn@users.noreply.github.com> | 2021-10-18 07:17:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-18 16:17:29 +1100 |
commit | 7e3ff206b8600265ea086040b397f1a600c4a7f3 (patch) | |
tree | 0af0d0f17c01eeae7b2d30eb7a82904928def9a2 /platforms | |
parent | 1a63b24548cf0891621e54772320a5fec04186cb (diff) | |
download | qmk_firmware-7e3ff206b8600265ea086040b397f1a600c4a7f3.tar.gz qmk_firmware-7e3ff206b8600265ea086040b397f1a600c4a7f3.zip |
Add HT32 support to core (#14388)
* tmk_core: temporary fix to allow HT32 based keyboards to work without patched ChibiOS-contrib (AnnePro2)
* HT32: add spi support
Add persistent led support with eeprom (#9)
* adding HT32 support to chibios SPI master driver
update spi driver, fix bad merging with master
* HT32: fix formatting
HT32: Fix formatting: tmk_core/protocol/chibios/usb_main.c
Co-authored-by: Drashna Jaelre <drashna@live.com>
* HT32: Apply suggestions from fauxpark's code review
Co-authored-by: Ryan <fauxpark@gmail.com>
* HT32: update spi driver
* ht32: apply code review suggestions, remove old workaround
Co-authored-by: tech2077 <tech2077@gmail.com>
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'platforms')
-rw-r--r-- | platforms/chibios/drivers/spi_master.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/platforms/chibios/drivers/spi_master.c b/platforms/chibios/drivers/spi_master.c index f98db6db9..c592369dd 100644 --- a/platforms/chibios/drivers/spi_master.c +++ b/platforms/chibios/drivers/spi_master.c | |||
@@ -110,6 +110,31 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) { | |||
110 | spiConfig.tar0 |= SPIx_CTARn_BR(8); | 110 | spiConfig.tar0 |= SPIx_CTARn_BR(8); |
111 | break; | 111 | break; |
112 | } | 112 | } |
113 | |||
114 | #elif defined(HT32) | ||
115 | spiConfig.cr0 = SPI_CR0_SELOEN; | ||
116 | spiConfig.cr1 = SPI_CR1_MODE | 8; // 8 bits and in master mode | ||
117 | |||
118 | if (lsbFirst) { | ||
119 | spiConfig.cr1 |= SPI_CR1_FIRSTBIT; | ||
120 | } | ||
121 | |||
122 | switch (mode) { | ||
123 | case 0: | ||
124 | spiConfig.cr1 |= SPI_CR1_FORMAT_MODE0; | ||
125 | break; | ||
126 | case 1: | ||
127 | spiConfig.cr1 |= SPI_CR1_FORMAT_MODE1; | ||
128 | break; | ||
129 | case 2: | ||
130 | spiConfig.cr1 |= SPI_CR1_FORMAT_MODE2; | ||
131 | break; | ||
132 | case 3: | ||
133 | spiConfig.cr1 |= SPI_CR1_FORMAT_MODE3; | ||
134 | break; | ||
135 | } | ||
136 | |||
137 | spiConfig.cpr = (roundedDivisor - 1) >> 1; | ||
113 | #else | 138 | #else |
114 | spiConfig.cr1 = 0; | 139 | spiConfig.cr1 = 0; |
115 | 140 | ||