Skip to content
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

Fix UART test settings and re-enable tests #224

Merged
merged 2 commits into from
Nov 22, 2023
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
11 changes: 6 additions & 5 deletions modules/drivers/uart/src/rtos_uart_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// This Software is subject to the terms of the XMOS Public Licence: Version 1.

#define DEBUG_UNIT RTOS_UART_RX
#define DEBUG_PRINT_ENABLE_RTOS_UART_RX 1

#include <xcore/triggerable.h>
#include <string.h>
Expand All @@ -18,7 +17,7 @@ DEFINE_RTOS_INTERRUPT_CALLBACK(rtos_uart_rx_isr, arg)

/* Grab byte received from rx which triggered ISR */
uint8_t byte = s_chan_in_byte(ctx->c.end_b);

BaseType_t pxHigherPriorityTaskWoken = pdFALSE;

/* We already know the task handle of the receiver so cast to correct type */
Expand All @@ -44,6 +43,8 @@ static void uart_rx_error_callback(uart_callback_code_t callback_code, void * ap

static void uart_rx_hil_thread(rtos_uart_rx_t *ctx)
{
rtos_printf("UART Rx on tile %d core %d\n", THIS_XCORE_TILE, rtos_core_id_get());
xluciano marked this conversation as resolved.
Show resolved Hide resolved

/* consume token (synch with RTOS driver) */
(void) s_chan_in_byte(ctx->c.end_a);

Expand Down Expand Up @@ -80,7 +81,7 @@ static void uart_rx_app_thread(rtos_uart_rx_t *ctx)
bytes_read += 1;
} while(ret == UART_BUFFER_OK);
bytes_read -= 1; /* important as we incremented this for the last read fail too */

if(bytes_read){
size_t xBytesSent = xStreamBufferSend(ctx->app_byte_buffer, bytes, bytes_read, 0);

Expand Down Expand Up @@ -149,7 +150,7 @@ void rtos_uart_rx_init(
uart_rx_error_callback,
uart_rx_ctx
);


uart_rx_ctx->c = s_chan_alloc();

Expand Down Expand Up @@ -177,7 +178,7 @@ void rtos_uart_rx_start(
unsigned interrupt_core_id,
unsigned priority,
size_t app_rx_buff_size){

/* Init callbacks & args */
uart_rx_ctx->app_data = app_data;
uart_rx_ctx->rx_start_cb = rx_start;
Expand Down
5 changes: 2 additions & 3 deletions modules/drivers/uart/src/rtos_uart_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// This Software is subject to the terms of the XMOS Public Licence: Version 1.

#define DEBUG_UNIT RTOS_UART_TX
#define DEBUG_PRINT_ENABLE_RTOS_UART_TX 1

#include "rtos_uart_tx.h"

Expand All @@ -21,7 +20,7 @@ static void uart_tx_local_write(
uart_tx(&ctx->dev, buff[i]);
rtos_interrupt_unmask_all();
}

rtos_osal_mutex_put(&ctx->lock);
}

Expand All @@ -44,7 +43,7 @@ void rtos_uart_tx_init(
const uart_parity_t parity,
const uint8_t stop_bits,
hwtimer_t tmr){

//uart init
uart_tx_blocking_init(
&ctx->dev,
Expand Down
3 changes: 2 additions & 1 deletion test/rtos_drivers/hil_add/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ Description

The RTOS driver tests are designed to regression test RTOS driver behavior for the following drivers:

- spi
- qspi_fast_read
- spi
- uart

These tests assume that the associated RTOS and HILs used have been verified by their own localized separate testing.

Expand Down
2 changes: 1 addition & 1 deletion test/rtos_drivers/hil_add/hil_add.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Individual tests
#**********************
set(SPI_TEST 1)
set(UART_TEST 0) # Appears to be broken
set(UART_TEST 1)
set(QSPI_FLASH_FAST_READ_TEST 1)

#**********************
Expand Down
2 changes: 1 addition & 1 deletion test/rtos_drivers/hil_add/src/app_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define SPI_TEST_BUF_SIZE 4096

#define UART_RX_CORE_MASK (1 << 2)
#define UART_RX_ISR_CORE 2
#define UART_RX_ISR_CORE 3
Copy link
Contributor

Choose a reason for hiding this comment

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

Great find!

#define UART_BAUD_RATE 921600


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ static void start_uart_devices(uart_test_ctx_t *test_ctx)
rtos_uart_rx_started,
rtos_uart_rx_complete,
rtos_uart_rx_error,
(1 << UART_RX_ISR_CORE),
Copy link
Contributor

Choose a reason for hiding this comment

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

Crikey this was a major fail originally..

UART_RX_ISR_CORE,
appconfSTARTUP_TASK_PRIORITY,
1024 // Big enough to hold tx_buff[] many times over
);
Expand Down
20 changes: 10 additions & 10 deletions test/rtos_drivers/hil_add/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,26 @@ void vApplicationDaemonTaskStartup(void *arg)
test_printf("SKIP QSPI_FLASH_FAST_READ");
}

if (RUN_UART_TESTS) {
if (uart_device_tests(rtos_uart_tx_ctx, rtos_uart_rx_ctx, other_tile_c) != 0)
if (RUN_SPI_TESTS) {
if (spi_device_tests(spi_master_ctx, test_spi_device_ctx, spi_slave_ctx, other_tile_c) != 0)
{
test_printf("FAIL UART");
test_printf("FAIL SPI");
} else {
test_printf("PASS UART");
test_printf("PASS SPI");
}
} else {
test_printf("SKIP UART");
test_printf("SKIP SPI");
}

if (RUN_SPI_TESTS) {
if (spi_device_tests(spi_master_ctx, test_spi_device_ctx, spi_slave_ctx, other_tile_c) != 0)
if (RUN_UART_TESTS) {
if (uart_device_tests(rtos_uart_tx_ctx, rtos_uart_rx_ctx, other_tile_c) != 0)
{
test_printf("FAIL SPI");
test_printf("FAIL UART");
} else {
test_printf("PASS SPI");
test_printf("PASS UART");
}
} else {
test_printf("SKIP SPI");
test_printf("SKIP UART");
}

_Exit(0);
Expand Down