2 * Copyright (c) 2015-2020 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 #define CMD_LEN 32UL // Length of command to SPI Server
39 #define RESP_GET_VER_LEN 16UL // Length of response from SPI Server to GET VER command
40 #define RESP_GET_CAP_LEN 32UL // Length of response from SPI Server to GET CAP command
41 #define RESP_GET_CNT_LEN 16UL // Length of response from SPI Server to GET CNT command
43 #define OP_SEND 0UL // Send operation
44 #define OP_RECEIVE 1UL // Receive operation
45 #define OP_TRANSFER 2UL // Transfer operation
46 #define OP_ABORT_SEND 3UL // Abort send operation
47 #define OP_ABORT_RECEIVE 4UL // Abort receive operation
48 #define OP_ABORT_TRANSFER 5UL // Abort transfer operation
50 #define MODE_INACTIVE 0UL // Inactive mode
51 #define MODE_MASTER 1UL // Master mode
52 #define MODE_SLAVE 2UL // Slave mode
53 #define SS_MODE_MASTER_UNUSED 0UL // Master mode Slave Select unused
54 #define SS_MODE_MASTER_SW 1UL // Master mode Slave Select software controlled
55 #define SS_MODE_MASTER_HW_OUTPUT 2UL // Master mode Slave Select hardware controlled output
56 #define SS_MODE_MASTER_HW_INPUT 3UL // Master mode Slave Select hardware monitored input
57 #define SS_MODE_SLAVE_HW 0UL // Slave mode Slave Select hardware monitored
58 #define SS_MODE_SLAVE_SW 1UL // Slave mode Slave Select software controlled
59 #define FORMAT_CPOL0_CPHA0 0UL // Clock Format: Polarity 0, Phase 0
60 #define FORMAT_CPOL0_CPHA1 1UL // Clock Format: Polarity 0, Phase 1
61 #define FORMAT_CPOL1_CPHA0 2UL // Clock Format: Polarity 1, Phase 0
62 #define FORMAT_CPOL1_CPHA1 3UL // Clock Format: Polarity 1, Phase 1
63 #define FORMAT_TI 4UL // Frame Format: Texas Instruments
64 #define FORMAT_MICROWIRE 5UL // Frame Format: National Semiconductor Microwire
65 #define BO_MSB_TO_LSB 0UL // Bit Order MSB to LSB
66 #define BO_LSB_TO_MSB 1UL // Bit Order LSB to MSB
68 // Testing Configuration definitions
69 #if (SPI_CFG_TEST_MODE != 0)
70 #define SPI_SERVER_USED 1
72 #define SPI_SERVER_USED 0
75 // Determine maximum number of items used for testing
76 #if (SPI_CFG_DEF_NUM == 0)
77 #error Default number of items to test must not be 0!
80 #define SPI_NUM_MAX SPI_CFG_DEF_NUM
81 #if (SPI_CFG_NUM1 > SPI_NUM_MAX)
83 #define SPI_NUM_MAX SPI_CFG_NUM1
85 #if (SPI_CFG_NUM2 > SPI_NUM_MAX)
87 #define SPI_NUM_MAX SPI_CFG_NUM2
89 #if (SPI_CFG_NUM3 > SPI_NUM_MAX)
91 #define SPI_NUM_MAX SPI_CFG_NUM3
93 #if (SPI_CFG_NUM4 > SPI_NUM_MAX)
95 #define SPI_NUM_MAX SPI_CFG_NUM4
97 #if (SPI_CFG_NUM5 > SPI_NUM_MAX)
99 #define SPI_NUM_MAX SPI_CFG_NUM5
102 // Calculate maximum required buffer size
103 #if ((SPI_CFG_DEF_DATA_BITS > 16) || ((SPI_TC_DATA_BIT_EN_MASK & 0xFFFF0000UL) != 0U))
104 #define SPI_BUF_MAX (SPI_NUM_MAX * 4U)
105 #elif ((SPI_CFG_DEF_DATA_BITS > 8) || ((SPI_TC_DATA_BIT_EN_MASK & 0x0000FF00UL) != 0U))
106 #define SPI_BUF_MAX (SPI_NUM_MAX * 2U)
108 #define SPI_BUF_MAX (SPI_NUM_MAX)
110 #if (SPI_SERVER_USED == 1)
111 // If selected Test Mode is SPI Server take into account SPI Server data bit settings
112 #if ((SPI_CFG_SRV_DATA_BITS > 16) && (SPI_BUF_MAX < (SPI_NUM_MAX * 4U)))
114 #define SPI_BUF_MAX (SPI_NUM_MAX * 4U)
115 #elif ((SPI_CFG_SRV_DATA_BITS > 8) && (SPI_BUF_MAX < (SPI_NUM_MAX * 2U)))
117 #define SPI_BUF_MAX (SPI_NUM_MAX * 2U)
122 typedef struct { // SPI Server version structure
123 uint8_t major; // Version major number
124 uint8_t minor; // Version minor number
125 uint16_t patch; // Version patch (revision) number
128 typedef struct { // SPI Server capabilities structure
129 uint32_t mode_mask; // Mode and Slave Select mask
130 uint32_t fmt_mask; // Clock Format or Frame Format mask
131 uint32_t db_mask; // Data Bits mask
132 uint32_t bo_mask; // Bit Order mask
133 uint32_t bs_min; // Min bus speed
134 uint32_t bs_max; // Max bus speed
137 // Register Driver_SPI#
138 #define _ARM_Driver_SPI_(n) Driver_SPI##n
139 #define ARM_Driver_SPI_(n) _ARM_Driver_SPI_(n)
140 extern ARM_DRIVER_SPI ARM_Driver_SPI_(DRV_SPI);
141 static ARM_DRIVER_SPI *drv = &ARM_Driver_SPI_(DRV_SPI);
143 // Global variables (used in this module only)
144 static int8_t buffers_ok;
145 static int8_t server_ok;
146 static int8_t driver_ok;
148 static SPI_SERV_CAP_t spi_serv_cap;
150 static volatile uint32_t event;
151 static volatile uint32_t duration;
152 static uint32_t systick_freq;
154 static char msg_buf [256];
156 // Allocated buffer pointers
157 static void *ptr_tx_buf_alloc;
158 static void *ptr_rx_buf_alloc;
159 static void *ptr_cmp_buf_alloc;
161 // Buffer pointers used for data transfers (must be aligned to 4 byte)
162 static uint8_t *ptr_tx_buf;
163 static uint8_t *ptr_rx_buf;
164 static uint8_t *ptr_cmp_buf;
166 // String representation of Driver codes
167 static const char *str_oper[] = {
176 static const char *str_ret[] = {
179 "ARM_DRIVER_ERROR_BUSY",
180 "ARM_DRIVER_ERROR_TIMEOUT",
181 "ARM_DRIVER_ERROR_UNSUPPORTED",
182 "ARM_DRIVER_ERROR_PARAMETER",
183 "ARM_DRIVER_ERROR_SPECIFIC"
184 "ARM_SPI_ERROR_MODE",
185 "ARM_SPI_ERROR_FRAME_FORMAT",
186 "ARM_SPI_ERROR_DATA_BITS",
187 "ARM_SPI_ERROR_BIT_ORDER",
188 "ARM_SPI_ERROR_SS_MODE"
192 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
193 static int32_t ComConfigDefault (void);
194 static int32_t ComSendCommand (const void *data_out, uint32_t len);
195 static int32_t ComReceiveResponse ( void *data_in, uint32_t len);
197 static int32_t CmdGetVer (void);
198 static int32_t CmdGetCap (void);
199 static int32_t CmdSetBufTx (char pattern);
200 static int32_t CmdSetBufRx (char pattern);
201 static int32_t CmdGetBufRx (uint32_t len);
202 static int32_t CmdSetCom (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed);
203 static int32_t CmdXfer (uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_ss);
204 static int32_t CheckServer (void);
207 static uint32_t DataBitsToBytes (uint32_t data_bits);
208 static int32_t InitDriver (void);
209 static int32_t CheckBuffers (void);
211 static void SPI_DataExchange_Operation (uint32_t operation, uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed, uint32_t num);
216 \fn void SPI_DrvEvent (uint32_t evt)
217 \brief Store event into global variable.
218 \detail This is a callback function called by the driver upon an event.
219 \param[in] evt SPI event
222 static void SPI_DrvEvent (uint32_t evt) {
227 \fn static uint32_t DataBitsToBytes (uint32_t data_bits)
228 \brief Calculate number of bytes used for an item at required data bits.
229 \return number of bytes per item
231 static uint32_t DataBitsToBytes (uint32_t data_bits) {
234 if (data_bits > 16U) {
236 } else if (data_bits > 8U) {
246 \fn static int32_t InitDriver (void)
247 \brief Initialize and power-on the driver.
248 \return execution status
249 - EXIT_SUCCESS: Operation successful
250 - EXIT_FAILURE: Operation failed
252 static int32_t InitDriver (void) {
254 if (driver_ok == -1) { // If -1, means it was not yet checked
256 if (drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK) {
257 if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
263 if (driver_ok == 1) {
267 TEST_FAIL_MESSAGE("[FAILED] SPI driver initialization or power-up failed. Test aborted!");
272 \fn static int32_t CheckBuffers (void)
273 \brief Check if buffers are valid.
274 \return execution status
275 - EXIT_SUCCESS: Operation successful
276 - EXIT_FAILURE: Operation failed
278 static int32_t CheckBuffers (void) {
280 if (buffers_ok == -1) { // If -1, means it was not yet checked
281 if ((ptr_tx_buf != NULL) &&
282 (ptr_rx_buf != NULL) &&
283 (ptr_cmp_buf != NULL)) {
290 if (buffers_ok == 1) {
294 TEST_FAIL_MESSAGE("[FAILED] Invalid data buffers! Increase heap memory! Test aborted!");
298 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
301 \fn static int32_t ComConfigDefault (void)
302 \brief Configure SPI Communication Interface to SPI Server default communication configuration.
303 \return execution status
304 - EXIT_SUCCESS: Operation successful
305 - EXIT_FAILURE: Operation failed
307 static int32_t ComConfigDefault (void) {
312 if (drv->Control(ARM_SPI_MODE_MASTER |
313 ((SPI_CFG_SRV_FORMAT << ARM_SPI_FRAME_FORMAT_Pos) & ARM_SPI_FRAME_FORMAT_Msk) |
314 ((SPI_CFG_SRV_DATA_BITS << ARM_SPI_DATA_BITS_Pos) & ARM_SPI_DATA_BITS_Msk) |
315 ((SPI_CFG_SRV_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos) & ARM_SPI_BIT_ORDER_Msk) |
316 ((SPI_CFG_SRV_SS_MODE << ARM_SPI_SS_MASTER_MODE_Pos) & ARM_SPI_SS_MASTER_MODE_Msk) ,
317 SPI_CFG_SRV_BUS_SPEED) != ARM_DRIVER_OK) {
321 if ((ret == EXIT_SUCCESS) && (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW)) {
322 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
327 if (ret != EXIT_SUCCESS) {
328 TEST_FAIL_MESSAGE("Failed to configure communication interface to SPI Server default settings. Testing aborted!");
331 // Give SPI Server 10 ms to prepare for reception of the command
338 \fn static int32_t ComSendCommand (const void *data_out, uint32_t num)
339 \brief Send command to SPI Server.
340 \param[out] data_out Pointer to memory containing data to be sent
341 \param[in] len Number of bytes to be sent
342 \return execution status
343 - EXIT_SUCCESS: Operation successful
344 - EXIT_FAILURE: Operation failed
346 static int32_t ComSendCommand (const void *data_out, uint32_t len) {
351 num = (len + DataBitsToBytes(SPI_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(SPI_CFG_SRV_DATA_BITS);
353 if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
354 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE) != ARM_DRIVER_OK) {
358 if (ret == EXIT_SUCCESS) {
359 if (drv->Send(data_out, num) == ARM_DRIVER_OK) {
360 for (tout = SPI_CFG_SRV_CMD_TOUT; tout != 0U; tout--) {
361 if ((drv->GetDataCount() == num) && (drv->GetStatus().busy == 0U)) {
366 if (tout == 0U) { // If send has timed out
373 if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
374 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
379 // Give SPI Server 10 ms to prepare for reception of the next command or to
380 // prepare the answer to this command, if it requires response
387 \fn static int32_t ComReceiveResponse (void *data_in, uint32_t num)
388 \brief Receive response from SPI Server.
389 \param[out] data_in Pointer to memory where data will be received
390 \param[in] len Number of data bytes to be received
391 \return execution status
392 - EXIT_SUCCESS: Operation successful
393 - EXIT_FAILURE: Operation failed
395 static int32_t ComReceiveResponse (void *data_in, uint32_t len) {
400 num = (len + DataBitsToBytes(SPI_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(SPI_CFG_SRV_DATA_BITS);
402 if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
403 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE) != ARM_DRIVER_OK) {
407 if (ret == EXIT_SUCCESS) {
408 if (drv->Receive(data_in, num) == ARM_DRIVER_OK) {
409 for (tout = SPI_CFG_SRV_CMD_TOUT; tout != 0U; tout--) {
410 if ((drv->GetDataCount() == num) && (drv->GetStatus().busy == 0U)) {
415 if (tout == 0U) { // If send has timed out
422 if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
423 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
428 // Give SPI Server 10 ms to prepare for reception of the next command
435 \fn static int32_t CmdGetVer (void)
436 \brief Get version from SPI Server and check that it is valid.
437 \return execution status
438 - EXIT_SUCCESS: Operation successful
439 - EXIT_FAILURE: Operation failed
441 static int32_t CmdGetVer (void) {
443 SPI_SERV_VER_t spi_serv_ver;
450 memset(&spi_serv_ver, 0, sizeof(spi_serv_ver));
452 // Send "GET VER" command to SPI Server
453 memset(ptr_tx_buf, 0, CMD_LEN);
454 memcpy(ptr_tx_buf, "GET VER", 7);
455 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
457 if (ret == EXIT_SUCCESS) {
458 // Receive response to "GET VER" command from SPI Server
459 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_VER_LEN);
460 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_VER_LEN);
464 if (ret == EXIT_SUCCESS) {
466 ptr_str = (const char *)ptr_rx_buf;
467 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
468 spi_serv_ver.major = val8;
473 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
475 ptr_str = strstr(ptr_str, "."); // Find '.'
476 if (ptr_str != NULL) {
477 ptr_str++; // Skip '.'
478 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
479 spi_serv_ver.minor = val8;
487 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
488 // Parse patch (revision)
489 ptr_str = strstr(ptr_str, "."); // Find next '.'
490 if (ptr_str != NULL) {
491 ptr_str++; // Skip '.'
492 if (sscanf(ptr_str, "%hx", &val16) == 1) {
493 spi_serv_ver.patch = val16;
502 if (ret == EXIT_SUCCESS) {
503 // Only supported version is v1.0.0
504 if ((spi_serv_ver.major != 1U) ||
505 (spi_serv_ver.minor != 0U) ||
506 (spi_serv_ver.patch != 0U)) {
511 if (ret != EXIT_SUCCESS) {
512 TEST_FAIL_MESSAGE("[FAILED] Get version from SPI Server.");
519 \fn static int32_t CmdGetCap (void)
520 \brief Get capabilities from SPI Server.
521 \return execution status
522 - EXIT_SUCCESS: Operation successful
523 - EXIT_FAILURE: Operation failed
525 static int32_t CmdGetCap (void) {
533 memset(&spi_serv_cap, 0, sizeof(spi_serv_cap));
535 // Send "GET CAP" command to SPI Server
536 memset(ptr_tx_buf, 0, RESP_GET_CAP_LEN);
537 memcpy(ptr_tx_buf, "GET CAP", 7);
538 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
540 if (ret == EXIT_SUCCESS) {
541 (void)osDelay(10U); // Give SPI Server 10 ms to auto-detect capabilities
543 // Receive response to "GET CAP" command from SPI Server
544 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_CAP_LEN);
545 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_CAP_LEN);
548 // Parse capabilities
549 if (ret == EXIT_SUCCESS) {
551 ptr_str = (const char *)ptr_rx_buf;
552 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
553 spi_serv_cap.mode_mask = val8;
558 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
560 ptr_str = strstr(ptr_str, ","); // Find ','
561 if (ptr_str != NULL) {
562 ptr_str++; // Skip ','
563 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
564 spi_serv_cap.fmt_mask = (uint32_t)val8;
572 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
573 // Parse data bit mask
574 ptr_str = strstr(ptr_str, ","); // Find next ','
575 if (ptr_str != NULL) {
576 ptr_str++; // Skip ','
577 if (sscanf(ptr_str, "%x", &val32) == 1) {
578 spi_serv_cap.db_mask = val32;
586 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
587 // Parse bit order mask
588 ptr_str = strstr(ptr_str, ","); // Find next ','
589 if (ptr_str != NULL) {
590 ptr_str++; // Skip ','
591 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
592 spi_serv_cap.bo_mask = (uint32_t)val8;
600 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
601 // Parse minimum bus speed
602 ptr_str = strstr(ptr_str, ","); // Find next ','
603 if (ptr_str != NULL) {
604 ptr_str++; // Skip ','
605 if (sscanf(ptr_str, "%u", &val32) == 1) {
606 spi_serv_cap.bs_min = val32 * 1000U;
614 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
615 // Parse maximum bus speed
616 ptr_str = strstr(ptr_str, ","); // Find next ','
617 if (ptr_str != NULL) {
618 ptr_str++; // Skip ','
619 if (sscanf(ptr_str, "%u", &val32) == 1) {
620 spi_serv_cap.bs_max = val32 * 1000U;
629 if (ret != EXIT_SUCCESS) {
630 TEST_FAIL_MESSAGE("[FAILED] Get capabilities from SPI Server.");
637 \fn static int32_t CmdSetBufTx (char pattern)
638 \brief Set Tx buffer of SPI Server to pattern.
639 \param[in] pattern Pattern to fill the buffer with
640 \return execution status
641 - EXIT_SUCCESS: Operation successful
642 - EXIT_FAILURE: Operation failed
644 static int32_t CmdSetBufTx (char pattern) {
647 // Send "SET BUF TX" command to SPI Server
648 memset(ptr_tx_buf, 0, 32);
649 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF TX,0,%02X", (int32_t)pattern);
650 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
652 if (ret != EXIT_SUCCESS) {
653 TEST_FAIL_MESSAGE("[FAILED] Set Tx buffer on SPI Server.");
660 \fn static int32_t CmdSetBufRx (char pattern)
661 \brief Set Rx buffer of SPI Server to pattern.
662 \param[in] pattern Pattern to fill the buffer with
663 \return execution status
664 - EXIT_SUCCESS: Operation successful
665 - EXIT_FAILURE: Operation failed
667 static int32_t CmdSetBufRx (char pattern) {
670 // Send "SET BUF RX" command to SPI Server
671 memset(ptr_tx_buf, 0, 32);
672 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF RX,0,%02X", (int32_t)pattern);
673 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
675 if (ret != EXIT_SUCCESS) {
676 TEST_FAIL_MESSAGE("[FAILED] Set Rx buffer on SPI Server.");
683 \fn static int32_t CmdGetBufRx (void)
684 \brief Get Rx buffer from SPI Server (into global array pointed to by ptr_rx_buf).
685 \param[in] len Number of bytes to read from Rx buffer
686 \return execution status
687 - EXIT_SUCCESS: Operation successful
688 - EXIT_FAILURE: Operation failed
690 static int32_t CmdGetBufRx (uint32_t len) {
693 // Send "GET BUF RX" command to SPI Server
694 memset(ptr_tx_buf, 0, 32);
695 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "GET BUF RX,%i", len);
696 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
698 if (ret == EXIT_SUCCESS) {
699 // Receive response to "GET BUF RX" command from SPI Server
700 memset(ptr_rx_buf, (int32_t)'U', len);
701 ret = ComReceiveResponse(ptr_rx_buf, len);
704 if (ret != EXIT_SUCCESS) {
705 TEST_FAIL_MESSAGE("[FAILED] Get Rx buffer from SPI Server.");
712 \fn static int32_t CmdSetCom (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed)
713 \brief Set communication parameters on SPI Server for next XFER command.
714 \param[in] mode mode (0 = Master, 1 = slave)
715 \param[in] format clock / frame format (0 = clock polarity 0, phase 0 .. 5 = Microwire)
716 \param[in] data_bits data bits (1..32)
717 \param[in] bit_order bit order (0 = MSB to LSB, 1 = LSB to MSB)
718 \param[in] ss_mode Slave Select mode
719 (0 = not used, 1 = used (in Master mode driven, in Slave mode monitored as hw input))
720 \param[in] bus_speed bus speed in bits per second (bps)
721 \return execution status
722 - EXIT_SUCCESS: Operation successful
723 - EXIT_FAILURE: Operation failed
725 static int32_t CmdSetCom (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed) {
728 // Send "SET COM" command to SPI Server
729 memset(ptr_tx_buf, 0, 32);
730 stat = snprintf((char *)ptr_tx_buf, CMD_LEN, "SET COM %i,%i,%i,%i,%i,%i", mode, format, data_bits, bit_order, ss_mode, bus_speed);
731 if ((stat > 0) && (stat < CMD_LEN)) {
732 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
737 if (ret != EXIT_SUCCESS) {
738 TEST_FAIL_MESSAGE("[FAILED] Set communication settings on SPI Server.");
745 \fn static int32_t CmdXfer (uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_ss)
746 \brief Activate transfer on SPI Server.
747 \param[in] num number of items (according CMSIS SPI driver specification)
748 \param[in] delay initial delay, in milliseconds, before starting requested operation
749 (0xFFFFFFFF = delay not used)
750 \param[in] timeout timeout in milliseconds, after delay, if delay is specified
751 \param[in] num_ss number of items after which Slave Select line should be activated
752 \return execution status
753 - EXIT_SUCCESS: Operation successful
754 - EXIT_FAILURE: Operation failed
756 static int32_t CmdXfer (uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_ss) {
759 // Send "XFER" command to SPI Server
760 memset(ptr_tx_buf, 0, 32);
762 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i,%i", num, delay, timeout, num_ss);
763 } else if ((delay != osWaitForever) && (timeout != 0U)) {
764 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i", num, delay, timeout);
765 } else if (delay != osWaitForever) {
766 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i", num, delay);
768 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i", num);
770 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
772 if (ret != EXIT_SUCCESS) {
773 TEST_FAIL_MESSAGE("[FAILED] Activate transfer on SPI Server.");
780 \fn static int32_t CheckServer (void)
781 \brief Check if communication with SPI Server is working and get capabilities.
782 \return execution status
783 - EXIT_SUCCESS: Operation successful
784 - EXIT_FAILURE: Operation failed
786 static int32_t CheckServer (void) {
788 if (server_ok == -1) { // If -1, means it was not yet checked
790 if (ComConfigDefault() != EXIT_SUCCESS) {
793 if (server_ok == 1) {
794 if (CmdGetVer() != EXIT_SUCCESS) {
798 if (server_ok == 1) {
799 if (CmdGetCap() != EXIT_SUCCESS) {
803 if (server_ok == 1) {
804 // Check if all default settings are supported by SPI Server
805 if ((spi_serv_cap.fmt_mask & (1UL << SPI_CFG_SRV_FORMAT)) == 0U) {
806 // If SPI Server does not support default clock / frame format
807 TEST_MESSAGE("[FAILED] Default clock / frame format setting in not supported by SPI Server!");
810 if ((spi_serv_cap.db_mask & (1UL << (SPI_CFG_SRV_DATA_BITS - 1U))) == 0U) {
811 // If SPI Server does not support default data bits
812 TEST_MESSAGE("[FAILED] Default data bits setting in not supported by SPI Server!");
815 if ((spi_serv_cap.bo_mask & (1UL << SPI_CFG_SRV_BIT_ORDER)) == 0U) {
816 // If SPI Server does not support default bit order
817 TEST_MESSAGE("[FAILED] Default bit order setting in not supported by SPI Server!");
820 if ((spi_serv_cap.bs_min > SPI_CFG_SRV_BUS_SPEED) ||
821 (spi_serv_cap.bs_max < SPI_CFG_SRV_BUS_SPEED)) {
822 // If SPI Server does not support default bus speed
823 TEST_MESSAGE("[FAILED] Default bus speed setting in not supported by SPI Server!");
829 if (server_ok == 1) {
833 TEST_FAIL_MESSAGE("[FAILED] Communication with SPI Server is not working. Test aborted!");
837 #endif // If Test Mode SPI Server is selected
840 \fn void SPI_DV_Initialize (void)
841 \brief Initialize testing environment for SPI testing.
842 \detail This function is called by the driver validation framework before SPI testing begins.
843 It initializes global variables and allocates memory buffers (from heap) used for the SPI testing.
846 void SPI_DV_Initialize (void) {
848 // Initialize global variables
853 duration = 0xFFFFFFFFUL;
854 systick_freq = osKernelGetSysTimerFreq();
856 memset(&spi_serv_cap, 0, sizeof(spi_serv_cap));
857 memset(&msg_buf, 0, sizeof(msg_buf));
859 // Allocate buffers for transmission, reception and comparison
860 // (maximum size is incremented by 4 bytes to ensure that buffer can be aligned to 4 bytes)
862 ptr_tx_buf_alloc = malloc(SPI_BUF_MAX + 4U);
863 if (((uint32_t)ptr_tx_buf_alloc & 3U) != 0U) {
864 // If allocated memory is not 4 byte aligned, use next 4 byte aligned address for ptr_tx_buf
865 ptr_tx_buf = (uint8_t *)((((uint32_t)ptr_tx_buf_alloc) + 3U) & (~3U));
867 // If allocated memory is 4 byte aligned, use it directly
868 ptr_tx_buf = (uint8_t *)ptr_tx_buf_alloc;
870 ptr_rx_buf_alloc = malloc(SPI_BUF_MAX + 4U);
871 if (((uint32_t)ptr_rx_buf_alloc & 3U) != 0U) {
872 ptr_rx_buf = (uint8_t *)((((uint32_t)ptr_rx_buf_alloc) + 3U) & (~3U));
874 ptr_rx_buf = (uint8_t *)ptr_rx_buf_alloc;
876 ptr_cmp_buf_alloc = malloc(SPI_BUF_MAX + 4U);
877 if (((uint32_t)ptr_cmp_buf_alloc & 3U) != 0U) {
878 ptr_cmp_buf = (uint8_t *)((((uint32_t)ptr_cmp_buf_alloc) + 3U) & (~3U));
880 ptr_cmp_buf = (uint8_t *)ptr_cmp_buf_alloc;
885 \fn void SPI_DV_Uninitialize (void)
886 \brief De-initialize testing environment after SPI testing.
887 \detail This function is called by the driver validation framework after SPI testing is finished.
888 It frees memory buffers used for the SPI testing.
891 void SPI_DV_Uninitialize (void) {
893 if (ptr_tx_buf_alloc != NULL) {
894 free(ptr_tx_buf_alloc);
896 ptr_tx_buf_alloc = NULL;
898 if (ptr_rx_buf_alloc != NULL) {
899 free(ptr_rx_buf_alloc);
901 ptr_rx_buf_alloc = NULL;
903 if (ptr_cmp_buf_alloc != NULL) {
904 free(ptr_cmp_buf_alloc);
906 ptr_cmp_buf_alloc = NULL;
910 #endif // End of exclude form the documentation
912 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
914 \defgroup dv_spi SPI Validation
915 \brief SPI driver validation
917 The SPI validation performs the following tests:
918 - API interface compliance.
919 - Data exchange with various speeds, transfer sizes and communication settings.
920 - Error event signaling.
922 Two Test Modes are available: <b>Loopback</b> and <b>SPI Server</b>.
924 Test Mode : <b>Loopback</b>
925 ---------------------------
927 This test mode allows only limited validation of the SPI Driver.<br>
928 It is recommended that this test mode is used only as a proof that driver is
929 good enough to be tested with the <b>SPI Server</b>.
931 To enable this mode of testing in the <b>DV_SPI_Config.h</b> configuration file select
932 the <b>Configuration: Test Mode: Loopback</b> setting.
934 Required pin connection for the <b>Loopback</b> test mode:
936 \image html spi_loopback_pin_connections.png
938 \note In this mode following operations / settings cannot be tested:
940 - Slave Select line functionality
941 - operation of the Receive function
942 - data content sent by the Send function
943 - clock / frame format and bit order settings
944 - data bit settings other then: 8, 16, 24 and 32
945 - error event generation
947 Test Mode : <b>SPI Server</b>
948 -----------------------------
950 This test mode allows extensive validation of the SPI Driver.<br>
951 Results of the Driver Validation in this test mode are relevant as a proof of driver compliance to the CMSIS-Driver specification.
953 To perform extensive communication tests, it is required to use an
954 \ref spi_server "SPI Server" running on a dedicated hardware.
956 To enable this mode of testing in the <b>DV_SPI_Config.h</b> configuration file select
957 the <b>Configuration: Test Mode: SPI Server</b> setting.
959 Required pin connections for the <b>SPI Server</b> test mode:
961 \image html spi_server_pin_connections.png
963 \defgroup spi_tests Tests
967 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
968 /* SPI Driver Management tests */
969 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
971 \defgroup spi_tests_drv_mgmt Driver Management
974 These tests verify API and operation of the SPI driver management functions.
976 The driver management tests verify the following driver functions
977 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
980 ARM_DRIVER_VERSION GetVersion (void);
984 ARM_SPI_CAPABILITIES GetCapabilities (void);
988 int32_t Initialize (ARM_SPI_SignalEvent_t cb_event);
992 int32_t Uninitialize (void);
996 int32_t PowerControl (ARM_POWER_STATE state);
1002 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1004 \brief Function: Function SPI_GetVersion
1006 The function \b SPI_GetVersion verifies the \b GetVersion function.
1008 ARM_DRIVER_VERSION GetVersion (void);
1012 - Driver is uninitialized and peripheral is powered-off:
1013 - Call GetVersion function
1014 - Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1016 void SPI_GetVersion (void) {
1017 ARM_DRIVER_VERSION ver;
1019 ver = drv->GetVersion();
1021 // Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1022 TEST_ASSERT((ver.api >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)) && (ver.drv >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)));
1024 (void)snprintf(msg_buf, sizeof(msg_buf), "[INFO] Driver API version %d.%d, Driver version %d.%d", (ver.api >> 8), (ver.api & 0xFFU), (ver.drv >> 8), (ver.drv & 0xFFU));
1025 TEST_MESSAGE(msg_buf);
1028 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1030 \brief Function: Function SPI_GetCapabilities
1032 The function \b SPI_GetCapabilities verifies the \b GetCapabilities function.
1034 ARM_SPI_CAPABILITIES GetCapabilities (void);
1038 - Driver is uninitialized and peripheral is powered-off:
1039 - Call GetCapabilities function
1040 - Assert that GetCapabilities function returned capabilities structure with reserved field 0
1042 void SPI_GetCapabilities (void) {
1043 ARM_SPI_CAPABILITIES cap;
1045 cap = drv->GetCapabilities();
1047 // Assert that GetCapabilities function returned capabilities structure with reserved field 0
1048 TEST_ASSERT_MESSAGE((cap.reserved == 0U), "[FAILED] Capabilities reserved field must be 0");
1051 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1053 \brief Function: Function SPI_Initialize_Uninitialize
1055 The function \b SPI_Initialize_Uninitialize verifies the \b Initialize and \b Uninitialize functions.
1057 int32_t Initialize (ARM_SPI_SignalEvent_t cb_event);
1060 int32_t Uninitialize (void);
1064 - Driver is uninitialized and peripheral is powered-off:
1065 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1066 - Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1067 - Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1068 - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1069 - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1070 - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1071 - Call GetDataCount function and assert that it returned 0
1072 - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1073 - Call GetStatus function
1074 - Assert that GetStatus function returned status structure with busy flag 0
1075 - Assert that GetStatus function returned status structure with data_lost flag 0
1076 - Assert that GetStatus function returned status structure with mode_fault flag 0
1077 - Assert that GetStatus function returned status structure with reserved field 0
1078 - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1079 - Driver is initialized and peripheral is powered-off:
1080 - Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1081 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1082 - Driver is uninitialized and peripheral is powered-off:
1083 - Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1084 - Driver is initialized and peripheral is powered-off:
1085 - Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1086 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1087 - Driver is uninitialized and peripheral is powered-off:
1088 - Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1089 - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1090 - Driver is initialized and peripheral is powered-off:
1091 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1092 - Driver is initialized and peripheral is powered-on:
1093 - Call Control function and assert that it returned ARM_DRIVER_OK status
1094 - Call Transfer function and assert that it returned ARM_DRIVER_OK status
1095 - Call GetStatus function
1096 - Assert that GetStatus function returned status structure with busy flag 1
1097 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status<br>
1098 (this must unconditionally terminate active transfer, power-off the peripheral and uninitialize the driver)
1099 - Driver is uninitialized and peripheral is powered-off:
1100 - Call GetStatus function
1101 - Assert that GetStatus function returned status structure with busy flag 0
1103 void SPI_Initialize_Uninitialize (void) {
1104 ARM_SPI_STATUS stat;
1106 // Driver is uninitialized and peripheral is powered-off:
1107 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1108 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_ERROR);
1110 // Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1111 TEST_ASSERT(drv->PowerControl (ARM_POWER_LOW) == ARM_DRIVER_ERROR);
1113 // Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1114 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_ERROR);
1116 // Call Send function and assert that it returned ARM_DRIVER_ERROR status
1117 TEST_ASSERT(drv->Send (ptr_tx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1119 // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1120 TEST_ASSERT(drv->Receive (ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1122 // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1123 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1125 // Call GetDataCount function and assert that it returned 0
1126 TEST_ASSERT(drv->GetDataCount () == 0U);
1128 // Call Control function and assert that it returned ARM_DRIVER_ERROR status
1129 TEST_ASSERT(drv->Control (ARM_SPI_MODE_MASTER | ARM_SPI_DATA_BITS(SPI_CFG_DEF_DATA_BITS), SPI_CFG_DEF_BUS_SPEED) == ARM_DRIVER_ERROR);
1131 // Call GetStatus function
1132 stat = drv->GetStatus();
1134 // Assert that GetStatus function returned status structure with busy flag 0
1135 TEST_ASSERT(stat.busy == 0U);
1137 // Assert that GetStatus function returned status structure with data_lost flag 0
1138 TEST_ASSERT(stat.data_lost == 0U);
1140 // Assert that GetStatus function returned status structure with mode_fault flag 0
1141 TEST_ASSERT(stat.mode_fault == 0U);
1143 // Assert that GetStatus function returned status structure with reserved field 0
1144 TEST_ASSERT(stat.reserved == 0U);
1146 // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1147 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1149 // Driver is initialized and peripheral is powered-off:
1150 // Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1151 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1153 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1154 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1156 // Driver is uninitialized and peripheral is powered-off:
1157 // Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1158 TEST_ASSERT(drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK);
1160 // Driver is initialized and peripheral is powered-off:
1161 // Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1162 TEST_ASSERT(drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK);
1164 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1165 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1167 // Driver is uninitialized and peripheral is powered-off:
1168 // Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1169 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1171 // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1172 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1174 // Driver is initialized and peripheral is powered-off:
1175 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1176 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1178 // Driver is initialized and peripheral is powered-on:
1179 // Call Control function and assert that it returned ARM_DRIVER_OK status
1180 TEST_ASSERT(drv->Control (ARM_SPI_MODE_MASTER | ARM_SPI_DATA_BITS(SPI_CFG_DEF_DATA_BITS), SPI_CFG_DEF_BUS_SPEED) == ARM_DRIVER_OK);
1182 // Call Transfer function and assert that it returned ARM_DRIVER_OK status
1183 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
1185 // Call GetStatus function
1186 stat = drv->GetStatus();
1188 // Assert that GetStatus function returned status structure with busy flag 1
1189 TEST_ASSERT(stat.busy == 1U);
1191 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1192 // (this must unconditionally terminate active transfer, power-off the peripheral and uninitialize the driver)
1193 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1195 // Driver is uninitialized and peripheral is powered-off:
1196 // Call GetStatus function
1197 stat = drv->GetStatus();
1199 // Assert that GetStatus function returned status structure with busy flag 0
1200 TEST_ASSERT(stat.busy == 0U);
1202 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1203 // Insure that SPI Server (if used) is ready for command reception
1204 (void)osDelay(SPI_CFG_XFER_TIMEOUT + 10U);
1208 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1210 \brief Function: Function SPI_PowerControl
1212 The function \b SPI_PowerControl verifies the \b PowerControl function.
1214 int32_t PowerControl (ARM_POWER_STATE state);
1218 - Driver is initialized and peripheral is powered-off:
1219 - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1220 - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1221 - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1222 - Call GetDataCount function and assert that it returned 0
1223 - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1224 - Call GetStatus function
1225 - Assert that GetStatus function returned status structure with busy flag 0
1226 - Assert that GetStatus function returned status structure with data_lost flag 0
1227 - Assert that GetStatus function returned status structure with mode_fault flag 0
1228 - Assert that GetStatus function returned status structure with reserved field 0
1229 - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1230 - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1231 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1232 - Driver is initialized and peripheral is powered-on:
1233 - Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
1234 - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1235 - Driver is initialized and peripheral is powered-off:
1236 - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1237 - Call PowerControl(ARM_POWER_LOW) function
1238 - Driver is initialized and peripheral is powered-on or in low-power mode:
1239 - Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
1240 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1241 - Driver is initialized and peripheral is powered-on:
1242 - Call Control function and assert that it returned ARM_DRIVER_OK status
1243 - Call Transfer function and assert that it returned ARM_DRIVER_OK status
1244 - Call GetStatus function
1245 - Assert that GetStatus function returned status structure with busy flag 1
1246 - Call PowerControl(ARM_POWER_OFF) function with transfer active and assert that it returned ARM_DRIVER_OK status<br>
1247 (this must unconditionally terminate active transfer and power-off the peripheral)
1248 - Driver is initialized and peripheral is powered-off:
1249 - Call GetStatus function
1250 - Assert that GetStatus function returned status structure with busy flag 0
1252 void SPI_PowerControl (void) {
1254 ARM_SPI_STATUS stat;
1256 (void)drv->Initialize (NULL);
1258 // Driver is initialized and peripheral is powered-off:
1259 // Call Send function and assert that it returned ARM_DRIVER_ERROR status
1260 TEST_ASSERT(drv->Send (ptr_tx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1262 // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1263 TEST_ASSERT(drv->Receive (ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1265 // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1266 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1268 // Call GetDataCount function and assert that it returned 0
1269 TEST_ASSERT(drv->GetDataCount () == 0U);
1271 // Call Control function and assert that it returned ARM_DRIVER_ERROR status
1272 TEST_ASSERT(drv->Control (ARM_SPI_MODE_MASTER | ARM_SPI_DATA_BITS(SPI_CFG_DEF_DATA_BITS), SPI_CFG_DEF_BUS_SPEED) == ARM_DRIVER_ERROR);
1274 // Call GetStatus function
1275 stat = drv->GetStatus();
1277 // Assert that GetStatus function returned status structure with busy flag 0
1278 TEST_ASSERT(stat.busy == 0U);
1280 // Assert that GetStatus function returned status structure with data_lost flag 0
1281 TEST_ASSERT(stat.data_lost == 0U);
1283 // Assert that GetStatus function returned status structure with mode_fault flag 0
1284 TEST_ASSERT(stat.mode_fault == 0U);
1286 // Assert that GetStatus function returned status structure with reserved field 0
1287 TEST_ASSERT(stat.reserved == 0U);
1289 // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1290 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1292 // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1293 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1295 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1296 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1298 // Driver is initialized and peripheral is powered-on:
1299 // Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
1300 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1302 // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1303 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1305 // Driver is initialized and peripheral is powered-off:
1306 // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1307 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1309 // Call PowerControl(ARM_POWER_LOW) function
1310 ret = drv->PowerControl (ARM_POWER_LOW);
1312 // Driver is initialized and peripheral is powered-on or in low-power mode:
1313 // Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
1314 TEST_ASSERT((ret == ARM_DRIVER_OK) || (ret == ARM_DRIVER_ERROR_UNSUPPORTED));
1315 if (ret == ARM_DRIVER_ERROR_UNSUPPORTED) {
1316 TEST_MESSAGE("[WARNING] PowerControl (ARM_POWER_LOW) is not supported");
1319 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1320 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1322 // Driver is initialized and peripheral is powered-on:
1323 // Call Control function and assert that it returned ARM_DRIVER_OK status
1324 TEST_ASSERT(drv->Control (ARM_SPI_MODE_MASTER | ARM_SPI_DATA_BITS(SPI_CFG_DEF_DATA_BITS), SPI_CFG_DEF_BUS_SPEED) == ARM_DRIVER_OK);
1326 // Call Transfer function and assert that it returned ARM_DRIVER_OK status
1327 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
1329 // Call GetStatus function
1330 stat = drv->GetStatus();
1332 // Assert that GetStatus function returned status structure with busy flag 1
1333 TEST_ASSERT(stat.busy == 1U);
1335 // Call PowerControl(ARM_POWER_OFF) function with transfer active and assert that it returned ARM_DRIVER_OK status
1336 // (this must unconditionally terminate active transfer and power-off the peripheral)
1337 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1339 // Driver is initialized and peripheral is powered-off:
1340 // Call GetStatus function
1341 stat = drv->GetStatus();
1343 // Assert that GetStatus function returned status structure with busy flag 0
1344 TEST_ASSERT(stat.busy == 0U);
1346 (void)drv->Uninitialize ();
1348 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1349 // Insure that SPI Server (if used) is ready for command reception
1350 (void)osDelay(SPI_CFG_XFER_TIMEOUT + 10U);
1357 // End of spi_tests_drv_mgmt
1359 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1360 /* SPI Data Exchange tests */
1361 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1363 \defgroup spi_tests_data_xchg Data Exchange
1366 These tests verify API and operation of the SPI data exchange functions.
1368 The data exchange tests verify the following driver functions
1369 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
1372 int32_t Send (const void *data, uint32_t num);
1376 int32_t Receive ( void *data, uint32_t num);
1380 int32_t Transfer (const void *data_out, void *data_in, uint32_t num);
1384 uint32_t GetDataCount (void);
1388 int32_t Control (uint32_t control, uint32_t arg);
1392 ARM_SPI_STATUS GetStatus (void);
1396 void (*ARM_SPI_SignalEvent_t) (uint32_t event);
1399 All of these tests execute a data exchange and check the result of this data exchange.
1401 Data exchange test procedure when Test Mode <b>SPI Server</b> is selected:
1402 - send command "SET BUF TX,.." to the SPI Server: Set Tx buffer
1403 - send command "SET BUF RX,.." to the SPI Server: Set Rx buffer
1404 - send command "SET COM .." to the SPI Server: Set communication settings for the next XFER command
1405 - send command "XFER .." to the SPI Server: Activate transfer
1406 - driver Control: Configure the SPI interface
1407 - driver Control: Set the default Tx value
1408 - driver Send/Receive/Transfer: Start the requested operation
1409 - driver GetStatus/SignalEvent: Wait for the current operation to finish or time out<br>
1410 (operation is finished when busy flag is 0 and completed event was signaled)
1411 - assert that operation has finished in expected time
1412 - assert that ARM_SPI_EVENT_TRANSFER_COMPLETE event was signaled
1413 - driver GetStatus: Assert that busy flag is 0
1414 - driver GetDataCount: Assert that number of transferred items is same as requested
1415 - if operation has timed out call driver Control function to Abort operation and wait timeout time<br>
1416 to make sure that the SPI Server is ready for the next command
1417 - assert that received content is as expected
1418 - send command "GET BUF RX,.." to the SPI Server: Get Rx buffer
1419 - assert that sent content (read from the SPI Server's receive buffer) is as expected
1421 Data exchange <b>Abort</b> test procedure when Test Mode <b>SPI Server</b> is selected:
1422 - send command "SET BUF TX,.." to the SPI Server: Set Tx buffer
1423 - send command "SET BUF RX,.." to the SPI Server: Set Rx buffer
1424 - send command "SET COM .." to the SPI Server: Set communication settings for the next XFER command
1425 - send command "XFER .." to the SPI Server: Activate transfer
1426 - driver Control: Configure the SPI interface
1427 - driver Control: Set the default Tx value
1428 - driver Send/Receive/Transfer: Start the requested operation
1430 - driver Control: Abort the current operation
1431 - driver GetStatus: Assert that busy flag is 0
1432 - driver GetDataCount: Assert that number of transferred items is less than requested
1434 Data exchange test procedure when Test Mode <b>Loopback</b> is selected:
1435 - driver Control: Configure the SPI interface
1436 - driver Control: Set the default Tx value
1437 - driver Send/Transfer: Start the requested operation
1438 - driver GetStatus/SignalEvent: Wait for the current operation to finish or time out<br>
1439 (operation is finished when busy flag is 0 and completed event was signaled)
1440 - assert that operation has finished in expected time
1441 - assert that ARM_SPI_EVENT_TRANSFER_COMPLETE event was signaled
1442 - driver GetStatus: Assert that busy flag is 0
1443 - driver GetDataCount: Assert that number of transferred items is same as requested
1444 - if operation has timed out call driver Control function to Abort operation
1445 - assert that received content is as expected (for Transfer operation only)
1447 \note Limitations of Data Exchange tests if Test Mode <b>Loopback</b> is selected:
1448 - only Master mode with Slave Select not used can be tested
1449 - Receive function cannot be tested
1450 - format tests are not supported
1451 - only 8, 16, 24 and 32 data bit tests are supported
1452 - bit order tests are not supported
1456 #ifndef __DOXYGEN__ // Exclude form the documentation
1458 \brief Execute SPI data exchange or data exchange abort operation.
1459 \param[in] operation operation (OP_SEND.. OP_ABORT_TRANSFER)
1460 \param[in] mode mode (MODE_MASTER or MODE_SLAVE)
1461 \param[in] format clock/frame format (0 = polarity0/phase0 .. 5 = Microwire)
1462 \param[in] data_bits data bits (1 .. 32)
1463 \param[in] bit_order bit order (BO_MSB_TO_LSB or BO_LSB_TO_MSB)
1464 \param[in] ss_mode Slave Select mode (SS_MODE_xxx)
1465 \param[in] bus_speed bus speed in bits per second (bps)
1466 \param[in] num number of items to send, receive or transfer
1469 static void SPI_DataExchange_Operation (uint32_t operation, uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed, uint32_t num) {
1470 // volatile specifier is used to prevent compiler from optimizing variables
1471 // in a way that they cannot be seen with debugger
1472 volatile int32_t stat, def_tx_stat;
1473 volatile uint32_t drv_mode, drv_format, drv_data_bits, drv_bit_order, drv_ss_mode;
1474 volatile uint32_t srv_mode, srv_ss_mode;
1475 volatile ARM_SPI_STATUS spi_stat;
1476 volatile uint32_t data_count;
1477 uint32_t start_cnt, max_cnt;
1478 uint32_t val, delay, i;
1480 // Prepare parameters for SPI Server and Driver configuration
1483 TEST_FAIL_MESSAGE("[FAILED] Inactive mode! Data exchange operation aborted!");
1486 drv_mode = ARM_SPI_MODE_MASTER;
1491 drv_mode = ARM_SPI_MODE_SLAVE;
1496 TEST_FAIL_MESSAGE("[FAILED] Unknown mode! Data exchange operation aborted!");
1501 case FORMAT_CPOL0_CPHA0:
1502 drv_format = ARM_SPI_CPOL0_CPHA0;
1504 case FORMAT_CPOL0_CPHA1:
1505 drv_format = ARM_SPI_CPOL0_CPHA1;
1507 case FORMAT_CPOL1_CPHA0:
1508 drv_format = ARM_SPI_CPOL1_CPHA0;
1510 case FORMAT_CPOL1_CPHA1:
1511 drv_format = ARM_SPI_CPOL1_CPHA1;
1514 drv_format = ARM_SPI_TI_SSI;
1516 case FORMAT_MICROWIRE:
1517 drv_format = ARM_SPI_MICROWIRE;
1520 TEST_FAIL_MESSAGE("[FAILED] Unknown clock / frame format! Data exchange operation aborted!");
1524 if ((data_bits > 0U) && (data_bits <= 32U)) {
1525 drv_data_bits = ARM_SPI_DATA_BITS(data_bits);
1527 TEST_FAIL_MESSAGE("[FAILED] Data bits not in range 1 to 32! Data exchange operation aborted!");
1531 switch (bit_order) {
1533 drv_bit_order = ARM_SPI_MSB_LSB;
1536 drv_bit_order = ARM_SPI_LSB_MSB;
1539 TEST_FAIL_MESSAGE("[FAILED] Unknown bit order! Data exchange operation aborted!");
1543 if (mode == MODE_MASTER) {
1545 case SS_MODE_MASTER_UNUSED:
1546 drv_ss_mode = ARM_SPI_SS_MASTER_UNUSED;
1549 case SS_MODE_MASTER_SW:
1550 drv_ss_mode = ARM_SPI_SS_MASTER_SW;
1553 case SS_MODE_MASTER_HW_OUTPUT:
1554 drv_ss_mode = ARM_SPI_SS_MASTER_HW_OUTPUT;
1557 case SS_MODE_MASTER_HW_INPUT:
1558 drv_ss_mode = ARM_SPI_SS_MASTER_UNUSED;
1562 TEST_FAIL_MESSAGE("[FAILED] Unknown Slave Select mode! Data exchange operation aborted!");
1567 case SS_MODE_SLAVE_HW:
1568 drv_ss_mode = ARM_SPI_SS_SLAVE_HW;
1571 case SS_MODE_SLAVE_SW:
1572 drv_ss_mode = ARM_SPI_SS_SLAVE_SW;
1576 TEST_FAIL_MESSAGE("[FAILED] Unknown Slave Select mode! Data exchange operation aborted!");
1581 // Check that SPI status is not busy before starting data exchange test
1582 spi_stat = drv->GetStatus(); // Get SPI status
1583 if (spi_stat.busy != 0U) {
1584 // If busy flag is still active
1585 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy active before operation! Data exchange operation aborted!");
1588 TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
1591 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1592 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
1593 if (CmdSetBufTx('S') != EXIT_SUCCESS) { break; }
1594 if (CmdSetBufRx('?') != EXIT_SUCCESS) { break; }
1595 if (CmdSetCom (srv_mode, format, data_bits, bit_order, srv_ss_mode, bus_speed) != EXIT_SUCCESS) { break; }
1596 if (CmdXfer (num, delay, SPI_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
1597 #else // If Test Mode Loopback is selected
1598 // Remove warnings for unused variables
1604 // Initialize buffers
1605 memset(ptr_tx_buf, (int32_t)'!' , SPI_BUF_MAX);
1606 memset(ptr_tx_buf, (int32_t)'T' , num * DataBitsToBytes(data_bits));
1607 memset(ptr_rx_buf, (int32_t)'?' , SPI_BUF_MAX);
1608 memset(ptr_cmp_buf, (int32_t)'?' , SPI_BUF_MAX);
1610 // Configure required communication settings
1611 if (mode == MODE_MASTER) {
1612 stat = drv->Control (drv_mode | drv_format | drv_data_bits | drv_bit_order | drv_ss_mode, bus_speed);
1613 (void)osDelay(10U); // Give time to SPI Server to prepare Slave transfer
1615 // For Slave mode bus speed argument is not used
1616 stat = drv->Control (drv_mode | drv_format | drv_data_bits | drv_bit_order | drv_ss_mode, 0U);
1618 if (stat != ARM_DRIVER_OK) {
1619 // If configuration has failed
1620 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Control function returned", str_ret[-stat]);
1622 // Assert that Control function returned ARM_DRIVER_OK
1623 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1624 if (stat != ARM_DRIVER_OK) {
1625 // If Control function has failed there is no sense to try to execute the data exchange
1626 (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U); // Wait for SPI Server to timeout the XFER command
1630 // Set default Tx value to 'D' byte values
1631 val = ((uint32_t)'D' << 24) | ((uint32_t)'D' << 16) | ((uint32_t)'D' << 8) | (uint32_t)'D';
1632 stat = drv->Control (ARM_SPI_SET_DEFAULT_TX_VALUE, val);
1634 if ((stat != ARM_DRIVER_OK) && (stat != ARM_DRIVER_ERROR_UNSUPPORTED)) {
1635 // If set default Tx value has failed or is not supported
1636 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Set default Tx value returned", str_ret[-stat]);
1638 // Assert that Control function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED
1639 TEST_ASSERT_MESSAGE((stat == ARM_DRIVER_OK) || (stat == ARM_DRIVER_ERROR_UNSUPPORTED), msg_buf);
1642 duration = 0xFFFFFFFFUL;
1644 max_cnt = (systick_freq /1024U) * (SPI_CFG_XFER_TIMEOUT + 10U);
1645 start_cnt = osKernelGetSysTimerCount();
1647 if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) ||
1648 ((mode == MODE_SLAVE) && (ss_mode == SS_MODE_SLAVE_SW))) {
1649 // If operation requires software Slave Select driving, activate Slave Select
1650 stat = drv->Control (ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE);
1651 if (stat != ARM_DRIVER_OK) {
1652 // If driving of Slave Select to active state has failed
1653 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
1655 // Assert that Control function returned ARM_DRIVER_OK
1656 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1659 // Start the data exchange operation
1660 switch (operation & 0x0FU) {
1663 stat = drv->Send(ptr_tx_buf, num);
1664 if (stat != ARM_DRIVER_OK) {
1665 // If Send activation has failed
1666 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Send function returned", str_ret[-stat]);
1668 // Assert that Send function returned ARM_DRIVER_OK
1669 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1672 case OP_ABORT_RECEIVE:
1673 stat = drv->Receive(ptr_rx_buf, num);
1674 if (stat != ARM_DRIVER_OK) {
1675 // If Receive activation has failed
1676 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receive function returned", str_ret[-stat]);
1678 // Assert that Receive function returned ARM_DRIVER_OK
1679 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1682 case OP_ABORT_TRANSFER:
1683 stat = drv->Transfer(ptr_tx_buf, ptr_rx_buf, num);
1684 if (stat != ARM_DRIVER_OK) {
1685 // If Transfer activation has failed
1686 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transfer function returned", str_ret[-stat]);
1688 // Assert that Transfer function returned ARM_DRIVER_OK
1689 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1692 TEST_FAIL_MESSAGE("[FAILED] Unknown operation! Data exchange operation aborted!");
1695 if (stat != ARM_DRIVER_OK) {
1696 // If Send/Receive/Transfer start has failed there is no sense to try to continue with the data exchange
1697 (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U); // Wait for SPI Server to timeout the XFER command
1701 if ((operation == OP_ABORT_SEND) || // This IF block tests only abort functionality
1702 (operation == OP_ABORT_RECEIVE) ||
1703 (operation == OP_ABORT_TRANSFER)) {
1704 (void)osDelay(1U); // Wait short time before doing Abort
1705 stat = drv->Control (ARM_SPI_ABORT_TRANSFER, 0U);
1706 if (stat != ARM_DRIVER_OK) {
1707 // If Abort has failed
1708 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
1710 // Assert that Control function returned ARM_DRIVER_OK
1711 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1713 if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) ||
1714 ((mode == MODE_SLAVE) && (ss_mode == SS_MODE_SLAVE_SW))) {
1715 // If operation requires software Slave Select driving, deactivate Slave Select
1716 drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE);
1718 spi_stat = drv->GetStatus(); // Get SPI status
1719 if (spi_stat.busy != 0U) {
1720 // If busy flag is still active
1721 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy still active after Abort");
1723 // Assert that busy flag is not active
1724 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1726 data_count = drv->GetDataCount(); // Get data count
1727 if (data_count >= num) {
1728 // If data count is more or equal to number of items then Abort has failed
1729 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetDataCount returned", data_count, "after Abort of", num, "items");
1731 // Assert data count is less then number of items requested for exchange
1732 TEST_ASSERT_MESSAGE(data_count < num, msg_buf);
1734 (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U); // Wait for SPI Server to timeout aborted operation
1736 return; // Here Abort test is finished, exit
1739 // Wait for operation to finish (status busy is 0 and event complete signaled, or timeout)
1741 if ((drv->GetStatus().busy == 0U) && ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) != 0U)) {
1742 duration = osKernelGetSysTimerCount() - start_cnt;
1745 } while ((osKernelGetSysTimerCount() - start_cnt) < max_cnt);
1747 if (duration == 0xFFFFFFFFUL) {
1748 // If operation has timed out
1749 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Operation timed out");
1751 // Assert that operation has finished in expected time
1752 TEST_ASSERT_MESSAGE(duration != 0xFFFFFFFFUL, msg_buf);
1754 if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) ||
1755 ((mode == MODE_SLAVE) && (ss_mode == SS_MODE_SLAVE_SW))) {
1756 // If operation requires software Slave Select driving, deactivate Slave Select
1757 stat = drv->Control (ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE);
1758 if (stat != ARM_DRIVER_OK) {
1759 // If driving of Slave Select to inactive state has failed
1760 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
1762 // Assert that Control function returned ARM_DRIVER_OK
1763 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1766 if ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) == 0U) {
1767 // If transfer complete event was not signaled
1768 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_SPI_EVENT_TRANSFER_COMPLETE was not signaled");
1770 // Assert that ARM_SPI_EVENT_TRANSFER_COMPLETE was signaled
1771 TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) != 0U, msg_buf);
1773 spi_stat = drv->GetStatus(); // Get SPI status
1774 if (spi_stat.busy != 0U) {
1775 // If busy flag is still active
1776 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy still active after operation");
1778 // Assert that busy flag is not active
1779 TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
1781 data_count = drv->GetDataCount(); // Get data count
1782 if (data_count != num) {
1783 // If data count is different then number of items, then operation has failed
1784 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %i %s %i %s", str_oper[operation], "GetDataCount returned", data_count, "expected was", num, "items");
1786 // Assert that data count is equal to number of items requested for exchange
1787 TEST_ASSERT_MESSAGE(data_count == num, msg_buf);
1789 if ((drv->GetStatus().busy != 0U) || ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) == 0U)) {
1790 // If transfer did not finish in time, abort it
1791 (void)drv->Control(ARM_SPI_ABORT_TRANSFER, 0U);
1792 (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U); // Wait for SPI Server to timeout aborted operation
1795 // Check received content for receive and transfer operations
1796 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1797 if ((operation == OP_RECEIVE) || (operation == OP_TRANSFER)) {
1798 memset(ptr_cmp_buf, (int32_t)'S', num * DataBitsToBytes(data_bits));
1799 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
1801 // If data received mismatches
1802 // Find on which byte mismatch starts
1803 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
1804 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
1808 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, received was 0x%02X, expected was 0x%02X", str_oper[operation], "Received data mismatches on", i, ptr_rx_buf[i], ptr_cmp_buf[i]);
1810 // Assert that data received is same as expected
1811 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
1814 // Check sent content (by checking SPI Server's received buffer content)
1815 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
1816 if (CmdGetBufRx(SPI_BUF_MAX) != EXIT_SUCCESS) { break; }
1818 if ((operation == OP_RECEIVE) && (def_tx_stat == ARM_DRIVER_OK)) {
1819 // Expected data received by SPI Server should be default Tx value
1820 memset(ptr_cmp_buf, (int32_t)'D', num * DataBitsToBytes(data_bits));
1822 if ((operation == OP_SEND) || (operation == OP_TRANSFER)) {
1823 // Expected data received by SPI Server should be what was sent
1824 memset(ptr_cmp_buf, (int32_t)'T', num * DataBitsToBytes(data_bits));
1827 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
1829 // If data sent mismatches
1830 // Find on which byte mismatch starts
1831 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
1832 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
1836 if (operation == OP_RECEIVE) {
1837 // If sent was default Tx value, 'D' bytes
1838 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, SPI Server received 0x%02X, sent was 0x%02X", str_oper[operation], "Default Tx data mismatches on", i, ptr_rx_buf[i], ptr_cmp_buf[i]);
1840 // If sent was 'T' bytes
1841 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, SPI Server received 0x%02X, sent was 0x%02X", str_oper[operation], "Sent data mismatches on", i, ptr_rx_buf[i], ptr_cmp_buf[i]);
1844 // Assert data sent is same as expected
1845 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
1847 #else // If Test Mode Loopback is selected
1848 if (operation == OP_TRANSFER) {
1849 memset(ptr_cmp_buf, (int32_t)'T', num * DataBitsToBytes(data_bits));
1850 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
1852 // If data received mismatches
1853 // Find on which byte mismatch starts
1854 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
1855 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
1859 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s byte %i, received was 0x%02X, expected was 0x%02X", str_oper[operation], "Received data mismatches on", i, ptr_rx_buf[i], ptr_cmp_buf[i]);
1861 // Assert that data received is same as expected
1862 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
1869 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1870 TEST_FAIL_MESSAGE("[FAILED] Problems in communication with SPI Server. Test aborted!");
1874 #endif // End of exclude form the documentation
1876 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1878 \brief Function: Function SPI_Mode_Master_SS_Unused
1880 The function \b SPI_Mode_Master_SS_Unused verifies data exchange:
1881 - in <b>Master Mode</b> with <b>Slave Select line not used</b>
1882 - with default clock / frame format
1883 - with default data bits
1884 - with default bit order
1885 - at default bus speed
1886 - for default number of data items
1888 \note In Test Mode <b>Loopback</b> Receive function is not checked
1890 void SPI_Mode_Master_SS_Unused (void) {
1892 if (InitDriver() != EXIT_SUCCESS) { return; }
1893 if (CheckBuffers() != EXIT_SUCCESS) { return; }
1894 #if (SPI_SERVER_USED != 0)
1895 if (CheckServer() != EXIT_SUCCESS) { return; }
1896 if ((spi_serv_cap.mode_mask & 2U) == 0U) { // If SPI Server does not support Slave mode
1897 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
1902 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_UNUSED, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1903 #if (SPI_SERVER_USED != 0)
1904 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_UNUSED, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1906 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_UNUSED, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1909 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1911 \brief Function: Function SPI_Mode_Master_SS_Sw_Ctrl
1913 The function \b SPI_Mode_Master_SS_Sw_Ctrl verifies data exchange:
1914 - in <b>Master Mode</b> with <b>Slave Select line Software Controlled</b>
1915 - with default clock / frame format
1916 - with default data bits
1917 - with default bit order
1918 - at default bus speed
1919 - for default number of data items
1921 \note In Test Mode <b>Loopback</b> this test is skipped
1923 void SPI_Mode_Master_SS_Sw_Ctrl (void) {
1925 #if (SPI_SERVER_USED != 0)
1926 if (InitDriver() != EXIT_SUCCESS) { return; }
1927 if (CheckBuffers() != EXIT_SUCCESS) { return; }
1928 if (CheckServer() != EXIT_SUCCESS) { return; }
1929 if ((spi_serv_cap.mode_mask & 2U) == 0U) { // If SPI Server does not support Slave mode
1930 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
1934 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1935 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1936 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1939 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
1943 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1945 \brief Function: Function SPI_Mode_Master_SS_Hw_Ctrl_Out
1947 The function \b SPI_Mode_Master_SS_Hw_Ctrl_Out verifies data exchange:
1948 - in <b>Master Mode</b> with <b>Slave Select line Hardware Controlled Output</b>
1949 - with default clock / frame format
1950 - with default data bits
1951 - with default bit order
1952 - at default bus speed
1953 - for default number of data items
1955 \note In Test Mode <b>Loopback</b> this test is skipped
1957 void SPI_Mode_Master_SS_Hw_Ctrl_Out (void) {
1959 #if (SPI_SERVER_USED != 0)
1960 if (InitDriver() != EXIT_SUCCESS) { return; }
1961 if (CheckBuffers() != EXIT_SUCCESS) { return; }
1962 if (CheckServer() != EXIT_SUCCESS) { return; }
1963 if ((spi_serv_cap.mode_mask & 2U) == 0U) { // If SPI Server does not support Slave mode
1964 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
1968 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1969 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1970 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
1973 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
1977 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1979 \brief Function: Function SPI_Mode_Master_SS_Hw_Mon_In
1981 The function \b SPI_Mode_Master_SS_Hw_Mon_In verifies data exchange:
1982 - in <b>Master Mode</b> with <b>Slave Select line Hardware Monitored Input</b>
1983 - with default clock / frame format
1984 - with default data bits
1985 - with default bit order
1986 - at default bus speed
1987 - for default number of data items
1989 \note In Test Mode <b>Loopback</b> this test is skipped
1991 void SPI_Mode_Master_SS_Hw_Mon_In (void) {
1993 #if (SPI_SERVER_USED != 0)
1994 if (InitDriver() != EXIT_SUCCESS) { return; }
1995 if (CheckBuffers() != EXIT_SUCCESS) { return; }
1996 if (CheckServer() != EXIT_SUCCESS) { return; }
1997 if ((spi_serv_cap.mode_mask & 2U) == 0U) { // If SPI Server does not support Slave mode
1998 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2002 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_INPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2003 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_INPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2004 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_INPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2007 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2011 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2013 \brief Function: Function SPI_Mode_Slave_SS_Hw_Mon
2015 The function \b SPI_Mode_Slave_SS_Hw_Mon verifies data exchange:
2016 - in <b>Slave Mode</b> with <b>Slave Select line Hardware Monitored</b>
2017 - with default clock / frame format
2018 - with default data bits
2019 - with default bit order
2020 - at default bus speed
2021 - for default number of data items
2023 \note In Test Mode <b>Loopback</b> this test is skipped
2025 void SPI_Mode_Slave_SS_Hw_Mon (void) {
2027 #if (SPI_SERVER_USED != 0)
2028 if (InitDriver() != EXIT_SUCCESS) { return; }
2029 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2030 if (CheckServer() != EXIT_SUCCESS) { return; }
2031 if ((spi_serv_cap.mode_mask & 1U) == 0U) { // If SPI Server does not support Master mode
2032 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2036 SPI_DataExchange_Operation(OP_SEND, MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_SLAVE_HW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2037 SPI_DataExchange_Operation(OP_RECEIVE, MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_SLAVE_HW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2038 SPI_DataExchange_Operation(OP_TRANSFER, MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_SLAVE_HW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2041 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2045 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2047 \brief Function: Function SPI_Mode_Slave_SS_Sw_Ctrl
2049 The function \b SPI_Mode_Slave_SS_Sw_Ctrl verifies data exchange:
2050 - in <b>Slave Mode</b> with <b>Slave Select line Software Controlled</b>
2051 - with default clock / frame format
2052 - with default data bits
2053 - with default bit order
2054 - at default bus speed
2055 - for default number of data items
2057 \note In Test Mode <b>Loopback</b> this test is skipped
2059 void SPI_Mode_Slave_SS_Sw_Ctrl (void) {
2061 #if (SPI_SERVER_USED != 0)
2062 if (InitDriver() != EXIT_SUCCESS) { return; }
2063 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2064 if (CheckServer() != EXIT_SUCCESS) { return; }
2065 if ((spi_serv_cap.mode_mask & 1U) == 0U) { // If SPI Server does not support Master mode
2066 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2070 SPI_DataExchange_Operation(OP_SEND, MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_SLAVE_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2071 SPI_DataExchange_Operation(OP_RECEIVE, MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_SLAVE_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2072 SPI_DataExchange_Operation(OP_TRANSFER, MODE_SLAVE, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_SLAVE_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2075 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2079 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2081 \brief Function: Function SPI_Format_Clock_Pol0_Pha0
2083 The function \b SPI_Format_Clock_Pol0_Pha0 verifies data exchange:
2084 - in Master Mode with default Slave Select mode
2085 - with clock format: <b>polarity 0 / phase 0</b>
2086 - with default data bits
2087 - with default bit order
2088 - at default bus speed
2089 - for default number of data items
2091 \note In Test Mode <b>Loopback</b> this test is skipped
2093 void SPI_Format_Clock_Pol0_Pha0 (void) {
2095 #if (SPI_SERVER_USED != 0)
2096 if (InitDriver() != EXIT_SUCCESS) { return; }
2097 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2098 if (CheckServer() != EXIT_SUCCESS) { return; }
2099 if ((spi_serv_cap.fmt_mask & 1U) == 0U) { // If SPI Server does not support format
2100 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2104 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, FORMAT_CPOL0_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2105 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, FORMAT_CPOL0_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2106 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_CPOL0_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2109 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2113 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2115 \brief Function: Function SPI_Format_Clock_Pol0_Pha1
2117 The function \b SPI_Format_Clock_Pol0_Pha1 verifies data exchange:
2118 - in Master Mode with default Slave Select mode
2119 - with clock format: <b>polarity 0 / phase 1</b>
2120 - with default data bits
2121 - with default bit order
2122 - at default bus speed
2123 - for default number of data items
2125 \note In Test Mode <b>Loopback</b> this test is skipped
2127 void SPI_Format_Clock_Pol0_Pha1 (void) {
2129 #if (SPI_SERVER_USED != 0)
2130 if (InitDriver() != EXIT_SUCCESS) { return; }
2131 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2132 if (CheckServer() != EXIT_SUCCESS) { return; }
2133 if ((spi_serv_cap.fmt_mask & 2U) == 0U) { // If SPI Server does not support format
2134 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2138 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, FORMAT_CPOL0_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2139 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, FORMAT_CPOL0_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2140 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_CPOL0_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2143 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2147 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2149 \brief Function: Function SPI_Format_Clock_Pol1_Pha0
2151 The function \b SPI_Format_Clock_Pol1_Pha0 verifies data exchange:
2152 - in Master Mode with default Slave Select mode
2153 - with clock format: <b>polarity 1 / phase 0</b>
2154 - with default data bits
2155 - with default bit order
2156 - at default bus speed
2157 - for default number of data items
2159 \note In Test Mode <b>Loopback</b> this test is skipped
2161 void SPI_Format_Clock_Pol1_Pha0 (void) {
2163 #if (SPI_SERVER_USED != 0)
2164 if (InitDriver() != EXIT_SUCCESS) { return; }
2165 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2166 if (CheckServer() != EXIT_SUCCESS) { return; }
2167 if ((spi_serv_cap.fmt_mask & 4U) == 0U) { // If SPI Server does not support format
2168 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2172 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, FORMAT_CPOL1_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2173 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, FORMAT_CPOL1_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2174 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_CPOL1_CPHA0, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2177 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2181 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2183 \brief Function: Function SPI_Format_Clock_Pol0_Pha0
2185 The function \b SPI_Format_Clock_Pol1_Pha1 verifies data exchange:
2186 - in Master Mode with default Slave Select mode
2187 - with clock format: <b>polarity 1 / phase 1</b>
2188 - with default data bits
2189 - with default bit order
2190 - at default bus speed
2191 - for default number of data items
2193 \note In Test Mode <b>Loopback</b> this test is skipped
2195 void SPI_Format_Clock_Pol1_Pha1 (void) {
2197 #if (SPI_SERVER_USED != 0)
2198 if (InitDriver() != EXIT_SUCCESS) { return; }
2199 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2200 if (CheckServer() != EXIT_SUCCESS) { return; }
2201 if ((spi_serv_cap.fmt_mask & 8U) == 0U) { // If SPI Server does not support format
2202 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2206 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, FORMAT_CPOL1_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2207 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, FORMAT_CPOL1_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2208 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_CPOL1_CPHA1, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2211 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2215 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2217 \brief Function: Function SPI_Format_Frame_TI
2219 The function \b SPI_Format_Frame_TI verifies data exchange:
2220 - in Master Mode with default Slave Select mode
2221 - with <b>Texas Instruments frame format</b>
2222 - with default data bits
2223 - with default bit order
2224 - at default bus speed
2225 - for default number of data items
2227 \note In Test Mode <b>Loopback</b> this test is skipped
2229 void SPI_Format_Frame_TI (void) {
2231 #if (SPI_SERVER_USED != 0)
2232 if (InitDriver() != EXIT_SUCCESS) { return; }
2233 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2234 if (CheckServer() != EXIT_SUCCESS) { return; }
2235 if ((spi_serv_cap.fmt_mask & 16U) == 0U) { // If SPI Server does not support format
2236 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2240 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, FORMAT_TI, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2241 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, FORMAT_TI, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2242 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_TI, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2245 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2249 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2251 \brief Function: Function SPI_Format_Clock_Microwire
2253 The function \b SPI_Format_Clock_Microwire verifies data exchange:
2254 - in Master Mode with default Slave Select mode
2255 - with <b>National Semiconductor Microwire frame format</b>
2256 - with default data bits
2257 - with default bit order
2258 - at default bus speed
2259 - for default number of data items
2261 \note In Test Mode <b>Loopback</b> this test is skipped
2263 void SPI_Format_Clock_Microwire (void) {
2265 #if (SPI_SERVER_USED != 0)
2266 if (InitDriver() != EXIT_SUCCESS) { return; }
2267 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2268 if (CheckServer() != EXIT_SUCCESS) { return; }
2269 if ((spi_serv_cap.fmt_mask & 32U) == 0U) { // If SPI Server does not support format
2270 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2274 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, FORMAT_MICROWIRE, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2275 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, FORMAT_MICROWIRE, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2276 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, FORMAT_MICROWIRE, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_HW_OUTPUT, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2279 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2283 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2285 \brief Function: Function SPI_Data_Bits_1
2287 The function \b SPI_Data_Bits_1 verifies data exchange:
2288 - in Master Mode with default Slave Select mode
2289 - with default clock / frame format
2290 - with <b>1 data bits</b> per frame
2291 - with default bit order
2292 - at default bus speed
2293 - for default number of data items
2295 \note In Test Mode <b>Loopback</b> this test is skipped
2297 void SPI_Data_Bits_1 (void) {
2299 #if (SPI_SERVER_USED != 0)
2300 if (InitDriver() != EXIT_SUCCESS) { return; }
2301 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2302 if (CheckServer() != EXIT_SUCCESS) { return; }
2303 if ((spi_serv_cap.db_mask & 1U) == 0U) { // If SPI Server does not support data bits setting
2304 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2308 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 1U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2309 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 1U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2310 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 1U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2313 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2317 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2319 \brief Function: Function SPI_Data_Bits_2
2321 The function \b SPI_Data_Bits_2 verifies data exchange:
2322 - in Master Mode with default Slave Select mode
2323 - with default clock / frame format
2324 - with <b>2 data bits</b> per frame
2325 - with default bit order
2326 - at default bus speed
2327 - for default number of data items
2329 \note In Test Mode <b>Loopback</b> this test is skipped
2331 void SPI_Data_Bits_2 (void) {
2333 #if (SPI_SERVER_USED != 0)
2334 if (InitDriver() != EXIT_SUCCESS) { return; }
2335 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2336 if (CheckServer() != EXIT_SUCCESS) { return; }
2337 if ((spi_serv_cap.db_mask & (1U << 1)) == 0U) { // If SPI Server does not support data bits setting
2338 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2342 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 2U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2343 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 2U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2344 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 2U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2347 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2351 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2353 \brief Function: Function SPI_Data_Bits_3
2355 The function \b SPI_Data_Bits_3 verifies data exchange:
2356 - in Master Mode with default Slave Select mode
2357 - with default clock / frame format
2358 - with <b>3 data bits</b> per frame
2359 - with default bit order
2360 - at default bus speed
2361 - for default number of data items
2363 \note In Test Mode <b>Loopback</b> this test is skipped
2365 void SPI_Data_Bits_3 (void) {
2367 #if (SPI_SERVER_USED != 0)
2368 if (InitDriver() != EXIT_SUCCESS) { return; }
2369 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2370 if (CheckServer() != EXIT_SUCCESS) { return; }
2371 if ((spi_serv_cap.db_mask & (1U << 2)) == 0U) { // If SPI Server does not support data bits setting
2372 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2376 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 3U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2377 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 3U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2378 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 3U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2381 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2385 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2387 \brief Function: Function SPI_Data_Bits_4
2389 The function \b SPI_Data_Bits_4 verifies data exchange:
2390 - in Master Mode with default Slave Select mode
2391 - with default clock / frame format
2392 - with <b>4 data bits</b> per frame
2393 - with default bit order
2394 - at default bus speed
2395 - for default number of data items
2397 \note In Test Mode <b>Loopback</b> this test is skipped
2399 void SPI_Data_Bits_4 (void) {
2401 #if (SPI_SERVER_USED != 0)
2402 if (InitDriver() != EXIT_SUCCESS) { return; }
2403 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2404 if (CheckServer() != EXIT_SUCCESS) { return; }
2405 if ((spi_serv_cap.db_mask & (1U << 3)) == 0U) { // If SPI Server does not support data bits setting
2406 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2410 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 4U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2411 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 4U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2412 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 4U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2415 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2419 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2421 \brief Function: Function SPI_Data_Bits_5
2423 The function \b SPI_Data_Bits_5 verifies data exchange:
2424 - in Master Mode with default Slave Select mode
2425 - with default clock / frame format
2426 - with <b>5 data bits</b> per frame
2427 - with default bit order
2428 - at default bus speed
2429 - for default number of data items
2431 \note In Test Mode <b>Loopback</b> this test is skipped
2433 void SPI_Data_Bits_5 (void) {
2435 #if (SPI_SERVER_USED != 0)
2436 if (InitDriver() != EXIT_SUCCESS) { return; }
2437 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2438 if (CheckServer() != EXIT_SUCCESS) { return; }
2439 if ((spi_serv_cap.db_mask & (1U << 4)) == 0U) { // If SPI Server does not support data bits setting
2440 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2444 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 5U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2445 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 5U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2446 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 5U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2449 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2453 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2455 \brief Function: Function SPI_Data_Bits_6
2457 The function \b SPI_Data_Bits_6 verifies data exchange:
2458 - in Master Mode with default Slave Select mode
2459 - with default clock / frame format
2460 - with <b>6 data bits</b> per frame
2461 - with default bit order
2462 - at default bus speed
2463 - for default number of data items
2465 \note In Test Mode <b>Loopback</b> this test is skipped
2467 void SPI_Data_Bits_6 (void) {
2469 #if (SPI_SERVER_USED != 0)
2470 if (InitDriver() != EXIT_SUCCESS) { return; }
2471 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2472 if (CheckServer() != EXIT_SUCCESS) { return; }
2473 if ((spi_serv_cap.db_mask & (1U << 5)) == 0U) { // If SPI Server does not support data bits setting
2474 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2478 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 6U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2479 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 6U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2480 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 6U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2483 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2487 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2489 \brief Function: Function SPI_Data_Bits_7
2491 The function \b SPI_Data_Bits_7 verifies data exchange:
2492 - in Master Mode with default Slave Select mode
2493 - with default clock / frame format
2494 - with <b>7 data bits</b> per frame
2495 - with default bit order
2496 - at default bus speed
2497 - for default number of data items
2499 \note In Test Mode <b>Loopback</b> this test is skipped
2501 void SPI_Data_Bits_7 (void) {
2503 #if (SPI_SERVER_USED != 0)
2504 if (InitDriver() != EXIT_SUCCESS) { return; }
2505 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2506 if (CheckServer() != EXIT_SUCCESS) { return; }
2507 if ((spi_serv_cap.db_mask & (1U << 6)) == 0U) { // If SPI Server does not support data bits setting
2508 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2512 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 7U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2513 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 7U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2514 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 7U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2517 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2521 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2523 \brief Function: Function SPI_Data_Bits_8
2525 The function \b SPI_Data_Bits_8 verifies data exchange:
2526 - in Master Mode with default Slave Select mode
2527 - with default clock / frame format
2528 - with <b>8 data bits</b> per frame
2529 - with default bit order
2530 - at default bus speed
2531 - for default number of data items
2533 void SPI_Data_Bits_8 (void) {
2535 if (InitDriver() != EXIT_SUCCESS) { return; }
2536 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2537 #if (SPI_SERVER_USED != 0)
2538 if (CheckServer() != EXIT_SUCCESS) { return; }
2539 if ((spi_serv_cap.db_mask & (1U << 7)) == 0U) { // If SPI Server does not support data bits setting
2540 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2545 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 8U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2546 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 8U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2547 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 8U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2550 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2552 \brief Function: Function SPI_Data_Bits_9
2554 The function \b SPI_Data_Bits_9 verifies data exchange:
2555 - in Master Mode with default Slave Select mode
2556 - with default clock / frame format
2557 - with <b>9 data bits</b> per frame
2558 - with default bit order
2559 - at default bus speed
2560 - for default number of data items
2562 \note In Test Mode <b>Loopback</b> this test is skipped
2564 void SPI_Data_Bits_9 (void) {
2566 #if (SPI_SERVER_USED != 0)
2567 if (InitDriver() != EXIT_SUCCESS) { return; }
2568 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2569 if (CheckServer() != EXIT_SUCCESS) { return; }
2570 if ((spi_serv_cap.db_mask & (1U << 8)) == 0U) { // If SPI Server does not support data bits setting
2571 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2575 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 9U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2576 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 9U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2577 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 9U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2580 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2584 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2586 \brief Function: Function SPI_Data_Bits_10
2588 The function \b SPI_Data_Bits_10 verifies data exchange:
2589 - in Master Mode with default Slave Select mode
2590 - with default clock / frame format
2591 - with <b>10 data bits</b> per frame
2592 - with default bit order
2593 - at default bus speed
2594 - for default number of data items
2596 \note In Test Mode <b>Loopback</b> this test is skipped
2598 void SPI_Data_Bits_10 (void) {
2600 #if (SPI_SERVER_USED != 0)
2601 if (InitDriver() != EXIT_SUCCESS) { return; }
2602 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2603 if (CheckServer() != EXIT_SUCCESS) { return; }
2604 if ((spi_serv_cap.db_mask & (1U << 9)) == 0U) { // If SPI Server does not support data bits setting
2605 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2609 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 10U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2610 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 10U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2611 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 10U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2614 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2618 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2620 \brief Function: Function SPI_Data_Bits_11
2622 The function \b SPI_Data_Bits_11 verifies data exchange:
2623 - in Master Mode with default Slave Select mode
2624 - with default clock / frame format
2625 - with <b>11 data bits</b> per frame
2626 - with default bit order
2627 - at default bus speed
2628 - for default number of data items
2630 \note In Test Mode <b>Loopback</b> this test is skipped
2632 void SPI_Data_Bits_11 (void) {
2634 #if (SPI_SERVER_USED != 0)
2635 if (InitDriver() != EXIT_SUCCESS) { return; }
2636 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2637 if (CheckServer() != EXIT_SUCCESS) { return; }
2638 if ((spi_serv_cap.db_mask & (1U << 10)) == 0U) { // If SPI Server does not support data bits setting
2639 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2643 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 11U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2644 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 11U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2645 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 11U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2648 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2652 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2654 \brief Function: Function SPI_Data_Bits_12
2656 The function \b SPI_Data_Bits_12 verifies data exchange:
2657 - in Master Mode with default Slave Select mode
2658 - with default clock / frame format
2659 - with <b>12 data bits</b> per frame
2660 - with default bit order
2661 - at default bus speed
2662 - for default number of data items
2664 \note In Test Mode <b>Loopback</b> this test is skipped
2666 void SPI_Data_Bits_12 (void) {
2668 #if (SPI_SERVER_USED != 0)
2669 if (InitDriver() != EXIT_SUCCESS) { return; }
2670 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2671 if (CheckServer() != EXIT_SUCCESS) { return; }
2672 if ((spi_serv_cap.db_mask & (1U << 11)) == 0U) { // If SPI Server does not support data bits setting
2673 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2677 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 12U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2678 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 12U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2679 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 12U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2682 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2686 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2688 \brief Function: Function SPI_Data_Bits_13
2690 The function \b SPI_Data_Bits_13 verifies data exchange:
2691 - in Master Mode with default Slave Select mode
2692 - with default clock / frame format
2693 - with <b>13 data bits</b> per frame
2694 - with default bit order
2695 - at default bus speed
2696 - for default number of data items
2698 \note In Test Mode <b>Loopback</b> this test is skipped
2700 void SPI_Data_Bits_13 (void) {
2702 #if (SPI_SERVER_USED != 0)
2703 if (InitDriver() != EXIT_SUCCESS) { return; }
2704 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2705 if (CheckServer() != EXIT_SUCCESS) { return; }
2706 if ((spi_serv_cap.db_mask & (1U << 12)) == 0U) { // If SPI Server does not support data bits setting
2707 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2711 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 13U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2712 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 13U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2713 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 13U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2716 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2720 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2722 \brief Function: Function SPI_Data_Bits_14
2724 The function \b SPI_Data_Bits_14 verifies data exchange:
2725 - in Master Mode with default Slave Select mode
2726 - with default clock / frame format
2727 - with <b>14 data bits</b> per frame
2728 - with default bit order
2729 - at default bus speed
2730 - for default number of data items
2732 \note In Test Mode <b>Loopback</b> this test is skipped
2734 void SPI_Data_Bits_14 (void) {
2736 #if (SPI_SERVER_USED != 0)
2737 if (InitDriver() != EXIT_SUCCESS) { return; }
2738 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2739 if (CheckServer() != EXIT_SUCCESS) { return; }
2740 if ((spi_serv_cap.db_mask & (1U << 13)) == 0U) { // If SPI Server does not support data bits setting
2741 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2745 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 14U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2746 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 14U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2747 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 14U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2750 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2754 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2756 \brief Function: Function SPI_Data_Bits_15
2758 The function \b SPI_Data_Bits_15 verifies data exchange:
2759 - in Master Mode with default Slave Select mode
2760 - with default clock / frame format
2761 - with <b>15 data bits</b> per frame
2762 - with default bit order
2763 - at default bus speed
2764 - for default number of data items
2766 \note In Test Mode <b>Loopback</b> this test is skipped
2768 void SPI_Data_Bits_15 (void) {
2770 #if (SPI_SERVER_USED != 0)
2771 if (InitDriver() != EXIT_SUCCESS) { return; }
2772 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2773 if (CheckServer() != EXIT_SUCCESS) { return; }
2774 if ((spi_serv_cap.db_mask & (1U << 14)) == 0U) { // If SPI Server does not support data bits setting
2775 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2779 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 15U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2780 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 15U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2781 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 15U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2784 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2788 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2790 \brief Function: Function SPI_Data_Bits_16
2792 The function \b SPI_Data_Bits_16 verifies data exchange:
2793 - in Master Mode with default Slave Select mode
2794 - with default clock / frame format
2795 - with <b>16 data bits</b> per frame
2796 - with default bit order
2797 - at default bus speed
2798 - for default number of data items
2800 void SPI_Data_Bits_16 (void) {
2802 if (InitDriver() != EXIT_SUCCESS) { return; }
2803 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2804 #if (SPI_SERVER_USED != 0)
2805 if (CheckServer() != EXIT_SUCCESS) { return; }
2806 if ((spi_serv_cap.db_mask & (1U << 15)) == 0U) { // If SPI Server does not support data bits setting
2807 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2812 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 16U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2813 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 16U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2814 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 16U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2817 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2819 \brief Function: Function SPI_Data_Bits_17
2821 The function \b SPI_Data_Bits_17 verifies data exchange:
2822 - in Master Mode with default Slave Select mode
2823 - with default clock / frame format
2824 - with <b>17 data bits</b> per frame
2825 - with default bit order
2826 - at default bus speed
2827 - for default number of data items
2829 \note In Test Mode <b>Loopback</b> this test is skipped
2831 void SPI_Data_Bits_17 (void) {
2833 #if (SPI_SERVER_USED != 0)
2834 if (InitDriver() != EXIT_SUCCESS) { return; }
2835 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2836 if (CheckServer() != EXIT_SUCCESS) { return; }
2837 if ((spi_serv_cap.db_mask & (1U << 16)) == 0U) { // If SPI Server does not support data bits setting
2838 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2842 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 17U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2843 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 17U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2844 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 17U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2847 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2851 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2853 \brief Function: Function SPI_Data_Bits_18
2855 The function \b SPI_Data_Bits_18 verifies data exchange:
2856 - in Master Mode with default Slave Select mode
2857 - with default clock / frame format
2858 - with <b>18 data bits</b> per frame
2859 - with default bit order
2860 - at default bus speed
2861 - for default number of data items
2863 \note In Test Mode <b>Loopback</b> this test is skipped
2865 void SPI_Data_Bits_18 (void) {
2867 #if (SPI_SERVER_USED != 0)
2868 if (InitDriver() != EXIT_SUCCESS) { return; }
2869 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2870 if (CheckServer() != EXIT_SUCCESS) { return; }
2871 if ((spi_serv_cap.db_mask & (1U << 17)) == 0U) { // If SPI Server does not support data bits setting
2872 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2876 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 18U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2877 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 18U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2878 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 18U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2881 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2885 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2887 \brief Function: Function SPI_Data_Bits_19
2889 The function \b SPI_Data_Bits_19 verifies data exchange:
2890 - in Master Mode with default Slave Select mode
2891 - with default clock / frame format
2892 - with <b>19 data bits</b> per frame
2893 - with default bit order
2894 - at default bus speed
2895 - for default number of data items
2897 \note In Test Mode <b>Loopback</b> this test is skipped
2899 void SPI_Data_Bits_19 (void) {
2901 #if (SPI_SERVER_USED != 0)
2902 if (InitDriver() != EXIT_SUCCESS) { return; }
2903 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2904 if (CheckServer() != EXIT_SUCCESS) { return; }
2905 if ((spi_serv_cap.db_mask & (1U << 18)) == 0U) { // If SPI Server does not support data bits setting
2906 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2910 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 19U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2911 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 19U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2912 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 19U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2915 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2919 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2921 \brief Function: Function SPI_Data_Bits_20
2923 The function \b SPI_Data_Bits_20 verifies data exchange:
2924 - in Master Mode with default Slave Select mode
2925 - with default clock / frame format
2926 - with <b>20 data bits</b> per frame
2927 - with default bit order
2928 - at default bus speed
2929 - for default number of data items
2931 \note In Test Mode <b>Loopback</b> this test is skipped
2933 void SPI_Data_Bits_20 (void) {
2935 #if (SPI_SERVER_USED != 0)
2936 if (InitDriver() != EXIT_SUCCESS) { return; }
2937 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2938 if (CheckServer() != EXIT_SUCCESS) { return; }
2939 if ((spi_serv_cap.db_mask & (1U << 19)) == 0U) { // If SPI Server does not support data bits setting
2940 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2944 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 20U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2945 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 20U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2946 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 20U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2949 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2953 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2955 \brief Function: Function SPI_Data_Bits_21
2957 The function \b SPI_Data_Bits_21 verifies data exchange:
2958 - in Master Mode with default Slave Select mode
2959 - with default clock / frame format
2960 - with <b>21 data bits</b> per frame
2961 - with default bit order
2962 - at default bus speed
2963 - for default number of data items
2965 \note In Test Mode <b>Loopback</b> this test is skipped
2967 void SPI_Data_Bits_21 (void) {
2969 #if (SPI_SERVER_USED != 0)
2970 if (InitDriver() != EXIT_SUCCESS) { return; }
2971 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2972 if (CheckServer() != EXIT_SUCCESS) { return; }
2973 if ((spi_serv_cap.db_mask & (1U << 20)) == 0U) { // If SPI Server does not support data bits setting
2974 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2978 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 21U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2979 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 21U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2980 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 21U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
2983 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2987 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2989 \brief Function: Function SPI_Data_Bits_22
2991 The function \b SPI_Data_Bits_22 verifies data exchange:
2992 - in Master Mode with default Slave Select mode
2993 - with default clock / frame format
2994 - with <b>22 data bits</b> per frame
2995 - with default bit order
2996 - at default bus speed
2997 - for default number of data items
2999 \note In Test Mode <b>Loopback</b> this test is skipped
3001 void SPI_Data_Bits_22 (void) {
3003 #if (SPI_SERVER_USED != 0)
3004 if (InitDriver() != EXIT_SUCCESS) { return; }
3005 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3006 if (CheckServer() != EXIT_SUCCESS) { return; }
3007 if ((spi_serv_cap.db_mask & (1U << 21)) == 0U) { // If SPI Server does not support data bits setting
3008 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3012 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 22U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3013 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 22U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3014 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 22U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3017 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3021 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3023 \brief Function: Function SPI_Data_Bits_23
3025 The function \b SPI_Data_Bits_23 verifies data exchange:
3026 - in Master Mode with default Slave Select mode
3027 - with default clock / frame format
3028 - with <b>23 data bits</b> per frame
3029 - with default bit order
3030 - at default bus speed
3031 - for default number of data items
3033 \note In Test Mode <b>Loopback</b> this test is skipped
3035 void SPI_Data_Bits_23 (void) {
3037 #if (SPI_SERVER_USED != 0)
3038 if (InitDriver() != EXIT_SUCCESS) { return; }
3039 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3040 if (CheckServer() != EXIT_SUCCESS) { return; }
3041 if ((spi_serv_cap.db_mask & (1U << 22)) == 0U) { // If SPI Server does not support data bits setting
3042 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3046 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 23U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3047 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 23U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3048 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 23U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3051 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3055 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3057 \brief Function: Function SPI_Data_Bits_24
3059 The function \b SPI_Data_Bits_24 verifies data exchange:
3060 - in Master Mode with default Slave Select mode
3061 - with default clock / frame format
3062 - with <b>24 data bits</b> per frame
3063 - with default bit order
3064 - at default bus speed
3065 - for default number of data items
3067 void SPI_Data_Bits_24 (void) {
3069 if (InitDriver() != EXIT_SUCCESS) { return; }
3070 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3071 #if (SPI_SERVER_USED != 0)
3072 if (CheckServer() != EXIT_SUCCESS) { return; }
3073 if ((spi_serv_cap.db_mask & (1U << 23)) == 0U) { // If SPI Server does not support data bits setting
3074 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3079 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 24U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3080 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 24U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3081 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 24U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3084 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3086 \brief Function: Function SPI_Data_Bits_25
3088 The function \b SPI_Data_Bits_25 verifies data exchange:
3089 - in Master Mode with default Slave Select mode
3090 - with default clock / frame format
3091 - with <b>25 data bits</b> per frame
3092 - with default bit order
3093 - at default bus speed
3094 - for default number of data items
3096 \note In Test Mode <b>Loopback</b> this test is skipped
3098 void SPI_Data_Bits_25 (void) {
3100 #if (SPI_SERVER_USED != 0)
3101 if (InitDriver() != EXIT_SUCCESS) { return; }
3102 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3103 if (CheckServer() != EXIT_SUCCESS) { return; }
3104 if ((spi_serv_cap.db_mask & (1U << 24)) == 0U) { // If SPI Server does not support data bits setting
3105 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3109 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 25U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3110 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 25U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3111 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 25U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3114 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3118 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3120 \brief Function: Function SPI_Data_Bits_26
3122 The function \b SPI_Data_Bits_26 verifies data exchange:
3123 - in Master Mode with default Slave Select mode
3124 - with default clock / frame format
3125 - with <b>26 data bits</b> per frame
3126 - with default bit order
3127 - at default bus speed
3128 - for default number of data items
3130 \note In Test Mode <b>Loopback</b> this test is skipped
3132 void SPI_Data_Bits_26 (void) {
3134 #if (SPI_SERVER_USED != 0)
3135 if (InitDriver() != EXIT_SUCCESS) { return; }
3136 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3137 if (CheckServer() != EXIT_SUCCESS) { return; }
3138 if ((spi_serv_cap.db_mask & (1U << 25)) == 0U) { // If SPI Server does not support data bits setting
3139 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3143 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 26U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3144 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 26U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3145 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 26U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3148 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3152 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3154 \brief Function: Function SPI_Data_Bits_27
3156 The function \b SPI_Data_Bits_27 verifies data exchange:
3157 - in Master Mode with default Slave Select mode
3158 - with default clock / frame format
3159 - with <b>27 data bits</b> per frame
3160 - with default bit order
3161 - at default bus speed
3162 - for default number of data items
3164 \note In Test Mode <b>Loopback</b> this test is skipped
3166 void SPI_Data_Bits_27 (void) {
3168 #if (SPI_SERVER_USED != 0)
3169 if (InitDriver() != EXIT_SUCCESS) { return; }
3170 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3171 if (CheckServer() != EXIT_SUCCESS) { return; }
3172 if ((spi_serv_cap.db_mask & (1U << 26)) == 0U) { // If SPI Server does not support data bits setting
3173 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3177 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 27U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3178 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 27U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3179 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 27U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3182 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3186 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3188 \brief Function: Function SPI_Data_Bits_28
3190 The function \b SPI_Data_Bits_28 verifies data exchange:
3191 - in Master Mode with default Slave Select mode
3192 - with default clock / frame format
3193 - with <b>28 data bits</b> per frame
3194 - with default bit order
3195 - at default bus speed
3196 - for default number of data items
3198 \note In Test Mode <b>Loopback</b> this test is skipped
3200 void SPI_Data_Bits_28 (void) {
3202 #if (SPI_SERVER_USED != 0)
3203 if (InitDriver() != EXIT_SUCCESS) { return; }
3204 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3205 if (CheckServer() != EXIT_SUCCESS) { return; }
3206 if ((spi_serv_cap.db_mask & (1U << 27)) == 0U) { // If SPI Server does not support data bits setting
3207 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3211 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 28U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3212 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 28U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3213 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 28U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3216 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3220 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3222 \brief Function: Function SPI_Data_Bits_29
3224 The function \b SPI_Data_Bits_29 verifies data exchange:
3225 - in Master Mode with default Slave Select mode
3226 - with default clock / frame format
3227 - with <b>29 data bits</b> per frame
3228 - with default bit order
3229 - at default bus speed
3230 - for default number of data items
3232 \note In Test Mode <b>Loopback</b> this test is skipped
3234 void SPI_Data_Bits_29 (void) {
3236 #if (SPI_SERVER_USED != 0)
3237 if (InitDriver() != EXIT_SUCCESS) { return; }
3238 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3239 if (CheckServer() != EXIT_SUCCESS) { return; }
3240 if ((spi_serv_cap.db_mask & (1U << 28)) == 0U) { // If SPI Server does not support data bits setting
3241 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3245 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 29U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3246 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 29U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3247 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 29U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3250 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3254 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3256 \brief Function: Function SPI_Data_Bits_30
3258 The function \b SPI_Data_Bits_30 verifies data exchange:
3259 - in Master Mode with default Slave Select mode
3260 - with default clock / frame format
3261 - with <b>30 data bits</b> per frame
3262 - with default bit order
3263 - at default bus speed
3264 - for default number of data items
3266 \note In Test Mode <b>Loopback</b> this test is skipped
3268 void SPI_Data_Bits_30 (void) {
3270 #if (SPI_SERVER_USED != 0)
3271 if (InitDriver() != EXIT_SUCCESS) { return; }
3272 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3273 if (CheckServer() != EXIT_SUCCESS) { return; }
3274 if ((spi_serv_cap.db_mask & (1U << 29)) == 0U) { // If SPI Server does not support data bits setting
3275 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3279 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 30U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3280 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 30U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3281 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 30U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3284 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3288 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3290 \brief Function: Function SPI_Data_Bits_31
3292 The function \b SPI_Data_Bits_31 verifies data exchange:
3293 - in Master Mode with default Slave Select mode
3294 - with default clock / frame format
3295 - with <b>31 data bits</b> per frame
3296 - with default bit order
3297 - at default bus speed
3298 - for default number of data items
3300 \note In Test Mode <b>Loopback</b> this test is skipped
3302 void SPI_Data_Bits_31 (void) {
3304 #if (SPI_SERVER_USED != 0)
3305 if (InitDriver() != EXIT_SUCCESS) { return; }
3306 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3307 if (CheckServer() != EXIT_SUCCESS) { return; }
3308 if ((spi_serv_cap.db_mask & (1U << 30)) == 0U) { // If SPI Server does not support data bits setting
3309 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3313 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 31U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3314 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 31U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3315 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 31U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3318 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3322 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3324 \brief Function: Function SPI_Data_Bits_32
3326 The function \b SPI_Data_Bits_32 verifies data exchange:
3327 - in Master Mode with default Slave Select mode
3328 - with default clock / frame format
3329 - with <b>32 data bits</b> per frame
3330 - with default bit order
3331 - at default bus speed
3332 - for default number of data items
3334 void SPI_Data_Bits_32 (void) {
3336 if (InitDriver() != EXIT_SUCCESS) { return; }
3337 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3338 #if (SPI_SERVER_USED != 0)
3339 if (CheckServer() != EXIT_SUCCESS) { return; }
3340 if ((spi_serv_cap.db_mask & (1UL << 31)) == 0U) { // If SPI Server does not support data bits setting
3341 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3346 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, 32U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3347 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, 32U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3348 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, 32U, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3351 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3353 \brief Function: Function SPI_Bit_Order_MSB_LSB
3355 The function \b SPI_Bit_Order_MSB_LSB verifies data exchange:
3356 - in Master Mode with default Slave Select mode
3357 - with default clock / frame format
3358 - with default data bits
3359 - with bit order <b>from MSB to LSB</b>
3360 - at default bus speed
3361 - for default number of data items
3363 \note In Test Mode <b>Loopback</b> this test is skipped
3365 void SPI_Bit_Order_MSB_LSB (void) {
3367 #if (SPI_SERVER_USED != 0)
3368 if (InitDriver() != EXIT_SUCCESS) { return; }
3369 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3370 if (CheckServer() != EXIT_SUCCESS) { return; }
3371 if ((spi_serv_cap.bo_mask & 1U) == 0U) { // If SPI Server does not support bit order setting
3372 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3376 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3377 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3378 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_MSB_TO_LSB, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3381 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3385 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3387 \brief Function: Function SPI_Bit_Order_LSB_MSB
3389 The function \b SPI_Bit_Order_LSB_MSB verifies data exchange:
3390 - in Master Mode with default Slave Select mode
3391 - with default clock / frame format
3392 - with default data bits
3393 - with bit order <b>from LSB to MSB</b>
3394 - at default bus speed
3395 - for default number of data items
3397 \note In Test Mode <b>Loopback</b> this test is skipped
3399 void SPI_Bit_Order_LSB_MSB (void) {
3401 #if (SPI_SERVER_USED != 0)
3402 if (InitDriver() != EXIT_SUCCESS) { return; }
3403 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3404 if (CheckServer() != EXIT_SUCCESS) { return; }
3405 if ((spi_serv_cap.bo_mask & 2U) == 0U) { // If SPI Server does not support bit order setting
3406 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3410 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_LSB_TO_MSB, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3411 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_LSB_TO_MSB, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3412 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, BO_LSB_TO_MSB, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3415 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3419 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3421 \brief Function: Function SPI_Bus_Speed_Min
3423 The function \b SPI_Bus_Speed_Min verifies data exchange:
3424 - in Master Mode with default Slave Select mode
3425 - with default clock / frame format
3426 - with default data bits
3427 - with default bit order
3428 - at <b>minimum bus speed</b> (define <c>SPI_CFG_MIN_BUS_SPEED</c> in DV_SPI_Config.h)
3429 - for default number of data items
3431 This test function checks the following requirements:
3432 - measured bus speed is not 25% lower, or higher than requested
3433 - bus speed value returned by the driver is not negative
3434 - bus speed value returned by the driver is not higher then requested
3435 - bus speed value returned by the driver is not lower then 75% of requested
3437 void SPI_Bus_Speed_Min (void) {
3438 volatile uint64_t bps;
3439 volatile int32_t got_bus_speed;
3441 if (InitDriver() != EXIT_SUCCESS) { return; }
3442 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3443 #if (SPI_SERVER_USED != 0)
3444 if (CheckServer() != EXIT_SUCCESS) { return; }
3445 if (spi_serv_cap.bs_min > SPI_CFG_MIN_BUS_SPEED) { // If SPI Server does not support minimum bus speed
3446 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3451 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_MIN_BUS_SPEED, SPI_CFG_DEF_NUM);
3452 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_MIN_BUS_SPEED, SPI_CFG_DEF_NUM);
3453 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_MIN_BUS_SPEED, SPI_CFG_DEF_NUM);
3455 if (duration != 0xFFFFFFFFU) { // If Transfer finished before timeout
3456 if (duration != 0U) { // If duration of transfer was more than 0 SysTick counts
3457 bps = ((uint64_t)systick_freq * SPI_CFG_DEF_DATA_BITS * SPI_CFG_DEF_NUM) / duration;
3458 if ((bps < ((SPI_CFG_MIN_BUS_SPEED * 3) / 4)) ||
3459 (bps > SPI_CFG_MIN_BUS_SPEED)) {
3460 // If measured bus speed is 25% lower, or higher than requested
3461 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] At requested bus speed of %i bps, effective bus speed is %i bps", SPI_CFG_MIN_BUS_SPEED, (uint32_t)bps);
3462 TEST_MESSAGE(msg_buf);
3467 drv->Control (ARM_SPI_SET_BUS_SPEED, SPI_CFG_MIN_BUS_SPEED);
3468 got_bus_speed = drv->Control (ARM_SPI_GET_BUS_SPEED, 0U);
3469 if (got_bus_speed < 0) {
3470 // If bus speed value returned by the driver is negative
3471 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned negative value %i", got_bus_speed);
3472 TEST_FAIL_MESSAGE(msg_buf);
3473 } else if ((uint32_t)got_bus_speed > SPI_CFG_MIN_BUS_SPEED) {
3474 // If bus speed value returned by the driver is higher then requested
3475 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned %i bps instead of requested %i bps", got_bus_speed, SPI_CFG_MIN_BUS_SPEED);
3476 TEST_FAIL_MESSAGE(msg_buf);
3477 } else if ((uint32_t)got_bus_speed < ((SPI_CFG_MIN_BUS_SPEED * 3) / 4)) {
3478 // If bus speed value returned by the driver is lower then 75% of requested
3479 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] Get bus speed returned %i bps instead of requested %i bps", got_bus_speed, SPI_CFG_MIN_BUS_SPEED);
3480 TEST_MESSAGE(msg_buf);
3484 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3486 \brief Function: Function SPI_Bus_Speed_Max
3488 The function \b SPI_Bus_Speed_Max verifies data exchange:
3489 - in Master Mode with default Slave Select mode
3490 - with default clock / frame format
3491 - with default data bits
3492 - with default bit order
3493 - at <b>maximum bus speed</b> (define <c>SPI_CFG_MAX_BUS_SPEED</c> in DV_SPI_Config.h)
3494 - for default number of data items
3496 This test function checks the following requirements:
3497 - measured bus speed is not 25% lower, or higher than requested
3498 - bus speed value returned by the driver is not negative
3499 - bus speed value returned by the driver is not higher then requested
3500 - bus speed value returned by the driver is not lower then 75% of requested
3502 void SPI_Bus_Speed_Max (void) {
3503 volatile uint64_t bps;
3504 volatile int32_t got_bus_speed;
3506 if (InitDriver() != EXIT_SUCCESS) { return; }
3507 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3508 #if (SPI_SERVER_USED != 0)
3509 if (CheckServer() != EXIT_SUCCESS) { return; }
3510 if (spi_serv_cap.bs_max < SPI_CFG_MAX_BUS_SPEED) { // If SPI Server does not support maximum bus speed
3511 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3516 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_MAX_BUS_SPEED, SPI_CFG_DEF_NUM);
3517 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_MAX_BUS_SPEED, SPI_CFG_DEF_NUM);
3518 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_MAX_BUS_SPEED, SPI_CFG_DEF_NUM);
3520 if (duration != 0xFFFFFFFFU) { // If Transfer finished before timeout
3521 if (duration != 0U) { // If duration of transfer was more than 0 SysTick counts
3522 bps = ((uint64_t)systick_freq * SPI_CFG_DEF_DATA_BITS * SPI_CFG_DEF_NUM) / duration;
3523 if ((bps < ((SPI_CFG_MAX_BUS_SPEED * 3) / 4)) ||
3524 (bps > SPI_CFG_MIN_BUS_SPEED)) {
3525 // If measured bus speed is 25% lower, or higher than requested
3526 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] At requested bus speed of %i bps, effective bus speed is %i bps", SPI_CFG_MAX_BUS_SPEED, (uint32_t)bps);
3527 TEST_MESSAGE(msg_buf);
3532 drv->Control (ARM_SPI_SET_BUS_SPEED, SPI_CFG_MAX_BUS_SPEED);
3533 got_bus_speed = drv->Control (ARM_SPI_GET_BUS_SPEED, 0U);
3534 if (got_bus_speed < 0) {
3535 // If bus speed value returned by the driver is negative
3536 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned negative value %i", got_bus_speed);
3537 TEST_FAIL_MESSAGE(msg_buf);
3538 } else if ((uint32_t)got_bus_speed > SPI_CFG_MAX_BUS_SPEED) {
3539 // If bus speed value returned by the driver is higher then requested
3540 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned %i bps instead of requested %i bps", got_bus_speed, SPI_CFG_MAX_BUS_SPEED);
3541 TEST_FAIL_MESSAGE(msg_buf);
3542 } else if ((uint32_t)got_bus_speed < ((SPI_CFG_MAX_BUS_SPEED * 3) / 4)) {
3543 // If bus speed value returned by the driver is lower then 75% of requested
3544 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] Get bus speed returned %i bps instead of requested %i bps", got_bus_speed, SPI_CFG_MAX_BUS_SPEED);
3545 TEST_MESSAGE(msg_buf);
3549 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3551 \brief Function: Function SPI_Number_Of_Items
3553 The function \b SPI_Number_Of_Items verifies data exchange:
3554 - in Master Mode with default Slave Select mode
3555 - with default clock / frame format
3556 - with default data bits
3557 - with default bit order
3558 - at default bus speed
3559 - for <b>different number of items</b> (defines <c>SPI_CFG_NUM1 .. SPI_CFG_NUM5</c> in DV_SPI_Config.h)
3561 void SPI_Number_Of_Items (void) {
3563 if (InitDriver() != EXIT_SUCCESS) { return; }
3564 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3565 #if (SPI_SERVER_USED != 0)
3566 if (CheckServer() != EXIT_SUCCESS) { return; }
3567 if ((spi_serv_cap.mode_mask & 2U) == 0U) { // If SPI Server does not support Slave mode
3568 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3573 #if (SPI_CFG_NUM1 != 0U)
3574 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM1);
3575 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM1);
3576 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM1);
3579 #if (SPI_CFG_NUM2 != 0U)
3580 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM2);
3581 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM2);
3582 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM2);
3585 #if (SPI_CFG_NUM3 != 0U)
3586 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM3);
3587 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM3);
3588 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM3);
3591 #if (SPI_CFG_NUM4 != 0U)
3592 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM4);
3593 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM4);
3594 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM4);
3597 #if (SPI_CFG_NUM5 != 0U)
3598 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM5);
3599 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM5);
3600 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SS_MODE_MASTER_SW, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM5);
3604 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3606 \brief Function: Function SPI_Abort
3608 The function \b SPI_Abort verifies data exchange Abort:
3609 - in Master Mode with default Slave Select mode
3610 - with default clock / frame format
3611 - with default data bits
3612 - with default bit order
3613 - at default bus speed
3615 void SPI_Abort (void) {
3617 if (InitDriver() != EXIT_SUCCESS) { return; }
3618 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3619 #if (SPI_SERVER_USED != 0)
3620 if (CheckServer() != EXIT_SUCCESS) { return; }
3623 SPI_DataExchange_Operation(OP_ABORT_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3624 SPI_DataExchange_Operation(OP_ABORT_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3625 SPI_DataExchange_Operation(OP_ABORT_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3631 // End of spi_tests_data_xchg
3633 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3634 /* SPI Error Event tests */
3635 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3637 \defgroup spi_tests_err_evt Error Event
3640 These tests verify API and operation of the SPI error event signaling.
3642 The error event tests verify the following driver function
3643 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
3646 void (*ARM_SPI_SignalEvent_t) (uint32_t event);
3649 \note In Test Mode <b>Loopback</b> these tests are skipped
3653 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3655 \brief Function: Function SPI_DataLost
3657 The function \b SPI_DataLost verifies signaling of the <b>ARM_SPI_EVENT_DATA_LOST</b> event:
3658 - in <b>Slave Mode</b> with <b>Slave Select line Hardware Monitored</b>
3659 - with default clock / frame format
3660 - with default data bits
3661 - with default bit order
3662 - at default bus speed
3664 void SPI_DataLost (void) {
3666 #if (SPI_SERVER_USED != 0)
3667 if (InitDriver() != EXIT_SUCCESS) { return; }
3668 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3669 if (CheckServer() != EXIT_SUCCESS) { return; }
3672 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3673 if (CmdSetCom (0U, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, 1U, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { break; }
3674 if (CmdXfer (SPI_CFG_DEF_NUM, 20U, SPI_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
3676 (void)drv->Control (ARM_SPI_MODE_SLAVE |
3677 ((SPI_CFG_DEF_FORMAT << ARM_SPI_FRAME_FORMAT_Pos) & ARM_SPI_FRAME_FORMAT_Msk) |
3678 ((SPI_CFG_DEF_DATA_BITS << ARM_SPI_DATA_BITS_Pos) & ARM_SPI_DATA_BITS_Msk) |
3679 ((SPI_CFG_DEF_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos) & ARM_SPI_BIT_ORDER_Msk) |
3680 ARM_SPI_SS_SLAVE_HW ,
3681 SPI_CFG_DEF_BUS_SPEED);
3684 (void)osDelay(SPI_CFG_XFER_TIMEOUT+20U); // Wait for SPI Server to timeout
3686 // Assert that event ARM_SPI_EVENT_DATA_LOST was signaled
3687 TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_DATA_LOST) != 0U, "[FAILED] Event ARM_SPI_EVENT_DATA_LOST was not signaled!");
3693 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3697 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3699 \brief Function: Function SPI_ModeFault
3701 The function \b SPI_ModeFault verifies signaling of the <b>ARM_SPI_EVENT_MODE_FAULT</b> event:
3702 - in <b>Master Mode</b> with <b>Slave Select line Hardware Monitored Input</b>
3703 - with default clock / frame format
3704 - with default data bits
3705 - with default bit order
3706 - at default bus speed
3708 void SPI_ModeFault (void) {
3710 if (drv->GetCapabilities().event_mode_fault == 0U) {
3711 TEST_MESSAGE("[WARNING] This driver does not support ARM_SPI_EVENT_MODE_FAULT event signaling! Test skipped!");
3715 #if (SPI_SERVER_USED != 0)
3716 if (InitDriver() != EXIT_SUCCESS) { return; }
3717 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3718 if (CheckServer() != EXIT_SUCCESS) { return; }
3721 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3722 if (CmdSetCom (1U, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, 0U, SPI_CFG_DEF_BUS_SPEED) != EXIT_SUCCESS) { break; }
3723 if (CmdXfer (SPI_CFG_DEF_NUM, 0U, SPI_CFG_XFER_TIMEOUT, SPI_CFG_DEF_NUM / 2U) != EXIT_SUCCESS) { break; }
3725 (void)drv->Control (ARM_SPI_MODE_MASTER |
3726 ((SPI_CFG_DEF_FORMAT << ARM_SPI_FRAME_FORMAT_Pos) & ARM_SPI_FRAME_FORMAT_Msk) |
3727 ((SPI_CFG_DEF_DATA_BITS << ARM_SPI_DATA_BITS_Pos) & ARM_SPI_DATA_BITS_Msk) |
3728 ((SPI_CFG_DEF_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos) & ARM_SPI_BIT_ORDER_Msk) |
3729 ARM_SPI_SS_MASTER_HW_INPUT ,
3730 SPI_CFG_DEF_BUS_SPEED);
3734 TEST_ASSERT(drv->Transfer(ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
3736 (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U); // Wait for SPI Server to timeout
3738 // Assert that event ARM_SPI_EVENT_MODE_FAULT was signaled
3739 TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_MODE_FAULT) != 0U, "[FAILED] Event ARM_SPI_EVENT_MODE_FAULT was not signaled!");
3745 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3752 // End of spi_tests_err_evt