aboutsummaryrefslogtreecommitdiff
path: root/drivers/arm/i2c_master.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/arm/i2c_master.c')
-rw-r--r--drivers/arm/i2c_master.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/arm/i2c_master.c b/drivers/arm/i2c_master.c
index 7369398cc..5814375f3 100644
--- a/drivers/arm/i2c_master.c
+++ b/drivers/arm/i2c_master.c
@@ -32,12 +32,10 @@
32 32
33static uint8_t i2c_address; 33static uint8_t i2c_address;
34 34
35// This configures the I2C clock to 400khz assuming a 72Mhz clock
36// For more info : https://www.st.com/en/embedded-software/stsw-stm32126.html
37static const I2CConfig i2cconfig = { 35static const I2CConfig i2cconfig = {
38 STM32_TIMINGR_PRESC(15U) | 36 STM32_TIMINGR_PRESC(I2C1_TIMINGR_PRESC) |
39 STM32_TIMINGR_SCLDEL(4U) | STM32_TIMINGR_SDADEL(2U) | 37 STM32_TIMINGR_SCLDEL(I2C1_TIMINGR_SCLDEL) | STM32_TIMINGR_SDADEL(I2C1_TIMINGR_SDADEL) |
40 STM32_TIMINGR_SCLH(15U) | STM32_TIMINGR_SCLL(21U), 38 STM32_TIMINGR_SCLH(I2C1_TIMINGR_SCLH) | STM32_TIMINGR_SCLL(I2C1_TIMINGR_SCLL),
41 0, 39 0,
42 0 40 0
43}; 41};
@@ -58,13 +56,13 @@ __attribute__ ((weak))
58void i2c_init(void) 56void i2c_init(void)
59{ 57{
60 // Try releasing special pins for a short time 58 // Try releasing special pins for a short time
61 palSetPadMode(I2C1_BANK, I2C1_SCL, PAL_MODE_INPUT); 59 palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_INPUT);
62 palSetPadMode(I2C1_BANK, I2C1_SDA, PAL_MODE_INPUT); 60 palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_INPUT);
63 61
64 chThdSleepMilliseconds(10); 62 chThdSleepMilliseconds(10);
65 63
66 palSetPadMode(I2C1_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN); 64 palSetPadMode(I2C1_SCL_BANK, I2C1_SCL, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
67 palSetPadMode(I2C1_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(4) | PAL_STM32_OTYPE_OPENDRAIN); 65 palSetPadMode(I2C1_SDA_BANK, I2C1_SDA, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN);
68 66
69 //i2cInit(); //This is invoked by halInit() so no need to redo it. 67 //i2cInit(); //This is invoked by halInit() so no need to redo it.
70} 68}