aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbryan newbold <bnewbold@robocracy.org>2015-06-12 03:05:43 -0700
committerbryan newbold <bnewbold@robocracy.org>2015-06-12 03:16:03 -0700
commit035a069b838a1b5a7df2d254d3c8617ea3dc98b5 (patch)
tree788a19cca80244e1a649942449addbde178c90f8
parent507a0c1e824ca57b048630d401b8eacc744edf97 (diff)
downloadlibrambutan-035a069b838a1b5a7df2d254d3c8617ea3dc98b5.tar.gz
librambutan-035a069b838a1b5a7df2d254d3c8617ea3dc98b5.zip
wirish/HardwareSPI: use board-agnostic SPI rates (dividers)
-rw-r--r--wirish/HardwareSPI.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/wirish/HardwareSPI.cpp b/wirish/HardwareSPI.cpp
index 1acba76..6cf6a96 100644
--- a/wirish/HardwareSPI.cpp
+++ b/wirish/HardwareSPI.cpp
@@ -39,7 +39,7 @@
#include <wirish/wirish.h>
#include <wirish/boards.h>
-#if CYCLES_PER_MICROSECOND != 72
+#if CYCLES_PER_MICROSECOND != 72 && CYCLES_PER_MICROSECOND != 84
/* TODO [0.2.0?] something smarter than this */
#warning "Unexpected clock speed; SPI frequency calculation will be incorrect"
#endif
@@ -123,7 +123,7 @@ void HardwareSPI::begin(SPIFrequency frequency, uint32 bitOrder, uint32 mode) {
}
void HardwareSPI::begin(void) {
- this->begin(SPI_1_125MHZ, MSBFIRST, 0);
+ this->begin(SPI_PCLK_DIV_32, MSBFIRST, 0); // 1.125 MHz for a 72 MHz board
}
void HardwareSPI::beginSlave(uint32 bitOrder, uint32 mode) {
@@ -333,8 +333,8 @@ static const spi_baud_rate baud_rates[MAX_SPI_FREQS] __FLASH__ = {
* (CYCLES_PER_MICROSECOND == 72, APB2 at 72MHz, APB1 at 36MHz).
*/
static spi_baud_rate determine_baud_rate(spi_dev *dev, SPIFrequency freq) {
- if (rcc_dev_clk(dev->clk_id) == RCC_APB2 && freq == SPI_140_625KHZ) {
- /* APB2 peripherals are too fast for 140.625 KHz */
+ if (rcc_dev_clk(dev->clk_id) == RCC_APB2 && freq == SPI_PCLK_DIV_256) {
+ /* APB2 peripherals are too fast for the largest divider */
ASSERT(0);
return (spi_baud_rate)~0;
}