File tree 4 files changed +17
-8
lines changed
4 files changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -243,6 +243,7 @@ typedef enum {
243
243
GPIO_AFMODE_USART4_6 = 8 ,
244
244
GPIO_AFMODE_CAN1_2 = 9 ,
245
245
GPIO_AFMODE_TIM12_14 = 9 ,
246
+ GPIO_AFMODE_I2C2_3 = 9 ,
246
247
GPIO_AFMODE_OTG_FS = 10 ,
247
248
GPIO_AFMODE_ETH = 11 ,
248
249
GPIO_AFMODE_FSMC = 12 ,
Original file line number Diff line number Diff line change @@ -55,8 +55,10 @@ i2c_dev i2c_dev1 = {
55
55
/** I2C2 device */
56
56
i2c_dev i2c_dev2 = {
57
57
.regs = I2C2_BASE ,
58
- .sda_pin = PB11 ,
59
- .scl_pin = PB10 ,
58
+ // .sda_pin = PB3,
59
+ //.scl_pin = PB10,
60
+ .sda_pin = BOARD_I2C2_SDA_PIN ,
61
+ .scl_pin = BOARD_I2C2_SCL_PIN ,
60
62
.clk_id = RCC_I2C2 ,
61
63
.ev_nvic_line = NVIC_I2C2_EV ,
62
64
.er_nvic_line = NVIC_I2C2_ER ,
@@ -206,7 +208,13 @@ void i2c_master_enable(i2c_dev *dev, uint32 flags) {
206
208
delay_us (2 );
207
209
gpio_set_af_mode (dev -> scl_pin , GPIO_AFMODE_I2C1_3 );
208
210
delay_us (2 );
209
- gpio_set_af_mode (dev -> sda_pin , GPIO_AFMODE_I2C1_3 );
211
+ if ((dev -> sda_pin == PB3 ) || (dev -> sda_pin == PB4 )) {
212
+ gpio_set_af_mode (dev -> sda_pin , GPIO_AFMODE_I2C2_3 );
213
+ }
214
+ else {
215
+ gpio_set_af_mode (dev -> sda_pin , GPIO_AFMODE_I2C1_3 );
216
+ }
217
+
210
218
211
219
i2c_init (dev );
212
220
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ tools.stlink_upload.cmd=stlink_upload
121
121
tools.stlink_upload.cmd.windows=stlink_upload.bat
122
122
tools.stlink_upload.path.windows={runtime.hardware.path}/tools/win
123
123
tools.stlink_upload.path.macosx={runtime.hardware.path}/tools/macosx
124
- tools.stlink_upload.path.linux={runtime.hardware.path}/tools/linux
124
+ tools.stlink_upload.path.linux={runtime.hardware.path}/tools/linux64
125
125
tools.stlink_upload.path.linux64={runtime.hardware.path}/tools/linux64
126
126
tools.stlink_upload.upload.params.verbose=-d
127
127
tools.stlink_upload.upload.params.quiet=
@@ -132,7 +132,7 @@ tools.hid_upload.cmd=hid_upload
132
132
tools.hid_upload.cmd.windows=hid_upload.bat
133
133
tools.hid_upload.path.windows={runtime.hardware.path}/tools/win
134
134
tools.hid_upload.path.macosx={runtime.hardware.path}/tools/macosx
135
- tools.hid_upload.path.linux={runtime.hardware.path}/tools/linux
135
+ tools.hid_upload.path.linux={runtime.hardware.path}/tools/linux64
136
136
tools.hid_upload.path.linux64={runtime.hardware.path}/tools/linux64
137
137
tools.hid_upload.upload.params.verbose=-d
138
138
tools.hid_upload.upload.params.quiet=n
Original file line number Diff line number Diff line change 52
52
//#define BOARD_USART6_TX_PIN PA11 // USB_DM
53
53
//#define BOARD_USART6_RX_PIN PA12 // USB_DP
54
54
55
- #define BOARD_NR_I2C 1
55
+ #define BOARD_NR_I2C 2
56
56
#define BOARD_I2C1_SCL_PIN PB6
57
57
#define BOARD_I2C1_SDA_PIN PB7
58
- #define BOARD_I2C1A_SCL_PIN PB8
59
- #define BOARD_I2C1A_SDA_PIN PB9
58
+ #define BOARD_I2C2_SCL_PIN PB10
59
+ #define BOARD_I2C2_SDA_PIN PB3
60
60
61
61
#define BOARD_NR_SPI 3
62
62
#define BOARD_SPI1_NSS_PIN PA4
You can’t perform that action at this time.
0 commit comments