Skip to content

i2c_loop tests update for STM32 #3072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 64 additions & 14 deletions features/unsupported/tests/mbed/i2c_master_slave/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,79 @@
#include "test_env.h"
#include <stdio.h>

#if !DEVICE_I2C
#error [NOT_SUPPORTED] I2C is not supported
#endif

#if !DEVICE_I2CSLAVE
#error [NOT_SUPPORTED] I2C Slave is not supported
#endif

#if defined(TARGET_NUCLEO_F031K6) || \
defined (TARGET_NUCLEO_L011K4) || \
defined (TARGET_NUCLEO_L031K6) || \
defined (TARGET_DISCO_F746NG) || \
defined (TARGET_DISCO_L476VG) || \
defined (TARGET_NUCLEO_F303K8) || \
defined (TARGET_NUCLEO_F334R8) || \
defined (TARGET_DISCO_F334C8) || \
defined (TARGET_NUCLEO_F042K6)
#error [NOT_SUPPORTED] Target has only one I2C instance
#endif

#define ADDR (0xA0)
#define FREQ 100000

// ********************************************************
// This tests data transfer between two I2C interfaces on
// the same chip, one configured as master, the other as
// slave. Works on:
//
// *LPC1768 mbed
// p28 <-> p9
// p27 <-> p10
// pull-up resistors on both lines
// *STM32F4 boards
// cf below for wiring
// slave.
//
// Wiring: connect master SCL to slave SCL, and master SDA to slave SDA
// ********************************************************

#if defined(TARGET_NUCLEO_F411RE) || defined (TARGET_NUCLEO_F446RE) || defined (TARGET_NUCLEO_F410RB) || defined (TARGET_NUCLEO_F401RE)
I2C master(PB_9, PB_8); // I2C_1 (Arduino: D14/D15)
I2CSlave slave(PB_3, PB_10); // I2C_2 (Arduino: D3/D6)
#elif defined (TARGET_NUCLEO_F429ZI) || defined (TARGET_DISCO_F429ZI) || defined (TARGET_NUCLEO_F446ZE)
I2C master(PB_9, PB_8); // I2C_1 (Arduino: D14/D15)
I2CSlave slave(PB_11, PB_10); // I2C_2
#if defined (TARGET_DISCO_F429ZI) || \
defined (TARGET_DISCO_L053C8)
I2C master(PB_9, PB_8);

#elif defined(TARGET_FF_ARDUINO)
I2C master(D14, D15); // I2C_SDA, I2C_SCL
#endif


#if defined (TARGET_NUCLEO_F429ZI) || \
defined (TARGET_NUCLEO_F767ZI) || \
defined (TARGET_NUCLEO_L053R8) || \
defined (TARGET_NUCLEO_L073RZ) || \
defined (TARGET_NUCLEO_L152RE) || \
defined (TARGET_NUCLEO_L476RG) || \
defined (TARGET_NUCLEO_F207ZG) || \
defined (TARGET_NUCLEO_F103RB) || \
defined (TARGET_NUCLEO_F091RC) || \
defined (TARGET_DISCO_F429ZI) || \
defined (TARGET_DISCO_F469NI) || \
defined (TARGET_DISCO_L053C8) || \
defined (TARGET_NUCLEO_F446ZE)
I2CSlave slave(PB_11, PB_10);

#elif defined (TARGET_NUCLEO_F303RE) || \
defined (TARGET_NUCLEO_F302R8)
I2CSlave slave(D2, D8);

#elif defined (TARGET_NUCLEO_F303ZE)
I2CSlave slave(PC_9, PA_8);

#elif defined (TARGET_NUCLEO_F746ZG)
I2CSlave slave(D2, D4);

#elif defined (TARGET_NUCLEO_F030R8) || \
defined (TARGET_NUCLEO_F070RB) || \
defined (TARGET_NUCLEO_F072RB)
I2CSlave slave(PB_11, D6);

#else
I2CSlave slave(D3, D6);

#endif

int main()
Expand Down
34 changes: 27 additions & 7 deletions features/unsupported/tests/mbed/i2c_master_slave_asynch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
#include "test_env.h"
#include <stdio.h>

#if !DEVICE_I2C
#error [NOT_SUPPORTED] I2C is not supported
#endif

#if !DEVICE_I2CSLAVE
#error [NOT_SUPPORTED] I2C Slave is not supported
#endif

#if !DEVICE_I2C_ASYNCH
#error [NOT_SUPPORTED] I2C Async is not supported
#endif

#define ADDR (0x90)
#define FREQ 100000
#define SIZE 10
Expand All @@ -11,15 +23,23 @@
// the same chip, one configured as master, the other as
// slave.
//
// Wiring: cf below
// Wiring: connect master SCL to slave SCL, and master SDA to slave SDA
// ********************************************************

#if defined (TARGET_NUCLEO_F411RE) || defined (TARGET_NUCLEO_F446RE) || defined (TARGET_NUCLEO_F410RB) || defined (TARGET_NUCLEO_F401RE)
I2C master(PB_9, PB_8); // I2C_1 (Arduino: D14/D15)
I2CSlave slave(PB_3, PB_10); // I2C_2 (Arduino: D3/D6)
#elif defined (TARGET_NUCLEO_F429ZI) || defined (TARGET_DISCO_F429ZI) || defined (TARGET_NUCLEO_F446ZE)
I2C master(PB_9, PB_8); // I2C_1 (Arduino: D14/D15)
I2CSlave slave(PB_11, PB_10); // I2C_2
#if defined (TARGET_DISCO_F429ZI)
I2C master(PB_9, PB_8);
#elif defined(TARGET_FF_ARDUINO)
I2C master(D14, D15); // I2C_SDA, I2C_SCL
#endif

#if defined (TARGET_NUCLEO_F429ZI) || \
defined (TARGET_DISCO_F429ZI) || \
defined (TARGET_NUCLEO_F446ZE)
I2CSlave slave(PB_11, PB_10);

#else
I2CSlave slave(D3, D6);

#endif

volatile int why;
Expand Down
12 changes: 3 additions & 9 deletions tools/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,8 @@

* i2c_loop:
* LPC1768: (p28 <-> p9), (p27 <-> p10)
* NUCLEO_F401RE: (PB_9 <-> PB_3), (PB_8 <-> PB_10)
* NUCLEO_F410RB: (PB_9 <-> PB_3), (PB_8 <-> PB_10)
* NUCLEO_F411RE: (PB_9 <-> PB_3), (PB_8 <-> PB_10)
* NUCLEO_F446RE: (PB_9 <-> PB_3), (PB_8 <-> PB_10)
* NUCLEO_F429ZI: (PB_9 <-> PB_11), (PB_8 <-> PB_10)
* NUCLEO_F446ZE: (PB_9 <-> PB_11), (PB_8 <-> PB_10)
* DISCO_F429ZI: (PB_9 <-> PB_11), (PB_8 <-> PB_10)
* NUCLEO64: (D14 <-> D3), (D15 <-> D6)
* NUCLEO144: (D14 <-> PB_11), (D15 <-> PB_10)

* i2c_eeprom:
* LPC1*: (SDA=p28 , SCL=p27)
Expand Down Expand Up @@ -271,7 +266,7 @@
"id": "MBED_A20", "description": "I2C master/slave test",
"source_dir": join(TEST_DIR, "mbed", "i2c_master_slave"),
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB,],
"mcu": ["LPC1768", "RZ_A1H", "NUCLEO_F411RE", "NUCLEO_F446RE", "NUCLEO_F429ZI", "DISCO_F429ZI", "NUCLEO_F446ZE", "NUCLEO_F410RB", "NUCLEO_F401RE"],
"automated": True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the intention here?

cc @bridadan

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question comes because the commit does not specify this change, and might not be related to the changes above (tests changes) ?

Copy link
Contributor

@bridadan bridadan Oct 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

automated just means that the test will be ran automatically if no test names are specified. It will still require the peripheral i2c_loop to be specified on the command line though, so it shouldn't cause issues.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense ? @jeromecoutant please details?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the change makes sense, since the test is completely automated (meaning requires no human interaction, which some of the mbed 2 tests do).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I'm back and agree with Brian
Thx

"peripherals": ["i2c_loop"]
},
{
Expand Down Expand Up @@ -352,7 +347,6 @@
"id": "MBED_A29", "description": "i2c_master_slave_asynch",
"source_dir": join(TEST_DIR, "mbed", "i2c_master_slave_asynch"),
"dependencies": [MBED_LIBRARIES, TEST_MBED_LIB],
"mcu": ["NUCLEO_F411RE", "NUCLEO_F446RE", "NUCLEO_F429ZI", "DISCO_F429ZI", "NUCLEO_F446ZE", "NUCLEO_F410RB", "NUCLEO_F401RE"],
"automated": True,
"peripherals": ["i2c_loop"]
},
Expand Down