Skip to content

Commit fe80efe

Browse files
authored
Merge pull request #3072 from jeromecoutant/PR_I2C_TESTS
i2c_loop tests update for STM32
2 parents 06fc7e4 + ae9041b commit fe80efe

File tree

3 files changed

+94
-30
lines changed

3 files changed

+94
-30
lines changed

features/unsupported/tests/mbed/i2c_master_slave/main.cpp

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,79 @@
22
#include "test_env.h"
33
#include <stdio.h>
44

5+
#if !DEVICE_I2C
6+
#error [NOT_SUPPORTED] I2C is not supported
7+
#endif
8+
9+
#if !DEVICE_I2CSLAVE
10+
#error [NOT_SUPPORTED] I2C Slave is not supported
11+
#endif
12+
13+
#if defined(TARGET_NUCLEO_F031K6) || \
14+
defined (TARGET_NUCLEO_L011K4) || \
15+
defined (TARGET_NUCLEO_L031K6) || \
16+
defined (TARGET_DISCO_F746NG) || \
17+
defined (TARGET_DISCO_L476VG) || \
18+
defined (TARGET_NUCLEO_F303K8) || \
19+
defined (TARGET_NUCLEO_F334R8) || \
20+
defined (TARGET_DISCO_F334C8) || \
21+
defined (TARGET_NUCLEO_F042K6)
22+
#error [NOT_SUPPORTED] Target has only one I2C instance
23+
#endif
24+
525
#define ADDR (0xA0)
626
#define FREQ 100000
727

828
// ********************************************************
929
// This tests data transfer between two I2C interfaces on
1030
// the same chip, one configured as master, the other as
11-
// slave. Works on:
12-
//
13-
// *LPC1768 mbed
14-
// p28 <-> p9
15-
// p27 <-> p10
16-
// pull-up resistors on both lines
17-
// *STM32F4 boards
18-
// cf below for wiring
31+
// slave.
1932
//
33+
// Wiring: connect master SCL to slave SCL, and master SDA to slave SDA
2034
// ********************************************************
2135

22-
#if defined(TARGET_NUCLEO_F411RE) || defined (TARGET_NUCLEO_F446RE) || defined (TARGET_NUCLEO_F410RB) || defined (TARGET_NUCLEO_F401RE)
23-
I2C master(PB_9, PB_8); // I2C_1 (Arduino: D14/D15)
24-
I2CSlave slave(PB_3, PB_10); // I2C_2 (Arduino: D3/D6)
25-
#elif defined (TARGET_NUCLEO_F429ZI) || defined (TARGET_DISCO_F429ZI) || defined (TARGET_NUCLEO_F446ZE)
26-
I2C master(PB_9, PB_8); // I2C_1 (Arduino: D14/D15)
27-
I2CSlave slave(PB_11, PB_10); // I2C_2
36+
#if defined (TARGET_DISCO_F429ZI) || \
37+
defined (TARGET_DISCO_L053C8)
38+
I2C master(PB_9, PB_8);
39+
40+
#elif defined(TARGET_FF_ARDUINO)
41+
I2C master(D14, D15); // I2C_SDA, I2C_SCL
42+
#endif
43+
44+
45+
#if defined (TARGET_NUCLEO_F429ZI) || \
46+
defined (TARGET_NUCLEO_F767ZI) || \
47+
defined (TARGET_NUCLEO_L053R8) || \
48+
defined (TARGET_NUCLEO_L073RZ) || \
49+
defined (TARGET_NUCLEO_L152RE) || \
50+
defined (TARGET_NUCLEO_L476RG) || \
51+
defined (TARGET_NUCLEO_F207ZG) || \
52+
defined (TARGET_NUCLEO_F103RB) || \
53+
defined (TARGET_NUCLEO_F091RC) || \
54+
defined (TARGET_DISCO_F429ZI) || \
55+
defined (TARGET_DISCO_F469NI) || \
56+
defined (TARGET_DISCO_L053C8) || \
57+
defined (TARGET_NUCLEO_F446ZE)
58+
I2CSlave slave(PB_11, PB_10);
59+
60+
#elif defined (TARGET_NUCLEO_F303RE) || \
61+
defined (TARGET_NUCLEO_F302R8)
62+
I2CSlave slave(D2, D8);
63+
64+
#elif defined (TARGET_NUCLEO_F303ZE)
65+
I2CSlave slave(PC_9, PA_8);
66+
67+
#elif defined (TARGET_NUCLEO_F746ZG)
68+
I2CSlave slave(D2, D4);
69+
70+
#elif defined (TARGET_NUCLEO_F030R8) || \
71+
defined (TARGET_NUCLEO_F070RB) || \
72+
defined (TARGET_NUCLEO_F072RB)
73+
I2CSlave slave(PB_11, D6);
74+
75+
#else
76+
I2CSlave slave(D3, D6);
77+
2878
#endif
2979

3080
int main()

features/unsupported/tests/mbed/i2c_master_slave_asynch/main.cpp

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22
#include "test_env.h"
33
#include <stdio.h>
44

5+
#if !DEVICE_I2C
6+
#error [NOT_SUPPORTED] I2C is not supported
7+
#endif
8+
9+
#if !DEVICE_I2CSLAVE
10+
#error [NOT_SUPPORTED] I2C Slave is not supported
11+
#endif
12+
13+
#if !DEVICE_I2C_ASYNCH
14+
#error [NOT_SUPPORTED] I2C Async is not supported
15+
#endif
16+
517
#define ADDR (0x90)
618
#define FREQ 100000
719
#define SIZE 10
@@ -11,15 +23,23 @@
1123
// the same chip, one configured as master, the other as
1224
// slave.
1325
//
14-
// Wiring: cf below
26+
// Wiring: connect master SCL to slave SCL, and master SDA to slave SDA
1527
// ********************************************************
1628

17-
#if defined (TARGET_NUCLEO_F411RE) || defined (TARGET_NUCLEO_F446RE) || defined (TARGET_NUCLEO_F410RB) || defined (TARGET_NUCLEO_F401RE)
18-
I2C master(PB_9, PB_8); // I2C_1 (Arduino: D14/D15)
19-
I2CSlave slave(PB_3, PB_10); // I2C_2 (Arduino: D3/D6)
20-
#elif defined (TARGET_NUCLEO_F429ZI) || defined (TARGET_DISCO_F429ZI) || defined (TARGET_NUCLEO_F446ZE)
21-
I2C master(PB_9, PB_8); // I2C_1 (Arduino: D14/D15)
22-
I2CSlave slave(PB_11, PB_10); // I2C_2
29+
#if defined (TARGET_DISCO_F429ZI)
30+
I2C master(PB_9, PB_8);
31+
#elif defined(TARGET_FF_ARDUINO)
32+
I2C master(D14, D15); // I2C_SDA, I2C_SCL
33+
#endif
34+
35+
#if defined (TARGET_NUCLEO_F429ZI) || \
36+
defined (TARGET_DISCO_F429ZI) || \
37+
defined (TARGET_NUCLEO_F446ZE)
38+
I2CSlave slave(PB_11, PB_10);
39+
40+
#else
41+
I2CSlave slave(D3, D6);
42+
2343
#endif
2444

2545
volatile int why;

tools/tests.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,8 @@
8989
9090
* i2c_loop:
9191
* LPC1768: (p28 <-> p9), (p27 <-> p10)
92-
* NUCLEO_F401RE: (PB_9 <-> PB_3), (PB_8 <-> PB_10)
93-
* NUCLEO_F410RB: (PB_9 <-> PB_3), (PB_8 <-> PB_10)
94-
* NUCLEO_F411RE: (PB_9 <-> PB_3), (PB_8 <-> PB_10)
95-
* NUCLEO_F446RE: (PB_9 <-> PB_3), (PB_8 <-> PB_10)
96-
* NUCLEO_F429ZI: (PB_9 <-> PB_11), (PB_8 <-> PB_10)
97-
* NUCLEO_F446ZE: (PB_9 <-> PB_11), (PB_8 <-> PB_10)
98-
* DISCO_F429ZI: (PB_9 <-> PB_11), (PB_8 <-> PB_10)
92+
* NUCLEO64: (D14 <-> D3), (D15 <-> D6)
93+
* NUCLEO144: (D14 <-> PB_11), (D15 <-> PB_10)
9994
10095
* i2c_eeprom:
10196
* LPC1*: (SDA=p28 , SCL=p27)
@@ -271,7 +266,7 @@
271266
"id": "MBED_A20", "description": "I2C master/slave test",
272267
"source_dir": join(TEST_DIR, "mbed", "i2c_master_slave"),
273268
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB,],
274-
"mcu": ["LPC1768", "RZ_A1H", "NUCLEO_F411RE", "NUCLEO_F446RE", "NUCLEO_F429ZI", "DISCO_F429ZI", "NUCLEO_F446ZE", "NUCLEO_F410RB", "NUCLEO_F401RE"],
269+
"automated": True,
275270
"peripherals": ["i2c_loop"]
276271
},
277272
{
@@ -346,7 +341,6 @@
346341
"id": "MBED_A29", "description": "i2c_master_slave_asynch",
347342
"source_dir": join(TEST_DIR, "mbed", "i2c_master_slave_asynch"),
348343
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
349-
"mcu": ["NUCLEO_F411RE", "NUCLEO_F446RE", "NUCLEO_F429ZI", "DISCO_F429ZI", "NUCLEO_F446ZE", "NUCLEO_F410RB", "NUCLEO_F401RE"],
350344
"automated": True,
351345
"peripherals": ["i2c_loop"]
352346
},

0 commit comments

Comments
 (0)