2 * Copyright (c) 2015-2022 Arm Limited. All rights reserved.
4 * SPDX-License-Identifier: Apache-2.0
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
10 * www.apache.org/licenses/LICENSE-2.0
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.
18 * -----------------------------------------------------------------------------
20 * Project: CMSIS-Driver Validation
21 * Title: Serial Peripheral Interface Bus (SPI) Driver Validation tests
23 * -----------------------------------------------------------------------------
26 #ifndef __DOXYGEN__ // Exclude form the documentation
33 #include "DV_SPI_Config.h"
34 #include "DV_Framework.h"
36 #include "Driver_SPI.h"
38 // Fixed settings for communication with SPI Server (not available through DV_SPI_Config.h)
39 #define SPI_CFG_SRV_FORMAT 0 // Clock Polarity 0 / Clock Phase 0
40 #define SPI_CFG_SRV_DATA_BITS 8 // 8 data bits
41 #define SPI_CFG_SRV_BIT_ORDER 0 // MSB to LSB bit order
43 #define CMD_LEN 32UL // Length of command to SPI Server
44 #define RESP_GET_VER_LEN 16UL // Length of response from SPI Server to GET VER command
45 #define RESP_GET_CAP_LEN 32UL // Length of response from SPI Server to GET CAP command
46 #define RESP_GET_CNT_LEN 16UL // Length of response from SPI Server to GET CNT command
48 #define OP_SEND 0UL // Send operation
49 #define OP_RECEIVE 1UL // Receive operation
50 #define OP_TRANSFER 2UL // Transfer operation
51 #define OP_ABORT_SEND 3UL // Abort send operation
52 #define OP_ABORT_RECEIVE 4UL // Abort receive operation
53 #define OP_ABORT_TRANSFER 5UL // Abort transfer operation
55 #define MODE_INACTIVE 0UL // Inactive mode
56 #define MODE_MASTER 1UL // Master mode
57 #define MODE_SLAVE 2UL // Slave mode
58 #define SS_MODE_MASTER_UNUSED 0UL // Master mode Slave Select unused
59 #define SS_MODE_MASTER_SW 1UL // Master mode Slave Select Software controlled
60 #define SS_MODE_MASTER_HW_OUTPUT 2UL // Master mode Slave Select Hardware controlled Output
61 #define SS_MODE_MASTER_HW_INPUT 3UL // Master mode Slave Select Hardware monitored Input
62 #define SS_MODE_SLAVE_HW 0UL // Slave mode Slave Select Hardware monitored
63 #define SS_MODE_SLAVE_SW 1UL // Slave mode Slave Select Software controlled
64 #define FORMAT_CPOL0_CPHA0 0UL // Clock Format: Polarity 0, Phase 0
65 #define FORMAT_CPOL0_CPHA1 1UL // Clock Format: Polarity 0, Phase 1
66 #define FORMAT_CPOL1_CPHA0 2UL // Clock Format: Polarity 1, Phase 0
67 #define FORMAT_CPOL1_CPHA1 3UL // Clock Format: Polarity 1, Phase 1
68 #define FORMAT_TI 4UL // Frame Format: Texas Instruments
69 #define FORMAT_MICROWIRE 5UL // Frame Format: National Semiconductor Microwire
70 #define BO_MSB_TO_LSB 0UL // Bit Order MSB to LSB
71 #define BO_LSB_TO_MSB 1UL // Bit Order LSB to MSB
73 // Testing Configuration definitions
74 #if (SPI_CFG_TEST_MODE != 0)
75 #define SPI_SERVER_USED 1
77 #define SPI_SERVER_USED 0
80 // Determine maximum number of items used for testing
81 #if (SPI_CFG_DEF_NUM == 0)
82 #error Default number of items must not be 0!
85 #define SPI_NUM_MAX SPI_CFG_DEF_NUM
86 #if (SPI_CFG_NUM1 > SPI_NUM_MAX)
88 #define SPI_NUM_MAX SPI_CFG_NUM1
90 #if (SPI_CFG_NUM2 > SPI_NUM_MAX)
92 #define SPI_NUM_MAX SPI_CFG_NUM2
94 #if (SPI_CFG_NUM3 > SPI_NUM_MAX)
96 #define SPI_NUM_MAX SPI_CFG_NUM3
98 #if (SPI_CFG_NUM4 > SPI_NUM_MAX)
100 #define SPI_NUM_MAX SPI_CFG_NUM4
102 #if (SPI_CFG_NUM5 > SPI_NUM_MAX)
104 #define SPI_NUM_MAX SPI_CFG_NUM5
107 // Calculate maximum required buffer size
108 #if ((SPI_CFG_DEF_DATA_BITS > 16) || ((SPI_TC_DATA_BIT_EN_MASK & 0xFFFF0000UL) != 0U))
109 #define SPI_BUF_MAX (SPI_NUM_MAX * 4U)
110 #elif ((SPI_CFG_DEF_DATA_BITS > 8) || ((SPI_TC_DATA_BIT_EN_MASK & 0x0000FF00UL) != 0U))
111 #define SPI_BUF_MAX (SPI_NUM_MAX * 2U)
113 #define SPI_BUF_MAX (SPI_NUM_MAX)
115 #if (SPI_SERVER_USED == 1)
116 // If selected Test Mode is SPI Server take into account SPI Server data bit settings
117 #if ((SPI_CFG_SRV_DATA_BITS > 16) && (SPI_BUF_MAX < (SPI_NUM_MAX * 4U)))
119 #define SPI_BUF_MAX (SPI_NUM_MAX * 4U)
120 #elif ((SPI_CFG_SRV_DATA_BITS > 8) && (SPI_BUF_MAX < (SPI_NUM_MAX * 2U)))
122 #define SPI_BUF_MAX (SPI_NUM_MAX * 2U)
126 typedef struct { // SPI Server version structure
127 uint8_t major; // Version major number
128 uint8_t minor; // Version minor number
129 uint16_t patch; // Version patch (revision) number
132 typedef struct { // SPI Server capabilities structure
133 uint32_t mode_mask; // Mode and Slave Select mask
134 uint32_t fmt_mask; // Clock Format or Frame Format mask
135 uint32_t db_mask; // Data Bits mask
136 uint32_t bo_mask; // Bit Order mask
137 uint32_t bs_min; // Min bus speed
138 uint32_t bs_max; // Max bus speed
141 // Register Driver_SPI#
142 #define _ARM_Driver_SPI_(n) Driver_SPI##n
143 #define ARM_Driver_SPI_(n) _ARM_Driver_SPI_(n)
144 extern ARM_DRIVER_SPI ARM_Driver_SPI_(DRV_SPI);
145 static ARM_DRIVER_SPI *drv = &ARM_Driver_SPI_(DRV_SPI);
147 // Global variables (used in this module only)
148 static int8_t buffers_ok;
149 static int8_t driver_ok;
150 static int8_t server_ok;
152 static SPI_SERV_VER_t spi_serv_ver;
153 static SPI_SERV_CAP_t spi_serv_cap;
155 static volatile uint32_t event;
156 static volatile uint32_t duration;
157 static volatile uint32_t xfer_count;
158 static volatile uint32_t data_count_sample;
159 static uint32_t systick_freq;
161 static osEventFlagsId_t event_flags;
163 static char msg_buf[256];
165 // Allocated buffer pointers
166 static void *ptr_tx_buf_alloc;
167 static void *ptr_rx_buf_alloc;
168 static void *ptr_cmp_buf_alloc;
170 // Buffer pointers used for data transfers (must be aligned to 4 byte)
171 static uint8_t *ptr_tx_buf;
172 static uint8_t *ptr_rx_buf;
173 static uint8_t *ptr_cmp_buf;
175 // String representation of various codes
176 static const char *str_srv_status[] = {
181 static const char *str_test_mode[] = {
186 static const char *str_oper[] = {
195 static const char *str_ss_mode[] = {
197 "Software controlled",
198 "Hardware controlled"
201 static const char *str_mode[] = {
206 static const char *str_format[] = {
207 "Clock Polarity 0, Clock Phase 0",
208 "Clock Polarity 0, Clock Phase 1",
209 "Clock Polarity 1, Clock Phase 0",
210 "Clock Polarity 1, Clock Phase 1",
212 "National Semiconductor Microwire"
215 static const char *str_bit_order[] = {
220 static const char *str_ret[] = {
223 "ARM_DRIVER_ERROR_BUSY",
224 "ARM_DRIVER_ERROR_TIMEOUT",
225 "ARM_DRIVER_ERROR_UNSUPPORTED",
226 "ARM_DRIVER_ERROR_PARAMETER",
227 "ARM_DRIVER_ERROR_SPECIFIC",
228 "ARM_SPI_ERROR_MODE",
229 "ARM_SPI_ERROR_FRAME_FORMAT",
230 "ARM_SPI_ERROR_DATA_BITS",
231 "ARM_SPI_ERROR_BIT_ORDER",
232 "ARM_SPI_ERROR_SS_MODE"
236 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
237 static int32_t ComConfigDefault (void);
238 static int32_t ComSendCommand (const void *data_out, uint32_t len);
239 static int32_t ComReceiveResponse ( void *data_in, uint32_t len);
241 static int32_t CmdGetVer (void);
242 static int32_t CmdGetCap (void);
243 static int32_t CmdSetBufTx (char pattern);
244 static int32_t CmdSetBufRx (char pattern);
245 static int32_t CmdGetBufRx (uint32_t len);
246 static int32_t CmdSetCom (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed);
247 static int32_t CmdXfer (uint32_t num, uint32_t delay_c, uint32_t delay_t, uint32_t timeout);
248 static int32_t CmdGetCnt (void);
250 static int32_t ServerInit (void);
251 static int32_t ServerCheck (void);
252 static int32_t ServerCheckSupport (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t bus_speed);
255 static int32_t IsNotLoopback (void);
256 static int32_t IsNotFrameTI (void);
257 static int32_t IsNotFrameMw (void);
258 static int32_t IsFormatValid (void);
259 static int32_t IsBitOrderValid (void);
261 static uint32_t DataBitsToBytes (uint32_t data_bits);
262 static int32_t DriverInit (void);
263 static int32_t BuffersCheck (void);
265 static void SPI_DataExchange_Operation (uint32_t operation, uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed, uint32_t num);
270 \fn void SPI_DrvEvent (uint32_t evt)
271 \brief Store event(s) into a global variable.
272 \detail This is a callback function called by the driver upon an event(s).
273 \param[in] evt SPI event
276 static void SPI_DrvEvent (uint32_t evt) {
279 (void)osEventFlagsSet(event_flags, evt);
283 \fn static uint32_t DataBitsToBytes (uint32_t data_bits)
284 \brief Calculate number of bytes used for an item at required data bits.
285 \return number of bytes per item
287 static uint32_t DataBitsToBytes (uint32_t data_bits) {
291 if (data_bits > 16U) {
293 } else if (data_bits > 8U) {
301 \fn static int32_t DriverInit (void)
302 \brief Initialize and power-on the driver.
303 \return execution status
304 - EXIT_SUCCESS: Driver initialized and powered-up successfully
305 - EXIT_FAILURE: Driver initialization or power-up failed
307 static int32_t DriverInit (void) {
309 if (drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK) {
310 if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
315 TEST_FAIL_MESSAGE("[FAILED] SPI driver initialize or power-up. Check driver Initialize and PowerControl functions! Test aborted!");
321 \fn static int32_t BuffersCheck (void)
322 \brief Check if buffers are valid.
323 \return execution status
324 - EXIT_SUCCESS: Buffers are valid
325 - EXIT_FAILURE: Buffers are not valid
327 static int32_t BuffersCheck (void) {
329 if ((ptr_tx_buf != NULL) &&
330 (ptr_rx_buf != NULL) &&
331 (ptr_cmp_buf != NULL)) {
335 TEST_FAIL_MESSAGE("[FAILED] Invalid data buffers! Increase heap memory! Test aborted!");
340 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
343 \fn static int32_t ComConfigDefault (void)
344 \brief Configure SPI Communication Interface to SPI Server default communication configuration.
345 \return execution status
346 - EXIT_SUCCESS: Default configuration set successfully
347 - EXIT_FAILURE: Default configuration failed
349 static int32_t ComConfigDefault (void) {
354 if (drv->Control(ARM_SPI_MODE_MASTER |
355 ((SPI_CFG_SRV_FORMAT << ARM_SPI_FRAME_FORMAT_Pos) & ARM_SPI_FRAME_FORMAT_Msk) |
356 ((SPI_CFG_SRV_DATA_BITS << ARM_SPI_DATA_BITS_Pos) & ARM_SPI_DATA_BITS_Msk) |
357 ((SPI_CFG_SRV_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos) & ARM_SPI_BIT_ORDER_Msk) |
358 ((SPI_CFG_SRV_SS_MODE << ARM_SPI_SS_MASTER_MODE_Pos) & ARM_SPI_SS_MASTER_MODE_Msk) ,
359 SPI_CFG_SRV_BUS_SPEED) != ARM_DRIVER_OK) {
363 if ((ret == EXIT_SUCCESS) && (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW)) {
364 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
369 if (ret != EXIT_SUCCESS) {
370 TEST_FAIL_MESSAGE("[FAILED] Configure communication interface to SPI Server default settings. Check driver Control function! Test aborted!");
377 \fn static int32_t ComSendCommand (const void *data_out, uint32_t num)
378 \brief Send command to SPI Server.
379 \param[out] data_out Pointer to memory containing data to be sent
380 \param[in] len Number of bytes to be sent
381 \return execution status
382 - EXIT_SUCCESS: Command sent successfully
383 - EXIT_FAILURE: Command send failed
385 static int32_t ComSendCommand (const void *data_out, uint32_t len) {
387 uint32_t flags, num, tout;
390 num = (len + DataBitsToBytes(SPI_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(SPI_CFG_SRV_DATA_BITS);
392 ret = ComConfigDefault();
394 if (ret == EXIT_SUCCESS) {
395 if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
396 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE) != ARM_DRIVER_OK) {
400 if (ret == EXIT_SUCCESS) {
401 (void)osEventFlagsClear(event_flags, 0x7FFFFFFFU);
402 if (drv->Send(data_out, num) == ARM_DRIVER_OK) {
403 flags = osEventFlagsWait(event_flags, ARM_SPI_EVENT_TRANSFER_COMPLETE, osFlagsWaitAny, SPI_CFG_SRV_CMD_TOUT);
404 if (((flags & 0x80000000U) != 0U) ||
405 ((flags & ARM_SPI_EVENT_TRANSFER_COMPLETE) == 0U)) {
407 (void)drv->Control (ARM_SPI_ABORT_TRANSFER, 0U);
411 if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
412 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
417 (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
423 \fn static int32_t ComReceiveResponse (void *data_in, uint32_t num)
424 \brief Receive response from SPI Server.
425 \param[out] data_in Pointer to memory where data will be received
426 \param[in] len Number of data bytes to be received
427 \return execution status
428 - EXIT_SUCCESS: Command received successfully
429 - EXIT_FAILURE: Command reception failed
431 static int32_t ComReceiveResponse (void *data_in, uint32_t len) {
433 uint32_t flags, num, tout;
436 num = (len + DataBitsToBytes(SPI_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(SPI_CFG_SRV_DATA_BITS);
438 ret = ComConfigDefault();
440 if (ret == EXIT_SUCCESS) {
441 if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
442 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE) != ARM_DRIVER_OK) {
446 if (ret == EXIT_SUCCESS) {
447 (void)osEventFlagsClear(event_flags, 0x7FFFFFFFU);
448 if (drv->Receive(data_in, num) == ARM_DRIVER_OK) {
449 flags = osEventFlagsWait(event_flags, ARM_SPI_EVENT_TRANSFER_COMPLETE, osFlagsWaitAny, SPI_CFG_SRV_CMD_TOUT);
450 if (((flags & 0x80000000U) != 0U) ||
451 ((flags & ARM_SPI_EVENT_TRANSFER_COMPLETE) == 0U)) {
453 (void)drv->Control (ARM_SPI_ABORT_TRANSFER, 0U);
457 if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
458 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
463 (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
469 \fn static int32_t CmdGetVer (void)
470 \brief Get version from SPI Server and check that it is valid.
471 \return execution status
472 - EXIT_SUCCESS: Version retrieved successfully
473 - EXIT_FAILURE: Version retreival failed
475 static int32_t CmdGetVer (void) {
483 memset(&spi_serv_ver, 0, sizeof(spi_serv_ver));
485 // Send "GET VER" command to SPI Server
486 memset(ptr_tx_buf, 0, CMD_LEN);
487 memcpy(ptr_tx_buf, "GET VER", 7);
488 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
491 if (ret == EXIT_SUCCESS) {
492 // Receive response to "GET VER" command from SPI Server
493 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_VER_LEN);
494 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_VER_LEN);
499 if (ret == EXIT_SUCCESS) {
501 ptr_str = (const char *)ptr_rx_buf;
502 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
503 spi_serv_ver.major = val8;
508 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
510 ptr_str = strstr(ptr_str, "."); // Find '.'
511 if (ptr_str != NULL) {
512 ptr_str++; // Skip '.'
513 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
514 spi_serv_ver.minor = val8;
522 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
523 // Parse patch (revision)
524 ptr_str = strstr(ptr_str, "."); // Find next '.'
525 if (ptr_str != NULL) {
526 ptr_str++; // Skip '.'
527 if (sscanf(ptr_str, "%hx", &val16) == 1) {
528 spi_serv_ver.patch = val16;
541 \fn static int32_t CmdGetCap (void)
542 \brief Get capabilities from SPI Server.
543 \return execution status
544 - EXIT_SUCCESS: Capabilities retrieved successfully
545 - EXIT_FAILURE: Capabilities retreival failed
547 static int32_t CmdGetCap (void) {
555 memset(&spi_serv_cap, 0, sizeof(spi_serv_cap));
557 // Send "GET CAP" command to SPI Server
558 memset(ptr_tx_buf, 0, CMD_LEN);
559 memcpy(ptr_tx_buf, "GET CAP", 7);
560 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
563 if (ret == EXIT_SUCCESS) {
564 (void)osDelay(20U); // Give SPI Server 20 ms to auto-detect capabilities
566 // Receive response to "GET CAP" command from SPI Server
567 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_CAP_LEN);
568 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_CAP_LEN);
572 // Parse capabilities
573 if (ret == EXIT_SUCCESS) {
575 ptr_str = (const char *)ptr_rx_buf;
576 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
577 spi_serv_cap.mode_mask = val8;
582 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
584 ptr_str = strstr(ptr_str, ","); // Find ','
585 if (ptr_str != NULL) {
586 ptr_str++; // Skip ','
587 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
588 spi_serv_cap.fmt_mask = (uint32_t)val8;
596 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
597 // Parse data bit mask
598 ptr_str = strstr(ptr_str, ","); // Find next ','
599 if (ptr_str != NULL) {
600 ptr_str++; // Skip ','
601 if (sscanf(ptr_str, "%x", &val32) == 1) {
602 spi_serv_cap.db_mask = val32;
610 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
611 // Parse bit order mask
612 ptr_str = strstr(ptr_str, ","); // Find next ','
613 if (ptr_str != NULL) {
614 ptr_str++; // Skip ','
615 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
616 spi_serv_cap.bo_mask = (uint32_t)val8;
624 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
625 // Parse minimum bus speed
626 ptr_str = strstr(ptr_str, ","); // Find next ','
627 if (ptr_str != NULL) {
628 ptr_str++; // Skip ','
629 if (sscanf(ptr_str, "%u", &val32) == 1) {
630 spi_serv_cap.bs_min = val32 * 1000U;
638 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
639 // Parse maximum bus speed
640 ptr_str = strstr(ptr_str, ","); // Find next ','
641 if (ptr_str != NULL) {
642 ptr_str++; // Skip ','
643 if (sscanf(ptr_str, "%u", &val32) == 1) {
644 spi_serv_cap.bs_max = val32 * 1000U;
657 \fn static int32_t CmdSetBufTx (char pattern)
658 \brief Set Tx buffer of SPI Server to pattern.
659 \param[in] pattern Pattern to fill the buffer with
660 \return execution status
661 - EXIT_SUCCESS: Command sent successfully
662 - EXIT_FAILURE: Command send failed
664 static int32_t CmdSetBufTx (char pattern) {
667 // Send "SET BUF TX" command to SPI Server
668 memset(ptr_tx_buf, 0, CMD_LEN);
669 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF TX,0,%02X", (int32_t)pattern);
670 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
673 if (ret != EXIT_SUCCESS) {
674 TEST_FAIL_MESSAGE("[FAILED] Set Tx buffer on SPI Server. Check SPI Server! Test aborted!");
681 \fn static int32_t CmdSetBufRx (char pattern)
682 \brief Set Rx buffer of SPI Server to pattern.
683 \param[in] pattern Pattern to fill the buffer with
684 \return execution status
685 - EXIT_SUCCESS: Command sent successfully
686 - EXIT_FAILURE: Command send failed
688 static int32_t CmdSetBufRx (char pattern) {
691 // Send "SET BUF RX" command to SPI Server
692 memset(ptr_tx_buf, 0, CMD_LEN);
693 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF RX,0,%02X", (int32_t)pattern);
694 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
697 if (ret != EXIT_SUCCESS) {
698 TEST_FAIL_MESSAGE("[FAILED] Set Rx buffer on SPI Server. Check SPI Server! Test aborted!");
705 \fn static int32_t CmdGetBufRx (uint32_t len)
706 \brief Get Rx buffer from SPI Server (into global array pointed to by ptr_rx_buf).
707 \param[in] len Number of bytes to read from Rx buffer
708 \return execution status
709 - EXIT_SUCCESS: Command sent and response received successfully
710 - EXIT_FAILURE: Command send or response reception failed
712 static int32_t CmdGetBufRx (uint32_t len) {
715 // Send "GET BUF RX" command to SPI Server
716 memset(ptr_tx_buf, 0, CMD_LEN);
717 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "GET BUF RX,%i", len);
718 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
721 if (ret == EXIT_SUCCESS) {
722 // Receive response to "GET BUF RX" command from SPI Server
723 memset(ptr_rx_buf, (int32_t)'?', len);
724 ret = ComReceiveResponse(ptr_rx_buf, len);
728 if (ret != EXIT_SUCCESS) {
729 TEST_FAIL_MESSAGE("[FAILED] Get Rx buffer from SPI Server. Check SPI Server! Test aborted!");
736 \fn static int32_t CmdSetCom (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed)
737 \brief Set communication parameters on SPI Server for next XFER command.
738 \param[in] mode mode (0 = Master, 1 = slave)
739 \param[in] format clock / frame format:
740 - value 0 = clock polarity 0, phase 0
741 - value 1 = clock polarity 0, phase 1
742 - value 2 = clock polarity 1, phase 0
743 - value 3 = clock polarity 1, phase 1
744 - value 4 = Texas Instruments frame format
745 - value 5 = Microwire frame format
746 \param[in] data_bits data bits
748 \param[in] bit_order bit order
749 - value 0 = MSB to LSB
750 - value 1 = LSB to MSB
751 \param[in] ss_mode Slave Select mode:
753 - value 1 = used (in Master mode driven, in Slave mode monitored as hw input)
754 \param[in] bus_speed bus speed in bits per second (bps)
755 \return execution status
756 - EXIT_SUCCESS: Command sent successfully
757 - EXIT_FAILURE: Command send failed
759 static int32_t CmdSetCom (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed) {
762 // Send "SET COM" command to SPI Server
763 memset(ptr_tx_buf, 0, CMD_LEN);
764 stat = snprintf((char *)ptr_tx_buf, CMD_LEN, "SET COM %i,%i,%i,%i,%i,%i", mode, format, data_bits, bit_order, ss_mode, bus_speed);
765 if ((stat > 0) && (stat < CMD_LEN)) {
766 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
772 if (ret != EXIT_SUCCESS) {
773 TEST_FAIL_MESSAGE("[FAILED] Set communication settings on SPI Server. Check SPI Server! Test aborted!");
780 \fn static int32_t CmdXfer (uint32_t num, uint32_t delay_c, uint32_t delay_t, uint32_t timeout)
781 \brief Activate transfer on SPI Server.
782 \param[in] num number of items (according CMSIS SPI driver specification)
783 \param[in] delay_c delay before control function is called, in milliseconds
784 (0xFFFFFFFF = delay not used)
785 \param[in] delay_t delay after control function is called but before transfer function is called, in milliseconds
786 (0xFFFFFFFF = delay not used)
787 \param[in] timeout timeout in milliseconds, after delay, if delay is specified
788 \return execution status
789 - EXIT_SUCCESS: Command sent successfully
790 - EXIT_FAILURE: Command send failed
792 static int32_t CmdXfer (uint32_t num, uint32_t delay_c, uint32_t delay_t, uint32_t timeout) {
795 // Send "XFER" command to SPI Server
796 memset(ptr_tx_buf, 0, CMD_LEN);
797 if ((delay_c != osWaitForever) && (delay_t != osWaitForever) && (timeout != 0U)) {
798 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i,%i", num, delay_c, delay_t, timeout);
799 } else if ((delay_c != osWaitForever) && (delay_t != osWaitForever)) {
800 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i", num, delay_c, delay_t);
801 } else if (delay_c != osWaitForever) {
802 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i", num, delay_c);
804 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i", num);
806 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
808 if (ret != EXIT_SUCCESS) {
809 TEST_FAIL_MESSAGE("[FAILED] Activate transfer on SPI Server. Check SPI Server! Test aborted!");
816 \fn static int32_t CmdGetCnt (void)
817 \brief Get XFER command Tx/Rx count from SPI Server.
818 \return execution status
819 - EXIT_SUCCESS: Operation successful
820 - EXIT_FAILURE: Operation failed
822 static int32_t CmdGetCnt (void) {
829 // Send "GET CNT" command to SPI Server
830 memset(ptr_tx_buf, 0, CMD_LEN);
831 memcpy(ptr_tx_buf, "GET CNT", 7);
832 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
835 if (ret == EXIT_SUCCESS) {
836 // Receive response to "GET CNT" command from SPI Server
837 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_CNT_LEN);
838 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_CNT_LEN);
842 if (ret == EXIT_SUCCESS) {
844 ptr_str = (const char *)ptr_rx_buf;
845 if (sscanf(ptr_str, "%i", &val32) == 1) {
852 if (ret != EXIT_SUCCESS) {
853 TEST_FAIL_MESSAGE("[FAILED] Get count from SPI Server. Check SPI Server! Test aborted!");
860 \fn static int32_t ServerInit (void)
861 \brief Initialize communication with SPI Server, get version and capabilities.
862 \return execution status
863 - EXIT_SUCCESS: SPI Server initialized successfully
864 - EXIT_FAILURE: SPI Server initialization failed
866 static int32_t ServerInit (void) {
868 if (server_ok == -1) { // If -1, means it was not yet checked
871 if (drv->Control(ARM_SPI_MODE_MASTER |
872 ((SPI_CFG_SRV_FORMAT << ARM_SPI_FRAME_FORMAT_Pos) & ARM_SPI_FRAME_FORMAT_Msk) |
873 ((SPI_CFG_SRV_DATA_BITS << ARM_SPI_DATA_BITS_Pos) & ARM_SPI_DATA_BITS_Msk) |
874 ((SPI_CFG_SRV_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos) & ARM_SPI_BIT_ORDER_Msk) |
875 ((SPI_CFG_SRV_SS_MODE << ARM_SPI_SS_MASTER_MODE_Pos) & ARM_SPI_SS_MASTER_MODE_Msk) ,
876 SPI_CFG_SRV_BUS_SPEED) != ARM_DRIVER_OK) {
879 if ((server_ok == 1) && (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW)) {
880 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
884 if (server_ok == 0) {
885 TEST_GROUP_INFO("Failed to configure communication interface to SPI Server default settings.\n"\
886 "Driver must support basic settings used for communication with SPI Server!");
889 if (server_ok == 1) {
891 if (CmdGetVer() != EXIT_SUCCESS) {
892 TEST_GROUP_INFO("Failed to Get version from SPI Server.\nCheck SPI Server!\n");
897 if (server_ok == 1) {
898 if ((spi_serv_ver.major <= 1U) && (spi_serv_ver.minor < 1U)) {
899 TEST_GROUP_INFO("SPI Server version must be 1.1.0. or higher.\nUpdate SPI Server to newer version!\n");
904 if (server_ok == 1) {
905 if (CmdGetCap() != EXIT_SUCCESS) {
906 TEST_GROUP_INFO("Failed to Get capabilities from SPI Server.\nCheck SPI Server!\n");
912 if (server_ok == 1) {
920 \fn static int32_t ServerCheck (void)
921 \brief Check if communication with SPI Server is working.
922 \return execution status
923 - EXIT_SUCCESS: If SPI Server status is ok
924 - EXIT_FAILURE: If SPI Server status is fail
926 static int32_t ServerCheck (void) {
928 if (server_ok == 1) {
932 TEST_FAIL_MESSAGE("[FAILED] SPI Server status. Check SPI Server! Test aborted!");
937 \fn static int32_t ServerCheckSupport (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t bus_speed)
938 \brief Check if SPI Server supports desired settings.
939 \param[in] mode mode (0 = Master, 1 = slave)
940 \param[in] format clock / frame format:
941 - value 0 = clock polarity 0, phase 0
942 - value 1 = clock polarity 0, phase 1
943 - value 2 = clock polarity 1, phase 0
944 - value 3 = clock polarity 1, phase 1
945 - value 4 = Texas Instruments frame format
946 - value 5 = Microwire frame format
947 \param[in] data_bits data bits
949 \param[in] bit_order bit order
950 - value 0 = MSB to LSB
951 - value 1 = LSB to MSB
952 \param[in] bus_speed bus speed in bits per second (bps)
953 \return execution status
954 - EXIT_SUCCESS: SPI Server supports desired settings
955 - EXIT_FAILURE: SPI Server does not support desired settings
957 static int32_t ServerCheckSupport (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t bus_speed) {
959 if ((spi_serv_cap.mode_mask & (1UL << (mode - 1U))) == 0U) {
960 // If SPI Server does not support desired mode
961 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] SPI Server does not support %s mode! Test aborted!", str_mode[mode - 1U]);
962 TEST_MESSAGE(msg_buf);
965 if ((spi_serv_cap.fmt_mask & (1UL << format)) == 0U) {
966 // If SPI Server does not support desired clock / frame format
967 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] SPI Server does not support %s clock / frame format! Test aborted!", str_format[format]);
968 TEST_MESSAGE(msg_buf);
971 if ((spi_serv_cap.db_mask & (1UL << (data_bits - 1U))) == 0U) {
972 // If SPI Server does not support desired data bits
973 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] SPI Server does not support %i data bits! Test aborted!", data_bits);
974 TEST_MESSAGE(msg_buf);
977 if ((spi_serv_cap.bo_mask & (1UL << bit_order)) == 0U) {
978 // If SPI Server does not support desired bit order
979 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] SPI Server does not support %s bit order! Test aborted!", str_bit_order[bit_order]);
980 TEST_MESSAGE(msg_buf);
983 if ((spi_serv_cap.bs_min > bus_speed) ||
984 (spi_serv_cap.bs_max < bus_speed)) {
985 // If SPI Server does not support desired bus speed
986 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] SPI Server does not support %i bps bus speed! Test aborted!", bus_speed);
987 TEST_MESSAGE(msg_buf);
994 #endif // If Test Mode SPI Server is selected
997 \fn static int32_t IsNotLoopback (void)
998 \brief Check if loopback is not selected.
999 \detail This function is used to skip executing a test if it is not supported
1001 \return execution status
1002 - EXIT_SUCCESS: Loopback is not selected
1003 - EXIT_FAILURE: Loopback is selected
1005 static int32_t IsNotLoopback (void) {
1007 #if (SPI_SERVER_USED == 1)
1008 return EXIT_SUCCESS;
1010 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test not executed!");
1011 return EXIT_FAILURE;
1016 \fn static int32_t IsNotFrameTI (void)
1017 \brief Check if Default Clock / Frame Format selected is not Texas Instruments.
1018 \detail This function is used to skip executing a test if it is not supported
1019 for Texas Instruments Frame Format.
1020 \return execution status
1021 - EXIT_SUCCESS: Texas Instruments Frame Format is not selected
1022 - EXIT_FAILURE: Texas Instruments Frame Format is selected
1024 static int32_t IsNotFrameTI (void) {
1026 #if (SPI_CFG_DEF_FORMAT != FORMAT_TI)
1027 return EXIT_SUCCESS;
1029 TEST_MESSAGE("[WARNING] Test not supported for Texas Instruments Frame Format! Test not executed!");
1030 return EXIT_FAILURE;
1035 \fn static int32_t IsNotFrameMw (void)
1036 \brief Check if Default Clock / Frame Format selected is not National Semiconductor Microwire.
1037 \detail This function is used to skip executing a test if it is not supported
1038 for National Semiconductor Microwire Frame Format.
1039 \return execution status
1040 - EXIT_SUCCESS: National Semiconductor Microwire Frame Format is not selected
1041 - EXIT_FAILURE: National Semiconductor Microwire Frame Format is selected
1043 static int32_t IsNotFrameMw (void) {
1045 #if (SPI_CFG_DEF_FORMAT != FORMAT_MICROWIRE)
1046 return EXIT_SUCCESS;
1048 TEST_MESSAGE("[WARNING] Test not supported for National Semiconductor Microwire Frame Format! Test not executed!");
1049 return EXIT_FAILURE;
1054 \fn static int32_t IsFormatValid (void)
1055 \brief Check if default format settings are valid.
1056 \detail This function is used to abort executing a test if Default settings
1057 specify TI or Microwire Frame Format and Slave Select handling
1058 other than Hardware controlled.
1059 \return execution status
1060 - EXIT_SUCCESS: Format is valid
1061 - EXIT_FAILURE: Format is not valid
1063 static int32_t IsFormatValid (void) {
1065 #if ((SPI_CFG_DEF_FORMAT == FORMAT_TI) && (SPI_CFG_DEF_SS_MODE != SS_MODE_MASTER_HW_OUTPUT))
1066 TEST_MESSAGE("[WARNING] TI Frame Format works only with Hardware controlled Slave Select! Test not executed!");
1067 return EXIT_FAILURE;
1068 #elif ((SPI_CFG_DEF_FORMAT == FORMAT_MICROWIRE) && (SPI_CFG_DEF_SS_MODE != SS_MODE_MASTER_HW_OUTPUT))
1069 TEST_MESSAGE("[WARNING] Microwire Frame Format works only with Hardware controlled Slave Select! Test not executed!");
1070 return EXIT_FAILURE;
1072 return EXIT_SUCCESS;
1077 \fn static int32_t IsBitOrderValid (void)
1078 \brief Check if default bit order settings valid.
1079 \detail This function is used to abort executing a test if Default settings
1080 specify TI or Microwire Frame Format and bit order is not MSB to LSB.
1081 \return execution status
1082 - EXIT_SUCCESS: bit order
1083 - EXIT_FAILURE: bit order
1085 static int32_t IsBitOrderValid (void) {
1087 #if ((SPI_CFG_DEF_FORMAT == FORMAT_TI) && (SPI_CFG_DEF_BIT_ORDER != BO_MSB_TO_LSB))
1088 TEST_MESSAGE("[WARNING] TI Frame Format works only with MSB to LSB bit order! Test not executed!");
1089 return EXIT_FAILURE;
1090 #elif ((SPI_CFG_DEF_FORMAT == FORMAT_MICROWIRE) && (SPI_CFG_DEF_BIT_ORDER != BO_MSB_TO_LSB))
1091 TEST_MESSAGE("[WARNING] Microwire Frame Format works only with MSB to LSB bit order! Test not executed!");
1092 return EXIT_FAILURE;
1094 return EXIT_SUCCESS;
1099 \fn void SPI_DV_Initialize (void)
1100 \brief Initialize testing environment for SPI testing.
1101 \detail This function is called by the driver validation framework before SPI testing begins.
1102 It initializes global variables and allocates memory buffers (from heap) used for the SPI testing.
1105 void SPI_DV_Initialize (void) {
1107 // Initialize global variables
1112 duration = 0xFFFFFFFFUL;
1113 systick_freq = osKernelGetSysTimerFreq();
1115 memset(&spi_serv_cap, 0, sizeof(spi_serv_cap));
1116 memset(&msg_buf, 0, sizeof(msg_buf));
1118 // Allocate buffers for transmission, reception and comparison
1119 // (maximum size is incremented by 32 bytes to ensure that buffer can be aligned to 32 bytes)
1121 ptr_tx_buf_alloc = malloc(SPI_BUF_MAX + 32U);
1122 if (((uint32_t)ptr_tx_buf_alloc & 31U) != 0U) {
1123 // If allocated memory is not 32 byte aligned, use next 32 byte aligned address for ptr_tx_buf
1124 ptr_tx_buf = (uint8_t *)((((uint32_t)ptr_tx_buf_alloc) + 31U) & (~31U));
1126 // If allocated memory is 32 byte aligned, use it directly
1127 ptr_tx_buf = (uint8_t *)ptr_tx_buf_alloc;
1129 ptr_rx_buf_alloc = malloc(SPI_BUF_MAX + 32U);
1130 if (((uint32_t)ptr_rx_buf_alloc & 31U) != 0U) {
1131 ptr_rx_buf = (uint8_t *)((((uint32_t)ptr_rx_buf_alloc) + 31U) & (~31U));
1133 ptr_rx_buf = (uint8_t *)ptr_rx_buf_alloc;
1135 ptr_cmp_buf_alloc = malloc(SPI_BUF_MAX + 32U);
1136 if (((uint32_t)ptr_cmp_buf_alloc & 31U) != 0U) {
1137 ptr_cmp_buf = (uint8_t *)((((uint32_t)ptr_cmp_buf_alloc) + 31U) & (~31U));
1139 ptr_cmp_buf = (uint8_t *)ptr_cmp_buf_alloc;
1142 event_flags = osEventFlagsNew(NULL);
1144 // Output configuration settings
1145 (void)snprintf(msg_buf,
1148 "Default settings:\n"\
1149 " - Slave Select: %s\n"\
1151 " - Data bits: %i\n"\
1152 " - Bit order: %s\n"\
1153 " - Bus speed: %i bps\n"\
1154 " - Number of Items: %i",
1155 str_test_mode[SPI_CFG_TEST_MODE],
1156 str_ss_mode [SPI_CFG_DEF_SS_MODE],
1157 str_format [SPI_CFG_DEF_FORMAT],
1158 SPI_CFG_DEF_DATA_BITS,
1159 str_bit_order[SPI_CFG_DEF_BIT_ORDER],
1160 SPI_CFG_DEF_BUS_SPEED,
1162 TEST_GROUP_INFO(msg_buf);
1164 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1165 // Test communication with SPI Server
1166 int32_t server_status;
1169 // Test communication with SPI Server
1170 if (drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK) {
1171 if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
1172 server_status = ServerInit();
1175 (void)drv->PowerControl(ARM_POWER_OFF);
1176 (void)drv->Uninitialize();
1178 //(void)snprintf(msg_buf, sizeof(msg_buf), "Server status: %s\n", str_srv_status[server_status]);
1179 //TEST_GROUP_INFO(msg_buf);
1184 \fn void SPI_DV_Uninitialize (void)
1185 \brief De-initialize testing environment after SPI testing.
1186 \detail This function is called by the driver validation framework after SPI testing is finished.
1187 It frees memory buffers used for the SPI testing.
1190 void SPI_DV_Uninitialize (void) {
1192 (void)osEventFlagsDelete(event_flags);
1194 if (ptr_tx_buf_alloc != NULL) {
1195 free(ptr_tx_buf_alloc);
1197 ptr_tx_buf_alloc = NULL;
1199 if (ptr_rx_buf_alloc != NULL) {
1200 free(ptr_rx_buf_alloc);
1202 ptr_rx_buf_alloc = NULL;
1204 if (ptr_cmp_buf_alloc != NULL) {
1205 free(ptr_cmp_buf_alloc);
1207 ptr_cmp_buf_alloc = NULL;
1211 #endif // End of exclude form the documentation
1213 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1215 \defgroup dv_spi SPI Validation
1216 \brief SPI driver validation
1218 The SPI validation performs the following tests:
1219 - API interface compliance
1220 - Data exchange with various speeds, transfer sizes and communication settings
1223 Two Test Modes are available: <b>Loopback</b> and <b>SPI Server</b>.
1225 Test Mode : <b>Loopback</b>
1226 ---------------------------
1228 This test mode allows only limited validation of the SPI Driver.<br>
1229 It is recommended that this test mode is used only as a proof that driver is
1230 good enough to be tested with the <b>SPI Server</b>.
1232 For this purpose following <b>Default settings</b> should be used:
1233 - Slave Select: Not used
1234 - Clock / Frame Format: Clock Polarity 0, Clock Phase 0
1236 - Bit Order: MSB to LSB
1237 - Bus Speed: same as setting for the SPI Server
1238 - Number of Items: 32
1240 To enable this mode of testing in the <b>DV_SPI_Config.h</b> configuration file select the
1241 <b>Configuration: Test Mode: Loopback</b> setting.
1243 Required pin connection for the <b>Loopback</b> test mode:
1245 \image html spi_loopback_pin_connections.png
1247 \note In this mode following operations / settings cannot be tested:
1249 - Slave Select line functionality
1250 - operation of the Receive function
1251 - data content sent by the Send function
1252 - clock / frame format and bit order settings
1253 - data bit settings other then: 8, 16, 24 and 32
1256 Test Mode : <b>SPI Server</b>
1257 -----------------------------
1259 This test mode allows extensive validation of the SPI Driver.<br>
1260 Results of the Driver Validation in this test mode are relevant as a proof of driver compliance
1261 to the CMSIS-Driver specification.
1263 To perform extensive communication tests, it is required to use an
1264 \ref spi_server "SPI Server" running on a dedicated hardware.
1266 To enable this mode of testing in the <b>DV_SPI_Config.h</b> configuration file select the
1267 <b>Configuration: Test Mode: SPI Server</b> setting.
1269 Required pin connections for the <b>SPI Server</b> test mode:
1271 \image html spi_server_pin_connections.png
1273 \note Slave Select line has to be pulled to Vcc by an external pull-up (for example 10 kOhm).
1274 \note To ensure proper signal quality:
1275 - keep the connecting wires as short as possible
1276 - if possible have SCK and GND wires as a twisted pair and MISO, MOSI and Slave Select
1277 wires separate from each other
1278 - ensure a good Ground (GND) connection between SPI Server and DUT
1279 \note If you experience issues with corrupt data content try reducing bus speed.
1282 \defgroup spi_tests Tests
1286 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1287 /* SPI Driver Management tests */
1288 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1290 \defgroup spi_tests_drv_mgmt Driver Management
1293 These tests verify API and operation of the SPI driver management functions.
1295 The driver management tests verify the following driver functions
1296 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
1299 ARM_DRIVER_VERSION GetVersion (void);
1301 - \b GetCapabilities
1303 ARM_SPI_CAPABILITIES GetCapabilities (void);
1307 int32_t Initialize (ARM_SPI_SignalEvent_t cb_event);
1311 int32_t Uninitialize (void);
1315 int32_t PowerControl (ARM_POWER_STATE state);
1321 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1323 \brief Function: Function SPI_GetVersion
1325 The function \b SPI_GetVersion verifies the \b GetVersion function.
1327 ARM_DRIVER_VERSION GetVersion (void);
1331 - Driver is uninitialized and peripheral is powered-off:
1332 - Call GetVersion function
1333 - Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1335 void SPI_GetVersion (void) {
1336 ARM_DRIVER_VERSION ver;
1338 ver = drv->GetVersion();
1340 // Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1341 TEST_ASSERT((ver.api >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)) && (ver.drv >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)));
1343 (void)snprintf(msg_buf, sizeof(msg_buf), "[INFO] Driver API version %d.%d, Driver version %d.%d", (ver.api >> 8), (ver.api & 0xFFU), (ver.drv >> 8), (ver.drv & 0xFFU));
1344 TEST_MESSAGE(msg_buf);
1347 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1349 \brief Function: Function SPI_GetCapabilities
1351 The function \b SPI_GetCapabilities verifies the \b GetCapabilities function.
1353 ARM_SPI_CAPABILITIES GetCapabilities (void);
1357 - Driver is uninitialized and peripheral is powered-off:
1358 - Call GetCapabilities function
1359 - Assert that GetCapabilities function returned capabilities structure with reserved field 0
1361 void SPI_GetCapabilities (void) {
1362 ARM_SPI_CAPABILITIES cap;
1364 cap = drv->GetCapabilities();
1366 // Assert that GetCapabilities function returned capabilities structure with reserved field 0
1367 TEST_ASSERT_MESSAGE((cap.reserved == 0U), "[FAILED] Capabilities reserved field must be 0");
1370 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1372 \brief Function: Function SPI_Initialize_Uninitialize
1374 The function \b SPI_Initialize_Uninitialize verifies the \b Initialize and \b Uninitialize functions.
1376 int32_t Initialize (ARM_SPI_SignalEvent_t cb_event);
1379 int32_t Uninitialize (void);
1383 - Driver is uninitialized and peripheral is powered-off:
1384 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1385 - Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1386 - Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1387 - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1388 - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1389 - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1390 - Call GetDataCount function and assert that it returned 0
1391 - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1392 - Call GetStatus function
1393 - Assert that GetStatus function returned status structure with busy flag 0
1394 - Assert that GetStatus function returned status structure with data_lost flag 0
1395 - Assert that GetStatus function returned status structure with mode_fault flag 0
1396 - Assert that GetStatus function returned status structure with reserved field 0
1397 - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1398 - Driver is initialized and peripheral is powered-off:
1399 - Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1400 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1401 - Driver is uninitialized and peripheral is powered-off:
1402 - Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1403 - Driver is initialized and peripheral is powered-off:
1404 - Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1405 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1406 - Driver is uninitialized and peripheral is powered-off:
1407 - Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1408 - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1409 - Driver is initialized and peripheral is powered-off:
1410 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1411 - Driver is initialized and peripheral is powered-on:
1412 - Call Control function and assert that it returned ARM_DRIVER_OK status
1413 - Call Transfer function and assert that it returned ARM_DRIVER_OK status
1414 - Call GetStatus function
1415 - Assert that GetStatus function returned status structure with busy flag 1
1416 - Call Uninitialize function with transfer active and assert that it returned ARM_DRIVER_OK status<br>
1417 (this must unconditionally terminate active transfer, power-off the peripheral and uninitialize the driver)
1418 - Driver is uninitialized and peripheral is powered-off:
1419 - Call GetStatus function
1420 - Assert that GetStatus function returned status structure with busy flag 0
1422 void SPI_Initialize_Uninitialize (void) {
1423 ARM_SPI_STATUS stat;
1425 // Driver is uninitialized and peripheral is powered-off:
1426 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1427 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_ERROR);
1429 // Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1430 TEST_ASSERT(drv->PowerControl (ARM_POWER_LOW) == ARM_DRIVER_ERROR);
1432 // Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1433 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_ERROR);
1435 // Call Send function and assert that it returned ARM_DRIVER_ERROR status
1436 TEST_ASSERT(drv->Send (ptr_tx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1438 // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1439 TEST_ASSERT(drv->Receive (ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1441 // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1442 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1444 // Call GetDataCount function and assert that it returned 0
1445 TEST_ASSERT(drv->GetDataCount () == 0U);
1447 // Call Control function and assert that it returned ARM_DRIVER_ERROR status
1448 TEST_ASSERT(drv->Control (ARM_SPI_MODE_MASTER | ARM_SPI_DATA_BITS(SPI_CFG_DEF_DATA_BITS), SPI_CFG_DEF_BUS_SPEED) == ARM_DRIVER_ERROR);
1450 // Call GetStatus function
1451 stat = drv->GetStatus();
1453 // Assert that GetStatus function returned status structure with busy flag 0
1454 TEST_ASSERT(stat.busy == 0U);
1456 // Assert that GetStatus function returned status structure with data_lost flag 0
1457 TEST_ASSERT(stat.data_lost == 0U);
1459 // Assert that GetStatus function returned status structure with mode_fault flag 0
1460 TEST_ASSERT(stat.mode_fault == 0U);
1462 // Assert that GetStatus function returned status structure with reserved field 0
1463 TEST_ASSERT(stat.reserved == 0U);
1465 // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1466 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1468 // Driver is initialized and peripheral is powered-off:
1469 // Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1470 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1472 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1473 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1475 // Driver is uninitialized and peripheral is powered-off:
1476 // Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1477 TEST_ASSERT(drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK);
1479 // Driver is initialized and peripheral is powered-off:
1480 // Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1481 TEST_ASSERT(drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK);
1483 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1484 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1486 // Driver is uninitialized and peripheral is powered-off:
1487 // Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1488 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1490 // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1491 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1493 // Driver is initialized and peripheral is powered-off:
1494 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1495 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1497 // Driver is initialized and peripheral is powered-on:
1498 // Call Control function and assert that it returned ARM_DRIVER_OK status
1499 TEST_ASSERT(drv->Control (ARM_SPI_MODE_MASTER | ARM_SPI_DATA_BITS(SPI_CFG_DEF_DATA_BITS), SPI_CFG_DEF_BUS_SPEED) == ARM_DRIVER_OK);
1501 // Call Transfer function and assert that it returned ARM_DRIVER_OK status
1502 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
1504 // Call GetStatus function
1505 stat = drv->GetStatus();
1507 // Assert that GetStatus function returned status structure with busy flag 1
1508 TEST_ASSERT(stat.busy == 1U);
1510 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1511 // (this must unconditionally terminate active transfer, power-off the peripheral and uninitialize the driver)
1512 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1514 // Driver is uninitialized and peripheral is powered-off:
1515 // Call GetStatus function
1516 stat = drv->GetStatus();
1518 // Assert that GetStatus function returned status structure with busy flag 0
1519 TEST_ASSERT(stat.busy == 0U);
1521 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1522 // Ensure that SPI Server (if used) is ready for command reception
1527 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1529 \brief Function: Function SPI_PowerControl
1531 The function \b SPI_PowerControl verifies the \b PowerControl function.
1533 int32_t PowerControl (ARM_POWER_STATE state);
1537 - Driver is initialized and peripheral is powered-off:
1538 - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1539 - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1540 - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1541 - Call GetDataCount function and assert that it returned 0
1542 - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1543 - Call GetStatus function
1544 - Assert that GetStatus function returned status structure with busy flag 0
1545 - Assert that GetStatus function returned status structure with data_lost flag 0
1546 - Assert that GetStatus function returned status structure with mode_fault flag 0
1547 - Assert that GetStatus function returned status structure with reserved field 0
1548 - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1549 - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1550 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1551 - Driver is initialized and peripheral is powered-on:
1552 - Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
1553 - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1554 - Driver is initialized and peripheral is powered-off:
1555 - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1556 - Call PowerControl(ARM_POWER_LOW) function
1557 - Driver is initialized and peripheral is powered-on or in low-power mode:
1558 - Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
1559 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1560 - Driver is initialized and peripheral is powered-on:
1561 - Call Control function and assert that it returned ARM_DRIVER_OK status
1562 - Call Transfer function and assert that it returned ARM_DRIVER_OK status
1563 - Call GetStatus function
1564 - Assert that GetStatus function returned status structure with busy flag 1
1565 - Call PowerControl(ARM_POWER_OFF) function with transfer active and assert that it returned ARM_DRIVER_OK status<br>
1566 (this must unconditionally terminate active transfer and power-off the peripheral)
1567 - Driver is initialized and peripheral is powered-off:
1568 - Call GetStatus function
1569 - Assert that GetStatus function returned status structure with busy flag 0
1571 void SPI_PowerControl (void) {
1573 ARM_SPI_STATUS stat;
1575 (void)drv->Initialize (NULL);
1577 // Driver is initialized and peripheral is powered-off:
1578 // Call Send function and assert that it returned ARM_DRIVER_ERROR status
1579 TEST_ASSERT(drv->Send (ptr_tx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1581 // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1582 TEST_ASSERT(drv->Receive (ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1584 // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1585 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1587 // Call GetDataCount function and assert that it returned 0
1588 TEST_ASSERT(drv->GetDataCount () == 0U);
1590 // Call Control function and assert that it returned ARM_DRIVER_ERROR status
1591 TEST_ASSERT(drv->Control (ARM_SPI_MODE_MASTER | ARM_SPI_DATA_BITS(SPI_CFG_DEF_DATA_BITS), SPI_CFG_DEF_BUS_SPEED) == ARM_DRIVER_ERROR);
1593 // Call GetStatus function
1594 stat = drv->GetStatus();
1596 // Assert that GetStatus function returned status structure with busy flag 0
1597 TEST_ASSERT(stat.busy == 0U);
1599 // Assert that GetStatus function returned status structure with data_lost flag 0
1600 TEST_ASSERT(stat.data_lost == 0U);
1602 // Assert that GetStatus function returned status structure with mode_fault flag 0
1603 TEST_ASSERT(stat.mode_fault == 0U);
1605 // Assert that GetStatus function returned status structure with reserved field 0
1606 TEST_ASSERT(stat.reserved == 0U);
1608 // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1609 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1611 // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1612 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1614 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1615 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1617 // Driver is initialized and peripheral is powered-on:
1618 // Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
1619 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1621 // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1622 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1624 // Driver is initialized and peripheral is powered-off:
1625 // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1626 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1628 // Call PowerControl(ARM_POWER_LOW) function
1629 ret = drv->PowerControl (ARM_POWER_LOW);
1631 // Driver is initialized and peripheral is powered-on or in low-power mode:
1632 // Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
1633 TEST_ASSERT((ret == ARM_DRIVER_OK) || (ret == ARM_DRIVER_ERROR_UNSUPPORTED));
1634 if (ret == ARM_DRIVER_ERROR_UNSUPPORTED) {
1635 TEST_MESSAGE("[WARNING] PowerControl (ARM_POWER_LOW) is not supported");
1638 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1639 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1641 // Driver is initialized and peripheral is powered-on:
1642 // Call Control function and assert that it returned ARM_DRIVER_OK status
1643 TEST_ASSERT(drv->Control (ARM_SPI_MODE_MASTER | ARM_SPI_DATA_BITS(SPI_CFG_DEF_DATA_BITS), SPI_CFG_DEF_BUS_SPEED) == ARM_DRIVER_OK);
1645 // Call Transfer function and assert that it returned ARM_DRIVER_OK status
1646 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
1648 // Call GetStatus function
1649 stat = drv->GetStatus();
1651 // Assert that GetStatus function returned status structure with busy flag 1
1652 TEST_ASSERT(stat.busy == 1U);
1654 // Call PowerControl(ARM_POWER_OFF) function with transfer active and assert that it returned ARM_DRIVER_OK status
1655 // (this must unconditionally terminate active transfer and power-off the peripheral)
1656 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1658 // Driver is initialized and peripheral is powered-off:
1659 // Call GetStatus function
1660 stat = drv->GetStatus();
1662 // Assert that GetStatus function returned status structure with busy flag 0
1663 TEST_ASSERT(stat.busy == 0U);
1665 (void)drv->Uninitialize ();
1667 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1668 // Ensure that SPI Server (if used) is ready for command reception
1676 // End of spi_tests_drv_mgmt
1678 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1679 /* SPI Data Exchange tests */
1680 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1682 \defgroup spi_tests_data_xchg Data Exchange
1685 These tests verify API and operation of the SPI data exchange functions.
1687 The data exchange tests verify the following driver functions
1688 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
1691 int32_t Send (const void *data, uint32_t num);
1695 int32_t Receive ( void *data, uint32_t num);
1699 int32_t Transfer (const void *data_out, void *data_in, uint32_t num);
1703 uint32_t GetDataCount (void);
1707 int32_t Control (uint32_t control, uint32_t arg);
1711 ARM_SPI_STATUS GetStatus (void);
1715 void (*ARM_SPI_SignalEvent_t) (uint32_t event);
1718 All of these tests execute a data exchange and check the result of this data exchange.
1720 Data exchange test procedure when Test Mode <b>SPI Server</b> is selected:
1721 - send command "SET BUF TX,.." to the SPI Server: Set Tx buffer
1722 - send command "SET BUF RX,.." to the SPI Server: Set Rx buffer
1723 - send command "SET COM .." to the SPI Server: Set communication settings for the next XFER command
1724 - send command "XFER .." to the SPI Server: Specify transfer
1725 - driver Control: Configure the SPI interface
1726 - driver Control: Set the default Tx value
1727 - driver Send/Receive/Transfer: Start the requested operation
1728 - driver GetStatus/SignalEvent: Wait for the current operation to finish or time-out<br>
1729 (operation is finished when busy flag is 0 and completed event was signaled)
1730 - assert that operation has finished in expected time
1731 - assert that ARM_SPI_EVENT_TRANSFER_COMPLETE event was signaled
1732 - driver GetStatus: Assert that busy flag is 0
1733 - driver GetDataCount: Assert that number of transferred items is same as requested
1734 - if operation has timed out call driver Control function to Abort operation and wait timeout time<br>
1735 to make sure that the SPI Server is ready for the next command
1736 - assert that received content is as expected
1737 - send command "GET BUF RX,.." to the SPI Server: Get Rx buffer
1738 - assert that sent content (read from the SPI Server's receive buffer) is as expected
1740 Data exchange <b>Abort</b> test procedure when Test Mode <b>SPI Server</b> is selected:
1741 - send command "SET BUF TX,.." to the SPI Server: Set Tx buffer
1742 - send command "SET BUF RX,.." to the SPI Server: Set Rx buffer
1743 - send command "SET COM .." to the SPI Server: Set communication settings for the next XFER command
1744 - send command "XFER .." to the SPI Server: Specify transfer
1745 - driver Control: Configure the SPI interface
1746 - driver Control: Set the default Tx value
1747 - driver Send/Receive/Transfer: Start the requested operation
1749 - driver Control: Abort the current operation
1750 - driver GetStatus: Assert that busy flag is 0
1751 - driver GetDataCount: Assert that number of transferred items is less than requested
1753 Data exchange test procedure when Test Mode <b>Loopback</b> is selected:
1754 - driver Control: Configure the SPI interface
1755 - driver Control: Set the default Tx value
1756 - driver Send/Transfer: Start the requested operation
1757 - driver GetStatus/SignalEvent: Wait for the current operation to finish or time-out<br>
1758 (operation is finished when busy flag is 0 and completed event was signaled)
1759 - assert that operation has finished in expected time
1760 - assert that ARM_SPI_EVENT_TRANSFER_COMPLETE event was signaled
1761 - driver GetStatus: Assert that busy flag is 0
1762 - driver GetDataCount: Assert that number of transferred items is same as requested
1763 - if operation has timed out call driver Control function to Abort operation
1764 - assert that received content is as expected (for Transfer operation only)
1766 \note Limitations of Data Exchange tests if Test Mode <b>Loopback</b> is selected:
1767 - only Master mode with Slave Select not used can be tested
1768 - Receive function cannot be tested
1769 - format tests are not supported
1770 - only 8, 16, 24 and 32 data bit tests are supported
1771 - bit order tests are not supported
1775 #ifndef __DOXYGEN__ // Exclude form the documentation
1777 \brief Execute SPI data exchange or abort operation.
1778 \param[in] operation operation (OP_SEND .. OP_ABORT_TRANSFER)
1779 \param[in] mode mode (MODE_MASTER or MODE_SLAVE)
1780 \param[in] format clock/frame format (0 = polarity0/phase0 .. 5 = Microwire)
1781 \param[in] data_bits data bits (1 .. 32)
1782 \param[in] bit_order bit order (BO_MSB_TO_LSB or BO_LSB_TO_MSB)
1783 \param[in] ss_mode Slave Select mode (SS_MODE_xxx)
1784 \param[in] bus_speed bus speed in bits per second (bps)
1785 \param[in] num number of items to send, receive or transfer
1788 static void SPI_DataExchange_Operation (uint32_t operation, uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed, uint32_t num) {
1789 // volatile specifier is used to prevent compiler from optimizing variables
1790 // in a way that they cannot be seen with a debugger
1791 volatile int32_t stat, def_tx_stat;
1792 volatile uint32_t drv_mode, drv_format, drv_data_bits, drv_bit_order, drv_ss_mode;
1793 volatile uint32_t srv_mode, srv_ss_mode;
1794 volatile ARM_SPI_STATUS spi_stat;
1795 volatile uint32_t data_count;
1798 volatile uint32_t srv_delay_c, srv_delay_t;
1799 volatile uint32_t drv_delay_c, drv_delay_t;
1800 uint32_t timeout, start_tick, curr_tick;
1803 // Prepare parameters for SPI Server and Driver configuration
1806 TEST_FAIL_MESSAGE("[FAILED] Inactive mode! Data exchange operation aborted!");
1809 // When Master mode is tested, time diagram is as follows:
1812 // Slave Control (SPI Server) .
1814 // Master Control (SPI Client (DUT)) .
1815 // ... 4 ms SPI_CFG_XFER_TIMEOUT
1816 // Slave Transfer (SPI Server) .
1818 // Master Send/Receive/Transfer (SPI Client (DUT)) .
1819 // ... data exchange _|_
1820 drv_mode = ARM_SPI_MODE_MASTER;
1828 // When Slave mode is tested, time diagram is as follows:
1831 // Slave Control (SPI Client (DUT)) .
1833 // Master Control (SPI Server) .
1834 // ... 4 ms SPI_CFG_XFER_TIMEOUT
1835 // Slave Transfer (SPI Client (DUT)) .
1837 // Master Send/Receive/Transfer (SPI Server) .
1838 // ... data exchange _|_
1839 drv_mode = ARM_SPI_MODE_SLAVE;
1847 TEST_FAIL_MESSAGE("[FAILED] Unknown mode! Data exchange operation aborted!");
1853 case FORMAT_CPOL0_CPHA0:
1854 drv_format = ARM_SPI_CPOL0_CPHA0;
1856 case FORMAT_CPOL0_CPHA1:
1857 drv_format = ARM_SPI_CPOL0_CPHA1;
1859 case FORMAT_CPOL1_CPHA0:
1860 drv_format = ARM_SPI_CPOL1_CPHA0;
1862 case FORMAT_CPOL1_CPHA1:
1863 drv_format = ARM_SPI_CPOL1_CPHA1;
1866 drv_format = ARM_SPI_TI_SSI;
1868 case FORMAT_MICROWIRE:
1869 drv_format = ARM_SPI_MICROWIRE;
1872 TEST_FAIL_MESSAGE("[FAILED] Unknown clock / frame format! Data exchange operation aborted!");
1876 if ((data_bits > 0U) && (data_bits <= 32U)) {
1877 drv_data_bits = ARM_SPI_DATA_BITS(data_bits);
1879 TEST_FAIL_MESSAGE("[FAILED] Data bits not in range 1 to 32! Data exchange operation aborted!");
1883 switch (bit_order) {
1885 drv_bit_order = ARM_SPI_MSB_LSB;
1888 drv_bit_order = ARM_SPI_LSB_MSB;
1891 TEST_FAIL_MESSAGE("[FAILED] Unknown bit order! Data exchange operation aborted!");
1895 if (mode == MODE_MASTER) {
1897 case SS_MODE_MASTER_UNUSED:
1898 drv_ss_mode = ARM_SPI_SS_MASTER_UNUSED;
1901 case SS_MODE_MASTER_SW:
1902 drv_ss_mode = ARM_SPI_SS_MASTER_SW;
1905 case SS_MODE_MASTER_HW_OUTPUT:
1906 drv_ss_mode = ARM_SPI_SS_MASTER_HW_OUTPUT;
1909 case SS_MODE_MASTER_HW_INPUT:
1910 drv_ss_mode = ARM_SPI_SS_MASTER_UNUSED;
1914 TEST_FAIL_MESSAGE("[FAILED] Unknown Slave Select mode! Data exchange operation aborted!");
1919 case SS_MODE_SLAVE_HW:
1920 drv_ss_mode = ARM_SPI_SS_SLAVE_HW;
1923 case SS_MODE_SLAVE_SW:
1924 drv_ss_mode = ARM_SPI_SS_SLAVE_SW;
1928 TEST_FAIL_MESSAGE("[FAILED] Unknown Slave Select mode! Data exchange operation aborted!");
1933 // Total transfer timeout (16 ms is overhead before transfer starts)
1934 timeout = SPI_CFG_XFER_TIMEOUT + 16U;
1936 // Check that SPI status is not busy before starting data exchange test
1937 spi_stat = drv->GetStatus(); // Get SPI status
1938 if (spi_stat.busy != 0U) {
1939 // If busy flag is active
1940 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy active before operation! Data exchange operation aborted!");
1942 TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
1945 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1946 if (CmdSetBufTx('S') != EXIT_SUCCESS) { break; }
1947 if (CmdSetBufRx('?') != EXIT_SUCCESS) { break; }
1948 if (CmdSetCom (srv_mode, format, data_bits, bit_order, srv_ss_mode, bus_speed) != EXIT_SUCCESS) { break; }
1949 if (CmdXfer (num, srv_delay_c, srv_delay_t, SPI_CFG_XFER_TIMEOUT) != EXIT_SUCCESS) { break; }
1950 (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
1951 #else // If Test Mode Loopback is selected
1952 // Remove warnings for unused variables
1958 start_tick = osKernelGetTickCount();
1960 // Initialize buffers
1961 memset(ptr_tx_buf, (int32_t)'!' , SPI_BUF_MAX);
1962 memset(ptr_tx_buf, (int32_t)'T' , num * DataBitsToBytes(data_bits));
1963 memset(ptr_rx_buf, (int32_t)'?' , SPI_BUF_MAX);
1964 memset(ptr_cmp_buf, (int32_t)'?' , SPI_BUF_MAX);
1966 // Configure required communication settings
1967 (void)osDelay(drv_delay_c); // Wait specified time before calling Control function
1968 if (mode == MODE_MASTER) {
1969 stat = drv->Control (drv_mode | drv_format | drv_data_bits | drv_bit_order | drv_ss_mode, bus_speed);
1971 // For Slave mode bus speed argument is not used
1972 stat = drv->Control (drv_mode | drv_format | drv_data_bits | drv_bit_order | drv_ss_mode, 0U);
1974 if (stat != ARM_DRIVER_OK) {
1975 // If configuration has failed
1976 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Control function returned", str_ret[-stat]);
1978 // Assert that Control function returned ARM_DRIVER_OK
1979 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1981 // Set default Tx value to 'D' byte values (only for master mode)
1982 if (mode == MODE_MASTER) {
1983 val = ((uint32_t)'D' << 24) | ((uint32_t)'D' << 16) | ((uint32_t)'D' << 8) | (uint32_t)'D';
1984 stat = drv->Control (ARM_SPI_SET_DEFAULT_TX_VALUE, val);
1986 if ((stat != ARM_DRIVER_OK) && (stat != ARM_DRIVER_ERROR_UNSUPPORTED)) {
1987 // If set default Tx value has failed
1988 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Set default Tx value returned", str_ret[-stat]);
1990 // Assert that Control function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED
1991 TEST_ASSERT_MESSAGE((stat == ARM_DRIVER_OK) || (stat == ARM_DRIVER_ERROR_UNSUPPORTED), msg_buf);
1993 if (stat == ARM_DRIVER_ERROR_UNSUPPORTED) {
1994 // If set default Tx value is not supported
1995 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] %s: %s", str_oper[operation], "Set default Tx value is not supported");
1996 TEST_MESSAGE(msg_buf);
1999 // For slave mode default Tx is not tested
2000 def_tx_stat = ARM_DRIVER_ERROR_UNSUPPORTED;
2002 (void)osDelay(drv_delay_t); // Wait specified time before calling Send/Receive/Transfer function
2004 // Prepare local variables
2006 duration = 0xFFFFFFFFUL;
2008 data_count_sample = 0U;
2010 start_cnt = osKernelGetSysTimerCount();
2012 if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) ||
2013 ((mode == MODE_SLAVE) && (ss_mode == SS_MODE_SLAVE_SW))) {
2014 // If operation requires software Slave Select driving, activate Slave Select
2015 stat = drv->Control (ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE);
2016 if (stat != ARM_DRIVER_OK) {
2017 // If driving of Slave Select to active state has failed
2018 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
2020 // Assert that Control function returned ARM_DRIVER_OK
2021 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2024 // Start the data exchange operation
2025 switch (operation & 0x0FU) {
2028 stat = drv->Send(ptr_tx_buf, num);
2029 if (stat != ARM_DRIVER_OK) {
2030 // If Send activation has failed
2031 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Send function returned", str_ret[-stat]);
2033 // Assert that Send function returned ARM_DRIVER_OK
2034 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2037 case OP_ABORT_RECEIVE:
2038 stat = drv->Receive(ptr_rx_buf, num);
2039 if (stat != ARM_DRIVER_OK) {
2040 // If Receive activation has failed
2041 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receive function returned", str_ret[-stat]);
2043 // Assert that Receive function returned ARM_DRIVER_OK
2044 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2047 case OP_ABORT_TRANSFER:
2048 stat = drv->Transfer(ptr_tx_buf, ptr_rx_buf, num);
2049 if (stat != ARM_DRIVER_OK) {
2050 // If Transfer activation has failed
2051 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transfer function returned", str_ret[-stat]);
2053 // Assert that Transfer function returned ARM_DRIVER_OK
2054 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2057 TEST_FAIL_MESSAGE("[FAILED] Unknown operation! Data exchange operation aborted!");
2060 if (stat != ARM_DRIVER_OK) {
2061 // If Send/Receive/Transfer start has failed
2062 (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
2065 if ((operation == OP_ABORT_SEND) || // This IF block tests only abort functionality
2066 (operation == OP_ABORT_RECEIVE) ||
2067 (operation == OP_ABORT_TRANSFER)) {
2068 (void)osDelay(1U); // Wait short time before doing Abort
2069 stat = drv->Control (ARM_SPI_ABORT_TRANSFER, 0U);
2070 if (stat != ARM_DRIVER_OK) {
2071 // If Abort has failed
2072 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
2074 // Assert that Control function returned ARM_DRIVER_OK
2075 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2077 if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) ||
2078 ((mode == MODE_SLAVE) && (ss_mode == SS_MODE_SLAVE_SW))) {
2079 // If operation requires software Slave Select driving, deactivate Slave Select
2080 drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE);
2082 spi_stat = drv->GetStatus(); // Get SPI status
2083 if (spi_stat.busy != 0U) {
2084 // If busy flag is still active
2085 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy still active after Abort");
2087 // Assert that busy flag is not active
2088 TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
2090 data_count = drv->GetDataCount(); // Get data count
2091 if (data_count >= num) {
2092 // If data count is more or equal to number of items then Abort has failed
2093 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetDataCount returned", data_count, "after Abort of", num, "items");
2095 // Assert data count is less then number of items requested for exchange
2096 TEST_ASSERT_MESSAGE(data_count < num, msg_buf);
2098 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
2100 (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
2102 // Wait until timeout expires
2103 curr_tick = osKernelGetTickCount();
2104 if ((curr_tick - start_tick) < timeout) {
2105 (void)osDelay(timeout - (curr_tick - start_tick));
2107 (void)osDelay(20U); // Wait for SPI Server to start reception of next command
2110 return; // Here Abort test is finished, exit
2113 // Wait for operation to finish (status busy is 0 and event complete signaled, or timeout)
2115 if (data_count_sample == 0U) {
2116 // Store first data count different than 0
2117 data_count_sample = drv->GetDataCount(); // Get data count
2119 if ((drv->GetStatus().busy == 0U) && ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) != 0U)) {
2120 duration = osKernelGetSysTimerCount() - start_cnt;
2123 } while ((osKernelGetTickCount() - start_tick) < timeout);
2125 if (duration == 0xFFFFFFFFUL) {
2126 // If operation has timed out
2127 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Operation timed out");
2129 // Assert that operation has finished in expected time
2130 TEST_ASSERT_MESSAGE(duration != 0xFFFFFFFFUL, msg_buf);
2132 if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) ||
2133 ((mode == MODE_SLAVE) && (ss_mode == SS_MODE_SLAVE_SW))) {
2134 // If operation requires software Slave Select driving, deactivate Slave Select
2135 stat = drv->Control (ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE);
2136 if (stat != ARM_DRIVER_OK) {
2137 // If driving of Slave Select to inactive state has failed
2138 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
2140 // Assert that Control function returned ARM_DRIVER_OK
2141 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
2144 if ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) == 0U) {
2145 // If transfer complete event was not signaled
2146 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_SPI_EVENT_TRANSFER_COMPLETE was not signaled");
2147 chk_data = 0U; // Do not check transferred content
2149 // Assert that ARM_SPI_EVENT_TRANSFER_COMPLETE was signaled
2150 TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) != 0U, msg_buf);
2152 spi_stat = drv->GetStatus(); // Get SPI status
2153 if (spi_stat.busy != 0U) {
2154 // If busy flag is still active
2155 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy still active after operation");
2156 chk_data = 0U; // Do not check transferred content
2158 // Assert that busy flag is not active
2159 TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
2161 if ((event & ARM_SPI_EVENT_DATA_LOST) != 0U) {
2162 // If data lost was signaled during the transfer
2163 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_SPI_EVENT_DATA_LOST was signaled");
2164 chk_data = 0U; // Do not check transferred content
2166 // Assert that ARM_SPI_EVENT_DATA_LOST was not signaled
2167 TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_DATA_LOST) == 0U, msg_buf);
2169 data_count = drv->GetDataCount(); // Get data count
2170 if (data_count != num) {
2171 // If data count is different then number of items, then operation has failed
2172 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetDataCount returned", data_count, "expected was", num, "items");
2173 chk_data = 0U; // Do not check transferred content
2175 // Assert that data count is equal to number of items requested for exchange
2176 TEST_ASSERT_MESSAGE(data_count == num, msg_buf);
2178 if ((drv->GetStatus().busy != 0U) || ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) == 0U)) {
2179 // If transfer did not finish in time, abort it
2180 (void)drv->Control(ARM_SPI_ABORT_TRANSFER, 0U);
2183 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
2185 (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
2187 // Wait until timeout expires
2188 curr_tick = osKernelGetTickCount();
2189 if ((curr_tick - start_tick) < timeout) {
2190 (void)osDelay(timeout - (curr_tick - start_tick));
2192 (void)osDelay(20U); // Wait for SPI Server to start reception of next command
2194 if (chk_data != 0U) { // If transferred content should be checked
2195 // Check received content for receive and transfer operations
2196 if ((operation == OP_RECEIVE) || (operation == OP_TRANSFER)) {
2197 memset(ptr_cmp_buf, (int32_t)'S', num * DataBitsToBytes(data_bits));
2198 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
2200 // If data received mismatches
2201 // Find on which byte mismatch starts
2202 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
2203 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
2207 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, received was 0x%02X, expected was 0x%02X", str_oper[operation], "Received data mismatches on", i, ptr_rx_buf[i], ptr_cmp_buf[i]);
2209 // Assert that data received is same as expected
2210 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
2213 // Check sent content (by checking SPI Server's received buffer content)
2214 if ((mode == MODE_MASTER) || (operation != OP_RECEIVE) || (def_tx_stat == ARM_DRIVER_OK)) {
2215 // Check sent data in all cases except Slave mode Receive operation
2216 // with Default Tx not working or unsupported
2217 if (CmdGetBufRx(SPI_BUF_MAX) != EXIT_SUCCESS) { break; }
2219 if ((operation == OP_RECEIVE) && (def_tx_stat == ARM_DRIVER_OK)) {
2220 // Expected data received by SPI Server should be default Tx value
2221 memset(ptr_cmp_buf, (int32_t)'D', num * DataBitsToBytes(data_bits));
2223 if ((operation == OP_SEND) || (operation == OP_TRANSFER)) {
2224 // Expected data received by SPI Server should be what was sent
2225 memset(ptr_cmp_buf, (int32_t)'T', num * DataBitsToBytes(data_bits));
2228 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
2230 // If data sent mismatches
2231 // Find on which byte mismatch starts
2232 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
2233 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
2237 if (operation == OP_RECEIVE) {
2238 // If sent was default Tx value, 'D' bytes
2239 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, SPI Server received 0x%02X, sent was 0x%02X", str_oper[operation], "Default Tx data mismatches on", i, ptr_rx_buf[i], ptr_cmp_buf[i]);
2241 // If sent was 'T' bytes
2242 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, SPI Server received 0x%02X, sent was 0x%02X", str_oper[operation], "Sent data mismatches on", i, ptr_rx_buf[i], ptr_cmp_buf[i]);
2245 // Assert data sent is same as expected
2246 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
2249 #else // If Test Mode Loopback is selected
2250 if (chk_data != 0U) { // If transferred content should be checked
2251 if (operation == OP_TRANSFER) {
2252 memset(ptr_cmp_buf, (int32_t)('T' & ((1U << data_bits) - 1U)), num * DataBitsToBytes(data_bits));
2253 if ((data_bits > 8U) && (data_bits < 16U)) {
2254 for (i = 1U; i < (num * DataBitsToBytes(data_bits)); i+= DataBitsToBytes(data_bits)) {
2255 ptr_cmp_buf[i] = 'T' & ((1U << (data_bits - 8U)) - 1U);
2257 } else if ((data_bits > 16U) && (data_bits < 32U)) {
2258 for (i = 2U; i < (num * DataBitsToBytes(data_bits)); i+= DataBitsToBytes(data_bits)) {
2259 if (data_bits <= 24U) {
2260 ptr_cmp_buf[i ] = 'T' & ((1U << (data_bits - 16U)) - 1U);
2261 ptr_cmp_buf[i+1] = 0U;
2263 ptr_cmp_buf[i+1] = 'T' & ((1U << (data_bits - 24U)) - 1U);
2267 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
2269 // If data received mismatches
2270 // Find on which byte mismatch starts
2271 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
2272 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
2276 (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]);
2278 // Assert that data received is same as expected
2279 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
2287 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
2288 TEST_FAIL_MESSAGE("[FAILED] Problems in communication with SPI Server. Test aborted!");
2292 #endif // End of exclude form the documentation
2294 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2296 \brief Function: Function SPI_Mode_Master_SS_Unused
2298 The function \b SPI_Mode_Master_SS_Unused verifies data exchange:
2299 - in <b>Master Mode</b> with <b>Slave Select line not used</b>
2300 - with default clock / frame format
2301 - with default data bits
2302 - with default bit order
2303 - at default bus speed
2304 - for default number of data items
2306 \note In Test Mode <b>Loopback</b> Receive function is not checked
2308 void SPI_Mode_Master_SS_Unused (void) {
2310 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
2311 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
2312 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2313 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2314 #if (SPI_SERVER_USED == 1)
2315 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2316 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2319 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);
2320 #if (SPI_SERVER_USED == 1)
2321 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_UNUSED, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2323 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);
2326 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2328 \brief Function: Function SPI_Mode_Master_SS_Sw_Ctrl
2330 The function \b SPI_Mode_Master_SS_Sw_Ctrl verifies data exchange:
2331 - in <b>Master Mode</b> with <b>Slave Select line Software controlled</b>
2332 - with default clock / frame format
2333 - with default data bits
2334 - with default bit order
2335 - at default bus speed
2336 - for default number of data items
2338 \note In Test Mode <b>Loopback</b> this test is not executed
2340 void SPI_Mode_Master_SS_Sw_Ctrl (void) {
2342 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
2343 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
2344 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
2345 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2346 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2347 #if (SPI_SERVER_USED == 1)
2348 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2349 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2352 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);
2353 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);
2354 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);
2357 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2359 \brief Function: Function SPI_Mode_Master_SS_Hw_Ctrl_Out
2361 The function \b SPI_Mode_Master_SS_Hw_Ctrl_Out verifies data exchange:
2362 - in <b>Master Mode</b> with <b>Slave Select line Hardware controlled Output</b>
2363 - with default clock / frame format
2364 - with default data bits
2365 - with default bit order
2366 - at default bus speed
2367 - for default number of data items
2369 \note In Test Mode <b>Loopback</b> this test not executed
2371 void SPI_Mode_Master_SS_Hw_Ctrl_Out (void) {
2373 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
2374 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2375 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2376 #if (SPI_SERVER_USED == 1)
2377 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2378 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2381 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);
2382 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);
2383 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);
2386 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2388 \brief Function: Function SPI_Mode_Master_SS_Hw_Mon_In
2390 The function \b SPI_Mode_Master_SS_Hw_Mon_In verifies data exchange:
2391 - in <b>Master Mode</b> with <b>Slave Select line Hardware monitored Input</b>
2392 - with default clock / frame format
2393 - with default data bits
2394 - with default bit order
2395 - at default bus speed
2396 - for default number of data items
2398 \note In Test Mode <b>Loopback</b> this test not executed
2400 void SPI_Mode_Master_SS_Hw_Mon_In (void) {
2402 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
2403 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
2404 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
2405 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2406 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2407 #if (SPI_SERVER_USED == 1)
2408 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2409 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2412 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);
2413 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);
2414 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);
2417 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2419 \brief Function: Function SPI_Mode_Slave_SS_Hw_Mon
2421 The function \b SPI_Mode_Slave_SS_Hw_Mon verifies data exchange:
2422 - in <b>Slave Mode</b> with <b>Slave Select line Hardware monitored</b>
2423 - with default clock / frame format
2424 - with default data bits
2425 - with default bit order
2426 - at default bus speed
2427 - for default number of data items
2429 \note In Test Mode <b>Loopback</b> this test not executed
2431 void SPI_Mode_Slave_SS_Hw_Mon (void) {
2433 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
2434 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2435 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2436 #if (SPI_SERVER_USED == 1)
2437 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2438 if (ServerCheckSupport(MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2441 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);
2442 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);
2443 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);
2446 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2448 \brief Function: Function SPI_Mode_Slave_SS_Sw_Ctrl
2450 The function \b SPI_Mode_Slave_SS_Sw_Ctrl verifies data exchange:
2451 - in <b>Slave Mode</b> with <b>Slave Select line Software controlled</b>
2452 - with default clock / frame format
2453 - with default data bits
2454 - with default bit order
2455 - at default bus speed
2456 - for default number of data items
2458 \note In Test Mode <b>Loopback</b> this test not executed
2460 void SPI_Mode_Slave_SS_Sw_Ctrl (void) {
2462 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
2463 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
2464 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
2465 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2466 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2467 #if (SPI_SERVER_USED == 1)
2468 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2469 if (ServerCheckSupport(MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2472 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);
2473 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);
2474 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);
2477 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2479 \brief Function: Function SPI_Format_Clock_Pol0_Pha0
2481 The function \b SPI_Format_Clock_Pol0_Pha0 verifies data exchange:
2482 - in Master Mode with default Slave Select mode
2483 - with clock format: <b>polarity 0 / phase 0</b>
2484 - with default data bits
2485 - with default bit order
2486 - at default bus speed
2487 - for default number of data items
2489 \note In Test Mode <b>Loopback</b> this test not executed
2491 void SPI_Format_Clock_Pol0_Pha0 (void) {
2493 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
2494 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2495 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2496 #if (SPI_SERVER_USED == 1)
2497 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2498 if (ServerCheckSupport(MODE_SLAVE, FORMAT_CPOL0_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2501 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);
2502 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);
2503 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);
2506 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2508 \brief Function: Function SPI_Format_Clock_Pol0_Pha1
2510 The function \b SPI_Format_Clock_Pol0_Pha1 verifies data exchange:
2511 - in Master Mode with default Slave Select mode
2512 - with clock format: <b>polarity 0 / phase 1</b>
2513 - with default data bits
2514 - with default bit order
2515 - at default bus speed
2516 - for default number of data items
2518 \note In Test Mode <b>Loopback</b> this test not executed
2520 void SPI_Format_Clock_Pol0_Pha1 (void) {
2522 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
2523 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2524 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2525 #if (SPI_SERVER_USED == 1)
2526 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2527 if (ServerCheckSupport(MODE_SLAVE, FORMAT_CPOL0_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2530 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);
2531 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);
2532 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);
2535 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2537 \brief Function: Function SPI_Format_Clock_Pol1_Pha0
2539 The function \b SPI_Format_Clock_Pol1_Pha0 verifies data exchange:
2540 - in Master Mode with default Slave Select mode
2541 - with clock format: <b>polarity 1 / phase 0</b>
2542 - with default data bits
2543 - with default bit order
2544 - at default bus speed
2545 - for default number of data items
2547 \note In Test Mode <b>Loopback</b> this test not executed
2549 void SPI_Format_Clock_Pol1_Pha0 (void) {
2551 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
2552 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2553 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2554 #if (SPI_SERVER_USED == 1)
2555 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2556 if (ServerCheckSupport(MODE_SLAVE, FORMAT_CPOL1_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2559 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);
2560 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);
2561 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);
2564 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2566 \brief Function: Function SPI_Format_Clock_Pol1_Pha1
2568 The function \b SPI_Format_Clock_Pol1_Pha1 verifies data exchange:
2569 - in Master Mode with default Slave Select mode
2570 - with clock format: <b>polarity 1 / phase 1</b>
2571 - with default data bits
2572 - with default bit order
2573 - at default bus speed
2574 - for default number of data items
2576 \note In Test Mode <b>Loopback</b> this test not executed
2578 void SPI_Format_Clock_Pol1_Pha1 (void) {
2580 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
2581 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2582 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2583 #if (SPI_SERVER_USED == 1)
2584 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2585 if (ServerCheckSupport(MODE_SLAVE, FORMAT_CPOL1_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2588 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);
2589 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);
2590 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);
2593 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2595 \brief Function: Function SPI_Format_Frame_TI
2597 The function \b SPI_Format_Frame_TI verifies data exchange:
2598 - in <b>Master Mode</b> with <b>Slave Select line Hardware controlled Output</b>
2599 - with <b>Texas Instruments frame format</b>
2600 - with default data bits
2601 - with bit order <b>from MSB to LSB</b>
2602 - at default bus speed
2603 - for default number of data items
2605 \note In Test Mode <b>Loopback</b> this test not executed
2607 void SPI_Format_Frame_TI (void) {
2609 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
2610 if (IsFormatValid() != EXIT_SUCCESS) { return; }
2611 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2612 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2613 #if (SPI_SERVER_USED == 1)
2614 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2615 if (ServerCheckSupport(MODE_SLAVE, FORMAT_TI, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2618 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, FORMAT_TI, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2619 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, FORMAT_TI, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2620 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_TI, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2623 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2625 \brief Function: Function SPI_Format_Clock_Microwire
2627 The function \b SPI_Format_Clock_Microwire verifies data exchange:
2628 - in <b>Master Mode</b> with <b>Slave Select line Hardware controlled Output</b>
2629 - with <b>National Semiconductor Microwire frame format</b>
2630 - with default data bits
2631 - with bit order <b>from MSB to LSB</b>
2632 - at default bus speed
2633 - for default number of data items
2635 \note In Test Mode <b>Loopback</b> this test not executed
2637 void SPI_Format_Clock_Microwire (void) {
2639 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
2640 if (IsFormatValid() != EXIT_SUCCESS) { return; }
2641 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2642 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2643 #if (SPI_SERVER_USED == 1)
2644 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2645 if (ServerCheckSupport(MODE_SLAVE, FORMAT_MICROWIRE, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2648 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, FORMAT_MICROWIRE, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2649 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, FORMAT_MICROWIRE, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2650 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_MICROWIRE, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2653 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2655 \brief Function: Function SPI_Data_Bits_1
2657 The function \b SPI_Data_Bits_1 verifies data exchange:
2658 - in Master Mode with default Slave Select mode
2659 - with default clock / frame format
2660 - with <b>1 data bits</b> per frame
2661 - with default bit order
2662 - at default bus speed
2663 - for default number of data items
2665 void SPI_Data_Bits_1 (void) {
2667 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
2668 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
2669 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2670 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2671 #if (SPI_SERVER_USED == 1)
2672 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2673 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 1U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2676 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);
2677 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);
2678 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);
2681 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2683 \brief Function: Function SPI_Data_Bits_2
2685 The function \b SPI_Data_Bits_2 verifies data exchange:
2686 - in Master Mode with default Slave Select mode
2687 - with default clock / frame format
2688 - with <b>2 data bits</b> per frame
2689 - with default bit order
2690 - at default bus speed
2691 - for default number of data items
2693 void SPI_Data_Bits_2 (void) {
2695 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
2696 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
2697 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2698 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2699 #if (SPI_SERVER_USED == 1)
2700 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2701 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 2U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2704 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);
2705 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);
2706 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);
2709 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2711 \brief Function: Function SPI_Data_Bits_3
2713 The function \b SPI_Data_Bits_3 verifies data exchange:
2714 - in Master Mode with default Slave Select mode
2715 - with default clock / frame format
2716 - with <b>3 data bits</b> per frame
2717 - with default bit order
2718 - at default bus speed
2719 - for default number of data items
2721 void SPI_Data_Bits_3 (void) {
2723 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
2724 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
2725 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2726 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2727 #if (SPI_SERVER_USED == 1)
2728 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2729 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 3U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2732 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);
2733 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);
2734 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);
2737 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2739 \brief Function: Function SPI_Data_Bits_4
2741 The function \b SPI_Data_Bits_4 verifies data exchange:
2742 - in Master Mode with default Slave Select mode
2743 - with default clock / frame format
2744 - with <b>4 data bits</b> per frame
2745 - with default bit order
2746 - at default bus speed
2747 - for default number of data items
2749 void SPI_Data_Bits_4 (void) {
2751 if (IsFormatValid() != EXIT_SUCCESS) { return; }
2752 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
2753 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2754 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2755 #if (SPI_SERVER_USED == 1)
2756 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2757 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 4U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2760 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);
2761 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);
2762 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);
2765 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2767 \brief Function: Function SPI_Data_Bits_5
2769 The function \b SPI_Data_Bits_5 verifies data exchange:
2770 - in Master Mode with default Slave Select mode
2771 - with default clock / frame format
2772 - with <b>5 data bits</b> per frame
2773 - with default bit order
2774 - at default bus speed
2775 - for default number of data items
2777 void SPI_Data_Bits_5 (void) {
2779 if (IsFormatValid() != EXIT_SUCCESS) { return; }
2780 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
2781 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2782 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2783 #if (SPI_SERVER_USED == 1)
2784 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2785 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 5U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2788 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);
2789 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);
2790 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);
2793 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2795 \brief Function: Function SPI_Data_Bits_6
2797 The function \b SPI_Data_Bits_6 verifies data exchange:
2798 - in Master Mode with default Slave Select mode
2799 - with default clock / frame format
2800 - with <b>6 data bits</b> per frame
2801 - with default bit order
2802 - at default bus speed
2803 - for default number of data items
2805 void SPI_Data_Bits_6 (void) {
2807 if (IsFormatValid() != EXIT_SUCCESS) { return; }
2808 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
2809 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2810 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2811 #if (SPI_SERVER_USED == 1)
2812 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2813 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 6U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2816 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);
2817 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);
2818 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);
2821 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2823 \brief Function: Function SPI_Data_Bits_7
2825 The function \b SPI_Data_Bits_7 verifies data exchange:
2826 - in Master Mode with default Slave Select mode
2827 - with default clock / frame format
2828 - with <b>7 data bits</b> per frame
2829 - with default bit order
2830 - at default bus speed
2831 - for default number of data items
2833 void SPI_Data_Bits_7 (void) {
2835 if (IsFormatValid() != EXIT_SUCCESS) { return; }
2836 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
2837 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2838 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2839 #if (SPI_SERVER_USED == 1)
2840 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2841 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 7U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2844 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);
2845 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);
2846 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);
2849 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2851 \brief Function: Function SPI_Data_Bits_8
2853 The function \b SPI_Data_Bits_8 verifies data exchange:
2854 - in Master Mode with default Slave Select mode
2855 - with default clock / frame format
2856 - with <b>8 data bits</b> per frame
2857 - with default bit order
2858 - at default bus speed
2859 - for default number of data items
2861 void SPI_Data_Bits_8 (void) {
2863 if (IsFormatValid() != EXIT_SUCCESS) { return; }
2864 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
2865 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2866 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2867 #if (SPI_SERVER_USED == 1)
2868 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2869 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 8U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2872 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);
2873 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);
2874 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);
2877 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2879 \brief Function: Function SPI_Data_Bits_9
2881 The function \b SPI_Data_Bits_9 verifies data exchange:
2882 - in Master Mode with default Slave Select mode
2883 - with default clock / frame format
2884 - with <b>9 data bits</b> per frame
2885 - with default bit order
2886 - at default bus speed
2887 - for default number of data items
2889 void SPI_Data_Bits_9 (void) {
2891 if (IsFormatValid() != EXIT_SUCCESS) { return; }
2892 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
2893 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2894 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2895 #if (SPI_SERVER_USED == 1)
2896 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2897 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 9U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2900 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);
2901 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);
2902 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);
2905 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2907 \brief Function: Function SPI_Data_Bits_10
2909 The function \b SPI_Data_Bits_10 verifies data exchange:
2910 - in Master Mode with default Slave Select mode
2911 - with default clock / frame format
2912 - with <b>10 data bits</b> per frame
2913 - with default bit order
2914 - at default bus speed
2915 - for default number of data items
2917 void SPI_Data_Bits_10 (void) {
2919 if (IsFormatValid() != EXIT_SUCCESS) { return; }
2920 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
2921 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2922 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2923 #if (SPI_SERVER_USED == 1)
2924 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2925 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 10U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2928 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);
2929 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);
2930 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);
2933 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2935 \brief Function: Function SPI_Data_Bits_11
2937 The function \b SPI_Data_Bits_11 verifies data exchange:
2938 - in Master Mode with default Slave Select mode
2939 - with default clock / frame format
2940 - with <b>11 data bits</b> per frame
2941 - with default bit order
2942 - at default bus speed
2943 - for default number of data items
2945 void SPI_Data_Bits_11 (void) {
2947 if (IsFormatValid() != EXIT_SUCCESS) { return; }
2948 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
2949 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2950 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2951 #if (SPI_SERVER_USED == 1)
2952 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2953 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 11U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2956 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);
2957 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);
2958 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);
2961 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2963 \brief Function: Function SPI_Data_Bits_12
2965 The function \b SPI_Data_Bits_12 verifies data exchange:
2966 - in Master Mode with default Slave Select mode
2967 - with default clock / frame format
2968 - with <b>12 data bits</b> per frame
2969 - with default bit order
2970 - at default bus speed
2971 - for default number of data items
2973 void SPI_Data_Bits_12 (void) {
2975 if (IsFormatValid() != EXIT_SUCCESS) { return; }
2976 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
2977 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2978 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2979 #if (SPI_SERVER_USED == 1)
2980 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
2981 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 12U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
2984 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);
2985 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);
2986 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);
2989 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2991 \brief Function: Function SPI_Data_Bits_13
2993 The function \b SPI_Data_Bits_13 verifies data exchange:
2994 - in Master Mode with default Slave Select mode
2995 - with default clock / frame format
2996 - with <b>13 data bits</b> per frame
2997 - with default bit order
2998 - at default bus speed
2999 - for default number of data items
3001 void SPI_Data_Bits_13 (void) {
3003 if (IsFormatValid() != EXIT_SUCCESS) { return; }
3004 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
3005 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3006 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3007 #if (SPI_SERVER_USED == 1)
3008 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3009 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 13U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3012 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);
3013 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);
3014 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);
3017 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3019 \brief Function: Function SPI_Data_Bits_14
3021 The function \b SPI_Data_Bits_14 verifies data exchange:
3022 - in Master Mode with default Slave Select mode
3023 - with default clock / frame format
3024 - with <b>14 data bits</b> per frame
3025 - with default bit order
3026 - at default bus speed
3027 - for default number of data items
3029 void SPI_Data_Bits_14 (void) {
3031 if (IsFormatValid() != EXIT_SUCCESS) { return; }
3032 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
3033 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3034 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3035 #if (SPI_SERVER_USED == 1)
3036 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3037 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 14U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3040 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);
3041 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);
3042 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);
3045 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3047 \brief Function: Function SPI_Data_Bits_15
3049 The function \b SPI_Data_Bits_15 verifies data exchange:
3050 - in Master Mode with default Slave Select mode
3051 - with default clock / frame format
3052 - with <b>15 data bits</b> per frame
3053 - with default bit order
3054 - at default bus speed
3055 - for default number of data items
3057 void SPI_Data_Bits_15 (void) {
3059 if (IsFormatValid() != EXIT_SUCCESS) { return; }
3060 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
3061 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3062 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3063 #if (SPI_SERVER_USED == 1)
3064 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3065 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 15U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3068 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);
3069 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);
3070 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);
3073 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3075 \brief Function: Function SPI_Data_Bits_16
3077 The function \b SPI_Data_Bits_16 verifies data exchange:
3078 - in Master Mode with default Slave Select mode
3079 - with default clock / frame format
3080 - with <b>16 data bits</b> per frame
3081 - with default bit order
3082 - at default bus speed
3083 - for default number of data items
3085 void SPI_Data_Bits_16 (void) {
3087 if (IsFormatValid() != EXIT_SUCCESS) { return; }
3088 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
3089 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3090 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3091 #if (SPI_SERVER_USED == 1)
3092 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3093 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 16U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3096 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);
3097 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);
3098 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);
3101 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3103 \brief Function: Function SPI_Data_Bits_17
3105 The function \b SPI_Data_Bits_17 verifies data exchange:
3106 - in Master Mode with default Slave Select mode
3107 - with default clock / frame format
3108 - with <b>17 data bits</b> per frame
3109 - with default bit order
3110 - at default bus speed
3111 - for default number of data items
3113 void SPI_Data_Bits_17 (void) {
3115 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3116 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3117 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3118 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3119 #if (SPI_SERVER_USED == 1)
3120 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3121 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 17U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3124 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);
3125 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);
3126 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);
3129 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3131 \brief Function: Function SPI_Data_Bits_18
3133 The function \b SPI_Data_Bits_18 verifies data exchange:
3134 - in Master Mode with default Slave Select mode
3135 - with default clock / frame format
3136 - with <b>18 data bits</b> per frame
3137 - with default bit order
3138 - at default bus speed
3139 - for default number of data items
3141 void SPI_Data_Bits_18 (void) {
3143 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3144 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3145 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3146 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3147 #if (SPI_SERVER_USED == 1)
3148 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3149 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 18U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3152 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);
3153 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);
3154 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);
3157 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3159 \brief Function: Function SPI_Data_Bits_19
3161 The function \b SPI_Data_Bits_19 verifies data exchange:
3162 - in Master Mode with default Slave Select mode
3163 - with default clock / frame format
3164 - with <b>19 data bits</b> per frame
3165 - with default bit order
3166 - at default bus speed
3167 - for default number of data items
3169 void SPI_Data_Bits_19 (void) {
3171 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3172 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3173 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3174 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3175 #if (SPI_SERVER_USED == 1)
3176 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3177 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 19U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3180 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);
3181 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);
3182 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);
3185 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3187 \brief Function: Function SPI_Data_Bits_20
3189 The function \b SPI_Data_Bits_20 verifies data exchange:
3190 - in Master Mode with default Slave Select mode
3191 - with default clock / frame format
3192 - with <b>20 data bits</b> per frame
3193 - with default bit order
3194 - at default bus speed
3195 - for default number of data items
3197 void SPI_Data_Bits_20 (void) {
3199 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3200 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3201 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3202 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3203 #if (SPI_SERVER_USED == 1)
3204 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3205 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 20U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3208 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);
3209 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);
3210 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);
3213 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3215 \brief Function: Function SPI_Data_Bits_21
3217 The function \b SPI_Data_Bits_21 verifies data exchange:
3218 - in Master Mode with default Slave Select mode
3219 - with default clock / frame format
3220 - with <b>21 data bits</b> per frame
3221 - with default bit order
3222 - at default bus speed
3223 - for default number of data items
3225 void SPI_Data_Bits_21 (void) {
3227 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3228 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3229 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3230 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3231 #if (SPI_SERVER_USED == 1)
3232 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3233 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 21U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3236 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);
3237 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);
3238 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);
3241 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3243 \brief Function: Function SPI_Data_Bits_22
3245 The function \b SPI_Data_Bits_22 verifies data exchange:
3246 - in Master Mode with default Slave Select mode
3247 - with default clock / frame format
3248 - with <b>22 data bits</b> per frame
3249 - with default bit order
3250 - at default bus speed
3251 - for default number of data items
3253 void SPI_Data_Bits_22 (void) {
3255 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3256 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3257 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3258 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3259 #if (SPI_SERVER_USED == 1)
3260 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3261 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 22U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3264 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);
3265 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);
3266 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);
3269 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3271 \brief Function: Function SPI_Data_Bits_23
3273 The function \b SPI_Data_Bits_23 verifies data exchange:
3274 - in Master Mode with default Slave Select mode
3275 - with default clock / frame format
3276 - with <b>23 data bits</b> per frame
3277 - with default bit order
3278 - at default bus speed
3279 - for default number of data items
3281 void SPI_Data_Bits_23 (void) {
3283 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3284 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3285 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3286 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3287 #if (SPI_SERVER_USED == 1)
3288 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3289 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 23U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3292 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);
3293 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);
3294 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);
3297 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3299 \brief Function: Function SPI_Data_Bits_24
3301 The function \b SPI_Data_Bits_24 verifies data exchange:
3302 - in Master Mode with default Slave Select mode
3303 - with default clock / frame format
3304 - with <b>24 data bits</b> per frame
3305 - with default bit order
3306 - at default bus speed
3307 - for default number of data items
3309 void SPI_Data_Bits_24 (void) {
3311 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3312 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3313 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3314 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3315 #if (SPI_SERVER_USED == 1)
3316 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3317 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 24U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3320 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);
3321 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);
3322 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);
3325 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3327 \brief Function: Function SPI_Data_Bits_25
3329 The function \b SPI_Data_Bits_25 verifies data exchange:
3330 - in Master Mode with default Slave Select mode
3331 - with default clock / frame format
3332 - with <b>25 data bits</b> per frame
3333 - with default bit order
3334 - at default bus speed
3335 - for default number of data items
3337 void SPI_Data_Bits_25 (void) {
3339 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3340 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3341 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3342 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3343 #if (SPI_SERVER_USED == 1)
3344 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3345 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 25U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3348 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);
3349 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);
3350 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);
3353 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3355 \brief Function: Function SPI_Data_Bits_26
3357 The function \b SPI_Data_Bits_26 verifies data exchange:
3358 - in Master Mode with default Slave Select mode
3359 - with default clock / frame format
3360 - with <b>26 data bits</b> per frame
3361 - with default bit order
3362 - at default bus speed
3363 - for default number of data items
3365 void SPI_Data_Bits_26 (void) {
3367 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3368 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3369 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3370 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3371 #if (SPI_SERVER_USED == 1)
3372 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3373 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 26U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3376 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);
3377 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);
3378 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);
3381 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3383 \brief Function: Function SPI_Data_Bits_27
3385 The function \b SPI_Data_Bits_27 verifies data exchange:
3386 - in Master Mode with default Slave Select mode
3387 - with default clock / frame format
3388 - with <b>27 data bits</b> per frame
3389 - with default bit order
3390 - at default bus speed
3391 - for default number of data items
3393 void SPI_Data_Bits_27 (void) {
3395 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3396 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3397 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3398 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3399 #if (SPI_SERVER_USED == 1)
3400 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3401 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 27U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3404 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);
3405 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);
3406 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);
3409 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3411 \brief Function: Function SPI_Data_Bits_28
3413 The function \b SPI_Data_Bits_28 verifies data exchange:
3414 - in Master Mode with default Slave Select mode
3415 - with default clock / frame format
3416 - with <b>28 data bits</b> per frame
3417 - with default bit order
3418 - at default bus speed
3419 - for default number of data items
3421 void SPI_Data_Bits_28 (void) {
3423 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3424 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3425 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3426 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3427 #if (SPI_SERVER_USED == 1)
3428 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3429 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 28U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3432 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);
3433 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);
3434 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);
3437 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3439 \brief Function: Function SPI_Data_Bits_29
3441 The function \b SPI_Data_Bits_29 verifies data exchange:
3442 - in Master Mode with default Slave Select mode
3443 - with default clock / frame format
3444 - with <b>29 data bits</b> per frame
3445 - with default bit order
3446 - at default bus speed
3447 - for default number of data items
3449 void SPI_Data_Bits_29 (void) {
3451 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3452 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3453 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3454 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3455 #if (SPI_SERVER_USED == 1)
3456 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3457 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 29U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3460 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);
3461 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);
3462 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);
3465 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3467 \brief Function: Function SPI_Data_Bits_30
3469 The function \b SPI_Data_Bits_30 verifies data exchange:
3470 - in Master Mode with default Slave Select mode
3471 - with default clock / frame format
3472 - with <b>30 data bits</b> per frame
3473 - with default bit order
3474 - at default bus speed
3475 - for default number of data items
3477 void SPI_Data_Bits_30 (void) {
3479 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3480 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3481 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3482 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3483 #if (SPI_SERVER_USED == 1)
3484 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3485 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 30U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3488 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);
3489 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);
3490 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);
3493 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3495 \brief Function: Function SPI_Data_Bits_31
3497 The function \b SPI_Data_Bits_31 verifies data exchange:
3498 - in Master Mode with default Slave Select mode
3499 - with default clock / frame format
3500 - with <b>31 data bits</b> per frame
3501 - with default bit order
3502 - at default bus speed
3503 - for default number of data items
3505 void SPI_Data_Bits_31 (void) {
3507 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3508 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3509 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3510 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3511 #if (SPI_SERVER_USED == 1)
3512 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3513 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 31U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3516 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);
3517 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);
3518 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);
3521 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3523 \brief Function: Function SPI_Data_Bits_32
3525 The function \b SPI_Data_Bits_32 verifies data exchange:
3526 - in Master Mode with default Slave Select mode
3527 - with default clock / frame format
3528 - with <b>32 data bits</b> per frame
3529 - with default bit order
3530 - at default bus speed
3531 - for default number of data items
3533 void SPI_Data_Bits_32 (void) {
3535 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3536 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3537 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3538 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3539 #if (SPI_SERVER_USED == 1)
3540 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3541 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, 32U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3544 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);
3545 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);
3546 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);
3549 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3551 \brief Function: Function SPI_Bit_Order_MSB_LSB
3553 The function \b SPI_Bit_Order_MSB_LSB 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 bit order <b>from MSB to LSB</b>
3558 - at default bus speed
3559 - for default number of data items
3561 \note In Test Mode <b>Loopback</b> this test is not executed
3563 void SPI_Bit_Order_MSB_LSB (void) {
3565 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
3566 if (IsFormatValid() != EXIT_SUCCESS) { return; }
3567 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3568 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3569 #if (SPI_SERVER_USED == 1)
3570 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3571 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3574 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);
3575 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);
3576 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);
3579 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3581 \brief Function: Function SPI_Bit_Order_LSB_MSB
3583 The function \b SPI_Bit_Order_LSB_MSB verifies data exchange:
3584 - in Master Mode with default Slave Select mode
3585 - with default clock / frame format
3586 - with default data bits
3587 - with bit order <b>from LSB to MSB</b>
3588 - at default bus speed
3589 - for default number of data items
3591 \note In Test Mode <b>Loopback</b> this test is not executed
3593 void SPI_Bit_Order_LSB_MSB (void) {
3595 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
3596 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3597 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3598 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3599 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3600 #if (SPI_SERVER_USED == 1)
3601 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3602 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_LSB_TO_MSB, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3605 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);
3606 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);
3607 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);
3610 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3612 \brief Function: Function SPI_Bus_Speed_Min
3614 The function \b SPI_Bus_Speed_Min verifies data exchange:
3615 - in Master Mode with default Slave Select mode
3616 - with default clock / frame format
3617 - with default data bits
3618 - with default bit order
3619 - at <b>minimum bus speed</b> (define <c>SPI_CFG_MIN_BUS_SPEED</c> in DV_SPI_Config.h)
3620 - for default number of data items
3622 This test function checks the following requirements:
3623 - measured bus speed is not 25% lower, or higher than requested
3624 - bus speed value returned by the driver is not negative
3625 - bus speed value returned by the driver is not higher then requested
3626 - bus speed value returned by the driver is not lower then 75% of requested
3628 void SPI_Bus_Speed_Min (void) {
3629 volatile uint64_t bps;
3630 volatile int32_t ret_bus_speed;
3632 if (IsFormatValid() != EXIT_SUCCESS) { return; }
3633 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
3634 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3635 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3636 #if (SPI_SERVER_USED == 1)
3637 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3638 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_MIN_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3641 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);
3642 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);
3643 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);
3645 if (duration != 0xFFFFFFFFU) { // If Transfer finished before timeout
3646 if (duration != 0U) { // If duration of transfer was more than 0 SysTick counts
3647 bps = ((uint64_t)systick_freq * SPI_CFG_DEF_DATA_BITS * SPI_CFG_DEF_NUM) / duration;
3648 if ((bps < ((SPI_CFG_MIN_BUS_SPEED * 3) / 4)) ||
3649 (bps > SPI_CFG_MIN_BUS_SPEED)) {
3650 // If measured bus speed is 25% lower, or higher than requested
3651 (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);
3652 TEST_MESSAGE(msg_buf);
3657 drv->Control (ARM_SPI_SET_BUS_SPEED, SPI_CFG_MIN_BUS_SPEED);
3658 ret_bus_speed = drv->Control (ARM_SPI_GET_BUS_SPEED, 0U);
3659 if (ret_bus_speed < 0) {
3660 // If bus speed value returned by the driver is negative
3661 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned negative value %i", ret_bus_speed);
3662 TEST_FAIL_MESSAGE(msg_buf);
3663 } else if ((uint32_t)ret_bus_speed > SPI_CFG_MIN_BUS_SPEED) {
3664 // If bus speed value returned by the driver is higher then requested
3665 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned %i bps instead of requested %i bps", ret_bus_speed, SPI_CFG_MIN_BUS_SPEED);
3666 TEST_FAIL_MESSAGE(msg_buf);
3667 } else if ((uint32_t)ret_bus_speed < ((SPI_CFG_MIN_BUS_SPEED * 3) / 4)) {
3668 // If bus speed value returned by the driver is lower then 75% of requested
3669 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] Get bus speed returned %i bps instead of requested %i bps", ret_bus_speed, SPI_CFG_MIN_BUS_SPEED);
3670 TEST_MESSAGE(msg_buf);
3674 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3676 \brief Function: Function SPI_Bus_Speed_Max
3678 The function \b SPI_Bus_Speed_Max verifies data exchange:
3679 - in Master Mode with default Slave Select mode
3680 - with default clock / frame format
3681 - with default data bits
3682 - with default bit order
3683 - at <b>maximum bus speed</b> (define <c>SPI_CFG_MAX_BUS_SPEED</c> in DV_SPI_Config.h)
3684 - for default number of data items
3686 This test function checks the following requirements:
3687 - measured bus speed is not 25% lower, or higher than requested
3688 - bus speed value returned by the driver is not negative
3689 - bus speed value returned by the driver is not higher then requested
3690 - bus speed value returned by the driver is not lower then 75% of requested
3692 void SPI_Bus_Speed_Max (void) {
3693 volatile uint64_t bps;
3694 volatile int32_t ret_bus_speed;
3696 if (IsFormatValid() != EXIT_SUCCESS) { return; }
3697 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
3698 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3699 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3700 #if (SPI_SERVER_USED == 1)
3701 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3702 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_MAX_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3705 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);
3706 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);
3707 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);
3709 if (duration != 0xFFFFFFFFU) { // If Transfer finished before timeout
3710 if (duration != 0U) { // If duration of transfer was more than 0 SysTick counts
3711 bps = ((uint64_t)systick_freq * SPI_CFG_DEF_DATA_BITS * SPI_CFG_DEF_NUM) / duration;
3712 if ((bps < ((SPI_CFG_MAX_BUS_SPEED * 3) / 4)) ||
3713 (bps > SPI_CFG_MAX_BUS_SPEED)) {
3714 // If measured bus speed is 25% lower, or higher than requested
3715 (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);
3716 TEST_MESSAGE(msg_buf);
3721 drv->Control (ARM_SPI_SET_BUS_SPEED, SPI_CFG_MAX_BUS_SPEED);
3722 ret_bus_speed = drv->Control (ARM_SPI_GET_BUS_SPEED, 0U);
3723 if (ret_bus_speed < 0) {
3724 // If bus speed value returned by the driver is negative
3725 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned negative value %i", ret_bus_speed);
3726 TEST_FAIL_MESSAGE(msg_buf);
3727 } else if ((uint32_t)ret_bus_speed > SPI_CFG_MAX_BUS_SPEED) {
3728 // If bus speed value returned by the driver is higher then requested
3729 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned %i bps instead of requested %i bps", ret_bus_speed, SPI_CFG_MAX_BUS_SPEED);
3730 TEST_FAIL_MESSAGE(msg_buf);
3731 } else if ((uint32_t)ret_bus_speed < ((SPI_CFG_MAX_BUS_SPEED * 3) / 4)) {
3732 // If bus speed value returned by the driver is lower then 75% of requested
3733 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] Get bus speed returned %i bps instead of requested %i bps", ret_bus_speed, SPI_CFG_MAX_BUS_SPEED);
3734 TEST_MESSAGE(msg_buf);
3738 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3740 \brief Function: Function SPI_Number_Of_Items
3742 The function \b SPI_Number_Of_Items verifies data exchange:
3743 - in Master Mode with default Slave Select mode
3744 - with default clock / frame format
3745 - with default data bits
3746 - with default bit order
3747 - at default bus speed
3748 - for <b>different number of items</b> (defines <c>SPI_CFG_NUM1 .. SPI_CFG_NUM5</c> in DV_SPI_Config.h)
3750 void SPI_Number_Of_Items (void) {
3752 if (IsFormatValid() != EXIT_SUCCESS) { return; }
3753 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
3754 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3755 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3756 #if (SPI_SERVER_USED == 1)
3757 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3758 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3761 #if (SPI_CFG_NUM1 != 0U)
3762 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM1);
3763 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM1);
3764 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM1);
3767 #if (SPI_CFG_NUM2 != 0U)
3768 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM2);
3769 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM2);
3770 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM2);
3773 #if (SPI_CFG_NUM3 != 0U)
3774 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM3);
3775 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM3);
3776 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM3);
3779 #if (SPI_CFG_NUM4 != 0U)
3780 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM4);
3781 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM4);
3782 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM4);
3785 #if (SPI_CFG_NUM5 != 0U)
3786 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM5);
3787 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM5);
3788 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM5);
3792 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3794 \brief Function: Function SPI_GetDataCount
3796 The function \b SPI_GetDataCount verifies \b GetDataCount function (count changing) during data exchange:
3797 - in Master Mode with default Slave Select mode
3798 - with default clock / frame format
3799 - with default data bits
3800 - with default bit order
3801 - at default bus speed
3803 void SPI_GetDataCount (void) {
3805 if (IsFormatValid() != EXIT_SUCCESS) { return; }
3806 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
3807 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3808 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3809 #if (SPI_SERVER_USED == 1)
3810 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3811 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3814 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3815 TEST_ASSERT_MESSAGE((data_count_sample != 0U) && (data_count_sample != SPI_CFG_DEF_NUM), "[FAILED] GetDataCount was not changing during the Send!");
3817 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3818 TEST_ASSERT_MESSAGE((data_count_sample != 0U) && (data_count_sample != SPI_CFG_DEF_NUM), "[FAILED] GetDataCount was not changing during the Receive!");
3820 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3821 TEST_ASSERT_MESSAGE((data_count_sample != 0U) && (data_count_sample != SPI_CFG_DEF_NUM), "[FAILED] GetDataCount was not changing during the Transfer!");
3824 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3826 \brief Function: Function SPI_Abort
3828 The function \b SPI_Abort verifies \b Abort function abort of data exchange:
3829 - in Master Mode with default Slave Select mode
3830 - with default clock / frame format
3831 - with default data bits
3832 - with default bit order
3833 - at default bus speed
3835 void SPI_Abort (void) {
3837 if (IsFormatValid() != EXIT_SUCCESS) { return; }
3838 if (IsBitOrderValid() != EXIT_SUCCESS) { return; }
3839 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3840 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3841 #if (SPI_SERVER_USED == 1)
3842 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3843 if (ServerCheckSupport(MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3846 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);
3847 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);
3848 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);
3854 // End of spi_tests_data_xchg
3856 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3857 /* SPI Event tests */
3858 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3860 \defgroup spi_tests_evt Event
3863 These tests verify API and operation of the SPI event signaling, except ARM_SPI_EVENT_TRANSFER_COMPLETE
3864 signal which is tested in the Data Exchange tests.
3866 The event tests verify the following driver function
3867 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
3870 void (*ARM_SPI_SignalEvent_t) (uint32_t event);
3873 \note In Test Mode <b>Loopback</b> these tests are not executed
3877 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3879 \brief Function: Function SPI_DataLost
3881 The function \b SPI_DataLost verifies signaling of the <b>ARM_SPI_EVENT_DATA_LOST</b> event:
3882 - in <b>Slave Mode</b> with <b>Slave Select line Hardware monitored</b>
3883 - with default clock / frame format
3884 - with default data bits
3885 - with default bit order
3886 - at default bus speed
3888 it also checks that status data_lost flag was activated.
3890 void SPI_DataLost (void) {
3892 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
3893 if (IsFormatValid() != EXIT_SUCCESS) { return; }
3894 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3895 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3896 #if (SPI_SERVER_USED == 1)
3897 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3898 if (ServerCheckSupport(MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3901 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; }
3902 if (CmdXfer (1U, 8U, 8U, SPI_CFG_XFER_TIMEOUT) != EXIT_SUCCESS) { break; }
3903 drv->Control (ARM_SPI_MODE_INACTIVE, 0U);
3907 (void)drv->Control (ARM_SPI_MODE_SLAVE |
3908 ((SPI_CFG_DEF_FORMAT << ARM_SPI_FRAME_FORMAT_Pos) & ARM_SPI_FRAME_FORMAT_Msk) |
3909 ((SPI_CFG_DEF_DATA_BITS << ARM_SPI_DATA_BITS_Pos) & ARM_SPI_DATA_BITS_Msk) |
3910 ((SPI_CFG_DEF_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos) & ARM_SPI_BIT_ORDER_Msk) |
3911 ARM_SPI_SS_SLAVE_HW ,
3914 (void)osDelay(SPI_CFG_XFER_TIMEOUT+20U); // Wait for SPI Server to timeout
3916 (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
3917 (void)osDelay(20U); // Wait for SPI Server to start reception of next command
3919 // Assert that event ARM_SPI_EVENT_DATA_LOST was signaled
3920 TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_DATA_LOST) != 0U, "[FAILED] Event ARM_SPI_EVENT_DATA_LOST was not signaled!");
3922 // Assert that status data_lost flag is active
3923 TEST_ASSERT_MESSAGE(drv->GetStatus().data_lost != 0U, "[FAILED] Status data_lost flag was not activated!");
3930 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3932 \brief Function: Function SPI_ModeFault
3934 The function \b SPI_ModeFault verifies signaling of the <b>ARM_SPI_EVENT_MODE_FAULT</b> event:
3935 - in <b>Master Mode</b> with <b>Slave Select line Hardware monitored Input</b>
3936 - with default clock / frame format
3937 - with default data bits
3938 - with default bit order
3939 - at default bus speed
3941 it also checks that status mode_fault flag was activated.
3943 void SPI_ModeFault (void) {
3945 if (IsNotLoopback() != EXIT_SUCCESS) { return; }
3946 if (IsNotFrameTI() != EXIT_SUCCESS) { return; }
3947 if (IsNotFrameMw() != EXIT_SUCCESS) { return; }
3948 if (DriverInit() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3949 if (BuffersCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3950 #if (SPI_SERVER_USED == 1)
3951 if (ServerCheck() != EXIT_SUCCESS) { TEST_FAIL(); return; }
3952 if (ServerCheckSupport(MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { TEST_FAIL(); return; }
3955 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; }
3956 if (CmdXfer (1U, 8U, 8U, SPI_CFG_XFER_TIMEOUT) != EXIT_SUCCESS) { break; }
3957 drv->Control (ARM_SPI_MODE_INACTIVE, 0U);
3961 (void)drv->Control (ARM_SPI_MODE_MASTER |
3962 ((SPI_CFG_DEF_FORMAT << ARM_SPI_FRAME_FORMAT_Pos) & ARM_SPI_FRAME_FORMAT_Msk) |
3963 ((SPI_CFG_DEF_DATA_BITS << ARM_SPI_DATA_BITS_Pos) & ARM_SPI_DATA_BITS_Msk) |
3964 ((SPI_CFG_DEF_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos) & ARM_SPI_BIT_ORDER_Msk) |
3965 ARM_SPI_SS_MASTER_HW_INPUT ,
3966 SPI_CFG_DEF_BUS_SPEED);
3968 (void)osDelay(SPI_CFG_XFER_TIMEOUT+20U); // Wait for SPI Server to timeout
3970 (void)drv->Control(ARM_SPI_MODE_INACTIVE, 0U);
3971 (void)osDelay(20U); // Wait for SPI Server to start reception of next command
3973 // Assert that event ARM_SPI_EVENT_MODE_FAULT was signaled
3974 TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_MODE_FAULT) != 0U, "[FAILED] Event ARM_SPI_EVENT_MODE_FAULT was not signaled!");
3976 // Assert that status mode_fault flag is active
3977 TEST_ASSERT_MESSAGE(drv->GetStatus().mode_fault != 0U, "[FAILED] Status mode_fault flag was not activated!");
3987 // End of spi_tests_evt