Skip to content

Commit 724637f

Browse files
committed
Move I2C speed to clock-style definition
1 parent c087024 commit 724637f

File tree

9 files changed

+56
-19
lines changed

9 files changed

+56
-19
lines changed

ports/stm/boards/nucleo_f746zg/mpconfigboard.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,5 @@
4646
#define BOARD_HSE_SOURCE (RCC_HSE_BYPASS) // ST boards use the STLink clock signal
4747
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
4848

49-
// Obtain I2C timing values for F7 and H7 boards from ST CubeMX
50-
#define CPY_I2CFAST_TIMINGR 0x6000030D
51-
#define CPY_I2CSTANDARD_TIMINGR 0x20404768
52-
5349
#define DEBUG_UART_TX (&pin_PD08)
5450
#define DEBUG_UART_RX (&pin_PD09)

ports/stm/boards/nucleo_f767zi/mpconfigboard.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040
#define CPY_SRAM_SUBMASK 0xFC // Mask 512 to 384
4141
#define CPY_SRAM_START_ADDR 0x20020000
4242

43-
// Obtain I2C timing values for F7 and H7 boards from ST CubeMX
44-
#define CPY_I2CFAST_TIMINGR 0x6000030D
45-
#define CPY_I2CSTANDARD_TIMINGR 0x20404768
46-
4743
#define HSE_VALUE ((uint32_t)8000000)
4844
#define LSE_VALUE ((uint32_t)32768)
4945
#define BOARD_HSE_SOURCE (RCC_HSE_BYPASS) // ST boards use the STLink clock signal

ports/stm/boards/nucleo_h743zi_2/mpconfigboard.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@
3939
#define CPY_SRAM_SUBMASK 0x00
4040
#define CPY_SRAM_START_ADDR 0x24000000
4141

42-
// Obtain I2C timing values for F7 and H7 boards from ST CubeMX
43-
#define CPY_I2CFAST_TIMINGR 0x00B03FDB
44-
#define CPY_I2CSTANDARD_TIMINGR 0x307075B1
45-
46-
47-
4842
#define HSE_VALUE ((uint32_t)8000000)
4943
#define LSE_VALUE ((uint32_t)32768)
5044
#define BOARD_HSE_SOURCE (RCC_HSE_BYPASS) // ST boards use the STLink clock signal

ports/stm/boards/openmv_h7/mpconfigboard.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,5 @@
3939
#define CPY_SRAM_SUBMASK 0x00
4040
#define CPY_SRAM_START_ADDR 0x24000000
4141

42-
// Obtain I2C timing values for F7 and H7 boards from ST CubeMX
43-
#define CPY_I2CFAST_TIMINGR 0x00B03FDB
44-
#define CPY_I2CSTANDARD_TIMINGR 0x307075B1
45-
4642
#define HSE_VALUE ((uint32_t)12000000)
4743
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)

ports/stm/common-hal/busio/I2C.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "shared-bindings/microcontroller/__init__.h"
3434
#include "supervisor/shared/translate.h"
3535
#include "common-hal/microcontroller/Pin.h"
36+
#include "clocks.h"
3637

3738
// Arrays use 0 based numbering: I2C1 is stored at index 0
3839
#define MAX_I2C 4
@@ -125,7 +126,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
125126
} else if (frequency == 100000) {
126127
self->handle.Init.Timing = CPY_I2CSTANDARD_TIMINGR;
127128
} else {
128-
mp_raise_ValueError(translate("MCU supports only I2C Standard and Fast modes"));
129+
mp_raise_ValueError(translate("Unsupported baudrate"));
129130
}
130131
#else
131132
self->handle.Init.ClockSpeed = frequency;

ports/stm/peripherals/clocks.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,34 @@
2424
* THE SOFTWARE.
2525
*/
2626

27+
// F4 Series
28+
#ifdef STM32F401xE
29+
#include "stm32f4/stm32f401xe/clocks.h"
30+
#endif
31+
#ifdef STM32F411xE
32+
#include "stm32f4/stm32f411xe/clocks.h"
33+
#endif
34+
#ifdef STM32F412Zx
35+
#include "stm32f4/stm32f412zx/clocks.h"
36+
#endif
37+
#ifdef STM32F405xx
38+
#include "stm32f4/stm32f405xx/clocks.h"
39+
#endif
40+
#ifdef STM32F407xx
41+
#include "stm32f4/stm32f407xx/clocks.h"
42+
#endif
43+
44+
// F7 Series
45+
#ifdef STM32F746xx
46+
#include "stm32f7/stm32f746xx/clocks.h"
47+
#endif
48+
#ifdef STM32F767xx
49+
#include "stm32f7/stm32f767xx/clocks.h"
50+
#endif
51+
52+
// H7 Series
53+
#ifdef STM32H743xx
54+
#include "stm32h7/stm32h743xx/clocks.h"
55+
#endif
56+
2757
void stm32_peripherals_clocks_init(void);

ports/stm/peripherals/stm32f7/stm32f746xx/clocks.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@
6161
#ifndef BOARD_HSE_SOURCE
6262
#define BOARD_HSE_SOURCE (RCC_HSE_ON)
6363
#endif
64+
65+
// Obtain I2C timing values for F7 and H7 boards from ST CubeMX
66+
#ifndef CPY_I2CFAST_TIMINGR
67+
#define CPY_I2CFAST_TIMINGR 0x6000030D
68+
#endif
69+
#ifndef CPY_I2CSTANDARD_TIMINGR
70+
#define CPY_I2CSTANDARD_TIMINGR 0x20404768
71+
#endif

ports/stm/peripherals/stm32f7/stm32f767xx/clocks.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,11 @@
6161
#ifndef BOARD_HSE_SOURCE
6262
#define BOARD_HSE_SOURCE (RCC_HSE_ON)
6363
#endif
64+
65+
// Obtain I2C timing values for F7 and H7 boards from ST CubeMX
66+
#ifndef CPY_I2CFAST_TIMINGR
67+
#define CPY_I2CFAST_TIMINGR 0x6000030D
68+
#endif
69+
#ifndef CPY_I2CSTANDARD_TIMINGR
70+
#define CPY_I2CSTANDARD_TIMINGR 0x20404768
71+
#endif

ports/stm/peripherals/stm32h7/stm32h743xx/clocks.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,11 @@
6868
#ifndef BOARD_HSE_SOURCE
6969
#define BOARD_HSE_SOURCE (RCC_HSE_ON)
7070
#endif
71+
72+
// Obtain I2C timing values for F7 and H7 boards from ST CubeMX
73+
#ifndef CPY_I2CFAST_TIMINGR
74+
#define CPY_I2CFAST_TIMINGR 0x00B03FDB
75+
#endif
76+
#ifndef CPY_I2CSTANDARD_TIMINGR
77+
#define CPY_I2CSTANDARD_TIMINGR 0x307075B1
78+
#endif

0 commit comments

Comments
 (0)