diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-03-24 19:45:43 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-03-25 11:35:04 -0400 |
commit | 6cab7bcfcb12003a538435f351a73978f5fbb954 (patch) | |
tree | cea0989f8e40a7ed337a6cb63c79488d82c8c158 /src/lpc176x/i2c.c | |
parent | 964e3cc456941f8b6ec5f63b6ada9b28f1e67e6d (diff) | |
download | kutter-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/i2c.c')
-rw-r--r-- | src/lpc176x/i2c.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lpc176x/i2c.c b/src/lpc176x/i2c.c index 10b45ede..4d8dc361 100644 --- a/src/lpc176x/i2c.c +++ b/src/lpc176x/i2c.c @@ -1,6 +1,6 @@ // I2C functions 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. @@ -54,7 +54,8 @@ i2c_setup(uint32_t bus, uint32_t rate, uint8_t addr) // Set 100Khz frequency enable_pclock(info->pclk); - uint32_t pclk = SystemCoreClock, pulse = pclk / (100000 * 2); + uint32_t pclk = get_pclock_frequency(info->pclk); + uint32_t pulse = pclk / (100000 * 2); i2c->I2SCLL = pulse; i2c->I2SCLH = pulse; |