Skip to content
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ unity: print_args clean check_unity_path
$(Q) find $(UNITY_PATH) -name '*.[hc]' \( -path '*extras*' -a -path '*src*' -or -path '*src*' -a \! -path '*example*' \) -exec \cp {} build \;
$(Q) find src/utils -name '*.[hc]*' -exec \cp {} build \;
$(Q) find src -maxdepth 1 -name '*.[hc]*' -exec \cp {} build \;
$(Q) find ../ -maxdepth 1 -name 'test_config.*' -exec \cp {} build \;
$(Q) find ../../tests -maxdepth 1 -name 'test_config.*' -exec \cp {} build \;
$(Q) cp src/test_main.ino build/build.ino

# Helper to extract the second word from the target name
Expand Down
43 changes: 37 additions & 6 deletions src/corelibs/analogio/test_analogio_adc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,34 +77,65 @@ static TEST_SETUP(analogio_adc) {
* @brief Tear down method called by Unity after every test in this test group.
*/
static TEST_TEAR_DOWN(analogio_adc) {
analogReadResolution(TEST_ADC_RESOLUTION);
}

#ifdef TEST_PIN_ANALOG_IO_VREF

/**
* @brief Verify ADC value for the DEFAULT volatage reference on the pin that is connected to VDDA
* @brief Verify ADC value for the DEFAULT volatage reference on the pin that is connected to VDDA with various resolution values
*/
TEST_IFX(analogio_adc, test_adc_read_default_vdda_vref_pin)
{
analogReference(DEFAULT);
int adc_value = analogRead(TEST_PIN_ANALOG_IO_VREF);
int expected_value = TEST_ADC_RESOLUTION;
TEST_ASSERT_TRUE_MESSAGE(validate_adc_raw_value(expected_value, adc_value), "ADC value is not within the expected range");
int expected_value = TEST_ADC_MAX_VALUE;
TEST_ASSERT_TRUE_MESSAGE(validate_adc_raw_value(expected_value, adc_value), "ADC value is not within the expected range for default resolution");

const int resolutions[] = {8, 10, 12};
const int num_resolutions = sizeof(resolutions) / sizeof(resolutions[0]);

for (int i = 0; i < num_resolutions; i++)
{
int resolution = resolutions[i];
analogReadResolution(resolution);

adc_value = analogRead(TEST_PIN_ANALOG_IO_VREF); // Perform ADC read

int expected_value = (1 << resolution) - 1; // 2^resolution - 1
TEST_ASSERT_TRUE_MESSAGE(validate_adc_raw_value(expected_value, adc_value), "ADC value does not match expected resolution range");
}
}

#endif // TEST_PIN_ANALOG_IO_VREF

#ifdef TEST_PIN_ANALOG_IO_DIVIDER

/**
* @brief Verify ADC value for the DEFAULT volatage reference on the pin that is connected to voltage divider.
* @brief Verify ADC value for the DEFAULT volatage reference on the pin that is connected to voltage divider with various resolution values.
*/
TEST_IFX(analogio_adc, test_adc_read_default_vdda_divider_pin)
{
analogReference(DEFAULT); // Configure reference to VDDA
int adc_value = analogRead(TEST_PIN_ANALOG_IO_DIVIDER);
int expected_value = TEST_ADC_RESOLUTION / 2;
TEST_ASSERT_TRUE_MESSAGE(validate_adc_raw_value(expected_value, adc_value), "ADC value is not within the expected range");
int expected_value = TEST_ADC_MAX_VALUE / 2;
TEST_ASSERT_TRUE_MESSAGE(validate_adc_raw_value(expected_value, adc_value), "ADC value is not within the expected range for default resolution");

const int resolutions[] = {8, 10, 12};
const int num_resolutions = sizeof(resolutions) / sizeof(resolutions[0]);

for (int i = 0; i < num_resolutions; i++)
{
int resolution = resolutions[i];
analogReadResolution(resolution);

adc_value = analogRead(TEST_PIN_ANALOG_IO_DIVIDER);

int expected_value = (1 << resolution) - 1; // 2^resolution - 1
expected_value = expected_value / 2;

TEST_ASSERT_TRUE_MESSAGE(validate_adc_raw_value(expected_value, adc_value), "ADC value does not match expected resolution range");
}
}

#endif // TEST_PIN_ANALOG_IO_DIVIDER
Expand Down
1 change: 0 additions & 1 deletion src/corelibs/spi/test_spi_connected1_loopback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ TEST_IFX(spi_connected1_loopback, test_spi_mode_configuration) {
TEST_IFX(spi_connected1_loopback, test_spi_reinitialization) {
spi->end();
spi->begin();
TEST_ASSERT_EQUAL_MESSAGE(CY_RSLT_SUCCESS, spi->status, "SPI reinitialization failed");
}

// Define test runner for the SPI test group
Expand Down
1 change: 0 additions & 1 deletion src/corelibs/uart/test_uart_connected2_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ static void uart_connected2_rx_suite_setup() {

// Method invoked after a test suite is run.
static void uart_connected2_rx_suite_teardown() {
uart->end(); // End UART communication
}

// define test group name
Expand Down
1 change: 0 additions & 1 deletion src/corelibs/uart/test_uart_connected2_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ static void uart_connected2_tx_suite_setup() {

// Method invoked after a test suite is run.
static void uart_connected2_tx_suite_teardown() {
uart->end(); // End UART communication
}

// define test group name
Expand Down
4 changes: 0 additions & 4 deletions src/corelibs/uart/test_uart_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,5 @@ TEST_GROUP_RUNNER(uart_rx) {
RUN_TEST_CASE(uart_rx, check_no_available_read_peek);
RUN_TEST_CASE(uart_rx, write_reply_back);
RUN_TEST_CASE(uart_rx, end);
/* Wait forever for now. */
/* This allows to check the rx
test manually. */
while(true) {};
}

4 changes: 0 additions & 4 deletions src/corelibs/uart/test_uart_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,4 @@ TEST_GROUP_RUNNER(uart_tx) {
RUN_TEST_CASE(uart_tx, read_reply);
RUN_TEST_CASE(uart_tx, end);
uart_tx_suite_teardown();
/* Wait forever for now. */
/* This allows to check the tx
test manually. */
while(true) {};
}