2 * Copyright (c) 2015-2024 Arm Limited. All rights reserved.
4 * SPDX-License-Identifier: Apache-2.0
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * -----------------------------------------------------------------------------
20 * Project: CMSIS-Driver Validation
21 * Title: Universal Synchronous Asynchronous Receiver/Transmitter (USART)
22 * Driver Validation tests
24 * -----------------------------------------------------------------------------
27 #ifndef __DOXYGEN__ // Exclude form the documentation
34 #include "DV_USART_Config.h"
35 #include "DV_Framework.h"
37 #include "Driver_USART.h"
39 // Fixed settings for communication with USART Server (not available through DV_USART_Config.h)
40 #define USART_CFG_SRV_BAUDRATE 115200 // Baudrate
41 #define USART_CFG_SRV_DATA_BITS 8 // 8 data bits
42 #define USART_CFG_SRV_PARITY 0 // None
43 #define USART_CFG_SRV_STOP_BITS 0 // 1 stop bit
44 #define USART_CFG_SRV_FLOW_CONTROL 0 // None
46 // Check configuration
47 #if (USART_CFG_TEST_MODE == 1) // If USART Server is selected
49 #if (USART_CFG_DEF_MODE == 1) // If default mode is Asynchronous
50 #if (USART_CFG_SRV_MODE != 1) // If USART Server mode is not Asynchronous
51 #warning When USART Server Test Mode is used and Default settings for Tests Mode (USART_CFG_DEF_MODE) is Asynchronous then Mode for USART Server (USART_CFG_SRV_MODE) must also be Asynchronous!
53 #elif (USART_CFG_DEF_MODE == 2) // If default mode is Synchronous Master
54 #if (USART_CFG_SRV_MODE != 1) // If USART Server mode is not Asynchronous
55 #warning When USART Server Test Mode is used and Default settings for Tests Mode (USART_CFG_DEF_MODE) is Synchronous Master then Mode for USART Server (USART_CFG_SRV_MODE) must be Asynchronous!
57 #elif (USART_CFG_DEF_MODE == 3) // If default mode is Synchronous Slave
58 #if (USART_CFG_SRV_MODE != 1) // If USART Server mode is not Asynchronous
59 #warning When USART Server Test Mode is used and Default settings for Tests Mode (USART_CFG_DEF_MODE) is Synchronous Slave then Mode for USART Server (USART_CFG_SRV_MODE) must be Asynchronous!
61 #elif (USART_CFG_DEF_MODE == 4) // If default mode is Single-wire
62 #if (USART_CFG_SRV_MODE != 4) // If USART Server mode is not Single-wire
63 #warning When USART Server Test Mode is used and Default settings for Tests Mode (USART_CFG_DEF_MODE) is Single-wire then Mode for USART Server (USART_CFG_SRV_MODE) must also be Single-wire!
65 #elif (USART_CFG_DEF_MODE == 5) // If default mode is IrDA
66 #if (USART_CFG_SRV_MODE != 5) // If USART Server mode is not IrDA
67 #warning When USART Server Test Mode is used and Default settings for Tests Mode (USART_CFG_DEF_MODE) is Single-wire then Mode for USART Server (USART_CFG_SRV_MODE) must also be Single-wire!
70 #warning Unknown Default settings for Tests Mode (USART_CFG_DEF_MODE)!
72 #else // If Loopback is selected
73 #if (USART_CFG_DEF_MODE != 1) // If default mode is not Asynchronous
74 #error For Loopback Test Mode only Default settings for Tests Mode (USART_CFG_DEF_MODE) Asynchronous setting is supported!
78 #define CMD_LEN 32UL // Length of command to USART Server
79 #define RESP_GET_VER_LEN 16UL // Length of response from USART Server to GET VER command
80 #define RESP_GET_CAP_LEN 32UL // Length of response from USART Server to GET CAP command
81 #define RESP_GET_CNT_LEN 16UL // Length of response from USART Server to GET CNT command
82 #define RESP_GET_BRK_LEN 1UL // Length of response from USART Server to GET BRK command
83 #define RESP_GET_MDM_LEN 1UL // Length of response from USART Server to GET MDM command
85 #define OP_SEND 0UL // Send operation
86 #define OP_RECEIVE 1UL // Receive operation
87 #define OP_TRANSFER 2UL // Transfer operation (in synchronous mode only)
88 #define OP_RECEIVE_SEND_LB 3UL // Loopback testing Receive and Send operation (in asynchronous mode only)
89 #define OP_ABORT_SEND 4UL // Abort send operation
90 #define OP_ABORT_RECEIVE 5UL // Abort receive operation
91 #define OP_ABORT_TRANSFER 6UL // Abort transfer operation
93 #define MODE_ASYNCHRONOUS 1UL // UART (Asynchronous)
94 #define MODE_SYNCHRONOUS_MASTER 2UL // Synchronous Master (generates clock signal)
95 #define MODE_SYNCHRONOUS_SLAVE 3UL // Synchronous Slave (external clock signal)
96 #define MODE_SINGLE_WIRE 4UL // UART Single-wire (half-duplex)
97 #define MODE_IRDA 5UL // UART IrDA
98 #define MODE_SMART_CARD 6UL // UART Smart Card
99 #define PARITY_NONE 0UL // No parity
100 #define PARITY_EVEN 1UL // Even Parity
101 #define PARITY_ODD 2UL // Odd Parity
102 #define STOP_BITS_1 0UL // 1 Stop bit
103 #define STOP_BITS_2 1UL // 2 Stop bits
104 #define STOP_BITS_1_5 2UL // 1.5 Stop bits
105 #define STOP_BITS_0_5 3UL // 0.5 Stop bits
106 #define FLOW_CONTROL_NONE 0UL // No flow control signal
107 #define FLOW_CONTROL_RTS 1UL // RTS flow control signal
108 #define FLOW_CONTROL_CTS 2UL // CTS flow control signal
109 #define FLOW_CONTROL_RTS_CTS 3UL // RTS and CTS flow control signal
110 #define CPOL0 0UL // Clock Polarity 0
111 #define CPOL1 1UL // Clock Polarity 1
112 #define CPHA0 0UL // Clock Phase 0
113 #define CPHA1 1UL // Clock Phase 1
114 #define RTS_AVAILABLE 1UL // Mask of RTS line available
115 #define CTS_AVAILABLE 2UL // Mask of CTS line available
116 #define DTR_AVAILABLE 4UL // Mask of DTR line available
117 #define DSR_AVAILABLE 8UL // Mask of DSR line available
118 #define DCD_AVAILABLE 16UL // Mask of DCD line available
119 #define RI_AVAILABLE 32UL // Mask of RI line available
120 #define RTS_ON 1UL // Set RTS to active state
121 #define DTR_ON 2UL // Set DTR to active state
122 #define TO_DCD_ON 4UL // Set line driving DCD on USART Client to active state
123 #define TO_RI_ON 8UL // Set line driving RI on USART Client to active state
126 #define DRIVER_DATA_BITS(x) ((x == 9U) ? ARM_USART_DATA_BITS_9 : ((x == 8U) ? ARM_USART_DATA_BITS_8 : (((x) << ARM_USART_DATA_BITS_Pos) & ARM_USART_DATA_BITS_Msk)))
128 // Testing Configuration definitions
129 #if (USART_CFG_TEST_MODE != 0)
130 #define USART_SERVER_USED 1
132 #define USART_SERVER_USED 0
135 // Prepare values for default setting
136 #define USART_CFG_DEF_MODE_VAL ((USART_CFG_DEF_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk)
137 #if (USART_CFG_DEF_DATA_BITS == 5U)
138 #define USART_CFG_DEF_DATA_BITS_VAL (ARM_USART_DATA_BITS_5)
139 #elif (USART_CFG_DEF_DATA_BITS == 6U)
140 #define USART_CFG_DEF_DATA_BITS_VAL (ARM_USART_DATA_BITS_6)
141 #elif (USART_CFG_DEF_DATA_BITS == 7U)
142 #define USART_CFG_DEF_DATA_BITS_VAL (ARM_USART_DATA_BITS_7)
143 #elif (USART_CFG_DEF_DATA_BITS == 8U)
144 #define USART_CFG_DEF_DATA_BITS_VAL (ARM_USART_DATA_BITS_8)
145 #elif (USART_CFG_DEF_DATA_BITS == 9U)
146 #define USART_CFG_DEF_DATA_VAL (ARM_USART_DATA_BITS_9)
148 #define USART_CFG_DEF_PARITY_VAL ((USART_CFG_DEF_PARITY << ARM_USART_PARITY_Pos) & ARM_USART_PARITY_Msk)
149 #define USART_CFG_DEF_STOP_BITS_VAL ((USART_CFG_DEF_STOP_BITS << ARM_USART_STOP_BITS_Pos) & ARM_USART_STOP_BITS_Msk)
150 #define USART_CFG_DEF_FLOW_CONTROL_VAL ((USART_CFG_DEF_FLOW_CONTROL << ARM_USART_FLOW_CONTROL_Pos) & ARM_USART_FLOW_CONTROL_Msk)
151 #define USART_CFG_DEF_CPOL_VAL ((USART_CFG_DEF_CPOL << ARM_USART_CPOL_Pos) & ARM_USART_CPOL_Msk)
152 #define USART_CFG_DEF_CPHA_VAL ((USART_CFG_DEF_CPHA << ARM_USART_CPHA_Pos) & ARM_USART_CPHA_Msk)
154 // Check if timeout setting is valid
155 #if (USART_CFG_XFER_TIMEOUT <= 2U)
156 #error Transfer timeout must be longer than 2ms!
159 // Check if default number of items setting is valid
160 #if (USART_CFG_DEF_NUM == 0)
161 #error Default number of items to test must not be 0!
164 // Determine maximum number of items used for testing
165 #define USART_NUM_MAX USART_CFG_DEF_NUM
166 #if (USART_CFG_NUM1 > USART_NUM_MAX)
168 #define USART_NUM_MAX USART_CFG_NUM1
170 #if (USART_CFG_NUM2 > USART_NUM_MAX)
172 #define USART_NUM_MAX USART_CFG_NUM2
174 #if (USART_CFG_NUM3 > USART_NUM_MAX)
176 #define USART_NUM_MAX USART_CFG_NUM3
178 #if (USART_CFG_NUM4 > USART_NUM_MAX)
180 #define USART_NUM_MAX USART_CFG_NUM4
182 #if (USART_CFG_NUM5 > USART_NUM_MAX)
184 #define USART_NUM_MAX USART_CFG_NUM5
187 // Calculate maximum required buffer size
188 #if (USART_CFG_DEF_DATA_BITS > 8)
189 #define USART_BUF_MAX (USART_NUM_MAX * 2U)
191 #define USART_BUF_MAX (USART_NUM_MAX)
194 typedef struct { // USART Server version structure
195 uint8_t major; // Version major number
196 uint8_t minor; // Version minor number
197 uint16_t patch; // Version patch (revision) number
200 typedef struct { // USART Server capabilities structure
201 uint32_t mode_mask; // Mode mask
202 uint32_t db_mask; // Data Bits mask
203 uint32_t parity_mask; // Parity mask
204 uint32_t sb_mask; // Stop Bits mask
205 uint32_t fc_mask; // Flow Control mask
206 uint32_t ml_mask; // Modem lines mask
207 uint32_t br_min; // Min baudrate
208 uint32_t br_max; // Max baudrate
211 // Register Driver_USART#
212 #define _ARM_Driver_USART_(n) Driver_USART##n
213 #define ARM_Driver_USART_(n) _ARM_Driver_USART_(n)
214 extern ARM_DRIVER_USART ARM_Driver_USART_(DRV_USART);
215 static ARM_DRIVER_USART *drv = &ARM_Driver_USART_(DRV_USART);
217 // Local variables (used in this module only)
218 static int8_t buffers_ok;
219 static int8_t driver_ok;
220 static int8_t server_ok;
222 static USART_SERV_VER_t usart_serv_ver;
223 static USART_SERV_CAP_t usart_serv_cap;
225 static ARM_USART_CAPABILITIES drv_cap;
226 static volatile uint32_t event;
227 static volatile uint32_t duration;
228 static volatile uint32_t xfer_count;
229 static volatile uint32_t tx_count_sample, rx_count_sample;
230 static volatile uint8_t modem_status;
231 static volatile uint8_t break_status;
232 static uint32_t systick_freq;
233 static uint32_t ticks_per_ms;
235 static osEventFlagsId_t event_flags;
237 static char msg_buf[512];
239 // Allocated buffer pointers
240 static void *ptr_tx_buf_alloc;
241 static void *ptr_rx_buf_alloc;
242 static void *ptr_cmp_buf_alloc;
244 // Buffer pointers used for data transfers (must be aligned to 4 byte)
245 static uint8_t *ptr_tx_buf;
246 static uint8_t *ptr_rx_buf;
247 static uint8_t *ptr_cmp_buf;
249 // String representation of various codes
250 static const char *str_srv_status[] = {
255 static const char *str_test_mode[] = {
260 static const char *str_oper[] = {
270 static const char *str_mode[] = {
273 "Synchronous Master",
280 static const char *str_parity[] = {
286 static const char *str_stop_bits[] = {
293 static const char *str_flow_control[] = {
300 static const char *str_cpol[] = {
305 static const char *str_cpha[] = {
310 static const char *str_ret[] = {
313 "ARM_DRIVER_ERROR_BUSY",
314 "ARM_DRIVER_ERROR_TIMEOUT",
315 "ARM_DRIVER_ERROR_UNSUPPORTED",
316 "ARM_DRIVER_ERROR_PARAMETER",
317 "ARM_DRIVER_ERROR_SPECIFIC",
318 "ARM_USART_ERROR_MODE",
319 "ARM_USART_ERROR_BAUDRATE",
320 "ARM_USART_ERROR_DATA_BITS",
321 "ARM_USART_ERROR_PARITY",
322 "ARM_USART_ERROR_STOP_BITS",
323 "ARM_USART_ERROR_FLOW_CONTROL",
324 "ARM_USART_ERROR_CPOL",
325 "ARM_USART_ERROR_CPHA"
329 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
330 static int32_t ComConfigDefault (void);
331 static int32_t ComSendCommand (const void *data_out, uint32_t len);
332 static int32_t ComReceiveResponse ( void *data_in, uint32_t len);
334 static int32_t CmdGetVer (void);
335 static int32_t CmdGetCap (void);
336 static int32_t CmdSetBufTx (char pattern);
337 static int32_t CmdSetBufRx (char pattern);
338 static int32_t CmdGetBufRx (uint32_t len);
339 static int32_t CmdSetCom (uint32_t mode, uint32_t data_bits, uint32_t parity, uint32_t stop_bits, uint32_t flow_control, uint32_t cpol, uint32_t cpha, uint32_t baudrate);
340 static int32_t CmdXfer (uint32_t dir, uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_cts);
341 static int32_t CmdGetCnt (void);
342 static int32_t CmdSetBrk (uint32_t delay, uint32_t duration);
343 static int32_t CmdGetBrk (void);
344 static int32_t CmdSetMdm (uint32_t mdm_ctrl, uint32_t delay, uint32_t duration);
345 static int32_t CmdGetMdm (void);
347 static int32_t ServerInit (void);
348 static int32_t ServerCheck (uint32_t mode, uint32_t data_bits, uint32_t parity, uint32_t stop_bits, uint32_t flow_control, uint32_t modem_line, uint32_t baudrate);
351 static int32_t IsNotLoopback (void);
352 static int32_t IsNotSync (void);
353 static int32_t IsNotAsync (void);
354 static int32_t IsNotSyncMaster (void);
355 static int32_t IsNotSingleWire (void);
357 static uint32_t DataBitsToBytes (uint32_t data_bits);
358 static int32_t DriverInit (void);
359 static int32_t BuffersCheck (void);
360 static int32_t DriverCheck (uint32_t mode, uint32_t flow_control, uint32_t modem_line_mask);
362 static void USART_DataExchange_Operation (uint32_t operation, uint32_t mode, uint32_t data_bits, uint32_t parity, uint32_t stop_bits, uint32_t flow_control, uint32_t cpol, uint32_t cpha, uint32_t baudrate, uint32_t num);
367 \fn void USART_DrvEvent (uint32_t evt)
368 \brief Store event(s) into a global variable.
369 \detail This is a callback function called by the driver upon an event(s).
370 \param[in] evt USART event
373 static void USART_DrvEvent (uint32_t evt) {
376 (void)osEventFlagsSet(event_flags, evt);
380 \fn static uint32_t DataBitsToBytes (uint32_t data_bits)
381 \brief Calculate number of bytes used for an item at required data bits.
382 \return number of bytes per item
384 static uint32_t DataBitsToBytes (uint32_t data_bits) {
388 if (data_bits > 8U) {
396 \fn static int32_t DriverInit (void)
397 \brief Initialize and power-on the driver.
398 \return execution status
399 - EXIT_SUCCESS: Driver initialized and powered-up successfully
400 - EXIT_FAILURE: Driver initialization or power-up failed
402 static int32_t DriverInit (void) {
404 if (drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK) {
405 if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
410 TEST_FAIL_MESSAGE("[FAILED] USART driver initialize or power-up. Check driver Initialize and PowerControl functions! Test aborted!");
416 \fn static int32_t IsNotLoopback (void)
417 \brief Check if loopback is not selected.
418 \detail This function is used to skip executing a test if it is not supported
420 \return execution status
421 - EXIT_SUCCESS: Loopback is not selected
422 - EXIT_FAILURE: Loopback is selected
424 static int32_t IsNotLoopback (void) {
426 #if (USART_SERVER_USED == 1)
429 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test not executed!");
435 \fn static int32_t IsNotSync (void)
436 \brief Check if Synchronous Slave/Master mode is not selected as default mode.
437 \detail This function is used to skip executing a test if it is not supported
439 \return execution status
440 - EXIT_SUCCESS: Synchronous mode is not selected
441 - EXIT_FAILURE: Synchronous mode is selected
443 static int32_t IsNotSync (void) {
445 #if ((USART_CFG_DEF_MODE != MODE_SYNCHRONOUS_MASTER) && (USART_CFG_DEF_MODE != MODE_SYNCHRONOUS_SLAVE))
448 TEST_MESSAGE("[WARNING] Test not supported for Synchronous Mode! Test not executed!");
454 \fn static int32_t IsNotSyncMaster (void)
455 \brief Check if Synchronous Master mode is not selected as default mode.
456 \detail This function is used to skip executing a test if it is not supported
457 in Synchronous Master mode.
458 \return execution status
459 - EXIT_SUCCESS: Synchronous Master mode is not selected
460 - EXIT_FAILURE: Synchronous Master mode is selected
462 static int32_t IsNotSyncMaster (void) {
464 #if (USART_CFG_DEF_MODE != MODE_SYNCHRONOUS_MASTER)
467 TEST_MESSAGE("[WARNING] Test not supported for Synchronous Master Mode! Test not executed!");
473 \fn static int32_t IsNotAsync (void)
474 \brief Check if Asynchronous/Single-wire/IrDA modes are not selected as default mode.
475 \detail This function is used to skip executing a test if it is not supported
476 in Asynchronous/Single-wire/IrDA mode.
477 \return execution status
478 - EXIT_SUCCESS: Asynchronous/Single-wire/IrDA mode is not selected
479 - EXIT_FAILURE: Asynchronous/Single-wire/IrDA mode is selected
481 static int32_t IsNotAsync (void) {
483 #if ((USART_CFG_DEF_MODE != MODE_ASYNCHRONOUS) && (USART_CFG_DEF_MODE != MODE_SINGLE_WIRE) && (USART_CFG_DEF_MODE != MODE_IRDA))
486 TEST_MESSAGE("[WARNING] Test not supported for Asynchronous/Single-wire/IrDA Mode! Test not executed!");
492 \fn static int32_t IsNotSingleWire (void)
493 \brief Check if Single-wire mode is not selected as default mode.
494 \detail This function is used to skip executing a test if it is not supported
496 \return execution status
497 - EXIT_SUCCESS: Single-wire mode is not selected
498 - EXIT_FAILURE: Single-wire mode is selected
500 static int32_t IsNotSingleWire (void) {
502 #if (USART_CFG_DEF_MODE != MODE_SINGLE_WIRE)
505 TEST_MESSAGE("[WARNING] Test not supported for Single-wire Mode! Test not executed!");
511 \fn static int32_t BuffersCheck (void)
512 \brief Check if buffers are valid.
513 \return execution status
514 - EXIT_SUCCESS: Buffers are valid
515 - EXIT_FAILURE: Buffers are not valid
517 static int32_t BuffersCheck (void) {
519 if ((ptr_tx_buf != NULL) &&
520 (ptr_rx_buf != NULL) &&
521 (ptr_cmp_buf != NULL)) {
525 TEST_FAIL_MESSAGE("[FAILED] Invalid data buffers! Increase heap memory! Test aborted!");
531 \fn static int32_t DriverCheck (uint32_t mode, uint32_t flow_control, uint32_t modem_line_mask, uint32_t baudrate)
532 \brief Check if USART Driver supports desired settings.
533 \param[in] mode mode:
534 - value 1 = Asynchronous
535 - value 2 = Synchronous Master
536 - value 3 = Synchronous Slave
537 - value 4 = Single Wire
539 - value 6 = Smart Card
540 \param[in] flow_control flow control:
545 \param[in] modem_line_mask modem line mask:
552 \return execution status
553 - EXIT_SUCCESS: USART Driver supports desired settings
554 - EXIT_FAILURE: USART Driver does not support desired settings
556 static int32_t DriverCheck (uint32_t mode, uint32_t flow_control, uint32_t modem_line_mask) {
562 case 1: // Asynchronous
563 if (drv_cap.asynchronous == 0U) {
567 case 2: // Synchronous master
568 if (drv_cap.synchronous_master == 0U) {
572 case 3: // Synchronous slave
573 if (drv_cap.synchronous_slave == 0U) {
577 case 4: // Single-wire
578 if (drv_cap.single_wire == 0U) {
583 if (drv_cap.irda == 0U) {
587 case 6: // Samrt Card
588 if (drv_cap.irda == 0U) {
597 if (ret != EXIT_SUCCESS) {
598 // If USART Driver does not support desired mode
600 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Driver does not support %s mode! Test aborted!", str_mode[mode]);
602 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Driver does not support unknown mode! Test aborted!");
604 TEST_MESSAGE(msg_buf);
608 switch (flow_control) {
612 if (drv_cap.flow_control_cts == 0U) {
617 if (drv_cap.flow_control_rts == 0U) {
622 if ((drv_cap.flow_control_cts == 0U) || (drv_cap.flow_control_rts == 0U)) {
631 if (ret != EXIT_SUCCESS) {
632 // If USART Driver does not support desired flow control
634 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Driver does not support %s flow control! Test aborted!", str_flow_control[flow_control]);
636 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Driver does not support unknown flow control! Test aborted!");
638 TEST_MESSAGE(msg_buf);
642 if ((modem_line_mask & 1U) != 0U) {
643 if (drv_cap.rts == 0U) {
644 TEST_MESSAGE("[FAILED] USART Driver does not support RTS modem line! Test aborted!");
648 if ((modem_line_mask & (1U << 1)) != 0U) {
649 if (drv_cap.cts == 0U) {
650 TEST_MESSAGE("[FAILED] USART Driver does not support CTS modem line! Test aborted!");
654 if ((modem_line_mask & (1U << 2)) != 0U) {
655 if (drv_cap.dtr == 0U) {
656 TEST_MESSAGE("[FAILED] USART Driver does not support DTR modem line! Test aborted!");
660 if ((modem_line_mask & (1U << 3)) != 0U) {
661 if (drv_cap.dsr == 0U) {
662 TEST_MESSAGE("[FAILED] USART Driver does not support DSR modem line! Test aborted!");
666 if ((modem_line_mask & (1U << 4)) != 0U) {
667 if (drv_cap.dcd == 0U) {
668 TEST_MESSAGE("[FAILED] USART Driver does not support DCD modem line! Test aborted!");
672 if ((modem_line_mask & (1U << 5)) != 0U) {
673 if (drv_cap.ri == 0U) {
674 TEST_MESSAGE("[FAILED] USART Driver does not support RI modem line! Test aborted!");
682 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
685 \fn static int32_t ComConfigDefault (void)
686 \brief Configure USART Communication Interface to USART Server default communication configuration.
687 \return execution status
688 - EXIT_SUCCESS: Default configuration set successfully
689 - EXIT_FAILURE: Default configuration failed
691 static int32_t ComConfigDefault (void) {
696 if (drv->Control(((USART_CFG_SRV_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
697 DRIVER_DATA_BITS(USART_CFG_SRV_DATA_BITS) |
698 ((USART_CFG_SRV_PARITY << ARM_USART_PARITY_Pos) & ARM_USART_PARITY_Msk) |
699 ((USART_CFG_SRV_STOP_BITS << ARM_USART_STOP_BITS_Pos) & ARM_USART_STOP_BITS_Msk) |
700 ((USART_CFG_SRV_FLOW_CONTROL << ARM_USART_FLOW_CONTROL_Pos) & ARM_USART_FLOW_CONTROL_Msk) ,
701 USART_CFG_SRV_BAUDRATE) != ARM_DRIVER_OK) {
704 if (drv->Control(ARM_USART_CONTROL_TX, 1U) != ARM_DRIVER_OK) {
708 if (ret != EXIT_SUCCESS) {
709 TEST_FAIL_MESSAGE("[FAILED] Configure communication interface to USART Server default settings. Check driver Control function! Test aborted!");
716 \fn static int32_t ComSendCommand (const void *data_out, uint32_t num)
717 \brief Send command to USART Server.
718 \param[out] data_out Pointer to memory containing data to be sent
719 \param[in] len Number of bytes to be sent
720 \return execution status
721 - EXIT_SUCCESS: Command sent successfully
722 - EXIT_FAILURE: Command send failed
724 static int32_t ComSendCommand (const void *data_out, uint32_t len) {
726 uint32_t flags, num, tout;
729 num = (len + DataBitsToBytes(USART_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(USART_CFG_SRV_DATA_BITS);
731 ret = ComConfigDefault();
733 if (ret == EXIT_SUCCESS) {
734 (void)osEventFlagsClear(event_flags, 0x7FFFFFFFU);
735 if (drv->Control(ARM_USART_CONTROL_TX, 1U) != ARM_DRIVER_OK) {
738 if (ret == EXIT_SUCCESS) {
739 if (drv->Send(data_out, num) != ARM_DRIVER_OK) {
742 if (ret == EXIT_SUCCESS) {
743 if (drv_cap.event_tx_complete != 0U) {
744 // If ARM_USART_EVENT_TX_COMPLETE is supported, wait for it
745 flags = osEventFlagsWait(event_flags, ARM_USART_EVENT_TX_COMPLETE, osFlagsWaitAny, USART_CFG_SRV_CMD_TOUT);
746 if (((flags & 0x80000000U) != 0U) ||
747 ((flags & ARM_USART_EVENT_TX_COMPLETE) == 0U)) {
751 // Otherwise wait for ARM_USART_EVENT_SEND_COMPLETE flag
752 flags = osEventFlagsWait(event_flags, ARM_USART_EVENT_SEND_COMPLETE, osFlagsWaitAny, USART_CFG_SRV_CMD_TOUT);
753 if (((flags & 0x80000000U) != 0U) ||
754 ((flags & ARM_USART_EVENT_SEND_COMPLETE) == 0U)) {
758 if (ret == EXIT_SUCCESS) {
759 // If completed event was signaled, wait for all data to be sent
760 for (tout = USART_CFG_SRV_CMD_TOUT; tout != 0U; tout--) {
761 if ((drv->GetTxCount() == len) && (drv->GetStatus().tx_busy == 0U)) {
769 if (ret == EXIT_FAILURE) {
770 (void)drv->Control(ARM_USART_ABORT_SEND, 0U);
774 (void)drv->Control(ARM_USART_CONTROL_TX, 0U);
780 \fn static int32_t ComReceiveResponse (void *data_in, uint32_t num)
781 \brief Receive response from USART Server.
782 \param[out] data_in Pointer to memory where data will be received
783 \param[in] len Number of data bytes to be received
784 \return execution status
785 - EXIT_SUCCESS: Command received successfully
786 - EXIT_FAILURE: Command reception failed
788 static int32_t ComReceiveResponse (void *data_in, uint32_t len) {
793 num = (len + DataBitsToBytes(USART_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(USART_CFG_SRV_DATA_BITS);
795 ret = ComConfigDefault();
797 if (ret == EXIT_SUCCESS) {
798 (void)osEventFlagsClear(event_flags, 0x7FFFFFFFU);
799 if (drv->Control(ARM_USART_CONTROL_RX, 1U) != ARM_DRIVER_OK) {
802 if (ret == EXIT_SUCCESS) {
803 if (drv->Receive(data_in, num) != ARM_DRIVER_OK) {
806 if (ret == EXIT_SUCCESS) {
807 flags = osEventFlagsWait(event_flags, ARM_USART_EVENT_RECEIVE_COMPLETE, osFlagsWaitAny, USART_CFG_SRV_CMD_TOUT);
808 if (((flags & 0x80000000U) != 0U) ||
809 ((flags & ARM_USART_EVENT_RECEIVE_COMPLETE) == 0U)) {
813 if (ret == EXIT_FAILURE) {
814 drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
818 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
824 \fn static int32_t CmdGetVer (void)
825 \brief Get version from USART Server and check that it is valid.
826 \return execution status
827 - EXIT_SUCCESS: Version retrieved successfully
828 - EXIT_FAILURE: Version retreival failed
830 static int32_t CmdGetVer (void) {
838 memset(&usart_serv_ver, 0, sizeof(usart_serv_ver));
840 // Send "GET VER" command to USART Server
841 memset(ptr_tx_buf, 0, CMD_LEN);
842 memcpy(ptr_tx_buf, "GET VER", 7);
843 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
845 if (ret == EXIT_SUCCESS) {
846 // Receive response to "GET VER" command from USART Server
847 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_VER_LEN);
848 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_VER_LEN);
853 if (ret == EXIT_SUCCESS) {
855 ptr_str = (const char *)ptr_rx_buf;
856 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
857 usart_serv_ver.major = val8;
862 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
864 ptr_str = strstr(ptr_str, "."); // Find '.'
865 if (ptr_str != NULL) {
866 ptr_str++; // Skip '.'
867 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
868 usart_serv_ver.minor = val8;
876 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
877 // Parse patch (revision)
878 ptr_str = strstr(ptr_str, "."); // Find next '.'
879 if (ptr_str != NULL) {
880 ptr_str++; // Skip '.'
881 if (sscanf(ptr_str, "%hx", &val16) == 1) {
882 usart_serv_ver.patch = val16;
895 \fn static int32_t CmdGetCap (void)
896 \brief Get capabilities from USART Server.
897 \return execution status
898 - EXIT_SUCCESS: Capabilities retrieved successfully
899 - EXIT_FAILURE: Capabilities retreival failed
901 static int32_t CmdGetCap (void) {
909 memset(&usart_serv_cap, 0, sizeof(usart_serv_cap));
911 // Send "GET CAP" command to USART Server
912 memset(ptr_tx_buf, 0, CMD_LEN);
913 memcpy(ptr_tx_buf, "GET CAP", 7);
914 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
916 if (ret == EXIT_SUCCESS) {
917 (void)osDelay(20U); // Give USART Server 20 ms to auto-detect capabilities
919 // Receive response to "GET CAP" command from USART Server
920 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_CAP_LEN);
921 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_CAP_LEN);
925 // Parse capabilities
926 if (ret == EXIT_SUCCESS) {
928 ptr_str = (const char *)ptr_rx_buf;
929 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
930 usart_serv_cap.mode_mask = val8;
935 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
936 // Parse data bit mask
937 ptr_str = strstr(ptr_str, ","); // Find ','
938 if (ptr_str != NULL) {
939 ptr_str++; // Skip ','
940 if (sscanf(ptr_str, "%x", &val32) == 1) {
941 usart_serv_cap.db_mask = val32;
949 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
951 ptr_str = strstr(ptr_str, ","); // Find next ','
952 if (ptr_str != NULL) {
953 ptr_str++; // Skip ','
954 if (sscanf(ptr_str, "%x", &val32) == 1) {
955 usart_serv_cap.parity_mask = val32;
963 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
964 // Parse stop bit mask
965 ptr_str = strstr(ptr_str, ","); // Find next ','
966 if (ptr_str != NULL) {
967 ptr_str++; // Skip ','
968 if (sscanf(ptr_str, "%x", &val32) == 1) {
969 usart_serv_cap.sb_mask = val32;
977 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
978 // Parse flow control mask
979 ptr_str = strstr(ptr_str, ","); // Find next ','
980 if (ptr_str != NULL) {
981 ptr_str++; // Skip ','
982 if (sscanf(ptr_str, "%x", &val32) == 1) {
983 usart_serv_cap.fc_mask = val32;
991 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
992 // Parse modem lines mask
993 ptr_str = strstr(ptr_str, ","); // Find next ','
994 if (ptr_str != NULL) {
995 ptr_str++; // Skip ','
996 if (sscanf(ptr_str, "%x", &val32) == 1) {
997 usart_serv_cap.ml_mask = val32;
1005 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
1006 // Parse minimum baudrate
1007 ptr_str = strstr(ptr_str, ","); // Find next ','
1008 if (ptr_str != NULL) {
1009 ptr_str++; // Skip ','
1010 if (sscanf(ptr_str, "%u", &val32) == 1) {
1011 usart_serv_cap.br_min = val32;
1019 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
1020 // Parse maximum baudrate
1021 ptr_str = strstr(ptr_str, ","); // Find next ','
1022 if (ptr_str != NULL) {
1023 ptr_str++; // Skip ','
1024 if (sscanf(ptr_str, "%u", &val32) == 1) {
1025 usart_serv_cap.br_max = val32;
1038 \fn static int32_t CmdSetBufTx (char pattern)
1039 \brief Set Tx buffer of USART Server to pattern.
1040 \param[in] pattern Pattern to fill the buffer with
1041 \return execution status
1042 - EXIT_SUCCESS: Command sent successfully
1043 - EXIT_FAILURE: Command send failed
1045 static int32_t CmdSetBufTx (char pattern) {
1048 // Send "SET BUF TX" command to USART Server
1049 memset(ptr_tx_buf, 0, CMD_LEN);
1050 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF TX,0,%02X", (int32_t)pattern);
1051 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1054 if (ret != EXIT_SUCCESS) {
1055 TEST_FAIL_MESSAGE("[FAILED] Set Tx buffer on USART Server. Check USART Server! Test aborted!");
1062 \fn static int32_t CmdSetBufRx (char pattern)
1063 \brief Set Rx buffer of USART Server to pattern.
1064 \param[in] pattern Pattern to fill the buffer with
1065 \return execution status
1066 - EXIT_SUCCESS: Command sent successfully
1067 - EXIT_FAILURE: Command send failed
1069 static int32_t CmdSetBufRx (char pattern) {
1072 // Send "SET BUF RX" command to USART Server
1073 memset(ptr_tx_buf, 0, CMD_LEN);
1074 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF RX,0,%02X", (int32_t)pattern);
1075 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1078 if (ret != EXIT_SUCCESS) {
1079 TEST_FAIL_MESSAGE("[FAILED] Set Rx buffer on USART Server. Check USART Server! Test aborted!");
1086 \fn static int32_t CmdGetBufRx (void)
1087 \brief Get Rx buffer from USART Server (into global array pointed to by ptr_rx_buf).
1088 \param[in] len Number of bytes to read from Rx buffer
1089 \return execution status
1090 - EXIT_SUCCESS: Command sent and response received successfully
1091 - EXIT_FAILURE: Command send or response reception failed
1093 static int32_t CmdGetBufRx (uint32_t len) {
1096 // Send "GET BUF RX" command to USART Server
1097 memset(ptr_tx_buf, 0, CMD_LEN);
1098 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "GET BUF RX,%i", len);
1099 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1101 if (ret == EXIT_SUCCESS) {
1102 // Receive response to "GET BUF RX" command from USART Server
1103 memset(ptr_rx_buf, (int32_t)'?', len);
1104 ret = ComReceiveResponse(ptr_rx_buf, len);
1108 if (ret != EXIT_SUCCESS) {
1109 TEST_FAIL_MESSAGE("[FAILED] Get Rx buffer from USART Server. Check USART Server! Test aborted!");
1116 \fn static int32_t CmdSetCom (uint32_t mode, uint32_t data_bits, uint32_t parity, uint32_t stop_bits, uint32_t flow_control, uint32_t cpol, uint32_t cpha, uint32_t baudrate)
1117 \brief Set communication parameters on USART Server for next XFER command.
1118 \param[in] mode mode:
1119 - value 0 = Asynchronous
1120 - value 1 = Synchronous Master
1121 - value 2 = Synchronous Slave
1122 - value 3 = Single Wire
1124 - value 5 = Smart Card
1125 \param[in] data_bits data bits:
1127 \param[in] parity parity:
1131 \param[in] stop_bits stop bits:
1132 - value 0 = 1 Stop Bit
1133 - value 1 = 2 Stop Bits
1134 - value 2 = 1.5 Stop Bits
1135 - value 3 = 0.5 Stop Bits
1136 \param[in] flow_control flow control:
1141 \param[in] cpol clock polarity:
1142 - value 0 = Data are captured on rising edge
1143 - value 1 = Data are captured on falling edge
1144 \param[in] cpha clock phase:
1145 - value 0 = Sample on first (leading) edge
1146 - value 1 = Sample on second (trailing) edge
1147 \param[in] baudrate baudrate in bauds
1148 \return execution status
1149 - EXIT_SUCCESS: Command sent successfully
1150 - EXIT_FAILURE: Command send failed
1152 static int32_t CmdSetCom (uint32_t mode, uint32_t data_bits, uint32_t parity, uint32_t stop_bits, uint32_t flow_control, uint32_t cpol, uint32_t cpha, uint32_t baudrate) {
1155 // Send "SET COM" command to USART Server
1156 memset(ptr_tx_buf, 0, CMD_LEN);
1157 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);
1158 if ((stat > 0) && (stat < (int32_t)CMD_LEN)) {
1159 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1165 if (ret != EXIT_SUCCESS) {
1166 TEST_FAIL_MESSAGE("[FAILED] Set communication settings on USART Server. Check USART Server! Test aborted!");
1173 \fn static int32_t CmdXfer (uint32_t dir, uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_cts)
1174 \brief Activate transfer on USART Server.
1175 \param[in] dir direction of transfer
1178 - 2 = Transfer (simultaneous Tx and Rx (in synchronous mode only))
1179 \param[in] num number of items (according CMSIS USART driver specification)
1180 \param[in] delay initial delay, in milliseconds, before starting requested operation
1181 (0xFFFFFFFF = delay not used)
1182 \param[in] timeout timeout in milliseconds, after delay, if delay is specified
1183 \param[in] num_cts number of items after which CTS line should be de-activated
1184 - 0 = no CTS deactivation
1185 \return execution status
1186 - EXIT_SUCCESS: Command sent successfully
1187 - EXIT_FAILURE: Command send failed
1189 static int32_t CmdXfer (uint32_t dir, uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_cts) {
1192 // Send "XFER" command to USART Server
1193 memset(ptr_tx_buf, 0, CMD_LEN);
1194 if (num_cts != 0U) {
1195 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i,%i,%i", dir, num, delay, timeout, num_cts);
1196 } else if ((delay != osWaitForever) && (timeout != 0U)) {
1197 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i,%i", dir, num, delay, timeout);
1198 } else if (delay != osWaitForever) {
1199 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i", dir, num, delay);
1201 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i", dir, num);
1203 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1205 if (ret != EXIT_SUCCESS) {
1206 TEST_FAIL_MESSAGE("[FAILED] Activate transfer on USART Server. Check USART Server! Test aborted!");
1213 \fn static int32_t CmdGetCnt (void)
1214 \brief Get XFER command Tx/Rx count from USART Server.
1215 \return execution status
1216 - EXIT_SUCCESS: Operation successful
1217 - EXIT_FAILURE: Operation failed
1219 static int32_t CmdGetCnt (void) {
1221 const char *ptr_str;
1226 // Send "GET CNT" command to USART Server
1227 memset(ptr_tx_buf, 0, CMD_LEN);
1228 memcpy(ptr_tx_buf, "GET CNT", 7);
1229 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1231 if (ret == EXIT_SUCCESS) {
1232 // Receive response to "GET CNT" command from USART Server
1233 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_CNT_LEN);
1234 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_CNT_LEN);
1238 if (ret == EXIT_SUCCESS) {
1240 ptr_str = (const char *)ptr_rx_buf;
1241 if (sscanf(ptr_str, "%i", &val32) == 1) {
1248 if (ret != EXIT_SUCCESS) {
1249 TEST_FAIL_MESSAGE("[FAILED] Get count from USART Server. Check USART Server! Test aborted!");
1256 \fn static int32_t CmdSetBrk (uint32_t delay, uint32_t duration)
1257 \brief Request USART Server to send break signal.
1258 \param[in] delay: initial delay, in milliseconds, before start of break signaling
1259 \param[in] duration: duration, in milliseconds, of break signaling
1260 \return execution status
1261 - EXIT_SUCCESS: Command sent successfully
1262 - EXIT_FAILURE: Command send failed
1264 static int32_t CmdSetBrk (uint32_t delay, uint32_t duration) {
1267 // Send "SET BRK" command to USART Server
1268 memset(ptr_tx_buf, 0, CMD_LEN);
1269 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BRK %i,%i", delay, duration);
1270 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1272 if (ret != EXIT_SUCCESS) {
1273 TEST_FAIL_MESSAGE("[FAILED] Set break on USART Server. Check USART Server! Test aborted!");
1280 \fn static int32_t CmdGetBrk (void)
1281 \brief Get information on Break state from USART Server.
1282 \return execution status
1283 - EXIT_SUCCESS: Command sent and response received successfully
1284 - EXIT_FAILURE: Command send or response reception failed
1286 static int32_t CmdGetBrk (void) {
1289 // Send "GET BRK" command to USART Server
1290 memset(ptr_tx_buf, 0, CMD_LEN);
1291 memcpy(ptr_tx_buf, "GET BRK", 7);
1292 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1294 if (ret == EXIT_SUCCESS) {
1295 // Receive response to "GET BRK" command from USART Server
1296 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_BRK_LEN);
1297 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_BRK_LEN);
1301 // Store modem status to global variable
1302 if (ret == EXIT_SUCCESS) {
1303 break_status = ptr_rx_buf[0] - '0';
1306 if (ret != EXIT_SUCCESS) {
1307 TEST_FAIL_MESSAGE("[FAILED] Get break state from USART Server. Check USART Server! Test aborted!");
1314 \fn static int32_t CmdSetMdm (uint32_t mdm_ctrl, uint32_t delay, uint32_t duration)
1315 \brief Set modem lines on USART Server.
1316 \param[in] mdm_ctrl: modem control line states:
1319 - bit 2.: Line to USART Client's DCD state
1320 - bit 3.: Line to USART Client's RI state
1321 \param[in] delay: initial delay, in milliseconds, before start of controlling modem lines
1322 \param[in] duration: duration, in milliseconds, of controlling modem lines
1323 \return execution status
1324 - EXIT_SUCCESS: Command sent successfully
1325 - EXIT_FAILURE: Command send failed
1327 static int32_t CmdSetMdm (uint32_t mdm_ctrl, uint32_t delay, uint32_t duration) {
1330 // Send "SET MDM" command to USART Server
1331 memset(ptr_tx_buf, 0, CMD_LEN);
1332 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET MDM %x,%i,%i", mdm_ctrl, delay, duration);
1333 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1335 if (ret != EXIT_SUCCESS) {
1336 TEST_FAIL_MESSAGE("[FAILED] Set modem control on USART Server. Check USART Server! Test aborted!");
1343 \fn static int32_t CmdGetMdm (void)
1344 \brief Get information on modem lines current state from USART Server.
1345 \return execution status
1346 - EXIT_SUCCESS: Command sent and response received successfully
1347 - EXIT_FAILURE: Command send or response reception failed
1349 static int32_t CmdGetMdm (void) {
1352 // Send "GET MDM" command to USART Server
1353 memset(ptr_tx_buf, 0, CMD_LEN);
1354 memcpy(ptr_tx_buf, "GET MDM", 7);
1355 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1357 if (ret == EXIT_SUCCESS) {
1358 // Receive response to "GET MDM" command from USART Server
1359 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_MDM_LEN);
1360 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_MDM_LEN);
1364 // Store modem status to global variable
1365 if (ret == EXIT_SUCCESS) {
1366 modem_status = ptr_rx_buf[0] - '0';
1369 if (ret != EXIT_SUCCESS) {
1370 TEST_FAIL_MESSAGE("[FAILED] Get modem lines state from USART Server. Check USART Server! Test aborted!");
1377 \fn static int32_t ServerInit (void)
1378 \brief Initialize communication with USART Server, get version and capabilities.
1379 \return execution status
1380 - EXIT_SUCCESS: USART Server initialized successfully
1381 - EXIT_FAILURE: USART Server initialization failed
1383 static int32_t ServerInit (void) {
1385 if (server_ok == -1) { // If -1, means it was not yet checked
1388 if (drv->Control(((USART_CFG_SRV_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
1389 DRIVER_DATA_BITS(USART_CFG_SRV_DATA_BITS) |
1390 ((USART_CFG_SRV_PARITY << ARM_USART_PARITY_Pos) & ARM_USART_PARITY_Msk) |
1391 ((USART_CFG_SRV_STOP_BITS << ARM_USART_STOP_BITS_Pos) & ARM_USART_STOP_BITS_Msk) |
1392 ((USART_CFG_SRV_FLOW_CONTROL << ARM_USART_FLOW_CONTROL_Pos) & ARM_USART_FLOW_CONTROL_Msk) ,
1393 USART_CFG_SRV_BAUDRATE) != ARM_DRIVER_OK) {
1396 if (server_ok == 0) {
1397 TEST_GROUP_INFO("Failed to configure communication interface to USART Server default settings.\n"\
1398 "Driver must support basic settings used for communication with USART Server!");
1401 if (server_ok == 1) {
1403 if (CmdGetVer() != EXIT_SUCCESS) {
1404 TEST_GROUP_INFO("Failed to Get version from USART Server.\nCheck USART Server!\n");
1409 if (server_ok == 1) {
1410 if (usart_serv_ver.major == 0U) {
1411 TEST_GROUP_INFO("USART Server version must be 1.0.0. or higher.\nUpdate USART Server to newer version!\n");
1416 if (server_ok == 1) {
1417 if (CmdGetCap() != EXIT_SUCCESS) {
1418 TEST_GROUP_INFO("Failed to Get capabilities from USART Server.\nCheck USART Server!\n");
1424 if (server_ok == 1) {
1425 return EXIT_SUCCESS;
1428 return EXIT_FAILURE;
1432 \fn static int32_t ServerCheck (uint32_t mode, uint32_t data_bits, uint32_t parity, uint32_t stop_bits, uint32_t flow_control, uint32_t modem_line, uint32_t baudrate)
1433 \brief Check if USART Server is functional and if it supports desired settings.
1434 \detail Parameters describe settings required to test, so server must support complementary sattings.
1435 For example to test RTS line server must support CTS line.
1436 \param[in] mode mode (expected to be tested):
1437 - value 1 = Asynchronous
1438 - value 2 = Synchronous Master
1439 - value 3 = Synchronous Slave
1440 - value 4 = Single Wire
1442 - value 6 = Smart Card
1443 \param[in] data_bits data bits (5 .. 9)
1444 \param[in] parity parity:
1448 \param[in] stop_bits stop bits:
1449 - value 0 = 1 Stop Bit
1450 - value 1 = 2 Stop Bits
1451 - value 2 = 1.5 Stop Bits
1452 - value 3 = 0.5 Stop Bits
1453 \param[in] flow_control flow control:
1458 \param[in] modem_line_mask modem line mask:
1465 \param[in] baudrate baudrate in bauds
1466 \return execution status
1467 - EXIT_SUCCESS: USART Server supports desired settings
1468 - EXIT_FAILURE: USART Server does not support desired settings
1470 static int32_t ServerCheck (uint32_t mode, uint32_t data_bits, uint32_t parity, uint32_t stop_bits, uint32_t flow_control, uint32_t modem_line_mask, uint32_t baudrate) {
1471 uint32_t srv_mode, srv_flow_control, srv_modem_line_mask;
1473 if (server_ok == 0) {
1474 TEST_FAIL_MESSAGE("[FAILED] USART Server status. Check USART Server! Test aborted!");
1475 return EXIT_FAILURE;
1478 #if (USART_CFG_SRV_MODE == MODE_ASYNCHRONOUS)
1479 if ((mode == MODE_SINGLE_WIRE) || (mode == MODE_IRDA)) {
1480 TEST_MESSAGE("[FAILED] USART Server mode Asynchronous does not support requested test mode! Test aborted!");
1481 return EXIT_FAILURE;
1483 #elif (USART_CFG_SRV_MODE == MODE_SINGLE_WIRE)
1484 if (mode != MODE_SINGLE_WIRE) {
1485 TEST_MESSAGE("[FAILED] USART Server mode Single-wire does not support requested test mode! Test aborted!");
1486 return EXIT_FAILURE;
1488 #elif (USART_CFG_SRV_MODE == MODE_SINGLE_IRDA)
1489 if (mode != MODE_SINGLE_IRDA) {
1490 TEST_MESSAGE("[FAILED] USART Server mode IrDA does not support requested test mode! Test aborted!");
1491 return EXIT_FAILURE;
1494 TEST_MESSAGE("[FAILED] USART Server mode unknown! Test aborted!");
1495 return EXIT_FAILURE;
1499 if (mode == MODE_SYNCHRONOUS_MASTER) { // If mode to be tested is Synchro Master then server must support Slave
1500 srv_mode = MODE_SYNCHRONOUS_SLAVE;
1501 } else if (mode == MODE_SYNCHRONOUS_SLAVE) { // If mode to be tested is Synchro Slave then server must support Master
1502 srv_mode = MODE_SYNCHRONOUS_MASTER;
1505 srv_flow_control = flow_control;
1506 if (flow_control == FLOW_CONTROL_RTS) {
1507 srv_flow_control = FLOW_CONTROL_CTS;
1509 if (flow_control == FLOW_CONTROL_CTS) {
1510 srv_flow_control = FLOW_CONTROL_RTS;
1513 srv_modem_line_mask = 0U;
1514 if ((modem_line_mask & RTS_AVAILABLE ) != 0U) {
1515 srv_modem_line_mask |= CTS_AVAILABLE;
1517 if ((modem_line_mask & CTS_AVAILABLE ) != 0U) {
1518 srv_modem_line_mask |= RTS_AVAILABLE;
1520 if ((modem_line_mask & DTR_AVAILABLE ) != 0U) {
1521 srv_modem_line_mask |= DSR_AVAILABLE;
1523 if ((modem_line_mask & DSR_AVAILABLE ) != 0U) {
1524 srv_modem_line_mask |= DTR_AVAILABLE;
1526 if ((modem_line_mask & DCD_AVAILABLE) != 0U) {
1527 srv_modem_line_mask |= DCD_AVAILABLE;
1529 if ((modem_line_mask & RI_AVAILABLE ) != 0U) {
1530 srv_modem_line_mask |= RI_AVAILABLE;
1533 if ((usart_serv_cap.mode_mask & (1UL << (srv_mode - 1U))) == 0U) {
1534 // If USART Server does not support desired mode
1535 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %s mode! Test aborted!", str_mode[mode]);
1536 TEST_MESSAGE(msg_buf);
1537 return EXIT_FAILURE;
1539 if ((usart_serv_cap.db_mask & (1UL << (data_bits - 5U))) == 0U) {
1540 // If USART Server does not support desired data bits
1541 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %i data bits! Test aborted!", data_bits);
1542 TEST_MESSAGE(msg_buf);
1543 return EXIT_FAILURE;
1545 if ((usart_serv_cap.parity_mask & (1UL << parity)) == 0U) {
1546 // If USART Server does not support desired parity
1547 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %s parity! Test aborted!", str_parity[parity]);
1548 TEST_MESSAGE(msg_buf);
1549 return EXIT_FAILURE;
1551 if ((usart_serv_cap.sb_mask & (1UL << stop_bits)) == 0U) {
1552 // If USART Server does not support desired stop bits
1553 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %s stop bits! Test aborted!", str_stop_bits[stop_bits]);
1554 TEST_MESSAGE(msg_buf);
1555 return EXIT_FAILURE;
1557 if ((usart_serv_cap.fc_mask & (1UL << srv_flow_control)) == 0U) {
1558 // If USART Server does not support desired flow control
1559 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %s flow control! Test aborted!", str_flow_control[flow_control]);
1560 TEST_MESSAGE(msg_buf);
1561 return EXIT_FAILURE;
1563 if (srv_modem_line_mask != 0U) {
1564 if ((usart_serv_cap.ml_mask & srv_modem_line_mask) == 0U) {
1565 // If USART Server does not support desired modem line
1566 TEST_MESSAGE("[FAILED] USART Server does not support desired modem line! Test aborted!");
1567 return EXIT_FAILURE;
1570 if ((usart_serv_cap.br_min > baudrate) ||
1571 (usart_serv_cap.br_max < baudrate)) {
1572 // If USART Server does not support desired baudrate
1573 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %i baudrate bus speed! Test aborted!", baudrate);
1574 TEST_MESSAGE(msg_buf);
1575 return EXIT_FAILURE;
1578 return EXIT_SUCCESS;
1581 #endif // If Test Mode USART Server is selected
1584 \fn static int32_t SettingsCheck (uint32_t mode, uint32_t data_bits, uint32_t parity, uint32_t stop_bits, uint32_t flow_control, uint32_t modem_line, uint32_t baudrate)
1585 \brief Check if Driver and USART Server (if used) is functional and if it supports desired settings.
1586 \detail Parameters describe settings required to test, so server must support complementary sattings.
1587 For example to test RTS line server must support CTS line.
1588 \param[in] mode mode (expected to be tested):
1589 - value 1 = Asynchronous
1590 - value 2 = Synchronous Master
1591 - value 3 = Synchronous Slave
1592 - value 4 = Single Wire
1594 - value 6 = Smart Card
1595 \param[in] data_bits data bits (5 .. 9)
1596 \param[in] parity parity:
1600 \param[in] stop_bits stop bits:
1601 - value 0 = 1 Stop Bit
1602 - value 1 = 2 Stop Bits
1603 - value 2 = 1.5 Stop Bits
1604 - value 3 = 0.5 Stop Bits
1605 \param[in] flow_control flow control:
1610 \param[in] modem_line_mask modem line mask:
1617 \param[in] baudrate baudrate in bauds
1618 \return execution status
1619 - EXIT_SUCCESS: Driver and USART Server supports desired settings
1620 - EXIT_FAILURE: Driver or USART Server does not support desired settings
1622 static int32_t SettingsCheck (uint32_t mode, uint32_t data_bits, uint32_t parity, uint32_t stop_bits, uint32_t flow_control, uint32_t modem_line_mask, uint32_t baudrate) {
1624 if (BuffersCheck() != EXIT_SUCCESS) {
1625 return EXIT_FAILURE;
1628 if (DriverCheck (mode, flow_control, modem_line_mask) != EXIT_SUCCESS) {
1629 return EXIT_FAILURE;
1631 #if (USART_SERVER_USED == 1)
1632 if (ServerCheck (mode, data_bits, parity, stop_bits, flow_control, modem_line_mask, baudrate) != EXIT_SUCCESS) {
1633 return EXIT_FAILURE;
1642 return EXIT_SUCCESS;
1646 \fn void USART_DV_Initialize (void)
1647 \brief Initialize testing environment for USART testing.
1648 \detail This function is called by the driver validation framework before USART testing begins.
1649 It initializes global variables and allocates memory buffers (from heap) used for the USART testing.
1652 void USART_DV_Initialize (void) {
1654 // Initialize global variables
1659 duration = 0xFFFFFFFFUL;
1660 systick_freq = osKernelGetSysTimerFreq();
1661 if (systick_freq == 0U) {
1662 // systick_freq must not be 0
1665 ticks_per_ms = systick_freq / 1000U;
1667 memset(&usart_serv_cap, 0, sizeof(usart_serv_cap));
1668 memset(&msg_buf, 0, sizeof(msg_buf));
1670 // Allocate buffers for transmission, reception and comparison
1671 // (maximum size is incremented by 32 bytes to ensure that buffer can be aligned to 32 bytes)
1673 ptr_tx_buf_alloc = malloc(USART_BUF_MAX + 32U);
1674 if (((uint32_t)ptr_tx_buf_alloc & 31U) != 0U) {
1675 // If allocated memory is not 32 byte aligned, use next 32 byte aligned address for ptr_tx_buf
1676 ptr_tx_buf = (uint8_t *)((((uint32_t)ptr_tx_buf_alloc) + 31U) & (~31U));
1678 // If allocated memory is 32 byte aligned, use it directly
1679 ptr_tx_buf = (uint8_t *)ptr_tx_buf_alloc;
1681 ptr_rx_buf_alloc = malloc(USART_BUF_MAX + 32U);
1682 if (((uint32_t)ptr_rx_buf_alloc & 31U) != 0U) {
1683 ptr_rx_buf = (uint8_t *)((((uint32_t)ptr_rx_buf_alloc) + 31U) & (~31U));
1685 ptr_rx_buf = (uint8_t *)ptr_rx_buf_alloc;
1687 ptr_cmp_buf_alloc = malloc(USART_BUF_MAX + 32U);
1688 if (((uint32_t)ptr_cmp_buf_alloc & 31U) != 0U) {
1689 ptr_cmp_buf = (uint8_t *)((((uint32_t)ptr_cmp_buf_alloc) + 31U) & (~31U));
1691 ptr_cmp_buf = (uint8_t *)ptr_cmp_buf_alloc;
1694 event_flags = osEventFlagsNew(NULL);
1696 // Output configuration settings
1697 (void)snprintf(msg_buf,
1700 "Default settings:\n"\
1702 " - Data bits: %i\n"\
1704 " - Stop bits: %s\n"\
1705 " - Flow control: %s\n"\
1706 " - Clock polarity: %s\n"\
1707 " - Clock phase: %s\n"\
1708 " - Bus speed: %i bauds\n"\
1709 " - Number of Items: %i",
1710 str_test_mode [USART_CFG_TEST_MODE],
1711 str_mode [USART_CFG_DEF_MODE],
1712 USART_CFG_DEF_DATA_BITS,
1713 str_parity [USART_CFG_DEF_PARITY],
1714 str_stop_bits [USART_CFG_DEF_STOP_BITS],
1715 str_flow_control[USART_CFG_DEF_FLOW_CONTROL],
1716 str_cpol [USART_CFG_DEF_CPOL],
1717 str_cpha [USART_CFG_DEF_CPHA],
1718 USART_CFG_DEF_BAUDRATE,
1720 TEST_GROUP_INFO(msg_buf);
1722 drv_cap = drv->GetCapabilities();
1724 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
1725 // Test communication with USART Server
1726 int32_t server_status;
1728 // Test communication with USART Server
1729 server_status = EXIT_FAILURE;
1730 if (drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK) {
1731 if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
1732 server_status = ServerInit();
1735 (void)drv->PowerControl(ARM_POWER_OFF);
1736 (void)drv->Uninitialize();
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);
1746 \fn void USART_DV_Uninitialize (void)
1747 \brief De-initialize testing environment after USART testing.
1748 \detail This function is called by the driver validation framework after USART testing is finished.
1749 It frees memory buffers used for the USART testing.
1752 void USART_DV_Uninitialize (void) {
1754 (void)osEventFlagsDelete(event_flags);
1756 if (ptr_tx_buf_alloc != NULL) {
1757 free(ptr_tx_buf_alloc);
1759 ptr_tx_buf_alloc = NULL;
1761 if (ptr_rx_buf_alloc != NULL) {
1762 free(ptr_rx_buf_alloc);
1764 ptr_rx_buf_alloc = NULL;
1766 if (ptr_cmp_buf_alloc != NULL) {
1767 free(ptr_cmp_buf_alloc);
1769 ptr_cmp_buf_alloc = NULL;
1773 #endif // End of exclude form the documentation
1775 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1777 \defgroup dv_usart USART Validation
1778 \brief USART driver validation
1780 The USART validation performs the following tests:
1781 - API interface compliance
1782 - Data exchange with various speeds, transfer sizes and communication settings
1783 - Modem lines operation
1786 Two Test Modes are available: <b>Loopback</b> and <b>USART Server</b>.
1788 Test Mode : <b>Loopback</b>
1789 ---------------------------
1791 This test mode allows only limited validation of the USART Driver.<br>
1792 It is recommended that this test mode is used only as a proof that driver is
1793 good enough to be tested with the <b>USART Server</b>.
1795 For this purpose following <b>Default settings</b> should be used:
1796 - Mode: Asynchronous
1801 - Clock Polarity: Clock Polarity 0
1802 - Clock Phase: Clock Phase 0
1804 - Number of Items: 32
1806 To enable this mode of testing in the <b>DV_USART_Config.h</b> configuration file select the
1807 <b>Configuration: Test Mode: Loopback</b> setting.
1809 Required pin connection for the <b>Loopback</b> test mode:
1811 \image html usart_loopback_pin_connections.png
1813 \note In this mode following operations / settings cannot be tested:
1814 - synchronous slave or single-wire modes
1815 - operation of the Receive function
1816 - data content sent by the Send function
1817 - parity, stop bits, flow control, clock polarity / phase settings
1818 - data bit settings other then 8
1819 - modem lines operation
1822 \anchor usart_server_con
1824 Test Mode : <b>USART Server</b>
1825 -----------------------------
1827 This test mode allows extensive validation of the USART Driver.<br>
1828 Results of the Driver Validation in this test mode are relevant as a proof of driver compliance
1829 to the CMSIS-Driver specification.
1831 To perform extensive communication tests, it is required to use an
1832 \ref usart_server "USART Server" running on a dedicated hardware.
1834 To enable this mode of testing in the <b>DV_USART_Config.h</b> configuration file select the
1835 <b>Configuration: Test Mode: USART Server</b> setting.
1837 Required pin connections for the <b>USART Server</b> test mode with <b>USART Server Mode</b>: <b>Asynchronous</b> or <b>IrDa</b>
1839 \note Only necessary pin connections are Tx, Rx and GND. Flow control (RTS, CTS), modem lines (DSR, DTR, DCD, RI) and
1840 synchronous clock (CLK) line are optional and depend on pin availability and driver support for flow control, modem lines and
1842 \note For stable idle level on Rx lines, external pull-ups can be added.
1844 \image html usart_server_pin_connections_async.png
1846 Required pin connections for the <b>USART Server</b> test mode with <b>USART Server Mode</b>: <b>Single-wire</b>
1848 \image html usart_server_pin_connections_single_wire.png
1850 \note Asynchronous and IrDa modes use same connection type and Single-wire uses a different connection.
1851 \note Please ensure that correct connection is used as required by tests otherwise damage to hardware may occur
1852 (For example using Asynchronous mode selected with hardware connected for Single-wire tests can result in damaged pins).
1853 \note In this mode Tx and Rx pins are internally connected together.
1854 \note Tx pin should use open-drain setting in this mode to prevent damage in case of simultaneous
1855 driving from both USART Server and USART Client.
1857 \note To ensure proper signal quality:
1858 - keep the connecting wires as short as possible
1859 - if possible keep Tx and Rx wires wires separate from each other
1860 - ensure a good Ground (GND) connection between USART Server and DUT
1862 \defgroup usart_tests Tests
1866 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1867 /* USART Driver Management tests */
1868 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1870 \defgroup usart_tests_drv_mgmt Driver Management
1871 \ingroup usart_tests
1873 These tests verify API and operation of the USART driver management functions.
1875 The driver management tests verify the following driver functions
1876 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html" target="_blank">USART Driver function documentation</a>):
1879 ARM_DRIVER_VERSION GetVersion (void);
1881 - \b GetCapabilities
1883 ARM_USART_CAPABILITIES GetCapabilities (void);
1887 int32_t Initialize (ARM_USART_SignalEvent_t cb_event);
1891 int32_t Uninitialize (void);
1895 int32_t PowerControl (ARM_POWER_STATE state);
1901 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1903 \brief Function: Function USART_GetVersion
1905 The function \b UDSART_GetVersion verifies the \b GetVersion function.
1907 ARM_DRIVER_VERSION GetVersion (void);
1911 - Driver is uninitialized and peripheral is powered-off:
1912 - Call GetVersion function
1913 - Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1915 void USART_GetVersion (void) {
1916 ARM_DRIVER_VERSION ver;
1918 ver = drv->GetVersion();
1920 // Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1921 TEST_ASSERT((ver.api >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)) && (ver.drv >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)));
1923 (void)snprintf(msg_buf, sizeof(msg_buf), "[INFO] Driver API version %d.%d, Driver version %d.%d", (ver.api >> 8), (ver.api & 0xFFU), (ver.drv >> 8), (ver.drv & 0xFFU));
1924 TEST_MESSAGE(msg_buf);
1927 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1929 \brief Function: Function USART_GetCapabilities
1931 The function \b USART_GetCapabilities verifies the \b GetCapabilities function.
1933 ARM_USART_CAPABILITIES GetCapabilities (void);
1937 - Driver is uninitialized and peripheral is powered-off:
1938 - Call GetCapabilities function
1939 - Assert that GetCapabilities function returned capabilities structure with reserved field 0
1941 void USART_GetCapabilities (void) {
1942 ARM_USART_CAPABILITIES cap;
1944 cap = drv->GetCapabilities();
1946 // Assert that GetCapabilities function returned capabilities structure with reserved field 0
1947 TEST_ASSERT_MESSAGE((cap.reserved == 0U), "[FAILED] Capabilities reserved field must be 0");
1950 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1952 \brief Function: Function USART_Initialize_Uninitialize
1954 The function \b USART_Initialize_Uninitialize verifies the \b Initialize and \b Uninitialize functions.
1956 int32_t Initialize (ARM_USART_SignalEvent_t cb_event);
1959 int32_t Uninitialize (void);
1963 - Driver is uninitialized and peripheral is powered-off:
1964 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1965 - Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1966 - Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1967 - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1968 - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1969 - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1970 - Call GetTxCount function and assert that it returned 0
1971 - Call GetRxCount function and assert that it returned 0
1972 - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1973 - Call GetStatus function
1974 - Assert that GetStatus function returned status structure with tx_busy flag 0
1975 - Assert that GetStatus function returned status structure with rx_busy flag 0
1976 - Assert that GetStatus function returned status structure with tx_underflow flag 0
1977 - Assert that GetStatus function returned status structure with rx_overflow flag 0
1978 - Assert that GetStatus function returned status structure with rx_break flag 0
1979 - Assert that GetStatus function returned status structure with rx_framing_error flag 0
1980 - Assert that GetStatus function returned status structure with rx_parity_error flag 0
1981 - Assert that GetStatus function returned status structure with reserved field 0
1982 - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1983 - Driver is initialized and peripheral is powered-off:
1984 - Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1985 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1986 - Driver is uninitialized and peripheral is powered-off:
1987 - Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1988 - Driver is initialized and peripheral is powered-off:
1989 - Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1990 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1991 - Driver is uninitialized and peripheral is powered-off:
1992 - Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1993 - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1994 - Driver is initialized and peripheral is powered-off:
1995 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1996 - Driver is initialized and peripheral is powered-on:
1997 - Call Control function and assert that it returned ARM_DRIVER_OK status
1998 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status<br>
1999 (this must unconditionally terminate active send/receive/transfer, power-off the peripheral and uninitialize the driver)
2000 - Driver is uninitialized and peripheral is powered-off:
2001 - Call GetStatus function
2002 - Assert that GetStatus function returned status structure with tx_busy flag 0
2003 - Assert that GetStatus function returned status structure with rx_busy flag 0
2005 void USART_Initialize_Uninitialize (void) {
2006 ARM_USART_STATUS stat;
2008 // Driver is uninitialized and peripheral is powered-off:
2009 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
2010 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_ERROR);
2012 stat = drv->GetStatus();
2014 // Call PowerControl(ARM_POWER_LOW) function and assert that it returned status different then ARM_DRIVER_OK
2015 TEST_ASSERT(drv->PowerControl (ARM_POWER_LOW) != ARM_DRIVER_OK);
2017 stat = drv->GetStatus();
2019 // Call Send function and assert that it returned ARM_DRIVER_ERROR status
2020 TEST_ASSERT(drv->Send (ptr_tx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2022 // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
2023 TEST_ASSERT(drv->Receive (ptr_rx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2025 // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
2026 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2028 // Call Control function and assert that it returned ARM_DRIVER_ERROR status
2029 TEST_ASSERT(drv->Control (((USART_CFG_DEF_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) | ARM_USART_DATA_BITS_8, USART_CFG_DEF_BAUDRATE) == ARM_DRIVER_ERROR);
2031 // Call GetStatus function
2032 stat = drv->GetStatus();
2034 // Assert that GetStatus function returned status structure with tx_busy flag 0
2035 TEST_ASSERT(stat.tx_busy == 0U);
2037 // Assert that GetStatus function returned status structure with rx_busy flag 0
2038 TEST_ASSERT(stat.rx_busy == 0U);
2040 // Assert that GetStatus function returned status structure with tx_underflow flag 0
2041 TEST_ASSERT(stat.tx_underflow == 0U);
2043 // Assert that GetStatus function returned status structure with rx_overflow flag 0
2044 TEST_ASSERT(stat.rx_overflow == 0U);
2046 // Assert that GetStatus function returned status structure with rx_break flag 0
2047 TEST_ASSERT(stat.rx_break == 0U);
2049 // Assert that GetStatus function returned status structure with rx_framing_error flag 0
2050 TEST_ASSERT(stat.rx_framing_error == 0U);
2052 // Assert that GetStatus function returned status structure with rx_parity_error flag 0
2053 TEST_ASSERT(stat.rx_parity_error == 0U);
2055 // Assert that GetStatus function returned status structure with reserved field 0
2056 TEST_ASSERT(stat.reserved == 0U);
2058 // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
2059 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
2061 // Driver is initialized and peripheral is powered-off:
2062 // Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
2063 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
2065 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
2066 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
2068 // Driver is uninitialized and peripheral is powered-off:
2069 // Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
2070 TEST_ASSERT(drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK);
2072 // Driver is initialized and peripheral is powered-off:
2073 // Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
2074 TEST_ASSERT(drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK);
2076 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
2077 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
2079 // Driver is uninitialized and peripheral is powered-off:
2080 // Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
2081 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
2083 // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
2084 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
2086 // Driver is initialized and peripheral is powered-off:
2087 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2088 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
2090 // Driver is initialized and peripheral is powered-on:
2091 // Call Control function and assert that it returned ARM_DRIVER_OK status
2092 TEST_ASSERT(drv->Control (((USART_CFG_DEF_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
2093 ((USART_CFG_DEF_CPOL << ARM_USART_CPOL_Pos) & ARM_USART_CPOL_Msk) |
2094 ((USART_CFG_DEF_CPHA << ARM_USART_CPHA_Pos) & ARM_USART_CPHA_Msk) |
2095 ARM_USART_DATA_BITS_8, USART_CFG_DEF_BAUDRATE) == ARM_DRIVER_OK);
2097 // Call Uninitialize function assert that it returned ARM_DRIVER_OK status
2098 // (this must unconditionally terminate active send/receive/transfer, power-off the peripheral and uninitialize the driver)
2099 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
2101 // Driver is uninitialized and peripheral is powered-off:
2102 // Call GetStatus function
2103 stat = drv->GetStatus();
2105 // Assert that GetStatus function returned status structure with tx_busy flag 0
2106 TEST_ASSERT(stat.tx_busy == 0U);
2108 // Assert that GetStatus function returned status structure with rx_busy flag 0
2109 TEST_ASSERT(stat.rx_busy == 0U);
2112 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2114 \brief Function: Function USART_PowerControl
2116 The function \b USART_PowerControl verifies the \b PowerControl function.
2118 int32_t PowerControl (ARM_POWER_STATE state);
2122 - Driver is initialized and peripheral is powered-off:
2123 - Call Send function and assert that it returned ARM_DRIVER_ERROR status
2124 - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
2125 - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
2126 - Call GetTxCount function and assert that it returned 0
2127 - Call GetRxCount function and assert that it returned 0
2128 - Call Control function and assert that it returned ARM_DRIVER_ERROR status
2129 - Call GetStatus function
2130 - Assert that GetStatus function returned status structure with tx_busy flag 0
2131 - Assert that GetStatus function returned status structure with rx_busy flag 0
2132 - Assert that GetStatus function returned status structure with tx_underflow flag 0
2133 - Assert that GetStatus function returned status structure with rx_overflow flag 0
2134 - Assert that GetStatus function returned status structure with rx_break flag 0
2135 - Assert that GetStatus function returned status structure with rx_framing_error flag 0
2136 - Assert that GetStatus function returned status structure with rx_parity_error flag 0
2137 - Assert that GetStatus function returned status structure with reserved field 0
2138 - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
2139 - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
2140 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2141 - Driver is initialized and peripheral is powered-on:
2142 - Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
2143 - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
2144 - Driver is initialized and peripheral is powered-off:
2145 - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
2146 - Call PowerControl(ARM_POWER_LOW) function
2147 - Driver is initialized and peripheral is powered-on or in low-power mode:
2148 - Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
2149 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2150 - Driver is initialized and peripheral is powered-on:
2151 - Call Control function and assert that it returned ARM_DRIVER_OK status
2152 - Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_OK status<br>
2153 (this must unconditionally terminate active send/receive/transfer and power-off the peripheral)
2154 - Driver is initialized and peripheral is powered-off:
2155 - Call GetStatus function
2156 - Assert that GetStatus function returned status structure with tx_busy flag 0
2157 - Assert that GetStatus function returned status structure with rx_busy flag 0
2159 void USART_PowerControl (void) {
2161 ARM_USART_STATUS stat;
2163 (void)drv->Initialize (NULL);
2165 // Driver is initialized and peripheral is powered-off:
2166 // Call Send function and assert that it returned ARM_DRIVER_ERROR status
2167 TEST_ASSERT(drv->Send (ptr_tx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2169 // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
2170 TEST_ASSERT(drv->Receive (ptr_rx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2172 // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
2173 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2175 // Call Control function and assert that it returned ARM_DRIVER_ERROR status
2176 TEST_ASSERT(drv->Control (((USART_CFG_DEF_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
2177 ((USART_CFG_DEF_CPOL << ARM_USART_CPOL_Pos) & ARM_USART_CPOL_Msk) |
2178 ((USART_CFG_DEF_CPHA << ARM_USART_CPHA_Pos) & ARM_USART_CPHA_Msk) |
2179 ARM_USART_DATA_BITS_8, USART_CFG_DEF_BAUDRATE) == ARM_DRIVER_ERROR);
2181 // Call GetStatus function
2182 stat = drv->GetStatus();
2184 // Assert that GetStatus function returned status structure with tx_busy flag 0
2185 TEST_ASSERT(stat.tx_busy == 0U);
2187 // Assert that GetStatus function returned status structure with rx_busy flag 0
2188 TEST_ASSERT(stat.rx_busy == 0U);
2190 // Assert that GetStatus function returned status structure with tx_underflow flag 0
2191 TEST_ASSERT(stat.tx_underflow == 0U);
2193 // Assert that GetStatus function returned status structure with rx_overflow flag 0
2194 TEST_ASSERT(stat.rx_overflow == 0U);
2196 // Assert that GetStatus function returned status structure with rx_break flag 0
2197 TEST_ASSERT(stat.rx_break == 0U);
2199 // Assert that GetStatus function returned status structure with rx_framing_error flag 0
2200 TEST_ASSERT(stat.rx_framing_error == 0U);
2202 // Assert that GetStatus function returned status structure with rx_parity_error flag 0
2203 TEST_ASSERT(stat.rx_parity_error == 0U);
2205 // Assert that GetStatus function returned status structure with reserved field 0
2206 TEST_ASSERT(stat.reserved == 0U);
2208 // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
2209 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2211 // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
2212 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2214 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2215 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
2217 // Driver is initialized and peripheral is powered-on:
2218 // Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
2219 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
2221 // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
2222 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2224 // Driver is initialized and peripheral is powered-off:
2225 // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
2226 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2228 // Call PowerControl(ARM_POWER_LOW) function
2229 ret = drv->PowerControl (ARM_POWER_LOW);
2231 // Driver is initialized and peripheral is powered-on or in low-power mode:
2232 // Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
2233 TEST_ASSERT((ret == ARM_DRIVER_OK) || (ret == ARM_DRIVER_ERROR_UNSUPPORTED));
2234 if (ret == ARM_DRIVER_ERROR_UNSUPPORTED) {
2235 TEST_MESSAGE("[WARNING] PowerControl (ARM_POWER_LOW) is not supported");
2238 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2239 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
2241 // Driver is initialized and peripheral is powered-on:
2242 // Call Control function and assert that it returned ARM_DRIVER_OK status
2243 TEST_ASSERT(drv->Control (((USART_CFG_DEF_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
2244 ((USART_CFG_DEF_CPOL << ARM_USART_CPOL_Pos) & ARM_USART_CPOL_Msk) |
2245 ((USART_CFG_DEF_CPHA << ARM_USART_CPHA_Pos) & ARM_USART_CPHA_Msk) |
2246 ARM_USART_DATA_BITS_8, USART_CFG_DEF_BAUDRATE) == ARM_DRIVER_OK);
2248 // Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_OK status
2249 // (this must unconditionally terminate active send/receive/transfer and power-off the peripheral)
2250 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2252 // Driver is initialized and peripheral is powered-off:
2253 // Call GetStatus function
2254 stat = drv->GetStatus();
2256 // Assert that GetStatus function returned status structure with tx_busy flag 0
2257 TEST_ASSERT(stat.tx_busy == 0U);
2259 // Assert that GetStatus function returned status structure with rx_busy flag 0
2260 TEST_ASSERT(stat.rx_busy == 0U);
2262 (void)drv->Uninitialize ();
2268 // End of usart_tests_drv_mgmt
2270 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2271 /* USART Data Exchange tests */
2272 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2274 \defgroup usart_tests_data_xchg Data Exchange
2275 \ingroup usart_tests
2277 These tests verify API and operation of the USART data exchange functions.
2279 The data exchange tests verify the following driver functions
2280 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html" target="_blank">USART Driver function documentation</a>):
2283 int32_t Send (const void *data, uint32_t num);
2287 int32_t Receive ( void *data, uint32_t num);
2291 int32_t Transfer (const void *data_out, void *data_in, uint32_t num);
2295 uint32_t GetTxCount (void);
2299 uint32_t GetRxCount (void);
2303 int32_t Control (uint32_t control, uint32_t arg);
2307 ARM_USART_STATUS GetStatus (void);
2311 void (*ARM_USART_SignalEvent_t) (uint32_t event);
2314 All of these tests execute a data exchange and check the result of this data exchange.
2316 Data exchange test procedure when Test Mode <b>USART Server</b> is selected:
2317 - send command "SET BUF TX,.." to the USART Server: Set Tx buffer
2318 - send command "SET BUF RX,.." to the USART Server: Set Rx buffer
2319 - send command "SET COM .." to the USART Server: Set communication settings for the next XFER command
2320 - send command "XFER .." to the USART Server: Specify transfer
2321 - driver Control: Configure the USART interface
2322 - driver Control: Set the default Tx value (in synchronous mode only)
2323 - driver Send/Receive/Transfer: Start the requested operation
2324 - driver GetStatus/SignalEvent: Wait for the current operation to finish or time-out<br>
2325 (operation is finished when appropriate tx_busy or rx_busy flag is 0 and send/receive/transfer completed event was signaled)
2326 - assert that operation has finished in expected time
2327 - assert that appropriate ARM_USART_EVENT_SEND_COMPLETE, ARM_USART_EVENT_RECEIVE_COMPLETE
2328 or ARM_USART_EVENT_TRANSFER_COMPLETE event was signaled
2329 - driver GetStatus: Assert that appropriate tx_busy or rx_busy flag is 0
2330 - driver GetTxCount: If it was a send or transfer operation assert that number of transmitted items is same as requested
2331 - driver GetRxCount: If it was a receive or transfer operation assert that number of received items is same as requested
2332 - if operation has timed out call driver Control function to Abort operation and wait timeout time<br>
2333 to make sure that the USART Server is ready for the next command
2334 - assert that received content is as expected
2335 - send command "GET BUF RX,.." to the USART Server: Get Rx buffer
2336 - assert that sent content (read from the USART Server's receive buffer) is as expected
2338 Data exchange <b>Abort</b> test procedure when Test Mode <b>USART Server</b> is selected:
2339 - send command "SET BUF TX,.." to the USART Server: Set Tx buffer
2340 - send command "SET BUF RX,.." to the USART Server: Set Rx buffer
2341 - send command "SET COM .." to the USART Server: Set communication settings for the next XFER command
2342 - send command "XFER .." to the USART Server: Specify transfer
2343 - driver Control: Configure the USART interface
2344 - driver Control: Set the default Tx value (in synchronous mode only)
2345 - driver Send/Receive/Transfer: Start the requested operation
2347 - driver Control: Abort the current operation
2348 - driver GetStatus: Assert that appropriate tx_busy or rx_busy flag is 0
2349 - driver GetTxCount: If it was a send or transfer operation assert that number of transmitted items is less than requested
2350 - driver GetRxCount: If it was a receive or transfer operation assert that number of received items is less than requested
2352 Data exchange test procedure when Test Mode <b>Loopback</b> is selected:
2353 - driver Control: Configure the USART interface
2354 - driver Control: Set the default Tx value (in synchronous mode only)
2355 - driver Send/Receive/Transfer: Start the requested operation
2356 - driver GetStatus/SignalEvent: Wait for the current operation to finish or time-out<br>
2357 (operation is finished when appropriate tx_busy or rx_busy flag is 0 and send/receive/transfer completed event was signaled)
2358 - assert that operation has finished in expected time
2359 - assert that appropriate ARM_USART_EVENT_SEND_COMPLETE and ARM_USART_EVENT_RECEIVE_COMPLETE
2360 or ARM_USART_EVENT_TRANSFER_COMPLETE event was signaled
2361 - driver GetStatus: Assert that appropriate tx_busy or rx_busy flag is 0
2362 - driver GetTxCount: If it was a send and receive or transfer operation assert that number of transmitted items is same as requested
2363 - driver GetRxCount: If it was a send and receive or transfer operation assert that number of received items is same as requested
2364 - if operation has timed out call driver Control function to Abort operation
2365 - assert that sent and received content is same
2367 \note Limitations of Data Exchange tests if Test Mode <b>Loopback</b> is selected:
2368 - in synchronous mode only Master mode transfer can be tested
2369 - only 8 data bit tests are supported
2370 - parity tests are not supported
2371 - stop bits tests are not supported
2372 - flow control tests are not supported
2373 - clock polarity and clock phase tests are not supported
2377 #ifndef __DOXYGEN__ // Exclude form the documentation
2379 \brief Execute USART data exchange or abort operation.
2380 \param[in] operation operation (OP_SEND .. OP_ABORT_TRANSFER)
2381 \param[in] mode mode (MODE_ASYNCHRONOUS .. MODE_SMART_CARD)
2382 \param[in] data_bits data bits (5 .. 9)
2383 \param[in] parity parity (PARITY_NONE, PARITY_EVEN or PARITY_ODD)
2384 \param[in] stop_bits stop bits (STOP_BITS_1 .. STOP_BITS_0_5)
2385 \param[in] flow_control flow control (FLOW_CONTROL_NONE .. FLOW_CONTROL_RTS_CTS)
2386 \param[in] cpol clock polarity (CPOL0 or CPOL1)
2387 \param[in] cpha clock phase (CPHA0 or CPHA1)
2388 \param[in] baudrate baudrate in bauds
2389 \param[in] num number of items to send, receive or transfer
2392 static void USART_DataExchange_Operation (uint32_t operation, uint32_t mode, uint32_t data_bits, uint32_t parity, uint32_t stop_bits, uint32_t flow_control, uint32_t cpol, uint32_t cpha, uint32_t baudrate, uint32_t num) {
2393 // volatile specifier is used to prevent compiler from optimizing variables
2394 // in a way that they cannot be seen with debugger
2395 volatile int32_t stat, def_tx_stat;
2396 volatile uint32_t drv_mode, drv_data_bits, drv_parity, drv_stop_bits, drv_flow_control, drv_cpol, drv_cpha;
2397 volatile uint32_t srv_mode, srv_dir, srv_flow_control;
2398 volatile ARM_USART_STATUS usart_stat;
2399 volatile uint32_t tx_count, rx_count;
2402 volatile uint32_t srv_delay;
2403 volatile uint32_t drv_delay;
2404 uint8_t chk_tx_data, chk_rx_data;
2405 uint32_t timeout, start_tick, curr_tick;
2407 // Prepare parameters for USART Server and Driver configuration
2408 switch (operation & 0x0FU) {
2414 if (mode == MODE_SYNCHRONOUS_MASTER) {
2415 // In Synchronous Master test wait for USART Server to start the trasnsfer
2418 } else if (mode == MODE_SYNCHRONOUS_SLAVE) {
2419 // In Synchronous Slave test make USART Server wait for driver to start the send operation
2425 case OP_ABORT_RECEIVE:
2429 if (mode == MODE_SYNCHRONOUS_MASTER) {
2430 // In Synchronous Master test wait for USART Server to start the trasnsfer
2433 } else if (mode == MODE_SYNCHRONOUS_SLAVE) {
2434 // In Synchronous Slave test make USART Server wait for driver to start the receive operation
2440 case OP_ABORT_TRANSFER:
2442 if (mode == MODE_SYNCHRONOUS_MASTER) {
2443 // In Synchronous Master test wait for USART Server to start the trasnsfer
2446 } else if (mode == MODE_SYNCHRONOUS_SLAVE) {
2447 // In Synchronous Slave test mode make USART Server wait for driver to start the transfer
2451 TEST_FAIL_MESSAGE("[FAILED] Synchronous mode unknown! Data exchange operation aborted!");
2454 case OP_RECEIVE_SEND_LB:
2460 case MODE_ASYNCHRONOUS:
2461 drv_mode = ARM_USART_MODE_ASYNCHRONOUS;
2462 srv_mode = MODE_ASYNCHRONOUS;
2464 case MODE_SYNCHRONOUS_MASTER:
2465 drv_mode = ARM_USART_MODE_SYNCHRONOUS_MASTER;
2466 srv_mode = MODE_SYNCHRONOUS_SLAVE;
2468 case MODE_SYNCHRONOUS_SLAVE:
2469 drv_mode = ARM_USART_MODE_SYNCHRONOUS_SLAVE;
2470 srv_mode = MODE_SYNCHRONOUS_MASTER;
2472 case MODE_SINGLE_WIRE:
2473 drv_mode = ARM_USART_MODE_SINGLE_WIRE;
2474 srv_mode = MODE_SINGLE_WIRE;
2477 drv_mode = ARM_USART_MODE_IRDA;
2478 srv_mode = MODE_IRDA;
2480 case MODE_SMART_CARD:
2481 TEST_FAIL_MESSAGE("[FAILED] Smart Card mode testing not supported! Data exchange operation aborted!");
2484 TEST_FAIL_MESSAGE("[FAILED] Unknown mode! Data exchange operation aborted!");
2488 switch (data_bits) {
2490 drv_data_bits = ARM_USART_DATA_BITS_5;
2493 drv_data_bits = ARM_USART_DATA_BITS_6;
2496 drv_data_bits = ARM_USART_DATA_BITS_7;
2499 drv_data_bits = ARM_USART_DATA_BITS_8;
2502 drv_data_bits = ARM_USART_DATA_BITS_9;
2505 TEST_FAIL_MESSAGE("[FAILED] Data bits not in range 5 to 9! Data exchange operation aborted!");
2511 drv_parity = ARM_USART_PARITY_NONE;
2514 drv_parity = ARM_USART_PARITY_EVEN;
2517 drv_parity = ARM_USART_PARITY_ODD;
2520 TEST_FAIL_MESSAGE("[FAILED] Unknown parity! Data exchange operation aborted!");
2524 switch (stop_bits) {
2526 drv_stop_bits = ARM_USART_STOP_BITS_1;
2529 drv_stop_bits = ARM_USART_STOP_BITS_2;
2532 drv_stop_bits = ARM_USART_STOP_BITS_1_5;
2535 drv_stop_bits = ARM_USART_STOP_BITS_0_5;
2538 TEST_FAIL_MESSAGE("[FAILED] Unknown stop bits! Data exchange operation aborted!");
2542 switch (flow_control) {
2543 case FLOW_CONTROL_NONE:
2544 drv_flow_control = ARM_USART_FLOW_CONTROL_NONE;
2545 srv_flow_control = FLOW_CONTROL_NONE;
2547 case FLOW_CONTROL_CTS:
2548 drv_flow_control = ARM_USART_FLOW_CONTROL_CTS;
2549 srv_flow_control = FLOW_CONTROL_RTS;
2551 case FLOW_CONTROL_RTS:
2552 drv_flow_control = ARM_USART_FLOW_CONTROL_RTS;
2553 srv_flow_control = FLOW_CONTROL_CTS;
2555 case FLOW_CONTROL_RTS_CTS:
2556 drv_flow_control = ARM_USART_FLOW_CONTROL_RTS_CTS;
2557 srv_flow_control = FLOW_CONTROL_RTS_CTS;
2560 TEST_FAIL_MESSAGE("[FAILED] Unknown flow control! Data exchange operation aborted!");
2566 drv_cpol = ARM_USART_CPOL0;
2569 drv_cpol = ARM_USART_CPOL1;
2572 TEST_FAIL_MESSAGE("[FAILED] Unknown clock polarity! Data exchange operation aborted!");
2578 drv_cpha = ARM_USART_CPHA0;
2581 drv_cpha = ARM_USART_CPHA1;
2584 TEST_FAIL_MESSAGE("[FAILED] Unknown clock phase! Data exchange operation aborted!");
2588 // Total transfer timeout (10 ms is overhead before transfer starts)
2589 timeout = USART_CFG_XFER_TIMEOUT + 10U;
2591 // Check that USART status is not busy before starting data exchange test
2592 usart_stat = drv->GetStatus(); // Get USART status
2593 if (usart_stat.tx_busy != 0U) {
2594 // If tx_busy flag is active
2595 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Tx busy active before operation! Data exchange operation aborted!");
2597 TEST_ASSERT_MESSAGE(usart_stat.tx_busy == 0U, msg_buf);
2598 if (usart_stat.rx_busy != 0U) {
2599 // If rx_busy flag is active
2600 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Rx busy active before operation! Data exchange operation aborted!");
2602 TEST_ASSERT_MESSAGE(usart_stat.rx_busy == 0U, msg_buf);
2603 if (usart_stat.tx_busy != 0U) {
2604 return; // If tx busy is active abort data exchange operation
2606 if (usart_stat.rx_busy != 0U) {
2607 return; // If rx busy is active abort data exchange operation
2611 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
2612 if (CmdSetBufTx('S') != EXIT_SUCCESS) { break; }
2613 if (CmdSetBufRx('?') != EXIT_SUCCESS) { break; }
2614 if (CmdSetCom (srv_mode, data_bits, parity, stop_bits, srv_flow_control, cpol, cpha, baudrate) != EXIT_SUCCESS) { break; }
2615 if (CmdXfer (srv_dir, num, srv_delay, USART_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
2616 #else // If Test Mode Loopback is selected
2617 // Remove warnings for unused variables
2620 (void)srv_flow_control;
2625 start_tick = osKernelGetTickCount();
2627 // Initialize buffers
2628 memset(ptr_tx_buf, (int32_t)'!' , USART_BUF_MAX);
2629 memset(ptr_tx_buf, (int32_t)'T' , num * DataBitsToBytes(data_bits));
2630 memset(ptr_rx_buf, (int32_t)'?' , USART_BUF_MAX);
2631 memset(ptr_cmp_buf, (int32_t)'?' , USART_BUF_MAX);
2633 // Configure required communication settings
2634 (void)osDelay(drv_delay); // Wait specified time before calling Control function
2635 stat = drv->Control (drv_mode | drv_data_bits | drv_parity | drv_stop_bits | drv_flow_control | drv_cpol | drv_cpha, baudrate);
2637 if (stat != ARM_DRIVER_OK) {
2638 // If configuration has failed
2639 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Control function returned", str_ret[-stat]);
2641 // Assert that Control function returned ARM_DRIVER_OK
2642 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2644 if (stat != ARM_DRIVER_OK) {
2645 // If control function has failed means driver does not support requested settings
2646 // wait for timeout and exit
2647 (void)osDelay(timeout+20U); // Wait for USART Server to timout XFER and start reception of next command
2648 return; // Here Abort test is finished, exit
2651 // Set default 3/16 bit IrDA pulse period (only for IrDA mode)
2652 if (mode == MODE_IRDA) {
2653 stat = drv->Control (ARM_USART_SET_IRDA_PULSE, 0U);
2654 if ((stat != ARM_DRIVER_OK) && (stat != ARM_DRIVER_ERROR_UNSUPPORTED)) {
2655 // If set IrDA pulse has failed
2656 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Set IrDA pulse value returned", str_ret[-stat]);
2658 // Assert that Control function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED
2659 TEST_ASSERT_MESSAGE((stat == ARM_DRIVER_OK) || (stat == ARM_DRIVER_ERROR_UNSUPPORTED), msg_buf);
2661 if (stat == ARM_DRIVER_ERROR_UNSUPPORTED) {
2662 // If set IrDA pulse value is not supported
2663 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] %s: %s", str_oper[operation], "Set default IrDA pulse value is not supported");
2664 TEST_MESSAGE(msg_buf);
2668 // Set default Tx value to 'D' byte values (only for synchronous mode)
2669 if ((mode == MODE_SYNCHRONOUS_MASTER) || (mode == MODE_SYNCHRONOUS_SLAVE)) {
2670 val = ((uint32_t)'D' << 24) | ((uint32_t)'D' << 16) | ((uint32_t)'D' << 8) | (uint32_t)'D';
2671 stat = drv->Control (ARM_USART_SET_DEFAULT_TX_VALUE, val);
2673 if ((stat != ARM_DRIVER_OK) && (stat != ARM_DRIVER_ERROR_UNSUPPORTED)) {
2674 // If set default Tx value has failed
2675 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Set default Tx value returned", str_ret[-stat]);
2677 // Assert that Control function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED
2678 TEST_ASSERT_MESSAGE((stat == ARM_DRIVER_OK) || (stat == ARM_DRIVER_ERROR_UNSUPPORTED), msg_buf);
2680 if (stat == ARM_DRIVER_ERROR_UNSUPPORTED) {
2681 // If set default Tx value is not supported
2682 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] %s: %s", str_oper[operation], "Set default Tx value is not supported");
2683 TEST_MESSAGE(msg_buf);
2686 // For slave mode default Tx is not tested
2687 def_tx_stat = ARM_DRIVER_ERROR_UNSUPPORTED;
2690 // Prepare local variables
2692 duration = 0xFFFFFFFFUL;
2695 tx_count_sample = 0U;
2696 rx_count_sample = 0U;
2699 start_cnt = osKernelGetSysTimerCount();
2701 // Start the data exchange operation
2702 switch (operation & 0x0FU) {
2705 stat = drv->Control(ARM_USART_CONTROL_TX, 1U);
2706 if (stat != ARM_DRIVER_OK) {
2707 // If transmitter enable has failed
2708 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transmitter enable returned", str_ret[-stat]);
2710 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
2711 chk_tx_data = 1U; // Check sent data
2713 stat = drv->Send(ptr_tx_buf, num);
2714 if (stat != ARM_DRIVER_OK) {
2715 // If Send activation has failed
2716 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Send function returned", str_ret[-stat]);
2718 // Assert that Send function returned ARM_DRIVER_OK
2719 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2722 case OP_ABORT_RECEIVE:
2723 stat = drv->Control(ARM_USART_CONTROL_RX, 1U);
2724 if (stat != ARM_DRIVER_OK) {
2725 // If receiver enable has failed
2726 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receiver enable returned", str_ret[-stat]);
2728 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
2729 chk_rx_data = 1U; // Check received data
2731 stat = drv->Receive(ptr_rx_buf, num);
2732 if (stat != ARM_DRIVER_OK) {
2733 // If Receive activation has failed
2734 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receive function returned", str_ret[-stat]);
2736 // Assert that Receive function returned ARM_DRIVER_OK
2737 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2740 case OP_ABORT_TRANSFER:
2741 stat = drv->Control(ARM_USART_CONTROL_TX, 1U);
2742 if (stat != ARM_DRIVER_OK) {
2743 // If transmitter enable has failed
2744 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transmitter enable returned", str_ret[-stat]);
2746 stat = drv->Control(ARM_USART_CONTROL_RX, 1U);
2747 if (stat != ARM_DRIVER_OK) {
2748 // If receiver enable has failed
2749 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receiver enable returned", str_ret[-stat]);
2751 chk_tx_data = 1U; // Check sent data
2752 chk_rx_data = 1U; // Check received data
2753 stat = drv->Transfer(ptr_tx_buf, ptr_rx_buf, num);
2754 if (stat != ARM_DRIVER_OK) {
2755 // If Transfer activation has failed
2756 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transfer function returned", str_ret[-stat]);
2758 // Assert that Transfer function returned ARM_DRIVER_OK
2759 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2761 case OP_RECEIVE_SEND_LB:
2762 stat = drv->Control(ARM_USART_CONTROL_TX, 1U);
2763 if (stat != ARM_DRIVER_OK) {
2764 // If transmitter enable has failed
2765 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transmitter enable returned", str_ret[-stat]);
2767 stat = drv->Control(ARM_USART_CONTROL_RX, 1U);
2768 if (stat != ARM_DRIVER_OK) {
2769 // If receiver enable has failed
2770 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receiver enable returned", str_ret[-stat]);
2772 chk_rx_data = 1U; // Check received data
2773 stat = drv->Receive(ptr_rx_buf, num);
2774 if (stat != ARM_DRIVER_OK) {
2775 // If Receive activation has failed
2776 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receive function returned", str_ret[-stat]);
2778 // Assert that Receive function returned ARM_DRIVER_OK
2779 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2780 chk_tx_data = 1U; // Check sent data
2781 stat = drv->Send(ptr_tx_buf, num);
2782 if (stat != ARM_DRIVER_OK) {
2783 // If Send activation has failed
2784 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Send function returned", str_ret[-stat]);
2786 // Assert that Send function returned ARM_DRIVER_OK
2787 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2790 TEST_FAIL_MESSAGE("[FAILED] Unknown operation! Data exchange operation aborted!");
2794 if ((operation == OP_ABORT_SEND) || // This IF block tests only abort functionality
2795 (operation == OP_ABORT_RECEIVE) ||
2796 (operation == OP_ABORT_TRANSFER)) {
2797 (void)osDelay(1U); // Wait short time before doing Abort
2798 switch (operation & 0x0FU) {
2800 stat = drv->Control (ARM_USART_ABORT_SEND, 0U);
2802 case OP_ABORT_RECEIVE:
2803 stat = drv->Control (ARM_USART_ABORT_RECEIVE, 0U);
2805 case OP_ABORT_TRANSFER:
2806 stat = drv->Control (ARM_USART_ABORT_TRANSFER, 0U);
2809 if (stat != ARM_DRIVER_OK) {
2810 // If Abort has failed
2811 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
2813 // Assert that Control function returned ARM_DRIVER_OK
2814 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2815 usart_stat = drv->GetStatus(); // Get USART status
2816 if (usart_stat.tx_busy != 0U) {
2817 // If tx_busy flag is still active
2818 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Tx busy still active after Abort");
2820 // Assert that tx_busy flag is not active
2821 TEST_ASSERT_MESSAGE(usart_stat.tx_busy == 0U, msg_buf);
2822 if (usart_stat.rx_busy != 0U) {
2823 // If rx_busy flag is still active
2824 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Rx busy still active after Abort");
2826 // Assert that rx_busy flag is not active
2827 TEST_ASSERT_MESSAGE(usart_stat.rx_busy == 0U, msg_buf);
2829 if ((operation == OP_ABORT_SEND) || (operation == OP_ABORT_TRANSFER)) {
2830 tx_count = drv->GetTxCount(); // Get Tx count
2831 if (tx_count >= num) {
2832 // If Tx count is more or equal to number of items then Abort has failed
2833 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetTxCount returned", tx_count, "after Abort of", num, "items");
2835 // Assert data count is less then number of items requested for send/transfer
2836 TEST_ASSERT_MESSAGE(tx_count < num, msg_buf);
2838 if ((operation == OP_ABORT_RECEIVE) || (operation == OP_ABORT_TRANSFER)) {
2839 rx_count = drv->GetRxCount(); // Get Rx count
2840 if (rx_count >= num) {
2841 // If Rx count is more or equal to number of items then Abort has failed
2842 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetRxCount returned", rx_count, "after Abort of", num, "items");
2844 // Assert data count is less then number of items requested for receive/transfer
2845 TEST_ASSERT_MESSAGE(rx_count < num, msg_buf);
2848 stat = drv->Control(ARM_USART_CONTROL_TX, 0U);
2849 if (stat != ARM_DRIVER_OK) {
2850 // If transmitter disable has failed
2851 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transmitter disable returned", str_ret[-stat]);
2853 stat = drv->Control(ARM_USART_CONTROL_RX, 0U);
2854 if (stat != ARM_DRIVER_OK) {
2855 // If receiver disable has failed
2856 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receiver disable returned", str_ret[-stat]);
2859 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
2860 // Wait until timeout expires
2861 curr_tick = osKernelGetTickCount();
2862 if ((curr_tick - start_tick) < timeout) {
2863 (void)osDelay(timeout - (curr_tick - start_tick));
2865 (void)osDelay(20U); // Wait for USART Server to start reception of next command
2868 return; // Here Abort test is finished, exit
2871 // Wait for operation to finish
2872 // for send operation wait until status tx_busy is 0 and
2873 // event ARM_USART_EVENT_SEND_COMPLETE is signaled, or timeout
2874 // for receive operation wait until status rx_busy is 0 and
2875 // event ARM_USART_EVENT_RECEIVE_COMPLETE is signaled, or timeout
2876 // for transfer operation wait until status tx_busy and rx_busy is 0 and
2877 // event ARM_USART_EVENT_TRANSFER_COMPLETE is signaled, or timeout
2878 // for receive and send operation wait until status tx_busy and rx_busy is 0 and
2879 // both events ARM_USART_EVENT_SEND_COMPLETE and ARM_USART_EVENT_RECEIVE_COMPLETE are signaled, or timeout
2881 if (operation == OP_SEND) {
2882 if (tx_count_sample == 0U) {
2883 // Store first Tx count different than 0
2884 tx_count_sample = drv->GetTxCount(); // Get Tx count
2886 if ((drv->GetStatus().tx_busy == 0U) && ((event & ARM_USART_EVENT_SEND_COMPLETE) != 0U)) {
2887 duration = osKernelGetSysTimerCount() - start_cnt;
2891 if (operation == OP_RECEIVE) {
2892 if (rx_count_sample == 0U) {
2893 // Store first Rx count different than 0
2894 rx_count_sample = drv->GetRxCount(); // Get Rx count
2896 if ((drv->GetStatus().rx_busy == 0U) && ((event & ARM_USART_EVENT_RECEIVE_COMPLETE) != 0U)) {
2897 duration = osKernelGetSysTimerCount() - start_cnt;
2901 if (operation == OP_TRANSFER) {
2902 if (tx_count_sample == 0U) {
2903 // Store first Tx count different than 0
2904 tx_count_sample = drv->GetTxCount(); // Get Tx count
2906 if (rx_count_sample == 0U) {
2907 // Store first Rx count different than 0
2908 rx_count_sample = drv->GetRxCount(); // Get Rx count
2910 if ((drv->GetStatus().tx_busy == 0U) && (drv->GetStatus().rx_busy == 0U) && ((event & ARM_USART_EVENT_TRANSFER_COMPLETE) != 0U)) {
2911 duration = osKernelGetSysTimerCount() - start_cnt;
2915 if (operation == OP_RECEIVE_SEND_LB) {
2916 if (tx_count_sample == 0U) {
2917 // Store first Tx count different than 0
2918 tx_count_sample = drv->GetTxCount(); // Get Tx count
2920 if (rx_count_sample == 0U) {
2921 // Store first Rx count different than 0
2922 rx_count_sample = drv->GetRxCount(); // Get Rx count
2924 if ((drv->GetStatus().tx_busy == 0U) && (drv->GetStatus().rx_busy == 0U) &&
2925 ((event & (ARM_USART_EVENT_RECEIVE_COMPLETE | ARM_USART_EVENT_SEND_COMPLETE)) ==
2926 (ARM_USART_EVENT_RECEIVE_COMPLETE | ARM_USART_EVENT_SEND_COMPLETE))) {
2927 duration = osKernelGetSysTimerCount() - start_cnt;
2931 } while ((osKernelGetTickCount() - start_tick) < timeout);
2933 if (duration == 0xFFFFFFFFUL) {
2934 // If operation has timed out
2935 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Operation timed out");
2937 // Assert that operation has finished in expected time
2938 TEST_ASSERT_MESSAGE(duration != 0xFFFFFFFFUL, msg_buf);
2940 if (duration != 0xFFFFFFFFUL) {
2941 // For Synchronous Slave duration is started by Master srv_delay later so this has to be deducted
2942 if (mode == MODE_SYNCHRONOUS_SLAVE) {
2943 if (srv_delay > 1U) {
2944 srv_delay --; // Reduce 1 ms tolerance of delay
2945 if (duration > (srv_delay * (systick_freq / 1000U))) {
2946 duration -= srv_delay * (systick_freq / 1000U);
2952 // Check all expected conditions after Send operation
2953 if (operation == OP_SEND) {
2954 if ((event & ARM_USART_EVENT_SEND_COMPLETE) == 0U) {
2955 // If send complete event was not signaled
2956 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_SEND_COMPLETE was not signaled");
2957 chk_tx_data = 0U; // Do not check sent content
2959 // Assert that ARM_USART_EVENT_SEND_COMPLETE was signaled
2960 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_SEND_COMPLETE) != 0U, msg_buf);
2962 if (drv_cap.event_tx_complete != 0U) {
2963 // If driver supports Tx complete signaling
2964 if ((event & ARM_USART_EVENT_TX_COMPLETE) == 0U) {
2965 // If Tx complete event was not signaled
2966 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_TX_COMPLETE was not signaled");
2967 chk_tx_data = 0U; // Do not check sent content
2969 // Assert that ARM_USART_EVENT_TX_COMPLETE was signaled
2970 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_TX_COMPLETE) != 0U, msg_buf);
2973 usart_stat = drv->GetStatus(); // Get USART status
2974 if (usart_stat.tx_busy != 0U) {
2975 // If tx_busy flag is still active
2976 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Tx busy still active after operation");
2977 chk_tx_data = 0U; // Do not check sent content
2979 // Assert that tx_busy flag is not active
2980 TEST_ASSERT_MESSAGE(usart_stat.tx_busy == 0U, msg_buf);
2982 tx_count = drv->GetTxCount(); // Get Tx count
2983 if (tx_count != num) {
2984 // If Tx count is different then number of items, then operation has failed
2985 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetTxCount returned", tx_count, "expected was", num, "items");
2986 chk_tx_data = 0U; // Do not check sent content
2988 // Assert that Tx count is equal to number of items requested for send
2989 TEST_ASSERT_MESSAGE(tx_count == num, msg_buf);
2991 if ((drv->GetStatus().tx_busy != 0U) || ((event & ARM_USART_EVENT_SEND_COMPLETE) == 0U)) {
2992 // If send did not finish in time, abort it
2993 (void)drv->Control(ARM_USART_ABORT_SEND, 0U);
2997 // Check all expected conditions after Receive operation
2998 if (operation == OP_RECEIVE) {
2999 if ((event & ARM_USART_EVENT_RECEIVE_COMPLETE) == 0U) {
3000 // If receive complete event was not signaled
3001 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_RECEIVE_COMPLETE was not signaled");
3002 chk_rx_data = 0U; // Do not check received content
3004 // Assert that ARM_USART_EVENT_RECEIVE_COMPLETE was signaled
3005 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RECEIVE_COMPLETE) != 0U, msg_buf);
3007 usart_stat = drv->GetStatus(); // Get USART status
3008 if (usart_stat.rx_busy != 0U) {
3009 // If rx_busy flag is still active
3010 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Rx busy still active after operation");
3011 chk_rx_data = 0U; // Do not check received content
3013 // Assert that rx_busy flag is not active
3014 TEST_ASSERT_MESSAGE(usart_stat.rx_busy == 0U, msg_buf);
3016 if ((event & ARM_USART_EVENT_RX_OVERFLOW) != 0U) {
3017 // If Rx overflow was signaled during the transfer
3018 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_RX_OVERFLOW was signaled");
3019 chk_rx_data = 0U; // Do not check received content
3021 // Assert that ARM_USART_EVENT_RX_OVERFLOW was not signaled
3022 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_OVERFLOW) == 0U, msg_buf);
3024 rx_count = drv->GetRxCount(); // Get Rx count
3025 if (rx_count != num) {
3026 // If Rx count is different then number of items, then operation has failed
3027 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetRxCount returned", rx_count, "expected was", num, "items");
3028 chk_rx_data = 0U; // Do not check received content
3030 // Assert that Rx count is equal to number of items requested for reception
3031 TEST_ASSERT_MESSAGE(rx_count == num, msg_buf);
3033 if ((drv->GetStatus().rx_busy != 0U) || ((event & ARM_USART_EVENT_RECEIVE_COMPLETE) == 0U)) {
3034 // If reception did not finish in time, abort it
3035 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
3039 // Check all expected conditions after Transfer operation
3040 if (operation == OP_TRANSFER) {
3041 if ((event & ARM_USART_EVENT_TRANSFER_COMPLETE) == 0U) {
3042 // If transfer complete event was not signaled
3043 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_TRANSFER_COMPLETE was not signaled");
3044 chk_tx_data = 0U; // Do not check sent content
3045 chk_rx_data = 0U; // Do not check received content
3047 // Assert that ARM_USART_EVENT_TRANSFER_COMPLETE was signaled
3048 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_TRANSFER_COMPLETE) != 0U, msg_buf);
3050 usart_stat = drv->GetStatus(); // Get USART status
3051 if (usart_stat.tx_busy != 0U) {
3052 // If tx_busy flag is still active
3053 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Tx busy still active after operation");
3054 chk_tx_data = 0U; // Do not check sent content
3056 // Assert that tx_busy flag is not active
3057 TEST_ASSERT_MESSAGE(usart_stat.tx_busy == 0U, msg_buf);
3058 if (usart_stat.rx_busy != 0U) {
3059 // If rx_busy flag is still active
3060 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Rx busy still active after operation");
3061 chk_rx_data = 0U; // Do not check received content
3063 // Assert that rx_busy flag is not active
3064 TEST_ASSERT_MESSAGE(usart_stat.rx_busy == 0U, msg_buf);
3066 if ((event & ARM_USART_EVENT_TX_UNDERFLOW) != 0U) {
3067 // If Tx underflow was signaled during the transfer
3068 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_TX_UNDERFLOW was signaled");
3069 chk_tx_data = 0U; // Do not check sent content
3071 // Assert that ARM_USART_EVENT_TX_UNDERFLOW was not signaled
3072 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_TX_UNDERFLOW) == 0U, msg_buf);
3074 if ((event & ARM_USART_EVENT_RX_OVERFLOW) != 0U) {
3075 // If Rx overflow was signaled during the transfer
3076 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_TX_UNDERFLOW was signaled");
3077 chk_rx_data = 0U; // Do not check received content
3079 // Assert that ARM_USART_EVENT_RX_OVERFLOW was not signaled
3080 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_OVERFLOW) == 0U, msg_buf);
3082 tx_count = drv->GetTxCount(); // Get Tx count
3083 if (tx_count != num) {
3084 // If Tx count is different then number of items, then operation has failed
3085 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetTxCount returned", tx_count, "expected was", num, "items");
3086 chk_tx_data = 0U; // Do not check sent content
3088 // Assert that Tx count is equal to number of items requested for transfer
3089 TEST_ASSERT_MESSAGE(tx_count == num, msg_buf);
3091 rx_count = drv->GetRxCount(); // Get Rx count
3092 if (rx_count != num) {
3093 // If Rx count is different then number of items, then operation has failed
3094 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetRxCount returned", rx_count, "expected was", num, "items");
3095 chk_rx_data = 0U; // Do not check received content
3097 // Assert that Rx count is equal to number of items requested for transfer
3098 TEST_ASSERT_MESSAGE(rx_count == num, msg_buf);
3100 if ((drv->GetStatus().tx_busy != 0U) || (drv->GetStatus().rx_busy != 0U) ||
3101 ((event & ARM_USART_EVENT_TRANSFER_COMPLETE) == 0U)) {
3102 // If transfer did not finish in time, abort it
3103 (void)drv->Control(ARM_USART_ABORT_TRANSFER, 0U);
3107 stat = drv->Control(ARM_USART_CONTROL_TX, 0U);
3108 if (stat != ARM_DRIVER_OK) {
3109 // If transmitter disable has failed
3110 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transmitter disable returned", str_ret[-stat]);
3112 stat = drv->Control(ARM_USART_CONTROL_RX, 0U);
3113 if (stat != ARM_DRIVER_OK) {
3114 // If receiver disable has failed
3115 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receiver disable returned", str_ret[-stat]);
3118 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
3120 // Wait until timeout expires
3121 curr_tick = osKernelGetTickCount();
3122 if ((curr_tick - start_tick) < timeout) {
3123 (void)osDelay(timeout - (curr_tick - start_tick));
3125 (void)osDelay(20U); // Wait for USART Server to start reception of next command
3127 if (chk_rx_data != 0U) { // If received content should be checked
3128 // Check received content
3129 memset(ptr_cmp_buf, (int32_t)'S', num * DataBitsToBytes(data_bits));
3130 if (data_bits == 9U) {
3131 // If 9-bit mode is used zero out unused bits in high byte
3132 for (i = 1U; i < num * 2U; i += 2U) {
3133 ptr_cmp_buf[i] &= 0x01U;
3136 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
3138 // If data received mismatches
3139 // Find on which byte mismatch starts
3140 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
3141 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
3145 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, received was 0x%02X, expected was 0x%02X", str_oper[operation], "Received data mismatches on", i, ptr_rx_buf[i], ptr_cmp_buf[i]);
3147 // Assert that data received is same as expected
3148 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
3151 if (chk_tx_data != 0U) { // If sent content should be checked
3152 // Check sent content (by checking USART Server's received buffer content)
3153 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3154 if (CmdGetBufRx(USART_BUF_MAX) != EXIT_SUCCESS) { break; }
3156 if ((operation == OP_RECEIVE) && (def_tx_stat == ARM_DRIVER_OK)) {
3157 // Expected data received by USART Server should be default Tx value
3158 memset(ptr_cmp_buf, (int32_t)'D', num * DataBitsToBytes(data_bits));
3160 // Expected data received by USART Server should be what was sent
3161 memset(ptr_cmp_buf, (int32_t)'T', num * DataBitsToBytes(data_bits));
3163 if (data_bits == 9U) {
3164 // If 9-bit mode is used zero out unused bits in high byte
3165 for (i = 1U; i < num * 2U; i += 2U) {
3166 ptr_cmp_buf[i] &= 0x01U;
3169 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
3171 // If data sent mismatches
3172 // Find on which byte mismatch starts
3173 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
3174 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
3178 if (operation == OP_RECEIVE) {
3179 // If sent was default Tx value, 'D' bytes
3180 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, USART Server received 0x%02X, sent was 0x%02X", str_oper[operation], "Default Tx data mismatches on", i, ptr_rx_buf[i], ptr_cmp_buf[i]);
3182 // If sent was 'T' bytes
3183 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, USART Server received 0x%02X, sent was 0x%02X", str_oper[operation], "Sent data mismatches on", i, ptr_rx_buf[i], ptr_cmp_buf[i]);
3186 // Assert data sent is same as expected
3187 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
3190 #else // If Test Mode Loopback is selected
3192 // Check all expected conditions after Receive and Send operation (in Loopback Test Mode)
3193 if (operation == OP_RECEIVE_SEND_LB) {
3194 if ((event & ARM_USART_EVENT_SEND_COMPLETE) == 0U) {
3195 // If send complete event was not signaled
3196 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_SEND_COMPLETE was not signaled");
3197 chk_tx_data = 0U; // Do not check sent content
3199 // Assert that ARM_USART_EVENT_SEND_COMPLETE was signaled
3200 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_SEND_COMPLETE) != 0U, msg_buf);
3201 if ((event & ARM_USART_EVENT_RECEIVE_COMPLETE) == 0U) {
3202 // If receive complete event was not signaled
3203 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_RECEIVE_COMPLETE was not signaled");
3204 chk_rx_data = 0U; // Do not check received content
3206 // Assert that ARM_USART_EVENT_RECEIVE_COMPLETE was signaled
3207 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RECEIVE_COMPLETE) != 0U, msg_buf);
3209 usart_stat = drv->GetStatus(); // Get USART status
3210 if (usart_stat.tx_busy != 0U) {
3211 // If tx_busy flag is still active
3212 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Tx busy still active after operation");
3213 chk_tx_data = 0U; // Do not check sent content
3215 // Assert that tx_busy flag is not active
3216 TEST_ASSERT_MESSAGE(usart_stat.tx_busy == 0U, msg_buf);
3217 if (usart_stat.rx_busy != 0U) {
3218 // If rx_busy flag is still active
3219 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Rx busy still active after operation");
3220 chk_rx_data = 0U; // Do not check received content
3222 // Assert that rx_busy flag is not active
3223 TEST_ASSERT_MESSAGE(usart_stat.rx_busy == 0U, msg_buf);
3225 if ((event & ARM_USART_EVENT_TX_UNDERFLOW) != 0U) {
3226 // If Tx underflow was signaled during the transfer
3227 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_TX_UNDERFLOW was signaled");
3228 chk_tx_data = 0U; // Do not check sent content
3230 // Assert that ARM_USART_EVENT_TX_UNDERFLOW was not signaled
3231 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_TX_UNDERFLOW) == 0U, msg_buf);
3233 if ((event & ARM_USART_EVENT_RX_OVERFLOW) != 0U) {
3234 // If Rx overflow was signaled during the transfer
3235 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_TX_UNDERFLOW was signaled");
3236 chk_rx_data = 0U; // Do not check received content
3238 // Assert that ARM_USART_EVENT_RX_OVERFLOW was not signaled
3239 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_OVERFLOW) == 0U, msg_buf);
3241 tx_count = drv->GetTxCount(); // Get Tx count
3242 if (tx_count != num) {
3243 // If Tx count is different then number of items, then operation has failed
3244 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetTxCount returned", tx_count, "expected was", num, "items");
3245 chk_tx_data = 0U; // Do not check sent content
3247 // Assert that Tx count is equal to number of items requested for transfer
3248 TEST_ASSERT_MESSAGE(tx_count == num, msg_buf);
3250 rx_count = drv->GetRxCount(); // Get Rx count
3251 if (rx_count != num) {
3252 // If Rx count is different then number of items, then operation has failed
3253 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetRxCount returned", rx_count, "expected was", num, "items");
3254 chk_rx_data = 0U; // Do not check received content
3256 // Assert that Rx count is equal to number of items requested for transfer
3257 TEST_ASSERT_MESSAGE(rx_count == num, msg_buf);
3259 if ((drv->GetStatus().tx_busy == 0U) && (drv->GetStatus().rx_busy == 0U) &&
3260 ((event & (ARM_USART_EVENT_RECEIVE_COMPLETE | ARM_USART_EVENT_SEND_COMPLETE)) ==
3261 (ARM_USART_EVENT_RECEIVE_COMPLETE | ARM_USART_EVENT_SEND_COMPLETE))) {
3262 // If transfer did not finish in time, abort it
3263 (void)drv->Control(ARM_USART_ABORT_TRANSFER, 0U);
3267 if ((chk_rx_data != 0U) && // If received content should be checked and
3268 (chk_tx_data != 0U)) { // if sent content should be checked
3269 stat = memcmp(ptr_rx_buf, ptr_tx_buf, num * DataBitsToBytes(data_bits));
3271 // If data received mismatches
3272 // Find on which byte mismatch starts
3273 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
3274 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
3278 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, received was 0x%02X, sent was 0x%02X", str_oper[operation], "Received data mismatches on", i, ptr_rx_buf[i], ptr_tx_buf[i]);
3280 // Assert that data received is same as expected
3281 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
3288 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
3289 TEST_FAIL_MESSAGE("[FAILED] Problems in communication with USART Server. Test aborted!");
3293 #endif // End of exclude form the documentation
3295 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3297 \brief Function: Function USART_Mode_Asynchronous
3299 The function \b USART_Mode_Asynchronous verifies data exchange:
3300 - in <b>Asynchronous</b> mode
3301 - with default data bits
3302 - with default parity
3303 - with default stop bits
3304 - with default flow control
3305 - at default baudrate
3306 - for default number of data items
3308 void USART_Mode_Asynchronous (void) {
3310 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3311 if (SettingsCheck (MODE_ASYNCHRONOUS, 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; }
3313 #if (USART_SERVER_USED == 1)
3314 USART_DataExchange_Operation(OP_SEND, MODE_ASYNCHRONOUS, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3315 USART_DataExchange_Operation(OP_RECEIVE, MODE_ASYNCHRONOUS, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3317 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, MODE_ASYNCHRONOUS, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3321 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3323 \brief Function: Function USART_Mode_Synchronous_Master
3325 The function \b USART_Mode_Synchronous_Master verifies data exchange:
3326 - in <b>Synchronous Master</b> mode
3327 - with default data bits
3330 - with no flow control
3331 - with default clock polarity
3332 - with default clock phase
3333 - at default baudrate
3334 - for default number of data items
3336 \note In Test Mode <b>Loopback</b> Receive function is not tested
3338 void USART_Mode_Synchronous_Master (void) {
3340 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3341 if (SettingsCheck (MODE_SYNCHRONOUS_MASTER, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3343 USART_DataExchange_Operation(OP_SEND, MODE_SYNCHRONOUS_MASTER, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3344 #if (USART_SERVER_USED == 1)
3345 USART_DataExchange_Operation(OP_RECEIVE, MODE_SYNCHRONOUS_MASTER, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3347 USART_DataExchange_Operation(OP_TRANSFER, MODE_SYNCHRONOUS_MASTER, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3350 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3352 \brief Function: Function USART_Mode_Synchronous_Slave
3354 The function \b USART_Mode_Synchronous_Slave verifies data exchange:
3355 - in <b>Synchronous Slave</b> mode
3356 - with default data bits
3359 - with no flow control
3360 - with default clock polarity
3361 - with default clock phase
3362 - at default baudrate
3363 - for default number of data items
3365 \note In Test Mode <b>Loopback</b> this test is not executed
3367 void USART_Mode_Synchronous_Slave (void) {
3369 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3370 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3371 if (SettingsCheck (MODE_SYNCHRONOUS_SLAVE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3373 USART_DataExchange_Operation(OP_SEND, MODE_SYNCHRONOUS_SLAVE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3374 USART_DataExchange_Operation(OP_RECEIVE, MODE_SYNCHRONOUS_SLAVE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3375 USART_DataExchange_Operation(OP_TRANSFER, MODE_SYNCHRONOUS_SLAVE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3378 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3380 \brief Function: Function USART_Mode_Single_Wire
3382 The function \b USART_Mode_Single_Wire verifies data exchange:
3383 - in <b>Single-Wire</b> mode
3384 - with default data bits
3385 - with default parity
3386 - with default stop bits
3387 - with no flow control
3388 - at default baudrate
3389 - for default number of data items
3391 \note In Test Mode <b>Loopback</b> this test is not executed
3393 void USART_Mode_Single_Wire (void) {
3395 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3396 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3397 if (SettingsCheck (MODE_SINGLE_WIRE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3399 #if (USART_SERVER_USED == 1)
3400 USART_DataExchange_Operation(OP_SEND, MODE_SINGLE_WIRE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3401 USART_DataExchange_Operation(OP_RECEIVE, MODE_SINGLE_WIRE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3403 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, MODE_SINGLE_WIRE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3407 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3409 \brief Function: Function USART_Mode_IrDA
3411 The function \b USART_Mode_IrDA verifies data exchange:
3412 - in <b>Infra-red Data</b> mode
3413 - with default data bits
3414 - with default parity
3415 - with default stop bits
3416 - with default flow control
3417 - at default baudrate
3418 - for default number of data items
3420 \note In Test Mode <b>Loopback</b> this test is not executed
3422 void USART_Mode_IrDA (void) {
3424 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3425 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3426 if (SettingsCheck (MODE_IRDA, 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; }
3428 #if (USART_SERVER_USED == 1)
3429 USART_DataExchange_Operation(OP_SEND, MODE_IRDA, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3430 USART_DataExchange_Operation(OP_RECEIVE, MODE_IRDA, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3432 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, MODE_IRDA, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3436 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3438 \brief Function: Function USART_Data_Bits_5
3440 The function \b USART_Data_Bits_5 verifies data exchange:
3442 - with <b>5 data bits</b>
3443 - with default parity
3444 - with default stop bits
3445 - with default flow control
3446 - with default clock polarity
3447 - with default clock phase
3448 - at default baudrate
3449 - for default number of data items
3451 \note In Test Mode <b>Loopback</b> this test is not executed
3453 void USART_Data_Bits_5 (void) {
3455 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3456 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3457 if (SettingsCheck (USART_CFG_DEF_MODE, 5U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3459 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, 5U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3460 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, 5U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3461 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3462 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, 5U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3466 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3468 \brief Function: Function USART_Data_Bits_6
3470 The function \b USART_Data_Bits_6 verifies data exchange:
3472 - with <b>6 data bits</b>
3473 - with default parity
3474 - with default stop bits
3475 - with default flow control
3476 - with default clock polarity
3477 - with default clock phase
3478 - at default baudrate
3479 - for default number of data items
3481 \note In Test Mode <b>Loopback</b> this test is not executed
3483 void USART_Data_Bits_6 (void) {
3485 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3486 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3487 if (SettingsCheck (USART_CFG_DEF_MODE, 6U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3489 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, 6U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3490 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, 6U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3491 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3492 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, 6U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3496 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3498 \brief Function: Function USART_Data_Bits_7
3500 The function \b USART_Data_Bits_7 verifies data exchange:
3502 - with <b>7 data bits</b>
3503 - with default parity
3504 - with default stop bits
3505 - with default flow control
3506 - with default clock polarity
3507 - with default clock phase
3508 - at default baudrate
3509 - for default number of data items
3511 \note In Test Mode <b>Loopback</b> this test is not executed
3513 void USART_Data_Bits_7 (void) {
3515 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3516 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3517 if (SettingsCheck (USART_CFG_DEF_MODE, 7U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3519 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, 7U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3520 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, 7U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3521 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3522 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, 7U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3526 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3528 \brief Function: Function USART_Data_Bits_8
3530 The function \b USART_Data_Bits_8 verifies data exchange:
3532 - with <b>8 data bits</b>
3533 - with default parity
3534 - with default stop bits
3535 - with default flow control
3536 - with default clock polarity
3537 - with default clock phase
3538 - at default baudrate
3539 - for default number of data items
3541 void USART_Data_Bits_8 (void) {
3543 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3544 if (SettingsCheck (USART_CFG_DEF_MODE, 8U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3546 #if (USART_SERVER_USED == 1)
3547 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, 8U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3548 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, 8U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3549 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3550 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, 8U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3553 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, 8U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3557 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3559 \brief Function: Function USART_Data_Bits_9
3561 The function \b USART_Data_Bits_9 verifies data exchange:
3563 - with <b>9 data bits</b>
3564 - with default parity
3565 - with default stop bits
3566 - with default flow control
3567 - with default clock polarity
3568 - with default clock phase
3569 - at default baudrate
3570 - for default number of data items
3572 \note In Test Mode <b>Loopback</b> this test is not executed
3574 void USART_Data_Bits_9 (void) {
3576 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3577 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3578 if (SettingsCheck (USART_CFG_DEF_MODE, 9U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3580 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, 9U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3581 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, 9U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3582 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3583 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, 9U, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3587 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3589 \brief Function: Function USART_Parity_None
3591 The function \b USART_Parity_None verifies data exchange:
3593 - with default data bits
3594 - with <b>no parity</b>
3595 - with default stop bits
3596 - with default flow control
3597 - with default clock polarity
3598 - with default clock phase
3599 - at default baudrate
3600 - for default number of data items
3602 void USART_Parity_None (void) {
3604 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3605 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3607 #if (USART_SERVER_USED == 1)
3608 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3609 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3610 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3611 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3614 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3618 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3620 \brief Function: Function USART_Parity_Even
3622 The function \b USART_Parity_Even verifies data exchange:
3624 - with default data bits
3625 - with <b>even parity</b>
3626 - with default stop bits
3627 - with default flow control
3628 - at default baudrate
3629 - for default number of data items
3631 \note This test is not executed if any of the following settings are selected:
3632 - Test Mode <b>Loopback</b>
3633 - Tests Default Mode <b>Synchronous Master/Slave</b>
3635 void USART_Parity_Even (void) {
3637 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3638 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3639 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3640 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_EVEN, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3642 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_EVEN, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3643 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_EVEN, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3646 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3648 \brief Function: Function USART_Parity_Odd
3650 The function \b USART_Parity_Odd verifies data exchange:
3652 - with default data bits
3653 - with <b>odd parity</b>
3654 - with default stop bits
3655 - with default flow control
3656 - at default baudrate
3657 - for default number of data items
3659 \note This test is not executed if any of the following settings are selected:
3660 - Test Mode <b>Loopback</b>
3661 - Tests Default Mode <b>Synchronous Master/Slave</b>
3663 void USART_Parity_Odd (void) {
3665 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3666 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3667 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3668 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_ODD, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3670 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_ODD, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3671 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_ODD, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3674 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3676 \brief Function: Function USART_Stop_Bits_1
3678 The function \b USART_Stop_Bits_1 verifies data exchange:
3680 - with default data bits
3681 - with default parity
3682 - with <b>1 stop bit</b>
3683 - with default flow control
3684 - with default clock polarity
3685 - with default clock phase
3686 - at default baudrate
3687 - for default number of data items
3689 void USART_Stop_Bits_1 (void) {
3691 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3692 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_1, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3694 #if (USART_SERVER_USED == 1)
3695 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_1, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3696 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_1, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3697 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3698 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_1, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3701 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_1, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3705 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3707 \brief Function: Function USART_Stop_Bits_2
3709 The function \b USART_Stop_Bits_2 verifies data exchange:
3711 - with default data bits
3712 - with default parity
3713 - with <b>2 stop bits</b>
3714 - with default flow control
3715 - at default baudrate
3716 - for default number of data items
3718 \note This test is not executed if any of the following settings are selected:
3719 - Test Mode <b>Loopback</b>
3720 - Tests Default Mode <b>Synchronous Master/Slave</b>
3722 void USART_Stop_Bits_2 (void) {
3724 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3725 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3726 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3727 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_2, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3729 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_2, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3730 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_2, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3733 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3735 \brief Function: Function USART_Stop_Bits_1_5
3737 The function \b USART_Stop_Bits_1_5 verifies data exchange:
3739 - with default data bits
3740 - with default parity
3741 - with <b>1.5 stop bits</b>
3742 - with default flow control
3743 - at default baudrate
3744 - for default number of data items
3746 \note This test is not executed if any of the following settings are selected:
3747 - Test Mode <b>Loopback</b>
3748 - Tests Default Mode <b>Synchronous Master/Slave</b>
3750 void USART_Stop_Bits_1_5 (void) {
3752 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3753 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3754 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3755 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_1_5, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3757 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_1_5, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3758 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_1_5, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3761 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3763 \brief Function: Function USART_Stop_Bits_0_5
3765 The function \b USART_Stop_Bits_0_5 verifies data exchange:
3767 - with default data bits
3768 - with default parity
3769 - with <b>0.5 stop bits</b>
3770 - with default flow control
3771 - at default baudrate
3772 - for default number of data items
3774 \note This test is not executed if any of the following settings are selected:
3775 - Test Mode <b>Loopback</b>
3776 - Tests Default Mode <b>Synchronous Master/Slave</b>
3778 void USART_Stop_Bits_0_5 (void) {
3780 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3781 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3782 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3783 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_0_5, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3785 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_0_5, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3786 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, STOP_BITS_0_5, USART_CFG_DEF_FLOW_CONTROL, 0U, 0U, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3789 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3791 \brief Function: Function USART_Flow_Control_None
3793 The function \b USART_Flow_Control_None verifies data exchange:
3795 - with default data bits
3796 - with default parity
3797 - with default stop bits
3798 - with <b>no flow control</b>
3799 - with default clock polarity
3800 - with default clock phase
3801 - at default baudrate
3802 - for default number of data items
3804 void USART_Flow_Control_None (void) {
3806 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3807 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3809 #if (USART_SERVER_USED == 1)
3810 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3811 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3813 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
3817 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3819 \brief Function: Function USART_Flow_Control_RTS
3821 The function \b USART_Flow_Control_RTS verifies functionality of the RTS line flow control by
3822 trying to receive half of default number of data items, after that, RTS line should
3823 be deactivated by the USART Client hardware and USART Server should stop sending further data.
3825 The RTS line flow control functionality is tested with following settings:
3827 - with default data bits
3828 - with default parity
3829 - with default stop bits
3830 - with <b>flow control using RTS signal</b>
3831 - at default baudrate
3833 Test procedure consists of the following steps:
3834 - start reception of half of default number of items
3835 - after half of default number of items was received
3836 the RTS line should go to inactive state
3837 - USART Server after seeing that its CTS line (USART Clients RTS line)
3838 went to inactive state should stop sending further data
3839 - after timeout read from USART Server the number of items it has sent
3840 and assert that it is less than default number of items
3842 \note This test is not executed if any of the following settings are selected:
3843 - Test Mode <b>Loopback</b>
3844 - Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b>
3846 void USART_Flow_Control_RTS (void) {
3848 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3849 #if (USART_SERVER_USED == 1)
3850 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3851 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3852 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3853 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_RTS, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3856 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3857 if (CmdSetCom (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_CTS, 0U, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { break; }
3858 if (CmdXfer (0U, USART_CFG_DEF_NUM, 10U, USART_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
3860 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
3861 USART_CFG_DEF_DATA_BITS_VAL |
3862 USART_CFG_DEF_PARITY_VAL |
3863 USART_CFG_DEF_STOP_BITS_VAL |
3864 ARM_USART_FLOW_CONTROL_RTS ,
3865 USART_CFG_DEF_BAUDRATE);
3869 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
3871 TEST_ASSERT(drv->Receive(ptr_rx_buf, USART_CFG_DEF_NUM / 2U) == ARM_DRIVER_OK);
3872 (void)osDelay(USART_CFG_XFER_TIMEOUT + 20U); // Wait for USART Server to timeout the XFER command
3874 // Abort and disable reception
3875 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
3876 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
3880 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3881 if (CmdGetCnt() != EXIT_SUCCESS) { break; }
3882 TEST_ASSERT_MESSAGE(xfer_count < USART_CFG_DEF_NUM, "[FAILED] All data was received, RTS line is not working!");
3884 if (CmdGetVer() != EXIT_SUCCESS) { break; }
3891 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3893 \brief Function: Function USART_Flow_Control_CTS
3895 The function \b USART_Flow_Control_CTS verifies functionality of the CTS line flow control by
3896 trying to send default number of data items, while at half of transmitted number
3897 of items the USART Server deactivates its RTS line (it is connected to CTS line on the USART Client).
3899 The CTS line flow control functionality is tested with following settings:
3901 - with default data bits
3902 - with default parity
3903 - with default stop bits
3904 - with <b>flow control using CTS signal</b>
3905 - at default baudrate
3907 Test procedure consists of the following steps:
3908 - start send of default number of items
3909 - after USART Server receives half of default number of items it
3910 will drive its RTS line (USART Clients CTS line) inactive
3911 - before timeout check that tx_busy is active and that number of transmitted items is less than default number of items
3913 \note This test is not executed if any of the following settings are selected:
3914 - Test Mode <b>Loopback</b>
3915 - Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b>
3917 void USART_Flow_Control_CTS (void) {
3919 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3920 #if (USART_SERVER_USED == 1)
3921 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3922 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3923 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3924 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_CTS, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3927 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3928 if (CmdSetCom (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, 0U, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { break; }
3929 if (CmdXfer (1U, USART_CFG_DEF_NUM, 0U, USART_CFG_XFER_TIMEOUT, USART_CFG_DEF_NUM / 2U) != EXIT_SUCCESS) { break; }
3931 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
3932 USART_CFG_DEF_DATA_BITS_VAL |
3933 USART_CFG_DEF_PARITY_VAL |
3934 USART_CFG_DEF_STOP_BITS_VAL |
3935 ARM_USART_FLOW_CONTROL_CTS ,
3936 USART_CFG_DEF_BAUDRATE);
3939 (void)osDelay(10U); // Wait for USART Server to start reception
3941 (void)drv->Control(ARM_USART_CONTROL_TX, 1U);
3942 TEST_ASSERT(drv->Send(ptr_tx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_OK);
3943 (void)osDelay(USART_CFG_XFER_TIMEOUT / 2U); // Wait for half of timeout, after which sending should have stopped
3945 // Assert that tx_busy is still active
3946 TEST_ASSERT_MESSAGE(drv->GetStatus().tx_busy != 0U, "[FAILED] Send has finished, CTS line is not working!");
3948 // Assert that tx count is not 0
3949 TEST_ASSERT_MESSAGE(drv->GetTxCount() != 0U, "[FAILED] No data was sent, CTS line is not working!");
3951 // Assert that tx count is less than default number of items
3952 TEST_ASSERT_MESSAGE(drv->GetTxCount() < USART_CFG_DEF_NUM, "[FAILED] All data was sent, CTS line is not working!");
3954 (void)osDelay(USART_CFG_XFER_TIMEOUT / 2U); // Wait for USART Server to timeout the XFER command
3956 // Abort and disable transmission
3957 (void)drv->Control(ARM_USART_ABORT_SEND, 0U);
3958 (void)drv->Control(ARM_USART_CONTROL_TX, 0U);
3960 (void)osDelay(10U); // Wait for USART Server to prepare for reception of new command
3962 // Do a dummy send command to flush any data left-over from previous send
3963 // (When flow control CTS is used the send is started for default number of items.
3964 // After half of default number of items are sent the CTS line is deasserted,
3965 // but data register was already loaded with next item to be sent.
3966 // To get rid of this loaded data we send a dummy command that USART Server will
3967 // ignore, but it will allow us to send next command properly.)
3968 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3969 (void)ComSendCommand("Dummy", 5U);
3971 (void)osDelay(USART_CFG_SRV_CMD_TOUT+10U); // Wait for USART Server to timeout the "Dummy" command
3978 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3980 \brief Function: Function USART_Flow_Control_RTS_CTS
3982 The function \b USART_Flow_Control_RTS_CTS verifies functionality of RTS And CTS lines.
3983 It calls function USART_Flow_Control_RTS that checks RTS line functionality, and
3984 USART_Flow_Control_CTS that checks CTS line functionality.
3986 \note This test is not executed if any of the following settings are selected:
3987 - Test Mode <b>Loopback</b>
3988 - Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b>
3990 void USART_Flow_Control_RTS_CTS (void) {
3992 USART_Flow_Control_RTS();
3993 USART_Flow_Control_CTS();
3996 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3998 \brief Function: Function USART_Clock_Pol0_Pha0
4000 The function \b USART_Clock_Pol0_Pha0 verifies data exchange:
4002 - with default data bits
4005 - with no flow control
4006 - with <b>clock polarity 0</b>
4007 - with <b>clock phase 0</b>
4008 - at default baudrate
4009 - for default number of data items
4011 \note This test is not executed if any of the following settings are selected:
4012 - Test Mode <b>Loopback</b>
4013 - Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b>
4015 void USART_Clock_Pol0_Pha0 (void) {
4017 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4018 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4019 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4020 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4022 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, CPOL0, CPHA0, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4023 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, CPOL0, CPHA0, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4024 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, CPOL0, CPHA0, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4027 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4029 \brief Function: Function USART_Clock_Pol0_Pha1
4031 The function \b USART_Clock_Pol0_Pha1 verifies data exchange:
4033 - with default data bits
4036 - with no flow control
4037 - with <b>clock polarity 0</b>
4038 - with <b>clock phase 1</b>
4039 - at default baudrate
4040 - for default number of data items
4042 \note This test is not executed if any of the following settings are selected:
4043 - Test Mode <b>Loopback</b>
4044 - Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b>
4046 void USART_Clock_Pol0_Pha1 (void) {
4048 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4049 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4050 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4051 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4053 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, CPOL0, CPHA1, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4054 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, CPOL0, CPHA1, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4055 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, CPOL0, CPHA1, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4058 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4060 \brief Function: Function USART_Clock_Pol1_Pha0
4062 The function \b USART_Clock_Pol1_Pha0 verifies data exchange:
4064 - with default data bits
4067 - with no flow control
4068 - with <b>clock polarity 1</b>
4069 - with <b>clock phase 0</b>
4070 - at default baudrate
4071 - for default number of data items
4073 \note This test is not executed if any of the following settings are selected:
4074 - Test Mode <b>Loopback</b>
4075 - Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b>
4077 void USART_Clock_Pol1_Pha0 (void) {
4079 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4080 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4081 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4082 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4084 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, CPOL1, CPHA0, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4085 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, CPOL1, CPHA0, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4086 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, CPOL1, CPHA0, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4089 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4091 \brief Function: Function USART_Clock_Pol1_Pha1
4093 The function \b USART_Clock_Pol1_Pha1 verifies data exchange:
4095 - with default data bits
4098 - with no flow control
4099 - with <b>clock polarity 1</b>
4100 - with <b>clock phase 1</b>
4101 - at default baudrate
4102 - for default number of data items
4104 \note This test is not executed if any of the following settings are selected:
4105 - Test Mode <b>Loopback</b>
4106 - Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b>
4108 void USART_Clock_Pol1_Pha1 (void) {
4110 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4111 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4112 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4113 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4115 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, CPOL1, CPHA1, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4116 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, CPOL1, CPHA1, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4117 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, CPOL1, CPHA1, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4120 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4122 \brief Function: Function USART_Baudrate_Min
4124 The function \b USART_Baudrate_Min verifies data exchange:
4126 - with default data bits
4127 - with default parity
4128 - with default stop bits
4129 - with default flow control
4130 - with default clock polarity
4131 - with default clock phase
4132 - at <b>minimum baudrate</b> (define <c>USART_CFG_MIN_BAUDRATE</c> in DV_USART_Config.h)
4133 - for default number of data items
4135 This test function checks the following requirement:
4136 - measured bus speed for Send operation in Test Mode <b>USART Server</b> or Send/Receive operation in Test Mode <b>Loopback</b>
4137 is not 25% lower, or higher than requested
4139 void USART_Baudrate_Min (void) {
4140 volatile uint64_t br;
4142 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4143 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; }
4145 #if (USART_SERVER_USED == 1)
4146 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_MIN_BAUDRATE, USART_CFG_DEF_NUM);
4147 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_MIN_BAUDRATE, USART_CFG_DEF_NUM);
4149 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_MIN_BAUDRATE, USART_CFG_DEF_NUM);
4152 if (duration != 0xFFFFFFFFU) { // If Transfer finished before timeout
4153 if (duration != 0U) { // If duration of transfer was more than 0 SysTick counts
4154 br = ((uint64_t)systick_freq * (1U + USART_CFG_DEF_DATA_BITS + USART_CFG_DEF_STOP_BITS + (uint32_t)(USART_CFG_DEF_PARITY != PARITY_NONE)) * USART_CFG_DEF_NUM) / duration;
4155 if ((br < ((USART_CFG_MIN_BAUDRATE * 3) / 4)) ||
4156 (br > USART_CFG_MIN_BAUDRATE)) {
4157 // If measured baudrate is 25% lower, or higher than requested
4158 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] At requested baudrate of %i bauds, effective transfer speed is %i bauds", USART_CFG_MIN_BAUDRATE, (uint32_t)br);
4159 TEST_MESSAGE(msg_buf);
4165 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4167 \brief Function: Function USART_Baudrate_Max
4169 The function \b USART_Baudrate_Max verifies data exchange:
4171 - with default data bits
4172 - with default parity
4173 - with default stop bits
4174 - with default flow control
4175 - with default clock polarity
4176 - with default clock phase
4177 - at <b>maximum baudrate</b> (define <c>USART_CFG_MAX_BAUDRATE</c> in DV_USART_Config.h)
4178 - for default number of data items
4180 This test function checks the following requirement:
4181 - measured bus speed for Send operation in Test Mode <b>USART Server</b> or Send/Receive operation in Test Mode <b>Loopback</b>
4182 is not 25% lower, or higher than requested
4184 void USART_Baudrate_Max (void) {
4185 volatile uint64_t br;
4187 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4188 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; }
4190 #if (USART_SERVER_USED == 1)
4191 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_MAX_BAUDRATE, USART_CFG_DEF_NUM);
4192 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_MAX_BAUDRATE, USART_CFG_DEF_NUM);
4194 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_MAX_BAUDRATE, USART_CFG_DEF_NUM);
4197 if (duration != 0xFFFFFFFFU) { // If Transfer finished before timeout
4198 if (duration != 0U) { // If duration of transfer was more than 0 SysTick counts
4199 br = ((uint64_t)systick_freq * (1U + USART_CFG_DEF_DATA_BITS + USART_CFG_DEF_STOP_BITS + (uint32_t)(USART_CFG_DEF_PARITY != PARITY_NONE)) * USART_CFG_DEF_NUM) / duration;
4200 if ((br < ((USART_CFG_MAX_BAUDRATE * 3) / 4)) ||
4201 (br > USART_CFG_MAX_BAUDRATE)) {
4202 // If measured baudrate is 25% lower, or higher than requested
4203 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] At requested baudrate of %i bauds, effective transfer speed is %i bauds", USART_CFG_MAX_BAUDRATE, (uint32_t)br);
4204 TEST_MESSAGE(msg_buf);
4210 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4212 \brief Function: Function USART_Number_Of_Items
4214 The function \b USART_Number_Of_Items verifies data exchange:
4216 - with default data bits
4217 - with default parity
4218 - with default stop bits
4219 - with default flow control
4220 - with default clock polarity
4221 - with default clock phase
4222 - at default baudrate
4223 - for <b>different number of items</b> (defines <c>USART_CFG_NUM1 .. USART_CFG_NUM5</c> in DV_USART_Config.h)
4225 void USART_Number_Of_Items (void) {
4227 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4228 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; }
4230 #if (USART_CFG_NUM1 != 0U)
4231 #if (USART_SERVER_USED == 1)
4232 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM1);
4233 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM1);
4235 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM1);
4239 #if (USART_CFG_NUM2 != 0U)
4240 #if (USART_SERVER_USED == 1)
4241 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM2);
4242 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM2);
4244 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM2);
4248 #if (USART_CFG_NUM3 != 0U)
4249 #if (USART_SERVER_USED == 1)
4250 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM3);
4251 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM3);
4253 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM3);
4257 #if (USART_CFG_NUM4 != 0U)
4258 #if (USART_SERVER_USED == 1)
4259 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM4);
4260 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM4);
4262 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM4);
4266 #if (USART_CFG_NUM5 != 0U)
4267 #if (USART_SERVER_USED == 1)
4268 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM5);
4269 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM5);
4271 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM5);
4276 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4278 \brief Function: Function USART_GetTxCount
4280 The function \b USART_GetTxCount verifies \b GetTxCount function (count changing) during data exchange (Send):
4282 - with default data bits
4283 - with default parity
4284 - with default stop bits
4285 - with default flow control
4286 - with default clock polarity
4287 - with default clock phase
4288 - at default baudrate
4290 void USART_GetTxCount (void) {
4292 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4293 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; }
4295 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4296 TEST_ASSERT_MESSAGE((tx_count_sample != 0U) && (tx_count_sample != USART_CFG_DEF_NUM), "[FAILED] GetTxCount was not changing during the Send!");
4299 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4301 \brief Function: Function USART_GetRxCount
4303 The function \b USART_GetRxCount verifies \b GetRxCount function (count changing) during data exchange (Receive):
4305 - with default data bits
4306 - with default parity
4307 - with default stop bits
4308 - with default flow control
4309 - with default clock polarity
4310 - with default clock phase
4311 - at default baudrate
4313 void USART_GetRxCount (void) {
4315 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4316 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; }
4318 #if (USART_SERVER_USED == 1)
4319 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4321 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4325 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4327 \brief Function: Function USART_GetTxRxCount
4329 The function \b USART_GetTxRxCount verifies \b GetTxCount and \b GetRxCount functions (count changing) during data exchange (Transfer):
4331 - with default data bits
4334 - with no flow control
4335 - with default clock polarity
4336 - with default clock phase
4337 - at default baudrate
4339 \note If Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b> is selected this test is not executed
4341 void USART_GetTxRxCount (void) {
4343 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4344 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4345 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4347 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4348 TEST_ASSERT_MESSAGE((tx_count_sample != 0U) && (tx_count_sample != USART_CFG_DEF_NUM), "[FAILED] GetTxCount was not changing during the Transfer!");
4349 TEST_ASSERT_MESSAGE((rx_count_sample != 0U) && (rx_count_sample != USART_CFG_DEF_NUM), "[FAILED] GetRxCount was not changing during the Transfer!");
4352 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4354 \brief Function: Function USART_AbortSend
4356 The function \b USART_AbortSend verifies \b Abort function abort of data exchange (Send):
4358 - with default data bits
4359 - with default parity
4360 - with default stop bits
4361 - with default flow control
4362 - at default baudrate
4364 void USART_AbortSend (void) {
4366 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4367 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; }
4369 USART_DataExchange_Operation(OP_ABORT_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4372 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4374 \brief Function: Function USART_AbortReceive
4376 The function \b USART_AbortReceive verifies \b Abort function abort of data exchange (Receive):
4378 - with default data bits
4379 - with default parity
4380 - with default stop bits
4381 - with default flow control
4382 - with default clock polarity
4383 - with default clock phase
4384 - at default baudrate
4386 void USART_AbortReceive (void) {
4388 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4389 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; }
4391 USART_DataExchange_Operation(OP_ABORT_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4394 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4396 \brief Function: Function USART_AbortTransfer
4398 The function \b USART_AbortTransfer verifies \b Abort function abort of data exchange (Transfer):
4400 - with default data bits
4403 - with no flow control
4404 - with default clock polarity
4405 - with default clock phase
4406 - at default baudrate
4408 \note If Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b> is selected this test is not executed
4410 void USART_AbortTransfer (void) {
4412 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4413 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4414 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4416 USART_DataExchange_Operation(OP_ABORT_TRANSFER, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4419 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4421 \brief Function: Function USART_TxBreak
4423 The function \b USART_TxBreak verifies Break signaling:
4425 - with default data bits
4426 - with default parity
4427 - with default stop bits
4428 - with no flow control
4429 - at default baudrate
4431 \note This test is not executed if any of the following settings are selected:
4432 - Test Mode <b>Loopback</b>
4433 - Tests Default Mode <b>Synchronous Master/Slave</b>
4435 void USART_TxBreak (void) {
4437 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4438 #if (USART_SERVER_USED == 1)
4439 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4440 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4441 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4444 // Dummy read break status to clear it
4445 if (CmdGetBrk() != EXIT_SUCCESS) { break; }
4447 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4448 if (CmdSetCom (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, 0U, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { break; }
4450 // Instruct USART Server to receive data so it can detect Break
4451 if (CmdXfer (1U, USART_CFG_DEF_NUM, 0U, USART_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
4453 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4454 USART_CFG_DEF_DATA_BITS_VAL |
4455 USART_CFG_DEF_PARITY_VAL |
4456 USART_CFG_DEF_STOP_BITS_VAL |
4457 ARM_USART_FLOW_CONTROL_NONE ,
4458 USART_CFG_DEF_BAUDRATE);
4462 (void)osDelay(10U); // Wait for USART Server to start reception
4464 (void)drv->Control(ARM_USART_CONTROL_TX, 1U);
4467 TEST_ASSERT(drv->Control(ARM_USART_CONTROL_BREAK, 1U) == ARM_DRIVER_OK);
4469 TEST_ASSERT(drv->Control(ARM_USART_CONTROL_BREAK, 0U) == ARM_DRIVER_OK);
4472 (void)drv->Control(ARM_USART_CONTROL_TX, 0U);
4474 (void)osDelay(USART_CFG_XFER_TIMEOUT + 10U); // Wait for USART Server to timeout the XFER command
4476 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4477 if (CmdGetBrk() != EXIT_SUCCESS) { break; }
4478 TEST_ASSERT_MESSAGE(break_status == 1U, "[FAILED] Break was not detected on USART Server!");
4480 (void)osDelay(10U); // Wait for USART Server to prepare for reception of new command
4490 // End of usart_tests_data_xchg
4492 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4493 /* USART Modem Lines tests */
4494 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4496 \defgroup usart_tests_modem Modem Lines
4497 \ingroup usart_tests
4499 These tests verify API and operation of the USART modem lines handling functions.
4501 The data exchange tests verify the following driver functions
4502 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html" target="_blank">USART Driver function documentation</a>):
4503 - \b SetModemControl
4505 int32_t SetModemControl (ARM_USART_MODEM_CONTROL control);
4509 ARM_USART_MODEM_STATUS GetModemStatus (void);
4512 \note These tests are not executed if any of the following settings are selected:
4513 - Test Mode <b>Loopback</b>
4514 - Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b>
4518 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4520 \brief Function: Function USART_Modem_RTS
4522 The function \b USART_Modem_RTS verifies driving of modem line Request To Send (RTS):
4524 - with default data bits
4525 - with default parity
4526 - with default stop bits
4527 - with no flow control
4528 - at default baudrate
4530 void USART_Modem_RTS (void) {
4532 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4533 #if (USART_SERVER_USED == 1)
4534 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4535 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4536 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4537 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, RTS_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4540 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4542 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4543 USART_CFG_DEF_DATA_BITS_VAL |
4544 USART_CFG_DEF_PARITY_VAL |
4545 USART_CFG_DEF_STOP_BITS_VAL |
4546 ARM_USART_FLOW_CONTROL_NONE ,
4547 USART_CFG_DEF_BAUDRATE);
4549 TEST_ASSERT(drv->SetModemControl(ARM_USART_RTS_CLEAR) == ARM_DRIVER_OK);
4552 if (CmdGetMdm() != EXIT_SUCCESS) { break; }
4554 TEST_ASSERT_MESSAGE((modem_status & 0x1U) == 0x0U, "[FAILED] CTS line on USART Server is not in inactive state!");
4556 TEST_ASSERT(drv->SetModemControl(ARM_USART_RTS_SET) == ARM_DRIVER_OK);
4559 if (CmdGetMdm() != EXIT_SUCCESS) { break; }
4561 TEST_ASSERT_MESSAGE((modem_status & 0x1U) == 0x1U, "[FAILED] CTS line on USART Server is not in active state!");
4563 (void)drv->SetModemControl(ARM_USART_RTS_CLEAR);
4565 // Give USART Server 10 ms to prepare for reception of the next command
4573 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4575 \brief Function: Function USART_Modem_DTR
4577 The function \b USART_Modem_DTR verifies driving of modem line Data Terminal Ready (DTR):
4579 - with default data bits
4580 - with default parity
4581 - with default stop bits
4582 - with no flow control
4583 - at default baudrate
4585 void USART_Modem_DTR (void) {
4587 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4588 #if (USART_SERVER_USED == 1)
4589 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4590 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4591 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4592 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, DTR_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4595 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4597 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4598 USART_CFG_DEF_DATA_BITS_VAL |
4599 USART_CFG_DEF_PARITY_VAL |
4600 USART_CFG_DEF_STOP_BITS_VAL |
4601 ARM_USART_FLOW_CONTROL_NONE ,
4602 USART_CFG_DEF_BAUDRATE);
4604 TEST_ASSERT(drv->SetModemControl(ARM_USART_DTR_CLEAR) == ARM_DRIVER_OK);
4607 if (CmdGetMdm() != EXIT_SUCCESS) { break; }
4609 TEST_ASSERT_MESSAGE((modem_status & 0x2U) == 0x0U, "[FAILED] DSR line on USART Server is not in inactive state!");
4611 TEST_ASSERT(drv->SetModemControl(ARM_USART_DTR_SET) == ARM_DRIVER_OK);
4614 if (CmdGetMdm() != EXIT_SUCCESS) { break; }
4616 TEST_ASSERT_MESSAGE((modem_status & 0x2U) == 0x2U, "[FAILED] DSR line on USART Server is not in active state!");
4618 (void)drv->SetModemControl(ARM_USART_DTR_CLEAR);
4620 // Give USART Server 10 ms to prepare for reception of the next command
4628 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4630 \brief Function: Function USART_Modem_CTS
4632 The function \b USART_Modem_CTS verifies read of modem line Clear To Send (CTS):
4634 - with default data bits
4635 - with default parity
4636 - with default stop bits
4637 - with no flow control
4638 - at default baudrate
4640 void USART_Modem_CTS (void) {
4642 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4643 #if (USART_SERVER_USED == 1)
4644 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4645 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4646 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4647 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, CTS_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4650 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4652 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4653 USART_CFG_DEF_DATA_BITS_VAL |
4654 USART_CFG_DEF_PARITY_VAL |
4655 USART_CFG_DEF_STOP_BITS_VAL |
4656 ARM_USART_FLOW_CONTROL_NONE ,
4657 USART_CFG_DEF_BAUDRATE);
4659 // Instruct USART Server to drive RTS to active state for 20 ms
4660 // RTS line from USART Server should be connected to CTS line on the USART Client (DUT)
4661 if (CmdSetMdm(RTS_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
4665 TEST_ASSERT_MESSAGE(drv->GetModemStatus().cts == 1U, "[FAILED] CTS line not active!");
4667 // Give USART Server 20 ms to finish SET MDM command and prepare for reception of the next command
4675 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4677 \brief Function: Function USART_Modem_DSR
4679 The function \b USART_Modem_DSR verifies read of modem line Data Set Ready (DSR):
4681 - with default data bits
4682 - with default parity
4683 - with default stop bits
4684 - with no flow control
4685 - at default baudrate
4687 void USART_Modem_DSR (void) {
4689 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4690 #if (USART_SERVER_USED == 1)
4691 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4692 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4693 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4694 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, DSR_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4697 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4699 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4700 USART_CFG_DEF_DATA_BITS_VAL |
4701 USART_CFG_DEF_PARITY_VAL |
4702 USART_CFG_DEF_STOP_BITS_VAL |
4703 ARM_USART_FLOW_CONTROL_NONE ,
4704 USART_CFG_DEF_BAUDRATE);
4706 // Instruct USART Server to drive DTR to active state for 20 ms
4707 // DTR line from USART Server should be connected to DSR line on the USART Client (DUT)
4708 if (CmdSetMdm(DTR_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
4712 TEST_ASSERT_MESSAGE(drv->GetModemStatus().dsr == 1U, "[FAILED] DSR line not active!");
4714 // Give USART Server 20 ms to finish SET MDM command and prepare for reception of the next command
4722 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4724 \brief Function: Function USART_Modem_DCD
4726 The function \b USART_Modem_DCD verifies read of modem line Data Carrier Detect (DCD):
4728 - with default data bits
4729 - with default parity
4730 - with default stop bits
4731 - with no flow control
4732 - at default baudrate
4734 void USART_Modem_DCD (void) {
4736 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4737 #if (USART_SERVER_USED == 1)
4738 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4739 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4740 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4741 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, DCD_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4744 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4746 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4747 USART_CFG_DEF_DATA_BITS_VAL |
4748 USART_CFG_DEF_PARITY_VAL |
4749 USART_CFG_DEF_STOP_BITS_VAL |
4750 ARM_USART_FLOW_CONTROL_NONE ,
4751 USART_CFG_DEF_BAUDRATE);
4753 // Instruct USART Server to drive DTR to active state for 20 ms
4754 if (CmdSetMdm(TO_DCD_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
4758 TEST_ASSERT_MESSAGE(drv->GetModemStatus().dcd == 1U, "[FAILED] DCD line not active!");
4760 // Give USART Server 20 ms to finish SET MDM command and prepare for reception of the next command
4768 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4770 \brief Function: Function USART_Modem_RI
4772 The function \b USART_Modem_RI verifies read of modem line Ring Indicator (RI):
4774 - with default data bits
4775 - with default parity
4776 - with default stop bits
4777 - with no flow control
4778 - at default baudrate
4780 void USART_Modem_RI (void) {
4782 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4783 #if (USART_SERVER_USED == 1)
4784 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4785 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4786 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4787 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, RI_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4790 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4792 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4793 USART_CFG_DEF_DATA_BITS_VAL |
4794 USART_CFG_DEF_PARITY_VAL |
4795 USART_CFG_DEF_STOP_BITS_VAL |
4796 ARM_USART_FLOW_CONTROL_NONE ,
4797 USART_CFG_DEF_BAUDRATE);
4799 // Instruct USART Server to drive RI to active state for 20 ms
4800 if (CmdSetMdm(TO_RI_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
4804 TEST_ASSERT_MESSAGE(drv->GetModemStatus().ri == 1U, "[FAILED] RI line not active!");
4806 // Give USART Server 20 ms to finish SET MDM command and prepare for reception of the next command
4817 // End of usart_tests_modem
4819 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4820 /* USART Event tests */
4821 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4823 \defgroup usart_tests_evt Event
4824 \ingroup usart_tests
4826 These tests verify API and operation of the USART event signaling, except ARM_USART_EVENT_SEND_COMPLETE,
4827 ARM_USART_EVENT_RECEIVE_COMPLETE, ARM_USART_EVENT_TRANSFER_COMPLETE and ARM_USART_EVENT_TX_COMPLETE signals
4828 which is tested in the Data Exchange tests.
4830 The event tests verify the following driver function
4831 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html" target="_blank">USART Driver function documentation</a>):
4834 void (*ARM_USART_SignalEvent_t) (uint32_t event);
4837 \note In Test Mode <b>Loopback</b> these tests are skipped
4841 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4843 \brief Function: Function USART_Tx_Underflow
4845 The function \b USART_Tx_Underflow verifies signaling of the <b>ARM_USART_EVENT_TX_UNDERFLOW</b> event:
4847 - with default data bits
4848 - with default parity
4849 - with default stop bits
4850 - with default flow control
4851 - at default baudrate
4853 it also checks that status tx_underflow flag was activated.
4855 \note If Tests Default Mode <b>Asynchronous/Synchronous Master/Single-wire/IrDA</b> is selected this test is not executed
4857 void USART_Tx_Underflow (void) {
4859 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4860 #if (USART_SERVER_USED == 1)
4861 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4862 if (IsNotSyncMaster() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4863 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4864 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; }
4867 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4868 if (CmdSetCom(USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { break; }
4869 if (CmdXfer (0U, 1U, 10U, 20U, 0U) != EXIT_SUCCESS) { break; }
4871 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4872 USART_CFG_DEF_DATA_BITS_VAL |
4873 USART_CFG_DEF_PARITY_VAL |
4874 USART_CFG_DEF_STOP_BITS_VAL |
4875 USART_CFG_DEF_FLOW_CONTROL_VAL |
4876 USART_CFG_DEF_CPOL_VAL |
4877 USART_CFG_DEF_CPHA_VAL ,
4878 USART_CFG_DEF_BAUDRATE);
4882 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
4884 (void)osDelay(30U); // Wait for USART Server to timeout
4886 // Assert that event ARM_USART_EVENT_TX_UNDERFLOW was signaled
4887 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_TX_UNDERFLOW) != 0U, "[FAILED] Event ARM_USART_EVENT_TX_UNDERFLOW was not signaled!");
4889 // Assert that status rx_overflow flag is active
4890 TEST_ASSERT_MESSAGE(drv->GetStatus().tx_underflow != 0U, "[FAILED] Status tx_underflow flag was not activated!");
4892 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
4894 // Give USART Server 10 ms to prepare for reception of the next command
4902 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4904 \brief Function: Function USART_Rx_Overflow
4906 The function \b USART_Rx_Overflow verifies signaling of the <b>ARM_USART_EVENT_RX_OVERFLOW</b> event:
4908 - with default data bits
4909 - with default parity
4910 - with default stop bits
4911 - with default flow control
4912 - at default baudrate
4914 it also checks that status rx_overflow flag was activated.
4916 \note If Tests Default Mode <b>Synchronous Master</b> is selected this test is not executed
4918 void USART_Rx_Overflow (void) {
4920 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4921 #if (USART_SERVER_USED == 1)
4922 if (IsNotSyncMaster() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4923 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4924 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; }
4927 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4928 if (CmdSetCom(USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { break; }
4929 if (CmdXfer (0U, 1U, 10U, 20U, 0U) != EXIT_SUCCESS) { break; }
4931 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4932 USART_CFG_DEF_DATA_BITS_VAL |
4933 USART_CFG_DEF_PARITY_VAL |
4934 USART_CFG_DEF_STOP_BITS_VAL |
4935 USART_CFG_DEF_FLOW_CONTROL_VAL |
4936 USART_CFG_DEF_CPOL_VAL |
4937 USART_CFG_DEF_CPHA_VAL ,
4938 USART_CFG_DEF_BAUDRATE);
4942 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
4944 (void)osDelay(30U); // Wait for USART Server to timeout
4946 // Assert that event ARM_USART_EVENT_RX_OVERFLOW was signaled
4947 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_OVERFLOW) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_OVERFLOW was not signaled!");
4949 // Assert that status rx_overflow flag is active
4950 TEST_ASSERT_MESSAGE(drv->GetStatus().rx_overflow != 0U, "[FAILED] Status rx_overflow flag was not activated!");
4952 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
4954 // Give USART Server 10 ms to prepare for reception of the next command
4962 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4964 \brief Function: Function USART_Rx_Timeout
4966 The function \b USART_Rx_Timeout verifies signaling of the <b>ARM_USART_EVENT_RX_TIMEOUT</b> event:
4968 - with default data bits
4969 - with default parity
4970 - with default stop bits
4971 - with default flow control
4972 - at default baudrate
4974 \note If Tests Default Mode <b>Synchronous Master/Slave</b> is selected this test is not executed
4976 void USART_Rx_Timeout (void) {
4978 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4979 #if (USART_SERVER_USED == 1)
4980 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4981 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4982 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; }
4985 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4986 if (CmdSetCom(USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { break; }
4987 if (CmdXfer (0U, 1U, 10U, 10U, 0U) != EXIT_SUCCESS) { break; }
4989 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4990 USART_CFG_DEF_DATA_BITS_VAL |
4991 USART_CFG_DEF_PARITY_VAL |
4992 USART_CFG_DEF_STOP_BITS_VAL |
4993 USART_CFG_DEF_FLOW_CONTROL_VAL |
4994 USART_CFG_DEF_CPOL_VAL |
4995 USART_CFG_DEF_CPHA_VAL ,
4996 USART_CFG_DEF_BAUDRATE);
5000 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
5001 (void)drv->Receive(ptr_rx_buf, 2U);
5003 (void)osDelay(30U); // Wait for USART Server to timeout
5005 // Assert that event ARM_USART_EVENT_RX_TIMEOUT was signaled
5006 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_TIMEOUT) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_TIMEOUT was not signaled!");
5008 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
5009 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
5011 // Give USART Server 10 ms to prepare for reception of the next command
5019 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5021 \brief Function: Function USART_Rx_Break
5023 The function \b USART_Rx_Break verifies signaling of the <b>ARM_USART_EVENT_RX_BREAK</b> event:
5025 - with default data bits
5026 - with default parity
5027 - with default stop bits
5028 - with default flow control
5029 - at default baudrate
5031 it also checks that status rx_break flag was activated.
5033 \note If Tests Default Mode <b>Synchronous Master/Slave</b> is selected this test is not executed
5035 void USART_Rx_Break (void) {
5037 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5038 #if (USART_SERVER_USED == 1)
5039 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5040 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5041 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; }
5044 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5046 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5047 USART_CFG_DEF_DATA_BITS_VAL |
5048 USART_CFG_DEF_PARITY_VAL |
5049 USART_CFG_DEF_STOP_BITS_VAL |
5050 USART_CFG_DEF_FLOW_CONTROL_VAL |
5051 USART_CFG_DEF_CPOL_VAL |
5052 USART_CFG_DEF_CPHA_VAL ,
5053 USART_CFG_DEF_BAUDRATE);
5055 // Instruct USART Server to signal Break for 20 ms
5056 if (CmdSetBrk(10U, 20U) != EXIT_SUCCESS) { break; }
5058 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
5059 (void)drv->Receive(ptr_rx_buf, 1U);
5061 // This test allows break detection for continuous mode as well
5062 // as LIN variant (return to inactive after 10/11 bits)
5065 // Assert that event ARM_USART_EVENT_RX_BREAK was signaled
5066 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_BREAK) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_BREAK was not signaled!");
5068 // Assert that status rx_break flag is active
5069 TEST_ASSERT_MESSAGE(drv->GetStatus().rx_break != 0U, "[FAILED] Status rx_break flag was not activated!");
5071 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
5072 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
5074 // Give USART Server 10 ms to prepare for reception of the next command
5082 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5084 \brief Function: Function USART_Rx_Framing_Error
5086 The function \b USART_Rx_Framing_Error verifies signaling of the <b>ARM_USART_EVENT_RX_FRAMING_ERROR</b> event:
5088 - with default data bits
5089 - with default parity
5090 - with default stop bits
5091 - with default flow control
5092 - at default baudrate
5094 it also checks that status rx_framing_error flag was activated.
5096 \note If Tests Default Mode <b>Synchronous Master/Slave</b> is selected this test is not executed
5098 void USART_Rx_Framing_Error (void) {
5100 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5101 #if (USART_SERVER_USED == 1)
5102 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5103 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5104 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; }
5107 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5109 // We test framing error by adding parity bit if it is not set as default setting,
5110 // or removing parity bit if it is set as default setting
5111 if (USART_CFG_DEF_PARITY == PARITY_NONE) {
5112 if (CmdSetCom(USART_CFG_SRV_MODE, USART_CFG_DEF_DATA_BITS, PARITY_EVEN, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { break; }
5114 if (CmdSetCom(USART_CFG_SRV_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { break; }
5116 if (CmdXfer (0U, 1U, 10U, 20U, 0U) != EXIT_SUCCESS) { break; }
5118 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5119 USART_CFG_DEF_DATA_BITS_VAL |
5120 USART_CFG_DEF_PARITY_VAL |
5121 USART_CFG_DEF_STOP_BITS_VAL |
5122 USART_CFG_DEF_FLOW_CONTROL_VAL |
5123 USART_CFG_DEF_CPOL_VAL |
5124 USART_CFG_DEF_CPHA_VAL ,
5125 USART_CFG_DEF_BAUDRATE);
5129 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
5130 (void)drv->Receive(ptr_rx_buf, 1U);
5132 (void)osDelay(30U); // Wait for USART Server to timeout
5134 // Assert that event ARM_USART_EVENT_RX_FRAMING_ERROR was signaled
5135 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_FRAMING_ERROR) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_FRAMING_ERROR was not signaled!");
5137 // Assert that status rx_framing_error flag is active
5138 TEST_ASSERT_MESSAGE(drv->GetStatus().rx_framing_error != 0U, "[FAILED] Status rx_framing_error flag was not activated!");
5140 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
5141 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
5143 // Give USART Server 10 ms to prepare for reception of the next command
5151 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5153 \brief Function: Function USART_Rx_Parity_Error
5155 The function \b USART_Rx_Parity_Error verifies signaling of the <b>ARM_USART_EVENT_RX_PARITY_ERROR</b> event:
5157 - with default data bits
5158 - with default parity
5159 - with default stop bits
5160 - with default flow control
5161 - at default baudrate
5163 it also checks that status rx_parity_error flag was activated.
5165 \note If Tests Default Mode <b>Synchronous Master/Slave</b> is selected this test is not executed
5167 void USART_Rx_Parity_Error (void) {
5169 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5170 #if (USART_SERVER_USED == 1)
5171 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5172 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5173 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; }
5176 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5178 // We test parity error by requesting USART Server to send an item at ODD parity
5179 // and configure USART Client to receive with EVEN parity
5180 if (CmdSetCom(USART_CFG_SRV_MODE, USART_CFG_DEF_DATA_BITS, PARITY_ODD, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { break; }
5182 if (CmdXfer (0U, 1U, 10U, 20U, 0U) != EXIT_SUCCESS) { break; }
5184 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5185 USART_CFG_DEF_DATA_BITS_VAL |
5186 ((PARITY_EVEN << ARM_USART_PARITY_Pos) & ARM_USART_PARITY_Msk) |
5187 USART_CFG_DEF_STOP_BITS_VAL |
5188 USART_CFG_DEF_FLOW_CONTROL_VAL |
5189 USART_CFG_DEF_CPOL_VAL |
5190 USART_CFG_DEF_CPHA_VAL ,
5191 USART_CFG_DEF_BAUDRATE);
5195 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
5196 (void)drv->Receive(ptr_rx_buf, 1U);
5198 (void)osDelay(30U); // Wait for USART Server to timeout
5200 // Assert that event ARM_USART_EVENT_RX_PARITY_ERROR was signaled
5201 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_PARITY_ERROR) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_PARITY_ERROR was not signaled!");
5203 // Assert that status rx_parity_error flag is active
5204 TEST_ASSERT_MESSAGE(drv->GetStatus().rx_parity_error != 0U, "[FAILED] Status rx_parity_error flag was not activated!");
5206 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
5207 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
5209 // Give USART Server 10 ms to prepare for reception of the next command
5217 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5219 \brief Function: Function USART_Event_CTS
5221 The function \b USART_Event_CTS verifies signaling of the <b>ARM_USART_EVENT_CTS</b> event:
5223 - with default data bits
5224 - with default parity
5225 - with default stop bits
5226 - with no flow control
5227 - at default baudrate
5229 \note If Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b> is selected this test is not executed
5231 void USART_Event_CTS (void) {
5233 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5234 #if (USART_SERVER_USED == 1)
5235 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5236 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5237 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5238 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, CTS_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
5241 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5243 // Instruct USART Server to drive RTS to active state for 20 ms
5244 // RTS line from USART Server should be connected to CTS line on the USART Client (DUT)
5245 if (CmdSetMdm(RTS_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
5247 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5248 USART_CFG_DEF_DATA_BITS_VAL |
5249 USART_CFG_DEF_PARITY_VAL |
5250 USART_CFG_DEF_STOP_BITS_VAL |
5251 ARM_USART_FLOW_CONTROL_CTS ,
5252 USART_CFG_DEF_BAUDRATE);
5258 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_CTS) == ARM_USART_EVENT_CTS, "[FAILED] CTS line did not register change!");
5267 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5269 \brief Function: Function USART_Event_DSR
5271 The function \b USART_Event_DSR verifies signaling of the <b>ARM_USART_EVENT_DSR</b> event:
5273 - with default data bits
5274 - with default parity
5275 - with default stop bits
5276 - with no flow control
5277 - at default baudrate
5279 \note If Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b> is selected this test is not executed
5281 void USART_Event_DSR (void) {
5283 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5284 #if (USART_SERVER_USED == 1)
5285 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5286 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5287 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5288 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, DSR_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
5291 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5293 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5294 USART_CFG_DEF_DATA_BITS_VAL |
5295 USART_CFG_DEF_PARITY_VAL |
5296 USART_CFG_DEF_STOP_BITS_VAL |
5297 ARM_USART_FLOW_CONTROL_NONE ,
5298 USART_CFG_DEF_BAUDRATE);
5302 // Instruct USART Server to drive DTR to active state for 20 ms
5303 // DTR line from USART Server should be connected to DSR line on the USART Client (DUT)
5304 if (CmdSetMdm(DTR_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
5308 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_DSR) == ARM_USART_EVENT_DSR, "[FAILED] DSR line did not register change!");
5317 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5319 \brief Function: Function USART_Event_DCD
5321 The function \b USART_Event_DCD verifies signaling of the <b>ARM_USART_EVENT_DCD</b> event:
5323 - with default data bits
5324 - with default parity
5325 - with default stop bits
5326 - with no flow control
5327 - at default baudrate
5329 \note If Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b> is selected this test is not executed
5331 void USART_Event_DCD (void) {
5333 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5334 #if (USART_SERVER_USED == 1)
5335 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5336 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5337 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5338 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, DCD_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
5341 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5343 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5344 USART_CFG_DEF_DATA_BITS_VAL |
5345 USART_CFG_DEF_PARITY_VAL |
5346 USART_CFG_DEF_STOP_BITS_VAL |
5347 ARM_USART_FLOW_CONTROL_NONE ,
5348 USART_CFG_DEF_BAUDRATE);
5352 // Instruct USART Server to drive RTS to active state for 20 ms
5353 if (CmdSetMdm(TO_DCD_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
5357 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_DCD) == ARM_USART_EVENT_DCD, "[FAILED] DCD line did not register change!");
5366 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5368 \brief Function: Function USART_Event_RI
5370 The function \b USART_Event_RI verifies signaling of the <b>ARM_USART_EVENT_RI</b> event:
5372 - with default data bits
5373 - with default parity
5374 - with default stop bits
5375 - with no flow control
5376 - at default baudrate
5378 \note If Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b> is selected this test is not executed
5380 void USART_Event_RI (void) {
5382 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5383 #if (USART_SERVER_USED == 1)
5384 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5385 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5386 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5387 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, RI_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
5390 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5392 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5393 USART_CFG_DEF_DATA_BITS_VAL |
5394 USART_CFG_DEF_PARITY_VAL |
5395 USART_CFG_DEF_STOP_BITS_VAL |
5396 ARM_USART_FLOW_CONTROL_NONE ,
5397 USART_CFG_DEF_BAUDRATE);
5401 // Instruct USART Server to drive RI to active state for 20 ms
5402 if (CmdSetMdm(TO_RI_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
5406 // RI event should be active after RI returns to inactive state (Trailing Edge RI)
5407 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RI) == ARM_USART_EVENT_RI, "[FAILED] RI line did not register change!");
5417 // End of usart_tests_evt