Move I2C speed to clock-style definition

This commit is contained in:
Lucian Copeland 2020-06-11 11:17:51 -04:00
parent c08702414e
commit 724637faa3
9 changed files with 56 additions and 19 deletions

View File

@ -46,9 +46,5 @@
#define BOARD_HSE_SOURCE (RCC_HSE_BYPASS) // ST boards use the STLink clock signal
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
// Obtain I2C timing values for F7 and H7 boards from ST CubeMX
#define CPY_I2CFAST_TIMINGR 0x6000030D
#define CPY_I2CSTANDARD_TIMINGR 0x20404768
#define DEBUG_UART_TX (&pin_PD08)
#define DEBUG_UART_RX (&pin_PD09)

View File

@ -40,10 +40,6 @@
#define CPY_SRAM_SUBMASK 0xFC // Mask 512 to 384
#define CPY_SRAM_START_ADDR 0x20020000
// Obtain I2C timing values for F7 and H7 boards from ST CubeMX
#define CPY_I2CFAST_TIMINGR 0x6000030D
#define CPY_I2CSTANDARD_TIMINGR 0x20404768
#define HSE_VALUE ((uint32_t)8000000)
#define LSE_VALUE ((uint32_t)32768)
#define BOARD_HSE_SOURCE (RCC_HSE_BYPASS) // ST boards use the STLink clock signal

View File

@ -39,12 +39,6 @@
#define CPY_SRAM_SUBMASK 0x00
#define CPY_SRAM_START_ADDR 0x24000000
// Obtain I2C timing values for F7 and H7 boards from ST CubeMX
#define CPY_I2CFAST_TIMINGR 0x00B03FDB
#define CPY_I2CSTANDARD_TIMINGR 0x307075B1
#define HSE_VALUE ((uint32_t)8000000)
#define LSE_VALUE ((uint32_t)32768)
#define BOARD_HSE_SOURCE (RCC_HSE_BYPASS) // ST boards use the STLink clock signal

View File

@ -39,9 +39,5 @@
#define CPY_SRAM_SUBMASK 0x00
#define CPY_SRAM_START_ADDR 0x24000000
// Obtain I2C timing values for F7 and H7 boards from ST CubeMX
#define CPY_I2CFAST_TIMINGR 0x00B03FDB
#define CPY_I2CSTANDARD_TIMINGR 0x307075B1
#define HSE_VALUE ((uint32_t)12000000)
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)

View File

@ -33,6 +33,7 @@
#include "shared-bindings/microcontroller/__init__.h"
#include "supervisor/shared/translate.h"
#include "common-hal/microcontroller/Pin.h"
#include "clocks.h"
// Arrays use 0 based numbering: I2C1 is stored at index 0
#define MAX_I2C 4
@ -125,7 +126,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self,
} else if (frequency == 100000) {
self->handle.Init.Timing = CPY_I2CSTANDARD_TIMINGR;
} else {
mp_raise_ValueError(translate("MCU supports only I2C Standard and Fast modes"));
mp_raise_ValueError(translate("Unsupported baudrate"));
}
#else
self->handle.Init.ClockSpeed = frequency;

View File

@ -24,4 +24,34 @@
* 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);

View File

@ -61,3 +61,11 @@
#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

View File

@ -61,3 +61,11 @@
#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

View File

@ -68,3 +68,11 @@
#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