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