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