stm32/i2c: Add hardware I2C implementation for STM32G4.

For STM32G4, hardware I2C can implement same as STM32L4 for machine.I2C.
This commit makes to be able to use of hardware I2C in machine.I2C.

Tested on NUCLEO-G474RE.

Signed-off-by: Yuuki NAGAO <wf.yn386@gmail.com>
This commit is contained in:
Yuuki NAGAO
2025-09-15 08:09:01 +09:00
committed by Damien George
parent 03e3a06de6
commit a6efc67064
2 changed files with 3 additions and 3 deletions

View File

@@ -271,12 +271,12 @@ int i2c_write(i2c_t *i2c, const uint8_t *src, size_t len, size_t next_len) {
return num_acks;
}
#elif defined(STM32F0) || defined(STM32F7) || defined(STM32H7) || defined(STM32L4)
#elif defined(STM32F0) || defined(STM32F7) || defined(STM32G4) || defined(STM32H7) || defined(STM32L4)
#if defined(STM32H7)
#define APB1ENR APB1LENR
#define RCC_APB1ENR_I2C1EN RCC_APB1LENR_I2C1EN
#elif defined(STM32L4)
#elif defined(STM32G4) || defined(STM32L4)
#define APB1ENR APB1ENR1
#define RCC_APB1ENR_I2C1EN RCC_APB1ENR1_I2C1EN
#endif

View File

@@ -34,7 +34,7 @@
#define I2C_POLL_DEFAULT_TIMEOUT_US (50000) // 50ms
#if defined(STM32F0) || defined(STM32F4) || defined(STM32F7) || defined(STM32H7) || defined(STM32L1) || defined(STM32L4)
#if defined(STM32F0) || defined(STM32F4) || defined(STM32F7) || defined(STM32G4) || defined(STM32H7) || defined(STM32L1) || defined(STM32L4)
typedef struct _machine_hard_i2c_obj_t {
mp_obj_base_t base;