]> begriffs open source - cmsis-driver-validation/blob - Source/DV_SPI.c
Update GitHub Actions runner to ubuntu-22.04 (#18)
[cmsis-driver-validation] / Source / DV_SPI.c
1 /*
2  * Copyright (c) 2015-2024 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;
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;
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 < (int32_t)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 32 bytes to ensure that buffer can be aligned to 32 bytes)
1120
1121   ptr_tx_buf_alloc = malloc(SPI_BUF_MAX + 32U);
1122   if (((uint32_t)ptr_tx_buf_alloc & 31U) != 0U) {
1123     // If allocated memory is not 32 byte aligned, use next 32 byte aligned address for ptr_tx_buf
1124     ptr_tx_buf = (uint8_t *)((((uint32_t)ptr_tx_buf_alloc) + 31U) & (~31U));
1125   } else {
1126     // If allocated memory is 32 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 + 32U);
1130   if (((uint32_t)ptr_rx_buf_alloc & 31U) != 0U) {
1131     ptr_rx_buf = (uint8_t *)((((uint32_t)ptr_rx_buf_alloc) + 31U) & (~31U));
1132   } else {
1133     ptr_rx_buf = (uint8_t *)ptr_rx_buf_alloc;
1134   }
1135   ptr_cmp_buf_alloc = malloc(SPI_BUF_MAX + 32U);
1136   if (((uint32_t)ptr_cmp_buf_alloc & 31U) != 0U) {
1137     ptr_cmp_buf = (uint8_t *)((((uint32_t)ptr_cmp_buf_alloc) + 31U) & (~31U));
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
1168   // Test communication with SPI Server
1169   server_status = EXIT_FAILURE;
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   if (server_status != EXIT_SUCCESS) {
1179     (void)snprintf(msg_buf, sizeof(msg_buf), "Server status:    %s\n", str_srv_status[server_status]);
1180     TEST_GROUP_INFO(msg_buf);
1181   }
1182 #endif
1183 }
1184
1185 /*
1186   \fn            void SPI_DV_Uninitialize (void)
1187   \brief         De-initialize testing environment after SPI testing.
1188   \detail        This function is called by the driver validation framework after SPI testing is finished.
1189                  It frees memory buffers used for the SPI testing.
1190   \return        none
1191 */
1192 void SPI_DV_Uninitialize (void) {
1193
1194   (void)osEventFlagsDelete(event_flags);
1195
1196   if (ptr_tx_buf_alloc != NULL) {
1197     free(ptr_tx_buf_alloc);
1198     ptr_tx_buf        = NULL;
1199     ptr_tx_buf_alloc  = NULL;
1200   }
1201   if (ptr_rx_buf_alloc != NULL) {
1202     free(ptr_rx_buf_alloc);
1203     ptr_rx_buf        = NULL;
1204     ptr_rx_buf_alloc  = NULL;
1205   }
1206   if (ptr_cmp_buf_alloc != NULL) {
1207     free(ptr_cmp_buf_alloc);
1208     ptr_cmp_buf       = NULL;
1209     ptr_cmp_buf_alloc = NULL;
1210   }
1211 }
1212
1213 #endif                                  // End of exclude form the documentation
1214
1215 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1216 /**
1217 \defgroup dv_spi SPI Validation
1218 \brief SPI driver validation
1219 \details
1220 The SPI validation performs the following tests:
1221 - API interface compliance
1222 - Data exchange with various speeds, transfer sizes and communication settings
1223 - Event signaling
1224
1225 Two Test Modes are available: <b>Loopback</b> and <b>SPI Server</b>.
1226
1227 Test Mode : <b>Loopback</b>
1228 ---------------------------
1229
1230 This test mode allows only limited validation of the SPI Driver.<br>
1231 It is recommended that this test mode is used only as a proof that driver is 
1232 good enough to be tested with the <b>SPI Server</b>.
1233
1234 For this purpose following <b>Default settings</b> should be used:
1235  - Slave Select: Not used
1236  - Clock / Frame Format: Clock Polarity 0, Clock Phase 0
1237  - Data Bits: 8
1238  - Bit Order: MSB to LSB
1239  - Bus Speed: same as setting for the SPI Server
1240  - Number of Items: 32
1241
1242 To enable this mode of testing in the <b>DV_SPI_Config.h</b> configuration file select the 
1243 <b>Configuration: Test Mode: Loopback</b> setting.
1244
1245 Required pin connection for the <b>Loopback</b> test mode:
1246
1247 \image html spi_loopback_pin_connections.png
1248
1249 \note In this mode following operations / settings cannot be tested:
1250  - SPI slave mode
1251  - Slave Select line functionality
1252  - operation of the Receive function
1253  - data content sent by the Send function
1254  - clock / frame format and bit order settings
1255  - data bit settings other then: 8, 16, 24 and 32
1256  - event signaling
1257
1258 Test Mode : <b>SPI Server</b>
1259 -----------------------------
1260
1261 This test mode allows extensive validation of the SPI Driver.<br>
1262 Results of the Driver Validation in this test mode are relevant as a proof of driver compliance 
1263 to the CMSIS-Driver specification.
1264
1265 To perform extensive communication tests, it is required to use an 
1266 \ref spi_server "SPI Server" running on a dedicated hardware.
1267
1268 To enable this mode of testing in the <b>DV_SPI_Config.h</b> configuration file select the 
1269 <b>Configuration: Test Mode: SPI Server</b> setting.
1270
1271 Required pin connections for the <b>SPI Server</b> test mode:
1272
1273 \image html spi_server_pin_connections.png
1274
1275 \note Slave Select line has to be pulled to Vcc by an external pull-up (for example 10 kOhm).
1276 \note To ensure proper signal quality:
1277        - keep the connecting wires as short as possible
1278        - if possible have SCK and GND wires as a twisted pair and MISO, MOSI and Slave Select 
1279          wires separate from each other
1280        - ensure a good Ground (GND) connection between SPI Server and DUT
1281 \note If you experience issues with corrupt data content try reducing bus speed.
1282
1283
1284 \defgroup spi_tests Tests
1285 \ingroup dv_spi
1286 */
1287
1288 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1289 /* SPI Driver Management tests                                                                                              */
1290 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1291 /**
1292 \defgroup spi_tests_drv_mgmt Driver Management
1293 \ingroup spi_tests
1294 \details
1295 These tests verify API and operation of the SPI driver management functions.
1296
1297 The driver management tests verify the following driver functions
1298 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
1299  - \b GetVersion
1300 \code
1301   ARM_DRIVER_VERSION   GetVersion      (void);
1302 \endcode
1303  - \b GetCapabilities
1304 \code
1305   ARM_SPI_CAPABILITIES GetCapabilities (void);
1306 \endcode
1307  - \b Initialize
1308 \code
1309   int32_t              Initialize      (ARM_SPI_SignalEvent_t cb_event);
1310 \endcode
1311  - \b Uninitialize
1312 \code
1313   int32_t              Uninitialize    (void);
1314 \endcode
1315  - \b PowerControl
1316 \code
1317   int32_t              PowerControl    (ARM_POWER_STATE state);
1318 \endcode
1319
1320 @{
1321 */
1322
1323 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1324 /**
1325 \brief Function: Function SPI_GetVersion
1326 \details
1327 The function \b SPI_GetVersion verifies the \b GetVersion function.
1328 \code
1329   ARM_DRIVER_VERSION GetVersion (void);
1330 \endcode
1331
1332 Testing sequence:
1333   - Driver is uninitialized and peripheral is powered-off:
1334     - Call GetVersion function
1335     - Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1336 */
1337 void SPI_GetVersion (void) {
1338   ARM_DRIVER_VERSION ver;
1339
1340   ver = drv->GetVersion();
1341
1342   // Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1343   TEST_ASSERT((ver.api >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)) && (ver.drv >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)));
1344
1345   (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));
1346   TEST_MESSAGE(msg_buf);
1347 }
1348
1349 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1350 /**
1351 \brief Function: Function SPI_GetCapabilities
1352 \details
1353 The function \b SPI_GetCapabilities verifies the \b GetCapabilities function.
1354 \code
1355   ARM_SPI_CAPABILITIES GetCapabilities (void);
1356 \endcode
1357
1358 Testing sequence:
1359   - Driver is uninitialized and peripheral is powered-off:
1360     - Call GetCapabilities function
1361     - Assert that GetCapabilities function returned capabilities structure with reserved field 0
1362 */
1363 void SPI_GetCapabilities (void) {
1364   ARM_SPI_CAPABILITIES cap;
1365
1366   cap = drv->GetCapabilities();
1367
1368   // Assert that GetCapabilities function returned capabilities structure with reserved field 0
1369   TEST_ASSERT_MESSAGE((cap.reserved == 0U), "[FAILED] Capabilities reserved field must be 0");
1370 }
1371
1372 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1373 /**
1374 \brief Function: Function SPI_Initialize_Uninitialize
1375 \details
1376 The function \b SPI_Initialize_Uninitialize verifies the \b Initialize and \b Uninitialize functions.
1377 \code
1378   int32_t Initialize (ARM_SPI_SignalEvent_t cb_event);
1379 \endcode
1380 \code
1381   int32_t Uninitialize (void);
1382 \endcode
1383
1384 Testing sequence:
1385   - Driver is uninitialized and peripheral is powered-off:
1386     - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1387     - Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR or ARM_DRIVER_ERROR_UNSUPPORTED status
1388     - Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_OK status
1389     - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1390     - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1391     - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1392     - Call GetDataCount function and assert that it returned 0
1393     - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1394     - Call GetStatus function
1395     - Assert that GetStatus function returned status structure with busy flag 0
1396     - Assert that GetStatus function returned status structure with data_lost flag 0
1397     - Assert that GetStatus function returned status structure with mode_fault flag 0
1398     - Assert that GetStatus function returned status structure with reserved field 0
1399     - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1400   - Driver is initialized and peripheral is powered-off:
1401     - Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1402     - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1403   - Driver is uninitialized and peripheral is powered-off:
1404     - Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1405   - Driver is initialized and peripheral is powered-off:
1406     - Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1407     - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1408   - Driver is uninitialized and peripheral is powered-off:
1409     - Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1410     - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1411   - Driver is initialized and peripheral is powered-off:
1412     - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1413   - Driver is initialized and peripheral is powered-on:
1414     - Call Control function and assert that it returned ARM_DRIVER_OK status
1415     - Call Transfer function and assert that it returned ARM_DRIVER_OK status
1416     - Call GetStatus function
1417     - Assert that GetStatus function returned status structure with busy flag 1
1418     - Call Uninitialize function with transfer active and assert that it returned ARM_DRIVER_OK status<br>
1419       (this must unconditionally terminate active transfer, power-off the peripheral and uninitialize the driver)
1420   - Driver is uninitialized and peripheral is powered-off:
1421     - Call GetStatus function
1422     - Assert that GetStatus function returned status structure with busy flag 0
1423 */
1424 void SPI_Initialize_Uninitialize (void) {
1425   int32_t        ret;
1426   ARM_SPI_STATUS stat;
1427
1428   // Driver is uninitialized and peripheral is powered-off:
1429   // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1430   TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_ERROR);
1431
1432   // Call PowerControl(ARM_POWER_LOW) function
1433   ret = drv->PowerControl (ARM_POWER_LOW);
1434
1435   // Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_ERROR or ARM_DRIVER_ERROR_UNSUPPORTED status
1436   TEST_ASSERT((ret == ARM_DRIVER_ERROR) || (ret == ARM_DRIVER_ERROR_UNSUPPORTED));
1437
1438   // Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_OK status
1439   TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1440
1441   // Call Send function and assert that it returned ARM_DRIVER_ERROR status
1442   TEST_ASSERT(drv->Send (ptr_tx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1443
1444   // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1445   TEST_ASSERT(drv->Receive (ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1446
1447   // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1448   TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1449
1450   // Call GetDataCount function and assert that it returned 0
1451   TEST_ASSERT(drv->GetDataCount () == 0U);
1452
1453   // Call Control function and assert that it returned ARM_DRIVER_ERROR status
1454   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);
1455
1456   // Call GetStatus function
1457   stat = drv->GetStatus();
1458
1459   // Assert that GetStatus function returned status structure with busy flag 0
1460   TEST_ASSERT(stat.busy == 0U);
1461
1462   // Assert that GetStatus function returned status structure with data_lost flag 0
1463   TEST_ASSERT(stat.data_lost == 0U);
1464
1465   // Assert that GetStatus function returned status structure with mode_fault flag 0
1466   TEST_ASSERT(stat.mode_fault == 0U);
1467
1468   // Assert that GetStatus function returned status structure with reserved field 0
1469   TEST_ASSERT(stat.reserved == 0U);
1470
1471   // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1472   TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1473
1474   // Driver is initialized and peripheral is powered-off:
1475   // Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1476   TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1477
1478   // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1479   TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1480
1481   // Driver is uninitialized and peripheral is powered-off:
1482   // Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1483   TEST_ASSERT(drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK);
1484
1485   // Driver is initialized and peripheral is powered-off:
1486   // Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1487   TEST_ASSERT(drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK);
1488
1489   // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1490   TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1491
1492   // Driver is uninitialized and peripheral is powered-off:
1493   // Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1494   TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1495
1496   // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1497   TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1498
1499   // Driver is initialized and peripheral is powered-off:
1500   // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1501   TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1502
1503   // Driver is initialized and peripheral is powered-on:
1504   // Call Control function and assert that it returned ARM_DRIVER_OK status
1505   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);
1506
1507   // Call Transfer function and assert that it returned ARM_DRIVER_OK status
1508   TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
1509
1510   // Call GetStatus function
1511   stat = drv->GetStatus();
1512
1513   // Assert that GetStatus function returned status structure with busy flag 1
1514   TEST_ASSERT(stat.busy == 1U);
1515
1516   // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1517   // (this must unconditionally terminate active transfer, power-off the peripheral and uninitialize the driver)
1518   TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1519
1520   // Driver is uninitialized and peripheral is powered-off:
1521   // Call GetStatus function
1522   stat = drv->GetStatus();
1523
1524   // Assert that GetStatus function returned status structure with busy flag 0
1525   TEST_ASSERT(stat.busy == 0U);
1526
1527 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
1528   // Ensure that SPI Server (if used) is ready for command reception
1529   (void)osDelay(20U);
1530 #endif
1531 }
1532
1533 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1534 /**
1535 \brief Function: Function SPI_PowerControl
1536 \details
1537 The function \b SPI_PowerControl verifies the \b PowerControl function.
1538 \code
1539   int32_t PowerControl (ARM_POWER_STATE state);
1540 \endcode
1541
1542 Testing sequence:
1543   - Driver is initialized and peripheral is powered-off:
1544     - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1545     - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1546     - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1547     - Call GetDataCount function and assert that it returned 0
1548     - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1549     - Call GetStatus function
1550     - Assert that GetStatus function returned status structure with busy flag 0
1551     - Assert that GetStatus function returned status structure with data_lost flag 0
1552     - Assert that GetStatus function returned status structure with mode_fault flag 0
1553     - Assert that GetStatus function returned status structure with reserved field 0
1554     - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1555     - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1556     - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1557   - Driver is initialized and peripheral is powered-on:
1558     - Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
1559     - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1560   - Driver is initialized and peripheral is powered-off:
1561     - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1562     - Call PowerControl(ARM_POWER_LOW) function
1563   - Driver is initialized and peripheral is powered-on or in low-power mode:
1564     - Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
1565     - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1566   - Driver is initialized and peripheral is powered-on:
1567     - Call Control function and assert that it returned ARM_DRIVER_OK status
1568     - Call Transfer function and assert that it returned ARM_DRIVER_OK status
1569     - Call GetStatus function
1570     - Assert that GetStatus function returned status structure with busy flag 1
1571     - Call PowerControl(ARM_POWER_OFF) function with transfer active and assert that it returned ARM_DRIVER_OK status<br>
1572       (this must unconditionally terminate active transfer and power-off the peripheral)
1573   - Driver is initialized and peripheral is powered-off:
1574     - Call GetStatus function
1575     - Assert that GetStatus function returned status structure with busy flag 0
1576 */
1577 void SPI_PowerControl (void) {
1578   int32_t        ret;
1579   ARM_SPI_STATUS stat;
1580
1581   (void)drv->Initialize (NULL);
1582
1583   // Driver is initialized and peripheral is powered-off:
1584   // Call Send function and assert that it returned ARM_DRIVER_ERROR status
1585   TEST_ASSERT(drv->Send (ptr_tx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1586
1587   // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1588   TEST_ASSERT(drv->Receive (ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1589
1590   // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1591   TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1592
1593   // Call GetDataCount function and assert that it returned 0
1594   TEST_ASSERT(drv->GetDataCount () == 0U);
1595
1596   // Call Control function and assert that it returned ARM_DRIVER_ERROR status
1597   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);
1598
1599   // Call GetStatus function
1600   stat = drv->GetStatus();
1601
1602   // Assert that GetStatus function returned status structure with busy flag 0
1603   TEST_ASSERT(stat.busy == 0U);
1604
1605   // Assert that GetStatus function returned status structure with data_lost flag 0
1606   TEST_ASSERT(stat.data_lost == 0U);
1607
1608   // Assert that GetStatus function returned status structure with mode_fault flag 0
1609   TEST_ASSERT(stat.mode_fault == 0U);
1610
1611   // Assert that GetStatus function returned status structure with reserved field 0
1612   TEST_ASSERT(stat.reserved == 0U);
1613
1614   // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1615   TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1616
1617   // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1618   TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1619
1620   // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1621   TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1622
1623   // Driver is initialized and peripheral is powered-on:
1624   // Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
1625   TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1626
1627   // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1628   TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1629
1630   // Driver is initialized and peripheral is powered-off:
1631   // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1632   TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1633
1634   // Call PowerControl(ARM_POWER_LOW) function
1635   ret = drv->PowerControl (ARM_POWER_LOW);
1636
1637   // Driver is initialized and peripheral is powered-on or in low-power mode:
1638   // Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
1639   TEST_ASSERT((ret == ARM_DRIVER_OK) || (ret == ARM_DRIVER_ERROR_UNSUPPORTED));
1640   if (ret == ARM_DRIVER_ERROR_UNSUPPORTED) {
1641     TEST_MESSAGE("[WARNING] PowerControl (ARM_POWER_LOW) is not supported");
1642   }
1643
1644   // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1645   TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1646
1647   // Driver is initialized and peripheral is powered-on:
1648   // Call Control function and assert that it returned ARM_DRIVER_OK status
1649   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);
1650
1651   // Call Transfer function and assert that it returned ARM_DRIVER_OK status
1652   TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
1653
1654   // Call GetStatus function
1655   stat = drv->GetStatus();
1656
1657   // Assert that GetStatus function returned status structure with busy flag 1
1658   TEST_ASSERT(stat.busy == 1U);
1659
1660   // Call PowerControl(ARM_POWER_OFF) function with transfer active and assert that it returned ARM_DRIVER_OK status
1661   // (this must unconditionally terminate active transfer and power-off the peripheral)
1662   TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1663
1664   // Driver is initialized and peripheral is powered-off:
1665   // Call GetStatus function
1666   stat = drv->GetStatus();
1667
1668   // Assert that GetStatus function returned status structure with busy flag 0
1669   TEST_ASSERT(stat.busy == 0U);
1670
1671   (void)drv->Uninitialize ();
1672
1673 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
1674   // Ensure that SPI Server (if used) is ready for command reception
1675   (void)osDelay(20U);
1676 #endif
1677 }
1678
1679 /**
1680 @}
1681 */
1682 // End of spi_tests_drv_mgmt
1683
1684 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1685 /* SPI Data Exchange tests                                                                                                  */
1686 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1687 /**
1688 \defgroup spi_tests_data_xchg Data Exchange
1689 \ingroup spi_tests
1690 \details
1691 These tests verify API and operation of the SPI data exchange functions.
1692
1693 The data exchange tests verify the following driver functions
1694 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
1695  - \b Send
1696 \code
1697   int32_t        Send         (const void *data,                    uint32_t num);
1698 \endcode
1699  - \b Receive
1700 \code
1701   int32_t        Receive      (      void *data,                    uint32_t num);
1702 \endcode
1703  - \b Transfer
1704 \code
1705   int32_t        Transfer     (const void *data_out, void *data_in, uint32_t num);
1706 \endcode
1707  - \b GetDataCount
1708 \code
1709   uint32_t       GetDataCount (void);
1710 \endcode
1711  - \b Control
1712 \code
1713   int32_t        Control      (uint32_t control, uint32_t arg);
1714 \endcode
1715  - \b GetStatus
1716 \code
1717   ARM_SPI_STATUS GetStatus    (void);
1718 \endcode
1719  - \b SignalEvent
1720 \code
1721   void (*ARM_SPI_SignalEvent_t) (uint32_t event);
1722 \endcode
1723
1724 All of these tests execute a data exchange and check the result of this data exchange.
1725
1726 Data exchange test procedure when Test Mode <b>SPI Server</b> is selected:
1727   - send command "SET BUF TX,.." to the SPI Server: Set Tx buffer
1728   - send command "SET BUF RX,.." to the SPI Server: Set Rx buffer
1729   - send command "SET COM .."    to the SPI Server: Set communication settings for the next XFER command
1730   - send command "XFER .."       to the SPI Server: Specify transfer
1731   - driver Control: Configure the SPI interface
1732   - driver Control: Set the default Tx value
1733   - driver Send/Receive/Transfer: Start the requested operation
1734   - driver GetStatus/SignalEvent: Wait for the current operation to finish or time-out<br>
1735     (operation is finished when busy flag is 0 and completed event was signaled)
1736   - assert that operation has finished in expected time
1737   - assert that ARM_SPI_EVENT_TRANSFER_COMPLETE event was signaled
1738   - driver GetStatus: Assert that busy flag is 0
1739   - driver GetDataCount: Assert that number of transferred items is same as requested
1740   - if operation has timed out call driver Control function to Abort operation and wait timeout time<br>
1741     to make sure that the SPI Server is ready for the next command
1742   - assert that received content is as expected
1743   - send command "GET BUF RX,.." to the SPI Server: Get Rx buffer
1744   - assert that sent content (read from the SPI Server's receive buffer) is as expected
1745
1746 Data exchange <b>Abort</b> test procedure when Test Mode <b>SPI Server</b> is selected:
1747   - send command "SET BUF TX,.." to the SPI Server: Set Tx buffer
1748   - send command "SET BUF RX,.." to the SPI Server: Set Rx buffer
1749   - send command "SET COM .."    to the SPI Server: Set communication settings for the next XFER command
1750   - send command "XFER .."       to the SPI Server: Specify transfer
1751   - driver Control: Configure the SPI interface
1752   - driver Control: Set the default Tx value
1753   - driver Send/Receive/Transfer: Start the requested operation
1754   - wait up to 1 ms
1755   - driver Control: Abort the current operation
1756   - driver GetStatus: Assert that busy flag is 0
1757   - driver GetDataCount: Assert that number of transferred items is less than requested
1758
1759 Data exchange test procedure when Test Mode <b>Loopback</b> is selected:
1760   - driver Control: Configure the SPI interface
1761   - driver Control: Set the default Tx value
1762   - driver Send/Transfer: Start the requested operation
1763   - driver GetStatus/SignalEvent: Wait for the current operation to finish or time-out<br>
1764     (operation is finished when busy flag is 0 and completed event was signaled)
1765   - assert that operation has finished in expected time
1766   - assert that ARM_SPI_EVENT_TRANSFER_COMPLETE event was signaled
1767   - driver GetStatus: Assert that busy flag is 0
1768   - driver GetDataCount: Assert that number of transferred items is same as requested
1769   - if operation has timed out call driver Control function to Abort operation
1770   - assert that received content is as expected (for Transfer operation only)
1771
1772 \note Limitations of Data Exchange tests if Test Mode <b>Loopback</b> is selected:
1773  - only Master mode with Slave Select not used can be tested
1774  - Receive function cannot be tested
1775  - format tests are not supported
1776  - only 8, 16, 24 and 32 data bit tests are supported
1777  - bit order tests are not supported
1778 @{
1779 */
1780
1781 #ifndef __DOXYGEN__                     // Exclude form the documentation
1782 /*
1783   \brief         Execute SPI data exchange or abort operation.
1784   \param[in]     operation      operation (OP_SEND .. OP_ABORT_TRANSFER)
1785   \param[in]     mode           mode (MODE_MASTER or MODE_SLAVE)
1786   \param[in]     format         clock/frame format (0 = polarity0/phase0 .. 5 = Microwire)
1787   \param[in]     data_bits      data bits (1 .. 32)
1788   \param[in]     bit_order      bit order (BO_MSB_TO_LSB or BO_LSB_TO_MSB)
1789   \param[in]     ss_mode        Slave Select mode (SS_MODE_xxx)
1790   \param[in]     bus_speed      bus speed in bits per second (bps)
1791   \param[in]     num            number of items to send, receive or transfer
1792   \return        none
1793 */
1794 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) {
1795   // volatile specifier is used to prevent compiler from optimizing variables 
1796   // in a way that they cannot be seen with a debugger
1797   volatile  int32_t       stat, def_tx_stat;
1798   volatile uint32_t       drv_mode, drv_format, drv_data_bits, drv_bit_order, drv_ss_mode;
1799   volatile uint32_t       srv_mode, srv_ss_mode;
1800   volatile ARM_SPI_STATUS spi_stat;
1801   volatile uint32_t       data_count;
1802            uint32_t       start_cnt;
1803            uint32_t       val, i;
1804   volatile uint32_t       srv_delay_c, srv_delay_t;
1805   volatile uint32_t       drv_delay_c, drv_delay_t;
1806            uint32_t       timeout, start_tick, curr_tick;
1807            uint8_t        chk_data;
1808
1809   // Prepare parameters for SPI Server and Driver configuration
1810   switch (mode) {
1811     case MODE_INACTIVE:
1812       TEST_FAIL_MESSAGE("[FAILED] Inactive mode! Data exchange operation aborted!");
1813       return;
1814     case MODE_MASTER:
1815       // When Master mode is tested, time diagram is as follows:
1816       // XFER                                                Â¯|¯
1817       // ... 4 ms                                             .
1818       // Slave Control (SPI Server)                           .
1819       // ... 4 ms                                             .
1820       // Master Control (SPI Client (DUT))                    .
1821       // ... 4 ms                                    SPI_CFG_XFER_TIMEOUT
1822       // Slave Transfer (SPI Server)                          .
1823       // ... 4 ms                                             .
1824       // Master Send/Receive/Transfer (SPI Client (DUT))      .
1825       // ... data exchange                                   _|_
1826       drv_mode    = ARM_SPI_MODE_MASTER;
1827       srv_mode    = 1U;
1828       srv_delay_c = 4U;
1829       srv_delay_t = 8U;
1830       drv_delay_c = 8U;
1831       drv_delay_t = 8U;
1832       break;
1833     case MODE_SLAVE:
1834       // When Slave mode is tested, time diagram is as follows:
1835       // XFER                                                Â¯|¯
1836       // ... 4 ms                                             .
1837       // Slave Control (SPI Client (DUT))                     .
1838       // ... 4 ms                                             .
1839       // Master Control (SPI Server)                          .
1840       // ... 4 ms                                    SPI_CFG_XFER_TIMEOUT
1841       // Slave Transfer (SPI Client (DUT))                    .
1842       // ... 4 ms                                             .
1843       // Master Send/Receive/Transfer (SPI Server)            .
1844       // ... data exchange                                   _|_
1845       drv_mode    = ARM_SPI_MODE_SLAVE;
1846       srv_mode    = 0U;
1847       srv_delay_c = 8U;
1848       srv_delay_t = 8U;
1849       drv_delay_c = 4U;
1850       drv_delay_t = 8U;
1851       break;
1852     default:
1853       TEST_FAIL_MESSAGE("[FAILED] Unknown mode! Data exchange operation aborted!");
1854       return;
1855   }
1856
1857
1858   switch (format) {
1859     case FORMAT_CPOL0_CPHA0:
1860       drv_format = ARM_SPI_CPOL0_CPHA0;
1861       break;
1862     case FORMAT_CPOL0_CPHA1:
1863       drv_format = ARM_SPI_CPOL0_CPHA1;
1864       break;
1865     case FORMAT_CPOL1_CPHA0:
1866       drv_format = ARM_SPI_CPOL1_CPHA0;
1867       break;
1868     case FORMAT_CPOL1_CPHA1:
1869       drv_format = ARM_SPI_CPOL1_CPHA1;
1870       break;
1871     case FORMAT_TI:
1872       drv_format = ARM_SPI_TI_SSI;
1873       break;
1874     case FORMAT_MICROWIRE:
1875       drv_format = ARM_SPI_MICROWIRE;
1876       break;
1877     default:
1878       TEST_FAIL_MESSAGE("[FAILED] Unknown clock / frame format! Data exchange operation aborted!");
1879       return;
1880   }
1881
1882   if ((data_bits > 0U) && (data_bits <= 32U)) {
1883     drv_data_bits = ARM_SPI_DATA_BITS(data_bits);
1884   } else {
1885     TEST_FAIL_MESSAGE("[FAILED] Data bits not in range 1 to 32! Data exchange operation aborted!");
1886     return;
1887   }
1888
1889   switch (bit_order) {
1890     case BO_MSB_TO_LSB:
1891       drv_bit_order = ARM_SPI_MSB_LSB;
1892       break;
1893     case BO_LSB_TO_MSB:
1894       drv_bit_order = ARM_SPI_LSB_MSB;
1895       break;
1896     default:
1897       TEST_FAIL_MESSAGE("[FAILED] Unknown bit order! Data exchange operation aborted!");
1898       return;
1899   }
1900
1901   if (mode == MODE_MASTER) {
1902     switch (ss_mode) {
1903       case SS_MODE_MASTER_UNUSED:
1904         drv_ss_mode = ARM_SPI_SS_MASTER_UNUSED;
1905         srv_ss_mode = 0U;
1906         break;
1907       case SS_MODE_MASTER_SW:
1908         drv_ss_mode = ARM_SPI_SS_MASTER_SW;
1909         srv_ss_mode = 1U;
1910         break;
1911       case SS_MODE_MASTER_HW_OUTPUT:
1912         drv_ss_mode = ARM_SPI_SS_MASTER_HW_OUTPUT;
1913         srv_ss_mode = 1U;
1914         break;
1915       case SS_MODE_MASTER_HW_INPUT:
1916         drv_ss_mode = ARM_SPI_SS_MASTER_UNUSED;
1917         srv_ss_mode = 0U;
1918         break;
1919       default:
1920         TEST_FAIL_MESSAGE("[FAILED] Unknown Slave Select mode! Data exchange operation aborted!");
1921         return;
1922     }
1923   } else {
1924     switch (ss_mode) {
1925       case SS_MODE_SLAVE_HW:
1926         drv_ss_mode = ARM_SPI_SS_SLAVE_HW;
1927         srv_ss_mode = 1U;
1928         break;
1929       case SS_MODE_SLAVE_SW:
1930         drv_ss_mode = ARM_SPI_SS_SLAVE_SW;
1931         srv_ss_mode = 0U;
1932         break;
1933       default:
1934         TEST_FAIL_MESSAGE("[FAILED] Unknown Slave Select mode! Data exchange operation aborted!");
1935         return;
1936     }
1937   }
1938
1939   // Total transfer timeout (16 ms is overhead before transfer starts)
1940   timeout = SPI_CFG_XFER_TIMEOUT + 16U;
1941
1942   // Check that SPI status is not busy before starting data exchange test
1943   spi_stat = drv->GetStatus();          // Get SPI status
1944   if (spi_stat.busy != 0U) {
1945     // If busy flag is active
1946     (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy active before operation! Data exchange operation aborted!");
1947   }
1948   TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
1949
1950   do {
1951 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
1952     if (CmdSetBufTx('S')   != EXIT_SUCCESS) { break; }
1953     if (CmdSetBufRx('?')   != EXIT_SUCCESS) { break; }
1954     if (CmdSetCom  (srv_mode, format, data_bits, bit_order, srv_ss_mode, bus_speed) != EXIT_SUCCESS) { break; }
1955     if (CmdXfer    (num, srv_delay_c, srv_delay_t, SPI_CFG_XFER_TIMEOUT) != EXIT_SUCCESS)            { break; }
1956     (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
1957 #else                                   // If Test Mode Loopback is selected
1958     // Remove warnings for unused variables
1959     (void)srv_mode;
1960     (void)srv_ss_mode;
1961     (void)srv_delay_c;
1962     (void)srv_delay_t;
1963     (void)def_tx_stat;
1964     (void)curr_tick;
1965 #endif
1966     start_tick = osKernelGetTickCount();
1967
1968     // Initialize buffers
1969     memset(ptr_tx_buf,  (int32_t)'!' , SPI_BUF_MAX);
1970     memset(ptr_tx_buf,  (int32_t)'T' , num * DataBitsToBytes(data_bits));
1971     memset(ptr_rx_buf,  (int32_t)'?' , SPI_BUF_MAX);
1972     memset(ptr_cmp_buf, (int32_t)'?' , SPI_BUF_MAX);
1973
1974     // Configure required communication settings
1975     (void)osDelay(drv_delay_c);         // Wait specified time before calling Control function
1976     if (mode == MODE_MASTER) {
1977       stat = drv->Control (drv_mode | drv_format | drv_data_bits | drv_bit_order | drv_ss_mode, bus_speed);
1978     } else {
1979       // For Slave mode bus speed argument is not used
1980       stat = drv->Control (drv_mode | drv_format | drv_data_bits | drv_bit_order | drv_ss_mode, 0U);
1981     }
1982     if (stat != ARM_DRIVER_OK) {
1983       // If configuration has failed
1984       (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Control function returned", str_ret[-stat]);
1985     }
1986     // Assert that Control function returned ARM_DRIVER_OK
1987     TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1988
1989     // Set default Tx value to 'D' byte values (only for master mode)
1990     if (mode == MODE_MASTER) {
1991       val = ((uint32_t)'D' << 24) | ((uint32_t)'D' << 16) | ((uint32_t)'D' << 8) | (uint32_t)'D';
1992       stat = drv->Control (ARM_SPI_SET_DEFAULT_TX_VALUE, val);
1993       def_tx_stat = stat;
1994       if ((stat != ARM_DRIVER_OK) && (stat != ARM_DRIVER_ERROR_UNSUPPORTED)) {
1995         // If set default Tx value has failed
1996         (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Set default Tx value returned", str_ret[-stat]);
1997       }
1998       // Assert that Control function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED
1999       TEST_ASSERT_MESSAGE((stat == ARM_DRIVER_OK) || (stat == ARM_DRIVER_ERROR_UNSUPPORTED), msg_buf);
2000
2001       if (stat == ARM_DRIVER_ERROR_UNSUPPORTED) {
2002         // If set default Tx value is not supported
2003         (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] %s: %s", str_oper[operation], "Set default Tx value is not supported");
2004         TEST_MESSAGE(msg_buf);
2005       }
2006     } else {
2007       // For slave mode default Tx is not tested
2008       def_tx_stat = ARM_DRIVER_ERROR_UNSUPPORTED;
2009     }
2010     (void)osDelay(drv_delay_t);         // Wait specified time before calling Send/Receive/Transfer function
2011
2012     // Prepare local variables
2013     event             = 0U;
2014     duration          = 0xFFFFFFFFUL;
2015     data_count        = 0U;
2016     data_count_sample = 0U;
2017     chk_data          = 1U;
2018     start_cnt         = osKernelGetSysTimerCount();
2019
2020     if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) || 
2021         ((mode == MODE_SLAVE)  && (ss_mode == SS_MODE_SLAVE_SW)))  {
2022       // If operation requires software Slave Select driving, activate Slave Select
2023       stat = drv->Control (ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE);
2024       if (stat != ARM_DRIVER_OK) {
2025         // If driving of Slave Select to active state has failed
2026         (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
2027       }
2028       // Assert that Control function returned ARM_DRIVER_OK
2029       TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2030     }
2031
2032     // Start the data exchange operation
2033     switch (operation & 0x0FU) {
2034       case OP_SEND:
2035       case OP_ABORT_SEND:
2036         stat = drv->Send(ptr_tx_buf, num);
2037         if (stat != ARM_DRIVER_OK) {
2038           // If Send activation has failed
2039           (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Send function returned", str_ret[-stat]);
2040         }
2041         // Assert that Send function returned ARM_DRIVER_OK
2042         TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2043         break;
2044       case OP_RECEIVE:
2045       case OP_ABORT_RECEIVE:
2046         stat = drv->Receive(ptr_rx_buf, num);
2047         if (stat != ARM_DRIVER_OK) {
2048           // If Receive activation has failed
2049           (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receive function returned", str_ret[-stat]);
2050         }
2051         // Assert that Receive function returned ARM_DRIVER_OK
2052         TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2053         break;
2054       case OP_TRANSFER:
2055       case OP_ABORT_TRANSFER:
2056         stat = drv->Transfer(ptr_tx_buf, ptr_rx_buf, num);
2057         if (stat != ARM_DRIVER_OK) {
2058           // If Transfer activation has failed
2059           (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transfer function returned", str_ret[-stat]);
2060         }
2061         // Assert that Transfer function returned ARM_DRIVER_OK
2062         TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2063         break;
2064       default:
2065         TEST_FAIL_MESSAGE("[FAILED] Unknown operation! Data exchange operation aborted!");
2066         return;
2067     }
2068     if (stat != ARM_DRIVER_OK) {
2069       // If Send/Receive/Transfer start has failed
2070       (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
2071     }
2072
2073     if ((operation == OP_ABORT_SEND)     ||     // This IF block tests only abort functionality
2074         (operation == OP_ABORT_RECEIVE)  ||
2075         (operation == OP_ABORT_TRANSFER)) {
2076       (void)osDelay(1U);                        // Wait short time before doing Abort
2077       stat = drv->Control (ARM_SPI_ABORT_TRANSFER, 0U);
2078       if (stat != ARM_DRIVER_OK) {
2079         // If Abort has failed
2080         (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
2081       }
2082       // Assert that Control function returned ARM_DRIVER_OK
2083       TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2084
2085       if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) || 
2086           ((mode == MODE_SLAVE)  && (ss_mode == SS_MODE_SLAVE_SW)))  {
2087         // If operation requires software Slave Select driving, deactivate Slave Select
2088         drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE);
2089       }
2090       spi_stat = drv->GetStatus();              // Get SPI status
2091       if (spi_stat.busy != 0U) {
2092         // If busy flag is still active
2093         (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy still active after Abort");
2094       }
2095       // Assert that busy flag is not active
2096       TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
2097
2098       data_count = drv->GetDataCount();         // Get data count
2099       if (data_count >= num) {
2100         // If data count is more or equal to number of items then Abort has failed
2101         (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");
2102       }
2103       // Assert data count is less then number of items requested for exchange
2104       TEST_ASSERT_MESSAGE(data_count < num, msg_buf);
2105
2106 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
2107       // Deactivate SPI
2108       (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
2109
2110       // Wait until timeout expires
2111       curr_tick = osKernelGetTickCount();
2112       if ((curr_tick - start_tick) < timeout) {
2113         (void)osDelay(timeout - (curr_tick - start_tick));
2114       }
2115       (void)osDelay(20U);                       // Wait for SPI Server to start reception of next command
2116 #endif
2117
2118       return;                                   // Here Abort test is finished, exit
2119     }
2120
2121     // Wait for operation to finish (status busy is 0 and event complete signaled, or timeout)
2122     do {
2123       if (data_count_sample == 0U) {
2124         // Store first data count different than 0
2125         data_count_sample = drv->GetDataCount();  // Get data count
2126       }
2127       if ((drv->GetStatus().busy == 0U) && ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) != 0U)) {
2128         duration = osKernelGetSysTimerCount() - start_cnt;
2129         break;
2130       }
2131     } while ((osKernelGetTickCount() - start_tick) < timeout);
2132
2133     if (duration == 0xFFFFFFFFUL) {
2134       // If operation has timed out
2135       (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Operation timed out");
2136     }
2137     // Assert that operation has finished in expected time
2138     TEST_ASSERT_MESSAGE(duration != 0xFFFFFFFFUL, msg_buf);
2139
2140     if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) || 
2141         ((mode == MODE_SLAVE)  && (ss_mode == SS_MODE_SLAVE_SW)))  {
2142       // If operation requires software Slave Select driving, deactivate Slave Select
2143       stat = drv->Control (ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE);
2144       if (stat != ARM_DRIVER_OK) {
2145         // If driving of Slave Select to inactive state has failed
2146         (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
2147       }
2148       // Assert that Control function returned ARM_DRIVER_OK
2149       TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2150     }
2151
2152     if ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) == 0U) {
2153       // If transfer complete event was not signaled
2154       (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_SPI_EVENT_TRANSFER_COMPLETE was not signaled");
2155       chk_data = 0U;                            // Do not check transferred content
2156     }
2157     // Assert that ARM_SPI_EVENT_TRANSFER_COMPLETE was signaled
2158     TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) != 0U, msg_buf);
2159
2160     spi_stat = drv->GetStatus();                // Get SPI status
2161     if (spi_stat.busy != 0U) {
2162       // If busy flag is still active
2163       (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy still active after operation");
2164       chk_data = 0U;                            // Do not check transferred content
2165     }
2166     // Assert that busy flag is not active
2167     TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
2168
2169     if ((event & ARM_SPI_EVENT_DATA_LOST) != 0U) {
2170       // If data lost was signaled during the transfer
2171       (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_SPI_EVENT_DATA_LOST was signaled");
2172       chk_data = 0U;                            // Do not check transferred content
2173     }
2174     // Assert that ARM_SPI_EVENT_DATA_LOST was not signaled
2175     TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_DATA_LOST) == 0U, msg_buf);
2176
2177     data_count = drv->GetDataCount();           // Get data count
2178     if (data_count != num) {
2179       // If data count is different then number of items, then operation has failed
2180       (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");
2181       chk_data = 0U;                            // Do not check transferred content
2182     }
2183     // Assert that data count is equal to number of items requested for exchange
2184     TEST_ASSERT_MESSAGE(data_count == num, msg_buf);
2185
2186     if ((drv->GetStatus().busy != 0U) || ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) == 0U)) {
2187       // If transfer did not finish in time, abort it
2188       (void)drv->Control(ARM_SPI_ABORT_TRANSFER, 0U);
2189     }
2190
2191 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
2192     // Deactivate SPI
2193     (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
2194
2195     // Wait until timeout expires
2196     curr_tick = osKernelGetTickCount();
2197     if ((curr_tick - start_tick) < timeout) {
2198       (void)osDelay(timeout - (curr_tick - start_tick));
2199     }
2200     (void)osDelay(20U);                 // Wait for SPI Server to start reception of next command
2201
2202     if (chk_data != 0U) {               // If transferred content should be checked
2203       // Check received content for receive and transfer operations
2204       if ((operation == OP_RECEIVE) || (operation == OP_TRANSFER)) {
2205         memset(ptr_cmp_buf, (int32_t)'S', num * DataBitsToBytes(data_bits));
2206         stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
2207         if (stat != 0) {
2208           // If data received mismatches
2209           // Find on which byte mismatch starts
2210           for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
2211             if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
2212               break;
2213             }
2214           }
2215           (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, received was 0x%02X, expected was 0x%02X", str_oper[operation], "Received data mismatches on", i, ptr_rx_buf[i], ptr_cmp_buf[i]);
2216         }
2217         // Assert that data received is same as expected
2218         TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
2219       }
2220
2221       // Check sent content (by checking SPI Server's received buffer content)
2222       if ((mode == MODE_MASTER) || (operation != OP_RECEIVE) || (def_tx_stat == ARM_DRIVER_OK)) {
2223         // Check sent data in all cases except Slave mode Receive operation
2224         // with Default Tx not working or unsupported
2225         if (CmdGetBufRx(SPI_BUF_MAX) != EXIT_SUCCESS) { break; }
2226
2227         if ((operation == OP_RECEIVE) && (def_tx_stat == ARM_DRIVER_OK)) {
2228           // Expected data received by SPI Server should be default Tx value
2229           memset(ptr_cmp_buf, (int32_t)'D', num * DataBitsToBytes(data_bits));
2230         }
2231         if ((operation == OP_SEND) || (operation == OP_TRANSFER)) {
2232           // Expected data received by SPI Server should be what was sent
2233           memset(ptr_cmp_buf, (int32_t)'T', num * DataBitsToBytes(data_bits));
2234         }
2235
2236         stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
2237         if (stat != 0) {
2238           // If data sent mismatches
2239           // Find on which byte mismatch starts
2240           for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
2241             if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
2242               break;
2243             }
2244           }
2245           if (operation == OP_RECEIVE) {
2246             // If sent was default Tx value, 'D' bytes
2247             (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]);
2248           } else {
2249             // If sent was 'T' bytes
2250             (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]);
2251           }
2252         }
2253         // Assert data sent is same as expected
2254         TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
2255       }
2256     }
2257 #else                                   // If Test Mode Loopback is selected
2258     if (chk_data != 0U) {               // If transferred content should be checked
2259       if (operation == OP_TRANSFER) {
2260         memset(ptr_cmp_buf, (int32_t)('T' & ((1U << data_bits) - 1U)), num * DataBitsToBytes(data_bits));
2261         if ((data_bits > 8U) && (data_bits < 16U)) {
2262           for (i = 1U; i < (num * DataBitsToBytes(data_bits)); i+= DataBitsToBytes(data_bits)) {
2263             ptr_cmp_buf[i] = 'T' & ((1U << (data_bits - 8U)) - 1U);
2264           }
2265         } else if ((data_bits > 16U) && (data_bits < 32U)) {
2266           for (i = 2U; i < (num * DataBitsToBytes(data_bits)); i+= DataBitsToBytes(data_bits)) {
2267             if (data_bits <= 24U) {
2268               ptr_cmp_buf[i  ] = 'T' & ((1U << (data_bits - 16U)) - 1U);
2269               ptr_cmp_buf[i+1] = 0U;
2270             } else {
2271               ptr_cmp_buf[i+1] = 'T' & ((1U << (data_bits - 24U)) - 1U);
2272             }
2273           }
2274         }
2275         stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
2276         if (stat != 0) {
2277           // If data received mismatches
2278           // Find on which byte mismatch starts
2279           for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
2280             if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
2281               break;
2282             }
2283           }
2284           (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]);
2285         }
2286         // Assert that data received is same as expected
2287         TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
2288       }
2289     }
2290 #endif
2291
2292     return;
2293   } while (false);
2294
2295 #if (SPI_SERVER_USED == 1)              // If Test Mode SPI Server is selected
2296   TEST_FAIL_MESSAGE("[FAILED] Problems in communication with SPI Server. Test aborted!");
2297 #endif
2298 }
2299
2300 #endif                                  // End of exclude form the documentation
2301
2302 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2303 /**
2304 \brief Function: Function SPI_Mode_Master_SS_Unused
2305 \details
2306 The function \b SPI_Mode_Master_SS_Unused verifies data exchange:
2307  - in <b>Master Mode</b> with <b>Slave Select line not used</b>
2308  - with default clock / frame format
2309  - with default data bits
2310  - with default bit order
2311  - at default bus speed
2312  - for default number of data items
2313
2314 \note In Test Mode <b>Loopback</b> Receive function is not checked
2315 */
2316 void SPI_Mode_Master_SS_Unused (void) {
2317
2318   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
2319   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
2320   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2321   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2322 #if  (SPI_SERVER_USED == 1)
2323   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2324   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; }
2325 #endif
2326
2327   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);
2328 #if (SPI_SERVER_USED == 1)
2329   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);
2330 #endif
2331   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);
2332 }
2333
2334 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2335 /**
2336 \brief Function: Function SPI_Mode_Master_SS_Sw_Ctrl
2337 \details
2338 The function \b SPI_Mode_Master_SS_Sw_Ctrl verifies data exchange:
2339  - in <b>Master Mode</b> with <b>Slave Select line Software controlled</b>
2340  - with default clock / frame format
2341  - with default data bits
2342  - with default bit order
2343  - at default bus speed
2344  - for default number of data items
2345
2346 \note In Test Mode <b>Loopback</b> this test is not executed
2347 */
2348 void SPI_Mode_Master_SS_Sw_Ctrl (void) {
2349
2350   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
2351   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
2352   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
2353   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2354   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2355 #if  (SPI_SERVER_USED == 1)
2356   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2357   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; }
2358 #endif
2359
2360   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);
2361   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);
2362   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);
2363 }
2364
2365 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2366 /**
2367 \brief Function: Function SPI_Mode_Master_SS_Hw_Ctrl_Out
2368 \details
2369 The function \b SPI_Mode_Master_SS_Hw_Ctrl_Out verifies data exchange:
2370  - in <b>Master Mode</b> with <b>Slave Select line Hardware controlled Output</b>
2371  - with default clock / frame format
2372  - with default data bits
2373  - with default bit order
2374  - at default bus speed
2375  - for default number of data items
2376
2377 \note In Test Mode <b>Loopback</b> this test not executed
2378 */
2379 void SPI_Mode_Master_SS_Hw_Ctrl_Out (void) {
2380
2381   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
2382   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2383   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2384 #if  (SPI_SERVER_USED == 1)
2385   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2386   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; }
2387 #endif
2388
2389   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);
2390   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);
2391   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);
2392 }
2393
2394 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2395 /**
2396 \brief Function: Function SPI_Mode_Master_SS_Hw_Mon_In
2397 \details
2398 The function \b SPI_Mode_Master_SS_Hw_Mon_In verifies data exchange:
2399  - in <b>Master Mode</b> with <b>Slave Select line Hardware monitored Input</b>
2400  - with default clock / frame format
2401  - with default data bits
2402  - with default bit order
2403  - at default bus speed
2404  - for default number of data items
2405
2406 \note In Test Mode <b>Loopback</b> this test not executed
2407 */
2408 void SPI_Mode_Master_SS_Hw_Mon_In (void) {
2409
2410   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
2411   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
2412   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
2413   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2414   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2415 #if  (SPI_SERVER_USED == 1)
2416   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2417   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; }
2418 #endif
2419
2420   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);
2421   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);
2422   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);
2423 }
2424
2425 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2426 /**
2427 \brief Function: Function SPI_Mode_Slave_SS_Hw_Mon
2428 \details
2429 The function \b SPI_Mode_Slave_SS_Hw_Mon verifies data exchange:
2430  - in <b>Slave Mode</b> with <b>Slave Select line Hardware monitored</b>
2431  - with default clock / frame format
2432  - with default data bits
2433  - with default bit order
2434  - at default bus speed
2435  - for default number of data items
2436
2437 \note In Test Mode <b>Loopback</b> this test not executed
2438 */
2439 void SPI_Mode_Slave_SS_Hw_Mon (void) {
2440
2441   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
2442   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2443   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2444 #if  (SPI_SERVER_USED == 1)
2445   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2446   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; }
2447 #endif
2448
2449   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);
2450   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);
2451   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);
2452 }
2453
2454 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2455 /**
2456 \brief Function: Function SPI_Mode_Slave_SS_Sw_Ctrl
2457 \details
2458 The function \b SPI_Mode_Slave_SS_Sw_Ctrl verifies data exchange:
2459  - in <b>Slave Mode</b> with <b>Slave Select line Software controlled</b>
2460  - with default clock / frame format
2461  - with default data bits
2462  - with default bit order
2463  - at default bus speed
2464  - for default number of data items
2465
2466 \note In Test Mode <b>Loopback</b> this test not executed
2467 */
2468 void SPI_Mode_Slave_SS_Sw_Ctrl (void) {
2469
2470   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
2471   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
2472   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
2473   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2474   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2475 #if  (SPI_SERVER_USED == 1)
2476   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2477   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; }
2478 #endif
2479
2480   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);
2481   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);
2482   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);
2483 }
2484
2485 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2486 /**
2487 \brief Function: Function SPI_Format_Clock_Pol0_Pha0
2488 \details
2489 The function \b SPI_Format_Clock_Pol0_Pha0 verifies data exchange:
2490  - in Master Mode with default Slave Select mode
2491  - with clock format: <b>polarity 0 / phase 0</b>
2492  - with default data bits
2493  - with default bit order
2494  - at default bus speed
2495  - for default number of data items
2496
2497 \note In Test Mode <b>Loopback</b> this test not executed
2498 */
2499 void SPI_Format_Clock_Pol0_Pha0 (void) {
2500
2501   if (IsNotLoopback()    != EXIT_SUCCESS) {              return; }
2502   if (DriverInit()       != EXIT_SUCCESS) { TEST_FAIL(); return; }
2503   if (BuffersCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2504 #if  (SPI_SERVER_USED == 1)
2505   if (ServerCheck()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2506   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; }
2507 #endif
2508
2509   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);
2510   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);
2511   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);
2512 }
2513
2514 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2515 /**
2516 \brief Function: Function SPI_Format_Clock_Pol0_Pha1
2517 \details
2518 The function \b SPI_Format_Clock_Pol0_Pha1 verifies data exchange:
2519  - in Master Mode with default Slave Select mode
2520  - with clock format: <b>polarity 0 / phase 1</b>
2521  - with default data bits
2522  - with default bit order
2523  - at default bus speed
2524  - for default number of data items
2525
2526 \note In Test Mode <b>Loopback</b> this test not executed
2527 */
2528 void SPI_Format_Clock_Pol0_Pha1 (void) {
2529
2530   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
2531   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2532   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2533 #if  (SPI_SERVER_USED == 1)
2534   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2535   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; }
2536 #endif
2537
2538   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);
2539   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);
2540   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);
2541 }
2542
2543 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2544 /**
2545 \brief Function: Function SPI_Format_Clock_Pol1_Pha0
2546 \details
2547 The function \b SPI_Format_Clock_Pol1_Pha0 verifies data exchange:
2548  - in Master Mode with default Slave Select mode
2549  - with clock format: <b>polarity 1 / phase 0</b>
2550  - with default data bits
2551  - with default bit order
2552  - at default bus speed
2553  - for default number of data items
2554
2555 \note In Test Mode <b>Loopback</b> this test not executed
2556 */
2557 void SPI_Format_Clock_Pol1_Pha0 (void) {
2558
2559   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
2560   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2561   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2562 #if  (SPI_SERVER_USED == 1)
2563   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2564   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; }
2565 #endif
2566
2567   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);
2568   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);
2569   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);
2570 }
2571
2572 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2573 /**
2574 \brief Function: Function SPI_Format_Clock_Pol1_Pha1
2575 \details
2576 The function \b SPI_Format_Clock_Pol1_Pha1 verifies data exchange:
2577  - in Master Mode with default Slave Select mode
2578  - with clock format: <b>polarity 1 / phase 1</b>
2579  - with default data bits
2580  - with default bit order
2581  - at default bus speed
2582  - for default number of data items
2583
2584 \note In Test Mode <b>Loopback</b> this test not executed
2585 */
2586 void SPI_Format_Clock_Pol1_Pha1 (void) {
2587
2588   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
2589   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2590   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2591 #if  (SPI_SERVER_USED == 1)
2592   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2593   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; }
2594 #endif
2595
2596   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);
2597   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);
2598   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);
2599 }
2600
2601 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2602 /**
2603 \brief Function: Function SPI_Format_Frame_TI
2604 \details
2605 The function \b SPI_Format_Frame_TI verifies data exchange:
2606  - in <b>Master Mode</b> with <b>Slave Select line Hardware controlled Output</b>
2607  - with <b>Texas Instruments frame format</b>
2608  - with default data bits
2609  - with bit order <b>from MSB to LSB</b>
2610  - at default bus speed
2611  - for default number of data items
2612
2613 \note In Test Mode <b>Loopback</b> this test not executed
2614 */
2615 void SPI_Format_Frame_TI (void) {
2616
2617   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
2618   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
2619   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2620   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2621 #if  (SPI_SERVER_USED == 1)
2622   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2623   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; }
2624 #endif
2625
2626   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);
2627   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);
2628   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);
2629 }
2630
2631 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2632 /**
2633 \brief Function: Function SPI_Format_Clock_Microwire
2634 \details
2635 The function \b SPI_Format_Clock_Microwire verifies data exchange:
2636  - in <b>Master Mode</b> with <b>Slave Select line Hardware controlled Output</b>
2637  - with <b>National Semiconductor Microwire frame format</b>
2638  - with default data bits
2639  - with bit order <b>from MSB to LSB</b>
2640  - at default bus speed
2641  - for default number of data items
2642
2643 \note In Test Mode <b>Loopback</b> this test not executed
2644 */
2645 void SPI_Format_Clock_Microwire (void) {
2646
2647   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
2648   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
2649   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2650   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2651 #if  (SPI_SERVER_USED == 1)
2652   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2653   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; }
2654 #endif
2655
2656   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);
2657   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);
2658   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);
2659 }
2660
2661 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2662 /**
2663 \brief Function: Function SPI_Data_Bits_1
2664 \details
2665 The function \b SPI_Data_Bits_1 verifies data exchange:
2666  - in Master Mode with default Slave Select mode
2667  - with default clock / frame format
2668  - with <b>1 data bits</b> per frame
2669  - with default bit order
2670  - at default bus speed
2671  - for default number of data items
2672 */
2673 void SPI_Data_Bits_1 (void) {
2674
2675   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
2676   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
2677   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2678   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2679 #if  (SPI_SERVER_USED == 1)
2680   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2681   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 1U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2682 #endif
2683
2684   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);
2685   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);
2686   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);
2687 }
2688
2689 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2690 /**
2691 \brief Function: Function SPI_Data_Bits_2
2692 \details
2693 The function \b SPI_Data_Bits_2 verifies data exchange:
2694  - in Master Mode with default Slave Select mode
2695  - with default clock / frame format
2696  - with <b>2 data bits</b> per frame
2697  - with default bit order
2698  - at default bus speed
2699  - for default number of data items
2700 */
2701 void SPI_Data_Bits_2 (void) {
2702
2703   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
2704   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
2705   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2706   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2707 #if  (SPI_SERVER_USED == 1)
2708   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2709   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 2U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2710 #endif
2711
2712   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);
2713   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);
2714   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);
2715 }
2716
2717 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2718 /**
2719 \brief Function: Function SPI_Data_Bits_3
2720 \details
2721 The function \b SPI_Data_Bits_3 verifies data exchange:
2722  - in Master Mode with default Slave Select mode
2723  - with default clock / frame format
2724  - with <b>3 data bits</b> per frame
2725  - with default bit order
2726  - at default bus speed
2727  - for default number of data items
2728 */
2729 void SPI_Data_Bits_3 (void) {
2730
2731   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
2732   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
2733   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2734   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2735 #if  (SPI_SERVER_USED == 1)
2736   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2737   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 3U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2738 #endif
2739
2740   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);
2741   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);
2742   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);
2743 }
2744
2745 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2746 /**
2747 \brief Function: Function SPI_Data_Bits_4
2748 \details
2749 The function \b SPI_Data_Bits_4 verifies data exchange:
2750  - in Master Mode with default Slave Select mode
2751  - with default clock / frame format
2752  - with <b>4 data bits</b> per frame
2753  - with default bit order
2754  - at default bus speed
2755  - for default number of data items
2756 */
2757 void SPI_Data_Bits_4 (void) {
2758
2759   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
2760   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
2761   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2762   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2763 #if  (SPI_SERVER_USED == 1)
2764   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2765   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 4U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2766 #endif
2767
2768   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);
2769   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);
2770   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);
2771 }
2772
2773 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2774 /**
2775 \brief Function: Function SPI_Data_Bits_5
2776 \details
2777 The function \b SPI_Data_Bits_5 verifies data exchange:
2778  - in Master Mode with default Slave Select mode
2779  - with default clock / frame format
2780  - with <b>5 data bits</b> per frame
2781  - with default bit order
2782  - at default bus speed
2783  - for default number of data items
2784 */
2785 void SPI_Data_Bits_5 (void) {
2786
2787   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
2788   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
2789   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2790   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2791 #if  (SPI_SERVER_USED == 1)
2792   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2793   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 5U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2794 #endif
2795
2796   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);
2797   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);
2798   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);
2799 }
2800
2801 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2802 /**
2803 \brief Function: Function SPI_Data_Bits_6
2804 \details
2805 The function \b SPI_Data_Bits_6 verifies data exchange:
2806  - in Master Mode with default Slave Select mode
2807  - with default clock / frame format
2808  - with <b>6 data bits</b> per frame
2809  - with default bit order
2810  - at default bus speed
2811  - for default number of data items
2812 */
2813 void SPI_Data_Bits_6 (void) {
2814
2815   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
2816   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
2817   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2818   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2819 #if  (SPI_SERVER_USED == 1)
2820   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2821   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 6U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2822 #endif
2823
2824   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);
2825   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);
2826   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);
2827 }
2828
2829 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2830 /**
2831 \brief Function: Function SPI_Data_Bits_7
2832 \details
2833 The function \b SPI_Data_Bits_7 verifies data exchange:
2834  - in Master Mode with default Slave Select mode
2835  - with default clock / frame format
2836  - with <b>7 data bits</b> per frame
2837  - with default bit order
2838  - at default bus speed
2839  - for default number of data items
2840 */
2841 void SPI_Data_Bits_7 (void) {
2842
2843   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
2844   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
2845   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2846   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2847 #if  (SPI_SERVER_USED == 1)
2848   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2849   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 7U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2850 #endif
2851
2852   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);
2853   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);
2854   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);
2855 }
2856
2857 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2858 /**
2859 \brief Function: Function SPI_Data_Bits_8
2860 \details
2861 The function \b SPI_Data_Bits_8 verifies data exchange:
2862  - in Master Mode with default Slave Select mode
2863  - with default clock / frame format
2864  - with <b>8 data bits</b> per frame
2865  - with default bit order
2866  - at default bus speed
2867  - for default number of data items
2868 */
2869 void SPI_Data_Bits_8 (void) {
2870
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 void SPI_Data_Bits_9 (void) {
2898
2899   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
2900   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
2901   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2902   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2903 #if  (SPI_SERVER_USED == 1)
2904   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2905   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 9U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2906 #endif
2907
2908   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);
2909   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);
2910   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);
2911 }
2912
2913 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2914 /**
2915 \brief Function: Function SPI_Data_Bits_10
2916 \details
2917 The function \b SPI_Data_Bits_10 verifies data exchange:
2918  - in Master Mode with default Slave Select mode
2919  - with default clock / frame format
2920  - with <b>10 data bits</b> per frame
2921  - with default bit order
2922  - at default bus speed
2923  - for default number of data items
2924 */
2925 void SPI_Data_Bits_10 (void) {
2926
2927   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
2928   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
2929   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2930   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2931 #if  (SPI_SERVER_USED == 1)
2932   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2933   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 10U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2934 #endif
2935
2936   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);
2937   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);
2938   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);
2939 }
2940
2941 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2942 /**
2943 \brief Function: Function SPI_Data_Bits_11
2944 \details
2945 The function \b SPI_Data_Bits_11 verifies data exchange:
2946  - in Master Mode with default Slave Select mode
2947  - with default clock / frame format
2948  - with <b>11 data bits</b> per frame
2949  - with default bit order
2950  - at default bus speed
2951  - for default number of data items
2952 */
2953 void SPI_Data_Bits_11 (void) {
2954
2955   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
2956   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
2957   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2958   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2959 #if  (SPI_SERVER_USED == 1)
2960   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2961   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 11U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2962 #endif
2963
2964   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);
2965   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);
2966   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);
2967 }
2968
2969 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2970 /**
2971 \brief Function: Function SPI_Data_Bits_12
2972 \details
2973 The function \b SPI_Data_Bits_12 verifies data exchange:
2974  - in Master Mode with default Slave Select mode
2975  - with default clock / frame format
2976  - with <b>12 data bits</b> per frame
2977  - with default bit order
2978  - at default bus speed
2979  - for default number of data items
2980 */
2981 void SPI_Data_Bits_12 (void) {
2982
2983   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
2984   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
2985   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
2986   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
2987 #if  (SPI_SERVER_USED == 1)
2988   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
2989   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 12U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2990 #endif
2991
2992   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);
2993   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);
2994   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);
2995 }
2996
2997 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2998 /**
2999 \brief Function: Function SPI_Data_Bits_13
3000 \details
3001 The function \b SPI_Data_Bits_13 verifies data exchange:
3002  - in Master Mode with default Slave Select mode
3003  - with default clock / frame format
3004  - with <b>13 data bits</b> per frame
3005  - with default bit order
3006  - at default bus speed
3007  - for default number of data items
3008 */
3009 void SPI_Data_Bits_13 (void) {
3010
3011   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
3012   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
3013   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3014   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3015 #if  (SPI_SERVER_USED == 1)
3016   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3017   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 13U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3018 #endif
3019
3020   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);
3021   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);
3022   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);
3023 }
3024
3025 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3026 /**
3027 \brief Function: Function SPI_Data_Bits_14
3028 \details
3029 The function \b SPI_Data_Bits_14 verifies data exchange:
3030  - in Master Mode with default Slave Select mode
3031  - with default clock / frame format
3032  - with <b>14 data bits</b> per frame
3033  - with default bit order
3034  - at default bus speed
3035  - for default number of data items
3036 */
3037 void SPI_Data_Bits_14 (void) {
3038
3039   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
3040   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
3041   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3042   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3043 #if  (SPI_SERVER_USED == 1)
3044   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3045   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 14U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3046 #endif
3047
3048   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);
3049   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);
3050   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);
3051 }
3052
3053 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3054 /**
3055 \brief Function: Function SPI_Data_Bits_15
3056 \details
3057 The function \b SPI_Data_Bits_15 verifies data exchange:
3058  - in Master Mode with default Slave Select mode
3059  - with default clock / frame format
3060  - with <b>15 data bits</b> per frame
3061  - with default bit order
3062  - at default bus speed
3063  - for default number of data items
3064 */
3065 void SPI_Data_Bits_15 (void) {
3066
3067   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
3068   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
3069   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3070   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3071 #if  (SPI_SERVER_USED == 1)
3072   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3073   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 15U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3074 #endif
3075
3076   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);
3077   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);
3078   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);
3079 }
3080
3081 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3082 /**
3083 \brief Function: Function SPI_Data_Bits_16
3084 \details
3085 The function \b SPI_Data_Bits_16 verifies data exchange:
3086  - in Master Mode with default Slave Select mode
3087  - with default clock / frame format
3088  - with <b>16 data bits</b> per frame
3089  - with default bit order
3090  - at default bus speed
3091  - for default number of data items
3092 */
3093 void SPI_Data_Bits_16 (void) {
3094
3095   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
3096   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
3097   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3098   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3099 #if  (SPI_SERVER_USED == 1)
3100   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3101   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 16U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3102 #endif
3103
3104   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);
3105   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);
3106   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);
3107 }
3108
3109 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3110 /**
3111 \brief Function: Function SPI_Data_Bits_17
3112 \details
3113 The function \b SPI_Data_Bits_17 verifies data exchange:
3114  - in Master Mode with default Slave Select mode
3115  - with default clock / frame format
3116  - with <b>17 data bits</b> per frame
3117  - with default bit order
3118  - at default bus speed
3119  - for default number of data items
3120 */
3121 void SPI_Data_Bits_17 (void) {
3122
3123   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3124   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3125   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3126   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3127 #if  (SPI_SERVER_USED == 1)
3128   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3129   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 17U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3130 #endif
3131
3132   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);
3133   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);
3134   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);
3135 }
3136
3137 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3138 /**
3139 \brief Function: Function SPI_Data_Bits_18
3140 \details
3141 The function \b SPI_Data_Bits_18 verifies data exchange:
3142  - in Master Mode with default Slave Select mode
3143  - with default clock / frame format
3144  - with <b>18 data bits</b> per frame
3145  - with default bit order
3146  - at default bus speed
3147  - for default number of data items
3148 */
3149 void SPI_Data_Bits_18 (void) {
3150
3151   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3152   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3153   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3154   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3155 #if  (SPI_SERVER_USED == 1)
3156   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3157   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 18U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3158 #endif
3159
3160   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);
3161   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);
3162   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);
3163 }
3164
3165 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3166 /**
3167 \brief Function: Function SPI_Data_Bits_19
3168 \details
3169 The function \b SPI_Data_Bits_19 verifies data exchange:
3170  - in Master Mode with default Slave Select mode
3171  - with default clock / frame format
3172  - with <b>19 data bits</b> per frame
3173  - with default bit order
3174  - at default bus speed
3175  - for default number of data items
3176 */
3177 void SPI_Data_Bits_19 (void) {
3178
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, 19U, 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, 19U, 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, 19U, 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, 19U, 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_20
3196 \details
3197 The function \b SPI_Data_Bits_20 verifies data exchange:
3198  - in Master Mode with default Slave Select mode
3199  - with default clock / frame format
3200  - with <b>20 data bits</b> per frame
3201  - with default bit order
3202  - at default bus speed
3203  - for default number of data items
3204 */
3205 void SPI_Data_Bits_20 (void) {
3206
3207   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3208   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3209   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3210   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3211 #if  (SPI_SERVER_USED == 1)
3212   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3213   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 20U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3214 #endif
3215
3216   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);
3217   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);
3218   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);
3219 }
3220
3221 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3222 /**
3223 \brief Function: Function SPI_Data_Bits_21
3224 \details
3225 The function \b SPI_Data_Bits_21 verifies data exchange:
3226  - in Master Mode with default Slave Select mode
3227  - with default clock / frame format
3228  - with <b>21 data bits</b> per frame
3229  - with default bit order
3230  - at default bus speed
3231  - for default number of data items
3232 */
3233 void SPI_Data_Bits_21 (void) {
3234
3235   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3236   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3237   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3238   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3239 #if  (SPI_SERVER_USED == 1)
3240   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3241   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 21U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3242 #endif
3243
3244   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);
3245   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);
3246   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);
3247 }
3248
3249 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3250 /**
3251 \brief Function: Function SPI_Data_Bits_22
3252 \details
3253 The function \b SPI_Data_Bits_22 verifies data exchange:
3254  - in Master Mode with default Slave Select mode
3255  - with default clock / frame format
3256  - with <b>22 data bits</b> per frame
3257  - with default bit order
3258  - at default bus speed
3259  - for default number of data items
3260 */
3261 void SPI_Data_Bits_22 (void) {
3262
3263   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3264   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3265   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3266   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3267 #if  (SPI_SERVER_USED == 1)
3268   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3269   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 22U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3270 #endif
3271
3272   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);
3273   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);
3274   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);
3275 }
3276
3277 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3278 /**
3279 \brief Function: Function SPI_Data_Bits_23
3280 \details
3281 The function \b SPI_Data_Bits_23 verifies data exchange:
3282  - in Master Mode with default Slave Select mode
3283  - with default clock / frame format
3284  - with <b>23 data bits</b> per frame
3285  - with default bit order
3286  - at default bus speed
3287  - for default number of data items
3288 */
3289 void SPI_Data_Bits_23 (void) {
3290
3291   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3292   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3293   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3294   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3295 #if  (SPI_SERVER_USED == 1)
3296   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3297   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 23U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3298 #endif
3299
3300   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);
3301   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);
3302   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);
3303 }
3304
3305 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3306 /**
3307 \brief Function: Function SPI_Data_Bits_24
3308 \details
3309 The function \b SPI_Data_Bits_24 verifies data exchange:
3310  - in Master Mode with default Slave Select mode
3311  - with default clock / frame format
3312  - with <b>24 data bits</b> per frame
3313  - with default bit order
3314  - at default bus speed
3315  - for default number of data items
3316 */
3317 void SPI_Data_Bits_24 (void) {
3318
3319   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3320   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3321   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3322   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3323 #if  (SPI_SERVER_USED == 1)
3324   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3325   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 24U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3326 #endif
3327
3328   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);
3329   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);
3330   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);
3331 }
3332
3333 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3334 /**
3335 \brief Function: Function SPI_Data_Bits_25
3336 \details
3337 The function \b SPI_Data_Bits_25 verifies data exchange:
3338  - in Master Mode with default Slave Select mode
3339  - with default clock / frame format
3340  - with <b>25 data bits</b> per frame
3341  - with default bit order
3342  - at default bus speed
3343  - for default number of data items
3344 */
3345 void SPI_Data_Bits_25 (void) {
3346
3347   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3348   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3349   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3350   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3351 #if  (SPI_SERVER_USED == 1)
3352   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3353   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 25U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3354 #endif
3355
3356   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);
3357   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);
3358   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);
3359 }
3360
3361 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3362 /**
3363 \brief Function: Function SPI_Data_Bits_26
3364 \details
3365 The function \b SPI_Data_Bits_26 verifies data exchange:
3366  - in Master Mode with default Slave Select mode
3367  - with default clock / frame format
3368  - with <b>26 data bits</b> per frame
3369  - with default bit order
3370  - at default bus speed
3371  - for default number of data items
3372 */
3373 void SPI_Data_Bits_26 (void) {
3374
3375   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3376   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3377   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3378   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3379 #if  (SPI_SERVER_USED == 1)
3380   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3381   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 26U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3382 #endif
3383
3384   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);
3385   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);
3386   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);
3387 }
3388
3389 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3390 /**
3391 \brief Function: Function SPI_Data_Bits_27
3392 \details
3393 The function \b SPI_Data_Bits_27 verifies data exchange:
3394  - in Master Mode with default Slave Select mode
3395  - with default clock / frame format
3396  - with <b>27 data bits</b> per frame
3397  - with default bit order
3398  - at default bus speed
3399  - for default number of data items
3400 */
3401 void SPI_Data_Bits_27 (void) {
3402
3403   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3404   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3405   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3406   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3407 #if  (SPI_SERVER_USED == 1)
3408   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3409   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 27U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3410 #endif
3411
3412   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);
3413   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);
3414   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);
3415 }
3416
3417 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3418 /**
3419 \brief Function: Function SPI_Data_Bits_28
3420 \details
3421 The function \b SPI_Data_Bits_28 verifies data exchange:
3422  - in Master Mode with default Slave Select mode
3423  - with default clock / frame format
3424  - with <b>28 data bits</b> per frame
3425  - with default bit order
3426  - at default bus speed
3427  - for default number of data items
3428 */
3429 void SPI_Data_Bits_28 (void) {
3430
3431   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3432   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3433   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3434   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3435 #if  (SPI_SERVER_USED == 1)
3436   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3437   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 28U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3438 #endif
3439
3440   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);
3441   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);
3442   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);
3443 }
3444
3445 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3446 /**
3447 \brief Function: Function SPI_Data_Bits_29
3448 \details
3449 The function \b SPI_Data_Bits_29 verifies data exchange:
3450  - in Master Mode with default Slave Select mode
3451  - with default clock / frame format
3452  - with <b>29 data bits</b> per frame
3453  - with default bit order
3454  - at default bus speed
3455  - for default number of data items
3456 */
3457 void SPI_Data_Bits_29 (void) {
3458
3459   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3460   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3461   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3462   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3463 #if  (SPI_SERVER_USED == 1)
3464   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3465   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 29U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3466 #endif
3467
3468   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);
3469   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);
3470   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);
3471 }
3472
3473 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3474 /**
3475 \brief Function: Function SPI_Data_Bits_30
3476 \details
3477 The function \b SPI_Data_Bits_30 verifies data exchange:
3478  - in Master Mode with default Slave Select mode
3479  - with default clock / frame format
3480  - with <b>30 data bits</b> per frame
3481  - with default bit order
3482  - at default bus speed
3483  - for default number of data items
3484 */
3485 void SPI_Data_Bits_30 (void) {
3486
3487   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3488   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3489   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3490   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3491 #if  (SPI_SERVER_USED == 1)
3492   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3493   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 30U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3494 #endif
3495
3496   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);
3497   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);
3498   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);
3499 }
3500
3501 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3502 /**
3503 \brief Function: Function SPI_Data_Bits_31
3504 \details
3505 The function \b SPI_Data_Bits_31 verifies data exchange:
3506  - in Master Mode with default Slave Select mode
3507  - with default clock / frame format
3508  - with <b>31 data bits</b> per frame
3509  - with default bit order
3510  - at default bus speed
3511  - for default number of data items
3512 */
3513 void SPI_Data_Bits_31 (void) {
3514
3515   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3516   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3517   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3518   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3519 #if  (SPI_SERVER_USED == 1)
3520   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3521   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 31U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3522 #endif
3523
3524   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);
3525   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);
3526   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);
3527 }
3528
3529 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3530 /**
3531 \brief Function: Function SPI_Data_Bits_32
3532 \details
3533 The function \b SPI_Data_Bits_32 verifies data exchange:
3534  - in Master Mode with default Slave Select mode
3535  - with default clock / frame format
3536  - with <b>32 data bits</b> per frame
3537  - with default bit order
3538  - at default bus speed
3539  - for default number of data items
3540 */
3541 void SPI_Data_Bits_32 (void) {
3542
3543   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3544   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3545   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3546   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3547 #if  (SPI_SERVER_USED == 1)
3548   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3549   if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 32U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3550 #endif
3551
3552   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);
3553   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);
3554   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);
3555 }
3556
3557 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3558 /**
3559 \brief Function: Function SPI_Bit_Order_MSB_LSB
3560 \details
3561 The function \b SPI_Bit_Order_MSB_LSB verifies data exchange:
3562  - in Master Mode with default Slave Select mode
3563  - with default clock / frame format
3564  - with default data bits
3565  - with bit order <b>from MSB to LSB</b>
3566  - at default bus speed
3567  - for default number of data items
3568
3569 \note In Test Mode <b>Loopback</b> this test is not executed
3570 */
3571 void SPI_Bit_Order_MSB_LSB (void) {
3572
3573   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
3574   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
3575   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3576   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3577 #if  (SPI_SERVER_USED == 1)
3578   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3579   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; }
3580 #endif
3581
3582   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);
3583   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);
3584   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);
3585 }
3586
3587 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3588 /**
3589 \brief Function: Function SPI_Bit_Order_LSB_MSB
3590 \details
3591 The function \b SPI_Bit_Order_LSB_MSB verifies data exchange:
3592  - in Master Mode with default Slave Select mode
3593  - with default clock / frame format
3594  - with default data bits
3595  - with bit order <b>from LSB to MSB</b>
3596  - at default bus speed
3597  - for default number of data items
3598
3599 \note In Test Mode <b>Loopback</b> this test is not executed
3600 */
3601 void SPI_Bit_Order_LSB_MSB (void) {
3602
3603   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
3604   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3605   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3606   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3607   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3608 #if  (SPI_SERVER_USED == 1)
3609   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3610   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; }
3611 #endif
3612
3613   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);
3614   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);
3615   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);
3616 }
3617
3618 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3619 /**
3620 \brief Function: Function SPI_Bus_Speed_Min
3621 \details
3622 The function \b SPI_Bus_Speed_Min verifies data exchange:
3623  - in Master Mode with default Slave Select mode
3624  - with default clock / frame format
3625  - with default data bits
3626  - with default bit order
3627  - at <b>minimum bus speed</b> (define <c>SPI_CFG_MIN_BUS_SPEED</c> in DV_SPI_Config.h)
3628  - for default number of data items
3629
3630 This test function checks the following requirements:
3631  - measured bus speed is not 25% lower, or higher than requested
3632  - bus speed value returned by the driver is not negative
3633  - bus speed value returned by the driver is not higher then requested
3634  - bus speed value returned by the driver is not lower then 75% of requested
3635 */
3636 void SPI_Bus_Speed_Min (void) {
3637   volatile uint64_t bps;
3638   volatile  int32_t ret_bus_speed;
3639
3640   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
3641   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
3642   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3643   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3644 #if  (SPI_SERVER_USED == 1)
3645   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3646   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; }
3647 #endif
3648
3649   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);
3650   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);
3651   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);
3652
3653   if (duration != 0xFFFFFFFFU) {        // If Transfer finished before timeout
3654     if (duration != 0U) {               // If duration of transfer was more than 0 SysTick counts
3655       bps = ((uint64_t)systick_freq * SPI_CFG_DEF_DATA_BITS * SPI_CFG_DEF_NUM) / duration;
3656       if ((bps < ((SPI_CFG_MIN_BUS_SPEED * 3) / 4)) ||
3657           (bps >   SPI_CFG_MIN_BUS_SPEED)) {
3658         // If measured bus speed is 25% lower, or higher than requested
3659         (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);
3660         TEST_MESSAGE(msg_buf);
3661       }
3662     }
3663   }
3664
3665   drv->Control (ARM_SPI_SET_BUS_SPEED, SPI_CFG_MIN_BUS_SPEED);
3666   ret_bus_speed = drv->Control (ARM_SPI_GET_BUS_SPEED, 0U);
3667   if (ret_bus_speed < 0) {
3668     // If bus speed value returned by the driver is negative
3669     (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned negative value %i", ret_bus_speed);
3670     TEST_FAIL_MESSAGE(msg_buf);
3671   } else if ((uint32_t)ret_bus_speed > SPI_CFG_MIN_BUS_SPEED) {
3672     // If bus speed value returned by the driver is higher then requested
3673     (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);
3674     TEST_FAIL_MESSAGE(msg_buf);
3675   } else if ((uint32_t)ret_bus_speed < ((SPI_CFG_MIN_BUS_SPEED * 3) / 4)) {
3676     // If bus speed value returned by the driver is lower then 75% of requested
3677     (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);
3678     TEST_MESSAGE(msg_buf);
3679   }
3680 }
3681
3682 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3683 /**
3684 \brief Function: Function SPI_Bus_Speed_Max
3685 \details
3686 The function \b SPI_Bus_Speed_Max 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>maximum bus speed</b> (define <c>SPI_CFG_MAX_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_Max (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_MAX_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_MAX_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_MAX_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_MAX_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_MAX_BUS_SPEED * 3) / 4)) ||
3721           (bps >   SPI_CFG_MAX_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_MAX_BUS_SPEED, (uint32_t)bps);
3724         TEST_MESSAGE(msg_buf);
3725       }
3726     }
3727   }
3728
3729   drv->Control (ARM_SPI_SET_BUS_SPEED, SPI_CFG_MAX_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_MAX_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_MAX_BUS_SPEED);
3738     TEST_FAIL_MESSAGE(msg_buf);
3739   } else if ((uint32_t)ret_bus_speed < ((SPI_CFG_MAX_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_MAX_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_Number_Of_Items
3749 \details
3750 The function \b SPI_Number_Of_Items 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 default bus speed
3756  - for <b>different number of items</b> (defines <c>SPI_CFG_NUM1 .. SPI_CFG_NUM5</c> in DV_SPI_Config.h)
3757 */
3758 void SPI_Number_Of_Items (void) {
3759
3760   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
3761   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
3762   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3763   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3764 #if  (SPI_SERVER_USED == 1)
3765   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3766   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; }
3767 #endif
3768
3769 #if (SPI_CFG_NUM1 != 0U)
3770   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);
3771   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);
3772   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);
3773 #endif
3774
3775 #if (SPI_CFG_NUM2 != 0U)
3776   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);
3777   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);
3778   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);
3779 #endif
3780
3781 #if (SPI_CFG_NUM3 != 0U)
3782   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);
3783   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);
3784   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);
3785 #endif
3786
3787 #if (SPI_CFG_NUM4 != 0U)
3788   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);
3789   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);
3790   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);
3791 #endif
3792
3793 #if (SPI_CFG_NUM5 != 0U)
3794   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);
3795   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);
3796   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);
3797 #endif
3798 }
3799
3800 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3801 /**
3802 \brief Function: Function SPI_GetDataCount
3803 \details
3804 The function \b SPI_GetDataCount verifies \b GetDataCount function (count changing) during data exchange:
3805  - in Master Mode with default Slave Select mode
3806  - with default clock / frame format
3807  - with default data bits
3808  - with default bit order
3809  - at default bus speed
3810 */
3811 void SPI_GetDataCount (void) {
3812
3813   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
3814   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
3815   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3816   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3817 #if  (SPI_SERVER_USED == 1)
3818   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3819   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; }
3820 #endif
3821
3822   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);
3823   TEST_ASSERT_MESSAGE((data_count_sample != 0U) && (data_count_sample != SPI_CFG_DEF_NUM), "[FAILED] GetDataCount was not changing during the Send!");
3824
3825   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);
3826   TEST_ASSERT_MESSAGE((data_count_sample != 0U) && (data_count_sample != SPI_CFG_DEF_NUM), "[FAILED] GetDataCount was not changing during the Receive!");
3827
3828   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);
3829   TEST_ASSERT_MESSAGE((data_count_sample != 0U) && (data_count_sample != SPI_CFG_DEF_NUM), "[FAILED] GetDataCount was not changing during the Transfer!");
3830 }
3831
3832 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3833 /**
3834 \brief Function: Function SPI_Abort
3835 \details
3836 The function \b SPI_Abort verifies \b Abort function abort of data exchange:
3837  - in Master Mode with default Slave Select mode
3838  - with default clock / frame format
3839  - with default data bits
3840  - with default bit order
3841  - at default bus speed
3842 */
3843 void SPI_Abort (void) {
3844
3845   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
3846   if (IsBitOrderValid() != EXIT_SUCCESS) {              return; }
3847   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3848   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3849 #if  (SPI_SERVER_USED == 1)
3850   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3851   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; }
3852 #endif
3853
3854   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);
3855   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);
3856   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);
3857 }
3858
3859 /**
3860 @}
3861 */
3862 // End of spi_tests_data_xchg
3863
3864 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3865 /* SPI Event tests                                                                                                          */
3866 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3867 /**
3868 \defgroup spi_tests_evt Event
3869 \ingroup spi_tests
3870 \details
3871 These tests verify API and operation of the SPI event signaling, except ARM_SPI_EVENT_TRANSFER_COMPLETE
3872 signal which is tested in the Data Exchange tests.
3873
3874 The event tests verify the following driver function
3875 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
3876  - \b SignalEvent
3877 \code
3878   void (*ARM_SPI_SignalEvent_t) (uint32_t event);
3879 \endcode
3880
3881 \note In Test Mode <b>Loopback</b> these tests are not executed
3882 @{
3883 */
3884
3885 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3886 /**
3887 \brief Function: Function SPI_DataLost
3888 \details
3889 The function \b SPI_DataLost verifies signaling of the <b>ARM_SPI_EVENT_DATA_LOST</b> event:
3890  - in <b>Slave Mode</b> with <b>Slave Select line Hardware monitored</b>
3891  - with default clock / frame format
3892  - with default data bits
3893  - with default bit order
3894  - at default bus speed
3895
3896 it also checks that status data_lost flag was activated.
3897 */
3898 void SPI_DataLost (void) {
3899
3900   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
3901   if (IsFormatValid()   != EXIT_SUCCESS) {              return; }
3902   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3903   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3904 #if  (SPI_SERVER_USED == 1)
3905   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3906   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; }
3907
3908   do {
3909     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; }
3910     if (CmdXfer    (1U, 8U, 8U, SPI_CFG_XFER_TIMEOUT) != EXIT_SUCCESS) { break; }
3911     drv->Control   (ARM_SPI_MODE_INACTIVE, 0U);
3912
3913     event = 0U;
3914     (void)osDelay(4U);
3915     (void)drv->Control (ARM_SPI_MODE_SLAVE                                                                 | 
3916                       ((SPI_CFG_DEF_FORMAT    << ARM_SPI_FRAME_FORMAT_Pos)   & ARM_SPI_FRAME_FORMAT_Msk)   | 
3917                       ((SPI_CFG_DEF_DATA_BITS << ARM_SPI_DATA_BITS_Pos)      & ARM_SPI_DATA_BITS_Msk)      | 
3918                       ((SPI_CFG_DEF_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos)      & ARM_SPI_BIT_ORDER_Msk)      | 
3919                         ARM_SPI_SS_SLAVE_HW                                                                , 
3920                         0U);
3921
3922     (void)osDelay(SPI_CFG_XFER_TIMEOUT+20U);    // Wait for SPI Server to timeout
3923
3924     (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
3925     (void)osDelay(20U);                 // Wait for SPI Server to start reception of next command
3926
3927     // Assert that event ARM_SPI_EVENT_DATA_LOST was signaled
3928     TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_DATA_LOST) != 0U, "[FAILED] Event ARM_SPI_EVENT_DATA_LOST was not signaled!");
3929
3930     // Assert that status data_lost flag is active
3931     TEST_ASSERT_MESSAGE(drv->GetStatus().data_lost != 0U, "[FAILED] Status data_lost flag was not activated!");
3932
3933     return;
3934   } while (false);
3935 #endif
3936 }
3937
3938 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3939 /**
3940 \brief Function: Function SPI_ModeFault
3941 \details
3942 The function \b SPI_ModeFault verifies signaling of the <b>ARM_SPI_EVENT_MODE_FAULT</b> event:
3943  - in <b>Master Mode</b> with <b>Slave Select line Hardware monitored Input</b>
3944  - with default clock / frame format
3945  - with default data bits
3946  - with default bit order
3947  - at default bus speed
3948
3949 it also checks that status mode_fault flag was activated.
3950 */
3951 void SPI_ModeFault (void) {
3952
3953   if (IsNotLoopback()   != EXIT_SUCCESS) {              return; }
3954   if (IsNotFrameTI()    != EXIT_SUCCESS) {              return; }
3955   if (IsNotFrameMw()    != EXIT_SUCCESS) {              return; }
3956   if (DriverInit()      != EXIT_SUCCESS) { TEST_FAIL(); return; }
3957   if (BuffersCheck()    != EXIT_SUCCESS) { TEST_FAIL(); return; }
3958 #if  (SPI_SERVER_USED == 1)
3959   if (ServerCheck()     != EXIT_SUCCESS) { TEST_FAIL(); return; }
3960   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; }
3961
3962   do {
3963     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; }
3964     if (CmdXfer    (1U, 8U, 8U, SPI_CFG_XFER_TIMEOUT) != EXIT_SUCCESS) { break; }
3965     drv->Control   (ARM_SPI_MODE_INACTIVE, 0U);
3966
3967     event = 0U;
3968     (void)osDelay(4U);
3969     (void)drv->Control (ARM_SPI_MODE_MASTER                                                              | 
3970                       ((SPI_CFG_DEF_FORMAT    << ARM_SPI_FRAME_FORMAT_Pos)   & ARM_SPI_FRAME_FORMAT_Msk) | 
3971                       ((SPI_CFG_DEF_DATA_BITS << ARM_SPI_DATA_BITS_Pos)      & ARM_SPI_DATA_BITS_Msk)    | 
3972                       ((SPI_CFG_DEF_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos)      & ARM_SPI_BIT_ORDER_Msk)    | 
3973                         ARM_SPI_SS_MASTER_HW_INPUT                                                       , 
3974                         SPI_CFG_DEF_BUS_SPEED);
3975
3976     (void)osDelay(SPI_CFG_XFER_TIMEOUT+20U);    // Wait for SPI Server to timeout
3977
3978     (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
3979     (void)osDelay(20U);                 // Wait for SPI Server to start reception of next command
3980
3981     // Assert that event ARM_SPI_EVENT_MODE_FAULT was signaled
3982     TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_MODE_FAULT) != 0U, "[FAILED] Event ARM_SPI_EVENT_MODE_FAULT was not signaled!");
3983
3984     // Assert that status mode_fault flag is active
3985     TEST_ASSERT_MESSAGE(drv->GetStatus().mode_fault != 0U, "[FAILED] Status mode_fault flag was not activated!");
3986
3987     return;
3988   } while (false);
3989 #endif
3990 }
3991
3992 /**
3993 @}
3994 */
3995 // End of spi_tests_evt