aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/stm32f1
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-06-22 14:44:15 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2012-06-22 15:07:08 -0400
commit7645bf2d485a74e11ae55fe1f281ff68fc49290f (patch)
tree7178381157a4a2a85f2b8b5ea784a7629c02b3ee /libmaple/stm32f1
parent929ef7192a497c7b6dc9d72c8bf455dc152dffbc (diff)
downloadlibrambutan-7645bf2d485a74e11ae55fe1f281ff68fc49290f.tar.gz
librambutan-7645bf2d485a74e11ae55fe1f281ff68fc49290f.zip
I2C: Move CCR/TRISE config helper back to libmaple/i2c.c.
We can implement it in terms of _i2c_bus_clk() instead of hard-coding STM32_PCLK1. This might be overkill, since I2C peripherals are slow and thus likely to be on APB1 for all STM32 devices (that is the case for F2/F4, for instance), but if we're going to have _i2c_bus_clk(), we might as well respect it. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'libmaple/stm32f1')
-rw-r--r--libmaple/stm32f1/i2c.c36
1 files changed, 0 insertions, 36 deletions
diff --git a/libmaple/stm32f1/i2c.c b/libmaple/stm32f1/i2c.c
index 3e0e146..8439793 100644
--- a/libmaple/stm32f1/i2c.c
+++ b/libmaple/stm32f1/i2c.c
@@ -127,39 +127,3 @@ void _i2c_irq_priority_fixup(i2c_dev *dev) {
nvic_irq_set_priority(dev->ev_nvic_line, 0);
nvic_irq_set_priority(dev->er_nvic_line, 0);
}
-
-void _i2c_set_ccr_trise(i2c_dev *dev, uint32 flags) {
-#define I2C_CLK (STM32_PCLK1/1000000)
- uint32 ccr = 0;
- uint32 trise = 0;
-
- /* I2C1 and I2C2 are fed from APB1, clocked at 36MHz */
- i2c_set_input_clk(dev, I2C_CLK);
-
- if (flags & I2C_FAST_MODE) {
- ccr |= I2C_CCR_FS;
-
- if (flags & I2C_DUTY_16_9) {
- /* Tlow/Thigh = 16/9 */
- ccr |= I2C_CCR_DUTY;
- ccr |= STM32_PCLK1/(400000 * 25);
- } else {
- /* Tlow/Thigh = 2 */
- ccr |= STM32_PCLK1/(400000 * 3);
- }
-
- trise = (300 * (I2C_CLK)/1000) + 1;
- } else {
- /* Tlow/Thigh = 1 */
- ccr = STM32_PCLK1/(100000 * 2);
- trise = I2C_CLK + 1;
- }
-
- /* Set minimum required value if CCR < 1*/
- if ((ccr & I2C_CCR_CCR) == 0) {
- ccr |= 0x1;
- }
-
- i2c_set_clk_control(dev, ccr);
- i2c_set_trise(dev, trise);
-}