Skip to content

Commit 3fad502

Browse files
committed
[STM32] Make most of the I2C code into a common file
Since most of the code in i2c_api.c is now relying on STM32 HAL, there is now a possibility to make a common usage of this code accross families. The IP version definition is introduced per family, to allow a switch of functionnalities, especially the frequency management which differs. BTw, we fix the F0 frequency settings at the same time. F1 is managed for now as an exception as the HAL API for sequential transmit /receive is not yet available (coming soon)
1 parent 23926a2 commit 3fad502

File tree

54 files changed

+1161
-3528
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1161
-3528
lines changed

targets/TARGET_STM/TARGET_STM32F0/TARGET_DISCO_F051R8/objects.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ struct dac_s {
6666
uint32_t channel;
6767
};
6868

69-
struct i2c_s {
70-
I2CName i2c;
71-
};
72-
7369
#include "common_objects.h"
7470
#include "gpio_object.h"
7571

targets/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F030R8/objects.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ struct analogin_s {
6060
uint32_t channel;
6161
};
6262

63-
struct i2c_s {
64-
I2CName i2c;
65-
};
66-
6763
#include "common_objects.h"
6864
#include "gpio_object.h"
6965

targets/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F031K6/objects.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ struct analogin_s {
6060
uint32_t channel;
6161
};
6262

63-
struct i2c_s {
64-
I2CName i2c;
65-
};
66-
6763
#include "common_objects.h"
6864
#include "gpio_object.h"
6965

targets/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F042K6/objects.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ struct analogin_s {
6060
uint32_t channel;
6161
};
6262

63-
struct i2c_s {
64-
I2CName i2c;
65-
};
66-
6763
struct can_s {
6864
CANName can;
6965
int index;

targets/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F070RB/objects.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ struct analogin_s {
6060
uint32_t channel;
6161
};
6262

63-
struct i2c_s {
64-
I2CName i2c;
65-
};
66-
6763
#include "common_objects.h"
6864
#include "gpio_object.h"
6965

targets/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F072RB/objects.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ struct dac_s {
6666
uint32_t channel;
6767
};
6868

69-
struct i2c_s {
70-
I2CName i2c;
71-
};
72-
7369
struct can_s {
7470
CANName can;
7571
int index;

targets/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F091RC/objects.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ struct dac_s {
6666
uint32_t channel;
6767
};
6868

69-
struct i2c_s {
70-
I2CName i2c;
71-
};
72-
7369
struct can_s {
7470
CANName can;
7571
int index;

targets/TARGET_STM/TARGET_STM32F0/common_objects.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,34 @@ struct serial_s {
8282
#endif
8383
};
8484

85+
struct i2c_s {
86+
/* The 1st 2 members I2CName i2c
87+
* and I2C_HandleTypeDef handle should
88+
* be kept as the first members of this struct
89+
* to ensure i2c_get_obj to work as expected
90+
*/
91+
I2CName i2c;
92+
I2C_HandleTypeDef handle;
93+
uint8_t index;
94+
int hz;
95+
PinName sda;
96+
PinName scl;
97+
IRQn_Type event_i2cIRQ;
98+
IRQn_Type error_i2cIRQ;
99+
uint32_t XferOperation;
100+
volatile uint8_t event;
101+
#if DEVICE_I2CSLAVE
102+
uint8_t slave;
103+
volatile uint8_t pending_slave_tx_master_rx;
104+
volatile uint8_t pending_slave_rx_maxter_tx;
105+
#endif
106+
#if DEVICE_I2C_ASYNCH
107+
uint32_t address;
108+
uint8_t stop;
109+
uint8_t available_events;
110+
#endif
111+
};
112+
85113
#include "gpio_object.h"
86114

87115
#ifdef __cplusplus

0 commit comments

Comments
 (0)