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

Minor update to SPI and USART driver validation #16

Merged
merged 1 commit into from
Jul 5, 2024
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
6 changes: 4 additions & 2 deletions ARM.CMSIS-Driver_Validation.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
Active Development ...
- Add GPIO Driver validation
- Improve Ethernet driver validation
- Minor update to SPI driver validation
- Minor update to USART driver validation
- Update examples
- Update documentation
</release>
Expand Down Expand Up @@ -160,7 +162,7 @@
</files>
</component>

<component Cclass="CMSIS Driver Validation" Cgroup="SPI" Cversion="2.1.2" condition="CMSIS Driver Validation SPI">
<component Cclass="CMSIS Driver Validation" Cgroup="SPI" Cversion="2.1.3" condition="CMSIS Driver Validation SPI">
<description>SPI driver validation</description>
<RTE_Components_h>
#define RTE_CMSIS_DV_SPI /* Driver Validation SPI enabled */
Expand All @@ -184,7 +186,7 @@
</files>
</component>

<component Cclass="CMSIS Driver Validation" Cgroup="USART" Cversion="2.0.0" condition="CMSIS Driver Validation USART">
<component Cclass="CMSIS Driver Validation" Cgroup="USART" Cversion="2.0.1" condition="CMSIS Driver Validation USART">
<description>USART driver validation</description>
<RTE_Components_h>
#define RTE_CMSIS_DV_USART /* Driver Validation USART enabled */
Expand Down
36 changes: 22 additions & 14 deletions Source/DV_SPI.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2022 Arm Limited. All rights reserved.
* Copyright (c) 2015-2024 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -384,7 +384,7 @@ static int32_t ComConfigDefault (void) {
*/
static int32_t ComSendCommand (const void *data_out, uint32_t len) {
int32_t ret;
uint32_t flags, num, tout;
uint32_t flags, num;

ret = EXIT_SUCCESS;
num = (len + DataBitsToBytes(SPI_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(SPI_CFG_SRV_DATA_BITS);
Expand Down Expand Up @@ -430,7 +430,7 @@ static int32_t ComSendCommand (const void *data_out, uint32_t len) {
*/
static int32_t ComReceiveResponse (void *data_in, uint32_t len) {
int32_t ret;
uint32_t flags, num, tout;
uint32_t flags, num;

ret = EXIT_SUCCESS;
num = (len + DataBitsToBytes(SPI_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(SPI_CFG_SRV_DATA_BITS);
Expand Down Expand Up @@ -762,7 +762,7 @@ static int32_t CmdSetCom (uint32_t mode, uint32_t format, uint32_t data_bits, ui
// Send "SET COM" command to SPI Server
memset(ptr_tx_buf, 0, CMD_LEN);
stat = snprintf((char *)ptr_tx_buf, CMD_LEN, "SET COM %i,%i,%i,%i,%i,%i", mode, format, data_bits, bit_order, ss_mode, bus_speed);
if ((stat > 0) && (stat < CMD_LEN)) {
if ((stat > 0) && (stat < (int32_t)CMD_LEN)) {
ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
(void)osDelay(10U);
} else {
Expand Down Expand Up @@ -1163,10 +1163,10 @@ void SPI_DV_Initialize (void) {

#if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
// Test communication with SPI Server
int32_t server_status;
uint32_t str_len;
int32_t server_status;

// Test communication with SPI Server
server_status = EXIT_FAILURE;
if (drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK) {
if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
server_status = ServerInit();
Expand All @@ -1175,8 +1175,10 @@ void SPI_DV_Initialize (void) {
(void)drv->PowerControl(ARM_POWER_OFF);
(void)drv->Uninitialize();

//(void)snprintf(msg_buf, sizeof(msg_buf), "Server status: %s\n", str_srv_status[server_status]);
//TEST_GROUP_INFO(msg_buf);
if (server_status != EXIT_SUCCESS) {
(void)snprintf(msg_buf, sizeof(msg_buf), "Server status: %s\n", str_srv_status[server_status]);
TEST_GROUP_INFO(msg_buf);
}
#endif
}

Expand Down Expand Up @@ -1382,8 +1384,8 @@ The function \b SPI_Initialize_Uninitialize verifies the \b Initialize and \b Un
Testing sequence:
- Driver is uninitialized and peripheral is powered-off:
- Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
- Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
- Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
- Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR or ARM_DRIVER_ERROR_UNSUPPORTED status
- Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_OK status
- Call Send function and assert that it returned ARM_DRIVER_ERROR status
- Call Receive function and assert that it returned ARM_DRIVER_ERROR status
- Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
Expand Down Expand Up @@ -1420,17 +1422,21 @@ Testing sequence:
- Assert that GetStatus function returned status structure with busy flag 0
*/
void SPI_Initialize_Uninitialize (void) {
int32_t ret;
ARM_SPI_STATUS stat;

// Driver is uninitialized and peripheral is powered-off:
// Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_ERROR);

// Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
TEST_ASSERT(drv->PowerControl (ARM_POWER_LOW) == ARM_DRIVER_ERROR);
// Call PowerControl(ARM_POWER_LOW) function
ret = drv->PowerControl (ARM_POWER_LOW);

// Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_ERROR or ARM_DRIVER_ERROR_UNSUPPORTED status
TEST_ASSERT((ret == ARM_DRIVER_ERROR) || (ret == ARM_DRIVER_ERROR_UNSUPPORTED));

// Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_ERROR);
// Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_OK status
TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);

// Call Send function and assert that it returned ARM_DRIVER_ERROR status
TEST_ASSERT(drv->Send (ptr_tx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
Expand Down Expand Up @@ -1954,6 +1960,8 @@ static void SPI_DataExchange_Operation (uint32_t operation, uint32_t mode, uint3
(void)srv_ss_mode;
(void)srv_delay_c;
(void)srv_delay_t;
(void)def_tx_stat;
(void)curr_tick;
#endif
start_tick = osKernelGetTickCount();

Expand Down
36 changes: 17 additions & 19 deletions Source/DV_USART.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015-2022 Arm Limited. All rights reserved.
* Copyright (c) 2015-2024 Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -307,15 +307,6 @@ static const char *str_cpha[] = {
"CPHA1"
};

static const char *str_modem_line[] = {
"RTS",
"CTS",
"DTR",
"DSR",
"DCD",
"RI"
};

static const char *str_ret[] = {
"ARM_DRIVER_OK",
"ARM_DRIVER_ERROR",
Expand Down Expand Up @@ -796,7 +787,7 @@ static int32_t ComSendCommand (const void *data_out, uint32_t len) {
*/
static int32_t ComReceiveResponse (void *data_in, uint32_t len) {
int32_t ret;
uint32_t flags, num, tout;
uint32_t flags, num;

ret = EXIT_SUCCESS;
num = (len + DataBitsToBytes(USART_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(USART_CFG_SRV_DATA_BITS);
Expand Down Expand Up @@ -1164,7 +1155,7 @@ static int32_t CmdSetCom (uint32_t mode, uint32_t data_bits, uint32_t parity, ui
// Send "SET COM" command to USART Server
memset(ptr_tx_buf, 0, CMD_LEN);
stat = snprintf((char *)ptr_tx_buf, CMD_LEN, "SET COM %i,%i,%i,%i,%i,%i,%i,%i", mode, data_bits, parity, stop_bits, flow_control, cpol, cpha, baudrate);
if ((stat > 0) && (stat < CMD_LEN)) {
if ((stat > 0) && (stat < (int32_t)CMD_LEN)) {
ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
(void)osDelay(10U);
} else {
Expand Down Expand Up @@ -1641,6 +1632,11 @@ static int32_t SettingsCheck (uint32_t mode, uint32_t data_bits, uint32_t parity
if (ServerCheck (mode, data_bits, parity, stop_bits, flow_control, modem_line_mask, baudrate) != EXIT_SUCCESS) {
return EXIT_FAILURE;
}
#else
(void)data_bits;
(void)parity;
(void)stop_bits;
(void)baudrate;
#endif

return EXIT_SUCCESS;
Expand Down Expand Up @@ -1727,10 +1723,10 @@ void USART_DV_Initialize (void) {

#if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
// Test communication with USART Server
int32_t server_status;
uint32_t str_len;
int32_t server_status;

// Test communication with USART Server
server_status = EXIT_FAILURE;
if (drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK) {
if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
server_status = ServerInit();
Expand All @@ -1739,8 +1735,10 @@ void USART_DV_Initialize (void) {
(void)drv->PowerControl(ARM_POWER_OFF);
(void)drv->Uninitialize();

//(void)snprintf(msg_buf, sizeof(msg_buf), "Server status: %s\n", str_srv_status[server_status]);
//TEST_GROUP_INFO(msg_buf);
if (server_status != EXIT_SUCCESS) {
(void)snprintf(msg_buf, sizeof(msg_buf), "Server status: %s\n", str_srv_status[server_status]);
TEST_GROUP_INFO(msg_buf);
}
#endif
}

Expand Down Expand Up @@ -2400,7 +2398,7 @@ static void USART_DataExchange_Operation (uint32_t operation, uint32_t mode, uin
volatile ARM_USART_STATUS usart_stat;
volatile uint32_t tx_count, rx_count;
uint32_t start_cnt;
uint32_t val, delay, i;
uint32_t val, i;
volatile uint32_t srv_delay;
volatile uint32_t drv_delay;
uint8_t chk_tx_data, chk_rx_data;
Expand Down Expand Up @@ -2621,6 +2619,8 @@ static void USART_DataExchange_Operation (uint32_t operation, uint32_t mode, uin
(void)srv_dir;
(void)srv_flow_control;
(void)srv_delay;
(void)def_tx_stat;
(void)curr_tick;
#endif
start_tick = osKernelGetTickCount();

Expand Down Expand Up @@ -4138,7 +4138,6 @@ This test function checks the following requirement:
*/
void USART_Baudrate_Min (void) {
volatile uint64_t br;
volatile int32_t got_baudrate;

if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
Expand Down Expand Up @@ -4184,7 +4183,6 @@ This test function checks the following requirement:
*/
void USART_Baudrate_Max (void) {
volatile uint64_t br;
volatile int32_t got_baudrate;

if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
Expand Down
Loading