]> begriffs open source - cmsis-driver-validation/blob - Source/DV_SPI.c
Minor correction in SPI testing
[cmsis-driver-validation] / Source / DV_SPI.c
1 /*
2  * Copyright (c) 2015-2020 Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
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
9  *
10  * www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  * -----------------------------------------------------------------------------
19  *
20  * Project:     CMSIS-Driver Validation
21  * Title:       Serial Peripheral Interface Bus (SPI) Driver Validation tests
22  *
23  * -----------------------------------------------------------------------------
24  */
25
26 #ifndef __DOXYGEN__                     // Exclude form the documentation
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31
32 #include "cmsis_dv.h"
33 #include "DV_SPI_Config.h"
34 #include "DV_Framework.h"
35
36 #include "Driver_SPI.h"
37
38 #define CMD_LEN                   32UL  // Length of command to SPI Server
39 #define RESP_GET_VER_LEN          16UL  // Length of response from SPI Server to GET VER command
40 #define RESP_GET_CAP_LEN          32UL  // Length of response from SPI Server to GET CAP command
41 #define RESP_GET_CNT_LEN          16UL  // Length of response from SPI Server to GET CNT command
42
43 #define OP_SEND                   0UL   // Send operation
44 #define OP_RECEIVE                1UL   // Receive operation
45 #define OP_TRANSFER               2UL   // Transfer operation
46 #define OP_ABORT_SEND             3UL   // Abort send operation
47 #define OP_ABORT_RECEIVE          4UL   // Abort receive operation
48 #define OP_ABORT_TRANSFER         5UL   // Abort transfer operation
49
50 #define MODE_INACTIVE             0UL   // Inactive mode
51 #define MODE_MASTER               1UL   // Master mode
52 #define MODE_SLAVE                2UL   // Slave  mode
53 #define SS_MODE_MASTER_UNUSED     0UL   // Master mode Slave Select unused
54 #define SS_MODE_MASTER_SW         1UL   // Master mode Slave Select software controlled
55 #define SS_MODE_MASTER_HW_OUTPUT  2UL   // Master mode Slave Select hardware controlled output
56 #define SS_MODE_MASTER_HW_INPUT   3UL   // Master mode Slave Select hardware monitored input
57 #define SS_MODE_SLAVE_HW          0UL   // Slave mode Slave Select hardware monitored
58 #define SS_MODE_SLAVE_SW          1UL   // Slave mode Slave Select software controlled
59 #define FORMAT_CPOL0_CPHA0        0UL   // Clock Format: Polarity 0, Phase 0
60 #define FORMAT_CPOL0_CPHA1        1UL   // Clock Format: Polarity 0, Phase 1
61 #define FORMAT_CPOL1_CPHA0        2UL   // Clock Format: Polarity 1, Phase 0
62 #define FORMAT_CPOL1_CPHA1        3UL   // Clock Format: Polarity 1, Phase 1
63 #define FORMAT_TI                 4UL   // Frame Format: Texas Instruments
64 #define FORMAT_MICROWIRE          5UL   // Frame Format: National Semiconductor Microwire
65 #define BO_MSB_TO_LSB             0UL   // Bit Order MSB to LSB
66 #define BO_LSB_TO_MSB             1UL   // Bit Order LSB to MSB
67
68 // Testing Configuration definitions
69 #if    (SPI_CFG_TEST_MODE != 0)
70 #define SPI_SERVER_USED                 1
71 #else
72 #define SPI_SERVER_USED                 0
73 #endif
74
75 // Determine maximum number of items used for testing
76 #if    (SPI_CFG_DEF_NUM == 0)
77 #error  Default number of items to test must not be 0!
78 #endif
79
80 #define SPI_NUM_MAX                     SPI_CFG_DEF_NUM
81 #if    (SPI_CFG_NUM1 > SPI_NUM_MAX)
82 #undef  SPI_NUM_MAX
83 #define SPI_NUM_MAX                     SPI_CFG_NUM1
84 #endif
85 #if    (SPI_CFG_NUM2 > SPI_NUM_MAX)
86 #undef  SPI_NUM_MAX
87 #define SPI_NUM_MAX                     SPI_CFG_NUM2
88 #endif
89 #if    (SPI_CFG_NUM3 > SPI_NUM_MAX)
90 #undef  SPI_NUM_MAX
91 #define SPI_NUM_MAX                     SPI_CFG_NUM3
92 #endif
93 #if    (SPI_CFG_NUM4 > SPI_NUM_MAX)
94 #undef  SPI_NUM_MAX
95 #define SPI_NUM_MAX                     SPI_CFG_NUM4
96 #endif
97 #if    (SPI_CFG_NUM5 > SPI_NUM_MAX)
98 #undef  SPI_NUM_MAX
99 #define SPI_NUM_MAX                     SPI_CFG_NUM5
100 #endif
101
102 // Calculate maximum required buffer size
103 #if   ((SPI_CFG_DEF_DATA_BITS > 16) || ((SPI_TC_DATA_BIT_EN_MASK & 0xFFFF0000UL) != 0U))
104 #define SPI_BUF_MAX                    (SPI_NUM_MAX * 4U)
105 #elif ((SPI_CFG_DEF_DATA_BITS > 8)  || ((SPI_TC_DATA_BIT_EN_MASK & 0x0000FF00UL) != 0U))
106 #define SPI_BUF_MAX                    (SPI_NUM_MAX * 2U)
107 #else
108 #define SPI_BUF_MAX                    (SPI_NUM_MAX)
109 #endif
110 #if    (SPI_SERVER_USED == 1)
111 // If selected Test Mode is SPI Server take into account SPI Server data bit settings
112 #if   ((SPI_CFG_SRV_DATA_BITS > 16) && (SPI_BUF_MAX < (SPI_NUM_MAX * 4U)))
113 #undef  SPI_BUF_MAX
114 #define SPI_BUF_MAX                    (SPI_NUM_MAX * 4U)
115 #elif ((SPI_CFG_SRV_DATA_BITS > 8)  && (SPI_BUF_MAX < (SPI_NUM_MAX * 2U)))
116 #undef  SPI_BUF_MAX
117 #define SPI_BUF_MAX                    (SPI_NUM_MAX * 2U)
118 #endif
119 #endif
120
121 typedef struct {                // SPI Server version structure
122   uint8_t  major;               // Version major number
123   uint8_t  minor;               // Version minor number
124   uint16_t patch;               // Version patch (revision) number
125 } SPI_SERV_VER_t;
126
127 typedef struct {                // SPI Server capabilities structure
128   uint32_t mode_mask;           // Mode and Slave Select mask
129   uint32_t fmt_mask;            // Clock Format or Frame Format mask
130   uint32_t db_mask;             // Data Bits mask
131   uint32_t bo_mask;             // Bit Order mask
132   uint32_t bs_min;              // Min bus speed
133   uint32_t bs_max;              // Max bus speed
134 } SPI_SERV_CAP_t;
135
136 // Register Driver_SPI#
137 #define _ARM_Driver_SPI_(n)         Driver_SPI##n
138 #define  ARM_Driver_SPI_(n)    _ARM_Driver_SPI_(n)
139 extern   ARM_DRIVER_SPI         ARM_Driver_SPI_(DRV_SPI);
140 static   ARM_DRIVER_SPI *drv = &ARM_Driver_SPI_(DRV_SPI);
141
142 // Global variables (used in this module only)
143 static int8_t                   buffers_ok;
144 static int8_t                   server_ok;
145 static int8_t                   driver_ok;
146
147 static SPI_SERV_CAP_t           spi_serv_cap;
148
149 static volatile uint32_t        event;
150 static volatile uint32_t        duration;
151 static volatile uint32_t        data_count_sample;
152 static uint32_t                 systick_freq;
153
154 static char                     msg_buf     [256];
155
156 // Allocated buffer pointers
157 static void                    *ptr_tx_buf_alloc;
158 static void                    *ptr_rx_buf_alloc;
159 static void                    *ptr_cmp_buf_alloc;
160
161 // Buffer pointers used for data transfers (must be aligned to 4 byte)
162 static uint8_t                 *ptr_tx_buf;
163 static uint8_t                 *ptr_rx_buf;
164 static uint8_t                 *ptr_cmp_buf;
165
166 // String representation of Driver codes
167 static const char *str_oper[] = {
168   "Send    ",
169   "Receive ",
170   "Transfer",
171   "Abort Send    ",
172   "Abort Receive ",
173   "Abort Transfer"
174 };
175
176 static const char *str_ret[] = {
177   "ARM_DRIVER_OK",
178   "ARM_DRIVER_ERROR",
179   "ARM_DRIVER_ERROR_BUSY",
180   "ARM_DRIVER_ERROR_TIMEOUT",
181   "ARM_DRIVER_ERROR_UNSUPPORTED",
182   "ARM_DRIVER_ERROR_PARAMETER",
183   "ARM_DRIVER_ERROR_SPECIFIC"
184   "ARM_SPI_ERROR_MODE",
185   "ARM_SPI_ERROR_FRAME_FORMAT",
186   "ARM_SPI_ERROR_DATA_BITS",
187   "ARM_SPI_ERROR_BIT_ORDER",
188   "ARM_SPI_ERROR_SS_MODE"
189 };
190
191 // Local functions
192 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
193 static int32_t  ComConfigDefault       (void);
194 static int32_t  ComSendCommand         (const void *data_out, uint32_t len);
195 static int32_t  ComReceiveResponse     (      void *data_in,  uint32_t len);
196
197 static int32_t  CmdGetVer              (void);
198 static int32_t  CmdGetCap              (void);
199 static int32_t  CmdSetBufTx            (char pattern);
200 static int32_t  CmdSetBufRx            (char pattern);
201 static int32_t  CmdGetBufRx            (uint32_t len);
202 static int32_t  CmdSetCom              (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed);
203 static int32_t  CmdXfer                (uint32_t num,  uint32_t delay,  uint32_t timeout,   uint32_t num_ss);
204 static int32_t  CheckServer            (void);
205 #endif
206
207 static uint32_t DataBitsToBytes        (uint32_t data_bits);
208 static int32_t  InitDriver             (void);
209 static int32_t  CheckBuffers           (void);
210
211 static void SPI_DataExchange_Operation (uint32_t operation, uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed, uint32_t num);
212
213 // Helper functions
214
215 /*
216   \fn            void SPI_DrvEvent (uint32_t evt)
217   \brief         Store event(s) into global variable.
218   \detail        This is a callback function called by the driver upon an event(s).
219   \param[in]     evt            SPI event
220   \return        none
221 */
222 static void SPI_DrvEvent (uint32_t evt) {
223   event |= evt;
224 }
225
226 /*
227   \fn            static uint32_t DataBitsToBytes (uint32_t data_bits)
228   \brief         Calculate number of bytes used for an item at required data bits.
229   \return        number of bytes per item
230 */
231 static uint32_t DataBitsToBytes (uint32_t data_bits) {
232   uint32_t ret;
233
234   ret = 1U;
235   if        (data_bits > 16U) {
236     ret = 4U;
237   } else if (data_bits > 8U) {
238     ret = 2U;
239   }
240
241   return ret;
242 }
243
244 /*
245   \fn            static int32_t InitDriver (void)
246   \brief         Initialize and power-on the driver.
247   \return        execution status
248                    - EXIT_SUCCESS: Operation successful
249                    - EXIT_FAILURE: Operation failed
250 */
251 static int32_t InitDriver (void) {
252
253   if (driver_ok == -1) {                // If -1, means it was not yet checked
254     driver_ok = 0;
255     if (drv->Initialize    (SPI_DrvEvent)   == ARM_DRIVER_OK) {
256       if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
257         driver_ok = 1;
258       }
259     }
260   }
261
262   if (driver_ok == 1) {
263     return EXIT_SUCCESS;
264   }
265
266   TEST_FAIL_MESSAGE("[FAILED] SPI driver initialization or power-up failed. Test aborted!");
267   return EXIT_FAILURE;
268 }
269
270 /*
271   \fn            static int32_t CheckBuffers (void)
272   \brief         Check if buffers are valid.
273   \return        execution status
274                    - EXIT_SUCCESS: Operation successful
275                    - EXIT_FAILURE: Operation failed
276 */
277 static int32_t CheckBuffers (void) {
278
279   if (buffers_ok == -1) {               // If -1, means it was not yet checked
280     if ((ptr_tx_buf  != NULL) &&
281         (ptr_rx_buf  != NULL) && 
282         (ptr_cmp_buf != NULL)) {
283       buffers_ok = 1;
284     } else {
285       buffers_ok = 0;
286     }
287   }
288
289   if (buffers_ok == 1) {
290     return EXIT_SUCCESS;
291   }
292
293   TEST_FAIL_MESSAGE("[FAILED] Invalid data buffers! Increase heap memory! Test aborted!");
294   return EXIT_FAILURE;
295 }
296
297 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
298
299 /*
300   \fn            static int32_t ComConfigDefault (void)
301   \brief         Configure SPI Communication Interface to SPI Server default communication configuration.
302   \return        execution status
303                    - EXIT_SUCCESS: Operation successful
304                    - EXIT_FAILURE: Operation failed
305 */
306 static int32_t ComConfigDefault (void) {
307   int32_t ret;
308
309   ret = EXIT_SUCCESS;
310
311   if (drv->Control(ARM_SPI_MODE_MASTER                                                                | 
312                  ((SPI_CFG_SRV_FORMAT    << ARM_SPI_FRAME_FORMAT_Pos)   & ARM_SPI_FRAME_FORMAT_Msk)   | 
313                  ((SPI_CFG_SRV_DATA_BITS << ARM_SPI_DATA_BITS_Pos)      & ARM_SPI_DATA_BITS_Msk)      | 
314                  ((SPI_CFG_SRV_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos)      & ARM_SPI_BIT_ORDER_Msk)      | 
315                  ((SPI_CFG_SRV_SS_MODE   << ARM_SPI_SS_MASTER_MODE_Pos) & ARM_SPI_SS_MASTER_MODE_Msk) , 
316                    SPI_CFG_SRV_BUS_SPEED) != ARM_DRIVER_OK) {
317     ret = EXIT_FAILURE;
318   }
319
320   if ((ret == EXIT_SUCCESS) && (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW)) {
321     if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
322       ret = EXIT_FAILURE;
323     }
324   }
325
326   if (ret != EXIT_SUCCESS) {
327     TEST_FAIL_MESSAGE("Failed to configure communication interface to SPI Server default settings. Testing aborted!");
328   }
329
330   // Give SPI Server 10 ms to prepare for reception of the command
331   (void)osDelay(10U);
332
333   return ret;
334 }
335
336 /**
337   \fn            static int32_t ComSendCommand (const void *data_out, uint32_t num)
338   \brief         Send command to SPI Server.
339   \param[out]    data_out       Pointer to memory containing data to be sent
340   \param[in]     len            Number of bytes to be sent
341   \return        execution status
342                    - EXIT_SUCCESS: Operation successful
343                    - EXIT_FAILURE: Operation failed
344 */
345 static int32_t ComSendCommand (const void *data_out, uint32_t len) {
346    int32_t ret;
347   uint32_t num, tout;
348
349   ret = EXIT_SUCCESS;
350   num = (len + DataBitsToBytes(SPI_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(SPI_CFG_SRV_DATA_BITS);
351
352   if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
353     if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE) != ARM_DRIVER_OK) {
354       ret = EXIT_FAILURE;
355     }
356   }
357   if (ret == EXIT_SUCCESS) {
358     if (drv->Send(data_out, num) == ARM_DRIVER_OK) {
359       for (tout = SPI_CFG_SRV_CMD_TOUT; tout != 0U; tout--) {
360         if ((drv->GetDataCount() == num) && (drv->GetStatus().busy == 0U)) { 
361           break;
362         }
363         (void)osDelay(1U);
364       }
365       if (tout == 0U) {                 // If send has timed out
366         ret = EXIT_FAILURE;
367       }
368     } else {
369       ret = EXIT_FAILURE;
370     }
371   }
372   if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
373     if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
374       ret = EXIT_FAILURE;
375     }
376   }
377
378   // Give SPI Server 10 ms to prepare for reception of the next command or to 
379   // prepare the answer to this command, if it requires response
380   (void)osDelay(10U);
381
382   return ret;
383 }
384
385 /**
386   \fn            static int32_t ComReceiveResponse (void *data_in, uint32_t num)
387   \brief         Receive response from SPI Server.
388   \param[out]    data_in     Pointer to memory where data will be received
389   \param[in]     len         Number of data bytes to be received
390   \return        execution status
391                    - EXIT_SUCCESS: Operation successful
392                    - EXIT_FAILURE: Operation failed
393 */
394 static int32_t ComReceiveResponse (void *data_in, uint32_t len) {
395    int32_t ret;
396   uint32_t num, tout;
397
398   ret = EXIT_SUCCESS;
399   num = (len + DataBitsToBytes(SPI_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(SPI_CFG_SRV_DATA_BITS);
400
401   if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
402     if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE) != ARM_DRIVER_OK) {
403       ret = EXIT_FAILURE;
404     }
405   }
406   if (ret == EXIT_SUCCESS) {
407     if (drv->Receive(data_in, num) == ARM_DRIVER_OK) {
408       for (tout = SPI_CFG_SRV_CMD_TOUT; tout != 0U; tout--) {
409         if ((drv->GetDataCount() == num) && (drv->GetStatus().busy == 0U)) { 
410           break;
411         }
412         (void)osDelay(1U);
413       }
414       if (tout == 0U) {                 // If send has timed out
415         ret = EXIT_FAILURE;
416       }
417     } else {
418       ret = EXIT_FAILURE;
419     }
420   }
421   if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
422     if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
423       ret = EXIT_FAILURE;
424     }
425   }
426
427   // Give SPI Server 10 ms to prepare for reception of the next command
428   (void)osDelay(10U);
429
430   return ret;
431 }
432
433 /**
434   \fn            static int32_t CmdGetVer (void)
435   \brief         Get version from SPI Server and check that it is valid.
436   \return        execution status
437                    - EXIT_SUCCESS: Operation successful
438                    - EXIT_FAILURE: Operation failed
439 */
440 static int32_t CmdGetVer (void) {
441   int32_t        ret;
442   SPI_SERV_VER_t spi_serv_ver;
443   const char    *ptr_str;
444   uint16_t       val16;
445   uint8_t        val8;
446
447   ptr_str = NULL;
448
449   memset(&spi_serv_ver, 0, sizeof(spi_serv_ver));
450
451   // Send "GET VER" command to SPI Server
452   memset(ptr_tx_buf, 0, CMD_LEN);
453   memcpy(ptr_tx_buf, "GET VER", 7);
454   ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
455
456   if (ret == EXIT_SUCCESS) {
457     // Receive response to "GET VER" command from SPI Server
458     memset(ptr_rx_buf, (int32_t)'?', RESP_GET_VER_LEN);
459     ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_VER_LEN);
460   }
461
462   // Parse version
463   if (ret == EXIT_SUCCESS) {
464     // Parse major
465     ptr_str = (const char *)ptr_rx_buf;
466     if (sscanf(ptr_str, "%hhx", &val8) == 1) {
467       spi_serv_ver.major = val8;
468     } else {
469       ret = EXIT_FAILURE;
470     }
471   }
472   if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
473     // Parse minor
474     ptr_str = strstr(ptr_str, ".");     // Find '.'
475     if (ptr_str != NULL) {
476       ptr_str++;                        // Skip '.'
477       if (sscanf(ptr_str, "%hhx", &val8) == 1) {
478         spi_serv_ver.minor = val8;
479       } else {
480         ret = EXIT_FAILURE;
481       }
482     } else {
483       ret = EXIT_FAILURE;
484     }
485   }
486   if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
487     // Parse patch (revision)
488     ptr_str = strstr(ptr_str, ".");     // Find next '.'
489     if (ptr_str != NULL) {
490       ptr_str++;                        // Skip '.'
491       if (sscanf(ptr_str, "%hx", &val16) == 1) {
492         spi_serv_ver.patch = val16;
493       } else {
494         ret = EXIT_FAILURE;
495       }
496     } else {
497       ret = EXIT_FAILURE;
498     }
499   }
500
501   if (ret == EXIT_SUCCESS) {
502     // Only supported version is v1.0.0
503     if ((spi_serv_ver.major != 1U) || 
504         (spi_serv_ver.minor != 0U) || 
505         (spi_serv_ver.patch != 0U)) { 
506       ret = EXIT_FAILURE;
507     }
508   }
509
510   if (ret != EXIT_SUCCESS) {
511     TEST_FAIL_MESSAGE("[FAILED] Get version from SPI Server.");
512   }
513
514   return ret;
515 }
516
517 /**
518   \fn            static int32_t CmdGetCap (void)
519   \brief         Get capabilities from SPI Server.
520   \return        execution status
521                    - EXIT_SUCCESS: Operation successful
522                    - EXIT_FAILURE: Operation failed
523 */
524 static int32_t CmdGetCap (void) {
525   int32_t     ret;
526   const char *ptr_str;
527   uint32_t    val32;
528   uint8_t     val8;
529
530   ptr_str = NULL;
531
532   memset(&spi_serv_cap, 0, sizeof(spi_serv_cap));
533
534   // Send "GET CAP" command to SPI Server
535   memset(ptr_tx_buf, 0, RESP_GET_CAP_LEN);
536   memcpy(ptr_tx_buf, "GET CAP", 7);
537   ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
538
539   if (ret == EXIT_SUCCESS) {
540     (void)osDelay(10U);                 // Give SPI Server 10 ms to auto-detect capabilities
541
542     // Receive response to "GET CAP" command from SPI Server
543     memset(ptr_rx_buf, (int32_t)'?', RESP_GET_CAP_LEN);
544     ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_CAP_LEN);
545   }
546
547   // Parse capabilities
548   if (ret == EXIT_SUCCESS) {
549     // Parse mode mask
550     ptr_str = (const char *)ptr_rx_buf;
551     if (sscanf(ptr_str, "%hhx", &val8) == 1) {
552       spi_serv_cap.mode_mask = val8;
553     } else {
554       ret = EXIT_FAILURE;
555     }
556   }
557   if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
558     // Parse format mask
559     ptr_str = strstr(ptr_str, ",");     // Find ','
560     if (ptr_str != NULL) {
561       ptr_str++;                        // Skip ','
562       if (sscanf(ptr_str, "%hhx", &val8) == 1) {
563         spi_serv_cap.fmt_mask = (uint32_t)val8;
564       } else {
565         ret = EXIT_FAILURE;
566       }
567     } else {
568       ret = EXIT_FAILURE;
569     }
570   }
571   if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
572     // Parse data bit mask
573     ptr_str = strstr(ptr_str, ",");     // Find next ','
574     if (ptr_str != NULL) {
575       ptr_str++;                        // Skip ','
576       if (sscanf(ptr_str, "%x", &val32) == 1) {
577         spi_serv_cap.db_mask = val32;
578       } else {
579         ret = EXIT_FAILURE;
580       }
581     } else {
582       ret = EXIT_FAILURE;
583     }
584   }
585   if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
586     // Parse bit order mask
587     ptr_str = strstr(ptr_str, ",");     // Find next ','
588     if (ptr_str != NULL) {
589       ptr_str++;                        // Skip ','
590       if (sscanf(ptr_str, "%hhx", &val8) == 1) {
591         spi_serv_cap.bo_mask = (uint32_t)val8;
592       } else {
593         ret = EXIT_FAILURE;
594       }
595     } else {
596       ret = EXIT_FAILURE;
597     }
598   }
599   if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
600     // Parse minimum bus speed
601     ptr_str = strstr(ptr_str, ",");     // Find next ','
602     if (ptr_str != NULL) {
603       ptr_str++;                        // Skip ','
604       if (sscanf(ptr_str, "%u", &val32) == 1) {
605         spi_serv_cap.bs_min = val32 * 1000U;
606       } else {
607         ret = EXIT_FAILURE;
608       }
609     } else {
610       ret = EXIT_FAILURE;
611     }
612   }
613   if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
614     // Parse maximum bus speed
615     ptr_str = strstr(ptr_str, ",");     // Find next ','
616     if (ptr_str != NULL) {
617       ptr_str++;                        // Skip ','
618       if (sscanf(ptr_str, "%u", &val32) == 1) {
619         spi_serv_cap.bs_max = val32 * 1000U;
620       } else {
621         ret = EXIT_FAILURE;
622       }
623     } else {
624       ret = EXIT_FAILURE;
625     }
626   }
627
628   if (ret != EXIT_SUCCESS) {
629     TEST_FAIL_MESSAGE("[FAILED] Get capabilities from SPI Server.");
630   }
631
632   return ret;
633 }
634
635 /**
636   \fn            static int32_t CmdSetBufTx (char pattern)
637   \brief         Set Tx buffer of SPI Server to pattern.
638   \param[in]     pattern        Pattern to fill the buffer with
639   \return        execution status
640                    - EXIT_SUCCESS: Operation successful
641                    - EXIT_FAILURE: Operation failed
642 */
643 static int32_t CmdSetBufTx (char pattern) {
644   int32_t ret;
645
646   // Send "SET BUF TX" command to SPI Server
647   memset(ptr_tx_buf, 0, 32);
648   (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF TX,0,%02X", (int32_t)pattern);
649   ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
650
651   if (ret != EXIT_SUCCESS) {
652     TEST_FAIL_MESSAGE("[FAILED] Set Tx buffer on SPI Server.");
653   }
654
655   return ret;
656 }
657
658 /**
659   \fn            static int32_t CmdSetBufRx (char pattern)
660   \brief         Set Rx buffer of SPI Server to pattern.
661   \param[in]     pattern        Pattern to fill the buffer with
662   \return        execution status
663                    - EXIT_SUCCESS: Operation successful
664                    - EXIT_FAILURE: Operation failed
665 */
666 static int32_t CmdSetBufRx (char pattern) {
667   int32_t ret;
668
669   // Send "SET BUF RX" command to SPI Server
670   memset(ptr_tx_buf, 0, 32);
671   (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF RX,0,%02X", (int32_t)pattern);
672   ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
673
674   if (ret != EXIT_SUCCESS) {
675     TEST_FAIL_MESSAGE("[FAILED] Set Rx buffer on SPI Server.");
676   }
677
678   return ret;
679 }
680
681 /**
682   \fn            static int32_t CmdGetBufRx (void)
683   \brief         Get Rx buffer from SPI Server (into global array pointed to by ptr_rx_buf).
684   \param[in]     len            Number of bytes to read from Rx buffer
685   \return        execution status
686                    - EXIT_SUCCESS: Operation successful
687                    - EXIT_FAILURE: Operation failed
688 */
689 static int32_t CmdGetBufRx (uint32_t len) {
690   int32_t ret;
691
692   // Send "GET BUF RX" command to SPI Server
693   memset(ptr_tx_buf, 0, 32);
694   (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "GET BUF RX,%i", len);
695   ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
696
697   if (ret == EXIT_SUCCESS) {
698     // Receive response to "GET BUF RX" command from SPI Server
699     memset(ptr_rx_buf, (int32_t)'U', len);
700     ret = ComReceiveResponse(ptr_rx_buf, len);
701   }
702
703   if (ret != EXIT_SUCCESS) {
704     TEST_FAIL_MESSAGE("[FAILED] Get Rx buffer from SPI Server.");
705   }
706
707   return ret;
708 }
709
710 /**
711   \fn            static int32_t CmdSetCom (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed)
712   \brief         Set communication parameters on SPI Server for next XFER command.
713   \param[in]     mode           mode (0 = Master, 1 = slave)
714   \param[in]     format         clock / frame format:
715                                   - value 0 = clock polarity 0, phase 0
716                                   - value 1 = clock polarity 0, phase 1
717                                   - value 2 = clock polarity 1, phase 0
718                                   - value 3 = clock polarity 1, phase 1
719                                   - value 4 = Texas Instruments frame format
720                                   - value 5 = Microwire frame format
721   \param[in]     data_bits      data bits
722                                   - values 1 to 32
723   \param[in]     bit_order      bit order
724                                   - value 0 = MSB to LSB
725                                   - value 1 = LSB to MSB
726   \param[in]     ss_mode        Slave Select mode:
727                                   - value 0 = not used
728                                   - value 1 = used (in Master mode driven, in Slave mode monitored as hw input)
729   \param[in]     bus_speed      bus speed in bits per second (bps)
730   \return        execution status
731                    - EXIT_SUCCESS: Operation successful
732                    - EXIT_FAILURE: Operation failed
733 */
734 static int32_t CmdSetCom (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed) {
735   int32_t ret, stat;
736
737   // Send "SET COM" command to SPI Server
738   memset(ptr_tx_buf, 0, 32);
739   stat = snprintf((char *)ptr_tx_buf, CMD_LEN, "SET COM %i,%i,%i,%i,%i,%i", mode, format, data_bits, bit_order, ss_mode, bus_speed);
740   if ((stat > 0) && (stat < CMD_LEN)) {
741     ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
742   } else {
743     ret = EXIT_FAILURE;
744   }
745
746   if (ret != EXIT_SUCCESS) {
747     TEST_FAIL_MESSAGE("[FAILED] Set communication settings on SPI Server.");
748   }
749
750   return ret;
751 }
752
753 /**
754   \fn            static int32_t CmdXfer (uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_ss)
755   \brief         Activate transfer on SPI Server.
756   \param[in]     num            number of items (according CMSIS SPI driver specification)
757   \param[in]     delay          initial delay, in milliseconds, before starting requested operation 
758                                 (0xFFFFFFFF = delay not used)
759   \param[in]     timeout        timeout in milliseconds, after delay, if delay is specified
760   \param[in]     num_ss         number of items after which Slave Select line should be activated
761   \return        execution status
762                    - EXIT_SUCCESS: Operation successful
763                    - EXIT_FAILURE: Operation failed
764 */
765 static int32_t CmdXfer (uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_ss) {
766   int32_t ret;
767
768   // Send "XFER" command to SPI Server
769   memset(ptr_tx_buf, 0, 32);
770   if (num_ss != 0U) {
771     (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i,%i", num, delay, timeout, num_ss);
772   } else if ((delay != osWaitForever) && (timeout != 0U)) {
773     (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i",    num, delay, timeout);
774   } else if  (delay != osWaitForever) {
775     (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i",       num, delay);
776   } else {
777     (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i",          num);
778   }
779   ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
780
781   if (ret != EXIT_SUCCESS) {
782     TEST_FAIL_MESSAGE("[FAILED] Activate transfer on SPI Server.");
783   }
784
785   return ret;
786 }
787
788 /*
789   \fn            static int32_t CheckServer (void)
790   \brief         Check if communication with SPI Server is working and get capabilities.
791   \return        execution status
792                    - EXIT_SUCCESS: Operation successful
793                    - EXIT_FAILURE: Operation failed
794 */
795 static int32_t CheckServer (void) {
796
797   if (server_ok == -1) {                // If -1, means it was not yet checked
798     server_ok = 1;
799     if (ComConfigDefault() != EXIT_SUCCESS) {
800       server_ok = 0;
801     }
802     if (server_ok == 1) {
803       if (CmdGetVer() != EXIT_SUCCESS) {
804         server_ok = 0;
805       }
806     }
807     if (server_ok == 1) {
808       if (CmdGetCap() != EXIT_SUCCESS) {
809         server_ok = 0;
810       }
811     }
812     if (server_ok == 1) {
813       // Check if all default settings are supported by SPI Server
814       if ((spi_serv_cap.fmt_mask & (1UL << SPI_CFG_SRV_FORMAT)) == 0U) {
815         // If SPI Server does not support default clock / frame format
816         TEST_MESSAGE("[FAILED] Default clock / frame format setting in not supported by SPI Server!");
817         server_ok = 0;
818       }
819       if ((spi_serv_cap.db_mask & (1UL << (SPI_CFG_SRV_DATA_BITS - 1U))) == 0U) {
820         // If SPI Server does not support default data bits
821         TEST_MESSAGE("[FAILED] Default data bits setting in not supported by SPI Server!");
822         server_ok = 0;
823       }
824       if ((spi_serv_cap.bo_mask & (1UL << SPI_CFG_SRV_BIT_ORDER)) == 0U) {
825         // If SPI Server does not support default bit order
826         TEST_MESSAGE("[FAILED] Default bit order setting in not supported by SPI Server!");
827         server_ok = 0;
828       }
829       if ((spi_serv_cap.bs_min > SPI_CFG_SRV_BUS_SPEED) ||
830           (spi_serv_cap.bs_max < SPI_CFG_SRV_BUS_SPEED)) {
831         // If SPI Server does not support default bus speed
832         TEST_MESSAGE("[FAILED] Default bus speed setting in not supported by SPI Server!");
833         server_ok = 0;
834       }
835     }
836   }
837
838   if (server_ok == 1) {
839     return EXIT_SUCCESS;
840   }
841
842   TEST_FAIL_MESSAGE("[FAILED] Communication with SPI Server is not working. Test aborted!");
843   return EXIT_FAILURE;
844 }
845
846 #endif                                  // If Test Mode SPI Server is selected
847
848 /*
849   \fn            void SPI_DV_Initialize (void)
850   \brief         Initialize testing environment for SPI testing.
851   \detail        This function is called by the driver validation framework before SPI testing begins.
852                  It initializes global variables and allocates memory buffers (from heap) used for the SPI testing.
853   \return        none
854 */
855 void SPI_DV_Initialize (void) {
856
857   // Initialize global variables
858   buffers_ok   = -1;
859   server_ok    = -1;
860   driver_ok    = -1;
861   event        = 0U;
862   duration     = 0xFFFFFFFFUL;
863   systick_freq = osKernelGetSysTimerFreq();
864
865   memset(&spi_serv_cap, 0, sizeof(spi_serv_cap));
866   memset(&msg_buf,      0, sizeof(msg_buf));
867
868   // Allocate buffers for transmission, reception and comparison
869   // (maximum size is incremented by 4 bytes to ensure that buffer can be aligned to 4 bytes)
870
871   ptr_tx_buf_alloc = malloc(SPI_BUF_MAX + 4U);
872   if (((uint32_t)ptr_tx_buf_alloc & 3U) != 0U) {
873     // If allocated memory is not 4 byte aligned, use next 4 byte aligned address for ptr_tx_buf
874     ptr_tx_buf = (uint8_t *)((((uint32_t)ptr_tx_buf_alloc) + 3U) & (~3U));
875   } else {
876     // If allocated memory is 4 byte aligned, use it directly
877     ptr_tx_buf = (uint8_t *)ptr_tx_buf_alloc;
878   }
879   ptr_rx_buf_alloc = malloc(SPI_BUF_MAX + 4U);
880   if (((uint32_t)ptr_rx_buf_alloc & 3U) != 0U) {
881     ptr_rx_buf = (uint8_t *)((((uint32_t)ptr_rx_buf_alloc) + 3U) & (~3U));
882   } else {
883     ptr_rx_buf = (uint8_t *)ptr_rx_buf_alloc;
884   }
885   ptr_cmp_buf_alloc = malloc(SPI_BUF_MAX + 4U);
886   if (((uint32_t)ptr_cmp_buf_alloc & 3U) != 0U) {
887     ptr_cmp_buf = (uint8_t *)((((uint32_t)ptr_cmp_buf_alloc) + 3U) & (~3U));
888   } else {
889     ptr_cmp_buf = (uint8_t *)ptr_cmp_buf_alloc;
890   }
891 }
892
893 /*
894   \fn            void SPI_DV_Uninitialize (void)
895   \brief         De-initialize testing environment after SPI testing.
896   \detail        This function is called by the driver validation framework after SPI testing is finished.
897                  It frees memory buffers used for the SPI testing.
898   \return        none
899 */
900 void SPI_DV_Uninitialize (void) {
901
902   if (ptr_tx_buf_alloc != NULL) {
903     free(ptr_tx_buf_alloc);
904     ptr_tx_buf        = NULL;
905     ptr_tx_buf_alloc  = NULL;
906   }
907   if (ptr_rx_buf_alloc != NULL) {
908     free(ptr_rx_buf_alloc);
909     ptr_rx_buf        = NULL;
910     ptr_rx_buf_alloc  = NULL;
911   }
912   if (ptr_cmp_buf_alloc != NULL) {
913     free(ptr_cmp_buf_alloc);
914     ptr_cmp_buf       = NULL;
915     ptr_cmp_buf_alloc = NULL;
916   }
917 }
918
919 #endif                                  // End of exclude form the documentation
920
921 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
922 /**
923 \defgroup dv_spi SPI Validation
924 \brief SPI driver validation
925 \details
926 The SPI validation performs the following tests:
927 - API interface compliance.
928 - Data exchange with various speeds, transfer sizes and communication settings.
929 - Error event signaling.
930
931 Two Test Modes are available: <b>Loopback</b> and <b>SPI Server</b>.
932
933 Test Mode : <b>Loopback</b>
934 ---------------------------
935
936 This test mode allows only limited validation of the SPI Driver.<br>
937 It is recommended that this test mode is used only as a proof that driver is 
938 good enough to be tested with the <b>SPI Server</b>.
939
940 To enable this mode of testing in the <b>DV_SPI_Config.h</b> configuration file select 
941 the <b>Configuration: Test Mode: Loopback</b> setting.
942
943 Required pin connection for the <b>Loopback</b> test mode:
944
945 \image html spi_loopback_pin_connections.png
946
947 \note In this mode following operations / settings cannot be tested:
948  - SPI slave mode
949  - Slave Select line functionality
950  - operation of the Receive function
951  - data content sent by the Send function
952  - clock / frame format and bit order settings
953  - data bit settings other then: 8, 16, 24 and 32
954  - error event signaling
955
956 Test Mode : <b>SPI Server</b>
957 -----------------------------
958
959 This test mode allows extensive validation of the SPI Driver.<br>
960 Results of the Driver Validation in this test mode are relevant as a proof of driver compliance to the CMSIS-Driver specification.
961
962 To perform extensive communication tests, it is required to use an 
963 \ref spi_server "SPI Server" running on a dedicated hardware.
964
965 To enable this mode of testing in the <b>DV_SPI_Config.h</b> configuration file select 
966 the <b>Configuration: Test Mode: SPI Server</b> setting.
967
968 Required pin connections for the <b>SPI Server</b> test mode:
969
970 \image html spi_server_pin_connections.png
971
972 \defgroup spi_tests Tests
973 \ingroup dv_spi
974 */
975
976 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
977 /* SPI Driver Management tests                                                                                              */
978 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
979 /**
980 \defgroup spi_tests_drv_mgmt Driver Management
981 \ingroup spi_tests
982 \details
983 These tests verify API and operation of the SPI driver management functions.
984
985 The driver management tests verify the following driver functions
986 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
987  - \b GetVersion
988 \code
989   ARM_DRIVER_VERSION   GetVersion      (void);
990 \endcode
991  - \b GetCapabilities
992 \code
993   ARM_SPI_CAPABILITIES GetCapabilities (void);
994 \endcode
995  - \b Initialize
996 \code
997   int32_t              Initialize      (ARM_SPI_SignalEvent_t cb_event);
998 \endcode
999  - \b Uninitialize
1000 \code
1001   int32_t              Uninitialize    (void);
1002 \endcode
1003  - \b PowerControl
1004 \code
1005   int32_t              PowerControl    (ARM_POWER_STATE state);
1006 \endcode
1007
1008 @{
1009 */
1010
1011 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1012 /**
1013 \brief Function: Function SPI_GetVersion
1014 \details
1015 The function \b SPI_GetVersion verifies the \b GetVersion function.
1016 \code
1017   ARM_DRIVER_VERSION GetVersion (void);
1018 \endcode
1019
1020 Testing sequence:
1021   - Driver is uninitialized and peripheral is powered-off:
1022     - Call GetVersion function
1023     - Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1024 */
1025 void SPI_GetVersion (void) {
1026   ARM_DRIVER_VERSION ver;
1027
1028   ver = drv->GetVersion();
1029
1030   // Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1031   TEST_ASSERT((ver.api >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)) && (ver.drv >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)));
1032
1033   (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));
1034   TEST_MESSAGE(msg_buf);
1035 }
1036
1037 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1038 /**
1039 \brief Function: Function SPI_GetCapabilities
1040 \details
1041 The function \b SPI_GetCapabilities verifies the \b GetCapabilities function.
1042 \code
1043   ARM_SPI_CAPABILITIES GetCapabilities (void);
1044 \endcode
1045
1046 Testing sequence:
1047   - Driver is uninitialized and peripheral is powered-off:
1048     - Call GetCapabilities function
1049     - Assert that GetCapabilities function returned capabilities structure with reserved field 0
1050 */
1051 void SPI_GetCapabilities (void) {
1052   ARM_SPI_CAPABILITIES cap;
1053
1054   cap = drv->GetCapabilities();
1055
1056   // Assert that GetCapabilities function returned capabilities structure with reserved field 0
1057   TEST_ASSERT_MESSAGE((cap.reserved == 0U), "[FAILED] Capabilities reserved field must be 0");
1058 }
1059
1060 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1061 /**
1062 \brief Function: Function SPI_Initialize_Uninitialize
1063 \details
1064 The function \b SPI_Initialize_Uninitialize verifies the \b Initialize and \b Uninitialize functions.
1065 \code
1066   int32_t Initialize (ARM_SPI_SignalEvent_t cb_event);
1067 \endcode
1068 \code
1069   int32_t Uninitialize (void);
1070 \endcode
1071
1072 Testing sequence:
1073   - Driver is uninitialized and peripheral is powered-off:
1074     - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1075     - Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1076     - Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1077     - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1078     - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1079     - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1080     - Call GetDataCount function and assert that it returned 0
1081     - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1082     - Call GetStatus function
1083     - Assert that GetStatus function returned status structure with busy flag 0
1084     - Assert that GetStatus function returned status structure with data_lost flag 0
1085     - Assert that GetStatus function returned status structure with mode_fault flag 0
1086     - Assert that GetStatus function returned status structure with reserved field 0
1087     - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1088   - Driver is initialized and peripheral is powered-off:
1089     - Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1090     - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1091   - Driver is uninitialized and peripheral is powered-off:
1092     - Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1093   - Driver is initialized and peripheral is powered-off:
1094     - Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1095     - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1096   - Driver is uninitialized and peripheral is powered-off:
1097     - Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1098     - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1099   - Driver is initialized and peripheral is powered-off:
1100     - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1101   - Driver is initialized and peripheral is powered-on:
1102     - Call Control function and assert that it returned ARM_DRIVER_OK status
1103     - Call Transfer function and assert that it returned ARM_DRIVER_OK status
1104     - Call GetStatus function
1105     - Assert that GetStatus function returned status structure with busy flag 1
1106     - Call Uninitialize function with transfer active and assert that it returned ARM_DRIVER_OK status<br>
1107       (this must unconditionally terminate active transfer, power-off the peripheral and uninitialize the driver)
1108   - Driver is uninitialized and peripheral is powered-off:
1109     - Call GetStatus function
1110     - Assert that GetStatus function returned status structure with busy flag 0
1111 */
1112 void SPI_Initialize_Uninitialize (void) {
1113   ARM_SPI_STATUS stat;
1114
1115   // Driver is uninitialized and peripheral is powered-off:
1116   // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1117   TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_ERROR);
1118
1119   // Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1120   TEST_ASSERT(drv->PowerControl (ARM_POWER_LOW) == ARM_DRIVER_ERROR);
1121
1122   // Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1123   TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_ERROR);
1124
1125   // Call Send function and assert that it returned ARM_DRIVER_ERROR status
1126   TEST_ASSERT(drv->Send (ptr_tx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1127
1128   // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1129   TEST_ASSERT(drv->Receive (ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1130
1131   // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1132   TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1133
1134   // Call GetDataCount function and assert that it returned 0
1135   TEST_ASSERT(drv->GetDataCount () == 0U);
1136
1137   // Call Control function and assert that it returned ARM_DRIVER_ERROR status
1138   TEST_ASSERT(drv->Control (ARM_SPI_MODE_MASTER | ARM_SPI_DATA_BITS(SPI_CFG_DEF_DATA_BITS), SPI_CFG_DEF_BUS_SPEED) == ARM_DRIVER_ERROR);
1139
1140   // Call GetStatus function
1141   stat = drv->GetStatus();
1142
1143   // Assert that GetStatus function returned status structure with busy flag 0
1144   TEST_ASSERT(stat.busy == 0U);
1145
1146   // Assert that GetStatus function returned status structure with data_lost flag 0
1147   TEST_ASSERT(stat.data_lost == 0U);
1148
1149   // Assert that GetStatus function returned status structure with mode_fault flag 0
1150   TEST_ASSERT(stat.mode_fault == 0U);
1151
1152   // Assert that GetStatus function returned status structure with reserved field 0
1153   TEST_ASSERT(stat.reserved == 0U);
1154
1155   // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1156   TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1157
1158   // Driver is initialized and peripheral is powered-off:
1159   // Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1160   TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1161
1162   // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1163   TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1164
1165   // Driver is uninitialized and peripheral is powered-off:
1166   // Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1167   TEST_ASSERT(drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK);
1168
1169   // Driver is initialized and peripheral is powered-off:
1170   // Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1171   TEST_ASSERT(drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK);
1172
1173   // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1174   TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1175
1176   // Driver is uninitialized and peripheral is powered-off:
1177   // Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1178   TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1179
1180   // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1181   TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1182
1183   // Driver is initialized and peripheral is powered-off:
1184   // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1185   TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1186
1187   // Driver is initialized and peripheral is powered-on:
1188   // Call Control function and assert that it returned ARM_DRIVER_OK status
1189   TEST_ASSERT(drv->Control (ARM_SPI_MODE_MASTER | ARM_SPI_DATA_BITS(SPI_CFG_DEF_DATA_BITS), SPI_CFG_DEF_BUS_SPEED) == ARM_DRIVER_OK);
1190
1191   // Call Transfer function and assert that it returned ARM_DRIVER_OK status
1192   TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
1193
1194   // Call GetStatus function
1195   stat = drv->GetStatus();
1196
1197   // Assert that GetStatus function returned status structure with busy flag 1
1198   TEST_ASSERT(stat.busy == 1U);
1199
1200   // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1201   // (this must unconditionally terminate active transfer, power-off the peripheral and uninitialize the driver)
1202   TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1203
1204   // Driver is uninitialized and peripheral is powered-off:
1205   // Call GetStatus function
1206   stat = drv->GetStatus();
1207
1208   // Assert that GetStatus function returned status structure with busy flag 0
1209   TEST_ASSERT(stat.busy == 0U);
1210
1211 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
1212   // Ensure that SPI Server (if used) is ready for command reception
1213   (void)osDelay(SPI_CFG_XFER_TIMEOUT + 10U);
1214 #endif
1215 }
1216
1217 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1218 /**
1219 \brief Function: Function SPI_PowerControl
1220 \details
1221 The function \b SPI_PowerControl verifies the \b PowerControl function.
1222 \code
1223   int32_t PowerControl (ARM_POWER_STATE state);
1224 \endcode
1225
1226 Testing sequence:
1227   - Driver is initialized and peripheral is powered-off:
1228     - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1229     - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1230     - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1231     - Call GetDataCount function and assert that it returned 0
1232     - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1233     - Call GetStatus function
1234     - Assert that GetStatus function returned status structure with busy flag 0
1235     - Assert that GetStatus function returned status structure with data_lost flag 0
1236     - Assert that GetStatus function returned status structure with mode_fault flag 0
1237     - Assert that GetStatus function returned status structure with reserved field 0
1238     - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1239     - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1240     - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1241   - Driver is initialized and peripheral is powered-on:
1242     - Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
1243     - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1244   - Driver is initialized and peripheral is powered-off:
1245     - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1246     - Call PowerControl(ARM_POWER_LOW) function
1247   - Driver is initialized and peripheral is powered-on or in low-power mode:
1248     - Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
1249     - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1250   - Driver is initialized and peripheral is powered-on:
1251     - Call Control function and assert that it returned ARM_DRIVER_OK status
1252     - Call Transfer function and assert that it returned ARM_DRIVER_OK status
1253     - Call GetStatus function
1254     - Assert that GetStatus function returned status structure with busy flag 1
1255     - Call PowerControl(ARM_POWER_OFF) function with transfer active and assert that it returned ARM_DRIVER_OK status<br>
1256       (this must unconditionally terminate active transfer and power-off the peripheral)
1257   - Driver is initialized and peripheral is powered-off:
1258     - Call GetStatus function
1259     - Assert that GetStatus function returned status structure with busy flag 0
1260 */
1261 void SPI_PowerControl (void) {
1262   int32_t        ret;
1263   ARM_SPI_STATUS stat;
1264
1265   (void)drv->Initialize (NULL);
1266
1267   // Driver is initialized and peripheral is powered-off:
1268   // Call Send function and assert that it returned ARM_DRIVER_ERROR status
1269   TEST_ASSERT(drv->Send (ptr_tx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1270
1271   // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1272   TEST_ASSERT(drv->Receive (ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1273
1274   // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1275   TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1276
1277   // Call GetDataCount function and assert that it returned 0
1278   TEST_ASSERT(drv->GetDataCount () == 0U);
1279
1280   // Call Control function and assert that it returned ARM_DRIVER_ERROR status
1281   TEST_ASSERT(drv->Control (ARM_SPI_MODE_MASTER | ARM_SPI_DATA_BITS(SPI_CFG_DEF_DATA_BITS), SPI_CFG_DEF_BUS_SPEED) == ARM_DRIVER_ERROR);
1282
1283   // Call GetStatus function
1284   stat = drv->GetStatus();
1285
1286   // Assert that GetStatus function returned status structure with busy flag 0
1287   TEST_ASSERT(stat.busy == 0U);
1288
1289   // Assert that GetStatus function returned status structure with data_lost flag 0
1290   TEST_ASSERT(stat.data_lost == 0U);
1291
1292   // Assert that GetStatus function returned status structure with mode_fault flag 0
1293   TEST_ASSERT(stat.mode_fault == 0U);
1294
1295   // Assert that GetStatus function returned status structure with reserved field 0
1296   TEST_ASSERT(stat.reserved == 0U);
1297
1298   // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1299   TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1300
1301   // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1302   TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1303
1304   // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1305   TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1306
1307   // Driver is initialized and peripheral is powered-on:
1308   // Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
1309   TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1310
1311   // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1312   TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1313
1314   // Driver is initialized and peripheral is powered-off:
1315   // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1316   TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1317
1318   // Call PowerControl(ARM_POWER_LOW) function
1319   ret = drv->PowerControl (ARM_POWER_LOW);
1320
1321   // Driver is initialized and peripheral is powered-on or in low-power mode:
1322   // Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
1323   TEST_ASSERT((ret == ARM_DRIVER_OK) || (ret == ARM_DRIVER_ERROR_UNSUPPORTED));
1324   if (ret == ARM_DRIVER_ERROR_UNSUPPORTED) {
1325     TEST_MESSAGE("[WARNING] PowerControl (ARM_POWER_LOW) is not supported");
1326   }
1327
1328   // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1329   TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1330
1331   // Driver is initialized and peripheral is powered-on:
1332   // Call Control function and assert that it returned ARM_DRIVER_OK status
1333   TEST_ASSERT(drv->Control (ARM_SPI_MODE_MASTER | ARM_SPI_DATA_BITS(SPI_CFG_DEF_DATA_BITS), SPI_CFG_DEF_BUS_SPEED) == ARM_DRIVER_OK);
1334
1335   // Call Transfer function and assert that it returned ARM_DRIVER_OK status
1336   TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
1337
1338   // Call GetStatus function
1339   stat = drv->GetStatus();
1340
1341   // Assert that GetStatus function returned status structure with busy flag 1
1342   TEST_ASSERT(stat.busy == 1U);
1343
1344   // Call PowerControl(ARM_POWER_OFF) function with transfer active and assert that it returned ARM_DRIVER_OK status
1345   // (this must unconditionally terminate active transfer and power-off the peripheral)
1346   TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1347
1348   // Driver is initialized and peripheral is powered-off:
1349   // Call GetStatus function
1350   stat = drv->GetStatus();
1351
1352   // Assert that GetStatus function returned status structure with busy flag 0
1353   TEST_ASSERT(stat.busy == 0U);
1354
1355   (void)drv->Uninitialize ();
1356
1357 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
1358   // Ensure that SPI Server (if used) is ready for command reception
1359   (void)osDelay(SPI_CFG_XFER_TIMEOUT + 10U);
1360 #endif
1361 }
1362
1363 /**
1364 @}
1365 */
1366 // End of spi_tests_drv_mgmt
1367
1368 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1369 /* SPI Data Exchange tests                                                                                                  */
1370 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1371 /**
1372 \defgroup spi_tests_data_xchg Data Exchange
1373 \ingroup spi_tests
1374 \details
1375 These tests verify API and operation of the SPI data exchange functions.
1376
1377 The data exchange tests verify the following driver functions
1378 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
1379  - \b Send
1380 \code
1381   int32_t        Send         (const void *data,                    uint32_t num);
1382 \endcode
1383  - \b Receive
1384 \code
1385   int32_t        Receive      (      void *data,                    uint32_t num);
1386 \endcode
1387  - \b Transfer
1388 \code
1389   int32_t        Transfer     (const void *data_out, void *data_in, uint32_t num);
1390 \endcode
1391  - \b GetDataCount
1392 \code
1393   uint32_t       GetDataCount (void);
1394 \endcode
1395  - \b Control
1396 \code
1397   int32_t        Control      (uint32_t control, uint32_t arg);
1398 \endcode
1399  - \b GetStatus
1400 \code
1401   ARM_SPI_STATUS GetStatus    (void);
1402 \endcode
1403  - \b SignalEvent
1404 \code
1405   void (*ARM_SPI_SignalEvent_t) (uint32_t event);
1406 \endcode
1407
1408 All of these tests execute a data exchange and check the result of this data exchange.
1409
1410 Data exchange test procedure when Test Mode <b>SPI Server</b> is selected:
1411   - send command "SET BUF TX,.." to the SPI Server: Set Tx buffer
1412   - send command "SET BUF RX,.." to the SPI Server: Set Rx buffer
1413   - send command "SET COM .."    to the SPI Server: Set communication settings for the next XFER command
1414   - send command "XFER .."       to the SPI Server: Activate transfer
1415   - driver Control: Configure the SPI interface
1416   - driver Control: Set the default Tx value
1417   - driver Send/Receive/Transfer: Start the requested operation
1418   - driver GetStatus/SignalEvent: Wait for the current operation to finish or time out<br>
1419     (operation is finished when busy flag is 0 and completed event was signaled)
1420   - assert that operation has finished in expected time
1421   - assert that ARM_SPI_EVENT_TRANSFER_COMPLETE event was signaled
1422   - driver GetStatus: Assert that busy flag is 0
1423   - driver GetDataCount: Assert that number of transferred items is same as requested
1424   - if operation has timed out call driver Control function to Abort operation and wait timeout time<br>
1425     to make sure that the SPI Server is ready for the next command
1426   - assert that received content is as expected
1427   - send command "GET BUF RX,.." to the SPI Server: Get Rx buffer
1428   - assert that sent content (read from the SPI Server's receive buffer) is as expected
1429
1430 Data exchange <b>Abort</b> test procedure when Test Mode <b>SPI Server</b> is selected:
1431   - send command "SET BUF TX,.." to the SPI Server: Set Tx buffer
1432   - send command "SET BUF RX,.." to the SPI Server: Set Rx buffer
1433   - send command "SET COM .."    to the SPI Server: Set communication settings for the next XFER command
1434   - send command "XFER .."       to the SPI Server: Activate transfer
1435   - driver Control: Configure the SPI interface
1436   - driver Control: Set the default Tx value
1437   - driver Send/Receive/Transfer: Start the requested operation
1438   - wait up to 1 ms
1439   - driver Control: Abort the current operation
1440   - driver GetStatus: Assert that busy flag is 0
1441   - driver GetDataCount: Assert that number of transferred items is less than requested
1442
1443 Data exchange test procedure when Test Mode <b>Loopback</b> is selected:
1444   - driver Control: Configure the SPI interface
1445   - driver Control: Set the default Tx value
1446   - driver Send/Transfer: Start the requested operation
1447   - driver GetStatus/SignalEvent: Wait for the current operation to finish or time out<br>
1448     (operation is finished when busy flag is 0 and completed event was signaled)
1449   - assert that operation has finished in expected time
1450   - assert that ARM_SPI_EVENT_TRANSFER_COMPLETE event was signaled
1451   - driver GetStatus: Assert that busy flag is 0
1452   - driver GetDataCount: Assert that number of transferred items is same as requested
1453   - if operation has timed out call driver Control function to Abort operation
1454   - assert that received content is as expected (for Transfer operation only)
1455
1456 \note Limitations of Data Exchange tests if Test Mode <b>Loopback</b> is selected:
1457  - only Master mode with Slave Select not used can be tested
1458  - Receive function cannot be tested
1459  - format tests are not supported
1460  - only 8, 16, 24 and 32 data bit tests are supported
1461  - bit order tests are not supported
1462 @{
1463 */
1464
1465 #ifndef __DOXYGEN__                     // Exclude form the documentation
1466 /*
1467   \brief         Execute SPI data exchange or data exchange abort operation.
1468   \param[in]     operation      operation (OP_SEND.. OP_ABORT_TRANSFER)
1469   \param[in]     mode           mode (MODE_MASTER or MODE_SLAVE)
1470   \param[in]     format         clock/frame format (0 = polarity0/phase0 .. 5 = Microwire)
1471   \param[in]     data_bits      data bits (1 .. 32)
1472   \param[in]     bit_order      bit order (BO_MSB_TO_LSB or BO_LSB_TO_MSB)
1473   \param[in]     ss_mode        Slave Select mode (SS_MODE_xxx)
1474   \param[in]     bus_speed      bus speed in bits per second (bps)
1475   \param[in]     num            number of items to send, receive or transfer
1476   \return        none
1477 */
1478 static void SPI_DataExchange_Operation (uint32_t operation, uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed, uint32_t num) {
1479   // volatile specifier is used to prevent compiler from optimizing variables 
1480   // in a way that they cannot be seen with debugger
1481   volatile  int32_t       stat, def_tx_stat;
1482   volatile uint32_t       drv_mode, drv_format, drv_data_bits, drv_bit_order, drv_ss_mode;
1483   volatile uint32_t       srv_mode, srv_ss_mode;
1484   volatile ARM_SPI_STATUS spi_stat;
1485   volatile uint32_t       data_count;
1486            uint32_t       start_cnt, max_cnt;
1487            uint32_t       val, delay, i;
1488            uint8_t        chk_data;
1489
1490   // Prepare parameters for SPI Server and Driver configuration
1491   switch (mode) {
1492     case MODE_INACTIVE:
1493       TEST_FAIL_MESSAGE("[FAILED] Inactive mode! Data exchange operation aborted!");
1494       return;
1495     case MODE_MASTER:
1496       drv_mode = ARM_SPI_MODE_MASTER;
1497       srv_mode = 1U;
1498       delay    = 0U;
1499       break;
1500     case MODE_SLAVE:
1501       drv_mode = ARM_SPI_MODE_SLAVE;
1502       srv_mode = 0U;
1503       delay    = 20U;
1504       break;
1505     default:
1506       TEST_FAIL_MESSAGE("[FAILED] Unknown mode! Data exchange operation aborted!");
1507       return;
1508   }
1509
1510   switch (format) {
1511     case FORMAT_CPOL0_CPHA0:
1512       drv_format = ARM_SPI_CPOL0_CPHA0;
1513       break;
1514     case FORMAT_CPOL0_CPHA1:
1515       drv_format = ARM_SPI_CPOL0_CPHA1;
1516       break;
1517     case FORMAT_CPOL1_CPHA0:
1518       drv_format = ARM_SPI_CPOL1_CPHA0;
1519       break;
1520     case FORMAT_CPOL1_CPHA1:
1521       drv_format = ARM_SPI_CPOL1_CPHA1;
1522       break;
1523     case FORMAT_TI:
1524       drv_format = ARM_SPI_TI_SSI;
1525       break;
1526     case FORMAT_MICROWIRE:
1527       drv_format = ARM_SPI_MICROWIRE;
1528       break;
1529     default:
1530       TEST_FAIL_MESSAGE("[FAILED] Unknown clock / frame format! Data exchange operation aborted!");
1531       return;
1532   }
1533
1534   if ((data_bits > 0U) && (data_bits <= 32U)) {
1535     drv_data_bits = ARM_SPI_DATA_BITS(data_bits);
1536   } else {
1537     TEST_FAIL_MESSAGE("[FAILED] Data bits not in range 1 to 32! Data exchange operation aborted!");
1538     return;
1539   }
1540
1541   switch (bit_order) {
1542     case BO_MSB_TO_LSB:
1543       drv_bit_order = ARM_SPI_MSB_LSB;
1544       break;
1545     case BO_LSB_TO_MSB:
1546       drv_bit_order = ARM_SPI_LSB_MSB;
1547       break;
1548     default:
1549       TEST_FAIL_MESSAGE("[FAILED] Unknown bit order! Data exchange operation aborted!");
1550       return;
1551   }
1552
1553   if (mode == MODE_MASTER) {
1554     switch (ss_mode) {
1555       case SS_MODE_MASTER_UNUSED:
1556         drv_ss_mode = ARM_SPI_SS_MASTER_UNUSED;
1557         srv_ss_mode = 0U;
1558         break;
1559       case SS_MODE_MASTER_SW:
1560         drv_ss_mode = ARM_SPI_SS_MASTER_SW;
1561         srv_ss_mode = 1U;
1562         break;
1563       case SS_MODE_MASTER_HW_OUTPUT:
1564         drv_ss_mode = ARM_SPI_SS_MASTER_HW_OUTPUT;
1565         srv_ss_mode = 1U;
1566         break;
1567       case SS_MODE_MASTER_HW_INPUT:
1568         drv_ss_mode = ARM_SPI_SS_MASTER_UNUSED;
1569         srv_ss_mode = 0U;
1570         break;
1571       default:
1572         TEST_FAIL_MESSAGE("[FAILED] Unknown Slave Select mode! Data exchange operation aborted!");
1573         return;
1574     }
1575   } else {
1576     switch (ss_mode) {
1577       case SS_MODE_SLAVE_HW:
1578         drv_ss_mode = ARM_SPI_SS_SLAVE_HW;
1579         srv_ss_mode = 1U;
1580         break;
1581       case SS_MODE_SLAVE_SW:
1582         drv_ss_mode = ARM_SPI_SS_SLAVE_SW;
1583         srv_ss_mode = 0U;
1584         break;
1585       default:
1586         TEST_FAIL_MESSAGE("[FAILED] Unknown Slave Select mode! Data exchange operation aborted!");
1587         return;
1588     }
1589   }
1590
1591   // Check that SPI status is not busy before starting data exchange test
1592   spi_stat = drv->GetStatus();          // Get SPI status
1593   if (spi_stat.busy != 0U) {
1594     // If busy flag is still active
1595     (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy active before operation! Data exchange operation aborted!");
1596     return;
1597   }
1598   TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
1599
1600   do {
1601 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
1602     if (ComConfigDefault() != EXIT_SUCCESS) { break; }
1603     if (CmdSetBufTx('S')   != EXIT_SUCCESS) { break; }
1604     if (CmdSetBufRx('?')   != EXIT_SUCCESS) { break; }
1605     if (CmdSetCom  (srv_mode, format, data_bits, bit_order, srv_ss_mode, bus_speed) != EXIT_SUCCESS) { break; }
1606     if (CmdXfer    (num, delay, SPI_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
1607 #else                                   // If Test Mode Loopback is selected
1608     // Remove warnings for unused variables
1609     (void)srv_mode;
1610     (void)srv_ss_mode;
1611     (void)delay;
1612 #endif
1613
1614     // Initialize buffers
1615     memset(ptr_tx_buf,  (int32_t)'!' , SPI_BUF_MAX);
1616     memset(ptr_tx_buf,  (int32_t)'T' , num * DataBitsToBytes(data_bits));
1617     memset(ptr_rx_buf,  (int32_t)'?' , SPI_BUF_MAX);
1618     memset(ptr_cmp_buf, (int32_t)'?' , SPI_BUF_MAX);
1619
1620     // Configure required communication settings
1621     if (mode == MODE_MASTER) {
1622       stat = drv->Control (drv_mode | drv_format | drv_data_bits | drv_bit_order | drv_ss_mode, bus_speed);
1623       (void)osDelay(10U);               // Give time to SPI Server to prepare Slave transfer
1624     } else {
1625       // For Slave mode bus speed argument is not used
1626       stat = drv->Control (drv_mode | drv_format | drv_data_bits | drv_bit_order | drv_ss_mode, 0U);
1627     }
1628     if (stat != ARM_DRIVER_OK) {
1629       // If configuration has failed
1630       (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Control function returned", str_ret[-stat]);
1631     }
1632     // Assert that Control function returned ARM_DRIVER_OK
1633     TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1634     if (stat != ARM_DRIVER_OK) {
1635       // If Control function has failed there is no sense to try to execute the data exchange
1636       (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U);  // Wait for SPI Server to timeout the XFER command
1637       return;
1638     }
1639
1640     // Set default Tx value to 'D' byte values (only for master mode)
1641     if (mode == MODE_MASTER) {
1642       val = ((uint32_t)'D' << 24) | ((uint32_t)'D' << 16) | ((uint32_t)'D' << 8) | (uint32_t)'D';
1643       stat = drv->Control (ARM_SPI_SET_DEFAULT_TX_VALUE, val);
1644       def_tx_stat = stat;
1645       if ((stat != ARM_DRIVER_OK) && (stat != ARM_DRIVER_ERROR_UNSUPPORTED)) {
1646         // If set default Tx value has failed
1647         (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Set default Tx value returned", str_ret[-stat]);
1648       }
1649       // Assert that Control function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED
1650       TEST_ASSERT_MESSAGE((stat == ARM_DRIVER_OK) || (stat == ARM_DRIVER_ERROR_UNSUPPORTED), msg_buf);
1651
1652       if (stat == ARM_DRIVER_ERROR_UNSUPPORTED) {
1653         // If set default Tx value is not supported
1654         (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] %s: %s", str_oper[operation], "Set default Tx value is not supported");
1655         TEST_MESSAGE(msg_buf);
1656       }
1657     } else {
1658       // For slave mode default Tx is not tested
1659       def_tx_stat = ARM_DRIVER_ERROR_UNSUPPORTED;
1660     }
1661
1662     event             = 0U;
1663     duration          = 0xFFFFFFFFUL;
1664     data_count        = 0U;
1665     data_count_sample = 0U;
1666     chk_data          = 1U;
1667     max_cnt           = (systick_freq /1024U) * (SPI_CFG_XFER_TIMEOUT + 10U);
1668     start_cnt         = osKernelGetSysTimerCount();
1669
1670     if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) || 
1671         ((mode == MODE_SLAVE)  && (ss_mode == SS_MODE_SLAVE_SW)))  {
1672       // If operation requires software Slave Select driving, activate Slave Select
1673       stat = drv->Control (ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE);
1674       if (stat != ARM_DRIVER_OK) {
1675         // If driving of Slave Select to active state has failed
1676         (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
1677       }
1678       // Assert that Control function returned ARM_DRIVER_OK
1679       TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1680     }
1681
1682     // Start the data exchange operation
1683     switch (operation & 0x0FU) {
1684       case OP_SEND:
1685       case OP_ABORT_SEND:
1686         stat = drv->Send(ptr_tx_buf, num);
1687         if (stat != ARM_DRIVER_OK) {
1688           // If Send activation has failed
1689           (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Send function returned", str_ret[-stat]);
1690         }
1691         // Assert that Send function returned ARM_DRIVER_OK
1692         TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1693         break;
1694       case OP_RECEIVE:
1695       case OP_ABORT_RECEIVE:
1696         stat = drv->Receive(ptr_rx_buf, num);
1697         if (stat != ARM_DRIVER_OK) {
1698           // If Receive activation has failed
1699           (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receive function returned", str_ret[-stat]);
1700         }
1701         // Assert that Receive function returned ARM_DRIVER_OK
1702         TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1703         break;
1704       case OP_TRANSFER:
1705       case OP_ABORT_TRANSFER:
1706         stat = drv->Transfer(ptr_tx_buf, ptr_rx_buf, num);
1707         if (stat != ARM_DRIVER_OK) {
1708           // If Transfer activation has failed
1709           (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transfer function returned", str_ret[-stat]);
1710         }
1711         // Assert that Transfer function returned ARM_DRIVER_OK
1712         TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1713         break;
1714       default:
1715         TEST_FAIL_MESSAGE("[FAILED] Unknown operation! Data exchange operation aborted!");
1716         return;
1717     }
1718     if (stat != ARM_DRIVER_OK) {
1719       // If Send/Receive/Transfer start has failed there is no sense to try to continue with the data exchange
1720       (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U);  // Wait for SPI Server to timeout the XFER command
1721       return;
1722     }
1723
1724     if ((operation == OP_ABORT_SEND)     ||     // This IF block tests only abort functionality
1725         (operation == OP_ABORT_RECEIVE)  ||
1726         (operation == OP_ABORT_TRANSFER)) {
1727       (void)osDelay(1U);                        // Wait short time before doing Abort
1728       stat = drv->Control (ARM_SPI_ABORT_TRANSFER, 0U);
1729       if (stat != ARM_DRIVER_OK) {
1730         // If Abort has failed
1731         (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
1732       }
1733       // Assert that Control function returned ARM_DRIVER_OK
1734       TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1735
1736       if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) || 
1737           ((mode == MODE_SLAVE)  && (ss_mode == SS_MODE_SLAVE_SW)))  {
1738         // If operation requires software Slave Select driving, deactivate Slave Select
1739         drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE);
1740       }
1741       spi_stat = drv->GetStatus();              // Get SPI status
1742       if (spi_stat.busy != 0U) {
1743         // If busy flag is still active
1744         (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy still active after Abort");
1745       }
1746       // Assert that busy flag is not active
1747       TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
1748
1749       data_count = drv->GetDataCount();         // Get data count
1750       if (data_count >= num) {
1751         // If data count is more or equal to number of items then Abort has failed
1752         (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetDataCount returned", data_count, "after Abort of", num, "items");
1753       }
1754       // Assert data count is less then number of items requested for exchange
1755       TEST_ASSERT_MESSAGE(data_count < num, msg_buf);
1756
1757       (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U);  // Wait for SPI Server to timeout aborted operation
1758
1759       return;                                   // Here Abort test is finished, exit
1760     }
1761
1762     // Wait for operation to finish (status busy is 0 and event complete signaled, or timeout)
1763     do {
1764       if (data_count_sample == 0U) {
1765         // Store first data count different than 0
1766         data_count_sample = drv->GetDataCount();  // Get data count
1767       }
1768       if ((drv->GetStatus().busy == 0U) && ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) != 0U)) {
1769         duration = osKernelGetSysTimerCount() - start_cnt;
1770         break;
1771       }
1772     } while ((osKernelGetSysTimerCount() - start_cnt) < max_cnt);
1773
1774     if (duration == 0xFFFFFFFFUL) {
1775       // If operation has timed out
1776       (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Operation timed out");
1777     }
1778     // Assert that operation has finished in expected time
1779     TEST_ASSERT_MESSAGE(duration != 0xFFFFFFFFUL, msg_buf);
1780
1781     if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) || 
1782         ((mode == MODE_SLAVE)  && (ss_mode == SS_MODE_SLAVE_SW)))  {
1783       // If operation requires software Slave Select driving, deactivate Slave Select
1784       stat = drv->Control (ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE);
1785       if (stat != ARM_DRIVER_OK) {
1786         // If driving of Slave Select to inactive state has failed
1787         (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
1788       }
1789       // Assert that Control function returned ARM_DRIVER_OK
1790       TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1791     }
1792
1793     if ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) == 0U) {
1794       // If transfer complete event was not signaled
1795       (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_SPI_EVENT_TRANSFER_COMPLETE was not signaled");
1796       chk_data = 0U;                            // Do not check transferred content
1797     }
1798     // Assert that ARM_SPI_EVENT_TRANSFER_COMPLETE was signaled
1799     TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) != 0U, msg_buf);
1800
1801     spi_stat = drv->GetStatus();                // Get SPI status
1802     if (spi_stat.busy != 0U) {
1803       // If busy flag is still active
1804       (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy still active after operation");
1805       chk_data = 0U;                            // Do not check transferred content
1806     }
1807     // Assert that busy flag is not active
1808     TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
1809
1810     if ((event & ARM_SPI_EVENT_DATA_LOST) != 0U) {
1811       // If data lost was signaled during the transfer
1812       (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_SPI_EVENT_DATA_LOST was signaled");
1813       chk_data = 0U;                            // Do not check transferred content
1814     }
1815     // Assert that ARM_SPI_EVENT_DATA_LOST was not signaled
1816     TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_DATA_LOST) == 0U, msg_buf);
1817
1818     data_count = drv->GetDataCount();           // Get data count
1819     if (data_count != num) {
1820       // If data count is different then number of items, then operation has failed
1821       (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetDataCount returned", data_count, "expected was", num, "items");
1822       chk_data = 0U;                            // Do not check transferred content
1823     }
1824     // Assert that data count is equal to number of items requested for exchange
1825     TEST_ASSERT_MESSAGE(data_count == num, msg_buf);
1826
1827     if ((drv->GetStatus().busy != 0U) || ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) == 0U)) {
1828       // If transfer did not finish in time, abort it
1829       (void)drv->Control(ARM_SPI_ABORT_TRANSFER, 0U);
1830       (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U);  // Wait for SPI Server to timeout aborted operation
1831     }
1832
1833     if (chk_data != 0U) {               // If transferred content should be checked
1834 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
1835       // Check received content for receive and transfer operations
1836       if ((operation == OP_RECEIVE) || (operation == OP_TRANSFER)) {
1837         memset(ptr_cmp_buf, (int32_t)'S', num * DataBitsToBytes(data_bits));
1838         stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
1839         if (stat != 0) {
1840           // If data received mismatches
1841           // Find on which byte mismatch starts
1842           for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
1843             if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
1844               break;
1845             }
1846           }
1847           (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]);
1848         }
1849         // Assert that data received is same as expected
1850         TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
1851       }
1852
1853       // Check sent content (by checking SPI Server's received buffer content)
1854       if ((mode == MODE_MASTER) || (operation != OP_RECEIVE) || (def_tx_stat == ARM_DRIVER_OK)) {
1855         // Check sent data in all cases except Slave mode Receive operation
1856         // with Default Tx not working or unsupported
1857         if (ComConfigDefault()       != EXIT_SUCCESS) { break; }
1858         if (CmdGetBufRx(SPI_BUF_MAX) != EXIT_SUCCESS) { break; }
1859
1860         if ((operation == OP_RECEIVE) && (def_tx_stat == ARM_DRIVER_OK)) {
1861           // Expected data received by SPI Server should be default Tx value
1862           memset(ptr_cmp_buf, (int32_t)'D', num * DataBitsToBytes(data_bits));
1863         }
1864         if ((operation == OP_SEND) || (operation == OP_TRANSFER)) {
1865           // Expected data received by SPI Server should be what was sent
1866           memset(ptr_cmp_buf, (int32_t)'T', num * DataBitsToBytes(data_bits));
1867         }
1868
1869         stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
1870         if (stat != 0) {
1871           // If data sent mismatches
1872           // Find on which byte mismatch starts
1873           for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
1874             if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
1875               break;
1876             }
1877           }
1878           if (operation == OP_RECEIVE) {
1879             // If sent was default Tx value, 'D' bytes
1880             (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, SPI 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]);
1881           } else {
1882             // If sent was 'T' bytes
1883             (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, SPI Server received 0x%02X, sent was 0x%02X", str_oper[operation], "Sent data mismatches on", i, ptr_rx_buf[i], ptr_cmp_buf[i]);
1884           }
1885         }
1886         // Assert data sent is same as expected
1887         TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
1888       }
1889
1890 #else                                   // If Test Mode Loopback is selected
1891       if (operation == OP_TRANSFER) {
1892         memset(ptr_cmp_buf, (int32_t)'T', num * DataBitsToBytes(data_bits));
1893         stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
1894         if (stat != 0) {
1895           // If data received mismatches
1896           // Find on which byte mismatch starts
1897           for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
1898             if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
1899               break;
1900             }
1901           }
1902           (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]);
1903         }
1904         // Assert that data received is same as expected
1905         TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
1906       }
1907 #endif
1908     }
1909
1910     return;
1911   } while (false);
1912
1913 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
1914   TEST_FAIL_MESSAGE("[FAILED] Problems in communication with SPI Server. Test aborted!");
1915 #endif
1916 }
1917
1918 #endif                                  // End of exclude form the documentation
1919
1920 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1921 /**
1922 \brief Function: Function SPI_Mode_Master_SS_Unused
1923 \details
1924 The function \b SPI_Mode_Master_SS_Unused verifies data exchange:
1925  - in <b>Master Mode</b> with <b>Slave Select line not used</b>
1926  - with default clock / frame format
1927  - with default data bits
1928  - with default bit order
1929  - at default bus speed
1930  - for default number of data items
1931
1932 \note In Test Mode <b>Loopback</b> Receive function is not checked
1933 */
1934 void SPI_Mode_Master_SS_Unused (void) {
1935
1936   if (InitDriver()   != EXIT_SUCCESS) { return; }
1937   if (CheckBuffers() != EXIT_SUCCESS) { return; }
1938 #if (SPI_SERVER_USED != 0)
1939   if (CheckServer()  != EXIT_SUCCESS) { return; }
1940   if ((spi_serv_cap.mode_mask & 2U) == 0U) {    // If SPI Server does not support Slave mode
1941     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
1942     return;
1943   }
1944 #endif
1945
1946   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_UNUSED, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1947 #if (SPI_SERVER_USED != 0)
1948   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_UNUSED, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1949 #endif
1950   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_UNUSED, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1951 }
1952
1953 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1954 /**
1955 \brief Function: Function SPI_Mode_Master_SS_Sw_Ctrl
1956 \details
1957 The function \b SPI_Mode_Master_SS_Sw_Ctrl verifies data exchange:
1958  - in <b>Master Mode</b> with <b>Slave Select line Software Controlled</b>
1959  - with default clock / frame format
1960  - with default data bits
1961  - with default bit order
1962  - at default bus speed
1963  - for default number of data items
1964
1965 \note In Test Mode <b>Loopback</b> this test is skipped
1966 */
1967 void SPI_Mode_Master_SS_Sw_Ctrl (void) {
1968
1969 #if (SPI_SERVER_USED != 0)
1970   if (InitDriver()   != EXIT_SUCCESS) { return; }
1971   if (CheckBuffers() != EXIT_SUCCESS) { return; }
1972   if (CheckServer()  != EXIT_SUCCESS) { return; }
1973   if ((spi_serv_cap.mode_mask & 2U) == 0U) {    // If SPI Server does not support Slave mode
1974     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
1975     return;
1976   }
1977
1978   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1979   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1980   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1981
1982 #else
1983   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
1984 #endif
1985 }
1986
1987 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1988 /**
1989 \brief Function: Function SPI_Mode_Master_SS_Hw_Ctrl_Out
1990 \details
1991 The function \b SPI_Mode_Master_SS_Hw_Ctrl_Out verifies data exchange:
1992  - in <b>Master Mode</b> with <b>Slave Select line Hardware Controlled Output</b>
1993  - with default clock / frame format
1994  - with default data bits
1995  - with default bit order
1996  - at default bus speed
1997  - for default number of data items
1998
1999 \note In Test Mode <b>Loopback</b> this test is skipped
2000 */
2001 void SPI_Mode_Master_SS_Hw_Ctrl_Out (void) {
2002
2003 #if (SPI_SERVER_USED != 0)
2004   if (InitDriver()   != EXIT_SUCCESS) { return; }
2005   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2006   if (CheckServer()  != EXIT_SUCCESS) { return; }
2007   if ((spi_serv_cap.mode_mask & 2U) == 0U) {    // If SPI Server does not support Slave mode
2008     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2009     return;
2010   }
2011
2012   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2013   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2014   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2015
2016 #else
2017   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2018 #endif
2019 }
2020
2021 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2022 /**
2023 \brief Function: Function SPI_Mode_Master_SS_Hw_Mon_In
2024 \details
2025 The function \b SPI_Mode_Master_SS_Hw_Mon_In verifies data exchange:
2026  - in <b>Master Mode</b> with <b>Slave Select line Hardware Monitored Input</b>
2027  - with default clock / frame format
2028  - with default data bits
2029  - with default bit order
2030  - at default bus speed
2031  - for default number of data items
2032
2033 \note In Test Mode <b>Loopback</b> this test is skipped
2034 */
2035 void SPI_Mode_Master_SS_Hw_Mon_In (void) {
2036
2037 #if (SPI_SERVER_USED != 0)
2038   if (InitDriver()   != EXIT_SUCCESS) { return; }
2039   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2040   if (CheckServer()  != EXIT_SUCCESS) { return; }
2041   if ((spi_serv_cap.mode_mask & 2U) == 0U) {    // If SPI Server does not support Slave mode
2042     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2043     return;
2044   }
2045
2046   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_INPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2047   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_INPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2048   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_INPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2049
2050 #else
2051   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2052 #endif
2053 }
2054
2055 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2056 /**
2057 \brief Function: Function SPI_Mode_Slave_SS_Hw_Mon
2058 \details
2059 The function \b SPI_Mode_Slave_SS_Hw_Mon verifies data exchange:
2060  - in <b>Slave Mode</b> with <b>Slave Select line Hardware Monitored</b>
2061  - with default clock / frame format
2062  - with default data bits
2063  - with default bit order
2064  - at default bus speed
2065  - for default number of data items
2066
2067 \note In Test Mode <b>Loopback</b> this test is skipped
2068 */
2069 void SPI_Mode_Slave_SS_Hw_Mon (void) {
2070
2071 #if (SPI_SERVER_USED != 0)
2072   if (InitDriver()   != EXIT_SUCCESS) { return; }
2073   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2074   if (CheckServer()  != EXIT_SUCCESS) { return; }
2075   if ((spi_serv_cap.mode_mask & 1U) == 0U) {    // If SPI Server does not support Master mode
2076     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2077     return;
2078   }
2079
2080   SPI_DataExchange_Operation(OP_SEND,     MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_SLAVE_HW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2081   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_SLAVE_HW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2082   SPI_DataExchange_Operation(OP_TRANSFER, MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_SLAVE_HW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2083
2084 #else
2085   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2086 #endif
2087 }
2088
2089 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2090 /**
2091 \brief Function: Function SPI_Mode_Slave_SS_Sw_Ctrl
2092 \details
2093 The function \b SPI_Mode_Slave_SS_Sw_Ctrl verifies data exchange:
2094  - in <b>Slave Mode</b> with <b>Slave Select line Software Controlled</b>
2095  - with default clock / frame format
2096  - with default data bits
2097  - with default bit order
2098  - at default bus speed
2099  - for default number of data items
2100
2101 \note In Test Mode <b>Loopback</b> this test is skipped
2102 */
2103 void SPI_Mode_Slave_SS_Sw_Ctrl (void) {
2104
2105 #if (SPI_SERVER_USED != 0)
2106   if (InitDriver()   != EXIT_SUCCESS) { return; }
2107   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2108   if (CheckServer()  != EXIT_SUCCESS) { return; }
2109   if ((spi_serv_cap.mode_mask & 1U) == 0U) {    // If SPI Server does not support Master mode
2110     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2111     return;
2112   }
2113
2114   SPI_DataExchange_Operation(OP_SEND,     MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_SLAVE_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2115   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_SLAVE_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2116   SPI_DataExchange_Operation(OP_TRANSFER, MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_SLAVE_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2117
2118 #else
2119   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2120 #endif
2121 }
2122
2123 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2124 /**
2125 \brief Function: Function SPI_Format_Clock_Pol0_Pha0
2126 \details
2127 The function \b SPI_Format_Clock_Pol0_Pha0 verifies data exchange:
2128  - in Master Mode with default Slave Select mode
2129  - with clock format: <b>polarity 0 / phase 0</b>
2130  - with default data bits
2131  - with default bit order
2132  - at default bus speed
2133  - for default number of data items
2134
2135 \note In Test Mode <b>Loopback</b> this test is skipped
2136 */
2137 void SPI_Format_Clock_Pol0_Pha0 (void) {
2138
2139 #if (SPI_SERVER_USED != 0)
2140   if (InitDriver()   != EXIT_SUCCESS) { return; }
2141   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2142   if (CheckServer()  != EXIT_SUCCESS) { return; }
2143   if ((spi_serv_cap.fmt_mask & 1U) == 0U) {     // If SPI Server does not support format
2144     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2145     return;
2146   }
2147
2148   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, FORMAT_CPOL0_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2149   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, FORMAT_CPOL0_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2150   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_CPOL0_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2151
2152 #else
2153   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2154 #endif
2155 }
2156
2157 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2158 /**
2159 \brief Function: Function SPI_Format_Clock_Pol0_Pha1
2160 \details
2161 The function \b SPI_Format_Clock_Pol0_Pha1 verifies data exchange:
2162  - in Master Mode with default Slave Select mode
2163  - with clock format: <b>polarity 0 / phase 1</b>
2164  - with default data bits
2165  - with default bit order
2166  - at default bus speed
2167  - for default number of data items
2168
2169 \note In Test Mode <b>Loopback</b> this test is skipped
2170 */
2171 void SPI_Format_Clock_Pol0_Pha1 (void) {
2172
2173 #if (SPI_SERVER_USED != 0)
2174   if (InitDriver()   != EXIT_SUCCESS) { return; }
2175   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2176   if (CheckServer()  != EXIT_SUCCESS) { return; }
2177   if ((spi_serv_cap.fmt_mask & 2U) == 0U) {     // If SPI Server does not support format
2178     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2179     return;
2180   }
2181
2182   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, FORMAT_CPOL0_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2183   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, FORMAT_CPOL0_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2184   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_CPOL0_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2185
2186 #else
2187   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2188 #endif
2189 }
2190
2191 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2192 /**
2193 \brief Function: Function SPI_Format_Clock_Pol1_Pha0
2194 \details
2195 The function \b SPI_Format_Clock_Pol1_Pha0 verifies data exchange:
2196  - in Master Mode with default Slave Select mode
2197  - with clock format: <b>polarity 1 / phase 0</b>
2198  - with default data bits
2199  - with default bit order
2200  - at default bus speed
2201  - for default number of data items
2202
2203 \note In Test Mode <b>Loopback</b> this test is skipped
2204 */
2205 void SPI_Format_Clock_Pol1_Pha0 (void) {
2206
2207 #if (SPI_SERVER_USED != 0)
2208   if (InitDriver()   != EXIT_SUCCESS) { return; }
2209   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2210   if (CheckServer()  != EXIT_SUCCESS) { return; }
2211   if ((spi_serv_cap.fmt_mask & 4U) == 0U) {     // If SPI Server does not support format
2212     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2213     return;
2214   }
2215
2216   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, FORMAT_CPOL1_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2217   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, FORMAT_CPOL1_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2218   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_CPOL1_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2219
2220 #else
2221   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2222 #endif
2223 }
2224
2225 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2226 /**
2227 \brief Function: Function SPI_Format_Clock_Pol0_Pha0
2228 \details
2229 The function \b SPI_Format_Clock_Pol1_Pha1 verifies data exchange:
2230  - in Master Mode with default Slave Select mode
2231  - with clock format: <b>polarity 1 / phase 1</b>
2232  - with default data bits
2233  - with default bit order
2234  - at default bus speed
2235  - for default number of data items
2236
2237 \note In Test Mode <b>Loopback</b> this test is skipped
2238 */
2239 void SPI_Format_Clock_Pol1_Pha1 (void) {
2240
2241 #if (SPI_SERVER_USED != 0)
2242   if (InitDriver()   != EXIT_SUCCESS) { return; }
2243   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2244   if (CheckServer()  != EXIT_SUCCESS) { return; }
2245   if ((spi_serv_cap.fmt_mask & 8U) == 0U) {     // If SPI Server does not support format
2246     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2247     return;
2248   }
2249
2250   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, FORMAT_CPOL1_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2251   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, FORMAT_CPOL1_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2252   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_CPOL1_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2253
2254 #else
2255   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2256 #endif
2257 }
2258
2259 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2260 /**
2261 \brief Function: Function SPI_Format_Frame_TI
2262 \details
2263 The function \b SPI_Format_Frame_TI verifies data exchange:
2264  - in Master Mode with default Slave Select mode
2265  - with <b>Texas Instruments frame format</b>
2266  - with default data bits
2267  - with default bit order
2268  - at default bus speed
2269  - for default number of data items
2270
2271 \note In Test Mode <b>Loopback</b> this test is skipped
2272 */
2273 void SPI_Format_Frame_TI (void) {
2274
2275 #if (SPI_SERVER_USED != 0)
2276   if (InitDriver()   != EXIT_SUCCESS) { return; }
2277   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2278   if (CheckServer()  != EXIT_SUCCESS) { return; }
2279   if ((spi_serv_cap.fmt_mask & 16U) == 0U) {    // If SPI Server does not support format
2280     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2281     return;
2282   }
2283
2284   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, FORMAT_TI, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2285   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, FORMAT_TI, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2286   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_TI, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2287
2288 #else
2289   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2290 #endif
2291 }
2292
2293 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2294 /**
2295 \brief Function: Function SPI_Format_Clock_Microwire
2296 \details
2297 The function \b SPI_Format_Clock_Microwire verifies data exchange:
2298  - in Master Mode with default Slave Select mode
2299  - with <b>National Semiconductor Microwire frame format</b>
2300  - with default data bits
2301  - with default bit order
2302  - at default bus speed
2303  - for default number of data items
2304
2305 \note In Test Mode <b>Loopback</b> this test is skipped
2306 */
2307 void SPI_Format_Clock_Microwire (void) {
2308
2309 #if (SPI_SERVER_USED != 0)
2310   if (InitDriver()   != EXIT_SUCCESS) { return; }
2311   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2312   if (CheckServer()  != EXIT_SUCCESS) { return; }
2313   if ((spi_serv_cap.fmt_mask & 32U) == 0U) {    // If SPI Server does not support format
2314     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2315     return;
2316   }
2317
2318   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, FORMAT_MICROWIRE, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2319   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, FORMAT_MICROWIRE, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2320   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_MICROWIRE, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2321
2322 #else
2323   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2324 #endif
2325 }
2326
2327 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2328 /**
2329 \brief Function: Function SPI_Data_Bits_1
2330 \details
2331 The function \b SPI_Data_Bits_1 verifies data exchange:
2332  - in Master Mode with default Slave Select mode
2333  - with default clock / frame format
2334  - with <b>1 data bits</b> per frame
2335  - with default bit order
2336  - at default bus speed
2337  - for default number of data items
2338
2339 \note In Test Mode <b>Loopback</b> this test is skipped
2340 */
2341 void SPI_Data_Bits_1 (void) {
2342
2343 #if (SPI_SERVER_USED != 0)
2344   if (InitDriver()   != EXIT_SUCCESS) { return; }
2345   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2346   if (CheckServer()  != EXIT_SUCCESS) { return; }
2347   if ((spi_serv_cap.db_mask & 1U) == 0U) {      // If SPI Server does not support data bits setting
2348     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2349     return;
2350   }
2351
2352   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 1U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2353   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 1U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2354   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 1U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2355
2356 #else
2357   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2358 #endif
2359 }
2360
2361 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2362 /**
2363 \brief Function: Function SPI_Data_Bits_2
2364 \details
2365 The function \b SPI_Data_Bits_2 verifies data exchange:
2366  - in Master Mode with default Slave Select mode
2367  - with default clock / frame format
2368  - with <b>2 data bits</b> per frame
2369  - with default bit order
2370  - at default bus speed
2371  - for default number of data items
2372
2373 \note In Test Mode <b>Loopback</b> this test is skipped
2374 */
2375 void SPI_Data_Bits_2 (void) {
2376
2377 #if (SPI_SERVER_USED != 0)
2378   if (InitDriver()   != EXIT_SUCCESS) { return; }
2379   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2380   if (CheckServer()  != EXIT_SUCCESS) { return; }
2381   if ((spi_serv_cap.db_mask & (1U << 1)) == 0U) {       // If SPI Server does not support data bits setting
2382     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2383     return;
2384   }
2385
2386   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 2U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2387   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 2U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2388   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 2U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2389
2390 #else
2391   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2392 #endif
2393 }
2394
2395 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2396 /**
2397 \brief Function: Function SPI_Data_Bits_3
2398 \details
2399 The function \b SPI_Data_Bits_3 verifies data exchange:
2400  - in Master Mode with default Slave Select mode
2401  - with default clock / frame format
2402  - with <b>3 data bits</b> per frame
2403  - with default bit order
2404  - at default bus speed
2405  - for default number of data items
2406
2407 \note In Test Mode <b>Loopback</b> this test is skipped
2408 */
2409 void SPI_Data_Bits_3 (void) {
2410
2411 #if (SPI_SERVER_USED != 0)
2412   if (InitDriver()   != EXIT_SUCCESS) { return; }
2413   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2414   if (CheckServer()  != EXIT_SUCCESS) { return; }
2415   if ((spi_serv_cap.db_mask & (1U << 2)) == 0U) {       // If SPI Server does not support data bits setting
2416     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2417     return;
2418   }
2419
2420   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 3U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2421   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 3U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2422   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 3U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2423
2424 #else
2425   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2426 #endif
2427 }
2428
2429 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2430 /**
2431 \brief Function: Function SPI_Data_Bits_4
2432 \details
2433 The function \b SPI_Data_Bits_4 verifies data exchange:
2434  - in Master Mode with default Slave Select mode
2435  - with default clock / frame format
2436  - with <b>4 data bits</b> per frame
2437  - with default bit order
2438  - at default bus speed
2439  - for default number of data items
2440
2441 \note In Test Mode <b>Loopback</b> this test is skipped
2442 */
2443 void SPI_Data_Bits_4 (void) {
2444
2445 #if (SPI_SERVER_USED != 0)
2446   if (InitDriver()   != EXIT_SUCCESS) { return; }
2447   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2448   if (CheckServer()  != EXIT_SUCCESS) { return; }
2449   if ((spi_serv_cap.db_mask & (1U << 3)) == 0U) {       // If SPI Server does not support data bits setting
2450     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2451     return;
2452   }
2453
2454   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 4U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2455   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 4U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2456   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 4U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2457
2458 #else
2459   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2460 #endif
2461 }
2462
2463 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2464 /**
2465 \brief Function: Function SPI_Data_Bits_5
2466 \details
2467 The function \b SPI_Data_Bits_5 verifies data exchange:
2468  - in Master Mode with default Slave Select mode
2469  - with default clock / frame format
2470  - with <b>5 data bits</b> per frame
2471  - with default bit order
2472  - at default bus speed
2473  - for default number of data items
2474
2475 \note In Test Mode <b>Loopback</b> this test is skipped
2476 */
2477 void SPI_Data_Bits_5 (void) {
2478
2479 #if (SPI_SERVER_USED != 0)
2480   if (InitDriver()   != EXIT_SUCCESS) { return; }
2481   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2482   if (CheckServer()  != EXIT_SUCCESS) { return; }
2483   if ((spi_serv_cap.db_mask & (1U << 4)) == 0U) {       // If SPI Server does not support data bits setting
2484     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2485     return;
2486   }
2487
2488   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 5U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2489   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 5U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2490   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 5U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2491
2492 #else
2493   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2494 #endif
2495 }
2496
2497 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2498 /**
2499 \brief Function: Function SPI_Data_Bits_6
2500 \details
2501 The function \b SPI_Data_Bits_6 verifies data exchange:
2502  - in Master Mode with default Slave Select mode
2503  - with default clock / frame format
2504  - with <b>6 data bits</b> per frame
2505  - with default bit order
2506  - at default bus speed
2507  - for default number of data items
2508
2509 \note In Test Mode <b>Loopback</b> this test is skipped
2510 */
2511 void SPI_Data_Bits_6 (void) {
2512
2513 #if (SPI_SERVER_USED != 0)
2514   if (InitDriver()   != EXIT_SUCCESS) { return; }
2515   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2516   if (CheckServer()  != EXIT_SUCCESS) { return; }
2517   if ((spi_serv_cap.db_mask & (1U << 5)) == 0U) {       // If SPI Server does not support data bits setting
2518     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2519     return;
2520   }
2521
2522   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 6U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2523   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 6U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2524   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 6U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2525
2526 #else
2527   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2528 #endif
2529 }
2530
2531 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2532 /**
2533 \brief Function: Function SPI_Data_Bits_7
2534 \details
2535 The function \b SPI_Data_Bits_7 verifies data exchange:
2536  - in Master Mode with default Slave Select mode
2537  - with default clock / frame format
2538  - with <b>7 data bits</b> per frame
2539  - with default bit order
2540  - at default bus speed
2541  - for default number of data items
2542
2543 \note In Test Mode <b>Loopback</b> this test is skipped
2544 */
2545 void SPI_Data_Bits_7 (void) {
2546
2547 #if (SPI_SERVER_USED != 0)
2548   if (InitDriver()   != EXIT_SUCCESS) { return; }
2549   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2550   if (CheckServer()  != EXIT_SUCCESS) { return; }
2551   if ((spi_serv_cap.db_mask & (1U << 6)) == 0U) {       // If SPI Server does not support data bits setting
2552     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2553     return;
2554   }
2555
2556   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 7U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2557   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 7U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2558   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 7U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2559
2560 #else
2561   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2562 #endif
2563 }
2564
2565 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2566 /**
2567 \brief Function: Function SPI_Data_Bits_8
2568 \details
2569 The function \b SPI_Data_Bits_8 verifies data exchange:
2570  - in Master Mode with default Slave Select mode
2571  - with default clock / frame format
2572  - with <b>8 data bits</b> per frame
2573  - with default bit order
2574  - at default bus speed
2575  - for default number of data items
2576 */
2577 void SPI_Data_Bits_8 (void) {
2578
2579   if (InitDriver()   != EXIT_SUCCESS) { return; }
2580   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2581 #if (SPI_SERVER_USED != 0)
2582   if (CheckServer()  != EXIT_SUCCESS) { return; }
2583   if ((spi_serv_cap.db_mask & (1U << 7)) == 0U) {       // If SPI Server does not support data bits setting
2584     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2585     return;
2586   }
2587 #endif
2588
2589   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 8U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2590   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 8U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2591   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 8U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2592 }
2593
2594 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2595 /**
2596 \brief Function: Function SPI_Data_Bits_9
2597 \details
2598 The function \b SPI_Data_Bits_9 verifies data exchange:
2599  - in Master Mode with default Slave Select mode
2600  - with default clock / frame format
2601  - with <b>9 data bits</b> per frame
2602  - with default bit order
2603  - at default bus speed
2604  - for default number of data items
2605
2606 \note In Test Mode <b>Loopback</b> this test is skipped
2607 */
2608 void SPI_Data_Bits_9 (void) {
2609
2610 #if (SPI_SERVER_USED != 0)
2611   if (InitDriver()   != EXIT_SUCCESS) { return; }
2612   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2613   if (CheckServer()  != EXIT_SUCCESS) { return; }
2614   if ((spi_serv_cap.db_mask & (1U << 8)) == 0U) {       // If SPI Server does not support data bits setting
2615     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2616     return;
2617   }
2618
2619   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 9U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2620   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 9U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2621   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 9U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2622
2623 #else
2624   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2625 #endif
2626 }
2627
2628 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2629 /**
2630 \brief Function: Function SPI_Data_Bits_10
2631 \details
2632 The function \b SPI_Data_Bits_10 verifies data exchange:
2633  - in Master Mode with default Slave Select mode
2634  - with default clock / frame format
2635  - with <b>10 data bits</b> per frame
2636  - with default bit order
2637  - at default bus speed
2638  - for default number of data items
2639
2640 \note In Test Mode <b>Loopback</b> this test is skipped
2641 */
2642 void SPI_Data_Bits_10 (void) {
2643
2644 #if (SPI_SERVER_USED != 0)
2645   if (InitDriver()   != EXIT_SUCCESS) { return; }
2646   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2647   if (CheckServer()  != EXIT_SUCCESS) { return; }
2648   if ((spi_serv_cap.db_mask & (1U << 9)) == 0U) {       // If SPI Server does not support data bits setting
2649     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2650     return;
2651   }
2652
2653   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 10U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2654   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 10U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2655   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 10U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2656
2657 #else
2658   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2659 #endif
2660 }
2661
2662 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2663 /**
2664 \brief Function: Function SPI_Data_Bits_11
2665 \details
2666 The function \b SPI_Data_Bits_11 verifies data exchange:
2667  - in Master Mode with default Slave Select mode
2668  - with default clock / frame format
2669  - with <b>11 data bits</b> per frame
2670  - with default bit order
2671  - at default bus speed
2672  - for default number of data items
2673
2674 \note In Test Mode <b>Loopback</b> this test is skipped
2675 */
2676 void SPI_Data_Bits_11 (void) {
2677
2678 #if (SPI_SERVER_USED != 0)
2679   if (InitDriver()   != EXIT_SUCCESS) { return; }
2680   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2681   if (CheckServer()  != EXIT_SUCCESS) { return; }
2682   if ((spi_serv_cap.db_mask & (1U << 10)) == 0U) {       // If SPI Server does not support data bits setting
2683     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2684     return;
2685   }
2686
2687   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 11U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2688   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 11U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2689   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 11U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2690
2691 #else
2692   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2693 #endif
2694 }
2695
2696 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2697 /**
2698 \brief Function: Function SPI_Data_Bits_12
2699 \details
2700 The function \b SPI_Data_Bits_12 verifies data exchange:
2701  - in Master Mode with default Slave Select mode
2702  - with default clock / frame format
2703  - with <b>12 data bits</b> per frame
2704  - with default bit order
2705  - at default bus speed
2706  - for default number of data items
2707
2708 \note In Test Mode <b>Loopback</b> this test is skipped
2709 */
2710 void SPI_Data_Bits_12 (void) {
2711
2712 #if (SPI_SERVER_USED != 0)
2713   if (InitDriver()   != EXIT_SUCCESS) { return; }
2714   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2715   if (CheckServer()  != EXIT_SUCCESS) { return; }
2716   if ((spi_serv_cap.db_mask & (1U << 11)) == 0U) {       // If SPI Server does not support data bits setting
2717     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2718     return;
2719   }
2720
2721   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 12U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2722   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 12U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2723   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 12U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2724
2725 #else
2726   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2727 #endif
2728 }
2729
2730 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2731 /**
2732 \brief Function: Function SPI_Data_Bits_13
2733 \details
2734 The function \b SPI_Data_Bits_13 verifies data exchange:
2735  - in Master Mode with default Slave Select mode
2736  - with default clock / frame format
2737  - with <b>13 data bits</b> per frame
2738  - with default bit order
2739  - at default bus speed
2740  - for default number of data items
2741
2742 \note In Test Mode <b>Loopback</b> this test is skipped
2743 */
2744 void SPI_Data_Bits_13 (void) {
2745
2746 #if (SPI_SERVER_USED != 0)
2747   if (InitDriver()   != EXIT_SUCCESS) { return; }
2748   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2749   if (CheckServer()  != EXIT_SUCCESS) { return; }
2750   if ((spi_serv_cap.db_mask & (1U << 12)) == 0U) {       // If SPI Server does not support data bits setting
2751     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2752     return;
2753   }
2754
2755   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 13U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2756   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 13U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2757   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 13U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2758
2759 #else
2760   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2761 #endif
2762 }
2763
2764 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2765 /**
2766 \brief Function: Function SPI_Data_Bits_14
2767 \details
2768 The function \b SPI_Data_Bits_14 verifies data exchange:
2769  - in Master Mode with default Slave Select mode
2770  - with default clock / frame format
2771  - with <b>14 data bits</b> per frame
2772  - with default bit order
2773  - at default bus speed
2774  - for default number of data items
2775
2776 \note In Test Mode <b>Loopback</b> this test is skipped
2777 */
2778 void SPI_Data_Bits_14 (void) {
2779
2780 #if (SPI_SERVER_USED != 0)
2781   if (InitDriver()   != EXIT_SUCCESS) { return; }
2782   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2783   if (CheckServer()  != EXIT_SUCCESS) { return; }
2784   if ((spi_serv_cap.db_mask & (1U << 13)) == 0U) {       // If SPI Server does not support data bits setting
2785     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2786     return;
2787   }
2788
2789   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 14U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2790   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 14U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2791   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 14U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2792
2793 #else
2794   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2795 #endif
2796 }
2797
2798 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2799 /**
2800 \brief Function: Function SPI_Data_Bits_15
2801 \details
2802 The function \b SPI_Data_Bits_15 verifies data exchange:
2803  - in Master Mode with default Slave Select mode
2804  - with default clock / frame format
2805  - with <b>15 data bits</b> per frame
2806  - with default bit order
2807  - at default bus speed
2808  - for default number of data items
2809
2810 \note In Test Mode <b>Loopback</b> this test is skipped
2811 */
2812 void SPI_Data_Bits_15 (void) {
2813
2814 #if (SPI_SERVER_USED != 0)
2815   if (InitDriver()   != EXIT_SUCCESS) { return; }
2816   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2817   if (CheckServer()  != EXIT_SUCCESS) { return; }
2818   if ((spi_serv_cap.db_mask & (1U << 14)) == 0U) {       // If SPI Server does not support data bits setting
2819     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2820     return;
2821   }
2822
2823   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 15U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2824   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 15U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2825   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 15U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2826
2827 #else
2828   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2829 #endif
2830 }
2831
2832 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2833 /**
2834 \brief Function: Function SPI_Data_Bits_16
2835 \details
2836 The function \b SPI_Data_Bits_16 verifies data exchange:
2837  - in Master Mode with default Slave Select mode
2838  - with default clock / frame format
2839  - with <b>16 data bits</b> per frame
2840  - with default bit order
2841  - at default bus speed
2842  - for default number of data items
2843 */
2844 void SPI_Data_Bits_16 (void) {
2845
2846   if (InitDriver()   != EXIT_SUCCESS) { return; }
2847   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2848 #if (SPI_SERVER_USED != 0)
2849   if (CheckServer()  != EXIT_SUCCESS) { return; }
2850   if ((spi_serv_cap.db_mask & (1U << 15)) == 0U) {       // If SPI Server does not support data bits setting
2851     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2852     return;
2853   }
2854 #endif
2855
2856   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 16U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2857   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 16U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2858   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 16U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2859 }
2860
2861 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2862 /**
2863 \brief Function: Function SPI_Data_Bits_17
2864 \details
2865 The function \b SPI_Data_Bits_17 verifies data exchange:
2866  - in Master Mode with default Slave Select mode
2867  - with default clock / frame format
2868  - with <b>17 data bits</b> per frame
2869  - with default bit order
2870  - at default bus speed
2871  - for default number of data items
2872
2873 \note In Test Mode <b>Loopback</b> this test is skipped
2874 */
2875 void SPI_Data_Bits_17 (void) {
2876
2877 #if (SPI_SERVER_USED != 0)
2878   if (InitDriver()   != EXIT_SUCCESS) { return; }
2879   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2880   if (CheckServer()  != EXIT_SUCCESS) { return; }
2881   if ((spi_serv_cap.db_mask & (1U << 16)) == 0U) {       // If SPI Server does not support data bits setting
2882     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2883     return;
2884   }
2885
2886   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 17U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2887   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 17U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2888   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 17U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2889
2890 #else
2891   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2892 #endif
2893 }
2894
2895 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2896 /**
2897 \brief Function: Function SPI_Data_Bits_18
2898 \details
2899 The function \b SPI_Data_Bits_18 verifies data exchange:
2900  - in Master Mode with default Slave Select mode
2901  - with default clock / frame format
2902  - with <b>18 data bits</b> per frame
2903  - with default bit order
2904  - at default bus speed
2905  - for default number of data items
2906
2907 \note In Test Mode <b>Loopback</b> this test is skipped
2908 */
2909 void SPI_Data_Bits_18 (void) {
2910
2911 #if (SPI_SERVER_USED != 0)
2912   if (InitDriver()   != EXIT_SUCCESS) { return; }
2913   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2914   if (CheckServer()  != EXIT_SUCCESS) { return; }
2915   if ((spi_serv_cap.db_mask & (1U << 17)) == 0U) {       // If SPI Server does not support data bits setting
2916     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2917     return;
2918   }
2919
2920   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 18U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2921   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 18U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2922   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 18U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2923
2924 #else
2925   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2926 #endif
2927 }
2928
2929 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2930 /**
2931 \brief Function: Function SPI_Data_Bits_19
2932 \details
2933 The function \b SPI_Data_Bits_19 verifies data exchange:
2934  - in Master Mode with default Slave Select mode
2935  - with default clock / frame format
2936  - with <b>19 data bits</b> per frame
2937  - with default bit order
2938  - at default bus speed
2939  - for default number of data items
2940
2941 \note In Test Mode <b>Loopback</b> this test is skipped
2942 */
2943 void SPI_Data_Bits_19 (void) {
2944
2945 #if (SPI_SERVER_USED != 0)
2946   if (InitDriver()   != EXIT_SUCCESS) { return; }
2947   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2948   if (CheckServer()  != EXIT_SUCCESS) { return; }
2949   if ((spi_serv_cap.db_mask & (1U << 18)) == 0U) {       // If SPI Server does not support data bits setting
2950     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2951     return;
2952   }
2953
2954   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 19U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2955   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 19U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2956   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 19U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2957
2958 #else
2959   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2960 #endif
2961 }
2962
2963 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2964 /**
2965 \brief Function: Function SPI_Data_Bits_20
2966 \details
2967 The function \b SPI_Data_Bits_20 verifies data exchange:
2968  - in Master Mode with default Slave Select mode
2969  - with default clock / frame format
2970  - with <b>20 data bits</b> per frame
2971  - with default bit order
2972  - at default bus speed
2973  - for default number of data items
2974
2975 \note In Test Mode <b>Loopback</b> this test is skipped
2976 */
2977 void SPI_Data_Bits_20 (void) {
2978
2979 #if (SPI_SERVER_USED != 0)
2980   if (InitDriver()   != EXIT_SUCCESS) { return; }
2981   if (CheckBuffers() != EXIT_SUCCESS) { return; }
2982   if (CheckServer()  != EXIT_SUCCESS) { return; }
2983   if ((spi_serv_cap.db_mask & (1U << 19)) == 0U) {       // If SPI Server does not support data bits setting
2984     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2985     return;
2986   }
2987
2988   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 20U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2989   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 20U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2990   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 20U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2991
2992 #else
2993   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2994 #endif
2995 }
2996
2997 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2998 /**
2999 \brief Function: Function SPI_Data_Bits_21
3000 \details
3001 The function \b SPI_Data_Bits_21 verifies data exchange:
3002  - in Master Mode with default Slave Select mode
3003  - with default clock / frame format
3004  - with <b>21 data bits</b> per frame
3005  - with default bit order
3006  - at default bus speed
3007  - for default number of data items
3008
3009 \note In Test Mode <b>Loopback</b> this test is skipped
3010 */
3011 void SPI_Data_Bits_21 (void) {
3012
3013 #if (SPI_SERVER_USED != 0)
3014   if (InitDriver()   != EXIT_SUCCESS) { return; }
3015   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3016   if (CheckServer()  != EXIT_SUCCESS) { return; }
3017   if ((spi_serv_cap.db_mask & (1U << 20)) == 0U) {       // If SPI Server does not support data bits setting
3018     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3019     return;
3020   }
3021
3022   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 21U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3023   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 21U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3024   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 21U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3025
3026 #else
3027   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3028 #endif
3029 }
3030
3031 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3032 /**
3033 \brief Function: Function SPI_Data_Bits_22
3034 \details
3035 The function \b SPI_Data_Bits_22 verifies data exchange:
3036  - in Master Mode with default Slave Select mode
3037  - with default clock / frame format
3038  - with <b>22 data bits</b> per frame
3039  - with default bit order
3040  - at default bus speed
3041  - for default number of data items
3042
3043 \note In Test Mode <b>Loopback</b> this test is skipped
3044 */
3045 void SPI_Data_Bits_22 (void) {
3046
3047 #if (SPI_SERVER_USED != 0)
3048   if (InitDriver()   != EXIT_SUCCESS) { return; }
3049   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3050   if (CheckServer()  != EXIT_SUCCESS) { return; }
3051   if ((spi_serv_cap.db_mask & (1U << 21)) == 0U) {       // If SPI Server does not support data bits setting
3052     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3053     return;
3054   }
3055
3056   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 22U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3057   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 22U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3058   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 22U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3059
3060 #else
3061   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3062 #endif
3063 }
3064
3065 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3066 /**
3067 \brief Function: Function SPI_Data_Bits_23
3068 \details
3069 The function \b SPI_Data_Bits_23 verifies data exchange:
3070  - in Master Mode with default Slave Select mode
3071  - with default clock / frame format
3072  - with <b>23 data bits</b> per frame
3073  - with default bit order
3074  - at default bus speed
3075  - for default number of data items
3076
3077 \note In Test Mode <b>Loopback</b> this test is skipped
3078 */
3079 void SPI_Data_Bits_23 (void) {
3080
3081 #if (SPI_SERVER_USED != 0)
3082   if (InitDriver()   != EXIT_SUCCESS) { return; }
3083   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3084   if (CheckServer()  != EXIT_SUCCESS) { return; }
3085   if ((spi_serv_cap.db_mask & (1U << 22)) == 0U) {       // If SPI Server does not support data bits setting
3086     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3087     return;
3088   }
3089
3090   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 23U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3091   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 23U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3092   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 23U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3093
3094 #else
3095   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3096 #endif
3097 }
3098
3099 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3100 /**
3101 \brief Function: Function SPI_Data_Bits_24
3102 \details
3103 The function \b SPI_Data_Bits_24 verifies data exchange:
3104  - in Master Mode with default Slave Select mode
3105  - with default clock / frame format
3106  - with <b>24 data bits</b> per frame
3107  - with default bit order
3108  - at default bus speed
3109  - for default number of data items
3110 */
3111 void SPI_Data_Bits_24 (void) {
3112
3113   if (InitDriver()   != EXIT_SUCCESS) { return; }
3114   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3115 #if (SPI_SERVER_USED != 0)
3116   if (CheckServer()  != EXIT_SUCCESS) { return; }
3117   if ((spi_serv_cap.db_mask & (1U << 23)) == 0U) {       // If SPI Server does not support data bits setting
3118     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3119     return;
3120   }
3121 #endif
3122
3123   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 24U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3124   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 24U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3125   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 24U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3126 }
3127
3128 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3129 /**
3130 \brief Function: Function SPI_Data_Bits_25
3131 \details
3132 The function \b SPI_Data_Bits_25 verifies data exchange:
3133  - in Master Mode with default Slave Select mode
3134  - with default clock / frame format
3135  - with <b>25 data bits</b> per frame
3136  - with default bit order
3137  - at default bus speed
3138  - for default number of data items
3139
3140 \note In Test Mode <b>Loopback</b> this test is skipped
3141 */
3142 void SPI_Data_Bits_25 (void) {
3143
3144 #if (SPI_SERVER_USED != 0)
3145   if (InitDriver()   != EXIT_SUCCESS) { return; }
3146   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3147   if (CheckServer()  != EXIT_SUCCESS) { return; }
3148   if ((spi_serv_cap.db_mask & (1U << 24)) == 0U) {       // If SPI Server does not support data bits setting
3149     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3150     return;
3151   }
3152
3153   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 25U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3154   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 25U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3155   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 25U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3156
3157 #else
3158   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3159 #endif
3160 }
3161
3162 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3163 /**
3164 \brief Function: Function SPI_Data_Bits_26
3165 \details
3166 The function \b SPI_Data_Bits_26 verifies data exchange:
3167  - in Master Mode with default Slave Select mode
3168  - with default clock / frame format
3169  - with <b>26 data bits</b> per frame
3170  - with default bit order
3171  - at default bus speed
3172  - for default number of data items
3173
3174 \note In Test Mode <b>Loopback</b> this test is skipped
3175 */
3176 void SPI_Data_Bits_26 (void) {
3177
3178 #if (SPI_SERVER_USED != 0)
3179   if (InitDriver()   != EXIT_SUCCESS) { return; }
3180   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3181   if (CheckServer()  != EXIT_SUCCESS) { return; }
3182   if ((spi_serv_cap.db_mask & (1U << 25)) == 0U) {       // If SPI Server does not support data bits setting
3183     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3184     return;
3185   }
3186
3187   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 26U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3188   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 26U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3189   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 26U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3190
3191 #else
3192   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3193 #endif
3194 }
3195
3196 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3197 /**
3198 \brief Function: Function SPI_Data_Bits_27
3199 \details
3200 The function \b SPI_Data_Bits_27 verifies data exchange:
3201  - in Master Mode with default Slave Select mode
3202  - with default clock / frame format
3203  - with <b>27 data bits</b> per frame
3204  - with default bit order
3205  - at default bus speed
3206  - for default number of data items
3207
3208 \note In Test Mode <b>Loopback</b> this test is skipped
3209 */
3210 void SPI_Data_Bits_27 (void) {
3211
3212 #if (SPI_SERVER_USED != 0)
3213   if (InitDriver()   != EXIT_SUCCESS) { return; }
3214   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3215   if (CheckServer()  != EXIT_SUCCESS) { return; }
3216   if ((spi_serv_cap.db_mask & (1U << 26)) == 0U) {       // If SPI Server does not support data bits setting
3217     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3218     return;
3219   }
3220
3221   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 27U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3222   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 27U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3223   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 27U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3224
3225 #else
3226   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3227 #endif
3228 }
3229
3230 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3231 /**
3232 \brief Function: Function SPI_Data_Bits_28
3233 \details
3234 The function \b SPI_Data_Bits_28 verifies data exchange:
3235  - in Master Mode with default Slave Select mode
3236  - with default clock / frame format
3237  - with <b>28 data bits</b> per frame
3238  - with default bit order
3239  - at default bus speed
3240  - for default number of data items
3241
3242 \note In Test Mode <b>Loopback</b> this test is skipped
3243 */
3244 void SPI_Data_Bits_28 (void) {
3245
3246 #if (SPI_SERVER_USED != 0)
3247   if (InitDriver()   != EXIT_SUCCESS) { return; }
3248   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3249   if (CheckServer()  != EXIT_SUCCESS) { return; }
3250   if ((spi_serv_cap.db_mask & (1U << 27)) == 0U) {       // If SPI Server does not support data bits setting
3251     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3252     return;
3253   }
3254
3255   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 28U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3256   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 28U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3257   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 28U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3258
3259 #else
3260   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3261 #endif
3262 }
3263
3264 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3265 /**
3266 \brief Function: Function SPI_Data_Bits_29
3267 \details
3268 The function \b SPI_Data_Bits_29 verifies data exchange:
3269  - in Master Mode with default Slave Select mode
3270  - with default clock / frame format
3271  - with <b>29 data bits</b> per frame
3272  - with default bit order
3273  - at default bus speed
3274  - for default number of data items
3275
3276 \note In Test Mode <b>Loopback</b> this test is skipped
3277 */
3278 void SPI_Data_Bits_29 (void) {
3279
3280 #if (SPI_SERVER_USED != 0)
3281   if (InitDriver()   != EXIT_SUCCESS) { return; }
3282   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3283   if (CheckServer()  != EXIT_SUCCESS) { return; }
3284   if ((spi_serv_cap.db_mask & (1U << 28)) == 0U) {       // If SPI Server does not support data bits setting
3285     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3286     return;
3287   }
3288
3289   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 29U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3290   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 29U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3291   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 29U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3292
3293 #else
3294   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3295 #endif
3296 }
3297
3298 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3299 /**
3300 \brief Function: Function SPI_Data_Bits_30
3301 \details
3302 The function \b SPI_Data_Bits_30 verifies data exchange:
3303  - in Master Mode with default Slave Select mode
3304  - with default clock / frame format
3305  - with <b>30 data bits</b> per frame
3306  - with default bit order
3307  - at default bus speed
3308  - for default number of data items
3309
3310 \note In Test Mode <b>Loopback</b> this test is skipped
3311 */
3312 void SPI_Data_Bits_30 (void) {
3313
3314 #if (SPI_SERVER_USED != 0)
3315   if (InitDriver()   != EXIT_SUCCESS) { return; }
3316   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3317   if (CheckServer()  != EXIT_SUCCESS) { return; }
3318   if ((spi_serv_cap.db_mask & (1U << 29)) == 0U) {       // If SPI Server does not support data bits setting
3319     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3320     return;
3321   }
3322
3323   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 30U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3324   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 30U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3325   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 30U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3326
3327 #else
3328   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3329 #endif
3330 }
3331
3332 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3333 /**
3334 \brief Function: Function SPI_Data_Bits_31
3335 \details
3336 The function \b SPI_Data_Bits_31 verifies data exchange:
3337  - in Master Mode with default Slave Select mode
3338  - with default clock / frame format
3339  - with <b>31 data bits</b> per frame
3340  - with default bit order
3341  - at default bus speed
3342  - for default number of data items
3343
3344 \note In Test Mode <b>Loopback</b> this test is skipped
3345 */
3346 void SPI_Data_Bits_31 (void) {
3347
3348 #if (SPI_SERVER_USED != 0)
3349   if (InitDriver()   != EXIT_SUCCESS) { return; }
3350   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3351   if (CheckServer()  != EXIT_SUCCESS) { return; }
3352   if ((spi_serv_cap.db_mask & (1U << 30)) == 0U) {       // If SPI Server does not support data bits setting
3353     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3354     return;
3355   }
3356
3357   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 31U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3358   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 31U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3359   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 31U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3360
3361 #else
3362   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3363 #endif
3364 }
3365
3366 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3367 /**
3368 \brief Function: Function SPI_Data_Bits_32
3369 \details
3370 The function \b SPI_Data_Bits_32 verifies data exchange:
3371  - in Master Mode with default Slave Select mode
3372  - with default clock / frame format
3373  - with <b>32 data bits</b> per frame
3374  - with default bit order
3375  - at default bus speed
3376  - for default number of data items
3377 */
3378 void SPI_Data_Bits_32 (void) {
3379
3380   if (InitDriver()   != EXIT_SUCCESS) { return; }
3381   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3382 #if (SPI_SERVER_USED != 0)
3383   if (CheckServer()  != EXIT_SUCCESS) { return; }
3384   if ((spi_serv_cap.db_mask & (1UL << 31)) == 0U) {      // If SPI Server does not support data bits setting
3385     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3386     return;
3387   }
3388 #endif
3389
3390   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, 32U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3391   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, 32U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3392   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 32U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3393 }
3394
3395 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3396 /**
3397 \brief Function: Function SPI_Bit_Order_MSB_LSB
3398 \details
3399 The function \b SPI_Bit_Order_MSB_LSB verifies data exchange:
3400  - in Master Mode with default Slave Select mode
3401  - with default clock / frame format
3402  - with default data bits
3403  - with bit order <b>from MSB to LSB</b>
3404  - at default bus speed
3405  - for default number of data items
3406
3407 \note In Test Mode <b>Loopback</b> this test is skipped
3408 */
3409 void SPI_Bit_Order_MSB_LSB (void) {
3410
3411 #if (SPI_SERVER_USED != 0)
3412   if (InitDriver()   != EXIT_SUCCESS) { return; }
3413   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3414   if (CheckServer()  != EXIT_SUCCESS) { return; }
3415   if ((spi_serv_cap.bo_mask & 1U) == 0U) {      // If SPI Server does not support bit order setting
3416     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3417     return;
3418   }
3419
3420   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3421   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3422   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3423
3424 #else
3425   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3426 #endif
3427 }
3428
3429 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3430 /**
3431 \brief Function: Function SPI_Bit_Order_LSB_MSB
3432 \details
3433 The function \b SPI_Bit_Order_LSB_MSB verifies data exchange:
3434  - in Master Mode with default Slave Select mode
3435  - with default clock / frame format
3436  - with default data bits
3437  - with bit order <b>from LSB to MSB</b>
3438  - at default bus speed
3439  - for default number of data items
3440
3441 \note In Test Mode <b>Loopback</b> this test is skipped
3442 */
3443 void SPI_Bit_Order_LSB_MSB (void) {
3444
3445 #if (SPI_SERVER_USED != 0)
3446   if (InitDriver()   != EXIT_SUCCESS) { return; }
3447   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3448   if (CheckServer()  != EXIT_SUCCESS) { return; }
3449   if ((spi_serv_cap.bo_mask & 2U) == 0U) {      // If SPI Server does not support bit order setting
3450     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3451     return;
3452   }
3453
3454   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_LSB_TO_MSB, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3455   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_LSB_TO_MSB, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3456   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_LSB_TO_MSB, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3457
3458 #else
3459   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3460 #endif
3461 }
3462
3463 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3464 /**
3465 \brief Function: Function SPI_Bus_Speed_Min
3466 \details
3467 The function \b SPI_Bus_Speed_Min verifies data exchange:
3468  - in Master Mode with default Slave Select mode
3469  - with default clock / frame format
3470  - with default data bits
3471  - with default bit order
3472  - at <b>minimum bus speed</b> (define <c>SPI_CFG_MIN_BUS_SPEED</c> in DV_SPI_Config.h)
3473  - for default number of data items
3474
3475 This test function checks the following requirements:
3476  - measured bus speed is not 25% lower, or higher than requested
3477  - bus speed value returned by the driver is not negative
3478  - bus speed value returned by the driver is not higher then requested
3479  - bus speed value returned by the driver is not lower then 75% of requested
3480 */
3481 void SPI_Bus_Speed_Min (void) {
3482   volatile uint64_t bps;
3483   volatile  int32_t got_bus_speed;
3484
3485   if (InitDriver()   != EXIT_SUCCESS) { return; }
3486   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3487 #if (SPI_SERVER_USED != 0)
3488   if (CheckServer()  != EXIT_SUCCESS) { return; }
3489   if (spi_serv_cap.bs_min > SPI_CFG_MIN_BUS_SPEED) {    // If SPI Server does not support minimum bus speed
3490     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3491     return;
3492   }
3493 #endif
3494
3495   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_MIN_BUS_SPEED, SPI_CFG_DEF_NUM);
3496   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_MIN_BUS_SPEED, SPI_CFG_DEF_NUM);
3497   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_MIN_BUS_SPEED, SPI_CFG_DEF_NUM);
3498
3499   if (duration != 0xFFFFFFFFU) {        // If Transfer finished before timeout
3500     if (duration != 0U) {               // If duration of transfer was more than 0 SysTick counts
3501       bps = ((uint64_t)systick_freq * SPI_CFG_DEF_DATA_BITS * SPI_CFG_DEF_NUM) / duration;
3502       if ((bps < ((SPI_CFG_MIN_BUS_SPEED * 3) / 4)) ||
3503           (bps >   SPI_CFG_MIN_BUS_SPEED)) {
3504         // If measured bus speed is 25% lower, or higher than requested
3505         (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] At requested bus speed of %i bps, effective bus speed is %i bps", SPI_CFG_MIN_BUS_SPEED, (uint32_t)bps);
3506         TEST_MESSAGE(msg_buf);
3507       }
3508     }
3509   }
3510
3511   drv->Control (ARM_SPI_SET_BUS_SPEED, SPI_CFG_MIN_BUS_SPEED);
3512   got_bus_speed = drv->Control (ARM_SPI_GET_BUS_SPEED, 0U);
3513   if (got_bus_speed < 0) {
3514     // If bus speed value returned by the driver is negative
3515     (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned negative value %i", got_bus_speed);
3516     TEST_FAIL_MESSAGE(msg_buf);
3517   } else if ((uint32_t)got_bus_speed > SPI_CFG_MIN_BUS_SPEED) {
3518     // If bus speed value returned by the driver is higher then requested
3519     (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned %i bps instead of requested %i bps", got_bus_speed, SPI_CFG_MIN_BUS_SPEED);
3520     TEST_FAIL_MESSAGE(msg_buf);
3521   } else if ((uint32_t)got_bus_speed < ((SPI_CFG_MIN_BUS_SPEED * 3) / 4)) {
3522     // If bus speed value returned by the driver is lower then 75% of requested
3523     (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] Get bus speed returned %i bps instead of requested %i bps", got_bus_speed, SPI_CFG_MIN_BUS_SPEED);
3524     TEST_MESSAGE(msg_buf);
3525   }
3526 }
3527
3528 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3529 /**
3530 \brief Function: Function SPI_Bus_Speed_Max
3531 \details
3532 The function \b SPI_Bus_Speed_Max verifies data exchange:
3533  - in Master Mode with default Slave Select mode
3534  - with default clock / frame format
3535  - with default data bits
3536  - with default bit order
3537  - at <b>maximum bus speed</b> (define <c>SPI_CFG_MAX_BUS_SPEED</c> in DV_SPI_Config.h)
3538  - for default number of data items
3539
3540 This test function checks the following requirements:
3541  - measured bus speed is not 25% lower, or higher than requested
3542  - bus speed value returned by the driver is not negative
3543  - bus speed value returned by the driver is not higher then requested
3544  - bus speed value returned by the driver is not lower then 75% of requested
3545 */
3546 void SPI_Bus_Speed_Max (void) {
3547   volatile uint64_t bps;
3548   volatile  int32_t got_bus_speed;
3549
3550   if (InitDriver()   != EXIT_SUCCESS) { return; }
3551   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3552 #if (SPI_SERVER_USED != 0)
3553   if (CheckServer()  != EXIT_SUCCESS) { return; }
3554   if (spi_serv_cap.bs_max < SPI_CFG_MAX_BUS_SPEED) {    // If SPI Server does not support maximum bus speed
3555     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3556     return;
3557   }
3558 #endif
3559
3560   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_MAX_BUS_SPEED, SPI_CFG_DEF_NUM);
3561   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_MAX_BUS_SPEED, SPI_CFG_DEF_NUM);
3562   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_MAX_BUS_SPEED, SPI_CFG_DEF_NUM);
3563
3564   if (duration != 0xFFFFFFFFU) {        // If Transfer finished before timeout
3565     if (duration != 0U) {               // If duration of transfer was more than 0 SysTick counts
3566       bps = ((uint64_t)systick_freq * SPI_CFG_DEF_DATA_BITS * SPI_CFG_DEF_NUM) / duration;
3567       if ((bps < ((SPI_CFG_MAX_BUS_SPEED * 3) / 4)) ||
3568           (bps >   SPI_CFG_MIN_BUS_SPEED)) {
3569         // If measured bus speed is 25% lower, or higher than requested
3570         (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] At requested bus speed of %i bps, effective bus speed is %i bps", SPI_CFG_MAX_BUS_SPEED, (uint32_t)bps);
3571         TEST_MESSAGE(msg_buf);
3572       }
3573     }
3574   }
3575
3576   drv->Control (ARM_SPI_SET_BUS_SPEED, SPI_CFG_MAX_BUS_SPEED);
3577   got_bus_speed = drv->Control (ARM_SPI_GET_BUS_SPEED, 0U);
3578   if (got_bus_speed < 0) {
3579     // If bus speed value returned by the driver is negative
3580     (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned negative value %i", got_bus_speed);
3581     TEST_FAIL_MESSAGE(msg_buf);
3582   } else if ((uint32_t)got_bus_speed > SPI_CFG_MAX_BUS_SPEED) {
3583     // If bus speed value returned by the driver is higher then requested
3584     (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned %i bps instead of requested %i bps", got_bus_speed, SPI_CFG_MAX_BUS_SPEED);
3585     TEST_FAIL_MESSAGE(msg_buf);
3586   } else if ((uint32_t)got_bus_speed < ((SPI_CFG_MAX_BUS_SPEED * 3) / 4)) {
3587     // If bus speed value returned by the driver is lower then 75% of requested
3588     (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] Get bus speed returned %i bps instead of requested %i bps", got_bus_speed, SPI_CFG_MAX_BUS_SPEED);
3589     TEST_MESSAGE(msg_buf);
3590   }
3591 }
3592
3593 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3594 /**
3595 \brief Function: Function SPI_Number_Of_Items
3596 \details
3597 The function \b SPI_Number_Of_Items verifies data exchange:
3598  - in Master Mode with default Slave Select mode
3599  - with default clock / frame format
3600  - with default data bits
3601  - with default bit order
3602  - at default bus speed
3603  - for <b>different number of items</b> (defines <c>SPI_CFG_NUM1 .. SPI_CFG_NUM5</c> in DV_SPI_Config.h)
3604 */
3605 void SPI_Number_Of_Items (void) {
3606
3607   if (InitDriver()   != EXIT_SUCCESS) { return; }
3608   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3609 #if (SPI_SERVER_USED != 0)
3610   if (CheckServer()  != EXIT_SUCCESS) { return; }
3611   if ((spi_serv_cap.mode_mask & 2U) == 0U) {    // If SPI Server does not support Slave mode
3612     TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3613     return;
3614   }
3615 #endif
3616
3617 #if (SPI_CFG_NUM1 != 0U)
3618   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM1);
3619   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM1);
3620   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM1);
3621 #endif
3622
3623 #if (SPI_CFG_NUM2 != 0U)
3624   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM2);
3625   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM2);
3626   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM2);
3627 #endif
3628
3629 #if (SPI_CFG_NUM3 != 0U)
3630   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM3);
3631   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM3);
3632   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM3);
3633 #endif
3634
3635 #if (SPI_CFG_NUM4 != 0U)
3636   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM4);
3637   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM4);
3638   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM4);
3639 #endif
3640
3641 #if (SPI_CFG_NUM5 != 0U)
3642   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM5);
3643   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM5);
3644   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM5);
3645 #endif
3646 }
3647
3648 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3649 /**
3650 \brief Function: Function SPI_GetDataCount
3651 \details
3652 The function \b SPI_GetDataCount verifies \b GetDataCount function (count changing) during data exchange:
3653  - in Master Mode with default Slave Select mode
3654  - with default clock / frame format
3655  - with default data bits
3656  - with default bit order
3657  - at default bus speed
3658 */
3659 void SPI_GetDataCount (void) {
3660
3661   if (InitDriver()   != EXIT_SUCCESS) { return; }
3662   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3663 #if (SPI_SERVER_USED != 0)
3664   if (CheckServer()  != EXIT_SUCCESS) { return; }
3665 #endif
3666
3667   SPI_DataExchange_Operation(OP_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3668   TEST_ASSERT_MESSAGE((data_count_sample != 0U) && (data_count_sample != SPI_CFG_DEF_NUM), "[FAILED] GetDataCount was not changing during the Send!");
3669
3670   SPI_DataExchange_Operation(OP_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3671   TEST_ASSERT_MESSAGE((data_count_sample != 0U) && (data_count_sample != SPI_CFG_DEF_NUM), "[FAILED] GetDataCount was not changing during the Receive!");
3672
3673   SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3674   TEST_ASSERT_MESSAGE((data_count_sample != 0U) && (data_count_sample != SPI_CFG_DEF_NUM), "[FAILED] GetDataCount was not changing during the Transfer!");
3675 }
3676
3677 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3678 /**
3679 \brief Function: Function SPI_Abort
3680 \details
3681 The function \b SPI_Abort verifies \b Abort function abort of data exchange:
3682  - in Master Mode with default Slave Select mode
3683  - with default clock / frame format
3684  - with default data bits
3685  - with default bit order
3686  - at default bus speed
3687 */
3688 void SPI_Abort (void) {
3689
3690   if (InitDriver()   != EXIT_SUCCESS) { return; }
3691   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3692 #if (SPI_SERVER_USED != 0)
3693   if (CheckServer()  != EXIT_SUCCESS) { return; }
3694 #endif
3695
3696   SPI_DataExchange_Operation(OP_ABORT_SEND,     MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3697   SPI_DataExchange_Operation(OP_ABORT_RECEIVE,  MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3698   SPI_DataExchange_Operation(OP_ABORT_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3699 }
3700
3701 /**
3702 @}
3703 */
3704 // End of spi_tests_data_xchg
3705
3706 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3707 /* SPI Error Event tests                                                                                                    */
3708 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3709 /**
3710 \defgroup spi_tests_err_evt Error Event
3711 \ingroup spi_tests
3712 \details
3713 These tests verify API and operation of the SPI error event signaling.
3714
3715 The error event tests verify the following driver function
3716 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
3717  - \b SignalEvent
3718 \code
3719   void (*ARM_SPI_SignalEvent_t) (uint32_t event);
3720 \endcode
3721
3722 \note In Test Mode <b>Loopback</b> these tests are skipped
3723 @{
3724 */
3725
3726 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3727 /**
3728 \brief Function: Function SPI_DataLost
3729 \details
3730 The function \b SPI_DataLost verifies signaling of the <b>ARM_SPI_EVENT_DATA_LOST</b> event:
3731  - in <b>Slave Mode</b> with <b>Slave Select line Hardware Monitored</b>
3732  - with default clock / frame format
3733  - with default data bits
3734  - with default bit order
3735  - at default bus speed
3736 */
3737 void SPI_DataLost (void) {
3738
3739 #if (SPI_SERVER_USED != 0)
3740   if (InitDriver()   != EXIT_SUCCESS) { return; }
3741   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3742   if (CheckServer()  != EXIT_SUCCESS) { return; }
3743
3744   do {
3745     if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3746     if (CmdSetCom  (0U, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, 1U, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { break; }
3747     if (CmdXfer    (SPI_CFG_DEF_NUM, 20U, SPI_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
3748
3749     (void)drv->Control (ARM_SPI_MODE_SLAVE                                                                 | 
3750                       ((SPI_CFG_DEF_FORMAT    << ARM_SPI_FRAME_FORMAT_Pos)   & ARM_SPI_FRAME_FORMAT_Msk)   | 
3751                       ((SPI_CFG_DEF_DATA_BITS << ARM_SPI_DATA_BITS_Pos)      & ARM_SPI_DATA_BITS_Msk)      | 
3752                       ((SPI_CFG_DEF_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos)      & ARM_SPI_BIT_ORDER_Msk)      | 
3753                         ARM_SPI_SS_SLAVE_HW                                                                , 
3754                         SPI_CFG_DEF_BUS_SPEED);
3755
3756     event = 0U;
3757     (void)osDelay(SPI_CFG_XFER_TIMEOUT+20U);    // Wait for SPI Server to timeout
3758
3759     // Assert that event ARM_SPI_EVENT_DATA_LOST was signaled
3760     TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_DATA_LOST) != 0U, "[FAILED] Event ARM_SPI_EVENT_DATA_LOST was not signaled!");
3761
3762     return;
3763   } while (false);
3764
3765 #else
3766   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3767 #endif
3768 }
3769
3770 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3771 /**
3772 \brief Function: Function SPI_ModeFault
3773 \details
3774 The function \b SPI_ModeFault verifies signaling of the <b>ARM_SPI_EVENT_MODE_FAULT</b> event:
3775  - in <b>Master Mode</b> with <b>Slave Select line Hardware Monitored Input</b>
3776  - with default clock / frame format
3777  - with default data bits
3778  - with default bit order
3779  - at default bus speed
3780 */
3781 void SPI_ModeFault (void) {
3782
3783   if (drv->GetCapabilities().event_mode_fault == 0U) {
3784     TEST_MESSAGE("[WARNING] This driver does not support ARM_SPI_EVENT_MODE_FAULT event signaling! Test skipped!");
3785     return;
3786   }
3787
3788 #if (SPI_SERVER_USED != 0)
3789   if (InitDriver()   != EXIT_SUCCESS) { return; }
3790   if (CheckBuffers() != EXIT_SUCCESS) { return; }
3791   if (CheckServer()  != EXIT_SUCCESS) { return; }
3792
3793   do {
3794     if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3795     if (CmdSetCom  (1U, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, 0U, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { break; }
3796     if (CmdXfer    (SPI_CFG_DEF_NUM, 0U, SPI_CFG_XFER_TIMEOUT, SPI_CFG_DEF_NUM / 2U) != EXIT_SUCCESS) { break; }
3797
3798     (void)drv->Control (ARM_SPI_MODE_MASTER                                                              | 
3799                       ((SPI_CFG_DEF_FORMAT    << ARM_SPI_FRAME_FORMAT_Pos)   & ARM_SPI_FRAME_FORMAT_Msk) | 
3800                       ((SPI_CFG_DEF_DATA_BITS << ARM_SPI_DATA_BITS_Pos)      & ARM_SPI_DATA_BITS_Msk)    | 
3801                       ((SPI_CFG_DEF_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos)      & ARM_SPI_BIT_ORDER_Msk)    | 
3802                         ARM_SPI_SS_MASTER_HW_INPUT                                                       , 
3803                         SPI_CFG_DEF_BUS_SPEED);
3804
3805     event = 0U;
3806     (void)osDelay(10U);
3807     TEST_ASSERT(drv->Transfer(ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
3808
3809     (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U);    // Wait for SPI Server to timeout
3810
3811     // Assert that event ARM_SPI_EVENT_MODE_FAULT was signaled
3812     TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_MODE_FAULT) != 0U, "[FAILED] Event ARM_SPI_EVENT_MODE_FAULT was not signaled!");
3813
3814     return;
3815   } while (false);
3816
3817 #else
3818   TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3819 #endif
3820 }
3821
3822 /**
3823 @}
3824 */
3825 // End of spi_tests_err_evt