aboutsummaryrefslogtreecommitdiffstats
path: root/src/lpc176x/spi.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2021-03-24 19:45:43 -0400
committerKevin O'Connor <kevin@koconnor.net>2021-03-25 11:35:04 -0400
commit6cab7bcfcb12003a538435f351a73978f5fbb954 (patch)
treecea0989f8e40a7ed337a6cb63c79488d82c8c158 /src/lpc176x/spi.c
parent964e3cc456941f8b6ec5f63b6ada9b28f1e67e6d (diff)
downloadkutter-6cab7bcfcb12003a538435f351a73978f5fbb954.tar.gz
kutter-6cab7bcfcb12003a538435f351a73978f5fbb954.tar.xz
kutter-6cab7bcfcb12003a538435f351a73978f5fbb954.zip
lpc176x: Introduce get_pclock_frequency()
Add get_pclock_frequency() - a standard way of obtaining the peripheral clock frequency. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/lpc176x/spi.c')
-rw-r--r--src/lpc176x/spi.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lpc176x/spi.c b/src/lpc176x/spi.c
index 2e644a1e..582fa77e 100644
--- a/src/lpc176x/spi.c
+++ b/src/lpc176x/spi.c
@@ -1,6 +1,6 @@
// SPI support on lpc176x
//
-// Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
+// Copyright (C) 2018-2021 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
@@ -58,7 +58,7 @@ spi_setup(uint32_t bus, uint8_t mode, uint32_t rate)
// Setup clock rate and mode
struct spi_config res = {spi_bus[bus].spi, 0, 0};
- uint32_t pclk = SystemCoreClock;
+ uint32_t pclk = get_pclock_frequency(spi_bus[bus].pclk);
uint32_t div = DIV_ROUND_UP(pclk/2, rate) << 1;
res.cpsr = div < 2 ? 2 : (div > 254 ? 254 : div);
res.cr0 = 0x07 | ((mode & 2) << 5) | ((mode & 1) << 7);