diff --git a/ports/stm/boards/stm32f746g_discovery/mpconfigboard.h b/ports/stm/boards/stm32f746g_discovery/mpconfigboard.h index 35a28ca3d1..769990a98c 100644 --- a/ports/stm/boards/stm32f746g_discovery/mpconfigboard.h +++ b/ports/stm/boards/stm32f746g_discovery/mpconfigboard.h @@ -50,10 +50,6 @@ #define CPY_CLK_FLASH_LATENCY (FLASH_LATENCY_6) #define CPY_CLK_USB_USES_AUDIOPLL (1) -// Obtain I2C timing values for F7 and H7 boards from ST CubeMX -#define CPY_I2CFAST_TIMINGR 0x00401959 -#define CPY_I2CSTANDARD_TIMINGR 0x00C0EAFF - #define BOARD_HSE_SOURCE (RCC_HSE_BYPASS) // ST boards use the STLink clock signal #define BOARD_HAS_LOW_SPEED_CRYSTAL (1) diff --git a/ports/stm/common-hal/busio/I2C.c b/ports/stm/common-hal/busio/I2C.c index 00f15aaa60..6adcf55750 100644 --- a/ports/stm/common-hal/busio/I2C.c +++ b/ports/stm/common-hal/busio/I2C.c @@ -33,7 +33,24 @@ #include "shared-bindings/microcontroller/__init__.h" #include "supervisor/shared/translate.h" #include "common-hal/microcontroller/Pin.h" -#include "clocks.h" + +// I2C timing specs for the H7 and F7 +// Configured for maximum possible clock settings for the family +#if (CPY_STM32F7) +#ifndef CPY_I2CFAST_TIMINGR +#define CPY_I2CFAST_TIMINGR 0x6000030D +#endif +#ifndef CPY_I2CSTANDARD_TIMINGR +#define CPY_I2CSTANDARD_TIMINGR 0x20404768 +#endif +#elif (CPY_STM32H7) +#ifndef CPY_I2CFAST_TIMINGR +#define CPY_I2CFAST_TIMINGR 0x00B03FDB +#endif +#ifndef CPY_I2CSTANDARD_TIMINGR +#define CPY_I2CSTANDARD_TIMINGR 0x307075B1 +#endif +#endif // Arrays use 0 based numbering: I2C1 is stored at index 0 #define MAX_I2C 4 diff --git a/ports/stm/peripherals/clocks.h b/ports/stm/peripherals/clocks.h index 192190e5ee..1f837c79ee 100644 --- a/ports/stm/peripherals/clocks.h +++ b/ports/stm/peripherals/clocks.h @@ -24,34 +24,4 @@ * THE SOFTWARE. */ -// F4 Series -#ifdef STM32F401xE -#include "stm32f4/stm32f401xe/clocks.h" -#endif -#ifdef STM32F411xE -#include "stm32f4/stm32f411xe/clocks.h" -#endif -#ifdef STM32F412Zx -#include "stm32f4/stm32f412zx/clocks.h" -#endif -#ifdef STM32F405xx -#include "stm32f4/stm32f405xx/clocks.h" -#endif -#ifdef STM32F407xx -#include "stm32f4/stm32f407xx/clocks.h" -#endif - -// F7 Series -#ifdef STM32F746xx -#include "stm32f7/stm32f746xx/clocks.h" -#endif -#ifdef STM32F767xx -#include "stm32f7/stm32f767xx/clocks.h" -#endif - -// H7 Series -#ifdef STM32H743xx -#include "stm32h7/stm32h743xx/clocks.h" -#endif - void stm32_peripherals_clocks_init(void); diff --git a/ports/stm/peripherals/stm32f7/stm32f746xx/clocks.h b/ports/stm/peripherals/stm32f7/stm32f746xx/clocks.h index bd53c38cd9..eb44625143 100644 --- a/ports/stm/peripherals/stm32f7/stm32f746xx/clocks.h +++ b/ports/stm/peripherals/stm32f7/stm32f746xx/clocks.h @@ -61,11 +61,3 @@ #ifndef BOARD_HSE_SOURCE #define BOARD_HSE_SOURCE (RCC_HSE_ON) #endif - -// Obtain I2C timing values for F7 and H7 boards from ST CubeMX -#ifndef CPY_I2CFAST_TIMINGR -#define CPY_I2CFAST_TIMINGR 0x6000030D -#endif -#ifndef CPY_I2CSTANDARD_TIMINGR -#define CPY_I2CSTANDARD_TIMINGR 0x20404768 -#endif diff --git a/ports/stm/peripherals/stm32f7/stm32f767xx/clocks.h b/ports/stm/peripherals/stm32f7/stm32f767xx/clocks.h index a89756db05..187a024ad0 100644 --- a/ports/stm/peripherals/stm32f7/stm32f767xx/clocks.h +++ b/ports/stm/peripherals/stm32f7/stm32f767xx/clocks.h @@ -61,11 +61,3 @@ #ifndef BOARD_HSE_SOURCE #define BOARD_HSE_SOURCE (RCC_HSE_ON) #endif - -// Obtain I2C timing values for F7 and H7 boards from ST CubeMX -#ifndef CPY_I2CFAST_TIMINGR -#define CPY_I2CFAST_TIMINGR 0x6000030D -#endif -#ifndef CPY_I2CSTANDARD_TIMINGR -#define CPY_I2CSTANDARD_TIMINGR 0x20404768 -#endif diff --git a/ports/stm/peripherals/stm32h7/stm32h743xx/clocks.h b/ports/stm/peripherals/stm32h7/stm32h743xx/clocks.h index e7c5170966..ad241b7ef6 100644 --- a/ports/stm/peripherals/stm32h7/stm32h743xx/clocks.h +++ b/ports/stm/peripherals/stm32h7/stm32h743xx/clocks.h @@ -68,11 +68,3 @@ #ifndef BOARD_HSE_SOURCE #define BOARD_HSE_SOURCE (RCC_HSE_ON) #endif - -// Obtain I2C timing values for F7 and H7 boards from ST CubeMX -#ifndef CPY_I2CFAST_TIMINGR -#define CPY_I2CFAST_TIMINGR 0x00B03FDB -#endif -#ifndef CPY_I2CSTANDARD_TIMINGR -#define CPY_I2CSTANDARD_TIMINGR 0x307075B1 -#endif