Skip to content

Improve uart gpio test #25

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 5 commits into from
Jun 6, 2025
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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Repo as shared ardino core tests using unity platform.
## Pre-conditions
Before running Unity tests, please ensure the following pre-conditions are met:

1. **Install Arduino CLI**:
- Download and install Arduino CLI. You can download the Windows version of Arduino CLI from the following link:
[Arduino CLI Download Link](https://downloads.arduino.cc/arduino-cli/arduino-cli_latest_Windows_64bit.zip)
- Add `arduino-cli.exe` to your system's PATH environment variable to access it from the command line.

2. **Update submodule**:
### Install Arduino CLI:
- Download and install Arduino CLI: https://arduino.github.io/arduino-cli/latest/installation/
You may need to add it to your system's PATH environment variable to access it from terminal.
### Install Make:
- Install GNU make: https://www.gnu.org/software/make/. We use currently Makefile to manage how we execute different tests.
### Update submodule:
- The Unity test framework is included as submodule in this project. The Unity test framework files should be located in the `unity` folder. Run `git submodule update --init --recursive` to update them. If you are nor familiar with submodules, check out: https://git-scm.com/book/en/v2/Git-Tools-Submodules

## Usage
Expand Down
7 changes: 6 additions & 1 deletion src/corelibs/digitalio/test_digitalio_single.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ TEST_IFX(digitalio_single_internal, test_digitalio_read_write_output_opendrain)

TEST_ASSERT_EQUAL_MESSAGE(LOW, digitalRead(TEST_PIN_DIGITAL_IO_INPUT), "Input Pin should be set to LOW initially");

digitalWrite(TEST_PIN_DIGITAL_IO_OUTPUT, HIGH);
digitalWrite(TEST_PIN_DIGITAL_IO_OUTPUT, HIGH);
Copy link
Member

Choose a reason for hiding this comment

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

In the setup, there should be some pull-up resistor no? Or we plan also to test the floating pin?

Copy link
Collaborator Author

@LinjingZhang LinjingZhang Jun 6, 2025

Choose a reason for hiding this comment

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

When I tested it, I just used the jumper to connect the two pins like in the description, without any additional resistor:

/* test_digitalio_single.cpp
*

  • This test is used to verify the functionality of the Digital IO module.
  • only one board is needed with TEST_PIN_DIGITAL_IO_OUTPUT pin connected to
  • TEST_PIN_DIGITAL_IO_INPUT pin for the test cases to work as expected.
    */

XMC fails if check the high state since it is floting?

#if defined(ARDUINO_ARCH_PSOC6)
TEST_ASSERT_EQUAL_MESSAGE(HIGH, digitalRead(TEST_PIN_DIGITAL_IO_INPUT), "Input Pin should be set to HIGH");
#endif // ARDUINO_ARCH_PSOC6
// Skip assert as it may not be set to HIGH due to open-drain configuration
digitalWrite(TEST_PIN_DIGITAL_IO_OUTPUT, LOW);
TEST_ASSERT_EQUAL_MESSAGE(LOW, digitalRead(TEST_PIN_DIGITAL_IO_INPUT), "Input Pin should be set to LOW");
}
Expand Down Expand Up @@ -159,10 +162,12 @@ static TEST_GROUP_RUNNER(digitalio_single_internal)
RUN_TEST_CASE(digitalio_single_internal, test_digitalio_read_write_input_pullup);
RUN_TEST_CASE(digitalio_single_internal, test_digitalio_read_write_input_pulldown);
RUN_TEST_CASE(digitalio_single_internal, test_digitalio_read_write_output_opendrain);
#if !defined(ARDUINO_ARCH_XMC)
RUN_TEST_CASE(digitalio_single_internal, test_pinMode_invalid_pin);
RUN_TEST_CASE(digitalio_single_internal, test_digitalWrite_invalid_pin);
RUN_TEST_CASE(digitalio_single_internal, test_digitalRead_invalid_pin);
RUN_TEST_CASE(digitalio_single_internal, test_invalid_pinmode);
#endif // ARDUINO_ARCH_XMC skip these tests.
}

/**
Expand Down
26 changes: 26 additions & 0 deletions src/corelibs/uart/test_uart_connected2_rx.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/*
* test_uart_connected2_rx.cpp
*
* This file contains tests for UART communication using the Arduino framework.
* It verifies the ability to send and receive data between UART devices at
* different baud rates and ensures the proper functioning of UART APIs.
*
* The tests use Serial1 (or more Serial instances) for UART communication
* and Serial for reporting test results.
* To run this test file, you need two boards, each with two or more serial ports enabled,
* with their respective TX and RX ports connected.
*
* Example for each Serial:
*
* terminal
* | ^
* v Serial |
* RX ^ TX
* |
* report status
* |
* TX <---> RX
* Serial1
*/


// std includes

// test includes
Expand Down
25 changes: 25 additions & 0 deletions src/corelibs/uart/test_uart_connected2_tx.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
/*
* test_uart_connected2_tx.cpp
*
* This file contains tests for UART communication using the Arduino framework.
* It verifies the ability to send and receive data between UART devices at
* different baud rates and ensures the proper functioning of UART APIs.
*
* The tests use Serial1 (or more Serial instances) for UART communication
* and Serial for reporting test results.
* To run this test file, you need two boards, each with two or more serial ports enabled,
* with their respective TX and RX ports connected.
*
* Example for each Serial:
*
* terminal
* | ^
* v Serial |
* RX ^ TX
* |
* report status
* |
* TX <---> RX
* Serial1
*/

// std includes

// test includes
Expand Down