2 * Copyright (c) 2015-2022 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_modem_line[] = {
319 static const char *str_ret[] = {
322 "ARM_DRIVER_ERROR_BUSY",
323 "ARM_DRIVER_ERROR_TIMEOUT",
324 "ARM_DRIVER_ERROR_UNSUPPORTED",
325 "ARM_DRIVER_ERROR_PARAMETER",
326 "ARM_DRIVER_ERROR_SPECIFIC",
327 "ARM_USART_ERROR_MODE",
328 "ARM_USART_ERROR_BAUDRATE",
329 "ARM_USART_ERROR_DATA_BITS",
330 "ARM_USART_ERROR_PARITY",
331 "ARM_USART_ERROR_STOP_BITS",
332 "ARM_USART_ERROR_FLOW_CONTROL",
333 "ARM_USART_ERROR_CPOL",
334 "ARM_USART_ERROR_CPHA"
338 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
339 static int32_t ComConfigDefault (void);
340 static int32_t ComSendCommand (const void *data_out, uint32_t len);
341 static int32_t ComReceiveResponse ( void *data_in, uint32_t len);
343 static int32_t CmdGetVer (void);
344 static int32_t CmdGetCap (void);
345 static int32_t CmdSetBufTx (char pattern);
346 static int32_t CmdSetBufRx (char pattern);
347 static int32_t CmdGetBufRx (uint32_t len);
348 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);
349 static int32_t CmdXfer (uint32_t dir, uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_cts);
350 static int32_t CmdGetCnt (void);
351 static int32_t CmdSetBrk (uint32_t delay, uint32_t duration);
352 static int32_t CmdGetBrk (void);
353 static int32_t CmdSetMdm (uint32_t mdm_ctrl, uint32_t delay, uint32_t duration);
354 static int32_t CmdGetMdm (void);
356 static int32_t ServerInit (void);
357 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);
360 static int32_t IsNotLoopback (void);
361 static int32_t IsNotSync (void);
362 static int32_t IsNotAsync (void);
363 static int32_t IsNotSyncMaster (void);
364 static int32_t IsNotSingleWire (void);
366 static uint32_t DataBitsToBytes (uint32_t data_bits);
367 static int32_t DriverInit (void);
368 static int32_t BuffersCheck (void);
369 static int32_t DriverCheck (uint32_t mode, uint32_t flow_control, uint32_t modem_line_mask);
371 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);
376 \fn void USART_DrvEvent (uint32_t evt)
377 \brief Store event(s) into a global variable.
378 \detail This is a callback function called by the driver upon an event(s).
379 \param[in] evt USART event
382 static void USART_DrvEvent (uint32_t evt) {
385 (void)osEventFlagsSet(event_flags, evt);
389 \fn static uint32_t DataBitsToBytes (uint32_t data_bits)
390 \brief Calculate number of bytes used for an item at required data bits.
391 \return number of bytes per item
393 static uint32_t DataBitsToBytes (uint32_t data_bits) {
397 if (data_bits > 8U) {
405 \fn static int32_t DriverInit (void)
406 \brief Initialize and power-on the driver.
407 \return execution status
408 - EXIT_SUCCESS: Driver initialized and powered-up successfully
409 - EXIT_FAILURE: Driver initialization or power-up failed
411 static int32_t DriverInit (void) {
413 if (drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK) {
414 if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
419 TEST_FAIL_MESSAGE("[FAILED] USART driver initialize or power-up. Check driver Initialize and PowerControl functions! Test aborted!");
425 \fn static int32_t IsNotLoopback (void)
426 \brief Check if loopback is not selected.
427 \detail This function is used to skip executing a test if it is not supported
429 \return execution status
430 - EXIT_SUCCESS: Loopback is not selected
431 - EXIT_FAILURE: Loopback is selected
433 static int32_t IsNotLoopback (void) {
435 #if (USART_SERVER_USED == 1)
438 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test not executed!");
444 \fn static int32_t IsNotSync (void)
445 \brief Check if Synchronous Slave/Master mode is not selected as default mode.
446 \detail This function is used to skip executing a test if it is not supported
448 \return execution status
449 - EXIT_SUCCESS: Synchronous mode is not selected
450 - EXIT_FAILURE: Synchronous mode is selected
452 static int32_t IsNotSync (void) {
454 #if ((USART_CFG_DEF_MODE != MODE_SYNCHRONOUS_MASTER) && (USART_CFG_DEF_MODE != MODE_SYNCHRONOUS_SLAVE))
457 TEST_MESSAGE("[WARNING] Test not supported for Synchronous Mode! Test not executed!");
463 \fn static int32_t IsNotSyncMaster (void)
464 \brief Check if Synchronous Master mode is not selected as default mode.
465 \detail This function is used to skip executing a test if it is not supported
466 in Synchronous Master mode.
467 \return execution status
468 - EXIT_SUCCESS: Synchronous Master mode is not selected
469 - EXIT_FAILURE: Synchronous Master mode is selected
471 static int32_t IsNotSyncMaster (void) {
473 #if (USART_CFG_DEF_MODE != MODE_SYNCHRONOUS_MASTER)
476 TEST_MESSAGE("[WARNING] Test not supported for Synchronous Master Mode! Test not executed!");
482 \fn static int32_t IsNotAsync (void)
483 \brief Check if Asynchronous/Single-wire/IrDA modes are not selected as default mode.
484 \detail This function is used to skip executing a test if it is not supported
485 in Asynchronous/Single-wire/IrDA mode.
486 \return execution status
487 - EXIT_SUCCESS: Asynchronous/Single-wire/IrDA mode is not selected
488 - EXIT_FAILURE: Asynchronous/Single-wire/IrDA mode is selected
490 static int32_t IsNotAsync (void) {
492 #if ((USART_CFG_DEF_MODE != MODE_ASYNCHRONOUS) && (USART_CFG_DEF_MODE != MODE_SINGLE_WIRE) && (USART_CFG_DEF_MODE != MODE_IRDA))
495 TEST_MESSAGE("[WARNING] Test not supported for Asynchronous/Single-wire/IrDA Mode! Test not executed!");
501 \fn static int32_t IsNotSingleWire (void)
502 \brief Check if Single-wire mode is not selected as default mode.
503 \detail This function is used to skip executing a test if it is not supported
505 \return execution status
506 - EXIT_SUCCESS: Single-wire mode is not selected
507 - EXIT_FAILURE: Single-wire mode is selected
509 static int32_t IsNotSingleWire (void) {
511 #if (USART_CFG_DEF_MODE != MODE_SINGLE_WIRE)
514 TEST_MESSAGE("[WARNING] Test not supported for Single-wire Mode! Test not executed!");
520 \fn static int32_t BuffersCheck (void)
521 \brief Check if buffers are valid.
522 \return execution status
523 - EXIT_SUCCESS: Buffers are valid
524 - EXIT_FAILURE: Buffers are not valid
526 static int32_t BuffersCheck (void) {
528 if ((ptr_tx_buf != NULL) &&
529 (ptr_rx_buf != NULL) &&
530 (ptr_cmp_buf != NULL)) {
534 TEST_FAIL_MESSAGE("[FAILED] Invalid data buffers! Increase heap memory! Test aborted!");
540 \fn static int32_t DriverCheck (uint32_t mode, uint32_t flow_control, uint32_t modem_line_mask, uint32_t baudrate)
541 \brief Check if USART Driver supports desired settings.
542 \param[in] mode mode:
543 - value 1 = Asynchronous
544 - value 2 = Synchronous Master
545 - value 3 = Synchronous Slave
546 - value 4 = Single Wire
548 - value 6 = Smart Card
549 \param[in] flow_control flow control:
554 \param[in] modem_line_mask modem line mask:
561 \return execution status
562 - EXIT_SUCCESS: USART Driver supports desired settings
563 - EXIT_FAILURE: USART Driver does not support desired settings
565 static int32_t DriverCheck (uint32_t mode, uint32_t flow_control, uint32_t modem_line_mask) {
571 case 1: // Asynchronous
572 if (drv_cap.asynchronous == 0U) {
576 case 2: // Synchronous master
577 if (drv_cap.synchronous_master == 0U) {
581 case 3: // Synchronous slave
582 if (drv_cap.synchronous_slave == 0U) {
586 case 4: // Single-wire
587 if (drv_cap.single_wire == 0U) {
592 if (drv_cap.irda == 0U) {
596 case 6: // Samrt Card
597 if (drv_cap.irda == 0U) {
606 if (ret != EXIT_SUCCESS) {
607 // If USART Driver does not support desired mode
609 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Driver does not support %s mode! Test aborted!", str_mode[mode]);
611 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Driver does not support unknown mode! Test aborted!");
613 TEST_MESSAGE(msg_buf);
617 switch (flow_control) {
621 if (drv_cap.flow_control_cts == 0U) {
626 if (drv_cap.flow_control_rts == 0U) {
631 if ((drv_cap.flow_control_cts == 0U) || (drv_cap.flow_control_rts == 0U)) {
640 if (ret != EXIT_SUCCESS) {
641 // If USART Driver does not support desired flow control
643 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Driver does not support %s flow control! Test aborted!", str_flow_control[flow_control]);
645 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Driver does not support unknown flow control! Test aborted!");
647 TEST_MESSAGE(msg_buf);
651 if ((modem_line_mask & 1U) != 0U) {
652 if (drv_cap.rts == 0U) {
653 TEST_MESSAGE("[FAILED] USART Driver does not support RTS modem line! Test aborted!");
657 if ((modem_line_mask & (1U << 1)) != 0U) {
658 if (drv_cap.cts == 0U) {
659 TEST_MESSAGE("[FAILED] USART Driver does not support CTS modem line! Test aborted!");
663 if ((modem_line_mask & (1U << 2)) != 0U) {
664 if (drv_cap.dtr == 0U) {
665 TEST_MESSAGE("[FAILED] USART Driver does not support DTR modem line! Test aborted!");
669 if ((modem_line_mask & (1U << 3)) != 0U) {
670 if (drv_cap.dsr == 0U) {
671 TEST_MESSAGE("[FAILED] USART Driver does not support DSR modem line! Test aborted!");
675 if ((modem_line_mask & (1U << 4)) != 0U) {
676 if (drv_cap.dcd == 0U) {
677 TEST_MESSAGE("[FAILED] USART Driver does not support DCD modem line! Test aborted!");
681 if ((modem_line_mask & (1U << 5)) != 0U) {
682 if (drv_cap.ri == 0U) {
683 TEST_MESSAGE("[FAILED] USART Driver does not support RI modem line! Test aborted!");
691 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
694 \fn static int32_t ComConfigDefault (void)
695 \brief Configure USART Communication Interface to USART Server default communication configuration.
696 \return execution status
697 - EXIT_SUCCESS: Default configuration set successfully
698 - EXIT_FAILURE: Default configuration failed
700 static int32_t ComConfigDefault (void) {
705 if (drv->Control(((USART_CFG_SRV_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
706 DRIVER_DATA_BITS(USART_CFG_SRV_DATA_BITS) |
707 ((USART_CFG_SRV_PARITY << ARM_USART_PARITY_Pos) & ARM_USART_PARITY_Msk) |
708 ((USART_CFG_SRV_STOP_BITS << ARM_USART_STOP_BITS_Pos) & ARM_USART_STOP_BITS_Msk) |
709 ((USART_CFG_SRV_FLOW_CONTROL << ARM_USART_FLOW_CONTROL_Pos) & ARM_USART_FLOW_CONTROL_Msk) ,
710 USART_CFG_SRV_BAUDRATE) != ARM_DRIVER_OK) {
713 if (drv->Control(ARM_USART_CONTROL_TX, 1U) != ARM_DRIVER_OK) {
717 if (ret != EXIT_SUCCESS) {
718 TEST_FAIL_MESSAGE("[FAILED] Configure communication interface to USART Server default settings. Check driver Control function! Test aborted!");
725 \fn static int32_t ComSendCommand (const void *data_out, uint32_t num)
726 \brief Send command to USART Server.
727 \param[out] data_out Pointer to memory containing data to be sent
728 \param[in] len Number of bytes to be sent
729 \return execution status
730 - EXIT_SUCCESS: Command sent successfully
731 - EXIT_FAILURE: Command send failed
733 static int32_t ComSendCommand (const void *data_out, uint32_t len) {
735 uint32_t flags, num, tout;
738 num = (len + DataBitsToBytes(USART_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(USART_CFG_SRV_DATA_BITS);
740 ret = ComConfigDefault();
742 if (ret == EXIT_SUCCESS) {
743 (void)osEventFlagsClear(event_flags, 0x7FFFFFFFU);
744 if (drv->Control(ARM_USART_CONTROL_TX, 1U) != ARM_DRIVER_OK) {
747 if (ret == EXIT_SUCCESS) {
748 if (drv->Send(data_out, num) != ARM_DRIVER_OK) {
751 if (ret == EXIT_SUCCESS) {
752 if (drv_cap.event_tx_complete != 0U) {
753 // If ARM_USART_EVENT_TX_COMPLETE is supported, wait for it
754 flags = osEventFlagsWait(event_flags, ARM_USART_EVENT_TX_COMPLETE, osFlagsWaitAny, USART_CFG_SRV_CMD_TOUT);
755 if (((flags & 0x80000000U) != 0U) ||
756 ((flags & ARM_USART_EVENT_TX_COMPLETE) == 0U)) {
760 // Otherwise wait for ARM_USART_EVENT_SEND_COMPLETE flag
761 flags = osEventFlagsWait(event_flags, ARM_USART_EVENT_SEND_COMPLETE, osFlagsWaitAny, USART_CFG_SRV_CMD_TOUT);
762 if (((flags & 0x80000000U) != 0U) ||
763 ((flags & ARM_USART_EVENT_SEND_COMPLETE) == 0U)) {
767 if (ret == EXIT_SUCCESS) {
768 // If completed event was signaled, wait for all data to be sent
769 for (tout = USART_CFG_SRV_CMD_TOUT; tout != 0U; tout--) {
770 if ((drv->GetTxCount() == len) && (drv->GetStatus().tx_busy == 0U)) {
778 if (ret == EXIT_FAILURE) {
779 (void)drv->Control(ARM_USART_ABORT_SEND, 0U);
783 (void)drv->Control(ARM_USART_CONTROL_TX, 0U);
789 \fn static int32_t ComReceiveResponse (void *data_in, uint32_t num)
790 \brief Receive response from USART Server.
791 \param[out] data_in Pointer to memory where data will be received
792 \param[in] len Number of data bytes to be received
793 \return execution status
794 - EXIT_SUCCESS: Command received successfully
795 - EXIT_FAILURE: Command reception failed
797 static int32_t ComReceiveResponse (void *data_in, uint32_t len) {
799 uint32_t flags, num, tout;
802 num = (len + DataBitsToBytes(USART_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(USART_CFG_SRV_DATA_BITS);
804 ret = ComConfigDefault();
806 if (ret == EXIT_SUCCESS) {
807 (void)osEventFlagsClear(event_flags, 0x7FFFFFFFU);
808 if (drv->Control(ARM_USART_CONTROL_RX, 1U) != ARM_DRIVER_OK) {
811 if (ret == EXIT_SUCCESS) {
812 if (drv->Receive(data_in, num) != ARM_DRIVER_OK) {
815 if (ret == EXIT_SUCCESS) {
816 flags = osEventFlagsWait(event_flags, ARM_USART_EVENT_RECEIVE_COMPLETE, osFlagsWaitAny, USART_CFG_SRV_CMD_TOUT);
817 if (((flags & 0x80000000U) != 0U) ||
818 ((flags & ARM_USART_EVENT_RECEIVE_COMPLETE) == 0U)) {
822 if (ret == EXIT_FAILURE) {
823 drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
827 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
833 \fn static int32_t CmdGetVer (void)
834 \brief Get version from USART Server and check that it is valid.
835 \return execution status
836 - EXIT_SUCCESS: Version retrieved successfully
837 - EXIT_FAILURE: Version retreival failed
839 static int32_t CmdGetVer (void) {
847 memset(&usart_serv_ver, 0, sizeof(usart_serv_ver));
849 // Send "GET VER" command to USART Server
850 memset(ptr_tx_buf, 0, CMD_LEN);
851 memcpy(ptr_tx_buf, "GET VER", 7);
852 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
854 if (ret == EXIT_SUCCESS) {
855 // Receive response to "GET VER" command from USART Server
856 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_VER_LEN);
857 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_VER_LEN);
862 if (ret == EXIT_SUCCESS) {
864 ptr_str = (const char *)ptr_rx_buf;
865 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
866 usart_serv_ver.major = val8;
871 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
873 ptr_str = strstr(ptr_str, "."); // Find '.'
874 if (ptr_str != NULL) {
875 ptr_str++; // Skip '.'
876 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
877 usart_serv_ver.minor = val8;
885 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
886 // Parse patch (revision)
887 ptr_str = strstr(ptr_str, "."); // Find next '.'
888 if (ptr_str != NULL) {
889 ptr_str++; // Skip '.'
890 if (sscanf(ptr_str, "%hx", &val16) == 1) {
891 usart_serv_ver.patch = val16;
904 \fn static int32_t CmdGetCap (void)
905 \brief Get capabilities from USART Server.
906 \return execution status
907 - EXIT_SUCCESS: Capabilities retrieved successfully
908 - EXIT_FAILURE: Capabilities retreival failed
910 static int32_t CmdGetCap (void) {
918 memset(&usart_serv_cap, 0, sizeof(usart_serv_cap));
920 // Send "GET CAP" command to USART Server
921 memset(ptr_tx_buf, 0, CMD_LEN);
922 memcpy(ptr_tx_buf, "GET CAP", 7);
923 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
925 if (ret == EXIT_SUCCESS) {
926 (void)osDelay(20U); // Give USART Server 20 ms to auto-detect capabilities
928 // Receive response to "GET CAP" command from USART Server
929 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_CAP_LEN);
930 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_CAP_LEN);
934 // Parse capabilities
935 if (ret == EXIT_SUCCESS) {
937 ptr_str = (const char *)ptr_rx_buf;
938 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
939 usart_serv_cap.mode_mask = val8;
944 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
945 // Parse data bit mask
946 ptr_str = strstr(ptr_str, ","); // Find ','
947 if (ptr_str != NULL) {
948 ptr_str++; // Skip ','
949 if (sscanf(ptr_str, "%x", &val32) == 1) {
950 usart_serv_cap.db_mask = val32;
958 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
960 ptr_str = strstr(ptr_str, ","); // Find next ','
961 if (ptr_str != NULL) {
962 ptr_str++; // Skip ','
963 if (sscanf(ptr_str, "%x", &val32) == 1) {
964 usart_serv_cap.parity_mask = val32;
972 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
973 // Parse stop bit mask
974 ptr_str = strstr(ptr_str, ","); // Find next ','
975 if (ptr_str != NULL) {
976 ptr_str++; // Skip ','
977 if (sscanf(ptr_str, "%x", &val32) == 1) {
978 usart_serv_cap.sb_mask = val32;
986 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
987 // Parse flow control mask
988 ptr_str = strstr(ptr_str, ","); // Find next ','
989 if (ptr_str != NULL) {
990 ptr_str++; // Skip ','
991 if (sscanf(ptr_str, "%x", &val32) == 1) {
992 usart_serv_cap.fc_mask = val32;
1000 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
1001 // Parse modem lines mask
1002 ptr_str = strstr(ptr_str, ","); // Find next ','
1003 if (ptr_str != NULL) {
1004 ptr_str++; // Skip ','
1005 if (sscanf(ptr_str, "%x", &val32) == 1) {
1006 usart_serv_cap.ml_mask = val32;
1014 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
1015 // Parse minimum baudrate
1016 ptr_str = strstr(ptr_str, ","); // Find next ','
1017 if (ptr_str != NULL) {
1018 ptr_str++; // Skip ','
1019 if (sscanf(ptr_str, "%u", &val32) == 1) {
1020 usart_serv_cap.br_min = val32;
1028 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
1029 // Parse maximum baudrate
1030 ptr_str = strstr(ptr_str, ","); // Find next ','
1031 if (ptr_str != NULL) {
1032 ptr_str++; // Skip ','
1033 if (sscanf(ptr_str, "%u", &val32) == 1) {
1034 usart_serv_cap.br_max = val32;
1047 \fn static int32_t CmdSetBufTx (char pattern)
1048 \brief Set Tx buffer of USART Server to pattern.
1049 \param[in] pattern Pattern to fill the buffer with
1050 \return execution status
1051 - EXIT_SUCCESS: Command sent successfully
1052 - EXIT_FAILURE: Command send failed
1054 static int32_t CmdSetBufTx (char pattern) {
1057 // Send "SET BUF TX" command to USART Server
1058 memset(ptr_tx_buf, 0, CMD_LEN);
1059 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF TX,0,%02X", (int32_t)pattern);
1060 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1063 if (ret != EXIT_SUCCESS) {
1064 TEST_FAIL_MESSAGE("[FAILED] Set Tx buffer on USART Server. Check USART Server! Test aborted!");
1071 \fn static int32_t CmdSetBufRx (char pattern)
1072 \brief Set Rx buffer of USART Server to pattern.
1073 \param[in] pattern Pattern to fill the buffer with
1074 \return execution status
1075 - EXIT_SUCCESS: Command sent successfully
1076 - EXIT_FAILURE: Command send failed
1078 static int32_t CmdSetBufRx (char pattern) {
1081 // Send "SET BUF RX" command to USART Server
1082 memset(ptr_tx_buf, 0, CMD_LEN);
1083 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF RX,0,%02X", (int32_t)pattern);
1084 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1087 if (ret != EXIT_SUCCESS) {
1088 TEST_FAIL_MESSAGE("[FAILED] Set Rx buffer on USART Server. Check USART Server! Test aborted!");
1095 \fn static int32_t CmdGetBufRx (void)
1096 \brief Get Rx buffer from USART Server (into global array pointed to by ptr_rx_buf).
1097 \param[in] len Number of bytes to read from Rx buffer
1098 \return execution status
1099 - EXIT_SUCCESS: Command sent and response received successfully
1100 - EXIT_FAILURE: Command send or response reception failed
1102 static int32_t CmdGetBufRx (uint32_t len) {
1105 // Send "GET BUF RX" command to USART Server
1106 memset(ptr_tx_buf, 0, CMD_LEN);
1107 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "GET BUF RX,%i", len);
1108 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1110 if (ret == EXIT_SUCCESS) {
1111 // Receive response to "GET BUF RX" command from USART Server
1112 memset(ptr_rx_buf, (int32_t)'?', len);
1113 ret = ComReceiveResponse(ptr_rx_buf, len);
1117 if (ret != EXIT_SUCCESS) {
1118 TEST_FAIL_MESSAGE("[FAILED] Get Rx buffer from USART Server. Check USART Server! Test aborted!");
1125 \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)
1126 \brief Set communication parameters on USART Server for next XFER command.
1127 \param[in] mode mode:
1128 - value 0 = Asynchronous
1129 - value 1 = Synchronous Master
1130 - value 2 = Synchronous Slave
1131 - value 3 = Single Wire
1133 - value 5 = Smart Card
1134 \param[in] data_bits data bits:
1136 \param[in] parity parity:
1140 \param[in] stop_bits stop bits:
1141 - value 0 = 1 Stop Bit
1142 - value 1 = 2 Stop Bits
1143 - value 2 = 1.5 Stop Bits
1144 - value 3 = 0.5 Stop Bits
1145 \param[in] flow_control flow control:
1150 \param[in] cpol clock polarity:
1151 - value 0 = Data are captured on rising edge
1152 - value 1 = Data are captured on falling edge
1153 \param[in] cpha clock phase:
1154 - value 0 = Sample on first (leading) edge
1155 - value 1 = Sample on second (trailing) edge
1156 \param[in] baudrate baudrate in bauds
1157 \return execution status
1158 - EXIT_SUCCESS: Command sent successfully
1159 - EXIT_FAILURE: Command send failed
1161 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) {
1164 // Send "SET COM" command to USART Server
1165 memset(ptr_tx_buf, 0, CMD_LEN);
1166 stat = snprintf((char *)ptr_tx_buf, CMD_LEN, "SET COM %i,%i,%i,%i,%i,%i,%i,%i", mode, data_bits, parity, stop_bits, flow_control, cpol, cpha, baudrate);
1167 if ((stat > 0) && (stat < CMD_LEN)) {
1168 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1174 if (ret != EXIT_SUCCESS) {
1175 TEST_FAIL_MESSAGE("[FAILED] Set communication settings on USART Server. Check USART Server! Test aborted!");
1182 \fn static int32_t CmdXfer (uint32_t dir, uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_cts)
1183 \brief Activate transfer on USART Server.
1184 \param[in] dir direction of transfer
1187 - 2 = Transfer (simultaneous Tx and Rx (in synchronous mode only))
1188 \param[in] num number of items (according CMSIS USART driver specification)
1189 \param[in] delay initial delay, in milliseconds, before starting requested operation
1190 (0xFFFFFFFF = delay not used)
1191 \param[in] timeout timeout in milliseconds, after delay, if delay is specified
1192 \param[in] num_cts number of items after which CTS line should be de-activated
1193 - 0 = no CTS deactivation
1194 \return execution status
1195 - EXIT_SUCCESS: Command sent successfully
1196 - EXIT_FAILURE: Command send failed
1198 static int32_t CmdXfer (uint32_t dir, uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_cts) {
1201 // Send "XFER" command to USART Server
1202 memset(ptr_tx_buf, 0, CMD_LEN);
1203 if (num_cts != 0U) {
1204 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i,%i,%i", dir, num, delay, timeout, num_cts);
1205 } else if ((delay != osWaitForever) && (timeout != 0U)) {
1206 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i,%i", dir, num, delay, timeout);
1207 } else if (delay != osWaitForever) {
1208 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i", dir, num, delay);
1210 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i", dir, num);
1212 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1214 if (ret != EXIT_SUCCESS) {
1215 TEST_FAIL_MESSAGE("[FAILED] Activate transfer on USART Server. Check USART Server! Test aborted!");
1222 \fn static int32_t CmdGetCnt (void)
1223 \brief Get XFER command Tx/Rx count from USART Server.
1224 \return execution status
1225 - EXIT_SUCCESS: Operation successful
1226 - EXIT_FAILURE: Operation failed
1228 static int32_t CmdGetCnt (void) {
1230 const char *ptr_str;
1235 // Send "GET CNT" command to USART Server
1236 memset(ptr_tx_buf, 0, CMD_LEN);
1237 memcpy(ptr_tx_buf, "GET CNT", 7);
1238 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1240 if (ret == EXIT_SUCCESS) {
1241 // Receive response to "GET CNT" command from USART Server
1242 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_CNT_LEN);
1243 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_CNT_LEN);
1247 if (ret == EXIT_SUCCESS) {
1249 ptr_str = (const char *)ptr_rx_buf;
1250 if (sscanf(ptr_str, "%i", &val32) == 1) {
1257 if (ret != EXIT_SUCCESS) {
1258 TEST_FAIL_MESSAGE("[FAILED] Get count from USART Server. Check USART Server! Test aborted!");
1265 \fn static int32_t CmdSetBrk (uint32_t delay, uint32_t duration)
1266 \brief Request USART Server to send break signal.
1267 \param[in] delay: initial delay, in milliseconds, before start of break signaling
1268 \param[in] duration: duration, in milliseconds, of break signaling
1269 \return execution status
1270 - EXIT_SUCCESS: Command sent successfully
1271 - EXIT_FAILURE: Command send failed
1273 static int32_t CmdSetBrk (uint32_t delay, uint32_t duration) {
1276 // Send "SET BRK" command to USART Server
1277 memset(ptr_tx_buf, 0, CMD_LEN);
1278 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BRK %i,%i", delay, duration);
1279 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1281 if (ret != EXIT_SUCCESS) {
1282 TEST_FAIL_MESSAGE("[FAILED] Set break on USART Server. Check USART Server! Test aborted!");
1289 \fn static int32_t CmdGetBrk (void)
1290 \brief Get information on Break state from USART Server.
1291 \return execution status
1292 - EXIT_SUCCESS: Command sent and response received successfully
1293 - EXIT_FAILURE: Command send or response reception failed
1295 static int32_t CmdGetBrk (void) {
1298 // Send "GET BRK" command to USART Server
1299 memset(ptr_tx_buf, 0, CMD_LEN);
1300 memcpy(ptr_tx_buf, "GET BRK", 7);
1301 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1303 if (ret == EXIT_SUCCESS) {
1304 // Receive response to "GET BRK" command from USART Server
1305 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_BRK_LEN);
1306 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_BRK_LEN);
1310 // Store modem status to global variable
1311 if (ret == EXIT_SUCCESS) {
1312 break_status = ptr_rx_buf[0] - '0';
1315 if (ret != EXIT_SUCCESS) {
1316 TEST_FAIL_MESSAGE("[FAILED] Get break state from USART Server. Check USART Server! Test aborted!");
1323 \fn static int32_t CmdSetMdm (uint32_t mdm_ctrl, uint32_t delay, uint32_t duration)
1324 \brief Set modem lines on USART Server.
1325 \param[in] mdm_ctrl: modem control line states:
1328 - bit 2.: Line to USART Client's DCD state
1329 - bit 3.: Line to USART Client's RI state
1330 \param[in] delay: initial delay, in milliseconds, before start of controlling modem lines
1331 \param[in] duration: duration, in milliseconds, of controlling modem lines
1332 \return execution status
1333 - EXIT_SUCCESS: Command sent successfully
1334 - EXIT_FAILURE: Command send failed
1336 static int32_t CmdSetMdm (uint32_t mdm_ctrl, uint32_t delay, uint32_t duration) {
1339 // Send "SET MDM" command to USART Server
1340 memset(ptr_tx_buf, 0, CMD_LEN);
1341 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET MDM %x,%i,%i", mdm_ctrl, delay, duration);
1342 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1344 if (ret != EXIT_SUCCESS) {
1345 TEST_FAIL_MESSAGE("[FAILED] Set modem control on USART Server. Check USART Server! Test aborted!");
1352 \fn static int32_t CmdGetMdm (void)
1353 \brief Get information on modem lines current state from USART Server.
1354 \return execution status
1355 - EXIT_SUCCESS: Command sent and response received successfully
1356 - EXIT_FAILURE: Command send or response reception failed
1358 static int32_t CmdGetMdm (void) {
1361 // Send "GET MDM" command to USART Server
1362 memset(ptr_tx_buf, 0, CMD_LEN);
1363 memcpy(ptr_tx_buf, "GET MDM", 7);
1364 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1366 if (ret == EXIT_SUCCESS) {
1367 // Receive response to "GET MDM" command from USART Server
1368 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_MDM_LEN);
1369 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_MDM_LEN);
1373 // Store modem status to global variable
1374 if (ret == EXIT_SUCCESS) {
1375 modem_status = ptr_rx_buf[0] - '0';
1378 if (ret != EXIT_SUCCESS) {
1379 TEST_FAIL_MESSAGE("[FAILED] Get modem lines state from USART Server. Check USART Server! Test aborted!");
1386 \fn static int32_t ServerInit (void)
1387 \brief Initialize communication with USART Server, get version and capabilities.
1388 \return execution status
1389 - EXIT_SUCCESS: USART Server initialized successfully
1390 - EXIT_FAILURE: USART Server initialization failed
1392 static int32_t ServerInit (void) {
1394 if (server_ok == -1) { // If -1, means it was not yet checked
1397 if (drv->Control(((USART_CFG_SRV_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
1398 DRIVER_DATA_BITS(USART_CFG_SRV_DATA_BITS) |
1399 ((USART_CFG_SRV_PARITY << ARM_USART_PARITY_Pos) & ARM_USART_PARITY_Msk) |
1400 ((USART_CFG_SRV_STOP_BITS << ARM_USART_STOP_BITS_Pos) & ARM_USART_STOP_BITS_Msk) |
1401 ((USART_CFG_SRV_FLOW_CONTROL << ARM_USART_FLOW_CONTROL_Pos) & ARM_USART_FLOW_CONTROL_Msk) ,
1402 USART_CFG_SRV_BAUDRATE) != ARM_DRIVER_OK) {
1405 if (server_ok == 0) {
1406 TEST_GROUP_INFO("Failed to configure communication interface to USART Server default settings.\n"\
1407 "Driver must support basic settings used for communication with USART Server!");
1410 if (server_ok == 1) {
1412 if (CmdGetVer() != EXIT_SUCCESS) {
1413 TEST_GROUP_INFO("Failed to Get version from USART Server.\nCheck USART Server!\n");
1418 if (server_ok == 1) {
1419 if (usart_serv_ver.major == 0U) {
1420 TEST_GROUP_INFO("USART Server version must be 1.0.0. or higher.\nUpdate USART Server to newer version!\n");
1425 if (server_ok == 1) {
1426 if (CmdGetCap() != EXIT_SUCCESS) {
1427 TEST_GROUP_INFO("Failed to Get capabilities from USART Server.\nCheck USART Server!\n");
1433 if (server_ok == 1) {
1434 return EXIT_SUCCESS;
1437 return EXIT_FAILURE;
1441 \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)
1442 \brief Check if USART Server is functional and if it supports desired settings.
1443 \detail Parameters describe settings required to test, so server must support complementary sattings.
1444 For example to test RTS line server must support CTS line.
1445 \param[in] mode mode (expected to be tested):
1446 - value 1 = Asynchronous
1447 - value 2 = Synchronous Master
1448 - value 3 = Synchronous Slave
1449 - value 4 = Single Wire
1451 - value 6 = Smart Card
1452 \param[in] data_bits data bits (5 .. 9)
1453 \param[in] parity parity:
1457 \param[in] stop_bits stop bits:
1458 - value 0 = 1 Stop Bit
1459 - value 1 = 2 Stop Bits
1460 - value 2 = 1.5 Stop Bits
1461 - value 3 = 0.5 Stop Bits
1462 \param[in] flow_control flow control:
1467 \param[in] modem_line_mask modem line mask:
1474 \param[in] baudrate baudrate in bauds
1475 \return execution status
1476 - EXIT_SUCCESS: USART Server supports desired settings
1477 - EXIT_FAILURE: USART Server does not support desired settings
1479 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) {
1480 uint32_t srv_mode, srv_flow_control, srv_modem_line_mask;
1482 if (server_ok == 0) {
1483 TEST_FAIL_MESSAGE("[FAILED] USART Server status. Check USART Server! Test aborted!");
1484 return EXIT_FAILURE;
1487 #if (USART_CFG_SRV_MODE == MODE_ASYNCHRONOUS)
1488 if ((mode == MODE_SINGLE_WIRE) || (mode == MODE_IRDA)) {
1489 TEST_MESSAGE("[FAILED] USART Server mode Asynchronous does not support requested test mode! Test aborted!");
1490 return EXIT_FAILURE;
1492 #elif (USART_CFG_SRV_MODE == MODE_SINGLE_WIRE)
1493 if (mode != MODE_SINGLE_WIRE) {
1494 TEST_MESSAGE("[FAILED] USART Server mode Single-wire does not support requested test mode! Test aborted!");
1495 return EXIT_FAILURE;
1497 #elif (USART_CFG_SRV_MODE == MODE_SINGLE_IRDA)
1498 if (mode != MODE_SINGLE_IRDA) {
1499 TEST_MESSAGE("[FAILED] USART Server mode IrDA does not support requested test mode! Test aborted!");
1500 return EXIT_FAILURE;
1503 TEST_MESSAGE("[FAILED] USART Server mode unknown! Test aborted!");
1504 return EXIT_FAILURE;
1508 if (mode == MODE_SYNCHRONOUS_MASTER) { // If mode to be tested is Synchro Master then server must support Slave
1509 srv_mode = MODE_SYNCHRONOUS_SLAVE;
1510 } else if (mode == MODE_SYNCHRONOUS_SLAVE) { // If mode to be tested is Synchro Slave then server must support Master
1511 srv_mode = MODE_SYNCHRONOUS_MASTER;
1514 srv_flow_control = flow_control;
1515 if (flow_control == FLOW_CONTROL_RTS) {
1516 srv_flow_control = FLOW_CONTROL_CTS;
1518 if (flow_control == FLOW_CONTROL_CTS) {
1519 srv_flow_control = FLOW_CONTROL_RTS;
1522 srv_modem_line_mask = 0U;
1523 if ((modem_line_mask & RTS_AVAILABLE ) != 0U) {
1524 srv_modem_line_mask |= CTS_AVAILABLE;
1526 if ((modem_line_mask & CTS_AVAILABLE ) != 0U) {
1527 srv_modem_line_mask |= RTS_AVAILABLE;
1529 if ((modem_line_mask & DTR_AVAILABLE ) != 0U) {
1530 srv_modem_line_mask |= DSR_AVAILABLE;
1532 if ((modem_line_mask & DSR_AVAILABLE ) != 0U) {
1533 srv_modem_line_mask |= DTR_AVAILABLE;
1535 if ((modem_line_mask & DCD_AVAILABLE) != 0U) {
1536 srv_modem_line_mask |= DCD_AVAILABLE;
1538 if ((modem_line_mask & RI_AVAILABLE ) != 0U) {
1539 srv_modem_line_mask |= RI_AVAILABLE;
1542 if ((usart_serv_cap.mode_mask & (1UL << (srv_mode - 1U))) == 0U) {
1543 // If USART Server does not support desired mode
1544 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %s mode! Test aborted!", str_mode[mode]);
1545 TEST_MESSAGE(msg_buf);
1546 return EXIT_FAILURE;
1548 if ((usart_serv_cap.db_mask & (1UL << (data_bits - 5U))) == 0U) {
1549 // If USART Server does not support desired data bits
1550 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %i data bits! Test aborted!", data_bits);
1551 TEST_MESSAGE(msg_buf);
1552 return EXIT_FAILURE;
1554 if ((usart_serv_cap.parity_mask & (1UL << parity)) == 0U) {
1555 // If USART Server does not support desired parity
1556 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %s parity! Test aborted!", str_parity[parity]);
1557 TEST_MESSAGE(msg_buf);
1558 return EXIT_FAILURE;
1560 if ((usart_serv_cap.sb_mask & (1UL << stop_bits)) == 0U) {
1561 // If USART Server does not support desired stop bits
1562 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %s stop bits! Test aborted!", str_stop_bits[stop_bits]);
1563 TEST_MESSAGE(msg_buf);
1564 return EXIT_FAILURE;
1566 if ((usart_serv_cap.fc_mask & (1UL << srv_flow_control)) == 0U) {
1567 // If USART Server does not support desired flow control
1568 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %s flow control! Test aborted!", str_flow_control[flow_control]);
1569 TEST_MESSAGE(msg_buf);
1570 return EXIT_FAILURE;
1572 if (srv_modem_line_mask != 0U) {
1573 if ((usart_serv_cap.ml_mask & srv_modem_line_mask) == 0U) {
1574 // If USART Server does not support desired modem line
1575 TEST_MESSAGE("[FAILED] USART Server does not support desired modem line! Test aborted!");
1576 return EXIT_FAILURE;
1579 if ((usart_serv_cap.br_min > baudrate) ||
1580 (usart_serv_cap.br_max < baudrate)) {
1581 // If USART Server does not support desired baudrate
1582 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %i baudrate bus speed! Test aborted!", baudrate);
1583 TEST_MESSAGE(msg_buf);
1584 return EXIT_FAILURE;
1587 return EXIT_SUCCESS;
1590 #endif // If Test Mode USART Server is selected
1593 \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)
1594 \brief Check if Driver and USART Server (if used) is functional and if it supports desired settings.
1595 \detail Parameters describe settings required to test, so server must support complementary sattings.
1596 For example to test RTS line server must support CTS line.
1597 \param[in] mode mode (expected to be tested):
1598 - value 1 = Asynchronous
1599 - value 2 = Synchronous Master
1600 - value 3 = Synchronous Slave
1601 - value 4 = Single Wire
1603 - value 6 = Smart Card
1604 \param[in] data_bits data bits (5 .. 9)
1605 \param[in] parity parity:
1609 \param[in] stop_bits stop bits:
1610 - value 0 = 1 Stop Bit
1611 - value 1 = 2 Stop Bits
1612 - value 2 = 1.5 Stop Bits
1613 - value 3 = 0.5 Stop Bits
1614 \param[in] flow_control flow control:
1619 \param[in] modem_line_mask modem line mask:
1626 \param[in] baudrate baudrate in bauds
1627 \return execution status
1628 - EXIT_SUCCESS: Driver and USART Server supports desired settings
1629 - EXIT_FAILURE: Driver or USART Server does not support desired settings
1631 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) {
1633 if (BuffersCheck() != EXIT_SUCCESS) {
1634 return EXIT_FAILURE;
1637 if (DriverCheck (mode, flow_control, modem_line_mask) != EXIT_SUCCESS) {
1638 return EXIT_FAILURE;
1640 #if (USART_SERVER_USED == 1)
1641 if (ServerCheck (mode, data_bits, parity, stop_bits, flow_control, modem_line_mask, baudrate) != EXIT_SUCCESS) {
1642 return EXIT_FAILURE;
1646 return EXIT_SUCCESS;
1650 \fn void USART_DV_Initialize (void)
1651 \brief Initialize testing environment for USART testing.
1652 \detail This function is called by the driver validation framework before USART testing begins.
1653 It initializes global variables and allocates memory buffers (from heap) used for the USART testing.
1656 void USART_DV_Initialize (void) {
1658 // Initialize global variables
1663 duration = 0xFFFFFFFFUL;
1664 systick_freq = osKernelGetSysTimerFreq();
1665 if (systick_freq == 0U) {
1666 // systick_freq must not be 0
1669 ticks_per_ms = systick_freq / 1000U;
1671 memset(&usart_serv_cap, 0, sizeof(usart_serv_cap));
1672 memset(&msg_buf, 0, sizeof(msg_buf));
1674 // Allocate buffers for transmission, reception and comparison
1675 // (maximum size is incremented by 32 bytes to ensure that buffer can be aligned to 32 bytes)
1677 ptr_tx_buf_alloc = malloc(USART_BUF_MAX + 32U);
1678 if (((uint32_t)ptr_tx_buf_alloc & 31U) != 0U) {
1679 // If allocated memory is not 32 byte aligned, use next 32 byte aligned address for ptr_tx_buf
1680 ptr_tx_buf = (uint8_t *)((((uint32_t)ptr_tx_buf_alloc) + 31U) & (~31U));
1682 // If allocated memory is 32 byte aligned, use it directly
1683 ptr_tx_buf = (uint8_t *)ptr_tx_buf_alloc;
1685 ptr_rx_buf_alloc = malloc(USART_BUF_MAX + 32U);
1686 if (((uint32_t)ptr_rx_buf_alloc & 31U) != 0U) {
1687 ptr_rx_buf = (uint8_t *)((((uint32_t)ptr_rx_buf_alloc) + 31U) & (~31U));
1689 ptr_rx_buf = (uint8_t *)ptr_rx_buf_alloc;
1691 ptr_cmp_buf_alloc = malloc(USART_BUF_MAX + 32U);
1692 if (((uint32_t)ptr_cmp_buf_alloc & 31U) != 0U) {
1693 ptr_cmp_buf = (uint8_t *)((((uint32_t)ptr_cmp_buf_alloc) + 31U) & (~31U));
1695 ptr_cmp_buf = (uint8_t *)ptr_cmp_buf_alloc;
1698 event_flags = osEventFlagsNew(NULL);
1700 // Output configuration settings
1701 (void)snprintf(msg_buf,
1704 "Default settings:\n"\
1706 " - Data bits: %i\n"\
1708 " - Stop bits: %s\n"\
1709 " - Flow control: %s\n"\
1710 " - Clock polarity: %s\n"\
1711 " - Clock phase: %s\n"\
1712 " - Bus speed: %i bauds\n"\
1713 " - Number of Items: %i",
1714 str_test_mode [USART_CFG_TEST_MODE],
1715 str_mode [USART_CFG_DEF_MODE],
1716 USART_CFG_DEF_DATA_BITS,
1717 str_parity [USART_CFG_DEF_PARITY],
1718 str_stop_bits [USART_CFG_DEF_STOP_BITS],
1719 str_flow_control[USART_CFG_DEF_FLOW_CONTROL],
1720 str_cpol [USART_CFG_DEF_CPOL],
1721 str_cpha [USART_CFG_DEF_CPHA],
1722 USART_CFG_DEF_BAUDRATE,
1724 TEST_GROUP_INFO(msg_buf);
1726 drv_cap = drv->GetCapabilities();
1728 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
1729 // Test communication with USART Server
1730 int32_t server_status;
1733 // Test communication with USART Server
1734 if (drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK) {
1735 if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
1736 server_status = ServerInit();
1739 (void)drv->PowerControl(ARM_POWER_OFF);
1740 (void)drv->Uninitialize();
1742 //(void)snprintf(msg_buf, sizeof(msg_buf), "Server status: %s\n", str_srv_status[server_status]);
1743 //TEST_GROUP_INFO(msg_buf);
1748 \fn void USART_DV_Uninitialize (void)
1749 \brief De-initialize testing environment after USART testing.
1750 \detail This function is called by the driver validation framework after USART testing is finished.
1751 It frees memory buffers used for the USART testing.
1754 void USART_DV_Uninitialize (void) {
1756 (void)osEventFlagsDelete(event_flags);
1758 if (ptr_tx_buf_alloc != NULL) {
1759 free(ptr_tx_buf_alloc);
1761 ptr_tx_buf_alloc = NULL;
1763 if (ptr_rx_buf_alloc != NULL) {
1764 free(ptr_rx_buf_alloc);
1766 ptr_rx_buf_alloc = NULL;
1768 if (ptr_cmp_buf_alloc != NULL) {
1769 free(ptr_cmp_buf_alloc);
1771 ptr_cmp_buf_alloc = NULL;
1775 #endif // End of exclude form the documentation
1777 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1779 \defgroup dv_usart USART Validation
1780 \brief USART driver validation
1782 The USART validation performs the following tests:
1783 - API interface compliance
1784 - Data exchange with various speeds, transfer sizes and communication settings
1785 - Modem lines operation
1788 Two Test Modes are available: <b>Loopback</b> and <b>USART Server</b>.
1790 Test Mode : <b>Loopback</b>
1791 ---------------------------
1793 This test mode allows only limited validation of the USART Driver.<br>
1794 It is recommended that this test mode is used only as a proof that driver is
1795 good enough to be tested with the <b>USART Server</b>.
1797 For this purpose following <b>Default settings</b> should be used:
1798 - Mode: Asynchronous
1803 - Clock Polarity: Clock Polarity 0
1804 - Clock Phase: Clock Phase 0
1806 - Number of Items: 32
1808 To enable this mode of testing in the <b>DV_USART_Config.h</b> configuration file select the
1809 <b>Configuration: Test Mode: Loopback</b> setting.
1811 Required pin connection for the <b>Loopback</b> test mode:
1813 \image html usart_loopback_pin_connections.png
1815 \note In this mode following operations / settings cannot be tested:
1816 - synchronous slave or single-wire modes
1817 - operation of the Receive function
1818 - data content sent by the Send function
1819 - parity, stop bits, flow control, clock polarity / phase settings
1820 - data bit settings other then 8
1821 - modem lines operation
1824 \anchor usart_server_con
1826 Test Mode : <b>USART Server</b>
1827 -----------------------------
1829 This test mode allows extensive validation of the USART Driver.<br>
1830 Results of the Driver Validation in this test mode are relevant as a proof of driver compliance
1831 to the CMSIS-Driver specification.
1833 To perform extensive communication tests, it is required to use an
1834 \ref usart_server "USART Server" running on a dedicated hardware.
1836 To enable this mode of testing in the <b>DV_USART_Config.h</b> configuration file select the
1837 <b>Configuration: Test Mode: USART Server</b> setting.
1839 Required pin connections for the <b>USART Server</b> test mode with <b>USART Server Mode</b>: <b>Asynchronous</b> or <b>IrDa</b>
1841 \note Only necessary pin connections are Tx, Rx and GND. Flow control (RTS, CTS), modem lines (DSR, DTR, DCD, RI) and
1842 synchronous clock (CLK) line are optional and depend on pin availability and driver support for flow control, modem lines and
1844 \note For stable idle level on Rx lines, external pull-ups can be added.
1846 \image html usart_server_pin_connections_async.png
1848 Required pin connections for the <b>USART Server</b> test mode with <b>USART Server Mode</b>: <b>Single-wire</b>
1850 \image html usart_server_pin_connections_single_wire.png
1852 \note Asynchronous and IrDa modes use same connection type and Single-wire uses a different connection.
1853 \note Please ensure that correct connection is used as required by tests otherwise damage to hardware may occur
1854 (For example using Asynchronous mode selected with hardware connected for Single-wire tests can result in damaged pins).
1855 \note In this mode Tx and Rx pins are internally connected together.
1856 \note Tx pin should use open-drain setting in this mode to prevent damage in case of simultaneous
1857 driving from both USART Server and USART Client.
1859 \note To ensure proper signal quality:
1860 - keep the connecting wires as short as possible
1861 - if possible keep Tx and Rx wires wires separate from each other
1862 - ensure a good Ground (GND) connection between USART Server and DUT
1864 \defgroup usart_tests Tests
1868 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1869 /* USART Driver Management tests */
1870 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1872 \defgroup usart_tests_drv_mgmt Driver Management
1873 \ingroup usart_tests
1875 These tests verify API and operation of the USART driver management functions.
1877 The driver management tests verify the following driver functions
1878 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html" target="_blank">USART Driver function documentation</a>):
1881 ARM_DRIVER_VERSION GetVersion (void);
1883 - \b GetCapabilities
1885 ARM_USART_CAPABILITIES GetCapabilities (void);
1889 int32_t Initialize (ARM_USART_SignalEvent_t cb_event);
1893 int32_t Uninitialize (void);
1897 int32_t PowerControl (ARM_POWER_STATE state);
1903 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1905 \brief Function: Function USART_GetVersion
1907 The function \b UDSART_GetVersion verifies the \b GetVersion function.
1909 ARM_DRIVER_VERSION GetVersion (void);
1913 - Driver is uninitialized and peripheral is powered-off:
1914 - Call GetVersion function
1915 - Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1917 void USART_GetVersion (void) {
1918 ARM_DRIVER_VERSION ver;
1920 ver = drv->GetVersion();
1922 // Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1923 TEST_ASSERT((ver.api >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)) && (ver.drv >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)));
1925 (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));
1926 TEST_MESSAGE(msg_buf);
1929 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1931 \brief Function: Function USART_GetCapabilities
1933 The function \b USART_GetCapabilities verifies the \b GetCapabilities function.
1935 ARM_USART_CAPABILITIES GetCapabilities (void);
1939 - Driver is uninitialized and peripheral is powered-off:
1940 - Call GetCapabilities function
1941 - Assert that GetCapabilities function returned capabilities structure with reserved field 0
1943 void USART_GetCapabilities (void) {
1944 ARM_USART_CAPABILITIES cap;
1946 cap = drv->GetCapabilities();
1948 // Assert that GetCapabilities function returned capabilities structure with reserved field 0
1949 TEST_ASSERT_MESSAGE((cap.reserved == 0U), "[FAILED] Capabilities reserved field must be 0");
1952 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1954 \brief Function: Function USART_Initialize_Uninitialize
1956 The function \b USART_Initialize_Uninitialize verifies the \b Initialize and \b Uninitialize functions.
1958 int32_t Initialize (ARM_USART_SignalEvent_t cb_event);
1961 int32_t Uninitialize (void);
1965 - Driver is uninitialized and peripheral is powered-off:
1966 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1967 - Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1968 - Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1969 - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1970 - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1971 - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1972 - Call GetTxCount function and assert that it returned 0
1973 - Call GetRxCount function and assert that it returned 0
1974 - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1975 - Call GetStatus function
1976 - Assert that GetStatus function returned status structure with tx_busy flag 0
1977 - Assert that GetStatus function returned status structure with rx_busy flag 0
1978 - Assert that GetStatus function returned status structure with tx_underflow flag 0
1979 - Assert that GetStatus function returned status structure with rx_overflow flag 0
1980 - Assert that GetStatus function returned status structure with rx_break flag 0
1981 - Assert that GetStatus function returned status structure with rx_framing_error flag 0
1982 - Assert that GetStatus function returned status structure with rx_parity_error flag 0
1983 - Assert that GetStatus function returned status structure with reserved field 0
1984 - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1985 - Driver is initialized and peripheral is powered-off:
1986 - Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1987 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1988 - Driver is uninitialized and peripheral is powered-off:
1989 - Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1990 - Driver is initialized and peripheral is powered-off:
1991 - Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1992 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1993 - Driver is uninitialized and peripheral is powered-off:
1994 - Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1995 - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1996 - Driver is initialized and peripheral is powered-off:
1997 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1998 - Driver is initialized and peripheral is powered-on:
1999 - Call Control function and assert that it returned ARM_DRIVER_OK status
2000 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status<br>
2001 (this must unconditionally terminate active send/receive/transfer, power-off the peripheral and uninitialize the driver)
2002 - Driver is uninitialized and peripheral is powered-off:
2003 - Call GetStatus function
2004 - Assert that GetStatus function returned status structure with tx_busy flag 0
2005 - Assert that GetStatus function returned status structure with rx_busy flag 0
2007 void USART_Initialize_Uninitialize (void) {
2008 ARM_USART_STATUS stat;
2010 // Driver is uninitialized and peripheral is powered-off:
2011 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
2012 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_ERROR);
2014 stat = drv->GetStatus();
2016 // Call PowerControl(ARM_POWER_LOW) function and assert that it returned status different then ARM_DRIVER_OK
2017 TEST_ASSERT(drv->PowerControl (ARM_POWER_LOW) != ARM_DRIVER_OK);
2019 stat = drv->GetStatus();
2021 // Call Send function and assert that it returned ARM_DRIVER_ERROR status
2022 TEST_ASSERT(drv->Send (ptr_tx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2024 // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
2025 TEST_ASSERT(drv->Receive (ptr_rx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2027 // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
2028 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2030 // Call Control function and assert that it returned ARM_DRIVER_ERROR status
2031 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);
2033 // Call GetStatus function
2034 stat = drv->GetStatus();
2036 // Assert that GetStatus function returned status structure with tx_busy flag 0
2037 TEST_ASSERT(stat.tx_busy == 0U);
2039 // Assert that GetStatus function returned status structure with rx_busy flag 0
2040 TEST_ASSERT(stat.rx_busy == 0U);
2042 // Assert that GetStatus function returned status structure with tx_underflow flag 0
2043 TEST_ASSERT(stat.tx_underflow == 0U);
2045 // Assert that GetStatus function returned status structure with rx_overflow flag 0
2046 TEST_ASSERT(stat.rx_overflow == 0U);
2048 // Assert that GetStatus function returned status structure with rx_break flag 0
2049 TEST_ASSERT(stat.rx_break == 0U);
2051 // Assert that GetStatus function returned status structure with rx_framing_error flag 0
2052 TEST_ASSERT(stat.rx_framing_error == 0U);
2054 // Assert that GetStatus function returned status structure with rx_parity_error flag 0
2055 TEST_ASSERT(stat.rx_parity_error == 0U);
2057 // Assert that GetStatus function returned status structure with reserved field 0
2058 TEST_ASSERT(stat.reserved == 0U);
2060 // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
2061 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
2063 // Driver is initialized and peripheral is powered-off:
2064 // Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
2065 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
2067 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
2068 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
2070 // Driver is uninitialized and peripheral is powered-off:
2071 // Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
2072 TEST_ASSERT(drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK);
2074 // Driver is initialized and peripheral is powered-off:
2075 // Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
2076 TEST_ASSERT(drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK);
2078 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
2079 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
2081 // Driver is uninitialized and peripheral is powered-off:
2082 // Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
2083 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
2085 // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
2086 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
2088 // Driver is initialized and peripheral is powered-off:
2089 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2090 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
2092 // Driver is initialized and peripheral is powered-on:
2093 // Call Control function and assert that it returned ARM_DRIVER_OK status
2094 TEST_ASSERT(drv->Control (((USART_CFG_DEF_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
2095 ((USART_CFG_DEF_CPOL << ARM_USART_CPOL_Pos) & ARM_USART_CPOL_Msk) |
2096 ((USART_CFG_DEF_CPHA << ARM_USART_CPHA_Pos) & ARM_USART_CPHA_Msk) |
2097 ARM_USART_DATA_BITS_8, USART_CFG_DEF_BAUDRATE) == ARM_DRIVER_OK);
2099 // Call Uninitialize function assert that it returned ARM_DRIVER_OK status
2100 // (this must unconditionally terminate active send/receive/transfer, power-off the peripheral and uninitialize the driver)
2101 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
2103 // Driver is uninitialized and peripheral is powered-off:
2104 // Call GetStatus function
2105 stat = drv->GetStatus();
2107 // Assert that GetStatus function returned status structure with tx_busy flag 0
2108 TEST_ASSERT(stat.tx_busy == 0U);
2110 // Assert that GetStatus function returned status structure with rx_busy flag 0
2111 TEST_ASSERT(stat.rx_busy == 0U);
2114 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2116 \brief Function: Function USART_PowerControl
2118 The function \b USART_PowerControl verifies the \b PowerControl function.
2120 int32_t PowerControl (ARM_POWER_STATE state);
2124 - Driver is initialized and peripheral is powered-off:
2125 - Call Send function and assert that it returned ARM_DRIVER_ERROR status
2126 - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
2127 - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
2128 - Call GetTxCount function and assert that it returned 0
2129 - Call GetRxCount function and assert that it returned 0
2130 - Call Control function and assert that it returned ARM_DRIVER_ERROR status
2131 - Call GetStatus function
2132 - Assert that GetStatus function returned status structure with tx_busy flag 0
2133 - Assert that GetStatus function returned status structure with rx_busy flag 0
2134 - Assert that GetStatus function returned status structure with tx_underflow flag 0
2135 - Assert that GetStatus function returned status structure with rx_overflow flag 0
2136 - Assert that GetStatus function returned status structure with rx_break flag 0
2137 - Assert that GetStatus function returned status structure with rx_framing_error flag 0
2138 - Assert that GetStatus function returned status structure with rx_parity_error flag 0
2139 - Assert that GetStatus function returned status structure with reserved field 0
2140 - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
2141 - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
2142 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2143 - Driver is initialized and peripheral is powered-on:
2144 - Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
2145 - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
2146 - Driver is initialized and peripheral is powered-off:
2147 - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
2148 - Call PowerControl(ARM_POWER_LOW) function
2149 - Driver is initialized and peripheral is powered-on or in low-power mode:
2150 - Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
2151 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2152 - Driver is initialized and peripheral is powered-on:
2153 - Call Control function and assert that it returned ARM_DRIVER_OK status
2154 - Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_OK status<br>
2155 (this must unconditionally terminate active send/receive/transfer and power-off the peripheral)
2156 - Driver is initialized and peripheral is powered-off:
2157 - Call GetStatus function
2158 - Assert that GetStatus function returned status structure with tx_busy flag 0
2159 - Assert that GetStatus function returned status structure with rx_busy flag 0
2161 void USART_PowerControl (void) {
2163 ARM_USART_STATUS stat;
2165 (void)drv->Initialize (NULL);
2167 // Driver is initialized and peripheral is powered-off:
2168 // Call Send function and assert that it returned ARM_DRIVER_ERROR status
2169 TEST_ASSERT(drv->Send (ptr_tx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2171 // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
2172 TEST_ASSERT(drv->Receive (ptr_rx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2174 // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
2175 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2177 // Call Control function and assert that it returned ARM_DRIVER_ERROR status
2178 TEST_ASSERT(drv->Control (((USART_CFG_DEF_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
2179 ((USART_CFG_DEF_CPOL << ARM_USART_CPOL_Pos) & ARM_USART_CPOL_Msk) |
2180 ((USART_CFG_DEF_CPHA << ARM_USART_CPHA_Pos) & ARM_USART_CPHA_Msk) |
2181 ARM_USART_DATA_BITS_8, USART_CFG_DEF_BAUDRATE) == ARM_DRIVER_ERROR);
2183 // Call GetStatus function
2184 stat = drv->GetStatus();
2186 // Assert that GetStatus function returned status structure with tx_busy flag 0
2187 TEST_ASSERT(stat.tx_busy == 0U);
2189 // Assert that GetStatus function returned status structure with rx_busy flag 0
2190 TEST_ASSERT(stat.rx_busy == 0U);
2192 // Assert that GetStatus function returned status structure with tx_underflow flag 0
2193 TEST_ASSERT(stat.tx_underflow == 0U);
2195 // Assert that GetStatus function returned status structure with rx_overflow flag 0
2196 TEST_ASSERT(stat.rx_overflow == 0U);
2198 // Assert that GetStatus function returned status structure with rx_break flag 0
2199 TEST_ASSERT(stat.rx_break == 0U);
2201 // Assert that GetStatus function returned status structure with rx_framing_error flag 0
2202 TEST_ASSERT(stat.rx_framing_error == 0U);
2204 // Assert that GetStatus function returned status structure with rx_parity_error flag 0
2205 TEST_ASSERT(stat.rx_parity_error == 0U);
2207 // Assert that GetStatus function returned status structure with reserved field 0
2208 TEST_ASSERT(stat.reserved == 0U);
2210 // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
2211 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2213 // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
2214 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2216 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2217 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
2219 // Driver is initialized and peripheral is powered-on:
2220 // Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
2221 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
2223 // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
2224 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2226 // Driver is initialized and peripheral is powered-off:
2227 // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
2228 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2230 // Call PowerControl(ARM_POWER_LOW) function
2231 ret = drv->PowerControl (ARM_POWER_LOW);
2233 // Driver is initialized and peripheral is powered-on or in low-power mode:
2234 // Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
2235 TEST_ASSERT((ret == ARM_DRIVER_OK) || (ret == ARM_DRIVER_ERROR_UNSUPPORTED));
2236 if (ret == ARM_DRIVER_ERROR_UNSUPPORTED) {
2237 TEST_MESSAGE("[WARNING] PowerControl (ARM_POWER_LOW) is not supported");
2240 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2241 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
2243 // Driver is initialized and peripheral is powered-on:
2244 // Call Control function and assert that it returned ARM_DRIVER_OK status
2245 TEST_ASSERT(drv->Control (((USART_CFG_DEF_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
2246 ((USART_CFG_DEF_CPOL << ARM_USART_CPOL_Pos) & ARM_USART_CPOL_Msk) |
2247 ((USART_CFG_DEF_CPHA << ARM_USART_CPHA_Pos) & ARM_USART_CPHA_Msk) |
2248 ARM_USART_DATA_BITS_8, USART_CFG_DEF_BAUDRATE) == ARM_DRIVER_OK);
2250 // Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_OK status
2251 // (this must unconditionally terminate active send/receive/transfer and power-off the peripheral)
2252 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2254 // Driver is initialized and peripheral is powered-off:
2255 // Call GetStatus function
2256 stat = drv->GetStatus();
2258 // Assert that GetStatus function returned status structure with tx_busy flag 0
2259 TEST_ASSERT(stat.tx_busy == 0U);
2261 // Assert that GetStatus function returned status structure with rx_busy flag 0
2262 TEST_ASSERT(stat.rx_busy == 0U);
2264 (void)drv->Uninitialize ();
2270 // End of usart_tests_drv_mgmt
2272 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2273 /* USART Data Exchange tests */
2274 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2276 \defgroup usart_tests_data_xchg Data Exchange
2277 \ingroup usart_tests
2279 These tests verify API and operation of the USART data exchange functions.
2281 The data exchange tests verify the following driver functions
2282 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html" target="_blank">USART Driver function documentation</a>):
2285 int32_t Send (const void *data, uint32_t num);
2289 int32_t Receive ( void *data, uint32_t num);
2293 int32_t Transfer (const void *data_out, void *data_in, uint32_t num);
2297 uint32_t GetTxCount (void);
2301 uint32_t GetRxCount (void);
2305 int32_t Control (uint32_t control, uint32_t arg);
2309 ARM_USART_STATUS GetStatus (void);
2313 void (*ARM_USART_SignalEvent_t) (uint32_t event);
2316 All of these tests execute a data exchange and check the result of this data exchange.
2318 Data exchange test procedure when Test Mode <b>USART Server</b> is selected:
2319 - send command "SET BUF TX,.." to the USART Server: Set Tx buffer
2320 - send command "SET BUF RX,.." to the USART Server: Set Rx buffer
2321 - send command "SET COM .." to the USART Server: Set communication settings for the next XFER command
2322 - send command "XFER .." to the USART Server: Specify transfer
2323 - driver Control: Configure the USART interface
2324 - driver Control: Set the default Tx value (in synchronous mode only)
2325 - driver Send/Receive/Transfer: Start the requested operation
2326 - driver GetStatus/SignalEvent: Wait for the current operation to finish or time-out<br>
2327 (operation is finished when appropriate tx_busy or rx_busy flag is 0 and send/receive/transfer completed event was signaled)
2328 - assert that operation has finished in expected time
2329 - assert that appropriate ARM_USART_EVENT_SEND_COMPLETE, ARM_USART_EVENT_RECEIVE_COMPLETE
2330 or ARM_USART_EVENT_TRANSFER_COMPLETE event was signaled
2331 - driver GetStatus: Assert that appropriate tx_busy or rx_busy flag is 0
2332 - driver GetTxCount: If it was a send or transfer operation assert that number of transmitted items is same as requested
2333 - driver GetRxCount: If it was a receive or transfer operation assert that number of received items is same as requested
2334 - if operation has timed out call driver Control function to Abort operation and wait timeout time<br>
2335 to make sure that the USART Server is ready for the next command
2336 - assert that received content is as expected
2337 - send command "GET BUF RX,.." to the USART Server: Get Rx buffer
2338 - assert that sent content (read from the USART Server's receive buffer) is as expected
2340 Data exchange <b>Abort</b> test procedure when Test Mode <b>USART Server</b> is selected:
2341 - send command "SET BUF TX,.." to the USART Server: Set Tx buffer
2342 - send command "SET BUF RX,.." to the USART Server: Set Rx buffer
2343 - send command "SET COM .." to the USART Server: Set communication settings for the next XFER command
2344 - send command "XFER .." to the USART Server: Specify transfer
2345 - driver Control: Configure the USART interface
2346 - driver Control: Set the default Tx value (in synchronous mode only)
2347 - driver Send/Receive/Transfer: Start the requested operation
2349 - driver Control: Abort the current operation
2350 - driver GetStatus: Assert that appropriate tx_busy or rx_busy flag is 0
2351 - driver GetTxCount: If it was a send or transfer operation assert that number of transmitted items is less than requested
2352 - driver GetRxCount: If it was a receive or transfer operation assert that number of received items is less than requested
2354 Data exchange test procedure when Test Mode <b>Loopback</b> is selected:
2355 - driver Control: Configure the USART interface
2356 - driver Control: Set the default Tx value (in synchronous mode only)
2357 - driver Send/Receive/Transfer: Start the requested operation
2358 - driver GetStatus/SignalEvent: Wait for the current operation to finish or time-out<br>
2359 (operation is finished when appropriate tx_busy or rx_busy flag is 0 and send/receive/transfer completed event was signaled)
2360 - assert that operation has finished in expected time
2361 - assert that appropriate ARM_USART_EVENT_SEND_COMPLETE and ARM_USART_EVENT_RECEIVE_COMPLETE
2362 or ARM_USART_EVENT_TRANSFER_COMPLETE event was signaled
2363 - driver GetStatus: Assert that appropriate tx_busy or rx_busy flag is 0
2364 - driver GetTxCount: If it was a send and receive or transfer operation assert that number of transmitted items is same as requested
2365 - driver GetRxCount: If it was a send and receive or transfer operation assert that number of received items is same as requested
2366 - if operation has timed out call driver Control function to Abort operation
2367 - assert that sent and received content is same
2369 \note Limitations of Data Exchange tests if Test Mode <b>Loopback</b> is selected:
2370 - in synchronous mode only Master mode transfer can be tested
2371 - only 8 data bit tests are supported
2372 - parity tests are not supported
2373 - stop bits tests are not supported
2374 - flow control tests are not supported
2375 - clock polarity and clock phase tests are not supported
2379 #ifndef __DOXYGEN__ // Exclude form the documentation
2381 \brief Execute USART data exchange or abort operation.
2382 \param[in] operation operation (OP_SEND .. OP_ABORT_TRANSFER)
2383 \param[in] mode mode (MODE_ASYNCHRONOUS .. MODE_SMART_CARD)
2384 \param[in] data_bits data bits (5 .. 9)
2385 \param[in] parity parity (PARITY_NONE, PARITY_EVEN or PARITY_ODD)
2386 \param[in] stop_bits stop bits (STOP_BITS_1 .. STOP_BITS_0_5)
2387 \param[in] flow_control flow control (FLOW_CONTROL_NONE .. FLOW_CONTROL_RTS_CTS)
2388 \param[in] cpol clock polarity (CPOL0 or CPOL1)
2389 \param[in] cpha clock phase (CPHA0 or CPHA1)
2390 \param[in] baudrate baudrate in bauds
2391 \param[in] num number of items to send, receive or transfer
2394 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) {
2395 // volatile specifier is used to prevent compiler from optimizing variables
2396 // in a way that they cannot be seen with debugger
2397 volatile int32_t stat, def_tx_stat;
2398 volatile uint32_t drv_mode, drv_data_bits, drv_parity, drv_stop_bits, drv_flow_control, drv_cpol, drv_cpha;
2399 volatile uint32_t srv_mode, srv_dir, srv_flow_control;
2400 volatile ARM_USART_STATUS usart_stat;
2401 volatile uint32_t tx_count, rx_count;
2403 uint32_t val, delay, i;
2404 volatile uint32_t srv_delay;
2405 volatile uint32_t drv_delay;
2406 uint8_t chk_tx_data, chk_rx_data;
2407 uint32_t timeout, start_tick, curr_tick;
2409 // Prepare parameters for USART Server and Driver configuration
2410 switch (operation & 0x0FU) {
2416 if (mode == MODE_SYNCHRONOUS_MASTER) {
2417 // In Synchronous Master test wait for USART Server to start the trasnsfer
2420 } else if (mode == MODE_SYNCHRONOUS_SLAVE) {
2421 // In Synchronous Slave test make USART Server wait for driver to start the send operation
2427 case OP_ABORT_RECEIVE:
2431 if (mode == MODE_SYNCHRONOUS_MASTER) {
2432 // In Synchronous Master test wait for USART Server to start the trasnsfer
2435 } else if (mode == MODE_SYNCHRONOUS_SLAVE) {
2436 // In Synchronous Slave test make USART Server wait for driver to start the receive operation
2442 case OP_ABORT_TRANSFER:
2444 if (mode == MODE_SYNCHRONOUS_MASTER) {
2445 // In Synchronous Master test wait for USART Server to start the trasnsfer
2448 } else if (mode == MODE_SYNCHRONOUS_SLAVE) {
2449 // In Synchronous Slave test mode make USART Server wait for driver to start the transfer
2453 TEST_FAIL_MESSAGE("[FAILED] Synchronous mode unknown! Data exchange operation aborted!");
2456 case OP_RECEIVE_SEND_LB:
2462 case MODE_ASYNCHRONOUS:
2463 drv_mode = ARM_USART_MODE_ASYNCHRONOUS;
2464 srv_mode = MODE_ASYNCHRONOUS;
2466 case MODE_SYNCHRONOUS_MASTER:
2467 drv_mode = ARM_USART_MODE_SYNCHRONOUS_MASTER;
2468 srv_mode = MODE_SYNCHRONOUS_SLAVE;
2470 case MODE_SYNCHRONOUS_SLAVE:
2471 drv_mode = ARM_USART_MODE_SYNCHRONOUS_SLAVE;
2472 srv_mode = MODE_SYNCHRONOUS_MASTER;
2474 case MODE_SINGLE_WIRE:
2475 drv_mode = ARM_USART_MODE_SINGLE_WIRE;
2476 srv_mode = MODE_SINGLE_WIRE;
2479 drv_mode = ARM_USART_MODE_IRDA;
2480 srv_mode = MODE_IRDA;
2482 case MODE_SMART_CARD:
2483 TEST_FAIL_MESSAGE("[FAILED] Smart Card mode testing not supported! Data exchange operation aborted!");
2486 TEST_FAIL_MESSAGE("[FAILED] Unknown mode! Data exchange operation aborted!");
2490 switch (data_bits) {
2492 drv_data_bits = ARM_USART_DATA_BITS_5;
2495 drv_data_bits = ARM_USART_DATA_BITS_6;
2498 drv_data_bits = ARM_USART_DATA_BITS_7;
2501 drv_data_bits = ARM_USART_DATA_BITS_8;
2504 drv_data_bits = ARM_USART_DATA_BITS_9;
2507 TEST_FAIL_MESSAGE("[FAILED] Data bits not in range 5 to 9! Data exchange operation aborted!");
2513 drv_parity = ARM_USART_PARITY_NONE;
2516 drv_parity = ARM_USART_PARITY_EVEN;
2519 drv_parity = ARM_USART_PARITY_ODD;
2522 TEST_FAIL_MESSAGE("[FAILED] Unknown parity! Data exchange operation aborted!");
2526 switch (stop_bits) {
2528 drv_stop_bits = ARM_USART_STOP_BITS_1;
2531 drv_stop_bits = ARM_USART_STOP_BITS_2;
2534 drv_stop_bits = ARM_USART_STOP_BITS_1_5;
2537 drv_stop_bits = ARM_USART_STOP_BITS_0_5;
2540 TEST_FAIL_MESSAGE("[FAILED] Unknown stop bits! Data exchange operation aborted!");
2544 switch (flow_control) {
2545 case FLOW_CONTROL_NONE:
2546 drv_flow_control = ARM_USART_FLOW_CONTROL_NONE;
2547 srv_flow_control = FLOW_CONTROL_NONE;
2549 case FLOW_CONTROL_CTS:
2550 drv_flow_control = ARM_USART_FLOW_CONTROL_CTS;
2551 srv_flow_control = FLOW_CONTROL_RTS;
2553 case FLOW_CONTROL_RTS:
2554 drv_flow_control = ARM_USART_FLOW_CONTROL_RTS;
2555 srv_flow_control = FLOW_CONTROL_CTS;
2557 case FLOW_CONTROL_RTS_CTS:
2558 drv_flow_control = ARM_USART_FLOW_CONTROL_RTS_CTS;
2559 srv_flow_control = FLOW_CONTROL_RTS_CTS;
2562 TEST_FAIL_MESSAGE("[FAILED] Unknown flow control! Data exchange operation aborted!");
2568 drv_cpol = ARM_USART_CPOL0;
2571 drv_cpol = ARM_USART_CPOL1;
2574 TEST_FAIL_MESSAGE("[FAILED] Unknown clock polarity! Data exchange operation aborted!");
2580 drv_cpha = ARM_USART_CPHA0;
2583 drv_cpha = ARM_USART_CPHA1;
2586 TEST_FAIL_MESSAGE("[FAILED] Unknown clock phase! Data exchange operation aborted!");
2590 // Total transfer timeout (10 ms is overhead before transfer starts)
2591 timeout = USART_CFG_XFER_TIMEOUT + 10U;
2593 // Check that USART status is not busy before starting data exchange test
2594 usart_stat = drv->GetStatus(); // Get USART status
2595 if (usart_stat.tx_busy != 0U) {
2596 // If tx_busy flag is active
2597 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Tx busy active before operation! Data exchange operation aborted!");
2599 TEST_ASSERT_MESSAGE(usart_stat.tx_busy == 0U, msg_buf);
2600 if (usart_stat.rx_busy != 0U) {
2601 // If rx_busy flag is active
2602 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Rx busy active before operation! Data exchange operation aborted!");
2604 TEST_ASSERT_MESSAGE(usart_stat.rx_busy == 0U, msg_buf);
2605 if (usart_stat.tx_busy != 0U) {
2606 return; // If tx busy is active abort data exchange operation
2608 if (usart_stat.rx_busy != 0U) {
2609 return; // If rx busy is active abort data exchange operation
2613 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
2614 if (CmdSetBufTx('S') != EXIT_SUCCESS) { break; }
2615 if (CmdSetBufRx('?') != EXIT_SUCCESS) { break; }
2616 if (CmdSetCom (srv_mode, data_bits, parity, stop_bits, srv_flow_control, cpol, cpha, baudrate) != EXIT_SUCCESS) { break; }
2617 if (CmdXfer (srv_dir, num, srv_delay, USART_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
2618 #else // If Test Mode Loopback is selected
2619 // Remove warnings for unused variables
2622 (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;
4141 volatile int32_t got_baudrate;
4143 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4144 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; }
4146 #if (USART_SERVER_USED == 1)
4147 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);
4148 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);
4150 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);
4153 if (duration != 0xFFFFFFFFU) { // If Transfer finished before timeout
4154 if (duration != 0U) { // If duration of transfer was more than 0 SysTick counts
4155 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;
4156 if ((br < ((USART_CFG_MIN_BAUDRATE * 3) / 4)) ||
4157 (br > USART_CFG_MIN_BAUDRATE)) {
4158 // If measured baudrate is 25% lower, or higher than requested
4159 (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);
4160 TEST_MESSAGE(msg_buf);
4166 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4168 \brief Function: Function USART_Baudrate_Max
4170 The function \b USART_Baudrate_Max verifies data exchange:
4172 - with default data bits
4173 - with default parity
4174 - with default stop bits
4175 - with default flow control
4176 - with default clock polarity
4177 - with default clock phase
4178 - at <b>maximum baudrate</b> (define <c>USART_CFG_MAX_BAUDRATE</c> in DV_USART_Config.h)
4179 - for default number of data items
4181 This test function checks the following requirement:
4182 - measured bus speed for Send operation in Test Mode <b>USART Server</b> or Send/Receive operation in Test Mode <b>Loopback</b>
4183 is not 25% lower, or higher than requested
4185 void USART_Baudrate_Max (void) {
4186 volatile uint64_t br;
4187 volatile int32_t got_baudrate;
4189 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4190 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; }
4192 #if (USART_SERVER_USED == 1)
4193 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);
4194 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);
4196 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);
4199 if (duration != 0xFFFFFFFFU) { // If Transfer finished before timeout
4200 if (duration != 0U) { // If duration of transfer was more than 0 SysTick counts
4201 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;
4202 if ((br < ((USART_CFG_MAX_BAUDRATE * 3) / 4)) ||
4203 (br > USART_CFG_MAX_BAUDRATE)) {
4204 // If measured baudrate is 25% lower, or higher than requested
4205 (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);
4206 TEST_MESSAGE(msg_buf);
4212 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4214 \brief Function: Function USART_Number_Of_Items
4216 The function \b USART_Number_Of_Items verifies data exchange:
4218 - with default data bits
4219 - with default parity
4220 - with default stop bits
4221 - with default flow control
4222 - with default clock polarity
4223 - with default clock phase
4224 - at default baudrate
4225 - for <b>different number of items</b> (defines <c>USART_CFG_NUM1 .. USART_CFG_NUM5</c> in DV_USART_Config.h)
4227 void USART_Number_Of_Items (void) {
4229 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4230 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; }
4232 #if (USART_CFG_NUM1 != 0U)
4233 #if (USART_SERVER_USED == 1)
4234 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);
4235 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);
4237 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);
4241 #if (USART_CFG_NUM2 != 0U)
4242 #if (USART_SERVER_USED == 1)
4243 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);
4244 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);
4246 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);
4250 #if (USART_CFG_NUM3 != 0U)
4251 #if (USART_SERVER_USED == 1)
4252 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);
4253 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);
4255 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);
4259 #if (USART_CFG_NUM4 != 0U)
4260 #if (USART_SERVER_USED == 1)
4261 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);
4262 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);
4264 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);
4268 #if (USART_CFG_NUM5 != 0U)
4269 #if (USART_SERVER_USED == 1)
4270 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);
4271 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);
4273 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);
4278 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4280 \brief Function: Function USART_GetTxCount
4282 The function \b USART_GetTxCount verifies \b GetTxCount function (count changing) during data exchange (Send):
4284 - with default data bits
4285 - with default parity
4286 - with default stop bits
4287 - with default flow control
4288 - with default clock polarity
4289 - with default clock phase
4290 - at default baudrate
4292 void USART_GetTxCount (void) {
4294 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4295 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; }
4297 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);
4298 TEST_ASSERT_MESSAGE((tx_count_sample != 0U) && (tx_count_sample != USART_CFG_DEF_NUM), "[FAILED] GetTxCount was not changing during the Send!");
4301 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4303 \brief Function: Function USART_GetRxCount
4305 The function \b USART_GetRxCount verifies \b GetRxCount function (count changing) during data exchange (Receive):
4307 - with default data bits
4308 - with default parity
4309 - with default stop bits
4310 - with default flow control
4311 - with default clock polarity
4312 - with default clock phase
4313 - at default baudrate
4315 void USART_GetRxCount (void) {
4317 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4318 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; }
4320 #if (USART_SERVER_USED == 1)
4321 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);
4323 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);
4327 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4329 \brief Function: Function USART_GetTxRxCount
4331 The function \b USART_GetTxRxCount verifies \b GetTxCount and \b GetRxCount functions (count changing) during data exchange (Transfer):
4333 - with default data bits
4336 - with no flow control
4337 - with default clock polarity
4338 - with default clock phase
4339 - at default baudrate
4341 \note If Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b> is selected this test is not executed
4343 void USART_GetTxRxCount (void) {
4345 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4346 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4347 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; }
4349 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);
4350 TEST_ASSERT_MESSAGE((tx_count_sample != 0U) && (tx_count_sample != USART_CFG_DEF_NUM), "[FAILED] GetTxCount was not changing during the Transfer!");
4351 TEST_ASSERT_MESSAGE((rx_count_sample != 0U) && (rx_count_sample != USART_CFG_DEF_NUM), "[FAILED] GetRxCount was not changing during the Transfer!");
4354 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4356 \brief Function: Function USART_AbortSend
4358 The function \b USART_AbortSend verifies \b Abort function abort of data exchange (Send):
4360 - with default data bits
4361 - with default parity
4362 - with default stop bits
4363 - with default flow control
4364 - at default baudrate
4366 void USART_AbortSend (void) {
4368 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4369 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; }
4371 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);
4374 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4376 \brief Function: Function USART_AbortReceive
4378 The function \b USART_AbortReceive verifies \b Abort function abort of data exchange (Receive):
4380 - with default data bits
4381 - with default parity
4382 - with default stop bits
4383 - with default flow control
4384 - with default clock polarity
4385 - with default clock phase
4386 - at default baudrate
4388 void USART_AbortReceive (void) {
4390 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4391 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; }
4393 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);
4396 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4398 \brief Function: Function USART_AbortTransfer
4400 The function \b USART_AbortTransfer verifies \b Abort function abort of data exchange (Transfer):
4402 - with default data bits
4405 - with no flow control
4406 - with default clock polarity
4407 - with default clock phase
4408 - at default baudrate
4410 \note If Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b> is selected this test is not executed
4412 void USART_AbortTransfer (void) {
4414 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4415 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4416 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; }
4418 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);
4421 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4423 \brief Function: Function USART_TxBreak
4425 The function \b USART_TxBreak verifies Break signaling:
4427 - with default data bits
4428 - with default parity
4429 - with default stop bits
4430 - with no flow control
4431 - at default baudrate
4433 \note This test is not executed if any of the following settings are selected:
4434 - Test Mode <b>Loopback</b>
4435 - Tests Default Mode <b>Synchronous Master/Slave</b>
4437 void USART_TxBreak (void) {
4439 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4440 #if (USART_SERVER_USED == 1)
4441 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4442 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4443 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; }
4446 // Dummy read break status to clear it
4447 if (CmdGetBrk() != EXIT_SUCCESS) { break; }
4449 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4450 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; }
4452 // Instruct USART Server to receive data so it can detect Break
4453 if (CmdXfer (1U, USART_CFG_DEF_NUM, 0U, USART_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
4455 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4456 USART_CFG_DEF_DATA_BITS_VAL |
4457 USART_CFG_DEF_PARITY_VAL |
4458 USART_CFG_DEF_STOP_BITS_VAL |
4459 ARM_USART_FLOW_CONTROL_NONE ,
4460 USART_CFG_DEF_BAUDRATE);
4464 (void)osDelay(10U); // Wait for USART Server to start reception
4466 (void)drv->Control(ARM_USART_CONTROL_TX, 1U);
4469 TEST_ASSERT(drv->Control(ARM_USART_CONTROL_BREAK, 1U) == ARM_DRIVER_OK);
4471 TEST_ASSERT(drv->Control(ARM_USART_CONTROL_BREAK, 0U) == ARM_DRIVER_OK);
4474 (void)drv->Control(ARM_USART_CONTROL_TX, 0U);
4476 (void)osDelay(USART_CFG_XFER_TIMEOUT + 10U); // Wait for USART Server to timeout the XFER command
4478 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4479 if (CmdGetBrk() != EXIT_SUCCESS) { break; }
4480 TEST_ASSERT_MESSAGE(break_status == 1U, "[FAILED] Break was not detected on USART Server!");
4482 (void)osDelay(10U); // Wait for USART Server to prepare for reception of new command
4492 // End of usart_tests_data_xchg
4494 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4495 /* USART Modem Lines tests */
4496 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4498 \defgroup usart_tests_modem Modem Lines
4499 \ingroup usart_tests
4501 These tests verify API and operation of the USART modem lines handling functions.
4503 The data exchange tests verify the following driver functions
4504 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html" target="_blank">USART Driver function documentation</a>):
4505 - \b SetModemControl
4507 int32_t SetModemControl (ARM_USART_MODEM_CONTROL control);
4511 ARM_USART_MODEM_STATUS GetModemStatus (void);
4514 \note These tests are not executed if any of the following settings are selected:
4515 - Test Mode <b>Loopback</b>
4516 - Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b>
4520 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4522 \brief Function: Function USART_Modem_RTS
4524 The function \b USART_Modem_RTS verifies driving of modem line Request To Send (RTS):
4526 - with default data bits
4527 - with default parity
4528 - with default stop bits
4529 - with no flow control
4530 - at default baudrate
4532 void USART_Modem_RTS (void) {
4534 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4535 #if (USART_SERVER_USED == 1)
4536 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4537 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4538 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4539 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; }
4542 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4544 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4545 USART_CFG_DEF_DATA_BITS_VAL |
4546 USART_CFG_DEF_PARITY_VAL |
4547 USART_CFG_DEF_STOP_BITS_VAL |
4548 ARM_USART_FLOW_CONTROL_NONE ,
4549 USART_CFG_DEF_BAUDRATE);
4551 TEST_ASSERT(drv->SetModemControl(ARM_USART_RTS_CLEAR) == ARM_DRIVER_OK);
4554 if (CmdGetMdm() != EXIT_SUCCESS) { break; }
4556 TEST_ASSERT_MESSAGE((modem_status & 0x1U) == 0x0U, "[FAILED] CTS line on USART Server is not in inactive state!");
4558 TEST_ASSERT(drv->SetModemControl(ARM_USART_RTS_SET) == ARM_DRIVER_OK);
4561 if (CmdGetMdm() != EXIT_SUCCESS) { break; }
4563 TEST_ASSERT_MESSAGE((modem_status & 0x1U) == 0x1U, "[FAILED] CTS line on USART Server is not in active state!");
4565 (void)drv->SetModemControl(ARM_USART_RTS_CLEAR);
4567 // Give USART Server 10 ms to prepare for reception of the next command
4575 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4577 \brief Function: Function USART_Modem_DTR
4579 The function \b USART_Modem_DTR verifies driving of modem line Data Terminal Ready (DTR):
4581 - with default data bits
4582 - with default parity
4583 - with default stop bits
4584 - with no flow control
4585 - at default baudrate
4587 void USART_Modem_DTR (void) {
4589 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4590 #if (USART_SERVER_USED == 1)
4591 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4592 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4593 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4594 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; }
4597 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4599 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4600 USART_CFG_DEF_DATA_BITS_VAL |
4601 USART_CFG_DEF_PARITY_VAL |
4602 USART_CFG_DEF_STOP_BITS_VAL |
4603 ARM_USART_FLOW_CONTROL_NONE ,
4604 USART_CFG_DEF_BAUDRATE);
4606 TEST_ASSERT(drv->SetModemControl(ARM_USART_DTR_CLEAR) == ARM_DRIVER_OK);
4609 if (CmdGetMdm() != EXIT_SUCCESS) { break; }
4611 TEST_ASSERT_MESSAGE((modem_status & 0x2U) == 0x0U, "[FAILED] DSR line on USART Server is not in inactive state!");
4613 TEST_ASSERT(drv->SetModemControl(ARM_USART_DTR_SET) == ARM_DRIVER_OK);
4616 if (CmdGetMdm() != EXIT_SUCCESS) { break; }
4618 TEST_ASSERT_MESSAGE((modem_status & 0x2U) == 0x2U, "[FAILED] DSR line on USART Server is not in active state!");
4620 (void)drv->SetModemControl(ARM_USART_DTR_CLEAR);
4622 // Give USART Server 10 ms to prepare for reception of the next command
4630 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4632 \brief Function: Function USART_Modem_CTS
4634 The function \b USART_Modem_CTS verifies read of modem line Clear To Send (CTS):
4636 - with default data bits
4637 - with default parity
4638 - with default stop bits
4639 - with no flow control
4640 - at default baudrate
4642 void USART_Modem_CTS (void) {
4644 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4645 #if (USART_SERVER_USED == 1)
4646 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4647 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4648 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4649 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; }
4652 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4654 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4655 USART_CFG_DEF_DATA_BITS_VAL |
4656 USART_CFG_DEF_PARITY_VAL |
4657 USART_CFG_DEF_STOP_BITS_VAL |
4658 ARM_USART_FLOW_CONTROL_NONE ,
4659 USART_CFG_DEF_BAUDRATE);
4661 // Instruct USART Server to drive RTS to active state for 20 ms
4662 // RTS line from USART Server should be connected to CTS line on the USART Client (DUT)
4663 if (CmdSetMdm(RTS_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
4667 TEST_ASSERT_MESSAGE(drv->GetModemStatus().cts == 1U, "[FAILED] CTS line not active!");
4669 // Give USART Server 20 ms to finish SET MDM command and prepare for reception of the next command
4677 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4679 \brief Function: Function USART_Modem_DSR
4681 The function \b USART_Modem_DSR verifies read of modem line Data Set Ready (DSR):
4683 - with default data bits
4684 - with default parity
4685 - with default stop bits
4686 - with no flow control
4687 - at default baudrate
4689 void USART_Modem_DSR (void) {
4691 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4692 #if (USART_SERVER_USED == 1)
4693 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4694 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4695 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4696 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; }
4699 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4701 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4702 USART_CFG_DEF_DATA_BITS_VAL |
4703 USART_CFG_DEF_PARITY_VAL |
4704 USART_CFG_DEF_STOP_BITS_VAL |
4705 ARM_USART_FLOW_CONTROL_NONE ,
4706 USART_CFG_DEF_BAUDRATE);
4708 // Instruct USART Server to drive DTR to active state for 20 ms
4709 // DTR line from USART Server should be connected to DSR line on the USART Client (DUT)
4710 if (CmdSetMdm(DTR_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
4714 TEST_ASSERT_MESSAGE(drv->GetModemStatus().dsr == 1U, "[FAILED] DSR line not active!");
4716 // Give USART Server 20 ms to finish SET MDM command and prepare for reception of the next command
4724 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4726 \brief Function: Function USART_Modem_DCD
4728 The function \b USART_Modem_DCD verifies read of modem line Data Carrier Detect (DCD):
4730 - with default data bits
4731 - with default parity
4732 - with default stop bits
4733 - with no flow control
4734 - at default baudrate
4736 void USART_Modem_DCD (void) {
4738 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4739 #if (USART_SERVER_USED == 1)
4740 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4741 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4742 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4743 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; }
4746 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4748 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4749 USART_CFG_DEF_DATA_BITS_VAL |
4750 USART_CFG_DEF_PARITY_VAL |
4751 USART_CFG_DEF_STOP_BITS_VAL |
4752 ARM_USART_FLOW_CONTROL_NONE ,
4753 USART_CFG_DEF_BAUDRATE);
4755 // Instruct USART Server to drive DTR to active state for 20 ms
4756 if (CmdSetMdm(TO_DCD_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
4760 TEST_ASSERT_MESSAGE(drv->GetModemStatus().dcd == 1U, "[FAILED] DCD line not active!");
4762 // Give USART Server 20 ms to finish SET MDM command and prepare for reception of the next command
4770 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4772 \brief Function: Function USART_Modem_RI
4774 The function \b USART_Modem_RI verifies read of modem line Ring Indicator (RI):
4776 - with default data bits
4777 - with default parity
4778 - with default stop bits
4779 - with no flow control
4780 - at default baudrate
4782 void USART_Modem_RI (void) {
4784 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4785 #if (USART_SERVER_USED == 1)
4786 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4787 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4788 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4789 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; }
4792 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4794 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4795 USART_CFG_DEF_DATA_BITS_VAL |
4796 USART_CFG_DEF_PARITY_VAL |
4797 USART_CFG_DEF_STOP_BITS_VAL |
4798 ARM_USART_FLOW_CONTROL_NONE ,
4799 USART_CFG_DEF_BAUDRATE);
4801 // Instruct USART Server to drive RI to active state for 20 ms
4802 if (CmdSetMdm(TO_RI_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
4806 TEST_ASSERT_MESSAGE(drv->GetModemStatus().ri == 1U, "[FAILED] RI line not active!");
4808 // Give USART Server 20 ms to finish SET MDM command and prepare for reception of the next command
4819 // End of usart_tests_modem
4821 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4822 /* USART Event tests */
4823 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4825 \defgroup usart_tests_evt Event
4826 \ingroup usart_tests
4828 These tests verify API and operation of the USART event signaling, except ARM_USART_EVENT_SEND_COMPLETE,
4829 ARM_USART_EVENT_RECEIVE_COMPLETE, ARM_USART_EVENT_TRANSFER_COMPLETE and ARM_USART_EVENT_TX_COMPLETE signals
4830 which is tested in the Data Exchange tests.
4832 The event tests verify the following driver function
4833 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html" target="_blank">USART Driver function documentation</a>):
4836 void (*ARM_USART_SignalEvent_t) (uint32_t event);
4839 \note In Test Mode <b>Loopback</b> these tests are skipped
4843 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4845 \brief Function: Function USART_Tx_Underflow
4847 The function \b USART_Tx_Underflow verifies signaling of the <b>ARM_USART_EVENT_TX_UNDERFLOW</b> event:
4849 - with default data bits
4850 - with default parity
4851 - with default stop bits
4852 - with default flow control
4853 - at default baudrate
4855 it also checks that status tx_underflow flag was activated.
4857 \note If Tests Default Mode <b>Asynchronous/Synchronous Master/Single-wire/IrDA</b> is selected this test is not executed
4859 void USART_Tx_Underflow (void) {
4861 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4862 #if (USART_SERVER_USED == 1)
4863 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4864 if (IsNotSyncMaster() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4865 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4866 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; }
4869 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4870 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; }
4871 if (CmdXfer (0U, 1U, 10U, 20U, 0U) != EXIT_SUCCESS) { break; }
4873 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4874 USART_CFG_DEF_DATA_BITS_VAL |
4875 USART_CFG_DEF_PARITY_VAL |
4876 USART_CFG_DEF_STOP_BITS_VAL |
4877 USART_CFG_DEF_FLOW_CONTROL_VAL |
4878 USART_CFG_DEF_CPOL_VAL |
4879 USART_CFG_DEF_CPHA_VAL ,
4880 USART_CFG_DEF_BAUDRATE);
4884 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
4886 (void)osDelay(30U); // Wait for USART Server to timeout
4888 // Assert that event ARM_USART_EVENT_TX_UNDERFLOW was signaled
4889 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_TX_UNDERFLOW) != 0U, "[FAILED] Event ARM_USART_EVENT_TX_UNDERFLOW was not signaled!");
4891 // Assert that status rx_overflow flag is active
4892 TEST_ASSERT_MESSAGE(drv->GetStatus().tx_underflow != 0U, "[FAILED] Status tx_underflow flag was not activated!");
4894 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
4896 // Give USART Server 10 ms to prepare for reception of the next command
4904 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4906 \brief Function: Function USART_Rx_Overflow
4908 The function \b USART_Rx_Overflow verifies signaling of the <b>ARM_USART_EVENT_RX_OVERFLOW</b> event:
4910 - with default data bits
4911 - with default parity
4912 - with default stop bits
4913 - with default flow control
4914 - at default baudrate
4916 it also checks that status rx_overflow flag was activated.
4918 \note If Tests Default Mode <b>Synchronous Master</b> is selected this test is not executed
4920 void USART_Rx_Overflow (void) {
4922 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4923 #if (USART_SERVER_USED == 1)
4924 if (IsNotSyncMaster() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4925 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4926 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; }
4929 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4930 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; }
4931 if (CmdXfer (0U, 1U, 10U, 20U, 0U) != EXIT_SUCCESS) { break; }
4933 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4934 USART_CFG_DEF_DATA_BITS_VAL |
4935 USART_CFG_DEF_PARITY_VAL |
4936 USART_CFG_DEF_STOP_BITS_VAL |
4937 USART_CFG_DEF_FLOW_CONTROL_VAL |
4938 USART_CFG_DEF_CPOL_VAL |
4939 USART_CFG_DEF_CPHA_VAL ,
4940 USART_CFG_DEF_BAUDRATE);
4944 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
4946 (void)osDelay(30U); // Wait for USART Server to timeout
4948 // Assert that event ARM_USART_EVENT_RX_OVERFLOW was signaled
4949 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_OVERFLOW) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_OVERFLOW was not signaled!");
4951 // Assert that status rx_overflow flag is active
4952 TEST_ASSERT_MESSAGE(drv->GetStatus().rx_overflow != 0U, "[FAILED] Status rx_overflow flag was not activated!");
4954 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
4956 // Give USART Server 10 ms to prepare for reception of the next command
4964 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4966 \brief Function: Function USART_Rx_Timeout
4968 The function \b USART_Rx_Timeout verifies signaling of the <b>ARM_USART_EVENT_RX_TIMEOUT</b> event:
4970 - with default data bits
4971 - with default parity
4972 - with default stop bits
4973 - with default flow control
4974 - at default baudrate
4976 \note If Tests Default Mode <b>Synchronous Master/Slave</b> is selected this test is not executed
4978 void USART_Rx_Timeout (void) {
4980 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4981 #if (USART_SERVER_USED == 1)
4982 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4983 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4984 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; }
4987 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4988 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; }
4989 if (CmdXfer (0U, 1U, 10U, 10U, 0U) != EXIT_SUCCESS) { break; }
4991 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4992 USART_CFG_DEF_DATA_BITS_VAL |
4993 USART_CFG_DEF_PARITY_VAL |
4994 USART_CFG_DEF_STOP_BITS_VAL |
4995 USART_CFG_DEF_FLOW_CONTROL_VAL |
4996 USART_CFG_DEF_CPOL_VAL |
4997 USART_CFG_DEF_CPHA_VAL ,
4998 USART_CFG_DEF_BAUDRATE);
5002 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
5003 (void)drv->Receive(ptr_rx_buf, 2U);
5005 (void)osDelay(30U); // Wait for USART Server to timeout
5007 // Assert that event ARM_USART_EVENT_RX_TIMEOUT was signaled
5008 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_TIMEOUT) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_TIMEOUT was not signaled!");
5010 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
5011 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
5013 // Give USART Server 10 ms to prepare for reception of the next command
5021 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5023 \brief Function: Function USART_Rx_Break
5025 The function \b USART_Rx_Break verifies signaling of the <b>ARM_USART_EVENT_RX_BREAK</b> event:
5027 - with default data bits
5028 - with default parity
5029 - with default stop bits
5030 - with default flow control
5031 - at default baudrate
5033 it also checks that status rx_break flag was activated.
5035 \note If Tests Default Mode <b>Synchronous Master/Slave</b> is selected this test is not executed
5037 void USART_Rx_Break (void) {
5039 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5040 #if (USART_SERVER_USED == 1)
5041 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5042 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5043 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; }
5046 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5048 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5049 USART_CFG_DEF_DATA_BITS_VAL |
5050 USART_CFG_DEF_PARITY_VAL |
5051 USART_CFG_DEF_STOP_BITS_VAL |
5052 USART_CFG_DEF_FLOW_CONTROL_VAL |
5053 USART_CFG_DEF_CPOL_VAL |
5054 USART_CFG_DEF_CPHA_VAL ,
5055 USART_CFG_DEF_BAUDRATE);
5057 // Instruct USART Server to signal Break for 20 ms
5058 if (CmdSetBrk(10U, 20U) != EXIT_SUCCESS) { break; }
5060 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
5061 (void)drv->Receive(ptr_rx_buf, 1U);
5063 // This test allows break detection for continuous mode as well
5064 // as LIN variant (return to inactive after 10/11 bits)
5067 // Assert that event ARM_USART_EVENT_RX_BREAK was signaled
5068 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_BREAK) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_BREAK was not signaled!");
5070 // Assert that status rx_break flag is active
5071 TEST_ASSERT_MESSAGE(drv->GetStatus().rx_break != 0U, "[FAILED] Status rx_break flag was not activated!");
5073 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
5074 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
5076 // Give USART Server 10 ms to prepare for reception of the next command
5084 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5086 \brief Function: Function USART_Rx_Framing_Error
5088 The function \b USART_Rx_Framing_Error verifies signaling of the <b>ARM_USART_EVENT_RX_FRAMING_ERROR</b> event:
5090 - with default data bits
5091 - with default parity
5092 - with default stop bits
5093 - with default flow control
5094 - at default baudrate
5096 it also checks that status rx_framing_error flag was activated.
5098 \note If Tests Default Mode <b>Synchronous Master/Slave</b> is selected this test is not executed
5100 void USART_Rx_Framing_Error (void) {
5102 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5103 #if (USART_SERVER_USED == 1)
5104 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5105 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5106 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; }
5109 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5111 // We test framing error by adding parity bit if it is not set as default setting,
5112 // or removing parity bit if it is set as default setting
5113 if (USART_CFG_DEF_PARITY == PARITY_NONE) {
5114 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; }
5116 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; }
5118 if (CmdXfer (0U, 1U, 10U, 20U, 0U) != EXIT_SUCCESS) { break; }
5120 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5121 USART_CFG_DEF_DATA_BITS_VAL |
5122 USART_CFG_DEF_PARITY_VAL |
5123 USART_CFG_DEF_STOP_BITS_VAL |
5124 USART_CFG_DEF_FLOW_CONTROL_VAL |
5125 USART_CFG_DEF_CPOL_VAL |
5126 USART_CFG_DEF_CPHA_VAL ,
5127 USART_CFG_DEF_BAUDRATE);
5131 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
5132 (void)drv->Receive(ptr_rx_buf, 1U);
5134 (void)osDelay(30U); // Wait for USART Server to timeout
5136 // Assert that event ARM_USART_EVENT_RX_FRAMING_ERROR was signaled
5137 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_FRAMING_ERROR) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_FRAMING_ERROR was not signaled!");
5139 // Assert that status rx_framing_error flag is active
5140 TEST_ASSERT_MESSAGE(drv->GetStatus().rx_framing_error != 0U, "[FAILED] Status rx_framing_error flag was not activated!");
5142 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
5143 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
5145 // Give USART Server 10 ms to prepare for reception of the next command
5153 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5155 \brief Function: Function USART_Rx_Parity_Error
5157 The function \b USART_Rx_Parity_Error verifies signaling of the <b>ARM_USART_EVENT_RX_PARITY_ERROR</b> event:
5159 - with default data bits
5160 - with default parity
5161 - with default stop bits
5162 - with default flow control
5163 - at default baudrate
5165 it also checks that status rx_parity_error flag was activated.
5167 \note If Tests Default Mode <b>Synchronous Master/Slave</b> is selected this test is not executed
5169 void USART_Rx_Parity_Error (void) {
5171 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5172 #if (USART_SERVER_USED == 1)
5173 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5174 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5175 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; }
5178 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5180 // We test parity error by requesting USART Server to send an item at ODD parity
5181 // and configure USART Client to receive with EVEN parity
5182 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; }
5184 if (CmdXfer (0U, 1U, 10U, 20U, 0U) != EXIT_SUCCESS) { break; }
5186 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5187 USART_CFG_DEF_DATA_BITS_VAL |
5188 ((PARITY_EVEN << ARM_USART_PARITY_Pos) & ARM_USART_PARITY_Msk) |
5189 USART_CFG_DEF_STOP_BITS_VAL |
5190 USART_CFG_DEF_FLOW_CONTROL_VAL |
5191 USART_CFG_DEF_CPOL_VAL |
5192 USART_CFG_DEF_CPHA_VAL ,
5193 USART_CFG_DEF_BAUDRATE);
5197 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
5198 (void)drv->Receive(ptr_rx_buf, 1U);
5200 (void)osDelay(30U); // Wait for USART Server to timeout
5202 // Assert that event ARM_USART_EVENT_RX_PARITY_ERROR was signaled
5203 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_PARITY_ERROR) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_PARITY_ERROR was not signaled!");
5205 // Assert that status rx_parity_error flag is active
5206 TEST_ASSERT_MESSAGE(drv->GetStatus().rx_parity_error != 0U, "[FAILED] Status rx_parity_error flag was not activated!");
5208 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
5209 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
5211 // Give USART Server 10 ms to prepare for reception of the next command
5219 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5221 \brief Function: Function USART_Event_CTS
5223 The function \b USART_Event_CTS verifies signaling of the <b>ARM_USART_EVENT_CTS</b> event:
5225 - with default data bits
5226 - with default parity
5227 - with default stop bits
5228 - with no flow control
5229 - at default baudrate
5231 \note If Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b> is selected this test is not executed
5233 void USART_Event_CTS (void) {
5235 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5236 #if (USART_SERVER_USED == 1)
5237 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5238 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5239 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5240 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; }
5243 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5245 // Instruct USART Server to drive RTS to active state for 20 ms
5246 // RTS line from USART Server should be connected to CTS line on the USART Client (DUT)
5247 if (CmdSetMdm(RTS_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
5249 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5250 USART_CFG_DEF_DATA_BITS_VAL |
5251 USART_CFG_DEF_PARITY_VAL |
5252 USART_CFG_DEF_STOP_BITS_VAL |
5253 ARM_USART_FLOW_CONTROL_CTS ,
5254 USART_CFG_DEF_BAUDRATE);
5260 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_CTS) == ARM_USART_EVENT_CTS, "[FAILED] CTS line did not register change!");
5269 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5271 \brief Function: Function USART_Event_DSR
5273 The function \b USART_Event_DSR verifies signaling of the <b>ARM_USART_EVENT_DSR</b> event:
5275 - with default data bits
5276 - with default parity
5277 - with default stop bits
5278 - with no flow control
5279 - at default baudrate
5281 \note If Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b> is selected this test is not executed
5283 void USART_Event_DSR (void) {
5285 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5286 #if (USART_SERVER_USED == 1)
5287 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5288 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5289 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5290 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; }
5293 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5295 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5296 USART_CFG_DEF_DATA_BITS_VAL |
5297 USART_CFG_DEF_PARITY_VAL |
5298 USART_CFG_DEF_STOP_BITS_VAL |
5299 ARM_USART_FLOW_CONTROL_NONE ,
5300 USART_CFG_DEF_BAUDRATE);
5304 // Instruct USART Server to drive DTR to active state for 20 ms
5305 // DTR line from USART Server should be connected to DSR line on the USART Client (DUT)
5306 if (CmdSetMdm(DTR_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
5310 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_DSR) == ARM_USART_EVENT_DSR, "[FAILED] DSR line did not register change!");
5319 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5321 \brief Function: Function USART_Event_DCD
5323 The function \b USART_Event_DCD verifies signaling of the <b>ARM_USART_EVENT_DCD</b> event:
5325 - with default data bits
5326 - with default parity
5327 - with default stop bits
5328 - with no flow control
5329 - at default baudrate
5331 \note If Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b> is selected this test is not executed
5333 void USART_Event_DCD (void) {
5335 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5336 #if (USART_SERVER_USED == 1)
5337 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5338 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5339 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5340 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; }
5343 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5345 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5346 USART_CFG_DEF_DATA_BITS_VAL |
5347 USART_CFG_DEF_PARITY_VAL |
5348 USART_CFG_DEF_STOP_BITS_VAL |
5349 ARM_USART_FLOW_CONTROL_NONE ,
5350 USART_CFG_DEF_BAUDRATE);
5354 // Instruct USART Server to drive RTS to active state for 20 ms
5355 if (CmdSetMdm(TO_DCD_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
5359 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_DCD) == ARM_USART_EVENT_DCD, "[FAILED] DCD line did not register change!");
5368 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5370 \brief Function: Function USART_Event_RI
5372 The function \b USART_Event_RI verifies signaling of the <b>ARM_USART_EVENT_RI</b> event:
5374 - with default data bits
5375 - with default parity
5376 - with default stop bits
5377 - with no flow control
5378 - at default baudrate
5380 \note If Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b> is selected this test is not executed
5382 void USART_Event_RI (void) {
5384 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5385 #if (USART_SERVER_USED == 1)
5386 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5387 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5388 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5389 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; }
5392 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5394 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5395 USART_CFG_DEF_DATA_BITS_VAL |
5396 USART_CFG_DEF_PARITY_VAL |
5397 USART_CFG_DEF_STOP_BITS_VAL |
5398 ARM_USART_FLOW_CONTROL_NONE ,
5399 USART_CFG_DEF_BAUDRATE);
5403 // Instruct USART Server to drive RI to active state for 20 ms
5404 if (CmdSetMdm(TO_RI_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
5408 // RI event should be active after RI returns to inactive state (Trailing Edge RI)
5409 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RI) == ARM_USART_EVENT_RI, "[FAILED] RI line did not register change!");
5419 // End of usart_tests_evt