Merge pull request #790 from openmv/cambus_speed

Add I2C timings to cambus.
This commit is contained in:
Ibrahim Abd Elkader 2020-05-09 19:14:20 +02:00 committed by GitHub
commit ecf6e4581e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 5 deletions

View File

@ -107,7 +107,7 @@
#define SCCB_PORT (GPIOB) #define SCCB_PORT (GPIOB)
#define SCCB_SCL_PIN (GPIO_PIN_8) #define SCCB_SCL_PIN (GPIO_PIN_8)
#define SCCB_SDA_PIN (GPIO_PIN_9) #define SCCB_SDA_PIN (GPIO_PIN_9)
#define SCCB_TIMING (0) // ignored #define SCCB_TIMING (I2C_TIMING_STANDARD) // ignored
/* DCMI */ /* DCMI */
#define DCMI_TIM (TIM1) #define DCMI_TIM (TIM1)

View File

@ -105,7 +105,7 @@
#define SCCB_PORT (GPIOB) #define SCCB_PORT (GPIOB)
#define SCCB_SCL_PIN (GPIO_PIN_8) #define SCCB_SCL_PIN (GPIO_PIN_8)
#define SCCB_SDA_PIN (GPIO_PIN_9) #define SCCB_SDA_PIN (GPIO_PIN_9)
#define SCCB_TIMING (0x1090699B) // Frequency: 100KHz Rise Time: 100ns Fall Time: 20ns #define SCCB_TIMING (I2C_TIMING_STANDARD)
/* DCMI */ /* DCMI */
#define DCMI_TIM (TIM1) #define DCMI_TIM (TIM1)

View File

@ -154,7 +154,7 @@
#define SCCB_PORT (GPIOB) #define SCCB_PORT (GPIOB)
#define SCCB_SCL_PIN (GPIO_PIN_8) #define SCCB_SCL_PIN (GPIO_PIN_8)
#define SCCB_SDA_PIN (GPIO_PIN_9) #define SCCB_SDA_PIN (GPIO_PIN_9)
#define SCCB_TIMING (0x20D09DE7) // Frequency: 100KHz Rise Time: 100ns Fall Time: 20ns #define SCCB_TIMING (I2C_TIMING_STANDARD)
/* DCMI */ /* DCMI */
#define DCMI_TIM (TIM1) #define DCMI_TIM (TIM1)

View File

@ -163,7 +163,7 @@
#define SCCB_PORT (GPIOB) #define SCCB_PORT (GPIOB)
#define SCCB_SCL_PIN (GPIO_PIN_8) #define SCCB_SCL_PIN (GPIO_PIN_8)
#define SCCB_SDA_PIN (GPIO_PIN_9) #define SCCB_SDA_PIN (GPIO_PIN_9)
#define SCCB_TIMING (0x20D09DE7) // Frequency: 100KHz Rise Time: 100ns Fall Time: 20ns #define SCCB_TIMING (I2C_TIMING_STANDARD)
/* DCMI */ /* DCMI */
#define DCMI_TIM (TIM1) #define DCMI_TIM (TIM1)

View File

@ -151,7 +151,7 @@
#define SCCB_PORT (GPIOB) #define SCCB_PORT (GPIOB)
#define SCCB_SCL_PIN (GPIO_PIN_6) #define SCCB_SCL_PIN (GPIO_PIN_6)
#define SCCB_SDA_PIN (GPIO_PIN_7) #define SCCB_SDA_PIN (GPIO_PIN_7)
#define SCCB_TIMING (0x20D09DE7) // Frequency: 100KHz Rise Time: 100ns Fall Time: 20ns #define SCCB_TIMING (I2C_TIMING_STANDARD)
#define DCMI_PWDN_PIN (GPIO_PIN_4) #define DCMI_PWDN_PIN (GPIO_PIN_4)
#define DCMI_PWDN_PORT (GPIOD) #define DCMI_PWDN_PORT (GPIOD)

View File

@ -12,6 +12,23 @@
#define __CAMBUS_H__ #define __CAMBUS_H__
#include <stdint.h> #include <stdint.h>
#include STM32_HAL_H #include STM32_HAL_H
#if defined(STM32F4)
#define I2C_TIMING_STANDARD (0)
#define I2C_TIMING_FULL (0)
#define I2C_TIMING_FAST (0)
#elif defined(STM32F7)
// These timing values are for f_I2CCLK=54MHz and are only approximate
#define I2C_TIMING_STANDARD (0x1090699B)
#define I2C_TIMING_FULL (0x70330309)
#define I2C_TIMING_FAST (0x50100103)
#elif defined(STM32H7)
// I2C timing obtained from the CUBEMX.
#define I2C_TIMING_STANDARD (0x20D09DE7)
#define I2C_TIMING_FULL (0x40900C22)
#define I2C_TIMING_FAST (0x4030040B)
#else
#error "no I2C timings for this MCU"
#endif
int cambus_init(I2C_HandleTypeDef *i2c, I2C_TypeDef *instance, uint32_t timing); int cambus_init(I2C_HandleTypeDef *i2c, I2C_TypeDef *instance, uint32_t timing);
int cambus_deinit(I2C_HandleTypeDef *i2c); int cambus_deinit(I2C_HandleTypeDef *i2c);