aboutsummaryrefslogtreecommitdiffstats
path: root/core/comm/HardwareSPI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/comm/HardwareSPI.cpp')
-rw-r--r--core/comm/HardwareSPI.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/core/comm/HardwareSPI.cpp b/core/comm/HardwareSPI.cpp
index 542742b..51093cb 100644
--- a/core/comm/HardwareSPI.cpp
+++ b/core/comm/HardwareSPI.cpp
@@ -26,7 +26,9 @@
* @brief HardwareSPI "wiring-like" api for SPI
*/
-/* Speeds:
+/* NOTES:
+ *
+ * Speeds:
* -----------------------------------
* Interface num: SPI1 SPI2
* Bus APB2 APB1
@@ -41,6 +43,8 @@
* 64: 1 125 000 562 500
* 128: 562 500 281 250
* 256: 281 250 140 625
+ *
+ * TODO: Do the complementary PWM outputs mess up SPI2?
* */
#include "wiring.h"
@@ -58,7 +62,6 @@ static const uint32 prescaleFactors[MAX_SPI_FREQS] = {
SPI_PRESCALE_256, // SPI_140_625KHZ
};
-
/**
* @brief Initialize a SPI peripheral
* @param freq frequency to run at, must one of the following values:
@@ -87,9 +90,15 @@ void HardwareSPI::begin(SPIFrequency freq, uint32 endianness, uint32 mode) {
return;
}
- /* SPI1 is too fast for 140625 */
- if ((spi_num == 1) && (freq == SPI_140_625KHZ)) {
- return;
+ if (spi_num == 1) {
+ /* SPI1 is too fast for 140625 */
+ if (freq == SPI_140_625KHZ) {
+ return;
+ }
+
+ /* Turn off PWM on shared pins */
+ timers_disable_channel(3, 2);
+ timers_disable_channel(3, 1);
}
endianness = (endianness == LSBFIRST) ? SPI_LSBFIRST : SPI_MSBFIRST;