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