aboutsummaryrefslogtreecommitdiffstats
path: root/src/lpc176x/spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lpc176x/spi.c')
-rw-r--r--src/lpc176x/spi.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lpc176x/spi.c b/src/lpc176x/spi.c
index 92e303d0..8373a39f 100644
--- a/src/lpc176x/spi.c
+++ b/src/lpc176x/spi.c
@@ -23,6 +23,9 @@ spi_init(void)
gpio_peripheral(0, 17, 2, 0);
gpio_peripheral(0, 18, 2, 0);
+ // Setup clock
+ enable_peripheral_clock(PCLK_SSP0);
+
// Set initial registers
LPC_SSP0->CR0 = 0x07;
LPC_SSP0->CPSR = 254;
@@ -40,7 +43,7 @@ spi_setup(uint32_t bus, uint8_t mode, uint32_t rate)
// Setup clock rate and mode
struct spi_config res = {0, 0};
- uint32_t pclk = SystemCoreClock / 4;
+ uint32_t pclk = SystemCoreClock;
uint32_t div = DIV_ROUND_UP(pclk/2, rate) << 1;
res.cpsr = div < 2 ? 2 : (div > 254 ? 254 : div);
res.cr0 = 0x07 | (mode << 6);