clocking for 54mhz

This commit is contained in:
pkolesnikov
2016-05-25 14:30:47 +02:00
parent 7eb65246ee
commit 9ee3fe3f19
+20 -31
View File
@@ -104,7 +104,7 @@
/* At least one I2C peripheral must be enabled */ /* At least one I2C peripheral must be enabled */
#if defined(CONFIG_STM32F7_I2C1) || defined(CONFIG_STM32F7_I2C2) || defined(CONFIG_STM32F7_I2C3) #if defined(CONFIG_STM32F7_I2C1) || defined(CONFIG_STM32F7_I2C2) || defined(CONFIG_STM32F7_I2C3)
/* This implementation is for the STM32 F1, F2, and F4 only */ /* This implementation is for the STM32F7 only */
/************************************************************************************ /************************************************************************************
@@ -1078,40 +1078,33 @@ static void stm32f7_i2c_setclock(FAR struct stm32f7_i2c_priv_s *priv, uint32_t f
/* Update timing and control registers */ /* Update timing and control registers */
/* TODO: speed/timing calcs */ /* TODO: speed/timing calcs, at the moment 45Mhz = STM32_PCLK1_FREQUENCY, analog filter is on,
#warning "check set filters before timing, see RM0316" digital off from STM32F0-F3_AN4235_V1.0.1 */
/* values from 100khz at 8mhz i2c clock */ if (frequency == 100000)
/* prescaler */
/* t_presc= (presc+1)*t_i2cclk */
/* RM0316 */
if (frequency == 10000)
{ {
presc = 0x01; presc = 0x06;
scl_l_period = 0xc7; s_time = 0x02;
scl_h_period = 0xc3; h_time = 0x00;
h_time = 0x02; scl_h_period = 0x1e;
s_time = 0x04; scl_l_period = 0x2b;
} }
else if (frequency == 100000) else if (frequency == 400000)
{ {
/* values from datasheet with clock 8mhz */ presc = 0x00;
s_time = 0x0A;
presc = 0x01; h_time = 0x00;
scl_l_period = 0x13; scl_h_period = 0x1b;
scl_h_period = 0x0f; scl_l_period = 0x5b;
h_time = 0x02;
s_time = 0x04;
} }
else else
{ {
presc = 0x00; presc = 0x00;
scl_l_period = 0x09; s_time = 0x08;
scl_h_period = 0x03; h_time = 0x00;
h_time = 0x01; scl_h_period = 0x09;
s_time = 0x03; scl_l_period = 0x1c;
} }
uint32_t timingr = uint32_t timingr =
@@ -1123,10 +1116,6 @@ static void stm32f7_i2c_setclock(FAR struct stm32f7_i2c_priv_s *priv, uint32_t f
stm32f7_i2c_putreg32(priv, STM32F7_I2C_TIMINGR_OFFSET, timingr); stm32f7_i2c_putreg32(priv, STM32F7_I2C_TIMINGR_OFFSET, timingr);
/* Bit 14 of OAR1 must be configured and kept at 1 */
stm32f7_i2c_putreg(priv, STM32F7_I2C_OAR1_OFFSET, I2C_OAR1_OA1EN);
/* Re-enable the peripheral (or not) */ /* Re-enable the peripheral (or not) */
if (pe) if (pe)