Skip to content

TARGET_NRF5: reworked i2c_api.c #3812

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 3 commits into from
Feb 21, 2017
Merged

TARGET_NRF5: reworked i2c_api.c #3812

merged 3 commits into from
Feb 21, 2017

Conversation

anangl
Copy link
Contributor

@anangl anangl commented Feb 21, 2017

Description

i2c_api implementation has been changed in order to support single byte reads and writes (the latter are used in I2CEeprom module used in CI tests, and this caused that tests-i2c-api were failing). These operations (single byte transfers) are not possible to achieve with the driver from nrf5 SDK (nrf_drv_twi), so the new implementation uses TWI HAL only.

This PR addresses issue #3392, too.

Status

READY

Migrations

NO

@anangl
Copy link
Contributor Author

anangl commented Feb 21, 2017

@nvlsianpu @pan- @0xc0170 Could you take a look?

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 21, 2017

@anangl Can you share the test results from CI?

@anangl
Copy link
Contributor Author

anangl commented Feb 21, 2017

Here are the results:

mbedgt: greentea test automation tool ver. 1.2.5
mbedgt: test specification file 'C:\mbed\ci-test-shield\BUILD\tests\NRF52_DK\GCC_ARM\test_spec.json' (specified with --test-spec option)
mbedgt: using 'C:\mbed\ci-test-shield\BUILD\tests\NRF52_DK\GCC_ARM\test_spec.json' from current directory!
mbedgt: detecting connected mbed-enabled devices...
mbedgt: detected 1 device
mbedgt: processing target 'NRF52_DK' toolchain 'GCC_ARM' compatible platforms... (note: switch set to --parallel 1)
mbedgt: test case filter (specified with -n option)
	test filtered in 'tests-api-i2c'
mbedgt: running 1 test for platform 'NRF52_DK' and toolchain 'GCC_ARM'
mbedgt: mbed-host-test-runner: started
mbedgt: checking for GCOV data...
mbedgt: test on hardware with target id: 1101021944203120314854373130392037313034B9C6DFD9
mbedgt: test suite 'tests-api-i2c' ................................................................... OK in 17.34 sec
	test case: 'I2C -  EEProm WR 10  Bytes' ...................................................... OK in 0.06 sec
	test case: 'I2C -  EEProm WR 100 Bytes' ...................................................... OK in 0.07 sec
	test case: 'I2C -  EEProm WR 2 Bytes' ........................................................ OK in 0.06 sec
	test case: 'I2C -  EEProm WR Single Byte' .................................................... OK in 0.06 sec
	test case: 'I2C -  Instantiation of I2C Object' .............................................. OK in 0.07 sec
	test case: 'I2C -  LM75B Temperature Read' ................................................... OK in 0.07 sec
mbedgt: test case summary: 6 passes, 0 failures
mbedgt: all tests finished!
mbedgt: shuffle seed: 0.1492364450
mbedgt: test suite report:
+------------------+---------------+---------------+--------+--------------------+-------------+
| target           | platform_name | test suite    | result | elapsed_time (sec) | copy_method |
+------------------+---------------+---------------+--------+--------------------+-------------+
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | OK     | 17.34              | shell       |
+------------------+---------------+---------------+--------+--------------------+-------------+
mbedgt: test suite results: 1 OK
mbedgt: test case report:
+------------------+---------------+---------------+------------------------------------+--------+--------+--------+--------------------+
| target           | platform_name | test suite    | test case                          | passed | failed | result | elapsed_time (sec) |
+------------------+---------------+---------------+------------------------------------+--------+--------+--------+--------------------+
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  EEProm WR 10  Bytes         | 1      | 0      | OK     | 0.06               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  EEProm WR 100 Bytes         | 1      | 0      | OK     | 0.07               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  EEProm WR 2 Bytes           | 1      | 0      | OK     | 0.06               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  EEProm WR Single Byte       | 1      | 0      | OK     | 0.06               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  Instantiation of I2C Object | 1      | 0      | OK     | 0.07               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  LM75B Temperature Read      | 1      | 0      | OK     | 0.07               |
+------------------+---------------+---------------+------------------------------------+--------+--------+--------+--------------------+
mbedgt: test case results: 6 OK
mbedgt: completed in 20.06 sec

@anangl
Copy link
Contributor Author

anangl commented Feb 21, 2017

And for NRF51:

mbedgt: greentea test automation tool ver. 1.2.5
mbedgt: test specification file 'C:\mbed\ci-test-shield\BUILD\tests\NRF51_DK\GCC_ARM\test_spec.json' (specified with --test-spec option)
mbedgt: using 'C:\mbed\ci-test-shield\BUILD\tests\NRF51_DK\GCC_ARM\test_spec.json' from current directory!
mbedgt: detecting connected mbed-enabled devices...
mbedgt: detected 1 device
mbedgt: processing target 'NRF51_DK' toolchain 'GCC_ARM' compatible platforms... (note: switch set to --parallel 1)
mbedgt: test case filter (specified with -n option)
	test filtered in 'tests-api-i2c'
mbedgt: running 1 test for platform 'NRF51_DK' and toolchain 'GCC_ARM'
mbedgt: mbed-host-test-runner: started
mbedgt: checking for GCOV data...
mbedgt: test on hardware with target id: 1100021952333120353935373230323134303035AFD5DFD8
mbedgt: test suite 'tests-api-i2c' ................................................................... OK in 15.58 sec
	test case: 'I2C -  EEProm WR 10  Bytes' ...................................................... OK in 0.06 sec
	test case: 'I2C -  EEProm WR 100 Bytes' ...................................................... OK in 0.08 sec
	test case: 'I2C -  EEProm WR 2 Bytes' ........................................................ OK in 0.07 sec
	test case: 'I2C -  EEProm WR Single Byte' .................................................... OK in 0.07 sec
	test case: 'I2C -  Instantiation of I2C Object' .............................................. OK in 0.07 sec
	test case: 'I2C -  LM75B Temperature Read' ................................................... OK in 0.06 sec
mbedgt: test case summary: 6 passes, 0 failures
mbedgt: all tests finished!
mbedgt: shuffle seed: 0.8143278334
mbedgt: test suite report:
+------------------+---------------+---------------+--------+--------------------+-------------+
| target           | platform_name | test suite    | result | elapsed_time (sec) | copy_method |
+------------------+---------------+---------------+--------+--------------------+-------------+
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | OK     | 15.58              | shell       |
+------------------+---------------+---------------+--------+--------------------+-------------+
mbedgt: test suite results: 1 OK
mbedgt: test case report:
+------------------+---------------+---------------+------------------------------------+--------+--------+--------+--------------------+
| target           | platform_name | test suite    | test case                          | passed | failed | result | elapsed_time (sec) |
+------------------+---------------+---------------+------------------------------------+--------+--------+--------+--------------------+
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  EEProm WR 10  Bytes         | 1      | 0      | OK     | 0.06               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  EEProm WR 100 Bytes         | 1      | 0      | OK     | 0.08               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  EEProm WR 2 Bytes           | 1      | 0      | OK     | 0.07               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  EEProm WR Single Byte       | 1      | 0      | OK     | 0.07               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  Instantiation of I2C Object | 1      | 0      | OK     | 0.07               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  LM75B Temperature Read      | 1      | 0      | OK     | 0.06               |
+------------------+---------------+---------------+------------------------------------+--------+--------+--------+--------------------+
mbedgt: test case results: 6 OK
mbedgt: completed in 19.94 sec

nrf_delay_us(4);

for (int i = 0; i < 9; i++)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

please fix the style as it is in the rest of the code for this function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 21, 2017

Just small changes, the rest LGMT. will fire CI once addressed.

Thanks for sharing the tests ! Always good to have as part of a patch!

@anangl
Copy link
Contributor Author

anangl commented Feb 21, 2017

Just realized that CI tests have been updated since I cloned the repository. Here are the refreshed test results:

mbedgt: test case summary: 10 passes, 0 failures
mbedgt: all tests finished!
mbedgt: shuffle seed: 0.5478125906
mbedgt: test suite report:
+------------------+---------------+---------------+--------+--------------------+-------------+
| target           | platform_name | test suite    | result | elapsed_time (sec) | copy_method |
+------------------+---------------+---------------+--------+--------------------+-------------+
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | OK     | 19.02              | shell       |
+------------------+---------------+---------------+--------+--------------------+-------------+
mbedgt: test suite results: 1 OK
mbedgt: test case report:
+------------------+---------------+---------------+------------------------------------+--------+--------+--------+--------------------+
| target           | platform_name | test suite    | test case                          | passed | failed | result | elapsed_time (sec) |
+------------------+---------------+---------------+------------------------------------+--------+--------+--------+--------------------+
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  EEProm 2nd WR 10  Bytes     | 1      | 0      | OK     | 0.06               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  EEProm 2nd WR 100 Bytes     | 1      | 0      | OK     | 0.08               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  EEProm 2nd WR 2 Bytes       | 1      | 0      | OK     | 0.06               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  EEProm 2nd WR Single Byte   | 1      | 0      | OK     | 0.06               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  EEProm WR 10  Bytes         | 1      | 0      | OK     | 0.06               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  EEProm WR 100 Bytes         | 1      | 0      | OK     | 0.08               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  EEProm WR 2 Bytes           | 1      | 0      | OK     | 0.05               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  EEProm WR Single Byte       | 1      | 0      | OK     | 0.06               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  Instantiation of I2C Object | 1      | 0      | OK     | 0.06               |
| NRF52_DK-GCC_ARM | NRF52_DK      | tests-api-i2c | I2C -  LM75B Temperature Read      | 1      | 0      | OK     | 0.06               |
+------------------+---------------+---------------+------------------------------------+--------+--------+--------+--------------------+
mbedgt: test case results: 10 OK
mbedgt: test case summary: 10 passes, 0 failures
mbedgt: all tests finished!
mbedgt: shuffle seed: 0.7769810228
mbedgt: test suite report:
+------------------+---------------+---------------+--------+--------------------+-------------+
| target           | platform_name | test suite    | result | elapsed_time (sec) | copy_method |
+------------------+---------------+---------------+--------+--------------------+-------------+
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | OK     | 17.22              | shell       |
+------------------+---------------+---------------+--------+--------------------+-------------+
mbedgt: test suite results: 1 OK
mbedgt: test case report:
+------------------+---------------+---------------+------------------------------------+--------+--------+--------+--------------------+
| target           | platform_name | test suite    | test case                          | passed | failed | result | elapsed_time (sec) |
+------------------+---------------+---------------+------------------------------------+--------+--------+--------+--------------------+
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  EEProm 2nd WR 10  Bytes     | 1      | 0      | OK     | 0.07               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  EEProm 2nd WR 100 Bytes     | 1      | 0      | OK     | 0.09               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  EEProm 2nd WR 2 Bytes       | 1      | 0      | OK     | 0.06               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  EEProm 2nd WR Single Byte   | 1      | 0      | OK     | 0.07               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  EEProm WR 10  Bytes         | 1      | 0      | OK     | 0.07               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  EEProm WR 100 Bytes         | 1      | 0      | OK     | 0.09               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  EEProm WR 2 Bytes           | 1      | 0      | OK     | 0.06               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  EEProm WR Single Byte       | 1      | 0      | OK     | 0.06               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  Instantiation of I2C Object | 1      | 0      | OK     | 0.06               |
| NRF51_DK-GCC_ARM | NRF51_DK      | tests-api-i2c | I2C -  LM75B Temperature Read      | 1      | 0      | OK     | 0.06               |
+------------------+---------------+---------------+------------------------------------+--------+--------+--------+--------------------+
mbedgt: test case results: 10 OK

@0xc0170
Copy link
Contributor

0xc0170 commented Feb 21, 2017

/morph test

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 1664

All builds and test passed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants