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 IsNotSingleWire (void);
365 static uint32_t DataBitsToBytes (uint32_t data_bits);
366 static int32_t DriverInit (void);
367 static int32_t BuffersCheck (void);
368 static int32_t DriverCheck (uint32_t mode, uint32_t flow_control, uint32_t modem_line_mask);
370 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);
375 \fn void USART_DrvEvent (uint32_t evt)
376 \brief Store event(s) into a global variable.
377 \detail This is a callback function called by the driver upon an event(s).
378 \param[in] evt USART event
381 static void USART_DrvEvent (uint32_t evt) {
384 (void)osEventFlagsSet(event_flags, evt);
388 \fn static uint32_t DataBitsToBytes (uint32_t data_bits)
389 \brief Calculate number of bytes used for an item at required data bits.
390 \return number of bytes per item
392 static uint32_t DataBitsToBytes (uint32_t data_bits) {
396 if (data_bits > 8U) {
404 \fn static int32_t DriverInit (void)
405 \brief Initialize and power-on the driver.
406 \return execution status
407 - EXIT_SUCCESS: Driver initialized and powered-up successfully
408 - EXIT_FAILURE: Driver initialization or power-up failed
410 static int32_t DriverInit (void) {
412 if (drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK) {
413 if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
418 TEST_FAIL_MESSAGE("[FAILED] USART driver initialize or power-up. Check driver Initialize and PowerControl functions! Test aborted!");
424 \fn static int32_t IsNotLoopback (void)
425 \brief Check if loopback is not selected.
426 \detail This function is used to skip executing a test if it is not supported
428 \return execution status
429 - EXIT_SUCCESS: Loopback is not selected
430 - EXIT_FAILURE: Loopback is selected
432 static int32_t IsNotLoopback (void) {
434 #if (USART_SERVER_USED == 1)
437 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test not executed!");
443 \fn static int32_t IsNotSync (void)
444 \brief Check if Synchronous Slave/Master mode is not selected as default mode.
445 \detail This function is used to skip executing a test if it is not supported
447 \return execution status
448 - EXIT_SUCCESS: Synchronous mode is not selected
449 - EXIT_FAILURE: Synchronous mode is selected
451 static int32_t IsNotSync (void) {
453 #if ((USART_CFG_DEF_MODE != MODE_SYNCHRONOUS_MASTER) && (USART_CFG_DEF_MODE != MODE_SYNCHRONOUS_SLAVE))
456 TEST_MESSAGE("[WARNING] Test not supported for Synchronous Mode! Test not executed!");
462 \fn static int32_t IsNotAsync (void)
463 \brief Check if Asynchronous/Single-wire/IrDA modes are not selected as default mode.
464 \detail This function is used to skip executing a test if it is not supported
465 in Asynchronous/Single-wire/IrDA mode.
466 \return execution status
467 - EXIT_SUCCESS: Asynchronous/Single-wire/IrDA mode is not selected
468 - EXIT_FAILURE: Asynchronous/Single-wire/IrDA mode is selected
470 static int32_t IsNotAsync (void) {
472 #if ((USART_CFG_DEF_MODE != MODE_ASYNCHRONOUS) && (USART_CFG_DEF_MODE != MODE_SINGLE_WIRE) && (USART_CFG_DEF_MODE != MODE_IRDA))
475 TEST_MESSAGE("[WARNING] Test not supported for Asynchronous/Single-wire/IrDA Mode! Test not executed!");
481 \fn static int32_t IsNotSingleWire (void)
482 \brief Check if Single-wire mode is not selected as default mode.
483 \detail This function is used to skip executing a test if it is not supported
485 \return execution status
486 - EXIT_SUCCESS: Single-wire mode is not selected
487 - EXIT_FAILURE: Single-wire mode is selected
489 static int32_t IsNotSingleWire (void) {
491 #if (USART_CFG_DEF_MODE != MODE_SINGLE_WIRE)
494 TEST_MESSAGE("[WARNING] Test not supported for Single-wire Mode! Test not executed!");
500 \fn static int32_t BuffersCheck (void)
501 \brief Check if buffers are valid.
502 \return execution status
503 - EXIT_SUCCESS: Buffers are valid
504 - EXIT_FAILURE: Buffers are not valid
506 static int32_t BuffersCheck (void) {
508 if ((ptr_tx_buf != NULL) &&
509 (ptr_rx_buf != NULL) &&
510 (ptr_cmp_buf != NULL)) {
514 TEST_FAIL_MESSAGE("[FAILED] Invalid data buffers! Increase heap memory! Test aborted!");
520 \fn static int32_t DriverCheck (uint32_t mode, uint32_t flow_control, uint32_t modem_line_mask, uint32_t baudrate)
521 \brief Check if USART Driver supports desired settings.
522 \param[in] mode mode:
523 - value 1 = Asynchronous
524 - value 2 = Synchronous Master
525 - value 3 = Synchronous Slave
526 - value 4 = Single Wire
528 - value 6 = Smart Card
529 \param[in] flow_control flow control:
534 \param[in] modem_line_mask modem line mask:
541 \return execution status
542 - EXIT_SUCCESS: USART Driver supports desired settings
543 - EXIT_FAILURE: USART Driver does not support desired settings
545 static int32_t DriverCheck (uint32_t mode, uint32_t flow_control, uint32_t modem_line_mask) {
551 case 1: // Asynchronous
552 if (drv_cap.asynchronous == 0U) {
556 case 2: // Synchronous master
557 if (drv_cap.synchronous_master == 0U) {
561 case 3: // Synchronous slave
562 if (drv_cap.synchronous_slave == 0U) {
566 case 4: // Single-wire
567 if (drv_cap.single_wire == 0U) {
572 if (drv_cap.irda == 0U) {
576 case 6: // Samrt Card
577 if (drv_cap.irda == 0U) {
586 if (ret != EXIT_SUCCESS) {
587 // If USART Driver does not support desired mode
589 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Driver does not support %s mode! Test aborted!", str_mode[mode]);
591 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Driver does not support unknown mode! Test aborted!");
593 TEST_MESSAGE(msg_buf);
597 switch (flow_control) {
601 if (drv_cap.flow_control_cts == 0U) {
606 if (drv_cap.flow_control_rts == 0U) {
611 if ((drv_cap.flow_control_cts == 0U) || (drv_cap.flow_control_rts == 0U)) {
620 if (ret != EXIT_SUCCESS) {
621 // If USART Driver does not support desired flow control
623 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Driver does not support %s flow control! Test aborted!", str_flow_control[flow_control]);
625 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Driver does not support unknown flow control! Test aborted!");
627 TEST_MESSAGE(msg_buf);
631 if ((modem_line_mask & 1U) != 0U) {
632 if (drv_cap.rts == 0U) {
633 TEST_MESSAGE("[FAILED] USART Driver does not support RTS modem line! Test aborted!");
637 if ((modem_line_mask & (1U << 1)) != 0U) {
638 if (drv_cap.cts == 0U) {
639 TEST_MESSAGE("[FAILED] USART Driver does not support CTS modem line! Test aborted!");
643 if ((modem_line_mask & (1U << 2)) != 0U) {
644 if (drv_cap.dtr == 0U) {
645 TEST_MESSAGE("[FAILED] USART Driver does not support DTR modem line! Test aborted!");
649 if ((modem_line_mask & (1U << 3)) != 0U) {
650 if (drv_cap.dsr == 0U) {
651 TEST_MESSAGE("[FAILED] USART Driver does not support DSR modem line! Test aborted!");
655 if ((modem_line_mask & (1U << 4)) != 0U) {
656 if (drv_cap.dcd == 0U) {
657 TEST_MESSAGE("[FAILED] USART Driver does not support DCD modem line! Test aborted!");
661 if ((modem_line_mask & (1U << 5)) != 0U) {
662 if (drv_cap.ri == 0U) {
663 TEST_MESSAGE("[FAILED] USART Driver does not support RI modem line! Test aborted!");
671 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
674 \fn static int32_t ComConfigDefault (void)
675 \brief Configure USART Communication Interface to USART Server default communication configuration.
676 \return execution status
677 - EXIT_SUCCESS: Default configuration set successfully
678 - EXIT_FAILURE: Default configuration failed
680 static int32_t ComConfigDefault (void) {
685 if (drv->Control(((USART_CFG_SRV_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
686 DRIVER_DATA_BITS(USART_CFG_SRV_DATA_BITS) |
687 ((USART_CFG_SRV_PARITY << ARM_USART_PARITY_Pos) & ARM_USART_PARITY_Msk) |
688 ((USART_CFG_SRV_STOP_BITS << ARM_USART_STOP_BITS_Pos) & ARM_USART_STOP_BITS_Msk) |
689 ((USART_CFG_SRV_FLOW_CONTROL << ARM_USART_FLOW_CONTROL_Pos) & ARM_USART_FLOW_CONTROL_Msk) ,
690 USART_CFG_SRV_BAUDRATE) != ARM_DRIVER_OK) {
693 if (drv->Control(ARM_USART_CONTROL_TX, 1U) != ARM_DRIVER_OK) {
697 if (ret != EXIT_SUCCESS) {
698 TEST_FAIL_MESSAGE("[FAILED] Configure communication interface to USART Server default settings. Check driver Control function! Test aborted!");
705 \fn static int32_t ComSendCommand (const void *data_out, uint32_t num)
706 \brief Send command to USART Server.
707 \param[out] data_out Pointer to memory containing data to be sent
708 \param[in] len Number of bytes to be sent
709 \return execution status
710 - EXIT_SUCCESS: Command sent successfully
711 - EXIT_FAILURE: Command send failed
713 static int32_t ComSendCommand (const void *data_out, uint32_t len) {
715 uint32_t flags, num, tout;
718 num = (len + DataBitsToBytes(USART_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(USART_CFG_SRV_DATA_BITS);
720 ret = ComConfigDefault();
722 if (ret == EXIT_SUCCESS) {
723 (void)osEventFlagsClear(event_flags, 0x7FFFFFFFU);
724 if (drv->Control(ARM_USART_CONTROL_TX, 1U) != ARM_DRIVER_OK) {
727 if (ret == EXIT_SUCCESS) {
728 if (drv->Send(data_out, num) != ARM_DRIVER_OK) {
731 if (ret == EXIT_SUCCESS) {
732 if (drv_cap.event_tx_complete != 0U) {
733 // If ARM_USART_EVENT_TX_COMPLETE is supported, wait for it
734 flags = osEventFlagsWait(event_flags, ARM_USART_EVENT_TX_COMPLETE, osFlagsWaitAny, USART_CFG_SRV_CMD_TOUT);
735 if (((flags & 0x80000000U) != 0U) ||
736 ((flags & ARM_USART_EVENT_TX_COMPLETE) == 0U)) {
740 // Otherwise wait for ARM_USART_EVENT_SEND_COMPLETE flag
741 flags = osEventFlagsWait(event_flags, ARM_USART_EVENT_SEND_COMPLETE, osFlagsWaitAny, USART_CFG_SRV_CMD_TOUT);
742 if (((flags & 0x80000000U) != 0U) ||
743 ((flags & ARM_USART_EVENT_SEND_COMPLETE) == 0U)) {
747 if (ret == EXIT_SUCCESS) {
748 // If completed event was signaled, wait for all data to be sent
749 for (tout = USART_CFG_SRV_CMD_TOUT; tout != 0U; tout--) {
750 if ((drv->GetTxCount() == len) && (drv->GetStatus().tx_busy == 0U)) {
758 if (ret == EXIT_FAILURE) {
759 (void)drv->Control(ARM_USART_ABORT_SEND, 0U);
763 (void)drv->Control(ARM_USART_CONTROL_TX, 0U);
769 \fn static int32_t ComReceiveResponse (void *data_in, uint32_t num)
770 \brief Receive response from USART Server.
771 \param[out] data_in Pointer to memory where data will be received
772 \param[in] len Number of data bytes to be received
773 \return execution status
774 - EXIT_SUCCESS: Command received successfully
775 - EXIT_FAILURE: Command reception failed
777 static int32_t ComReceiveResponse (void *data_in, uint32_t len) {
779 uint32_t flags, num, tout;
782 num = (len + DataBitsToBytes(USART_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(USART_CFG_SRV_DATA_BITS);
784 ret = ComConfigDefault();
786 if (ret == EXIT_SUCCESS) {
787 (void)osEventFlagsClear(event_flags, 0x7FFFFFFFU);
788 if (drv->Control(ARM_USART_CONTROL_RX, 1U) != ARM_DRIVER_OK) {
791 if (ret == EXIT_SUCCESS) {
792 if (drv->Receive(data_in, num) != ARM_DRIVER_OK) {
795 if (ret == EXIT_SUCCESS) {
796 flags = osEventFlagsWait(event_flags, ARM_USART_EVENT_RECEIVE_COMPLETE, osFlagsWaitAny, USART_CFG_SRV_CMD_TOUT);
797 if (((flags & 0x80000000U) != 0U) ||
798 ((flags & ARM_USART_EVENT_RECEIVE_COMPLETE) == 0U)) {
802 if (ret == EXIT_FAILURE) {
803 drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
807 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
813 \fn static int32_t CmdGetVer (void)
814 \brief Get version from USART Server and check that it is valid.
815 \return execution status
816 - EXIT_SUCCESS: Version retrieved successfully
817 - EXIT_FAILURE: Version retreival failed
819 static int32_t CmdGetVer (void) {
827 memset(&usart_serv_ver, 0, sizeof(usart_serv_ver));
829 // Send "GET VER" command to USART Server
830 memset(ptr_tx_buf, 0, CMD_LEN);
831 memcpy(ptr_tx_buf, "GET VER", 7);
832 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
834 if (ret == EXIT_SUCCESS) {
835 // Receive response to "GET VER" command from USART Server
836 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_VER_LEN);
837 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_VER_LEN);
842 if (ret == EXIT_SUCCESS) {
844 ptr_str = (const char *)ptr_rx_buf;
845 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
846 usart_serv_ver.major = val8;
851 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
853 ptr_str = strstr(ptr_str, "."); // Find '.'
854 if (ptr_str != NULL) {
855 ptr_str++; // Skip '.'
856 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
857 usart_serv_ver.minor = val8;
865 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
866 // Parse patch (revision)
867 ptr_str = strstr(ptr_str, "."); // Find next '.'
868 if (ptr_str != NULL) {
869 ptr_str++; // Skip '.'
870 if (sscanf(ptr_str, "%hx", &val16) == 1) {
871 usart_serv_ver.patch = val16;
884 \fn static int32_t CmdGetCap (void)
885 \brief Get capabilities from USART Server.
886 \return execution status
887 - EXIT_SUCCESS: Capabilities retrieved successfully
888 - EXIT_FAILURE: Capabilities retreival failed
890 static int32_t CmdGetCap (void) {
898 memset(&usart_serv_cap, 0, sizeof(usart_serv_cap));
900 // Send "GET CAP" command to USART Server
901 memset(ptr_tx_buf, 0, CMD_LEN);
902 memcpy(ptr_tx_buf, "GET CAP", 7);
903 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
905 if (ret == EXIT_SUCCESS) {
906 (void)osDelay(20U); // Give USART Server 20 ms to auto-detect capabilities
908 // Receive response to "GET CAP" command from USART Server
909 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_CAP_LEN);
910 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_CAP_LEN);
914 // Parse capabilities
915 if (ret == EXIT_SUCCESS) {
917 ptr_str = (const char *)ptr_rx_buf;
918 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
919 usart_serv_cap.mode_mask = val8;
924 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
925 // Parse data bit mask
926 ptr_str = strstr(ptr_str, ","); // Find ','
927 if (ptr_str != NULL) {
928 ptr_str++; // Skip ','
929 if (sscanf(ptr_str, "%x", &val32) == 1) {
930 usart_serv_cap.db_mask = val32;
938 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
940 ptr_str = strstr(ptr_str, ","); // Find next ','
941 if (ptr_str != NULL) {
942 ptr_str++; // Skip ','
943 if (sscanf(ptr_str, "%x", &val32) == 1) {
944 usart_serv_cap.parity_mask = val32;
952 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
953 // Parse stop bit mask
954 ptr_str = strstr(ptr_str, ","); // Find next ','
955 if (ptr_str != NULL) {
956 ptr_str++; // Skip ','
957 if (sscanf(ptr_str, "%x", &val32) == 1) {
958 usart_serv_cap.sb_mask = val32;
966 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
967 // Parse flow control mask
968 ptr_str = strstr(ptr_str, ","); // Find next ','
969 if (ptr_str != NULL) {
970 ptr_str++; // Skip ','
971 if (sscanf(ptr_str, "%x", &val32) == 1) {
972 usart_serv_cap.fc_mask = val32;
980 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
981 // Parse modem lines mask
982 ptr_str = strstr(ptr_str, ","); // Find next ','
983 if (ptr_str != NULL) {
984 ptr_str++; // Skip ','
985 if (sscanf(ptr_str, "%x", &val32) == 1) {
986 usart_serv_cap.ml_mask = val32;
994 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
995 // Parse minimum baudrate
996 ptr_str = strstr(ptr_str, ","); // Find next ','
997 if (ptr_str != NULL) {
998 ptr_str++; // Skip ','
999 if (sscanf(ptr_str, "%u", &val32) == 1) {
1000 usart_serv_cap.br_min = val32;
1008 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
1009 // Parse maximum baudrate
1010 ptr_str = strstr(ptr_str, ","); // Find next ','
1011 if (ptr_str != NULL) {
1012 ptr_str++; // Skip ','
1013 if (sscanf(ptr_str, "%u", &val32) == 1) {
1014 usart_serv_cap.br_max = val32;
1027 \fn static int32_t CmdSetBufTx (char pattern)
1028 \brief Set Tx buffer of USART Server to pattern.
1029 \param[in] pattern Pattern to fill the buffer with
1030 \return execution status
1031 - EXIT_SUCCESS: Command sent successfully
1032 - EXIT_FAILURE: Command send failed
1034 static int32_t CmdSetBufTx (char pattern) {
1037 // Send "SET BUF TX" command to USART Server
1038 memset(ptr_tx_buf, 0, CMD_LEN);
1039 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF TX,0,%02X", (int32_t)pattern);
1040 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1043 if (ret != EXIT_SUCCESS) {
1044 TEST_FAIL_MESSAGE("[FAILED] Set Tx buffer on USART Server. Check USART Server! Test aborted!");
1051 \fn static int32_t CmdSetBufRx (char pattern)
1052 \brief Set Rx buffer of USART Server to pattern.
1053 \param[in] pattern Pattern to fill the buffer with
1054 \return execution status
1055 - EXIT_SUCCESS: Command sent successfully
1056 - EXIT_FAILURE: Command send failed
1058 static int32_t CmdSetBufRx (char pattern) {
1061 // Send "SET BUF RX" command to USART Server
1062 memset(ptr_tx_buf, 0, CMD_LEN);
1063 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF RX,0,%02X", (int32_t)pattern);
1064 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1067 if (ret != EXIT_SUCCESS) {
1068 TEST_FAIL_MESSAGE("[FAILED] Set Rx buffer on USART Server. Check USART Server! Test aborted!");
1075 \fn static int32_t CmdGetBufRx (void)
1076 \brief Get Rx buffer from USART Server (into global array pointed to by ptr_rx_buf).
1077 \param[in] len Number of bytes to read from Rx buffer
1078 \return execution status
1079 - EXIT_SUCCESS: Command sent and response received successfully
1080 - EXIT_FAILURE: Command send or response reception failed
1082 static int32_t CmdGetBufRx (uint32_t len) {
1085 // Send "GET BUF RX" command to USART Server
1086 memset(ptr_tx_buf, 0, CMD_LEN);
1087 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "GET BUF RX,%i", len);
1088 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1090 if (ret == EXIT_SUCCESS) {
1091 // Receive response to "GET BUF RX" command from USART Server
1092 memset(ptr_rx_buf, (int32_t)'?', len);
1093 ret = ComReceiveResponse(ptr_rx_buf, len);
1097 if (ret != EXIT_SUCCESS) {
1098 TEST_FAIL_MESSAGE("[FAILED] Get Rx buffer from USART Server. Check USART Server! Test aborted!");
1105 \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)
1106 \brief Set communication parameters on USART Server for next XFER command.
1107 \param[in] mode mode:
1108 - value 0 = Asynchronous
1109 - value 1 = Synchronous Master
1110 - value 2 = Synchronous Slave
1111 - value 3 = Single Wire
1113 - value 5 = Smart Card
1114 \param[in] data_bits data bits:
1116 \param[in] parity parity:
1120 \param[in] stop_bits stop bits:
1121 - value 0 = 1 Stop Bit
1122 - value 1 = 2 Stop Bits
1123 - value 2 = 1.5 Stop Bits
1124 - value 3 = 0.5 Stop Bits
1125 \param[in] flow_control flow control:
1130 \param[in] cpol clock polarity:
1131 - value 0 = Data are captured on rising edge
1132 - value 1 = Data are captured on falling edge
1133 \param[in] cpha clock phase:
1134 - value 0 = Sample on first (leading) edge
1135 - value 1 = Sample on second (trailing) edge
1136 \param[in] baudrate baudrate in bauds
1137 \return execution status
1138 - EXIT_SUCCESS: Command sent successfully
1139 - EXIT_FAILURE: Command send failed
1141 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) {
1144 // Send "SET COM" command to USART Server
1145 memset(ptr_tx_buf, 0, CMD_LEN);
1146 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);
1147 if ((stat > 0) && (stat < CMD_LEN)) {
1148 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1154 if (ret != EXIT_SUCCESS) {
1155 TEST_FAIL_MESSAGE("[FAILED] Set communication settings on USART Server. Check USART Server! Test aborted!");
1162 \fn static int32_t CmdXfer (uint32_t dir, uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_cts)
1163 \brief Activate transfer on USART Server.
1164 \param[in] dir direction of transfer
1167 - 2 = Transfer (simultaneous Tx and Rx (in synchronous mode only))
1168 \param[in] num number of items (according CMSIS USART driver specification)
1169 \param[in] delay initial delay, in milliseconds, before starting requested operation
1170 (0xFFFFFFFF = delay not used)
1171 \param[in] timeout timeout in milliseconds, after delay, if delay is specified
1172 \param[in] num_cts number of items after which CTS line should be de-activated
1173 - 0 = no CTS deactivation
1174 \return execution status
1175 - EXIT_SUCCESS: Command sent successfully
1176 - EXIT_FAILURE: Command send failed
1178 static int32_t CmdXfer (uint32_t dir, uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_cts) {
1181 // Send "XFER" command to USART Server
1182 memset(ptr_tx_buf, 0, CMD_LEN);
1183 if (num_cts != 0U) {
1184 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i,%i,%i", dir, num, delay, timeout, num_cts);
1185 } else if ((delay != osWaitForever) && (timeout != 0U)) {
1186 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i,%i", dir, num, delay, timeout);
1187 } else if (delay != osWaitForever) {
1188 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i", dir, num, delay);
1190 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i", dir, num);
1192 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1194 if (ret != EXIT_SUCCESS) {
1195 TEST_FAIL_MESSAGE("[FAILED] Activate transfer on USART Server. Check USART Server! Test aborted!");
1202 \fn static int32_t CmdGetCnt (void)
1203 \brief Get XFER command Tx/Rx count from USART Server.
1204 \return execution status
1205 - EXIT_SUCCESS: Operation successful
1206 - EXIT_FAILURE: Operation failed
1208 static int32_t CmdGetCnt (void) {
1210 const char *ptr_str;
1215 // Send "GET CNT" command to USART Server
1216 memset(ptr_tx_buf, 0, CMD_LEN);
1217 memcpy(ptr_tx_buf, "GET CNT", 7);
1218 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1220 if (ret == EXIT_SUCCESS) {
1221 // Receive response to "GET CNT" command from USART Server
1222 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_CNT_LEN);
1223 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_CNT_LEN);
1227 if (ret == EXIT_SUCCESS) {
1229 ptr_str = (const char *)ptr_rx_buf;
1230 if (sscanf(ptr_str, "%i", &val32) == 1) {
1237 if (ret != EXIT_SUCCESS) {
1238 TEST_FAIL_MESSAGE("[FAILED] Get count from USART Server. Check USART Server! Test aborted!");
1245 \fn static int32_t CmdSetBrk (uint32_t delay, uint32_t duration)
1246 \brief Request USART Server to send break signal.
1247 \param[in] delay: initial delay, in milliseconds, before start of break signaling
1248 \param[in] duration: duration, in milliseconds, of break signaling
1249 \return execution status
1250 - EXIT_SUCCESS: Command sent successfully
1251 - EXIT_FAILURE: Command send failed
1253 static int32_t CmdSetBrk (uint32_t delay, uint32_t duration) {
1256 // Send "SET BRK" command to USART Server
1257 memset(ptr_tx_buf, 0, CMD_LEN);
1258 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BRK %i,%i", delay, duration);
1259 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1261 if (ret != EXIT_SUCCESS) {
1262 TEST_FAIL_MESSAGE("[FAILED] Set break on USART Server. Check USART Server! Test aborted!");
1269 \fn static int32_t CmdGetBrk (void)
1270 \brief Get information on Break state from USART Server.
1271 \return execution status
1272 - EXIT_SUCCESS: Command sent and response received successfully
1273 - EXIT_FAILURE: Command send or response reception failed
1275 static int32_t CmdGetBrk (void) {
1278 // Send "GET BRK" command to USART Server
1279 memset(ptr_tx_buf, 0, CMD_LEN);
1280 memcpy(ptr_tx_buf, "GET BRK", 7);
1281 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1283 if (ret == EXIT_SUCCESS) {
1284 // Receive response to "GET BRK" command from USART Server
1285 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_BRK_LEN);
1286 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_BRK_LEN);
1290 // Store modem status to global variable
1291 if (ret == EXIT_SUCCESS) {
1292 break_status = ptr_rx_buf[0] - '0';
1295 if (ret != EXIT_SUCCESS) {
1296 TEST_FAIL_MESSAGE("[FAILED] Get break state from USART Server. Check USART Server! Test aborted!");
1303 \fn static int32_t CmdSetMdm (uint32_t mdm_ctrl, uint32_t delay, uint32_t duration)
1304 \brief Set modem lines on USART Server.
1305 \param[in] mdm_ctrl: modem control line states:
1308 - bit 2.: Line to USART Client's DCD state
1309 - bit 3.: Line to USART Client's RI state
1310 \param[in] delay: initial delay, in milliseconds, before start of controlling modem lines
1311 \param[in] duration: duration, in milliseconds, of controlling modem lines
1312 \return execution status
1313 - EXIT_SUCCESS: Command sent successfully
1314 - EXIT_FAILURE: Command send failed
1316 static int32_t CmdSetMdm (uint32_t mdm_ctrl, uint32_t delay, uint32_t duration) {
1319 // Send "SET MDM" command to USART Server
1320 memset(ptr_tx_buf, 0, CMD_LEN);
1321 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET MDM %x,%i,%i", mdm_ctrl, delay, duration);
1322 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1325 if (ret != EXIT_SUCCESS) {
1326 TEST_FAIL_MESSAGE("[FAILED] Set modem control on USART Server. Check USART Server! Test aborted!");
1333 \fn static int32_t CmdGetMdm (void)
1334 \brief Get information on modem lines current state from USART Server.
1335 \return execution status
1336 - EXIT_SUCCESS: Command sent and response received successfully
1337 - EXIT_FAILURE: Command send or response reception failed
1339 static int32_t CmdGetMdm (void) {
1342 // Send "GET MDM" command to USART Server
1343 memset(ptr_tx_buf, 0, CMD_LEN);
1344 memcpy(ptr_tx_buf, "GET MDM", 7);
1345 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
1347 if (ret == EXIT_SUCCESS) {
1348 // Receive response to "GET MDM" command from USART Server
1349 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_MDM_LEN);
1350 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_MDM_LEN);
1354 // Store modem status to global variable
1355 if (ret == EXIT_SUCCESS) {
1356 modem_status = ptr_rx_buf[0] - '0';
1359 if (ret != EXIT_SUCCESS) {
1360 TEST_FAIL_MESSAGE("[FAILED] Get modem lines state from USART Server. Check USART Server! Test aborted!");
1367 \fn static int32_t ServerInit (void)
1368 \brief Initialize communication with USART Server, get version and capabilities.
1369 \return execution status
1370 - EXIT_SUCCESS: USART Server initialized successfully
1371 - EXIT_FAILURE: USART Server initialization failed
1373 static int32_t ServerInit (void) {
1375 if (server_ok == -1) { // If -1, means it was not yet checked
1378 if (drv->Control(((USART_CFG_SRV_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
1379 DRIVER_DATA_BITS(USART_CFG_SRV_DATA_BITS) |
1380 ((USART_CFG_SRV_PARITY << ARM_USART_PARITY_Pos) & ARM_USART_PARITY_Msk) |
1381 ((USART_CFG_SRV_STOP_BITS << ARM_USART_STOP_BITS_Pos) & ARM_USART_STOP_BITS_Msk) |
1382 ((USART_CFG_SRV_FLOW_CONTROL << ARM_USART_FLOW_CONTROL_Pos) & ARM_USART_FLOW_CONTROL_Msk) ,
1383 USART_CFG_SRV_BAUDRATE) != ARM_DRIVER_OK) {
1386 if (server_ok == 0) {
1387 TEST_GROUP_INFO("Failed to configure communication interface to USART Server default settings.\n"\
1388 "Driver must support basic settings used for communication with USART Server!");
1391 if (server_ok == 1) {
1393 if (CmdGetVer() != EXIT_SUCCESS) {
1394 TEST_GROUP_INFO("Failed to Get version from USART Server.\nCheck USART Server!\n");
1399 if (server_ok == 1) {
1400 if (usart_serv_ver.major == 0U) {
1401 TEST_GROUP_INFO("USART Server version must be 1.0.0. or higher.\nUpdate USART Server to newer version!\n");
1406 if (server_ok == 1) {
1407 if (CmdGetCap() != EXIT_SUCCESS) {
1408 TEST_GROUP_INFO("Failed to Get capabilities from USART Server.\nCheck USART Server!\n");
1414 if (server_ok == 1) {
1415 return EXIT_SUCCESS;
1418 return EXIT_FAILURE;
1422 \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)
1423 \brief Check if USART Server is functional and if it supports desired settings.
1424 \detail Parameters describe settings required to test, so server must support complementary sattings.
1425 For example to test RTS line server must support CTS line.
1426 \param[in] mode mode (expected to be tested):
1427 - value 1 = Asynchronous
1428 - value 2 = Synchronous Master
1429 - value 3 = Synchronous Slave
1430 - value 4 = Single Wire
1432 - value 6 = Smart Card
1433 \param[in] data_bits data bits (5 .. 9)
1434 \param[in] parity parity:
1438 \param[in] stop_bits stop bits:
1439 - value 0 = 1 Stop Bit
1440 - value 1 = 2 Stop Bits
1441 - value 2 = 1.5 Stop Bits
1442 - value 3 = 0.5 Stop Bits
1443 \param[in] flow_control flow control:
1448 \param[in] modem_line_mask modem line mask:
1455 \param[in] baudrate baudrate in bauds
1456 \return execution status
1457 - EXIT_SUCCESS: USART Server supports desired settings
1458 - EXIT_FAILURE: USART Server does not support desired settings
1460 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) {
1461 uint32_t srv_mode, srv_flow_control, srv_modem_line_mask;
1463 if (server_ok == 0) {
1464 TEST_FAIL_MESSAGE("[FAILED] USART Server status. Check USART Server! Test aborted!");
1465 return EXIT_FAILURE;
1468 #if (USART_CFG_SRV_MODE == MODE_ASYNCHRONOUS)
1469 if ((mode == MODE_SINGLE_WIRE) || (mode == MODE_IRDA)) {
1470 TEST_MESSAGE("[FAILED] USART Server mode Asynchronous does not support requested test mode! Test aborted!");
1471 return EXIT_FAILURE;
1473 #elif (USART_CFG_SRV_MODE == MODE_SINGLE_WIRE)
1474 if (mode != MODE_SINGLE_WIRE) {
1475 TEST_MESSAGE("[FAILED] USART Server mode Single-wire does not support requested test mode! Test aborted!");
1476 return EXIT_FAILURE;
1478 #elif (USART_CFG_SRV_MODE == MODE_SINGLE_IRDA)
1479 if (mode != MODE_SINGLE_IRDA) {
1480 TEST_MESSAGE("[FAILED] USART Server mode IrDA does not support requested test mode! Test aborted!");
1481 return EXIT_FAILURE;
1484 TEST_MESSAGE("[FAILED] USART Server mode unknown! Test aborted!");
1485 return EXIT_FAILURE;
1489 if (mode == MODE_SYNCHRONOUS_MASTER) { // If mode to be tested is Synchro Master then server must support Slave
1490 srv_mode = MODE_SYNCHRONOUS_SLAVE;
1491 } else if (mode == MODE_SYNCHRONOUS_SLAVE) { // If mode to be tested is Synchro Slave then server must support Master
1492 srv_mode = MODE_SYNCHRONOUS_MASTER;
1495 srv_flow_control = flow_control;
1496 if (flow_control == FLOW_CONTROL_RTS) {
1497 srv_flow_control = FLOW_CONTROL_CTS;
1499 if (flow_control == FLOW_CONTROL_CTS) {
1500 srv_flow_control = FLOW_CONTROL_RTS;
1503 srv_modem_line_mask = 0U;
1504 if ((modem_line_mask & RTS_AVAILABLE ) != 0U) {
1505 srv_modem_line_mask |= CTS_AVAILABLE;
1507 if ((modem_line_mask & CTS_AVAILABLE ) != 0U) {
1508 srv_modem_line_mask |= RTS_AVAILABLE;
1510 if ((modem_line_mask & DTR_AVAILABLE ) != 0U) {
1511 srv_modem_line_mask |= DSR_AVAILABLE;
1513 if ((modem_line_mask & DSR_AVAILABLE ) != 0U) {
1514 srv_modem_line_mask |= DTR_AVAILABLE;
1516 if ((modem_line_mask & DCD_AVAILABLE) != 0U) {
1517 srv_modem_line_mask |= DCD_AVAILABLE;
1519 if ((modem_line_mask & RI_AVAILABLE ) != 0U) {
1520 srv_modem_line_mask |= RI_AVAILABLE;
1523 if ((usart_serv_cap.mode_mask & (1UL << (srv_mode - 1U))) == 0U) {
1524 // If USART Server does not support desired mode
1525 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %s mode! Test aborted!", str_mode[mode]);
1526 TEST_MESSAGE(msg_buf);
1527 return EXIT_FAILURE;
1529 if ((usart_serv_cap.db_mask & (1UL << (data_bits - 5U))) == 0U) {
1530 // If USART Server does not support desired data bits
1531 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %i data bits! Test aborted!", data_bits);
1532 TEST_MESSAGE(msg_buf);
1533 return EXIT_FAILURE;
1535 if ((usart_serv_cap.parity_mask & (1UL << parity)) == 0U) {
1536 // If USART Server does not support desired parity
1537 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %s parity! Test aborted!", str_parity[parity]);
1538 TEST_MESSAGE(msg_buf);
1539 return EXIT_FAILURE;
1541 if ((usart_serv_cap.sb_mask & (1UL << stop_bits)) == 0U) {
1542 // If USART Server does not support desired stop bits
1543 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %s stop bits! Test aborted!", str_stop_bits[stop_bits]);
1544 TEST_MESSAGE(msg_buf);
1545 return EXIT_FAILURE;
1547 if ((usart_serv_cap.fc_mask & (1UL << srv_flow_control)) == 0U) {
1548 // If USART Server does not support desired flow control
1549 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %s flow control! Test aborted!", str_flow_control[flow_control]);
1550 TEST_MESSAGE(msg_buf);
1551 return EXIT_FAILURE;
1553 if (srv_modem_line_mask != 0U) {
1554 if ((usart_serv_cap.ml_mask & srv_modem_line_mask) == 0U) {
1555 // If USART Server does not support desired modem line
1556 TEST_MESSAGE("[FAILED] USART Server does not support desired modem line! Test aborted!");
1557 return EXIT_FAILURE;
1560 if ((usart_serv_cap.br_min > baudrate) ||
1561 (usart_serv_cap.br_max < baudrate)) {
1562 // If USART Server does not support desired baudrate
1563 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] USART Server does not support %i baudrate bus speed! Test aborted!", baudrate);
1564 TEST_MESSAGE(msg_buf);
1565 return EXIT_FAILURE;
1568 return EXIT_SUCCESS;
1571 #endif // If Test Mode USART Server is selected
1574 \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)
1575 \brief Check if Driver and USART Server (if used) is functional and if it supports desired settings.
1576 \detail Parameters describe settings required to test, so server must support complementary sattings.
1577 For example to test RTS line server must support CTS line.
1578 \param[in] mode mode (expected to be tested):
1579 - value 1 = Asynchronous
1580 - value 2 = Synchronous Master
1581 - value 3 = Synchronous Slave
1582 - value 4 = Single Wire
1584 - value 6 = Smart Card
1585 \param[in] data_bits data bits (5 .. 9)
1586 \param[in] parity parity:
1590 \param[in] stop_bits stop bits:
1591 - value 0 = 1 Stop Bit
1592 - value 1 = 2 Stop Bits
1593 - value 2 = 1.5 Stop Bits
1594 - value 3 = 0.5 Stop Bits
1595 \param[in] flow_control flow control:
1600 \param[in] modem_line_mask modem line mask:
1607 \param[in] baudrate baudrate in bauds
1608 \return execution status
1609 - EXIT_SUCCESS: Driver and USART Server supports desired settings
1610 - EXIT_FAILURE: Driver or USART Server does not support desired settings
1612 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) {
1614 if (BuffersCheck() != EXIT_SUCCESS) {
1615 return EXIT_FAILURE;
1618 if (DriverCheck (mode, flow_control, modem_line_mask) != EXIT_SUCCESS) {
1619 return EXIT_FAILURE;
1621 #if (USART_SERVER_USED == 1)
1622 if (ServerCheck (mode, data_bits, parity, stop_bits, flow_control, modem_line_mask, baudrate) != EXIT_SUCCESS) {
1623 return EXIT_FAILURE;
1627 return EXIT_SUCCESS;
1631 \fn void USART_DV_Initialize (void)
1632 \brief Initialize testing environment for USART testing.
1633 \detail This function is called by the driver validation framework before USART testing begins.
1634 It initializes global variables and allocates memory buffers (from heap) used for the USART testing.
1637 void USART_DV_Initialize (void) {
1639 // Initialize global variables
1644 duration = 0xFFFFFFFFUL;
1645 systick_freq = osKernelGetSysTimerFreq();
1646 if (systick_freq == 0U) {
1647 // systick_freq must not be 0
1650 ticks_per_ms = systick_freq / 1000U;
1652 memset(&usart_serv_cap, 0, sizeof(usart_serv_cap));
1653 memset(&msg_buf, 0, sizeof(msg_buf));
1655 // Allocate buffers for transmission, reception and comparison
1656 // (maximum size is incremented by 4 bytes to ensure that buffer can be aligned to 4 bytes)
1658 ptr_tx_buf_alloc = malloc(USART_BUF_MAX + 4U);
1659 if (((uint32_t)ptr_tx_buf_alloc & 3U) != 0U) {
1660 // If allocated memory is not 4 byte aligned, use next 4 byte aligned address for ptr_tx_buf
1661 ptr_tx_buf = (uint8_t *)((((uint32_t)ptr_tx_buf_alloc) + 3U) & (~3U));
1663 // If allocated memory is 4 byte aligned, use it directly
1664 ptr_tx_buf = (uint8_t *)ptr_tx_buf_alloc;
1666 ptr_rx_buf_alloc = malloc(USART_BUF_MAX + 4U);
1667 if (((uint32_t)ptr_rx_buf_alloc & 3U) != 0U) {
1668 ptr_rx_buf = (uint8_t *)((((uint32_t)ptr_rx_buf_alloc) + 3U) & (~3U));
1670 ptr_rx_buf = (uint8_t *)ptr_rx_buf_alloc;
1672 ptr_cmp_buf_alloc = malloc(USART_BUF_MAX + 4U);
1673 if (((uint32_t)ptr_cmp_buf_alloc & 3U) != 0U) {
1674 ptr_cmp_buf = (uint8_t *)((((uint32_t)ptr_cmp_buf_alloc) + 3U) & (~3U));
1676 ptr_cmp_buf = (uint8_t *)ptr_cmp_buf_alloc;
1679 event_flags = osEventFlagsNew(NULL);
1681 // Output configuration settings
1682 (void)snprintf(msg_buf,
1685 "Default settings:\n"\
1687 " - Data bits: %i\n"\
1689 " - Stop bits: %s\n"\
1690 " - Flow control: %s\n"\
1691 " - Clock polarity: %s\n"\
1692 " - Clock phase: %s\n"\
1693 " - Bus speed: %i bauds\n"\
1694 " - Number of Items: %i",
1695 str_test_mode [USART_CFG_TEST_MODE],
1696 str_mode [USART_CFG_DEF_MODE],
1697 USART_CFG_DEF_DATA_BITS,
1698 str_parity [USART_CFG_DEF_PARITY],
1699 str_stop_bits [USART_CFG_DEF_STOP_BITS],
1700 str_flow_control[USART_CFG_DEF_FLOW_CONTROL],
1701 str_cpol [USART_CFG_DEF_CPOL],
1702 str_cpha [USART_CFG_DEF_CPHA],
1703 USART_CFG_DEF_BAUDRATE,
1705 TEST_GROUP_INFO(msg_buf);
1707 drv_cap = drv->GetCapabilities();
1709 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
1710 // Test communication with USART Server
1711 int32_t server_status;
1714 // Test communication with USART Server
1715 if (drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK) {
1716 if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
1717 server_status = ServerInit();
1720 (void)drv->PowerControl(ARM_POWER_OFF);
1721 (void)drv->Uninitialize();
1723 //(void)snprintf(msg_buf, sizeof(msg_buf), "Server status: %s\n", str_srv_status[server_status]);
1724 //TEST_GROUP_INFO(msg_buf);
1729 \fn void USART_DV_Uninitialize (void)
1730 \brief De-initialize testing environment after USART testing.
1731 \detail This function is called by the driver validation framework after USART testing is finished.
1732 It frees memory buffers used for the USART testing.
1735 void USART_DV_Uninitialize (void) {
1737 (void)osEventFlagsDelete(event_flags);
1739 if (ptr_tx_buf_alloc != NULL) {
1740 free(ptr_tx_buf_alloc);
1742 ptr_tx_buf_alloc = NULL;
1744 if (ptr_rx_buf_alloc != NULL) {
1745 free(ptr_rx_buf_alloc);
1747 ptr_rx_buf_alloc = NULL;
1749 if (ptr_cmp_buf_alloc != NULL) {
1750 free(ptr_cmp_buf_alloc);
1752 ptr_cmp_buf_alloc = NULL;
1756 #endif // End of exclude form the documentation
1758 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1760 \defgroup dv_usart USART Validation
1761 \brief USART driver validation
1763 The USART validation performs the following tests:
1764 - API interface compliance
1765 - Data exchange with various speeds, transfer sizes and communication settings
1766 - Modem lines operation
1769 Two Test Modes are available: <b>Loopback</b> and <b>USART Server</b>.
1771 Test Mode : <b>Loopback</b>
1772 ---------------------------
1774 This test mode allows only limited validation of the USART Driver.<br>
1775 It is recommended that this test mode is used only as a proof that driver is
1776 good enough to be tested with the <b>USART Server</b>.
1778 For this purpose following <b>Default settings</b> should be used:
1779 - Mode: Asynchronous
1784 - Clock Polarity: Clock Polarity 0
1785 - Clock Phase: Clock Phase 0
1787 - Number of Items: 32
1789 To enable this mode of testing in the <b>DV_USART_Config.h</b> configuration file select the
1790 <b>Configuration: Test Mode: Loopback</b> setting.
1792 Required pin connection for the <b>Loopback</b> test mode:
1794 \image html usart_loopback_pin_connections.png
1796 \note In this mode following operations / settings cannot be tested:
1797 - synchronous slave or single-wire modes
1798 - operation of the Receive function
1799 - data content sent by the Send function
1800 - parity, stop bits, flow control, clock polarity / phase settings
1801 - data bit settings other then 8
1802 - modem lines operation
1805 \anchor usart_server_con
1807 Test Mode : <b>USART Server</b>
1808 -----------------------------
1810 This test mode allows extensive validation of the USART Driver.<br>
1811 Results of the Driver Validation in this test mode are relevant as a proof of driver compliance
1812 to the CMSIS-Driver specification.
1814 To perform extensive communication tests, it is required to use an
1815 \ref usart_server "USART Server" running on a dedicated hardware.
1817 To enable this mode of testing in the <b>DV_USART_Config.h</b> configuration file select the
1818 <b>Configuration: Test Mode: USART Server</b> setting.
1820 Required pin connections for the <b>USART Server</b> test mode with <b>USART Server Mode</b>: <b>Asynchronous</b> or <b>IrDa</b>
1822 \note Only necessary pin connections are Tx, Rx and GND. Flow control (RTS, CTS), modem lines (DSR, DTR, DCD, RI) and
1823 synchronous clock (CLK) line are optional and depend on pin availability and driver support for flow control, modem lines and
1825 \note For stable idle level on Rx lines, external pull-ups can be added.
1827 \image html usart_server_pin_connections_async.png
1829 Required pin connections for the <b>USART Server</b> test mode with <b>USART Server Mode</b>: <b>Single-wire</b>
1831 \image html usart_server_pin_connections_single_wire.png
1833 \note Asynchronous and IrDa modes use same connection type and Single-wire uses a different connection.
1834 \note Please ensure that correct connection is used as required by tests otherwise damage to hardware may occur
1835 (For example using Asynchronous mode selected with hardware connected for Single-wire tests can result in damaged pins).
1836 \note In this mode Tx and Rx pins are internally connected together.
1837 \note Tx pin should use open-drain setting in this mode to prevent damage in case of simultaneous
1838 driving from both USART Server and USART Client.
1840 \note To ensure proper signal quality:
1841 - keep the connecting wires as short as possible
1842 - if possible keep Tx and Rx wires wires separate from each other
1843 - ensure a good Ground (GND) connection between USART Server and DUT
1845 \defgroup usart_tests Tests
1849 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1850 /* USART Driver Management tests */
1851 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1853 \defgroup usart_tests_drv_mgmt Driver Management
1854 \ingroup usart_tests
1856 These tests verify API and operation of the USART driver management functions.
1858 The driver management tests verify the following driver functions
1859 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html" target="_blank">USART Driver function documentation</a>):
1862 ARM_DRIVER_VERSION GetVersion (void);
1864 - \b GetCapabilities
1866 ARM_USART_CAPABILITIES GetCapabilities (void);
1870 int32_t Initialize (ARM_USART_SignalEvent_t cb_event);
1874 int32_t Uninitialize (void);
1878 int32_t PowerControl (ARM_POWER_STATE state);
1884 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1886 \brief Function: Function USART_GetVersion
1888 The function \b UDSART_GetVersion verifies the \b GetVersion function.
1890 ARM_DRIVER_VERSION GetVersion (void);
1894 - Driver is uninitialized and peripheral is powered-off:
1895 - Call GetVersion function
1896 - Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1898 void USART_GetVersion (void) {
1899 ARM_DRIVER_VERSION ver;
1901 ver = drv->GetVersion();
1903 // Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1904 TEST_ASSERT((ver.api >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)) && (ver.drv >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)));
1906 (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));
1907 TEST_MESSAGE(msg_buf);
1910 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1912 \brief Function: Function USART_GetCapabilities
1914 The function \b USART_GetCapabilities verifies the \b GetCapabilities function.
1916 ARM_USART_CAPABILITIES GetCapabilities (void);
1920 - Driver is uninitialized and peripheral is powered-off:
1921 - Call GetCapabilities function
1922 - Assert that GetCapabilities function returned capabilities structure with reserved field 0
1924 void USART_GetCapabilities (void) {
1925 ARM_USART_CAPABILITIES cap;
1927 cap = drv->GetCapabilities();
1929 // Assert that GetCapabilities function returned capabilities structure with reserved field 0
1930 TEST_ASSERT_MESSAGE((cap.reserved == 0U), "[FAILED] Capabilities reserved field must be 0");
1933 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1935 \brief Function: Function USART_Initialize_Uninitialize
1937 The function \b USART_Initialize_Uninitialize verifies the \b Initialize and \b Uninitialize functions.
1939 int32_t Initialize (ARM_USART_SignalEvent_t cb_event);
1942 int32_t Uninitialize (void);
1946 - Driver is uninitialized and peripheral is powered-off:
1947 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1948 - Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1949 - Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1950 - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1951 - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1952 - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1953 - Call GetTxCount function and assert that it returned 0
1954 - Call GetRxCount function and assert that it returned 0
1955 - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1956 - Call GetStatus function
1957 - Assert that GetStatus function returned status structure with tx_busy flag 0
1958 - Assert that GetStatus function returned status structure with rx_busy flag 0
1959 - Assert that GetStatus function returned status structure with tx_underflow flag 0
1960 - Assert that GetStatus function returned status structure with rx_overflow flag 0
1961 - Assert that GetStatus function returned status structure with rx_break flag 0
1962 - Assert that GetStatus function returned status structure with rx_framing_error flag 0
1963 - Assert that GetStatus function returned status structure with rx_parity_error flag 0
1964 - Assert that GetStatus function returned status structure with reserved field 0
1965 - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1966 - Driver is initialized and peripheral is powered-off:
1967 - Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1968 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1969 - Driver is uninitialized and peripheral is powered-off:
1970 - Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1971 - Driver is initialized and peripheral is powered-off:
1972 - Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1973 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1974 - Driver is uninitialized and peripheral is powered-off:
1975 - Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1976 - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1977 - Driver is initialized and peripheral is powered-off:
1978 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1979 - Driver is initialized and peripheral is powered-on:
1980 - Call Control function and assert that it returned ARM_DRIVER_OK status
1981 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status<br>
1982 (this must unconditionally terminate active send/receive/transfer, power-off the peripheral and uninitialize the driver)
1983 - Driver is uninitialized and peripheral is powered-off:
1984 - Call GetStatus function
1985 - Assert that GetStatus function returned status structure with tx_busy flag 0
1986 - Assert that GetStatus function returned status structure with rx_busy flag 0
1988 void USART_Initialize_Uninitialize (void) {
1989 ARM_USART_STATUS stat;
1991 // Driver is uninitialized and peripheral is powered-off:
1992 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1993 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_ERROR);
1995 stat = drv->GetStatus();
1997 // Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1998 TEST_ASSERT(drv->PowerControl (ARM_POWER_LOW) == ARM_DRIVER_ERROR);
2000 stat = drv->GetStatus();
2002 // Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
2003 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_ERROR);
2005 stat = drv->GetStatus();
2007 // Call Send function and assert that it returned ARM_DRIVER_ERROR status
2008 TEST_ASSERT(drv->Send (ptr_tx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2010 // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
2011 TEST_ASSERT(drv->Receive (ptr_rx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2013 // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
2014 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2016 // Call GetTxCount function and assert that it returned 0
2017 TEST_ASSERT(drv->GetTxCount () == 0U);
2019 // Call GetRxCount function and assert that it returned 0
2020 TEST_ASSERT(drv->GetRxCount () == 0U);
2022 // Call Control function and assert that it returned ARM_DRIVER_ERROR status
2023 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);
2025 // Call GetStatus function
2026 stat = drv->GetStatus();
2028 // Assert that GetStatus function returned status structure with tx_busy flag 0
2029 TEST_ASSERT(stat.tx_busy == 0U);
2031 // Assert that GetStatus function returned status structure with rx_busy flag 0
2032 TEST_ASSERT(stat.rx_busy == 0U);
2034 // Assert that GetStatus function returned status structure with tx_underflow flag 0
2035 TEST_ASSERT(stat.tx_underflow == 0U);
2037 // Assert that GetStatus function returned status structure with rx_overflow flag 0
2038 TEST_ASSERT(stat.rx_overflow == 0U);
2040 // Assert that GetStatus function returned status structure with rx_break flag 0
2041 TEST_ASSERT(stat.rx_break == 0U);
2043 // Assert that GetStatus function returned status structure with rx_framing_error flag 0
2044 TEST_ASSERT(stat.rx_framing_error == 0U);
2046 // Assert that GetStatus function returned status structure with rx_parity_error flag 0
2047 TEST_ASSERT(stat.rx_parity_error == 0U);
2049 // Assert that GetStatus function returned status structure with reserved field 0
2050 TEST_ASSERT(stat.reserved == 0U);
2052 // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
2053 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
2055 // Driver is initialized and peripheral is powered-off:
2056 // Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
2057 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
2059 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
2060 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
2062 // Driver is uninitialized and peripheral is powered-off:
2063 // Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
2064 TEST_ASSERT(drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK);
2066 // Driver is initialized and peripheral is powered-off:
2067 // Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
2068 TEST_ASSERT(drv->Initialize (USART_DrvEvent) == ARM_DRIVER_OK);
2070 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
2071 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
2073 // Driver is uninitialized and peripheral is powered-off:
2074 // Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
2075 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
2077 // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
2078 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
2080 // Driver is initialized and peripheral is powered-off:
2081 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2082 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
2084 // Driver is initialized and peripheral is powered-on:
2085 // Call Control function and assert that it returned ARM_DRIVER_OK status
2086 TEST_ASSERT(drv->Control (((USART_CFG_DEF_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
2087 ((USART_CFG_DEF_CPOL << ARM_USART_CPOL_Pos) & ARM_USART_CPOL_Msk) |
2088 ((USART_CFG_DEF_CPHA << ARM_USART_CPHA_Pos) & ARM_USART_CPHA_Msk) |
2089 ARM_USART_DATA_BITS_8, USART_CFG_DEF_BAUDRATE) == ARM_DRIVER_OK);
2091 // Call Uninitialize function assert that it returned ARM_DRIVER_OK status
2092 // (this must unconditionally terminate active send/receive/transfer, power-off the peripheral and uninitialize the driver)
2093 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
2095 // Driver is uninitialized and peripheral is powered-off:
2096 // Call GetStatus function
2097 stat = drv->GetStatus();
2099 // Assert that GetStatus function returned status structure with tx_busy flag 0
2100 TEST_ASSERT(stat.tx_busy == 0U);
2102 // Assert that GetStatus function returned status structure with rx_busy flag 0
2103 TEST_ASSERT(stat.rx_busy == 0U);
2106 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2108 \brief Function: Function USART_PowerControl
2110 The function \b USART_PowerControl verifies the \b PowerControl function.
2112 int32_t PowerControl (ARM_POWER_STATE state);
2116 - Driver is initialized and peripheral is powered-off:
2117 - Call Send function and assert that it returned ARM_DRIVER_ERROR status
2118 - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
2119 - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
2120 - Call GetTxCount function and assert that it returned 0
2121 - Call GetRxCount function and assert that it returned 0
2122 - Call Control function and assert that it returned ARM_DRIVER_ERROR status
2123 - Call GetStatus function
2124 - Assert that GetStatus function returned status structure with tx_busy flag 0
2125 - Assert that GetStatus function returned status structure with rx_busy flag 0
2126 - Assert that GetStatus function returned status structure with tx_underflow flag 0
2127 - Assert that GetStatus function returned status structure with rx_overflow flag 0
2128 - Assert that GetStatus function returned status structure with rx_break flag 0
2129 - Assert that GetStatus function returned status structure with rx_framing_error flag 0
2130 - Assert that GetStatus function returned status structure with rx_parity_error flag 0
2131 - Assert that GetStatus function returned status structure with reserved field 0
2132 - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
2133 - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
2134 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2135 - Driver is initialized and peripheral is powered-on:
2136 - Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
2137 - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
2138 - Driver is initialized and peripheral is powered-off:
2139 - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
2140 - Call PowerControl(ARM_POWER_LOW) function
2141 - Driver is initialized and peripheral is powered-on or in low-power mode:
2142 - Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
2143 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2144 - Driver is initialized and peripheral is powered-on:
2145 - Call Control function and assert that it returned ARM_DRIVER_OK status
2146 - Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_OK status<br>
2147 (this must unconditionally terminate active send/receive/transfer and power-off the peripheral)
2148 - Driver is initialized and peripheral is powered-off:
2149 - Call GetStatus function
2150 - Assert that GetStatus function returned status structure with tx_busy flag 0
2151 - Assert that GetStatus function returned status structure with rx_busy flag 0
2153 void USART_PowerControl (void) {
2155 ARM_USART_STATUS stat;
2157 (void)drv->Initialize (NULL);
2159 // Driver is initialized and peripheral is powered-off:
2160 // Call Send function and assert that it returned ARM_DRIVER_ERROR status
2161 TEST_ASSERT(drv->Send (ptr_tx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2163 // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
2164 TEST_ASSERT(drv->Receive (ptr_rx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2166 // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
2167 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
2169 // Call GetTxCount function and assert that it returned 0
2170 TEST_ASSERT(drv->GetTxCount () == 0U);
2172 // Call GetRxCount function and assert that it returned 0
2173 TEST_ASSERT(drv->GetRxCount () == 0U);
2175 // Call Control function and assert that it returned ARM_DRIVER_ERROR status
2176 TEST_ASSERT(drv->Control (((USART_CFG_DEF_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
2177 ((USART_CFG_DEF_CPOL << ARM_USART_CPOL_Pos) & ARM_USART_CPOL_Msk) |
2178 ((USART_CFG_DEF_CPHA << ARM_USART_CPHA_Pos) & ARM_USART_CPHA_Msk) |
2179 ARM_USART_DATA_BITS_8, USART_CFG_DEF_BAUDRATE) == ARM_DRIVER_ERROR);
2181 // Call GetStatus function
2182 stat = drv->GetStatus();
2184 // Assert that GetStatus function returned status structure with tx_busy flag 0
2185 TEST_ASSERT(stat.tx_busy == 0U);
2187 // Assert that GetStatus function returned status structure with rx_busy flag 0
2188 TEST_ASSERT(stat.rx_busy == 0U);
2190 // Assert that GetStatus function returned status structure with tx_underflow flag 0
2191 TEST_ASSERT(stat.tx_underflow == 0U);
2193 // Assert that GetStatus function returned status structure with rx_overflow flag 0
2194 TEST_ASSERT(stat.rx_overflow == 0U);
2196 // Assert that GetStatus function returned status structure with rx_break flag 0
2197 TEST_ASSERT(stat.rx_break == 0U);
2199 // Assert that GetStatus function returned status structure with rx_framing_error flag 0
2200 TEST_ASSERT(stat.rx_framing_error == 0U);
2202 // Assert that GetStatus function returned status structure with rx_parity_error flag 0
2203 TEST_ASSERT(stat.rx_parity_error == 0U);
2205 // Assert that GetStatus function returned status structure with reserved field 0
2206 TEST_ASSERT(stat.reserved == 0U);
2208 // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
2209 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2211 // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
2212 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2214 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2215 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
2217 // Driver is initialized and peripheral is powered-on:
2218 // Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
2219 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
2221 // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
2222 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2224 // Driver is initialized and peripheral is powered-off:
2225 // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
2226 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2228 // Call PowerControl(ARM_POWER_LOW) function
2229 ret = drv->PowerControl (ARM_POWER_LOW);
2231 // Driver is initialized and peripheral is powered-on or in low-power mode:
2232 // Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
2233 TEST_ASSERT((ret == ARM_DRIVER_OK) || (ret == ARM_DRIVER_ERROR_UNSUPPORTED));
2234 if (ret == ARM_DRIVER_ERROR_UNSUPPORTED) {
2235 TEST_MESSAGE("[WARNING] PowerControl (ARM_POWER_LOW) is not supported");
2238 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
2239 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
2241 // Driver is initialized and peripheral is powered-on:
2242 // Call Control function and assert that it returned ARM_DRIVER_OK status
2243 TEST_ASSERT(drv->Control (((USART_CFG_DEF_MODE << ARM_USART_CONTROL_Pos) & ARM_USART_CONTROL_Msk) |
2244 ((USART_CFG_DEF_CPOL << ARM_USART_CPOL_Pos) & ARM_USART_CPOL_Msk) |
2245 ((USART_CFG_DEF_CPHA << ARM_USART_CPHA_Pos) & ARM_USART_CPHA_Msk) |
2246 ARM_USART_DATA_BITS_8, USART_CFG_DEF_BAUDRATE) == ARM_DRIVER_OK);
2248 // Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_OK status
2249 // (this must unconditionally terminate active send/receive/transfer and power-off the peripheral)
2250 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
2252 // Driver is initialized and peripheral is powered-off:
2253 // Call GetStatus function
2254 stat = drv->GetStatus();
2256 // Assert that GetStatus function returned status structure with tx_busy flag 0
2257 TEST_ASSERT(stat.tx_busy == 0U);
2259 // Assert that GetStatus function returned status structure with rx_busy flag 0
2260 TEST_ASSERT(stat.rx_busy == 0U);
2262 (void)drv->Uninitialize ();
2268 // End of usart_tests_drv_mgmt
2270 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2271 /* USART Data Exchange tests */
2272 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2274 \defgroup usart_tests_data_xchg Data Exchange
2275 \ingroup usart_tests
2277 These tests verify API and operation of the USART data exchange functions.
2279 The data exchange tests verify the following driver functions
2280 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html" target="_blank">USART Driver function documentation</a>):
2283 int32_t Send (const void *data, uint32_t num);
2287 int32_t Receive ( void *data, uint32_t num);
2291 int32_t Transfer (const void *data_out, void *data_in, uint32_t num);
2295 uint32_t GetTxCount (void);
2299 uint32_t GetRxCount (void);
2303 int32_t Control (uint32_t control, uint32_t arg);
2307 ARM_USART_STATUS GetStatus (void);
2311 void (*ARM_USART_SignalEvent_t) (uint32_t event);
2314 All of these tests execute a data exchange and check the result of this data exchange.
2316 Data exchange test procedure when Test Mode <b>USART Server</b> is selected:
2317 - send command "SET BUF TX,.." to the USART Server: Set Tx buffer
2318 - send command "SET BUF RX,.." to the USART Server: Set Rx buffer
2319 - send command "SET COM .." to the USART Server: Set communication settings for the next XFER command
2320 - send command "XFER .." to the USART Server: Specify transfer
2321 - driver Control: Configure the USART interface
2322 - driver Control: Set the default Tx value (in synchronous mode only)
2323 - driver Send/Receive/Transfer: Start the requested operation
2324 - driver GetStatus/SignalEvent: Wait for the current operation to finish or time-out<br>
2325 (operation is finished when appropriate tx_busy or rx_busy flag is 0 and send/receive/transfer completed event was signaled)
2326 - assert that operation has finished in expected time
2327 - assert that appropriate ARM_USART_EVENT_SEND_COMPLETE, ARM_USART_EVENT_RECEIVE_COMPLETE
2328 or ARM_USART_EVENT_TRANSFER_COMPLETE event was signaled
2329 - driver GetStatus: Assert that appropriate tx_busy or rx_busy flag is 0
2330 - driver GetTxCount: If it was a send or transfer operation assert that number of transmitted items is same as requested
2331 - driver GetRxCount: If it was a receive or transfer operation assert that number of received items is same as requested
2332 - if operation has timed out call driver Control function to Abort operation and wait timeout time<br>
2333 to make sure that the USART Server is ready for the next command
2334 - assert that received content is as expected
2335 - send command "GET BUF RX,.." to the USART Server: Get Rx buffer
2336 - assert that sent content (read from the USART Server's receive buffer) is as expected
2338 Data exchange <b>Abort</b> test procedure when Test Mode <b>USART Server</b> is selected:
2339 - send command "SET BUF TX,.." to the USART Server: Set Tx buffer
2340 - send command "SET BUF RX,.." to the USART Server: Set Rx buffer
2341 - send command "SET COM .." to the USART Server: Set communication settings for the next XFER command
2342 - send command "XFER .." to the USART Server: Specify transfer
2343 - driver Control: Configure the USART interface
2344 - driver Control: Set the default Tx value (in synchronous mode only)
2345 - driver Send/Receive/Transfer: Start the requested operation
2347 - driver Control: Abort the current operation
2348 - driver GetStatus: Assert that appropriate tx_busy or rx_busy flag is 0
2349 - driver GetTxCount: If it was a send or transfer operation assert that number of transmitted items is less than requested
2350 - driver GetRxCount: If it was a receive or transfer operation assert that number of received items is less than requested
2352 Data exchange test procedure when Test Mode <b>Loopback</b> is selected:
2353 - driver Control: Configure the USART interface
2354 - driver Control: Set the default Tx value (in synchronous mode only)
2355 - driver Send/Receive/Transfer: Start the requested operation
2356 - driver GetStatus/SignalEvent: Wait for the current operation to finish or time-out<br>
2357 (operation is finished when appropriate tx_busy or rx_busy flag is 0 and send/receive/transfer completed event was signaled)
2358 - assert that operation has finished in expected time
2359 - assert that appropriate ARM_USART_EVENT_SEND_COMPLETE and ARM_USART_EVENT_RECEIVE_COMPLETE
2360 or ARM_USART_EVENT_TRANSFER_COMPLETE event was signaled
2361 - driver GetStatus: Assert that appropriate tx_busy or rx_busy flag is 0
2362 - driver GetTxCount: If it was a send and receive or transfer operation assert that number of transmitted items is same as requested
2363 - driver GetRxCount: If it was a send and receive or transfer operation assert that number of received items is same as requested
2364 - if operation has timed out call driver Control function to Abort operation
2365 - assert that sent and received content is same
2367 \note Limitations of Data Exchange tests if Test Mode <b>Loopback</b> is selected:
2368 - in synchronous mode only Master mode transfer can be tested
2369 - only 8 data bit tests are supported
2370 - parity tests are not supported
2371 - stop bits tests are not supported
2372 - flow control tests are not supported
2373 - clock polarity and clock phase tests are not supported
2377 #ifndef __DOXYGEN__ // Exclude form the documentation
2379 \brief Execute USART data exchange or abort operation.
2380 \param[in] operation operation (OP_SEND .. OP_ABORT_TRANSFER)
2381 \param[in] mode mode (MODE_ASYNCHRONOUS .. MODE_SMART_CARD)
2382 \param[in] data_bits data bits (5 .. 9)
2383 \param[in] parity parity (PARITY_NONE, PARITY_EVEN or PARITY_ODD)
2384 \param[in] stop_bits stop bits (STOP_BITS_1 .. STOP_BITS_0_5)
2385 \param[in] flow_control flow control (FLOW_CONTROL_NONE .. FLOW_CONTROL_RTS_CTS)
2386 \param[in] cpol clock polarity (CPOL0 or CPOL1)
2387 \param[in] cpha clock phase (CPHA0 or CPHA1)
2388 \param[in] baudrate baudrate in bauds
2389 \param[in] num number of items to send, receive or transfer
2392 static void USART_DataExchange_Operation (uint32_t operation, uint32_t mode, uint32_t data_bits, uint32_t parity, uint32_t stop_bits, uint32_t flow_control, uint32_t cpol, uint32_t cpha, uint32_t baudrate, uint32_t num) {
2393 // volatile specifier is used to prevent compiler from optimizing variables
2394 // in a way that they cannot be seen with debugger
2395 volatile int32_t stat, def_tx_stat;
2396 volatile uint32_t drv_mode, drv_data_bits, drv_parity, drv_stop_bits, drv_flow_control, drv_cpol, drv_cpha;
2397 volatile uint32_t srv_mode, srv_dir, srv_flow_control;
2398 volatile ARM_USART_STATUS usart_stat;
2399 volatile uint32_t tx_count, rx_count;
2401 uint32_t val, delay, i;
2402 volatile uint32_t srv_delay;
2403 volatile uint32_t drv_delay;
2404 uint8_t chk_tx_data, chk_rx_data;
2405 uint32_t timeout, start_tick, curr_tick;
2407 // Prepare parameters for USART Server and Driver configuration
2408 switch (operation & 0x0FU) {
2414 if (mode == MODE_SYNCHRONOUS_MASTER) {
2415 // In Synchronous Master test wait for USART Server to start the trasnsfer
2418 } else if (mode == MODE_SYNCHRONOUS_SLAVE) {
2419 // In Synchronous Slave test make USART Server wait for driver to start the send operation
2425 case OP_ABORT_RECEIVE:
2429 if (mode == MODE_SYNCHRONOUS_MASTER) {
2430 // In Synchronous Master test wait for USART Server to start the trasnsfer
2433 } else if (mode == MODE_SYNCHRONOUS_SLAVE) {
2434 // In Synchronous Slave test make USART Server wait for driver to start the receive operation
2440 case OP_ABORT_TRANSFER:
2442 if (mode == MODE_SYNCHRONOUS_MASTER) {
2443 // In Synchronous Master test wait for USART Server to start the trasnsfer
2446 } else if (mode == MODE_SYNCHRONOUS_SLAVE) {
2447 // In Synchronous Slave test mode make USART Server wait for driver to start the transfer
2451 TEST_FAIL_MESSAGE("[FAILED] Synchronous mode unknown! Data exchange operation aborted!");
2454 case OP_RECEIVE_SEND_LB:
2460 case MODE_ASYNCHRONOUS:
2461 drv_mode = ARM_USART_MODE_ASYNCHRONOUS;
2462 srv_mode = MODE_ASYNCHRONOUS;
2464 case MODE_SYNCHRONOUS_MASTER:
2465 drv_mode = ARM_USART_MODE_SYNCHRONOUS_MASTER;
2466 srv_mode = MODE_SYNCHRONOUS_SLAVE;
2468 case MODE_SYNCHRONOUS_SLAVE:
2469 drv_mode = ARM_USART_MODE_SYNCHRONOUS_SLAVE;
2470 srv_mode = MODE_SYNCHRONOUS_MASTER;
2472 case MODE_SINGLE_WIRE:
2473 drv_mode = ARM_USART_MODE_SINGLE_WIRE;
2474 srv_mode = MODE_SINGLE_WIRE;
2477 drv_mode = ARM_USART_MODE_IRDA;
2478 srv_mode = MODE_IRDA;
2480 case MODE_SMART_CARD:
2481 TEST_FAIL_MESSAGE("[FAILED] Smart Card mode testing not supported! Data exchange operation aborted!");
2484 TEST_FAIL_MESSAGE("[FAILED] Unknown mode! Data exchange operation aborted!");
2488 switch (data_bits) {
2490 drv_data_bits = ARM_USART_DATA_BITS_5;
2493 drv_data_bits = ARM_USART_DATA_BITS_6;
2496 drv_data_bits = ARM_USART_DATA_BITS_7;
2499 drv_data_bits = ARM_USART_DATA_BITS_8;
2502 drv_data_bits = ARM_USART_DATA_BITS_9;
2505 TEST_FAIL_MESSAGE("[FAILED] Data bits not in range 5 to 9! Data exchange operation aborted!");
2511 drv_parity = ARM_USART_PARITY_NONE;
2514 drv_parity = ARM_USART_PARITY_EVEN;
2517 drv_parity = ARM_USART_PARITY_ODD;
2520 TEST_FAIL_MESSAGE("[FAILED] Unknown parity! Data exchange operation aborted!");
2524 switch (stop_bits) {
2526 drv_stop_bits = ARM_USART_STOP_BITS_1;
2529 drv_stop_bits = ARM_USART_STOP_BITS_2;
2532 drv_stop_bits = ARM_USART_STOP_BITS_1_5;
2535 drv_stop_bits = ARM_USART_STOP_BITS_0_5;
2538 TEST_FAIL_MESSAGE("[FAILED] Unknown stop bits! Data exchange operation aborted!");
2542 switch (flow_control) {
2543 case FLOW_CONTROL_NONE:
2544 drv_flow_control = ARM_USART_FLOW_CONTROL_NONE;
2545 srv_flow_control = FLOW_CONTROL_NONE;
2547 case FLOW_CONTROL_CTS:
2548 drv_flow_control = ARM_USART_FLOW_CONTROL_CTS;
2549 srv_flow_control = FLOW_CONTROL_RTS;
2551 case FLOW_CONTROL_RTS:
2552 drv_flow_control = ARM_USART_FLOW_CONTROL_RTS;
2553 srv_flow_control = FLOW_CONTROL_CTS;
2555 case FLOW_CONTROL_RTS_CTS:
2556 drv_flow_control = ARM_USART_FLOW_CONTROL_RTS_CTS;
2557 srv_flow_control = FLOW_CONTROL_RTS_CTS;
2560 TEST_FAIL_MESSAGE("[FAILED] Unknown flow control! Data exchange operation aborted!");
2566 drv_cpol = ARM_USART_CPOL0;
2569 drv_cpol = ARM_USART_CPOL1;
2572 TEST_FAIL_MESSAGE("[FAILED] Unknown clock polarity! Data exchange operation aborted!");
2578 drv_cpha = ARM_USART_CPHA0;
2581 drv_cpha = ARM_USART_CPHA1;
2584 TEST_FAIL_MESSAGE("[FAILED] Unknown clock phase! Data exchange operation aborted!");
2588 // Total transfer timeout (10 ms is overhead before transfer starts)
2589 timeout = USART_CFG_XFER_TIMEOUT + 10U;
2591 // Check that USART status is not busy before starting data exchange test
2592 usart_stat = drv->GetStatus(); // Get USART status
2593 if (usart_stat.tx_busy != 0U) {
2594 // If tx_busy flag is active
2595 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Tx busy active before operation! Data exchange operation aborted!");
2597 TEST_ASSERT_MESSAGE(usart_stat.tx_busy == 0U, msg_buf);
2598 if (usart_stat.rx_busy != 0U) {
2599 // If rx_busy flag is active
2600 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Rx busy active before operation! Data exchange operation aborted!");
2602 TEST_ASSERT_MESSAGE(usart_stat.rx_busy == 0U, msg_buf);
2603 if (usart_stat.tx_busy != 0U) {
2604 return; // If tx busy is active abort data exchange operation
2606 if (usart_stat.rx_busy != 0U) {
2607 return; // If rx busy is active abort data exchange operation
2611 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
2612 if (CmdSetBufTx('S') != EXIT_SUCCESS) { break; }
2613 if (CmdSetBufRx('?') != EXIT_SUCCESS) { break; }
2614 if (CmdSetCom (srv_mode, data_bits, parity, stop_bits, srv_flow_control, cpol, cpha, baudrate) != EXIT_SUCCESS) { break; }
2615 if (CmdXfer (srv_dir, num, srv_delay, USART_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
2616 #else // If Test Mode Loopback is selected
2617 // Remove warnings for unused variables
2620 (void)srv_flow_control;
2623 start_tick = osKernelGetTickCount();
2625 // Initialize buffers
2626 memset(ptr_tx_buf, (int32_t)'!' , USART_BUF_MAX);
2627 memset(ptr_tx_buf, (int32_t)'T' , num * DataBitsToBytes(data_bits));
2628 memset(ptr_rx_buf, (int32_t)'?' , USART_BUF_MAX);
2629 memset(ptr_cmp_buf, (int32_t)'?' , USART_BUF_MAX);
2631 // Configure required communication settings
2632 (void)osDelay(drv_delay); // Wait specified time before calling Control function
2633 stat = drv->Control (drv_mode | drv_data_bits | drv_parity | drv_stop_bits | drv_flow_control | drv_cpol | drv_cpha, baudrate);
2635 if (stat != ARM_DRIVER_OK) {
2636 // If configuration has failed
2637 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Control function returned", str_ret[-stat]);
2639 // Assert that Control function returned ARM_DRIVER_OK
2640 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2642 if (stat != ARM_DRIVER_OK) {
2643 // If control function has failed means driver does not support requested settings
2644 // wait for timeout and exit
2645 (void)osDelay(timeout+20U); // Wait for USART Server to timout XFER and start reception of next command
2646 return; // Here Abort test is finished, exit
2649 // Set default 3/16 bit IrDA pulse period (only for IrDA mode)
2650 if (mode == MODE_IRDA) {
2651 stat = drv->Control (ARM_USART_SET_IRDA_PULSE, 0U);
2652 if ((stat != ARM_DRIVER_OK) && (stat != ARM_DRIVER_ERROR_UNSUPPORTED)) {
2653 // If set IrDA pulse has failed
2654 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Set IrDA pulse value returned", str_ret[-stat]);
2656 // Assert that Control function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED
2657 TEST_ASSERT_MESSAGE((stat == ARM_DRIVER_OK) || (stat == ARM_DRIVER_ERROR_UNSUPPORTED), msg_buf);
2659 if (stat == ARM_DRIVER_ERROR_UNSUPPORTED) {
2660 // If set IrDA pulse value is not supported
2661 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] %s: %s", str_oper[operation], "Set default IrDA pulse value is not supported");
2662 TEST_MESSAGE(msg_buf);
2666 // Set default Tx value to 'D' byte values (only for synchronous mode)
2667 if ((mode == MODE_SYNCHRONOUS_MASTER) || (mode == MODE_SYNCHRONOUS_SLAVE)) {
2668 val = ((uint32_t)'D' << 24) | ((uint32_t)'D' << 16) | ((uint32_t)'D' << 8) | (uint32_t)'D';
2669 stat = drv->Control (ARM_USART_SET_DEFAULT_TX_VALUE, val);
2671 if ((stat != ARM_DRIVER_OK) && (stat != ARM_DRIVER_ERROR_UNSUPPORTED)) {
2672 // If set default Tx value has failed
2673 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Set default Tx value returned", str_ret[-stat]);
2675 // Assert that Control function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED
2676 TEST_ASSERT_MESSAGE((stat == ARM_DRIVER_OK) || (stat == ARM_DRIVER_ERROR_UNSUPPORTED), msg_buf);
2678 if (stat == ARM_DRIVER_ERROR_UNSUPPORTED) {
2679 // If set default Tx value is not supported
2680 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] %s: %s", str_oper[operation], "Set default Tx value is not supported");
2681 TEST_MESSAGE(msg_buf);
2684 // For slave mode default Tx is not tested
2685 def_tx_stat = ARM_DRIVER_ERROR_UNSUPPORTED;
2688 // Prepare local variables
2690 duration = 0xFFFFFFFFUL;
2693 tx_count_sample = 0U;
2694 rx_count_sample = 0U;
2697 start_cnt = osKernelGetSysTimerCount();
2699 // Start the data exchange operation
2700 switch (operation & 0x0FU) {
2703 stat = drv->Control(ARM_USART_CONTROL_TX, 1U);
2704 if (stat != ARM_DRIVER_OK) {
2705 // If transmitter enable has failed
2706 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transmitter enable returned", str_ret[-stat]);
2708 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
2709 chk_tx_data = 1U; // Check sent data
2711 stat = drv->Send(ptr_tx_buf, num);
2712 if (stat != ARM_DRIVER_OK) {
2713 // If Send activation has failed
2714 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Send function returned", str_ret[-stat]);
2716 // Assert that Send function returned ARM_DRIVER_OK
2717 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2720 case OP_ABORT_RECEIVE:
2721 stat = drv->Control(ARM_USART_CONTROL_RX, 1U);
2722 if (stat != ARM_DRIVER_OK) {
2723 // If receiver enable has failed
2724 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receiver enable returned", str_ret[-stat]);
2726 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
2727 chk_rx_data = 1U; // Check received data
2729 stat = drv->Receive(ptr_rx_buf, num);
2730 if (stat != ARM_DRIVER_OK) {
2731 // If Receive activation has failed
2732 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receive function returned", str_ret[-stat]);
2734 // Assert that Receive function returned ARM_DRIVER_OK
2735 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2738 case OP_ABORT_TRANSFER:
2739 stat = drv->Control(ARM_USART_CONTROL_TX, 1U);
2740 if (stat != ARM_DRIVER_OK) {
2741 // If transmitter enable has failed
2742 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transmitter enable returned", str_ret[-stat]);
2744 stat = drv->Control(ARM_USART_CONTROL_RX, 1U);
2745 if (stat != ARM_DRIVER_OK) {
2746 // If receiver enable has failed
2747 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receiver enable returned", str_ret[-stat]);
2749 chk_tx_data = 1U; // Check sent data
2750 chk_rx_data = 1U; // Check received data
2751 stat = drv->Transfer(ptr_tx_buf, ptr_rx_buf, num);
2752 if (stat != ARM_DRIVER_OK) {
2753 // If Transfer activation has failed
2754 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transfer function returned", str_ret[-stat]);
2756 // Assert that Transfer function returned ARM_DRIVER_OK
2757 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2759 case OP_RECEIVE_SEND_LB:
2760 stat = drv->Control(ARM_USART_CONTROL_TX, 1U);
2761 if (stat != ARM_DRIVER_OK) {
2762 // If transmitter enable has failed
2763 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transmitter enable returned", str_ret[-stat]);
2765 stat = drv->Control(ARM_USART_CONTROL_RX, 1U);
2766 if (stat != ARM_DRIVER_OK) {
2767 // If receiver enable has failed
2768 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receiver enable returned", str_ret[-stat]);
2770 chk_rx_data = 1U; // Check received data
2771 stat = drv->Receive(ptr_rx_buf, num);
2772 if (stat != ARM_DRIVER_OK) {
2773 // If Receive activation has failed
2774 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receive function returned", str_ret[-stat]);
2776 // Assert that Receive function returned ARM_DRIVER_OK
2777 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2778 chk_tx_data = 1U; // Check sent data
2779 stat = drv->Send(ptr_tx_buf, num);
2780 if (stat != ARM_DRIVER_OK) {
2781 // If Send activation has failed
2782 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Send function returned", str_ret[-stat]);
2784 // Assert that Send function returned ARM_DRIVER_OK
2785 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2788 TEST_FAIL_MESSAGE("[FAILED] Unknown operation! Data exchange operation aborted!");
2792 if ((operation == OP_ABORT_SEND) || // This IF block tests only abort functionality
2793 (operation == OP_ABORT_RECEIVE) ||
2794 (operation == OP_ABORT_TRANSFER)) {
2795 (void)osDelay(1U); // Wait short time before doing Abort
2796 switch (operation & 0x0FU) {
2798 stat = drv->Control (ARM_USART_ABORT_SEND, 0U);
2800 case OP_ABORT_RECEIVE:
2801 stat = drv->Control (ARM_USART_ABORT_RECEIVE, 0U);
2803 case OP_ABORT_TRANSFER:
2804 stat = drv->Control (ARM_USART_ABORT_TRANSFER, 0U);
2807 if (stat != ARM_DRIVER_OK) {
2808 // If Abort has failed
2809 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
2811 // Assert that Control function returned ARM_DRIVER_OK
2812 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2813 usart_stat = drv->GetStatus(); // Get USART status
2814 if (usart_stat.tx_busy != 0U) {
2815 // If tx_busy flag is still active
2816 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Tx busy still active after Abort");
2818 // Assert that tx_busy flag is not active
2819 TEST_ASSERT_MESSAGE(usart_stat.tx_busy == 0U, msg_buf);
2820 if (usart_stat.rx_busy != 0U) {
2821 // If rx_busy flag is still active
2822 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Rx busy still active after Abort");
2824 // Assert that rx_busy flag is not active
2825 TEST_ASSERT_MESSAGE(usart_stat.rx_busy == 0U, msg_buf);
2827 if ((operation == OP_ABORT_SEND) || (operation == OP_ABORT_TRANSFER)) {
2828 tx_count = drv->GetTxCount(); // Get Tx count
2829 if (tx_count >= num) {
2830 // If Tx count is more or equal to number of items then Abort has failed
2831 (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");
2833 // Assert data count is less then number of items requested for send/transfer
2834 TEST_ASSERT_MESSAGE(tx_count < num, msg_buf);
2836 if ((operation == OP_ABORT_RECEIVE) || (operation == OP_ABORT_TRANSFER)) {
2837 rx_count = drv->GetRxCount(); // Get Rx count
2838 if (rx_count >= num) {
2839 // If Rx count is more or equal to number of items then Abort has failed
2840 (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");
2842 // Assert data count is less then number of items requested for receive/transfer
2843 TEST_ASSERT_MESSAGE(rx_count < num, msg_buf);
2846 stat = drv->Control(ARM_USART_CONTROL_TX, 0U);
2847 if (stat != ARM_DRIVER_OK) {
2848 // If transmitter disable has failed
2849 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transmitter disable returned", str_ret[-stat]);
2851 stat = drv->Control(ARM_USART_CONTROL_RX, 0U);
2852 if (stat != ARM_DRIVER_OK) {
2853 // If receiver disable has failed
2854 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receiver disable returned", str_ret[-stat]);
2857 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
2858 // Wait until timeout expires
2859 curr_tick = osKernelGetTickCount();
2860 if ((curr_tick - start_tick) < timeout) {
2861 (void)osDelay(timeout - (curr_tick - start_tick));
2863 (void)osDelay(20U); // Wait for USART Server to start reception of next command
2866 return; // Here Abort test is finished, exit
2869 // Wait for operation to finish
2870 // for send operation wait until status tx_busy is 0 and
2871 // event ARM_USART_EVENT_SEND_COMPLETE is signaled, or timeout
2872 // for receive operation wait until status rx_busy is 0 and
2873 // event ARM_USART_EVENT_RECEIVE_COMPLETE is signaled, or timeout
2874 // for transfer operation wait until status tx_busy and rx_busy is 0 and
2875 // event ARM_USART_EVENT_TRANSFER_COMPLETE is signaled, or timeout
2876 // for receive and send operation wait until status tx_busy and rx_busy is 0 and
2877 // both events ARM_USART_EVENT_SEND_COMPLETE and ARM_USART_EVENT_RECEIVE_COMPLETE are signaled, or timeout
2879 if (operation == OP_SEND) {
2880 if (tx_count_sample == 0U) {
2881 // Store first Tx count different than 0
2882 tx_count_sample = drv->GetTxCount(); // Get Tx count
2884 if ((drv->GetStatus().tx_busy == 0U) && ((event & ARM_USART_EVENT_SEND_COMPLETE) != 0U)) {
2885 duration = osKernelGetSysTimerCount() - start_cnt;
2889 if (operation == OP_RECEIVE) {
2890 if (rx_count_sample == 0U) {
2891 // Store first Rx count different than 0
2892 rx_count_sample = drv->GetRxCount(); // Get Rx count
2894 if ((drv->GetStatus().rx_busy == 0U) && ((event & ARM_USART_EVENT_RECEIVE_COMPLETE) != 0U)) {
2895 duration = osKernelGetSysTimerCount() - start_cnt;
2899 if (operation == OP_TRANSFER) {
2900 if (tx_count_sample == 0U) {
2901 // Store first Tx count different than 0
2902 tx_count_sample = drv->GetTxCount(); // Get Tx count
2904 if (rx_count_sample == 0U) {
2905 // Store first Rx count different than 0
2906 rx_count_sample = drv->GetRxCount(); // Get Rx count
2908 if ((drv->GetStatus().tx_busy == 0U) && (drv->GetStatus().rx_busy == 0U) && ((event & ARM_USART_EVENT_TRANSFER_COMPLETE) != 0U)) {
2909 duration = osKernelGetSysTimerCount() - start_cnt;
2913 if (operation == OP_RECEIVE_SEND_LB) {
2914 if (tx_count_sample == 0U) {
2915 // Store first Tx count different than 0
2916 tx_count_sample = drv->GetTxCount(); // Get Tx count
2918 if (rx_count_sample == 0U) {
2919 // Store first Rx count different than 0
2920 rx_count_sample = drv->GetRxCount(); // Get Rx count
2922 if ((drv->GetStatus().tx_busy == 0U) && (drv->GetStatus().rx_busy == 0U) &&
2923 ((event & (ARM_USART_EVENT_RECEIVE_COMPLETE | ARM_USART_EVENT_SEND_COMPLETE)) ==
2924 (ARM_USART_EVENT_RECEIVE_COMPLETE | ARM_USART_EVENT_SEND_COMPLETE))) {
2925 duration = osKernelGetSysTimerCount() - start_cnt;
2929 } while ((osKernelGetTickCount() - start_tick) < timeout);
2931 if (duration == 0xFFFFFFFFUL) {
2932 // If operation has timed out
2933 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Operation timed out");
2935 // Assert that operation has finished in expected time
2936 TEST_ASSERT_MESSAGE(duration != 0xFFFFFFFFUL, msg_buf);
2938 if (duration != 0xFFFFFFFFUL) {
2939 // For Synchronous Slave duration is started by Master srv_delay later so this has to be deducted
2940 if (mode == MODE_SYNCHRONOUS_SLAVE) {
2941 if (srv_delay > 1U) {
2942 srv_delay --; // Reduce 1 ms tolerance of delay
2943 if (duration > (srv_delay * (systick_freq / 1000U))) {
2944 duration -= srv_delay * (systick_freq / 1000U);
2950 // Check all expected conditions after Send operation
2951 if (operation == OP_SEND) {
2952 if ((event & ARM_USART_EVENT_SEND_COMPLETE) == 0U) {
2953 // If send complete event was not signaled
2954 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_SEND_COMPLETE was not signaled");
2955 chk_tx_data = 0U; // Do not check sent content
2957 // Assert that ARM_USART_EVENT_SEND_COMPLETE was signaled
2958 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_SEND_COMPLETE) != 0U, msg_buf);
2960 if (drv_cap.event_tx_complete != 0U) {
2961 // If driver supports Tx complete signaling
2962 if ((event & ARM_USART_EVENT_TX_COMPLETE) == 0U) {
2963 // If Tx complete event was not signaled
2964 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_TX_COMPLETE was not signaled");
2965 chk_tx_data = 0U; // Do not check sent content
2967 // Assert that ARM_USART_EVENT_TX_COMPLETE was signaled
2968 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_TX_COMPLETE) != 0U, msg_buf);
2971 usart_stat = drv->GetStatus(); // Get USART status
2972 if (usart_stat.tx_busy != 0U) {
2973 // If tx_busy flag is still active
2974 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Tx busy still active after operation");
2975 chk_tx_data = 0U; // Do not check sent content
2977 // Assert that tx_busy flag is not active
2978 TEST_ASSERT_MESSAGE(usart_stat.tx_busy == 0U, msg_buf);
2980 tx_count = drv->GetTxCount(); // Get Tx count
2981 if (tx_count != num) {
2982 // If Tx count is different then number of items, then operation has failed
2983 (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");
2984 chk_tx_data = 0U; // Do not check sent content
2986 // Assert that Tx count is equal to number of items requested for send
2987 TEST_ASSERT_MESSAGE(tx_count == num, msg_buf);
2989 if ((drv->GetStatus().tx_busy != 0U) || ((event & ARM_USART_EVENT_SEND_COMPLETE) == 0U)) {
2990 // If send did not finish in time, abort it
2991 (void)drv->Control(ARM_USART_ABORT_SEND, 0U);
2995 // Check all expected conditions after Receive operation
2996 if (operation == OP_RECEIVE) {
2997 if ((event & ARM_USART_EVENT_RECEIVE_COMPLETE) == 0U) {
2998 // If receive complete event was not signaled
2999 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_RECEIVE_COMPLETE was not signaled");
3000 chk_rx_data = 0U; // Do not check received content
3002 // Assert that ARM_USART_EVENT_RECEIVE_COMPLETE was signaled
3003 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RECEIVE_COMPLETE) != 0U, msg_buf);
3005 usart_stat = drv->GetStatus(); // Get USART status
3006 if (usart_stat.rx_busy != 0U) {
3007 // If rx_busy flag is still active
3008 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Rx busy still active after operation");
3009 chk_rx_data = 0U; // Do not check received content
3011 // Assert that rx_busy flag is not active
3012 TEST_ASSERT_MESSAGE(usart_stat.rx_busy == 0U, msg_buf);
3014 if ((event & ARM_USART_EVENT_RX_OVERFLOW) != 0U) {
3015 // If Rx overflow was signaled during the transfer
3016 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_RX_OVERFLOW was signaled");
3017 chk_rx_data = 0U; // Do not check received content
3019 // Assert that ARM_USART_EVENT_RX_OVERFLOW was not signaled
3020 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_OVERFLOW) == 0U, msg_buf);
3022 rx_count = drv->GetRxCount(); // Get Rx count
3023 if (rx_count != num) {
3024 // If Rx count is different then number of items, then operation has failed
3025 (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");
3026 chk_rx_data = 0U; // Do not check received content
3028 // Assert that Rx count is equal to number of items requested for reception
3029 TEST_ASSERT_MESSAGE(rx_count == num, msg_buf);
3031 if ((drv->GetStatus().rx_busy != 0U) || ((event & ARM_USART_EVENT_RECEIVE_COMPLETE) == 0U)) {
3032 // If reception did not finish in time, abort it
3033 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
3037 // Check all expected conditions after Transfer operation
3038 if (operation == OP_TRANSFER) {
3039 if ((event & ARM_USART_EVENT_TRANSFER_COMPLETE) == 0U) {
3040 // If transfer complete event was not signaled
3041 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_TRANSFER_COMPLETE was not signaled");
3042 chk_tx_data = 0U; // Do not check sent content
3043 chk_rx_data = 0U; // Do not check received content
3045 // Assert that ARM_USART_EVENT_TRANSFER_COMPLETE was signaled
3046 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_TRANSFER_COMPLETE) != 0U, msg_buf);
3048 usart_stat = drv->GetStatus(); // Get USART status
3049 if (usart_stat.tx_busy != 0U) {
3050 // If tx_busy flag is still active
3051 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Tx busy still active after operation");
3052 chk_tx_data = 0U; // Do not check sent content
3054 // Assert that tx_busy flag is not active
3055 TEST_ASSERT_MESSAGE(usart_stat.tx_busy == 0U, msg_buf);
3056 if (usart_stat.rx_busy != 0U) {
3057 // If rx_busy flag is still active
3058 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Rx busy still active after operation");
3059 chk_rx_data = 0U; // Do not check received content
3061 // Assert that rx_busy flag is not active
3062 TEST_ASSERT_MESSAGE(usart_stat.rx_busy == 0U, msg_buf);
3064 if ((event & ARM_USART_EVENT_TX_UNDERFLOW) != 0U) {
3065 // If Tx underflow was signaled during the transfer
3066 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_TX_UNDERFLOW was signaled");
3067 chk_tx_data = 0U; // Do not check sent content
3069 // Assert that ARM_USART_EVENT_TX_UNDERFLOW was not signaled
3070 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_TX_UNDERFLOW) == 0U, msg_buf);
3072 if ((event & ARM_USART_EVENT_RX_OVERFLOW) != 0U) {
3073 // If Rx overflow was signaled during the transfer
3074 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_TX_UNDERFLOW was signaled");
3075 chk_rx_data = 0U; // Do not check received content
3077 // Assert that ARM_USART_EVENT_RX_OVERFLOW was not signaled
3078 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_OVERFLOW) == 0U, msg_buf);
3080 tx_count = drv->GetTxCount(); // Get Tx count
3081 if (tx_count != num) {
3082 // If Tx count is different then number of items, then operation has failed
3083 (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");
3084 chk_tx_data = 0U; // Do not check sent content
3086 // Assert that Tx count is equal to number of items requested for transfer
3087 TEST_ASSERT_MESSAGE(tx_count == num, msg_buf);
3089 rx_count = drv->GetRxCount(); // Get Rx count
3090 if (rx_count != num) {
3091 // If Rx count is different then number of items, then operation has failed
3092 (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");
3093 chk_rx_data = 0U; // Do not check received content
3095 // Assert that Rx count is equal to number of items requested for transfer
3096 TEST_ASSERT_MESSAGE(rx_count == num, msg_buf);
3098 if ((drv->GetStatus().tx_busy != 0U) || (drv->GetStatus().rx_busy != 0U) ||
3099 ((event & ARM_USART_EVENT_TRANSFER_COMPLETE) == 0U)) {
3100 // If transfer did not finish in time, abort it
3101 (void)drv->Control(ARM_USART_ABORT_TRANSFER, 0U);
3105 stat = drv->Control(ARM_USART_CONTROL_TX, 0U);
3106 if (stat != ARM_DRIVER_OK) {
3107 // If transmitter disable has failed
3108 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transmitter disable returned", str_ret[-stat]);
3110 stat = drv->Control(ARM_USART_CONTROL_RX, 0U);
3111 if (stat != ARM_DRIVER_OK) {
3112 // If receiver disable has failed
3113 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receiver disable returned", str_ret[-stat]);
3116 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
3118 // Wait until timeout expires
3119 curr_tick = osKernelGetTickCount();
3120 if ((curr_tick - start_tick) < timeout) {
3121 (void)osDelay(timeout - (curr_tick - start_tick));
3123 (void)osDelay(20U); // Wait for USART Server to start reception of next command
3125 if (chk_rx_data != 0U) { // If received content should be checked
3126 // Check received content
3127 memset(ptr_cmp_buf, (int32_t)'S', num * DataBitsToBytes(data_bits));
3128 if (data_bits == 9U) {
3129 // If 9-bit mode is used zero out unused bits in high byte
3130 for (i = 1U; i < num * 2U; i += 2U) {
3131 ptr_cmp_buf[i] &= 0x01U;
3134 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
3136 // If data received mismatches
3137 // Find on which byte mismatch starts
3138 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
3139 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
3143 (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]);
3145 // Assert that data received is same as expected
3146 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
3149 if (chk_tx_data != 0U) { // If sent content should be checked
3150 // Check sent content (by checking USART Server's received buffer content)
3151 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3152 if (CmdGetBufRx(USART_BUF_MAX) != EXIT_SUCCESS) { break; }
3154 if ((operation == OP_RECEIVE) && (def_tx_stat == ARM_DRIVER_OK)) {
3155 // Expected data received by USART Server should be default Tx value
3156 memset(ptr_cmp_buf, (int32_t)'D', num * DataBitsToBytes(data_bits));
3158 // Expected data received by USART Server should be what was sent
3159 memset(ptr_cmp_buf, (int32_t)'T', num * DataBitsToBytes(data_bits));
3161 if (data_bits == 9U) {
3162 // If 9-bit mode is used zero out unused bits in high byte
3163 for (i = 1U; i < num * 2U; i += 2U) {
3164 ptr_cmp_buf[i] &= 0x01U;
3167 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
3169 // If data sent mismatches
3170 // Find on which byte mismatch starts
3171 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
3172 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
3176 if (operation == OP_RECEIVE) {
3177 // If sent was default Tx value, 'D' bytes
3178 (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]);
3180 // If sent was 'T' bytes
3181 (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]);
3184 // Assert data sent is same as expected
3185 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
3188 #else // If Test Mode Loopback is selected
3190 // Check all expected conditions after Receive and Send operation (in Loopback Test Mode)
3191 if (operation == OP_RECEIVE_SEND_LB) {
3192 if ((event & ARM_USART_EVENT_SEND_COMPLETE) == 0U) {
3193 // If send complete event was not signaled
3194 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_SEND_COMPLETE was not signaled");
3195 chk_tx_data = 0U; // Do not check sent content
3197 // Assert that ARM_USART_EVENT_SEND_COMPLETE was signaled
3198 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_SEND_COMPLETE) != 0U, msg_buf);
3199 if ((event & ARM_USART_EVENT_RECEIVE_COMPLETE) == 0U) {
3200 // If receive complete event was not signaled
3201 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_RECEIVE_COMPLETE was not signaled");
3202 chk_rx_data = 0U; // Do not check received content
3204 // Assert that ARM_USART_EVENT_RECEIVE_COMPLETE was signaled
3205 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RECEIVE_COMPLETE) != 0U, msg_buf);
3207 usart_stat = drv->GetStatus(); // Get USART status
3208 if (usart_stat.tx_busy != 0U) {
3209 // If tx_busy flag is still active
3210 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Tx busy still active after operation");
3211 chk_tx_data = 0U; // Do not check sent content
3213 // Assert that tx_busy flag is not active
3214 TEST_ASSERT_MESSAGE(usart_stat.tx_busy == 0U, msg_buf);
3215 if (usart_stat.rx_busy != 0U) {
3216 // If rx_busy flag is still active
3217 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Rx busy still active after operation");
3218 chk_rx_data = 0U; // Do not check received content
3220 // Assert that rx_busy flag is not active
3221 TEST_ASSERT_MESSAGE(usart_stat.rx_busy == 0U, msg_buf);
3223 if ((event & ARM_USART_EVENT_TX_UNDERFLOW) != 0U) {
3224 // If Tx underflow was signaled during the transfer
3225 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_TX_UNDERFLOW was signaled");
3226 chk_tx_data = 0U; // Do not check sent content
3228 // Assert that ARM_USART_EVENT_TX_UNDERFLOW was not signaled
3229 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_TX_UNDERFLOW) == 0U, msg_buf);
3231 if ((event & ARM_USART_EVENT_RX_OVERFLOW) != 0U) {
3232 // If Rx overflow was signaled during the transfer
3233 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_USART_EVENT_TX_UNDERFLOW was signaled");
3234 chk_rx_data = 0U; // Do not check received content
3236 // Assert that ARM_USART_EVENT_RX_OVERFLOW was not signaled
3237 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_OVERFLOW) == 0U, msg_buf);
3239 tx_count = drv->GetTxCount(); // Get Tx count
3240 if (tx_count != num) {
3241 // If Tx count is different then number of items, then operation has failed
3242 (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");
3243 chk_tx_data = 0U; // Do not check sent content
3245 // Assert that Tx count is equal to number of items requested for transfer
3246 TEST_ASSERT_MESSAGE(tx_count == num, msg_buf);
3248 rx_count = drv->GetRxCount(); // Get Rx count
3249 if (rx_count != num) {
3250 // If Rx count is different then number of items, then operation has failed
3251 (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");
3252 chk_rx_data = 0U; // Do not check received content
3254 // Assert that Rx count is equal to number of items requested for transfer
3255 TEST_ASSERT_MESSAGE(rx_count == num, msg_buf);
3257 if ((drv->GetStatus().tx_busy == 0U) && (drv->GetStatus().rx_busy == 0U) &&
3258 ((event & (ARM_USART_EVENT_RECEIVE_COMPLETE | ARM_USART_EVENT_SEND_COMPLETE)) ==
3259 (ARM_USART_EVENT_RECEIVE_COMPLETE | ARM_USART_EVENT_SEND_COMPLETE))) {
3260 // If transfer did not finish in time, abort it
3261 (void)drv->Control(ARM_USART_ABORT_TRANSFER, 0U);
3265 if ((chk_rx_data != 0U) && // If received content should be checked and
3266 (chk_tx_data != 0U)) { // if sent content should be checked
3267 stat = memcmp(ptr_rx_buf, ptr_tx_buf, num * DataBitsToBytes(data_bits));
3269 // If data received mismatches
3270 // Find on which byte mismatch starts
3271 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
3272 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
3276 (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]);
3278 // Assert that data received is same as expected
3279 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
3286 #if (USART_SERVER_USED == 1) // If Test Mode USART Server is selected
3287 TEST_FAIL_MESSAGE("[FAILED] Problems in communication with USART Server. Test aborted!");
3291 #endif // End of exclude form the documentation
3293 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3295 \brief Function: Function USART_Mode_Asynchronous
3297 The function \b USART_Mode_Asynchronous verifies data exchange:
3298 - in <b>Asynchronous</b> mode
3299 - with default data bits
3300 - with default parity
3301 - with default stop bits
3302 - with default flow control
3303 - at default baudrate
3304 - for default number of data items
3306 void USART_Mode_Asynchronous (void) {
3308 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3309 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; }
3311 #if (USART_SERVER_USED == 1)
3312 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);
3313 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);
3315 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);
3319 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3321 \brief Function: Function USART_Mode_Synchronous_Master
3323 The function \b USART_Mode_Synchronous_Master verifies data exchange:
3324 - in <b>Synchronous Master</b> mode
3325 - with default data bits
3328 - with no flow control
3329 - with default clock polarity
3330 - with default clock phase
3331 - at default baudrate
3332 - for default number of data items
3334 \note In Test Mode <b>Loopback</b> Receive function is not tested
3336 void USART_Mode_Synchronous_Master (void) {
3338 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3339 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; }
3341 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);
3342 #if (USART_SERVER_USED == 1)
3343 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);
3345 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);
3348 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3350 \brief Function: Function USART_Mode_Synchronous_Slave
3352 The function \b USART_Mode_Synchronous_Slave verifies data exchange:
3353 - in <b>Synchronous Slave</b> mode
3354 - with default data bits
3357 - with no flow control
3358 - with default clock polarity
3359 - with default clock phase
3360 - at default baudrate
3361 - for default number of data items
3363 \note In Test Mode <b>Loopback</b> this test is not executed
3365 void USART_Mode_Synchronous_Slave (void) {
3367 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3368 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3369 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; }
3371 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);
3372 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);
3373 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);
3376 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3378 \brief Function: Function USART_Mode_Single_Wire
3380 The function \b USART_Mode_Single_Wire verifies data exchange:
3381 - in <b>Single-Wire</b> mode
3382 - with default data bits
3383 - with default parity
3384 - with default stop bits
3385 - with no flow control
3386 - at default baudrate
3387 - for default number of data items
3389 \note In Test Mode <b>Loopback</b> this test is not executed
3391 void USART_Mode_Single_Wire (void) {
3393 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3394 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3395 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; }
3397 #if (USART_SERVER_USED == 1)
3398 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);
3399 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);
3401 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);
3405 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3407 \brief Function: Function USART_Mode_IrDA
3409 The function \b USART_Mode_IrDA verifies data exchange:
3410 - in <b>Infra-red Data</b> mode
3411 - with default data bits
3412 - with default parity
3413 - with default stop bits
3414 - with default flow control
3415 - at default baudrate
3416 - for default number of data items
3418 \note In Test Mode <b>Loopback</b> this test is not executed
3420 void USART_Mode_IrDA (void) {
3422 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3423 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3424 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; }
3426 #if (USART_SERVER_USED == 1)
3427 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);
3428 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);
3430 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);
3434 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3436 \brief Function: Function USART_Data_Bits_5
3438 The function \b USART_Data_Bits_5 verifies data exchange:
3440 - with <b>5 data bits</b>
3441 - with default parity
3442 - with default stop bits
3443 - with default flow control
3444 - with default clock polarity
3445 - with default clock phase
3446 - at default baudrate
3447 - for default number of data items
3449 \note In Test Mode <b>Loopback</b> this test is not executed
3451 void USART_Data_Bits_5 (void) {
3453 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3454 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3455 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; }
3457 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);
3458 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);
3459 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3460 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);
3464 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3466 \brief Function: Function USART_Data_Bits_6
3468 The function \b USART_Data_Bits_6 verifies data exchange:
3470 - with <b>6 data bits</b>
3471 - with default parity
3472 - with default stop bits
3473 - with default flow control
3474 - with default clock polarity
3475 - with default clock phase
3476 - at default baudrate
3477 - for default number of data items
3479 \note In Test Mode <b>Loopback</b> this test is not executed
3481 void USART_Data_Bits_6 (void) {
3483 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3484 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3485 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; }
3487 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);
3488 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);
3489 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3490 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);
3494 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3496 \brief Function: Function USART_Data_Bits_7
3498 The function \b USART_Data_Bits_7 verifies data exchange:
3500 - with <b>7 data bits</b>
3501 - with default parity
3502 - with default stop bits
3503 - with default flow control
3504 - with default clock polarity
3505 - with default clock phase
3506 - at default baudrate
3507 - for default number of data items
3509 \note In Test Mode <b>Loopback</b> this test is not executed
3511 void USART_Data_Bits_7 (void) {
3513 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3514 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3515 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; }
3517 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);
3518 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);
3519 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3520 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);
3524 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3526 \brief Function: Function USART_Data_Bits_8
3528 The function \b USART_Data_Bits_8 verifies data exchange:
3530 - with <b>8 data bits</b>
3531 - with default parity
3532 - with default stop bits
3533 - with default flow control
3534 - with default clock polarity
3535 - with default clock phase
3536 - at default baudrate
3537 - for default number of data items
3539 void USART_Data_Bits_8 (void) {
3541 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3542 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; }
3544 #if (USART_SERVER_USED == 1)
3545 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);
3546 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);
3547 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3548 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);
3551 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);
3555 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3557 \brief Function: Function USART_Data_Bits_9
3559 The function \b USART_Data_Bits_9 verifies data exchange:
3561 - with <b>9 data bits</b>
3562 - with default parity
3563 - with default stop bits
3564 - with default flow control
3565 - with default clock polarity
3566 - with default clock phase
3567 - at default baudrate
3568 - for default number of data items
3570 \note In Test Mode <b>Loopback</b> this test is not executed
3572 void USART_Data_Bits_9 (void) {
3574 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3575 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3576 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; }
3578 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);
3579 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);
3580 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3581 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);
3585 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3587 \brief Function: Function USART_Parity_None
3589 The function \b USART_Parity_None verifies data exchange:
3591 - with default data bits
3592 - with <b>no parity</b>
3593 - with default stop bits
3594 - with default flow control
3595 - with default clock polarity
3596 - with default clock phase
3597 - at default baudrate
3598 - for default number of data items
3600 void USART_Parity_None (void) {
3602 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3603 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; }
3605 #if (USART_SERVER_USED == 1)
3606 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);
3607 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);
3608 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3609 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);
3612 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);
3616 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3618 \brief Function: Function USART_Parity_Even
3620 The function \b USART_Parity_Even verifies data exchange:
3622 - with default data bits
3623 - with <b>even parity</b>
3624 - with default stop bits
3625 - with default flow control
3626 - at default baudrate
3627 - for default number of data items
3629 \note This test is not executed if any of the following settings are selected:
3630 - Test Mode <b>Loopback</b>
3631 - Tests Default Mode <b>Synchronous Master/Slave</b>
3633 void USART_Parity_Even (void) {
3635 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3636 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3637 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3638 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; }
3640 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);
3641 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);
3644 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3646 \brief Function: Function USART_Parity_Odd
3648 The function \b USART_Parity_Odd verifies data exchange:
3650 - with default data bits
3651 - with <b>odd parity</b>
3652 - with default stop bits
3653 - with default flow control
3654 - at default baudrate
3655 - for default number of data items
3657 \note This test is not executed if any of the following settings are selected:
3658 - Test Mode <b>Loopback</b>
3659 - Tests Default Mode <b>Synchronous Master/Slave</b>
3661 void USART_Parity_Odd (void) {
3663 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3664 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3665 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3666 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; }
3668 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);
3669 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);
3672 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3674 \brief Function: Function USART_Stop_Bits_1
3676 The function \b USART_Stop_Bits_1 verifies data exchange:
3678 - with default data bits
3679 - with default parity
3680 - with <b>1 stop bit</b>
3681 - with default flow control
3682 - with default clock polarity
3683 - with default clock phase
3684 - at default baudrate
3685 - for default number of data items
3687 void USART_Stop_Bits_1 (void) {
3689 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3690 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; }
3692 #if (USART_SERVER_USED == 1)
3693 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);
3694 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);
3695 #if ((USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_MASTER) || (USART_CFG_DEF_MODE == MODE_SYNCHRONOUS_SLAVE))
3696 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);
3699 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);
3703 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3705 \brief Function: Function USART_Stop_Bits_2
3707 The function \b USART_Stop_Bits_2 verifies data exchange:
3709 - with default data bits
3710 - with default parity
3711 - with <b>2 stop bits</b>
3712 - with default flow control
3713 - at default baudrate
3714 - for default number of data items
3716 \note This test is not executed if any of the following settings are selected:
3717 - Test Mode <b>Loopback</b>
3718 - Tests Default Mode <b>Synchronous Master/Slave</b>
3720 void USART_Stop_Bits_2 (void) {
3722 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3723 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3724 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3725 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; }
3727 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);
3728 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);
3731 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3733 \brief Function: Function USART_Stop_Bits_1_5
3735 The function \b USART_Stop_Bits_1_5 verifies data exchange:
3737 - with default data bits
3738 - with default parity
3739 - with <b>1.5 stop bits</b>
3740 - with default flow control
3741 - at default baudrate
3742 - for default number of data items
3744 \note This test is not executed if any of the following settings are selected:
3745 - Test Mode <b>Loopback</b>
3746 - Tests Default Mode <b>Synchronous Master/Slave</b>
3748 void USART_Stop_Bits_1_5 (void) {
3750 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3751 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3752 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3753 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; }
3755 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);
3756 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);
3759 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3761 \brief Function: Function USART_Stop_Bits_0_5
3763 The function \b USART_Stop_Bits_0_5 verifies data exchange:
3765 - with default data bits
3766 - with default parity
3767 - with <b>0.5 stop bits</b>
3768 - with default flow control
3769 - at default baudrate
3770 - for default number of data items
3772 \note This test is not executed if any of the following settings are selected:
3773 - Test Mode <b>Loopback</b>
3774 - Tests Default Mode <b>Synchronous Master/Slave</b>
3776 void USART_Stop_Bits_0_5 (void) {
3778 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3779 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3780 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3781 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; }
3783 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);
3784 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);
3787 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3789 \brief Function: Function USART_Flow_Control_None
3791 The function \b USART_Flow_Control_None verifies data exchange:
3793 - with default data bits
3794 - with default parity
3795 - with default stop bits
3796 - with <b>no flow control</b>
3797 - with default clock polarity
3798 - with default clock phase
3799 - at default baudrate
3800 - for default number of data items
3802 void USART_Flow_Control_None (void) {
3804 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3805 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; }
3807 #if (USART_SERVER_USED == 1)
3808 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);
3809 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);
3811 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);
3815 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3817 \brief Function: Function USART_Flow_Control_RTS
3819 The function \b USART_Flow_Control_RTS verifies functionality of the RTS line flow control by
3820 trying to receive half of default number of data items, after that, RTS line should
3821 be deactivated by the USART Client hardware and USART Server should stop sending further data.
3823 The RTS line flow control functionality is tested with following settings:
3825 - with default data bits
3826 - with default parity
3827 - with default stop bits
3828 - with <b>flow control using RTS signal</b>
3829 - at default baudrate
3831 Test procedure consists of the following steps:
3832 - start reception of half of default number of items
3833 - after half of default number of items was received
3834 the RTS line should go to inactive state
3835 - USART Server after seeing that its CTS line (USART Clients RTS line)
3836 went to inactive state should stop sending further data
3837 - after timeout read from USART Server the number of items it has sent
3838 and assert that it is less than default number of items
3840 \note This test is not executed if any of the following settings are selected:
3841 - Test Mode <b>Loopback</b>
3842 - Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b>
3844 void USART_Flow_Control_RTS (void) {
3846 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3847 #if (USART_SERVER_USED == 1)
3848 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3849 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3850 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3851 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; }
3854 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3855 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; }
3856 if (CmdXfer (0U, USART_CFG_DEF_NUM, 10U, USART_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
3858 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
3859 USART_CFG_DEF_DATA_BITS_VAL |
3860 USART_CFG_DEF_PARITY_VAL |
3861 USART_CFG_DEF_STOP_BITS_VAL |
3862 ARM_USART_FLOW_CONTROL_RTS ,
3863 USART_CFG_DEF_BAUDRATE);
3867 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
3869 TEST_ASSERT(drv->Receive(ptr_rx_buf, USART_CFG_DEF_NUM / 2U) == ARM_DRIVER_OK);
3870 (void)osDelay(USART_CFG_XFER_TIMEOUT + 20U); // Wait for USART Server to timeout the XFER command
3872 // Abort and disable reception
3873 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
3874 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
3878 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3879 if (CmdGetCnt() != EXIT_SUCCESS) { break; }
3880 TEST_ASSERT_MESSAGE(xfer_count < USART_CFG_DEF_NUM, "[FAILED] All data was received, RTS line is not working!");
3882 if (CmdGetVer() != EXIT_SUCCESS) { break; }
3889 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3891 \brief Function: Function USART_Flow_Control_CTS
3893 The function \b USART_Flow_Control_CTS verifies functionality of the CTS line flow control by
3894 trying to send default number of data items, while at half of transmitted number
3895 of items the USART Server deactivates its RTS line (it is connected to CTS line on the USART Client).
3897 The CTS line flow control functionality is tested with following settings:
3899 - with default data bits
3900 - with default parity
3901 - with default stop bits
3902 - with <b>flow control using CTS signal</b>
3903 - at default baudrate
3905 Test procedure consists of the following steps:
3906 - start send of default number of items
3907 - after USART Server receives half of default number of items it
3908 will drive its RTS line (USART Clients CTS line) inactive
3909 - before timeout check that tx_busy is active and that number of transmitted items is less than default number of items
3911 \note This test is not executed if any of the following settings are selected:
3912 - Test Mode <b>Loopback</b>
3913 - Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b>
3915 void USART_Flow_Control_CTS (void) {
3917 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3918 #if (USART_SERVER_USED == 1)
3919 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3920 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3921 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3922 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; }
3925 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3926 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; }
3927 if (CmdXfer (1U, USART_CFG_DEF_NUM, 0U, USART_CFG_XFER_TIMEOUT, USART_CFG_DEF_NUM / 2U) != EXIT_SUCCESS) { break; }
3929 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
3930 USART_CFG_DEF_DATA_BITS_VAL |
3931 USART_CFG_DEF_PARITY_VAL |
3932 USART_CFG_DEF_STOP_BITS_VAL |
3933 ARM_USART_FLOW_CONTROL_CTS ,
3934 USART_CFG_DEF_BAUDRATE);
3937 (void)osDelay(10U); // Wait for USART Server to start reception
3939 (void)drv->Control(ARM_USART_CONTROL_TX, 1U);
3940 TEST_ASSERT(drv->Send(ptr_tx_buf, USART_CFG_DEF_NUM) == ARM_DRIVER_OK);
3941 (void)osDelay(USART_CFG_XFER_TIMEOUT / 2U); // Wait for half of timeout, after which sending should have stopped
3943 // Assert that tx_busy is still active
3944 TEST_ASSERT_MESSAGE(drv->GetStatus().tx_busy != 0U, "[FAILED] Send has finished, CTS line is not working!");
3946 // Assert that tx count is not 0
3947 TEST_ASSERT_MESSAGE(drv->GetTxCount() != 0U, "[FAILED] No data was sent, CTS line is not working!");
3949 // Assert that tx count is less than default number of items
3950 TEST_ASSERT_MESSAGE(drv->GetTxCount() < USART_CFG_DEF_NUM, "[FAILED] All data was sent, CTS line is not working!");
3952 (void)osDelay(USART_CFG_XFER_TIMEOUT / 2U); // Wait for USART Server to timeout the XFER command
3954 // Abort and disable transmission
3955 (void)drv->Control(ARM_USART_ABORT_SEND, 0U);
3956 (void)drv->Control(ARM_USART_CONTROL_TX, 0U);
3958 (void)osDelay(10U); // Wait for USART Server to prepare for reception of new command
3960 // Do a dummy send command to flush any data left-over from previous send
3961 // (When flow control CTS is used the send is started for default number of items.
3962 // After half of default number of items are sent the CTS line is deasserted,
3963 // but data register was already loaded with next item to be sent.
3964 // To get rid of this loaded data we send a dummy command that USART Server will
3965 // ignore, but it will allow us to send next command properly.)
3966 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3967 (void)ComSendCommand("Dummy", 5U);
3969 (void)osDelay(USART_CFG_SRV_CMD_TOUT+10U); // Wait for USART Server to timeout the "Dummy" command
3976 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3978 \brief Function: Function USART_Flow_Control_RTS_CTS
3980 The function \b USART_Flow_Control_RTS_CTS verifies functionality of RTS And CTS lines.
3981 It calls function USART_Flow_Control_RTS that checks RTS line functionality, and
3982 USART_Flow_Control_CTS that checks CTS line functionality.
3984 \note This test is not executed if any of the following settings are selected:
3985 - Test Mode <b>Loopback</b>
3986 - Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b>
3988 void USART_Flow_Control_RTS_CTS (void) {
3990 USART_Flow_Control_RTS();
3991 USART_Flow_Control_CTS();
3994 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3996 \brief Function: Function USART_Clock_Pol0_Pha0
3998 The function \b USART_Clock_Pol0_Pha0 verifies data exchange:
4000 - with default data bits
4003 - with no flow control
4004 - with <b>clock polarity 0</b>
4005 - with <b>clock phase 0</b>
4006 - at default baudrate
4007 - for default number of data items
4009 \note This test is not executed if any of the following settings are selected:
4010 - Test Mode <b>Loopback</b>
4011 - Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b>
4013 void USART_Clock_Pol0_Pha0 (void) {
4015 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4016 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4017 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4018 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; }
4020 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);
4021 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);
4022 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);
4025 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4027 \brief Function: Function USART_Clock_Pol0_Pha1
4029 The function \b USART_Clock_Pol0_Pha1 verifies data exchange:
4031 - with default data bits
4034 - with no flow control
4035 - with <b>clock polarity 0</b>
4036 - with <b>clock phase 1</b>
4037 - at default baudrate
4038 - for default number of data items
4040 \note This test is not executed if any of the following settings are selected:
4041 - Test Mode <b>Loopback</b>
4042 - Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b>
4044 void USART_Clock_Pol0_Pha1 (void) {
4046 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4047 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4048 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4049 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; }
4051 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);
4052 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);
4053 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);
4056 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4058 \brief Function: Function USART_Clock_Pol1_Pha0
4060 The function \b USART_Clock_Pol1_Pha0 verifies data exchange:
4062 - with default data bits
4065 - with no flow control
4066 - with <b>clock polarity 1</b>
4067 - with <b>clock phase 0</b>
4068 - at default baudrate
4069 - for default number of data items
4071 \note This test is not executed if any of the following settings are selected:
4072 - Test Mode <b>Loopback</b>
4073 - Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b>
4075 void USART_Clock_Pol1_Pha0 (void) {
4077 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4078 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4079 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4080 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; }
4082 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);
4083 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);
4084 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);
4087 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4089 \brief Function: Function USART_Clock_Pol1_Pha1
4091 The function \b USART_Clock_Pol1_Pha1 verifies data exchange:
4093 - with default data bits
4096 - with no flow control
4097 - with <b>clock polarity 1</b>
4098 - with <b>clock phase 1</b>
4099 - at default baudrate
4100 - for default number of data items
4102 \note This test is not executed if any of the following settings are selected:
4103 - Test Mode <b>Loopback</b>
4104 - Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b>
4106 void USART_Clock_Pol1_Pha1 (void) {
4108 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4109 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4110 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4111 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; }
4113 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);
4114 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);
4115 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);
4118 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4120 \brief Function: Function USART_Baudrate_Min
4122 The function \b USART_Baudrate_Min verifies data exchange:
4124 - with default data bits
4125 - with default parity
4126 - with default stop bits
4127 - with default flow control
4128 - with default clock polarity
4129 - with default clock phase
4130 - at <b>minimum baudrate</b> (define <c>USART_CFG_MIN_BAUDRATE</c> in DV_USART_Config.h)
4131 - for default number of data items
4133 This test function checks the following requirement:
4134 - measured bus speed for Send operation in Test Mode <b>USART Server</b> or Send/Receive operation in Test Mode <b>Loopback</b>
4135 is not 25% lower, or higher than requested
4137 void USART_Baudrate_Min (void) {
4138 volatile uint64_t br;
4139 volatile int32_t got_baudrate;
4141 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4142 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; }
4144 #if (USART_SERVER_USED == 1)
4145 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);
4146 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);
4148 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);
4151 if (duration != 0xFFFFFFFFU) { // If Transfer finished before timeout
4152 if (duration != 0U) { // If duration of transfer was more than 0 SysTick counts
4153 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;
4154 if ((br < ((USART_CFG_MIN_BAUDRATE * 3) / 4)) ||
4155 (br > USART_CFG_MIN_BAUDRATE)) {
4156 // If measured baudrate is 25% lower, or higher than requested
4157 (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);
4158 TEST_MESSAGE(msg_buf);
4164 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4166 \brief Function: Function USART_Baudrate_Max
4168 The function \b USART_Baudrate_Max verifies data exchange:
4170 - with default data bits
4171 - with default parity
4172 - with default stop bits
4173 - with default flow control
4174 - with default clock polarity
4175 - with default clock phase
4176 - at <b>maximum baudrate</b> (define <c>USART_CFG_MAX_BAUDRATE</c> in DV_USART_Config.h)
4177 - for default number of data items
4179 This test function checks the following requirement:
4180 - measured bus speed for Send operation in Test Mode <b>USART Server</b> or Send/Receive operation in Test Mode <b>Loopback</b>
4181 is not 25% lower, or higher than requested
4183 void USART_Baudrate_Max (void) {
4184 volatile uint64_t br;
4185 volatile int32_t got_baudrate;
4187 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4188 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4190 #if (USART_SERVER_USED == 1)
4191 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_MAX_BAUDRATE, USART_CFG_DEF_NUM);
4192 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_MAX_BAUDRATE, USART_CFG_DEF_NUM);
4194 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_MAX_BAUDRATE, USART_CFG_DEF_NUM);
4197 if (duration != 0xFFFFFFFFU) { // If Transfer finished before timeout
4198 if (duration != 0U) { // If duration of transfer was more than 0 SysTick counts
4199 br = ((uint64_t)systick_freq * (1U + USART_CFG_DEF_DATA_BITS + USART_CFG_DEF_STOP_BITS + (uint32_t)(USART_CFG_DEF_PARITY != PARITY_NONE)) * USART_CFG_DEF_NUM) / duration;
4200 if ((br < ((USART_CFG_MAX_BAUDRATE * 3) / 4)) ||
4201 (br > USART_CFG_MAX_BAUDRATE)) {
4202 // If measured baudrate is 25% lower, or higher than requested
4203 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] At requested baudrate of %i bauds, effective transfer speed is %i bauds", USART_CFG_MAX_BAUDRATE, (uint32_t)br);
4204 TEST_MESSAGE(msg_buf);
4210 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4212 \brief Function: Function USART_Number_Of_Items
4214 The function \b USART_Number_Of_Items verifies data exchange:
4216 - with default data bits
4217 - with default parity
4218 - with default stop bits
4219 - with default flow control
4220 - with default clock polarity
4221 - with default clock phase
4222 - at default baudrate
4223 - for <b>different number of items</b> (defines <c>USART_CFG_NUM1 .. USART_CFG_NUM5</c> in DV_USART_Config.h)
4225 void USART_Number_Of_Items (void) {
4227 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4228 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4230 #if (USART_CFG_NUM1 != 0U)
4231 #if (USART_SERVER_USED == 1)
4232 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM1);
4233 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM1);
4235 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM1);
4239 #if (USART_CFG_NUM2 != 0U)
4240 #if (USART_SERVER_USED == 1)
4241 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM2);
4242 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM2);
4244 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM2);
4248 #if (USART_CFG_NUM3 != 0U)
4249 #if (USART_SERVER_USED == 1)
4250 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM3);
4251 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM3);
4253 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM3);
4257 #if (USART_CFG_NUM4 != 0U)
4258 #if (USART_SERVER_USED == 1)
4259 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM4);
4260 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM4);
4262 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM4);
4266 #if (USART_CFG_NUM5 != 0U)
4267 #if (USART_SERVER_USED == 1)
4268 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM5);
4269 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM5);
4271 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_NUM5);
4276 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4278 \brief Function: Function USART_GetTxCount
4280 The function \b USART_GetTxCount verifies \b GetTxCount function (count changing) during data exchange (Send):
4282 - with default data bits
4283 - with default parity
4284 - with default stop bits
4285 - with default flow control
4286 - with default clock polarity
4287 - with default clock phase
4288 - at default baudrate
4290 void USART_GetTxCount (void) {
4292 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4293 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4295 USART_DataExchange_Operation(OP_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4296 TEST_ASSERT_MESSAGE((tx_count_sample != 0U) && (tx_count_sample != USART_CFG_DEF_NUM), "[FAILED] GetTxCount was not changing during the Send!");
4299 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4301 \brief Function: Function USART_GetRxCount
4303 The function \b USART_GetRxCount verifies \b GetRxCount function (count changing) during data exchange (Receive):
4305 - with default data bits
4306 - with default parity
4307 - with default stop bits
4308 - with default flow control
4309 - with default clock polarity
4310 - with default clock phase
4311 - at default baudrate
4313 void USART_GetRxCount (void) {
4315 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4316 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4318 #if (USART_SERVER_USED == 1)
4319 USART_DataExchange_Operation(OP_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4321 USART_DataExchange_Operation(OP_RECEIVE_SEND_LB, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4325 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4327 \brief Function: Function USART_GetTxRxCount
4329 The function \b USART_GetTxRxCount verifies \b GetTxCount and \b GetRxCount functions (count changing) during data exchange (Transfer):
4331 - with default data bits
4334 - with no flow control
4335 - with default clock polarity
4336 - with default clock phase
4337 - at default baudrate
4339 \note If Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b> is selected this test is not executed
4341 void USART_GetTxRxCount (void) {
4343 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4344 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4345 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4347 USART_DataExchange_Operation(OP_TRANSFER, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4348 TEST_ASSERT_MESSAGE((tx_count_sample != 0U) && (tx_count_sample != USART_CFG_DEF_NUM), "[FAILED] GetTxCount was not changing during the Transfer!");
4349 TEST_ASSERT_MESSAGE((rx_count_sample != 0U) && (rx_count_sample != USART_CFG_DEF_NUM), "[FAILED] GetRxCount was not changing during the Transfer!");
4352 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4354 \brief Function: Function USART_AbortSend
4356 The function \b USART_AbortSend verifies \b Abort function abort of data exchange (Send):
4358 - with default data bits
4359 - with default parity
4360 - with default stop bits
4361 - with default flow control
4362 - at default baudrate
4364 void USART_AbortSend (void) {
4366 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4367 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4369 USART_DataExchange_Operation(OP_ABORT_SEND, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4372 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4374 \brief Function: Function USART_AbortReceive
4376 The function \b USART_AbortReceive verifies \b Abort function abort of data exchange (Receive):
4378 - with default data bits
4379 - with default parity
4380 - with default stop bits
4381 - with default flow control
4382 - with default clock polarity
4383 - with default clock phase
4384 - at default baudrate
4386 void USART_AbortReceive (void) {
4388 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4389 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4391 USART_DataExchange_Operation(OP_ABORT_RECEIVE, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, USART_CFG_DEF_FLOW_CONTROL, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4394 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4396 \brief Function: Function USART_AbortTransfer
4398 The function \b USART_AbortTransfer verifies \b Abort function abort of data exchange (Transfer):
4400 - with default data bits
4403 - with no flow control
4404 - with default clock polarity
4405 - with default clock phase
4406 - at default baudrate
4408 \note If Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b> is selected this test is not executed
4410 void USART_AbortTransfer (void) {
4412 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4413 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4414 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4416 USART_DataExchange_Operation(OP_ABORT_TRANSFER, USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, PARITY_NONE, STOP_BITS_1, FLOW_CONTROL_NONE, USART_CFG_DEF_CPOL, USART_CFG_DEF_CPHA, USART_CFG_DEF_BAUDRATE, USART_CFG_DEF_NUM);
4419 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4421 \brief Function: Function USART_TxBreak
4423 The function \b USART_TxBreak verifies Break signaling:
4425 - with default data bits
4426 - with default parity
4427 - with default stop bits
4428 - with no flow control
4429 - at default baudrate
4431 \note This test is not executed if any of the following settings are selected:
4432 - Test Mode <b>Loopback</b>
4433 - Tests Default Mode <b>Synchronous Master/Slave</b>
4435 void USART_TxBreak (void) {
4437 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4438 #if (USART_SERVER_USED == 1)
4439 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4440 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4441 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4444 // Dummy read break status to clear it
4445 if (CmdGetBrk() != EXIT_SUCCESS) { break; }
4447 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4448 if (CmdSetCom (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, 0U, 0U, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { break; }
4450 // Instruct USART Server to receive data so it can detect Break
4451 if (CmdXfer (1U, USART_CFG_DEF_NUM, 0U, USART_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
4453 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4454 USART_CFG_DEF_DATA_BITS_VAL |
4455 USART_CFG_DEF_PARITY_VAL |
4456 USART_CFG_DEF_STOP_BITS_VAL |
4457 ARM_USART_FLOW_CONTROL_NONE ,
4458 USART_CFG_DEF_BAUDRATE);
4462 (void)osDelay(10U); // Wait for USART Server to start reception
4464 (void)drv->Control(ARM_USART_CONTROL_TX, 1U);
4467 TEST_ASSERT(drv->Control(ARM_USART_CONTROL_BREAK, 1U) == ARM_DRIVER_OK);
4469 TEST_ASSERT(drv->Control(ARM_USART_CONTROL_BREAK, 0U) == ARM_DRIVER_OK);
4472 (void)drv->Control(ARM_USART_CONTROL_TX, 0U);
4474 (void)osDelay(USART_CFG_XFER_TIMEOUT + 10U); // Wait for USART Server to timeout the XFER command
4476 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4477 if (CmdGetBrk() != EXIT_SUCCESS) { break; }
4478 TEST_ASSERT_MESSAGE(break_status == 1U, "[FAILED] Break was not detected on USART Server!");
4480 (void)osDelay(10U); // Wait for USART Server to prepare for reception of new command
4490 // End of usart_tests_data_xchg
4492 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4493 /* USART Modem Lines tests */
4494 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4496 \defgroup usart_tests_modem Modem Lines
4497 \ingroup usart_tests
4499 These tests verify API and operation of the USART modem lines handling functions.
4501 The data exchange tests verify the following driver functions
4502 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html" target="_blank">USART Driver function documentation</a>):
4503 - \b SetModemControl
4505 int32_t SetModemControl (ARM_USART_MODEM_CONTROL control);
4509 ARM_USART_MODEM_STATUS GetModemStatus (void);
4512 \note These tests are not executed if any of the following settings are selected:
4513 - Test Mode <b>Loopback</b>
4514 - Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b>
4518 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4520 \brief Function: Function USART_Modem_RTS
4522 The function \b USART_Modem_RTS verifies driving of modem line Request To Send (RTS):
4524 - with default data bits
4525 - with default parity
4526 - with default stop bits
4527 - with no flow control
4528 - at default baudrate
4530 void USART_Modem_RTS (void) {
4532 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4533 #if (USART_SERVER_USED == 1)
4534 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4535 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4536 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4537 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, RTS_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4540 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4542 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4543 USART_CFG_DEF_DATA_BITS_VAL |
4544 USART_CFG_DEF_PARITY_VAL |
4545 USART_CFG_DEF_STOP_BITS_VAL |
4546 ARM_USART_FLOW_CONTROL_NONE ,
4547 USART_CFG_DEF_BAUDRATE);
4549 TEST_ASSERT(drv->SetModemControl(ARM_USART_RTS_CLEAR) == ARM_DRIVER_OK);
4552 if (CmdGetMdm() != EXIT_SUCCESS) { break; }
4554 TEST_ASSERT_MESSAGE((modem_status & 0x1U) == 0x0U, "[FAILED] CTS line on USART Server is not in inactive state!");
4556 TEST_ASSERT(drv->SetModemControl(ARM_USART_RTS_SET) == ARM_DRIVER_OK);
4559 if (CmdGetMdm() != EXIT_SUCCESS) { break; }
4561 TEST_ASSERT_MESSAGE((modem_status & 0x1U) == 0x1U, "[FAILED] CTS line on USART Server is not in active state!");
4563 (void)drv->SetModemControl(ARM_USART_RTS_CLEAR);
4565 // Give USART Server 10 ms to prepare for reception of the next command
4573 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4575 \brief Function: Function USART_Modem_DTR
4577 The function \b USART_Modem_DTR verifies driving of modem line Data Terminal Ready (DTR):
4579 - with default data bits
4580 - with default parity
4581 - with default stop bits
4582 - with no flow control
4583 - at default baudrate
4585 void USART_Modem_DTR (void) {
4587 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4588 #if (USART_SERVER_USED == 1)
4589 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4590 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4591 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4592 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, DTR_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4595 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4597 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4598 USART_CFG_DEF_DATA_BITS_VAL |
4599 USART_CFG_DEF_PARITY_VAL |
4600 USART_CFG_DEF_STOP_BITS_VAL |
4601 ARM_USART_FLOW_CONTROL_NONE ,
4602 USART_CFG_DEF_BAUDRATE);
4604 TEST_ASSERT(drv->SetModemControl(ARM_USART_DTR_CLEAR) == ARM_DRIVER_OK);
4607 if (CmdGetMdm() != EXIT_SUCCESS) { break; }
4609 TEST_ASSERT_MESSAGE((modem_status & 0x2U) == 0x0U, "[FAILED] DSR line on USART Server is not in inactive state!");
4611 TEST_ASSERT(drv->SetModemControl(ARM_USART_DTR_SET) == ARM_DRIVER_OK);
4614 if (CmdGetMdm() != EXIT_SUCCESS) { break; }
4616 TEST_ASSERT_MESSAGE((modem_status & 0x2U) == 0x2U, "[FAILED] DSR line on USART Server is not in active state!");
4618 (void)drv->SetModemControl(ARM_USART_DTR_CLEAR);
4620 // Give USART Server 10 ms to prepare for reception of the next command
4628 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4630 \brief Function: Function USART_Modem_CTS
4632 The function \b USART_Modem_CTS verifies read of modem line Clear To Send (CTS):
4634 - with default data bits
4635 - with default parity
4636 - with default stop bits
4637 - with no flow control
4638 - at default baudrate
4640 void USART_Modem_CTS (void) {
4642 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4643 #if (USART_SERVER_USED == 1)
4644 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4645 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4646 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4647 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, CTS_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4650 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4652 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4653 USART_CFG_DEF_DATA_BITS_VAL |
4654 USART_CFG_DEF_PARITY_VAL |
4655 USART_CFG_DEF_STOP_BITS_VAL |
4656 ARM_USART_FLOW_CONTROL_NONE ,
4657 USART_CFG_DEF_BAUDRATE);
4659 // Instruct USART Server to drive RTS to active state for 20 ms
4660 // RTS line from USART Server should be connected to CTS line on the USART Client (DUT)
4661 if (CmdSetMdm(RTS_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
4665 TEST_ASSERT_MESSAGE(drv->GetModemStatus().cts == 1U, "[FAILED] CTS line not active!");
4667 // Give USART Server 20 ms to finish SET MDM command and prepare for reception of the next command
4675 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4677 \brief Function: Function USART_Modem_DSR
4679 The function \b USART_Modem_DSR verifies read of modem line Data Set Ready (DSR):
4681 - with default data bits
4682 - with default parity
4683 - with default stop bits
4684 - with no flow control
4685 - at default baudrate
4687 void USART_Modem_DSR (void) {
4689 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4690 #if (USART_SERVER_USED == 1)
4691 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4692 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4693 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4694 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, DSR_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4697 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4699 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4700 USART_CFG_DEF_DATA_BITS_VAL |
4701 USART_CFG_DEF_PARITY_VAL |
4702 USART_CFG_DEF_STOP_BITS_VAL |
4703 ARM_USART_FLOW_CONTROL_NONE ,
4704 USART_CFG_DEF_BAUDRATE);
4706 // Instruct USART Server to drive DTR to active state for 20 ms
4707 // DTR line from USART Server should be connected to DSR line on the USART Client (DUT)
4708 if (CmdSetMdm(DTR_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
4712 TEST_ASSERT_MESSAGE(drv->GetModemStatus().dsr == 1U, "[FAILED] DSR line not active!");
4714 // Give USART Server 20 ms to finish SET MDM command and prepare for reception of the next command
4722 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4724 \brief Function: Function USART_Modem_DCD
4726 The function \b USART_Modem_DCD verifies read of modem line Data Carrier Detect (DCD):
4728 - with default data bits
4729 - with default parity
4730 - with default stop bits
4731 - with no flow control
4732 - at default baudrate
4734 void USART_Modem_DCD (void) {
4736 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4737 #if (USART_SERVER_USED == 1)
4738 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4739 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4740 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4741 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, DCD_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4744 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4746 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4747 USART_CFG_DEF_DATA_BITS_VAL |
4748 USART_CFG_DEF_PARITY_VAL |
4749 USART_CFG_DEF_STOP_BITS_VAL |
4750 ARM_USART_FLOW_CONTROL_NONE ,
4751 USART_CFG_DEF_BAUDRATE);
4753 // Instruct USART Server to drive DTR to active state for 20 ms
4754 if (CmdSetMdm(TO_DCD_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
4758 TEST_ASSERT_MESSAGE(drv->GetModemStatus().dcd == 1U, "[FAILED] DCD line not active!");
4760 // Give USART Server 20 ms to finish SET MDM command and prepare for reception of the next command
4768 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4770 \brief Function: Function USART_Modem_RI
4772 The function \b USART_Modem_RI verifies read of modem line Ring Indicator (RI):
4774 - with default data bits
4775 - with default parity
4776 - with default stop bits
4777 - with no flow control
4778 - at default baudrate
4780 void USART_Modem_RI (void) {
4782 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4783 #if (USART_SERVER_USED == 1)
4784 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4785 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4786 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4787 if (SettingsCheck (USART_CFG_DEF_MODE, USART_CFG_DEF_DATA_BITS, USART_CFG_DEF_PARITY, USART_CFG_DEF_STOP_BITS, FLOW_CONTROL_NONE, RI_AVAILABLE, USART_CFG_DEF_BAUDRATE) != EXIT_SUCCESS) { TEST_FAIL(); return; }
4790 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4792 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4793 USART_CFG_DEF_DATA_BITS_VAL |
4794 USART_CFG_DEF_PARITY_VAL |
4795 USART_CFG_DEF_STOP_BITS_VAL |
4796 ARM_USART_FLOW_CONTROL_NONE ,
4797 USART_CFG_DEF_BAUDRATE);
4799 // Instruct USART Server to drive RI to active state for 20 ms
4800 if (CmdSetMdm(TO_RI_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
4804 TEST_ASSERT_MESSAGE(drv->GetModemStatus().ri == 1U, "[FAILED] RI line not active!");
4806 // Give USART Server 20 ms to finish SET MDM command and prepare for reception of the next command
4817 // End of usart_tests_modem
4819 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4820 /* USART Event tests */
4821 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4823 \defgroup usart_tests_evt Event
4824 \ingroup usart_tests
4826 These tests verify API and operation of the USART event signaling, except ARM_USART_EVENT_SEND_COMPLETE,
4827 ARM_USART_EVENT_RECEIVE_COMPLETE, ARM_USART_EVENT_TRANSFER_COMPLETE and ARM_USART_EVENT_TX_COMPLETE signals
4828 which is tested in the Data Exchange tests.
4830 The event tests verify the following driver function
4831 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html" target="_blank">USART Driver function documentation</a>):
4834 void (*ARM_USART_SignalEvent_t) (uint32_t event);
4837 \note In Test Mode <b>Loopback</b> these tests are skipped
4841 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4843 \brief Function: Function USART_Tx_Underflow
4845 The function \b USART_Tx_Underflow verifies signaling of the <b>ARM_USART_EVENT_TX_UNDERFLOW</b> event:
4847 - with default data bits
4848 - with default parity
4849 - with default stop bits
4850 - with default flow control
4851 - at default baudrate
4853 it also checks that status tx_underflow flag was activated.
4855 \note If Tests Default Mode <b>Asynchronous/Single-wire/IrDA</b> is selected this test is not executed
4857 void USART_Tx_Underflow (void) {
4859 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4860 #if (USART_SERVER_USED == 1)
4861 if (IsNotAsync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4862 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4863 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; }
4866 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4867 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; }
4868 if (CmdXfer (0U, 1U, 10U, 20U, 0U) != EXIT_SUCCESS) { break; }
4870 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4871 USART_CFG_DEF_DATA_BITS_VAL |
4872 USART_CFG_DEF_PARITY_VAL |
4873 USART_CFG_DEF_STOP_BITS_VAL |
4874 USART_CFG_DEF_FLOW_CONTROL_VAL |
4875 USART_CFG_DEF_CPOL_VAL |
4876 USART_CFG_DEF_CPHA_VAL ,
4877 USART_CFG_DEF_BAUDRATE);
4881 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
4883 (void)osDelay(30U); // Wait for USART Server to timeout
4885 // Assert that event ARM_USART_EVENT_TX_UNDERFLOW was signaled
4886 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_TX_UNDERFLOW) != 0U, "[FAILED] Event ARM_USART_EVENT_TX_UNDERFLOW was not signaled!");
4888 // Assert that status rx_overflow flag is active
4889 TEST_ASSERT_MESSAGE(drv->GetStatus().tx_underflow != 0U, "[FAILED] Status tx_underflow flag was not activated!");
4891 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
4893 // Give USART Server 10 ms to prepare for reception of the next command
4901 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4903 \brief Function: Function USART_Rx_Overflow
4905 The function \b USART_Rx_Overflow verifies signaling of the <b>ARM_USART_EVENT_RX_OVERFLOW</b> event:
4907 - with default data bits
4908 - with default parity
4909 - with default stop bits
4910 - with default flow control
4911 - at default baudrate
4913 it also checks that status rx_overflow flag was activated.
4915 void USART_Rx_Overflow (void) {
4917 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4918 #if (USART_SERVER_USED == 1)
4919 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4920 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; }
4923 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4924 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; }
4925 if (CmdXfer (0U, 1U, 10U, 20U, 0U) != EXIT_SUCCESS) { break; }
4927 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4928 USART_CFG_DEF_DATA_BITS_VAL |
4929 USART_CFG_DEF_PARITY_VAL |
4930 USART_CFG_DEF_STOP_BITS_VAL |
4931 USART_CFG_DEF_FLOW_CONTROL_VAL |
4932 USART_CFG_DEF_CPOL_VAL |
4933 USART_CFG_DEF_CPHA_VAL ,
4934 USART_CFG_DEF_BAUDRATE);
4938 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
4940 (void)osDelay(30U); // Wait for USART Server to timeout
4942 // Assert that event ARM_USART_EVENT_RX_OVERFLOW was signaled
4943 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_OVERFLOW) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_OVERFLOW was not signaled!");
4945 // Assert that status rx_overflow flag is active
4946 TEST_ASSERT_MESSAGE(drv->GetStatus().rx_overflow != 0U, "[FAILED] Status rx_overflow flag was not activated!");
4948 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
4950 // Give USART Server 10 ms to prepare for reception of the next command
4958 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
4960 \brief Function: Function USART_Rx_Timeout
4962 The function \b USART_Rx_Timeout verifies signaling of the <b>ARM_USART_EVENT_RX_TIMEOUT</b> event:
4964 - with default data bits
4965 - with default parity
4966 - with default stop bits
4967 - with default flow control
4968 - at default baudrate
4970 \note If Tests Default Mode <b>Synchronous Master/Slave</b> is selected this test is not executed
4972 void USART_Rx_Timeout (void) {
4974 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4975 #if (USART_SERVER_USED == 1)
4976 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4977 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
4978 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; }
4981 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
4982 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; }
4983 if (CmdXfer (0U, 1U, 10U, 10U, 0U) != EXIT_SUCCESS) { break; }
4985 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
4986 USART_CFG_DEF_DATA_BITS_VAL |
4987 USART_CFG_DEF_PARITY_VAL |
4988 USART_CFG_DEF_STOP_BITS_VAL |
4989 USART_CFG_DEF_FLOW_CONTROL_VAL |
4990 USART_CFG_DEF_CPOL_VAL |
4991 USART_CFG_DEF_CPHA_VAL ,
4992 USART_CFG_DEF_BAUDRATE);
4996 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
4997 (void)drv->Receive(ptr_rx_buf, 2U);
4999 (void)osDelay(30U); // Wait for USART Server to timeout
5001 // Assert that event ARM_USART_EVENT_RX_TIMEOUT was signaled
5002 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_TIMEOUT) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_TIMEOUT was not signaled!");
5004 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
5005 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
5007 // Give USART Server 10 ms to prepare for reception of the next command
5015 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5017 \brief Function: Function USART_Rx_Break
5019 The function \b USART_Rx_Break verifies signaling of the <b>ARM_USART_EVENT_RX_BREAK</b> event:
5021 - with default data bits
5022 - with default parity
5023 - with default stop bits
5024 - with default flow control
5025 - at default baudrate
5027 it also checks that status rx_break flag was activated.
5029 \note If Tests Default Mode <b>Synchronous Master/Slave</b> is selected this test is not executed
5031 void USART_Rx_Break (void) {
5033 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5034 #if (USART_SERVER_USED == 1)
5035 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5036 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5037 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; }
5040 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5042 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5043 USART_CFG_DEF_DATA_BITS_VAL |
5044 USART_CFG_DEF_PARITY_VAL |
5045 USART_CFG_DEF_STOP_BITS_VAL |
5046 USART_CFG_DEF_FLOW_CONTROL_VAL |
5047 USART_CFG_DEF_CPOL_VAL |
5048 USART_CFG_DEF_CPHA_VAL ,
5049 USART_CFG_DEF_BAUDRATE);
5051 // Instruct USART Server to signal Break for 20 ms
5052 if (CmdSetBrk(10U, 20U) != EXIT_SUCCESS) { break; }
5054 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
5055 (void)drv->Receive(ptr_rx_buf, 1U);
5057 // This test allows break detection for continuous mode as well
5058 // as LIN variant (return to inactive after 10/11 bits)
5061 // Assert that event ARM_USART_EVENT_RX_BREAK was signaled
5062 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_BREAK) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_BREAK was not signaled!");
5064 // Assert that status rx_break flag is active
5065 TEST_ASSERT_MESSAGE(drv->GetStatus().rx_break != 0U, "[FAILED] Status rx_break flag was not activated!");
5067 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
5068 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
5070 // Give USART Server 10 ms to prepare for reception of the next command
5078 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5080 \brief Function: Function USART_Rx_Framing_Error
5082 The function \b USART_Rx_Framing_Error verifies signaling of the <b>ARM_USART_EVENT_RX_FRAMING_ERROR</b> event:
5084 - with default data bits
5085 - with default parity
5086 - with default stop bits
5087 - with default flow control
5088 - at default baudrate
5090 it also checks that status rx_framing_error flag was activated.
5092 \note If Tests Default Mode <b>Synchronous Master/Slave</b> is selected this test is not executed
5094 void USART_Rx_Framing_Error (void) {
5096 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5097 #if (USART_SERVER_USED == 1)
5098 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5099 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5100 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; }
5103 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5105 // We test framing error by adding parity bit if it is not set as default setting,
5106 // or removing parity bit if it is set as default setting
5107 if (USART_CFG_DEF_PARITY == PARITY_NONE) {
5108 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; }
5110 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; }
5112 if (CmdXfer (0U, 1U, 10U, 20U, 0U) != EXIT_SUCCESS) { break; }
5114 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5115 USART_CFG_DEF_DATA_BITS_VAL |
5116 USART_CFG_DEF_PARITY_VAL |
5117 USART_CFG_DEF_STOP_BITS_VAL |
5118 USART_CFG_DEF_FLOW_CONTROL_VAL |
5119 USART_CFG_DEF_CPOL_VAL |
5120 USART_CFG_DEF_CPHA_VAL ,
5121 USART_CFG_DEF_BAUDRATE);
5125 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
5126 (void)drv->Receive(ptr_rx_buf, 1U);
5128 (void)osDelay(30U); // Wait for USART Server to timeout
5130 // Assert that event ARM_USART_EVENT_RX_FRAMING_ERROR was signaled
5131 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_FRAMING_ERROR) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_FRAMING_ERROR was not signaled!");
5133 // Assert that status rx_framing_error flag is active
5134 TEST_ASSERT_MESSAGE(drv->GetStatus().rx_framing_error != 0U, "[FAILED] Status rx_framing_error flag was not activated!");
5136 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
5137 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
5139 // Give USART Server 10 ms to prepare for reception of the next command
5147 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5149 \brief Function: Function USART_Rx_Parity_Error
5151 The function \b USART_Rx_Parity_Error verifies signaling of the <b>ARM_USART_EVENT_RX_PARITY_ERROR</b> event:
5153 - with default data bits
5154 - with default parity
5155 - with default stop bits
5156 - with default flow control
5157 - at default baudrate
5159 it also checks that status rx_parity_error flag was activated.
5161 \note If Tests Default Mode <b>Synchronous Master/Slave</b> is selected this test is not executed
5163 void USART_Rx_Parity_Error (void) {
5165 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5166 #if (USART_SERVER_USED == 1)
5167 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5168 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5169 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; }
5172 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5174 // We test parity error by requesting USART Server to send an item at ODD parity
5175 // and configure USART Client to receive with EVEN parity
5176 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; }
5178 if (CmdXfer (0U, 1U, 10U, 20U, 0U) != EXIT_SUCCESS) { break; }
5180 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5181 USART_CFG_DEF_DATA_BITS_VAL |
5182 ((PARITY_EVEN << ARM_USART_PARITY_Pos) & ARM_USART_PARITY_Msk) |
5183 USART_CFG_DEF_STOP_BITS_VAL |
5184 USART_CFG_DEF_FLOW_CONTROL_VAL |
5185 USART_CFG_DEF_CPOL_VAL |
5186 USART_CFG_DEF_CPHA_VAL ,
5187 USART_CFG_DEF_BAUDRATE);
5191 (void)drv->Control(ARM_USART_CONTROL_RX, 1U);
5192 (void)drv->Receive(ptr_rx_buf, 1U);
5194 (void)osDelay(30U); // Wait for USART Server to timeout
5196 // Assert that event ARM_USART_EVENT_RX_PARITY_ERROR was signaled
5197 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RX_PARITY_ERROR) != 0U, "[FAILED] Event ARM_USART_EVENT_RX_PARITY_ERROR was not signaled!");
5199 // Assert that status rx_parity_error flag is active
5200 TEST_ASSERT_MESSAGE(drv->GetStatus().rx_parity_error != 0U, "[FAILED] Status rx_parity_error flag was not activated!");
5202 (void)drv->Control(ARM_USART_ABORT_RECEIVE, 0U);
5203 (void)drv->Control(ARM_USART_CONTROL_RX, 0U);
5205 // Give USART Server 10 ms to prepare for reception of the next command
5213 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5215 \brief Function: Function USART_Event_CTS
5217 The function \b USART_Event_CTS verifies signaling of the <b>ARM_USART_EVENT_CTS</b> event:
5219 - with default data bits
5220 - with default parity
5221 - with default stop bits
5222 - with no flow control
5223 - at default baudrate
5225 \note If Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b> is selected this test is not executed
5227 void USART_Event_CTS (void) {
5229 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5230 #if (USART_SERVER_USED == 1)
5231 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5232 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5233 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5234 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; }
5237 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5239 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5240 USART_CFG_DEF_DATA_BITS_VAL |
5241 USART_CFG_DEF_PARITY_VAL |
5242 USART_CFG_DEF_STOP_BITS_VAL |
5243 ARM_USART_FLOW_CONTROL_NONE ,
5244 USART_CFG_DEF_BAUDRATE);
5248 // Instruct USART Server to drive RTS to active state for 20 ms
5249 // RTS line from USART Server should be connected to CTS line on the USART Client (DUT)
5250 if (CmdSetMdm(RTS_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
5254 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_CTS) == ARM_USART_EVENT_CTS, "[FAILED] CTS line did not register change!");
5263 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5265 \brief Function: Function USART_Event_DSR
5267 The function \b USART_Event_DSR verifies signaling of the <b>ARM_USART_EVENT_DSR</b> event:
5269 - with default data bits
5270 - with default parity
5271 - with default stop bits
5272 - with no flow control
5273 - at default baudrate
5275 \note If Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b> is selected this test is not executed
5277 void USART_Event_DSR (void) {
5279 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5280 #if (USART_SERVER_USED == 1)
5281 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5282 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5283 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5284 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; }
5287 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5289 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5290 USART_CFG_DEF_DATA_BITS_VAL |
5291 USART_CFG_DEF_PARITY_VAL |
5292 USART_CFG_DEF_STOP_BITS_VAL |
5293 ARM_USART_FLOW_CONTROL_NONE ,
5294 USART_CFG_DEF_BAUDRATE);
5298 // Instruct USART Server to drive DTR to active state for 20 ms
5299 // DTR line from USART Server should be connected to DSR line on the USART Client (DUT)
5300 if (CmdSetMdm(DTR_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
5304 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_DSR) == ARM_USART_EVENT_DSR, "[FAILED] DSR line did not register change!");
5313 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5315 \brief Function: Function USART_Event_DCD
5317 The function \b USART_Event_DCD verifies signaling of the <b>ARM_USART_EVENT_DCD</b> event:
5319 - with default data bits
5320 - with default parity
5321 - with default stop bits
5322 - with no flow control
5323 - at default baudrate
5325 \note If Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b> is selected this test is not executed
5327 void USART_Event_DCD (void) {
5329 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5330 #if (USART_SERVER_USED == 1)
5331 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5332 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5333 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5334 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; }
5337 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5339 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5340 USART_CFG_DEF_DATA_BITS_VAL |
5341 USART_CFG_DEF_PARITY_VAL |
5342 USART_CFG_DEF_STOP_BITS_VAL |
5343 ARM_USART_FLOW_CONTROL_NONE ,
5344 USART_CFG_DEF_BAUDRATE);
5348 // Instruct USART Server to drive RTS to active state for 20 ms
5349 if (CmdSetMdm(TO_DCD_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
5353 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_DCD) == ARM_USART_EVENT_DCD, "[FAILED] DCD line did not register change!");
5362 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
5364 \brief Function: Function USART_Event_RI
5366 The function \b USART_Event_RI verifies signaling of the <b>ARM_USART_EVENT_RI</b> event:
5368 - with default data bits
5369 - with default parity
5370 - with default stop bits
5371 - with no flow control
5372 - at default baudrate
5374 \note If Tests Default Mode <b>Synchronous Master/Slave</b> or <b>Single-wire</b> is selected this test is not executed
5376 void USART_Event_RI (void) {
5378 if (IsNotLoopback() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5379 #if (USART_SERVER_USED == 1)
5380 if (IsNotSync() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5381 if (IsNotSingleWire() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5382 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
5383 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; }
5386 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
5388 (void)drv->Control(USART_CFG_DEF_MODE_VAL |
5389 USART_CFG_DEF_DATA_BITS_VAL |
5390 USART_CFG_DEF_PARITY_VAL |
5391 USART_CFG_DEF_STOP_BITS_VAL |
5392 ARM_USART_FLOW_CONTROL_NONE ,
5393 USART_CFG_DEF_BAUDRATE);
5397 // Instruct USART Server to drive RI to active state for 20 ms
5398 if (CmdSetMdm(TO_RI_ON, 10U, 20U) != EXIT_SUCCESS) { break; }
5402 // RI event should be active after RI returns to inactive state (Trailing Edge RI)
5403 TEST_ASSERT_MESSAGE((event & ARM_USART_EVENT_RI) == ARM_USART_EVENT_RI, "[FAILED] RI line did not register change!");
5413 // End of usart_tests_evt