Skip to content

Commit a4e044d

Browse files
Minor update to SPI and USART driver validation (#16)
- clean-up unused variables - minor update to SPI Initialize/Uninitialize tests
1 parent a9e52e2 commit a4e044d

3 files changed

Lines changed: 43 additions & 35 deletions

File tree

ARM.CMSIS-Driver_Validation.pdsc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
Active Development ...
1313
- Add GPIO Driver validation
1414
- Improve Ethernet driver validation
15+
- Minor update to SPI driver validation
16+
- Minor update to USART driver validation
1517
- Update examples
1618
- Update documentation
1719
</release>
@@ -160,7 +162,7 @@
160162
</files>
161163
</component>
162164

163-
<component Cclass="CMSIS Driver Validation" Cgroup="SPI" Cversion="2.1.2" condition="CMSIS Driver Validation SPI">
165+
<component Cclass="CMSIS Driver Validation" Cgroup="SPI" Cversion="2.1.3" condition="CMSIS Driver Validation SPI">
164166
<description>SPI driver validation</description>
165167
<RTE_Components_h>
166168
#define RTE_CMSIS_DV_SPI /* Driver Validation SPI enabled */
@@ -184,7 +186,7 @@
184186
</files>
185187
</component>
186188

187-
<component Cclass="CMSIS Driver Validation" Cgroup="USART" Cversion="2.0.0" condition="CMSIS Driver Validation USART">
189+
<component Cclass="CMSIS Driver Validation" Cgroup="USART" Cversion="2.0.1" condition="CMSIS Driver Validation USART">
188190
<description>USART driver validation</description>
189191
<RTE_Components_h>
190192
#define RTE_CMSIS_DV_USART /* Driver Validation USART enabled */

Source/DV_SPI.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2022 Arm Limited. All rights reserved.
2+
* Copyright (c) 2015-2024 Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -384,7 +384,7 @@ static int32_t ComConfigDefault (void) {
384384
*/
385385
static int32_t ComSendCommand (const void *data_out, uint32_t len) {
386386
int32_t ret;
387-
uint32_t flags, num, tout;
387+
uint32_t flags, num;
388388

389389
ret = EXIT_SUCCESS;
390390
num = (len + DataBitsToBytes(SPI_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(SPI_CFG_SRV_DATA_BITS);
@@ -430,7 +430,7 @@ static int32_t ComSendCommand (const void *data_out, uint32_t len) {
430430
*/
431431
static int32_t ComReceiveResponse (void *data_in, uint32_t len) {
432432
int32_t ret;
433-
uint32_t flags, num, tout;
433+
uint32_t flags, num;
434434

435435
ret = EXIT_SUCCESS;
436436
num = (len + DataBitsToBytes(SPI_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(SPI_CFG_SRV_DATA_BITS);
@@ -762,7 +762,7 @@ static int32_t CmdSetCom (uint32_t mode, uint32_t format, uint32_t data_bits, ui
762762
// Send "SET COM" command to SPI Server
763763
memset(ptr_tx_buf, 0, CMD_LEN);
764764
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);
765-
if ((stat > 0) && (stat < CMD_LEN)) {
765+
if ((stat > 0) && (stat < (int32_t)CMD_LEN)) {
766766
ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
767767
(void)osDelay(10U);
768768
} else {
@@ -1163,10 +1163,10 @@ void SPI_DV_Initialize (void) {
11631163

11641164
#if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
11651165
// Test communication with SPI Server
1166-
int32_t server_status;
1167-
uint32_t str_len;
1166+
int32_t server_status;
11681167

11691168
// Test communication with SPI Server
1169+
server_status = EXIT_FAILURE;
11701170
if (drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK) {
11711171
if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
11721172
server_status = ServerInit();
@@ -1175,8 +1175,10 @@ void SPI_DV_Initialize (void) {
11751175
(void)drv->PowerControl(ARM_POWER_OFF);
11761176
(void)drv->Uninitialize();
11771177

1178-
//(void)snprintf(msg_buf, sizeof(msg_buf), "Server status: %s\n", str_srv_status[server_status]);
1179-
//TEST_GROUP_INFO(msg_buf);
1178+
if (server_status != EXIT_SUCCESS) {
1179+
(void)snprintf(msg_buf, sizeof(msg_buf), "Server status: %s\n", str_srv_status[server_status]);
1180+
TEST_GROUP_INFO(msg_buf);
1181+
}
11801182
#endif
11811183
}
11821184

@@ -1382,8 +1384,8 @@ The function \b SPI_Initialize_Uninitialize verifies the \b Initialize and \b Un
13821384
Testing sequence:
13831385
- Driver is uninitialized and peripheral is powered-off:
13841386
- Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1385-
- Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1386-
- Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1387+
- Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR or ARM_DRIVER_ERROR_UNSUPPORTED status
1388+
- Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_OK status
13871389
- Call Send function and assert that it returned ARM_DRIVER_ERROR status
13881390
- Call Receive function and assert that it returned ARM_DRIVER_ERROR status
13891391
- Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
@@ -1420,17 +1422,21 @@ Testing sequence:
14201422
- Assert that GetStatus function returned status structure with busy flag 0
14211423
*/
14221424
void SPI_Initialize_Uninitialize (void) {
1425+
int32_t ret;
14231426
ARM_SPI_STATUS stat;
14241427

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

1429-
// Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1430-
TEST_ASSERT(drv->PowerControl (ARM_POWER_LOW) == ARM_DRIVER_ERROR);
1432+
// Call PowerControl(ARM_POWER_LOW) function
1433+
ret = drv->PowerControl (ARM_POWER_LOW);
1434+
1435+
// Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_ERROR or ARM_DRIVER_ERROR_UNSUPPORTED status
1436+
TEST_ASSERT((ret == ARM_DRIVER_ERROR) || (ret == ARM_DRIVER_ERROR_UNSUPPORTED));
14311437

1432-
// Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1433-
TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_ERROR);
1438+
// Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_OK status
1439+
TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
14341440

14351441
// Call Send function and assert that it returned ARM_DRIVER_ERROR status
14361442
TEST_ASSERT(drv->Send (ptr_tx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
@@ -1954,6 +1960,8 @@ static void SPI_DataExchange_Operation (uint32_t operation, uint32_t mode, uint3
19541960
(void)srv_ss_mode;
19551961
(void)srv_delay_c;
19561962
(void)srv_delay_t;
1963+
(void)def_tx_stat;
1964+
(void)curr_tick;
19571965
#endif
19581966
start_tick = osKernelGetTickCount();
19591967

Source/DV_USART.c

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015-2022 Arm Limited. All rights reserved.
2+
* Copyright (c) 2015-2024 Arm Limited. All rights reserved.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -307,15 +307,6 @@ static const char *str_cpha[] = {
307307
"CPHA1"
308308
};
309309

310-
static const char *str_modem_line[] = {
311-
"RTS",
312-
"CTS",
313-
"DTR",
314-
"DSR",
315-
"DCD",
316-
"RI"
317-
};
318-
319310
static const char *str_ret[] = {
320311
"ARM_DRIVER_OK",
321312
"ARM_DRIVER_ERROR",
@@ -796,7 +787,7 @@ static int32_t ComSendCommand (const void *data_out, uint32_t len) {
796787
*/
797788
static int32_t ComReceiveResponse (void *data_in, uint32_t len) {
798789
int32_t ret;
799-
uint32_t flags, num, tout;
790+
uint32_t flags, num;
800791

801792
ret = EXIT_SUCCESS;
802793
num = (len + DataBitsToBytes(USART_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(USART_CFG_SRV_DATA_BITS);
@@ -1164,7 +1155,7 @@ static int32_t CmdSetCom (uint32_t mode, uint32_t data_bits, uint32_t parity, ui
11641155
// Send "SET COM" command to USART Server
11651156
memset(ptr_tx_buf, 0, CMD_LEN);
11661157
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);
1167-
if ((stat > 0) && (stat < CMD_LEN)) {
1158+
if ((stat > 0) && (stat < (int32_t)CMD_LEN)) {
11681159
ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
11691160
(void)osDelay(10U);
11701161
} else {
@@ -1641,6 +1632,11 @@ static int32_t SettingsCheck (uint32_t mode, uint32_t data_bits, uint32_t parity
16411632
if (ServerCheck (mode, data_bits, parity, stop_bits, flow_control, modem_line_mask, baudrate) != EXIT_SUCCESS) {
16421633
return EXIT_FAILURE;
16431634
}
1635+
#else
1636+
(void)data_bits;
1637+
(void)parity;
1638+
(void)stop_bits;
1639+
(void)baudrate;
16441640
#endif
16451641

16461642
return EXIT_SUCCESS;
@@ -1727,10 +1723,10 @@ void USART_DV_Initialize (void) {
17271723

17281724
#if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
17291725
// Test communication with USART Server
1730-
int32_t server_status;
1731-
uint32_t str_len;
1726+
int32_t server_status;
17321727

17331728
// Test communication with USART Server
1729+
server_status = EXIT_FAILURE;
17341730
if (drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK) {
17351731
if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
17361732
server_status = ServerInit();
@@ -1739,8 +1735,10 @@ void USART_DV_Initialize (void) {
17391735
(void)drv->PowerControl(ARM_POWER_OFF);
17401736
(void)drv->Uninitialize();
17411737

1742-
//(void)snprintf(msg_buf, sizeof(msg_buf), "Server status: %s\n", str_srv_status[server_status]);
1743-
//TEST_GROUP_INFO(msg_buf);
1738+
if (server_status != EXIT_SUCCESS) {
1739+
(void)snprintf(msg_buf, sizeof(msg_buf), "Server status: %s\n", str_srv_status[server_status]);
1740+
TEST_GROUP_INFO(msg_buf);
1741+
}
17441742
#endif
17451743
}
17461744

@@ -2400,7 +2398,7 @@ static void USART_DataExchange_Operation (uint32_t operation, uint32_t mode, uin
24002398
volatile ARM_USART_STATUS usart_stat;
24012399
volatile uint32_t tx_count, rx_count;
24022400
uint32_t start_cnt;
2403-
uint32_t val, delay, i;
2401+
uint32_t val, i;
24042402
volatile uint32_t srv_delay;
24052403
volatile uint32_t drv_delay;
24062404
uint8_t chk_tx_data, chk_rx_data;
@@ -2621,6 +2619,8 @@ static void USART_DataExchange_Operation (uint32_t operation, uint32_t mode, uin
26212619
(void)srv_dir;
26222620
(void)srv_flow_control;
26232621
(void)srv_delay;
2622+
(void)def_tx_stat;
2623+
(void)curr_tick;
26242624
#endif
26252625
start_tick = osKernelGetTickCount();
26262626

@@ -4138,7 +4138,6 @@ This test function checks the following requirement:
41384138
*/
41394139
void USART_Baudrate_Min (void) {
41404140
volatile uint64_t br;
4141-
volatile int32_t got_baudrate;
41424141

41434142
if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
41444143
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; }
@@ -4184,7 +4183,6 @@ This test function checks the following requirement:
41844183
*/
41854184
void USART_Baudrate_Max (void) {
41864185
volatile uint64_t br;
4187-
volatile int32_t got_baudrate;
41884186

41894187
if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
41904188
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; }

0 commit comments

Comments
 (0)