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)
121 typedef struct { // SPI Server version structure
122 uint8_t major; // Version major number
123 uint8_t minor; // Version minor number
124 uint16_t patch; // Version patch (revision) number
127 typedef struct { // SPI Server capabilities structure
128 uint32_t mode_mask; // Mode and Slave Select mask
129 uint32_t fmt_mask; // Clock Format or Frame Format mask
130 uint32_t db_mask; // Data Bits mask
131 uint32_t bo_mask; // Bit Order mask
132 uint32_t bs_min; // Min bus speed
133 uint32_t bs_max; // Max bus speed
136 // Register Driver_SPI#
137 #define _ARM_Driver_SPI_(n) Driver_SPI##n
138 #define ARM_Driver_SPI_(n) _ARM_Driver_SPI_(n)
139 extern ARM_DRIVER_SPI ARM_Driver_SPI_(DRV_SPI);
140 static ARM_DRIVER_SPI *drv = &ARM_Driver_SPI_(DRV_SPI);
142 // Global variables (used in this module only)
143 static int8_t buffers_ok;
144 static int8_t server_ok;
145 static int8_t driver_ok;
147 static SPI_SERV_CAP_t spi_serv_cap;
149 static volatile uint32_t event;
150 static volatile uint32_t duration;
151 static volatile uint32_t data_count_sample;
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(s) into global variable.
218 \detail This is a callback function called by the driver upon an event(s).
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) {
235 if (data_bits > 16U) {
237 } else if (data_bits > 8U) {
245 \fn static int32_t InitDriver (void)
246 \brief Initialize and power-on the driver.
247 \return execution status
248 - EXIT_SUCCESS: Operation successful
249 - EXIT_FAILURE: Operation failed
251 static int32_t InitDriver (void) {
253 if (driver_ok == -1) { // If -1, means it was not yet checked
255 if (drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK) {
256 if (drv->PowerControl(ARM_POWER_FULL) == ARM_DRIVER_OK) {
262 if (driver_ok == 1) {
266 TEST_FAIL_MESSAGE("[FAILED] SPI driver initialization or power-up failed. Test aborted!");
271 \fn static int32_t CheckBuffers (void)
272 \brief Check if buffers are valid.
273 \return execution status
274 - EXIT_SUCCESS: Operation successful
275 - EXIT_FAILURE: Operation failed
277 static int32_t CheckBuffers (void) {
279 if (buffers_ok == -1) { // If -1, means it was not yet checked
280 if ((ptr_tx_buf != NULL) &&
281 (ptr_rx_buf != NULL) &&
282 (ptr_cmp_buf != NULL)) {
289 if (buffers_ok == 1) {
293 TEST_FAIL_MESSAGE("[FAILED] Invalid data buffers! Increase heap memory! Test aborted!");
297 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
300 \fn static int32_t ComConfigDefault (void)
301 \brief Configure SPI Communication Interface to SPI Server default communication configuration.
302 \return execution status
303 - EXIT_SUCCESS: Operation successful
304 - EXIT_FAILURE: Operation failed
306 static int32_t ComConfigDefault (void) {
311 if (drv->Control(ARM_SPI_MODE_MASTER |
312 ((SPI_CFG_SRV_FORMAT << ARM_SPI_FRAME_FORMAT_Pos) & ARM_SPI_FRAME_FORMAT_Msk) |
313 ((SPI_CFG_SRV_DATA_BITS << ARM_SPI_DATA_BITS_Pos) & ARM_SPI_DATA_BITS_Msk) |
314 ((SPI_CFG_SRV_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos) & ARM_SPI_BIT_ORDER_Msk) |
315 ((SPI_CFG_SRV_SS_MODE << ARM_SPI_SS_MASTER_MODE_Pos) & ARM_SPI_SS_MASTER_MODE_Msk) ,
316 SPI_CFG_SRV_BUS_SPEED) != ARM_DRIVER_OK) {
320 if ((ret == EXIT_SUCCESS) && (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW)) {
321 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
326 if (ret != EXIT_SUCCESS) {
327 TEST_FAIL_MESSAGE("Failed to configure communication interface to SPI Server default settings. Testing aborted!");
330 // Give SPI Server 10 ms to prepare for reception of the command
337 \fn static int32_t ComSendCommand (const void *data_out, uint32_t num)
338 \brief Send command to SPI Server.
339 \param[out] data_out Pointer to memory containing data to be sent
340 \param[in] len Number of bytes to be sent
341 \return execution status
342 - EXIT_SUCCESS: Operation successful
343 - EXIT_FAILURE: Operation failed
345 static int32_t ComSendCommand (const void *data_out, uint32_t len) {
350 num = (len + DataBitsToBytes(SPI_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(SPI_CFG_SRV_DATA_BITS);
352 if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
353 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE) != ARM_DRIVER_OK) {
357 if (ret == EXIT_SUCCESS) {
358 if (drv->Send(data_out, num) == ARM_DRIVER_OK) {
359 for (tout = SPI_CFG_SRV_CMD_TOUT; tout != 0U; tout--) {
360 if ((drv->GetDataCount() == num) && (drv->GetStatus().busy == 0U)) {
365 if (tout == 0U) { // If send has timed out
372 if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
373 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
378 // Give SPI Server 10 ms to prepare for reception of the next command or to
379 // prepare the answer to this command, if it requires response
386 \fn static int32_t ComReceiveResponse (void *data_in, uint32_t num)
387 \brief Receive response from SPI Server.
388 \param[out] data_in Pointer to memory where data will be received
389 \param[in] len Number of data bytes to be received
390 \return execution status
391 - EXIT_SUCCESS: Operation successful
392 - EXIT_FAILURE: Operation failed
394 static int32_t ComReceiveResponse (void *data_in, uint32_t len) {
399 num = (len + DataBitsToBytes(SPI_CFG_SRV_DATA_BITS) - 1U) / DataBitsToBytes(SPI_CFG_SRV_DATA_BITS);
401 if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
402 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE) != ARM_DRIVER_OK) {
406 if (ret == EXIT_SUCCESS) {
407 if (drv->Receive(data_in, num) == ARM_DRIVER_OK) {
408 for (tout = SPI_CFG_SRV_CMD_TOUT; tout != 0U; tout--) {
409 if ((drv->GetDataCount() == num) && (drv->GetStatus().busy == 0U)) {
414 if (tout == 0U) { // If send has timed out
421 if (SPI_CFG_SRV_SS_MODE == SS_MODE_MASTER_SW) {
422 if (drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE) != ARM_DRIVER_OK) {
427 // Give SPI Server 10 ms to prepare for reception of the next command
434 \fn static int32_t CmdGetVer (void)
435 \brief Get version from SPI Server and check that it is valid.
436 \return execution status
437 - EXIT_SUCCESS: Operation successful
438 - EXIT_FAILURE: Operation failed
440 static int32_t CmdGetVer (void) {
442 SPI_SERV_VER_t spi_serv_ver;
449 memset(&spi_serv_ver, 0, sizeof(spi_serv_ver));
451 // Send "GET VER" command to SPI Server
452 memset(ptr_tx_buf, 0, CMD_LEN);
453 memcpy(ptr_tx_buf, "GET VER", 7);
454 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
456 if (ret == EXIT_SUCCESS) {
457 // Receive response to "GET VER" command from SPI Server
458 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_VER_LEN);
459 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_VER_LEN);
463 if (ret == EXIT_SUCCESS) {
465 ptr_str = (const char *)ptr_rx_buf;
466 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
467 spi_serv_ver.major = val8;
472 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
474 ptr_str = strstr(ptr_str, "."); // Find '.'
475 if (ptr_str != NULL) {
476 ptr_str++; // Skip '.'
477 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
478 spi_serv_ver.minor = val8;
486 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
487 // Parse patch (revision)
488 ptr_str = strstr(ptr_str, "."); // Find next '.'
489 if (ptr_str != NULL) {
490 ptr_str++; // Skip '.'
491 if (sscanf(ptr_str, "%hx", &val16) == 1) {
492 spi_serv_ver.patch = val16;
501 if (ret == EXIT_SUCCESS) {
502 // Only supported version is v1.0.0
503 if ((spi_serv_ver.major != 1U) ||
504 (spi_serv_ver.minor != 0U) ||
505 (spi_serv_ver.patch != 0U)) {
510 if (ret != EXIT_SUCCESS) {
511 TEST_FAIL_MESSAGE("[FAILED] Get version from SPI Server.");
518 \fn static int32_t CmdGetCap (void)
519 \brief Get capabilities from SPI Server.
520 \return execution status
521 - EXIT_SUCCESS: Operation successful
522 - EXIT_FAILURE: Operation failed
524 static int32_t CmdGetCap (void) {
532 memset(&spi_serv_cap, 0, sizeof(spi_serv_cap));
534 // Send "GET CAP" command to SPI Server
535 memset(ptr_tx_buf, 0, RESP_GET_CAP_LEN);
536 memcpy(ptr_tx_buf, "GET CAP", 7);
537 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
539 if (ret == EXIT_SUCCESS) {
540 (void)osDelay(10U); // Give SPI Server 10 ms to auto-detect capabilities
542 // Receive response to "GET CAP" command from SPI Server
543 memset(ptr_rx_buf, (int32_t)'?', RESP_GET_CAP_LEN);
544 ret = ComReceiveResponse(ptr_rx_buf, RESP_GET_CAP_LEN);
547 // Parse capabilities
548 if (ret == EXIT_SUCCESS) {
550 ptr_str = (const char *)ptr_rx_buf;
551 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
552 spi_serv_cap.mode_mask = val8;
557 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
559 ptr_str = strstr(ptr_str, ","); // Find ','
560 if (ptr_str != NULL) {
561 ptr_str++; // Skip ','
562 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
563 spi_serv_cap.fmt_mask = (uint32_t)val8;
571 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
572 // Parse data bit mask
573 ptr_str = strstr(ptr_str, ","); // Find next ','
574 if (ptr_str != NULL) {
575 ptr_str++; // Skip ','
576 if (sscanf(ptr_str, "%x", &val32) == 1) {
577 spi_serv_cap.db_mask = val32;
585 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
586 // Parse bit order mask
587 ptr_str = strstr(ptr_str, ","); // Find next ','
588 if (ptr_str != NULL) {
589 ptr_str++; // Skip ','
590 if (sscanf(ptr_str, "%hhx", &val8) == 1) {
591 spi_serv_cap.bo_mask = (uint32_t)val8;
599 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
600 // Parse minimum bus speed
601 ptr_str = strstr(ptr_str, ","); // Find next ','
602 if (ptr_str != NULL) {
603 ptr_str++; // Skip ','
604 if (sscanf(ptr_str, "%u", &val32) == 1) {
605 spi_serv_cap.bs_min = val32 * 1000U;
613 if ((ret == EXIT_SUCCESS) && (ptr_str != NULL)) {
614 // Parse maximum bus speed
615 ptr_str = strstr(ptr_str, ","); // Find next ','
616 if (ptr_str != NULL) {
617 ptr_str++; // Skip ','
618 if (sscanf(ptr_str, "%u", &val32) == 1) {
619 spi_serv_cap.bs_max = val32 * 1000U;
628 if (ret != EXIT_SUCCESS) {
629 TEST_FAIL_MESSAGE("[FAILED] Get capabilities from SPI Server.");
636 \fn static int32_t CmdSetBufTx (char pattern)
637 \brief Set Tx buffer of SPI Server to pattern.
638 \param[in] pattern Pattern to fill the buffer with
639 \return execution status
640 - EXIT_SUCCESS: Operation successful
641 - EXIT_FAILURE: Operation failed
643 static int32_t CmdSetBufTx (char pattern) {
646 // Send "SET BUF TX" command to SPI Server
647 memset(ptr_tx_buf, 0, 32);
648 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF TX,0,%02X", (int32_t)pattern);
649 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
651 if (ret != EXIT_SUCCESS) {
652 TEST_FAIL_MESSAGE("[FAILED] Set Tx buffer on SPI Server.");
659 \fn static int32_t CmdSetBufRx (char pattern)
660 \brief Set Rx buffer of SPI Server to pattern.
661 \param[in] pattern Pattern to fill the buffer with
662 \return execution status
663 - EXIT_SUCCESS: Operation successful
664 - EXIT_FAILURE: Operation failed
666 static int32_t CmdSetBufRx (char pattern) {
669 // Send "SET BUF RX" command to SPI Server
670 memset(ptr_tx_buf, 0, 32);
671 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "SET BUF RX,0,%02X", (int32_t)pattern);
672 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
674 if (ret != EXIT_SUCCESS) {
675 TEST_FAIL_MESSAGE("[FAILED] Set Rx buffer on SPI Server.");
682 \fn static int32_t CmdGetBufRx (void)
683 \brief Get Rx buffer from SPI Server (into global array pointed to by ptr_rx_buf).
684 \param[in] len Number of bytes to read from Rx buffer
685 \return execution status
686 - EXIT_SUCCESS: Operation successful
687 - EXIT_FAILURE: Operation failed
689 static int32_t CmdGetBufRx (uint32_t len) {
692 // Send "GET BUF RX" command to SPI Server
693 memset(ptr_tx_buf, 0, 32);
694 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "GET BUF RX,%i", len);
695 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
697 if (ret == EXIT_SUCCESS) {
698 // Receive response to "GET BUF RX" command from SPI Server
699 memset(ptr_rx_buf, (int32_t)'U', len);
700 ret = ComReceiveResponse(ptr_rx_buf, len);
703 if (ret != EXIT_SUCCESS) {
704 TEST_FAIL_MESSAGE("[FAILED] Get Rx buffer from SPI Server.");
711 \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)
712 \brief Set communication parameters on SPI Server for next XFER command.
713 \param[in] mode mode (0 = Master, 1 = slave)
714 \param[in] format clock / frame format:
715 - value 0 = clock polarity 0, phase 0
716 - value 1 = clock polarity 0, phase 1
717 - value 2 = clock polarity 1, phase 0
718 - value 3 = clock polarity 1, phase 1
719 - value 4 = Texas Instruments frame format
720 - value 5 = Microwire frame format
721 \param[in] data_bits data bits
723 \param[in] bit_order bit order
724 - value 0 = MSB to LSB
725 - value 1 = LSB to MSB
726 \param[in] ss_mode Slave Select mode:
728 - value 1 = used (in Master mode driven, in Slave mode monitored as hw input)
729 \param[in] bus_speed bus speed in bits per second (bps)
730 \return execution status
731 - EXIT_SUCCESS: Operation successful
732 - EXIT_FAILURE: Operation failed
734 static int32_t CmdSetCom (uint32_t mode, uint32_t format, uint32_t data_bits, uint32_t bit_order, uint32_t ss_mode, uint32_t bus_speed) {
737 // Send "SET COM" command to SPI Server
738 memset(ptr_tx_buf, 0, 32);
739 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);
740 if ((stat > 0) && (stat < CMD_LEN)) {
741 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
746 if (ret != EXIT_SUCCESS) {
747 TEST_FAIL_MESSAGE("[FAILED] Set communication settings on SPI Server.");
754 \fn static int32_t CmdXfer (uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_ss)
755 \brief Activate transfer on SPI Server.
756 \param[in] num number of items (according CMSIS SPI driver specification)
757 \param[in] delay initial delay, in milliseconds, before starting requested operation
758 (0xFFFFFFFF = delay not used)
759 \param[in] timeout timeout in milliseconds, after delay, if delay is specified
760 \param[in] num_ss number of items after which Slave Select line should be activated
761 \return execution status
762 - EXIT_SUCCESS: Operation successful
763 - EXIT_FAILURE: Operation failed
765 static int32_t CmdXfer (uint32_t num, uint32_t delay, uint32_t timeout, uint32_t num_ss) {
768 // Send "XFER" command to SPI Server
769 memset(ptr_tx_buf, 0, 32);
771 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i,%i", num, delay, timeout, num_ss);
772 } else if ((delay != osWaitForever) && (timeout != 0U)) {
773 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i,%i", num, delay, timeout);
774 } else if (delay != osWaitForever) {
775 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i,%i", num, delay);
777 (void)snprintf((char *)ptr_tx_buf, CMD_LEN, "XFER %i", num);
779 ret = ComSendCommand(ptr_tx_buf, CMD_LEN);
781 if (ret != EXIT_SUCCESS) {
782 TEST_FAIL_MESSAGE("[FAILED] Activate transfer on SPI Server.");
789 \fn static int32_t CheckServer (void)
790 \brief Check if communication with SPI Server is working and get capabilities.
791 \return execution status
792 - EXIT_SUCCESS: Operation successful
793 - EXIT_FAILURE: Operation failed
795 static int32_t CheckServer (void) {
797 if (server_ok == -1) { // If -1, means it was not yet checked
799 if (ComConfigDefault() != EXIT_SUCCESS) {
802 if (server_ok == 1) {
803 if (CmdGetVer() != EXIT_SUCCESS) {
807 if (server_ok == 1) {
808 if (CmdGetCap() != EXIT_SUCCESS) {
812 if (server_ok == 1) {
813 // Check if all default settings are supported by SPI Server
814 if ((spi_serv_cap.fmt_mask & (1UL << SPI_CFG_SRV_FORMAT)) == 0U) {
815 // If SPI Server does not support default clock / frame format
816 TEST_MESSAGE("[FAILED] Default clock / frame format setting in not supported by SPI Server!");
819 if ((spi_serv_cap.db_mask & (1UL << (SPI_CFG_SRV_DATA_BITS - 1U))) == 0U) {
820 // If SPI Server does not support default data bits
821 TEST_MESSAGE("[FAILED] Default data bits setting in not supported by SPI Server!");
824 if ((spi_serv_cap.bo_mask & (1UL << SPI_CFG_SRV_BIT_ORDER)) == 0U) {
825 // If SPI Server does not support default bit order
826 TEST_MESSAGE("[FAILED] Default bit order setting in not supported by SPI Server!");
829 if ((spi_serv_cap.bs_min > SPI_CFG_SRV_BUS_SPEED) ||
830 (spi_serv_cap.bs_max < SPI_CFG_SRV_BUS_SPEED)) {
831 // If SPI Server does not support default bus speed
832 TEST_MESSAGE("[FAILED] Default bus speed setting in not supported by SPI Server!");
838 if (server_ok == 1) {
842 TEST_FAIL_MESSAGE("[FAILED] Communication with SPI Server is not working. Test aborted!");
846 #endif // If Test Mode SPI Server is selected
849 \fn void SPI_DV_Initialize (void)
850 \brief Initialize testing environment for SPI testing.
851 \detail This function is called by the driver validation framework before SPI testing begins.
852 It initializes global variables and allocates memory buffers (from heap) used for the SPI testing.
855 void SPI_DV_Initialize (void) {
857 // Initialize global variables
862 duration = 0xFFFFFFFFUL;
863 systick_freq = osKernelGetSysTimerFreq();
865 memset(&spi_serv_cap, 0, sizeof(spi_serv_cap));
866 memset(&msg_buf, 0, sizeof(msg_buf));
868 // Allocate buffers for transmission, reception and comparison
869 // (maximum size is incremented by 4 bytes to ensure that buffer can be aligned to 4 bytes)
871 ptr_tx_buf_alloc = malloc(SPI_BUF_MAX + 4U);
872 if (((uint32_t)ptr_tx_buf_alloc & 3U) != 0U) {
873 // If allocated memory is not 4 byte aligned, use next 4 byte aligned address for ptr_tx_buf
874 ptr_tx_buf = (uint8_t *)((((uint32_t)ptr_tx_buf_alloc) + 3U) & (~3U));
876 // If allocated memory is 4 byte aligned, use it directly
877 ptr_tx_buf = (uint8_t *)ptr_tx_buf_alloc;
879 ptr_rx_buf_alloc = malloc(SPI_BUF_MAX + 4U);
880 if (((uint32_t)ptr_rx_buf_alloc & 3U) != 0U) {
881 ptr_rx_buf = (uint8_t *)((((uint32_t)ptr_rx_buf_alloc) + 3U) & (~3U));
883 ptr_rx_buf = (uint8_t *)ptr_rx_buf_alloc;
885 ptr_cmp_buf_alloc = malloc(SPI_BUF_MAX + 4U);
886 if (((uint32_t)ptr_cmp_buf_alloc & 3U) != 0U) {
887 ptr_cmp_buf = (uint8_t *)((((uint32_t)ptr_cmp_buf_alloc) + 3U) & (~3U));
889 ptr_cmp_buf = (uint8_t *)ptr_cmp_buf_alloc;
894 \fn void SPI_DV_Uninitialize (void)
895 \brief De-initialize testing environment after SPI testing.
896 \detail This function is called by the driver validation framework after SPI testing is finished.
897 It frees memory buffers used for the SPI testing.
900 void SPI_DV_Uninitialize (void) {
902 if (ptr_tx_buf_alloc != NULL) {
903 free(ptr_tx_buf_alloc);
905 ptr_tx_buf_alloc = NULL;
907 if (ptr_rx_buf_alloc != NULL) {
908 free(ptr_rx_buf_alloc);
910 ptr_rx_buf_alloc = NULL;
912 if (ptr_cmp_buf_alloc != NULL) {
913 free(ptr_cmp_buf_alloc);
915 ptr_cmp_buf_alloc = NULL;
919 #endif // End of exclude form the documentation
921 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
923 \defgroup dv_spi SPI Validation
924 \brief SPI driver validation
926 The SPI validation performs the following tests:
927 - API interface compliance.
928 - Data exchange with various speeds, transfer sizes and communication settings.
929 - Error event signaling.
931 Two Test Modes are available: <b>Loopback</b> and <b>SPI Server</b>.
933 Test Mode : <b>Loopback</b>
934 ---------------------------
936 This test mode allows only limited validation of the SPI Driver.<br>
937 It is recommended that this test mode is used only as a proof that driver is
938 good enough to be tested with the <b>SPI Server</b>.
940 To enable this mode of testing in the <b>DV_SPI_Config.h</b> configuration file select
941 the <b>Configuration: Test Mode: Loopback</b> setting.
943 Required pin connection for the <b>Loopback</b> test mode:
945 \image html spi_loopback_pin_connections.png
947 \note In this mode following operations / settings cannot be tested:
949 - Slave Select line functionality
950 - operation of the Receive function
951 - data content sent by the Send function
952 - clock / frame format and bit order settings
953 - data bit settings other then: 8, 16, 24 and 32
954 - error event signaling
956 Test Mode : <b>SPI Server</b>
957 -----------------------------
959 This test mode allows extensive validation of the SPI Driver.<br>
960 Results of the Driver Validation in this test mode are relevant as a proof of driver compliance to the CMSIS-Driver specification.
962 To perform extensive communication tests, it is required to use an
963 \ref spi_server "SPI Server" running on a dedicated hardware.
965 To enable this mode of testing in the <b>DV_SPI_Config.h</b> configuration file select
966 the <b>Configuration: Test Mode: SPI Server</b> setting.
968 Required pin connections for the <b>SPI Server</b> test mode:
970 \image html spi_server_pin_connections.png
972 \defgroup spi_tests Tests
976 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
977 /* SPI Driver Management tests */
978 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
980 \defgroup spi_tests_drv_mgmt Driver Management
983 These tests verify API and operation of the SPI driver management functions.
985 The driver management tests verify the following driver functions
986 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
989 ARM_DRIVER_VERSION GetVersion (void);
993 ARM_SPI_CAPABILITIES GetCapabilities (void);
997 int32_t Initialize (ARM_SPI_SignalEvent_t cb_event);
1001 int32_t Uninitialize (void);
1005 int32_t PowerControl (ARM_POWER_STATE state);
1011 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1013 \brief Function: Function SPI_GetVersion
1015 The function \b SPI_GetVersion verifies the \b GetVersion function.
1017 ARM_DRIVER_VERSION GetVersion (void);
1021 - Driver is uninitialized and peripheral is powered-off:
1022 - Call GetVersion function
1023 - Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1025 void SPI_GetVersion (void) {
1026 ARM_DRIVER_VERSION ver;
1028 ver = drv->GetVersion();
1030 // Assert that GetVersion function returned version structure with API and implementation versions higher or equal to 1.0
1031 TEST_ASSERT((ver.api >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)) && (ver.drv >= ARM_DRIVER_VERSION_MAJOR_MINOR(1UL,0UL)));
1033 (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));
1034 TEST_MESSAGE(msg_buf);
1037 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1039 \brief Function: Function SPI_GetCapabilities
1041 The function \b SPI_GetCapabilities verifies the \b GetCapabilities function.
1043 ARM_SPI_CAPABILITIES GetCapabilities (void);
1047 - Driver is uninitialized and peripheral is powered-off:
1048 - Call GetCapabilities function
1049 - Assert that GetCapabilities function returned capabilities structure with reserved field 0
1051 void SPI_GetCapabilities (void) {
1052 ARM_SPI_CAPABILITIES cap;
1054 cap = drv->GetCapabilities();
1056 // Assert that GetCapabilities function returned capabilities structure with reserved field 0
1057 TEST_ASSERT_MESSAGE((cap.reserved == 0U), "[FAILED] Capabilities reserved field must be 0");
1060 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1062 \brief Function: Function SPI_Initialize_Uninitialize
1064 The function \b SPI_Initialize_Uninitialize verifies the \b Initialize and \b Uninitialize functions.
1066 int32_t Initialize (ARM_SPI_SignalEvent_t cb_event);
1069 int32_t Uninitialize (void);
1073 - Driver is uninitialized and peripheral is powered-off:
1074 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1075 - Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1076 - Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1077 - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1078 - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1079 - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1080 - Call GetDataCount function and assert that it returned 0
1081 - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1082 - Call GetStatus function
1083 - Assert that GetStatus function returned status structure with busy flag 0
1084 - Assert that GetStatus function returned status structure with data_lost flag 0
1085 - Assert that GetStatus function returned status structure with mode_fault flag 0
1086 - Assert that GetStatus function returned status structure with reserved field 0
1087 - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1088 - Driver is initialized and peripheral is powered-off:
1089 - Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1090 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1091 - Driver is uninitialized and peripheral is powered-off:
1092 - Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1093 - Driver is initialized and peripheral is powered-off:
1094 - Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1095 - Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1096 - Driver is uninitialized and peripheral is powered-off:
1097 - Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1098 - Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1099 - Driver is initialized and peripheral is powered-off:
1100 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1101 - Driver is initialized and peripheral is powered-on:
1102 - Call Control function and assert that it returned ARM_DRIVER_OK status
1103 - Call Transfer function and assert that it returned ARM_DRIVER_OK status
1104 - Call GetStatus function
1105 - Assert that GetStatus function returned status structure with busy flag 1
1106 - Call Uninitialize function with transfer active and assert that it returned ARM_DRIVER_OK status<br>
1107 (this must unconditionally terminate active transfer, power-off the peripheral and uninitialize the driver)
1108 - Driver is uninitialized and peripheral is powered-off:
1109 - Call GetStatus function
1110 - Assert that GetStatus function returned status structure with busy flag 0
1112 void SPI_Initialize_Uninitialize (void) {
1113 ARM_SPI_STATUS stat;
1115 // Driver is uninitialized and peripheral is powered-off:
1116 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_ERROR status
1117 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_ERROR);
1119 // Call PowerControl(ARM_POWER_LOW) function and assert that it returned ARM_DRIVER_ERROR status
1120 TEST_ASSERT(drv->PowerControl (ARM_POWER_LOW) == ARM_DRIVER_ERROR);
1122 // Call PowerControl(ARM_POWER_OFF) function and assert that it returned ARM_DRIVER_ERROR status
1123 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_ERROR);
1125 // Call Send function and assert that it returned ARM_DRIVER_ERROR status
1126 TEST_ASSERT(drv->Send (ptr_tx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1128 // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1129 TEST_ASSERT(drv->Receive (ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1131 // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1132 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1134 // Call GetDataCount function and assert that it returned 0
1135 TEST_ASSERT(drv->GetDataCount () == 0U);
1137 // Call Control function and assert that it returned ARM_DRIVER_ERROR status
1138 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);
1140 // Call GetStatus function
1141 stat = drv->GetStatus();
1143 // Assert that GetStatus function returned status structure with busy flag 0
1144 TEST_ASSERT(stat.busy == 0U);
1146 // Assert that GetStatus function returned status structure with data_lost flag 0
1147 TEST_ASSERT(stat.data_lost == 0U);
1149 // Assert that GetStatus function returned status structure with mode_fault flag 0
1150 TEST_ASSERT(stat.mode_fault == 0U);
1152 // Assert that GetStatus function returned status structure with reserved field 0
1153 TEST_ASSERT(stat.reserved == 0U);
1155 // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1156 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1158 // Driver is initialized and peripheral is powered-off:
1159 // Call Initialize function (without callback specified) again and assert that it returned ARM_DRIVER_OK status
1160 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1162 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1163 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1165 // Driver is uninitialized and peripheral is powered-off:
1166 // Call Initialize function (with callback specified) and assert that it returned ARM_DRIVER_OK status
1167 TEST_ASSERT(drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK);
1169 // Driver is initialized and peripheral is powered-off:
1170 // Call Initialize function (with callback specified) again and assert that it returned ARM_DRIVER_OK status
1171 TEST_ASSERT(drv->Initialize (SPI_DrvEvent) == ARM_DRIVER_OK);
1173 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1174 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1176 // Driver is uninitialized and peripheral is powered-off:
1177 // Call Uninitialize function again and assert that it returned ARM_DRIVER_OK status
1178 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1180 // Call Initialize function (without callback specified) and assert that it returned ARM_DRIVER_OK status
1181 TEST_ASSERT(drv->Initialize (NULL) == ARM_DRIVER_OK);
1183 // Driver is initialized and peripheral is powered-off:
1184 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1185 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1187 // Driver is initialized and peripheral is powered-on:
1188 // Call Control function and assert that it returned ARM_DRIVER_OK status
1189 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);
1191 // Call Transfer function and assert that it returned ARM_DRIVER_OK status
1192 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
1194 // Call GetStatus function
1195 stat = drv->GetStatus();
1197 // Assert that GetStatus function returned status structure with busy flag 1
1198 TEST_ASSERT(stat.busy == 1U);
1200 // Call Uninitialize function and assert that it returned ARM_DRIVER_OK status
1201 // (this must unconditionally terminate active transfer, power-off the peripheral and uninitialize the driver)
1202 TEST_ASSERT(drv->Uninitialize () == ARM_DRIVER_OK);
1204 // Driver is uninitialized and peripheral is powered-off:
1205 // Call GetStatus function
1206 stat = drv->GetStatus();
1208 // Assert that GetStatus function returned status structure with busy flag 0
1209 TEST_ASSERT(stat.busy == 0U);
1211 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1212 // Ensure that SPI Server (if used) is ready for command reception
1213 (void)osDelay(SPI_CFG_XFER_TIMEOUT + 10U);
1217 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1219 \brief Function: Function SPI_PowerControl
1221 The function \b SPI_PowerControl verifies the \b PowerControl function.
1223 int32_t PowerControl (ARM_POWER_STATE state);
1227 - Driver is initialized and peripheral is powered-off:
1228 - Call Send function and assert that it returned ARM_DRIVER_ERROR status
1229 - Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1230 - Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1231 - Call GetDataCount function and assert that it returned 0
1232 - Call Control function and assert that it returned ARM_DRIVER_ERROR status
1233 - Call GetStatus function
1234 - Assert that GetStatus function returned status structure with busy flag 0
1235 - Assert that GetStatus function returned status structure with data_lost flag 0
1236 - Assert that GetStatus function returned status structure with mode_fault flag 0
1237 - Assert that GetStatus function returned status structure with reserved field 0
1238 - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1239 - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK 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 PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
1243 - Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1244 - Driver is initialized and peripheral is powered-off:
1245 - Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1246 - Call PowerControl(ARM_POWER_LOW) function
1247 - Driver is initialized and peripheral is powered-on or in low-power mode:
1248 - Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
1249 - Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1250 - Driver is initialized and peripheral is powered-on:
1251 - Call Control function and assert that it returned ARM_DRIVER_OK status
1252 - Call Transfer function and assert that it returned ARM_DRIVER_OK status
1253 - Call GetStatus function
1254 - Assert that GetStatus function returned status structure with busy flag 1
1255 - Call PowerControl(ARM_POWER_OFF) function with transfer active and assert that it returned ARM_DRIVER_OK status<br>
1256 (this must unconditionally terminate active transfer and power-off the peripheral)
1257 - Driver is initialized and peripheral is powered-off:
1258 - Call GetStatus function
1259 - Assert that GetStatus function returned status structure with busy flag 0
1261 void SPI_PowerControl (void) {
1263 ARM_SPI_STATUS stat;
1265 (void)drv->Initialize (NULL);
1267 // Driver is initialized and peripheral is powered-off:
1268 // Call Send function and assert that it returned ARM_DRIVER_ERROR status
1269 TEST_ASSERT(drv->Send (ptr_tx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1271 // Call Receive function and assert that it returned ARM_DRIVER_ERROR status
1272 TEST_ASSERT(drv->Receive (ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1274 // Call Transfer function and assert that it returned ARM_DRIVER_ERROR status
1275 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_ERROR);
1277 // Call GetDataCount function and assert that it returned 0
1278 TEST_ASSERT(drv->GetDataCount () == 0U);
1280 // Call Control function and assert that it returned ARM_DRIVER_ERROR status
1281 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);
1283 // Call GetStatus function
1284 stat = drv->GetStatus();
1286 // Assert that GetStatus function returned status structure with busy flag 0
1287 TEST_ASSERT(stat.busy == 0U);
1289 // Assert that GetStatus function returned status structure with data_lost flag 0
1290 TEST_ASSERT(stat.data_lost == 0U);
1292 // Assert that GetStatus function returned status structure with mode_fault flag 0
1293 TEST_ASSERT(stat.mode_fault == 0U);
1295 // Assert that GetStatus function returned status structure with reserved field 0
1296 TEST_ASSERT(stat.reserved == 0U);
1298 // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1299 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1301 // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1302 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1304 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1305 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1307 // Driver is initialized and peripheral is powered-on:
1308 // Call PowerControl(ARM_POWER_FULL) function again and assert that it returned ARM_DRIVER_OK status
1309 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1311 // Call PowerControl(ARM_POWER_OFF) and assert that it returned ARM_DRIVER_OK status
1312 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1314 // Driver is initialized and peripheral is powered-off:
1315 // Call PowerControl(ARM_POWER_OFF) again and assert that it returned ARM_DRIVER_OK status
1316 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1318 // Call PowerControl(ARM_POWER_LOW) function
1319 ret = drv->PowerControl (ARM_POWER_LOW);
1321 // Driver is initialized and peripheral is powered-on or in low-power mode:
1322 // Assert that PowerControl(ARM_POWER_LOW) function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED status
1323 TEST_ASSERT((ret == ARM_DRIVER_OK) || (ret == ARM_DRIVER_ERROR_UNSUPPORTED));
1324 if (ret == ARM_DRIVER_ERROR_UNSUPPORTED) {
1325 TEST_MESSAGE("[WARNING] PowerControl (ARM_POWER_LOW) is not supported");
1328 // Call PowerControl(ARM_POWER_FULL) function and assert that it returned ARM_DRIVER_OK status
1329 TEST_ASSERT(drv->PowerControl (ARM_POWER_FULL) == ARM_DRIVER_OK);
1331 // Driver is initialized and peripheral is powered-on:
1332 // Call Control function and assert that it returned ARM_DRIVER_OK status
1333 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);
1335 // Call Transfer function and assert that it returned ARM_DRIVER_OK status
1336 TEST_ASSERT(drv->Transfer (ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
1338 // Call GetStatus function
1339 stat = drv->GetStatus();
1341 // Assert that GetStatus function returned status structure with busy flag 1
1342 TEST_ASSERT(stat.busy == 1U);
1344 // Call PowerControl(ARM_POWER_OFF) function with transfer active and assert that it returned ARM_DRIVER_OK status
1345 // (this must unconditionally terminate active transfer and power-off the peripheral)
1346 TEST_ASSERT(drv->PowerControl (ARM_POWER_OFF) == ARM_DRIVER_OK);
1348 // Driver is initialized and peripheral is powered-off:
1349 // Call GetStatus function
1350 stat = drv->GetStatus();
1352 // Assert that GetStatus function returned status structure with busy flag 0
1353 TEST_ASSERT(stat.busy == 0U);
1355 (void)drv->Uninitialize ();
1357 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1358 // Ensure that SPI Server (if used) is ready for command reception
1359 (void)osDelay(SPI_CFG_XFER_TIMEOUT + 10U);
1366 // End of spi_tests_drv_mgmt
1368 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1369 /* SPI Data Exchange tests */
1370 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1372 \defgroup spi_tests_data_xchg Data Exchange
1375 These tests verify API and operation of the SPI data exchange functions.
1377 The data exchange tests verify the following driver functions
1378 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
1381 int32_t Send (const void *data, uint32_t num);
1385 int32_t Receive ( void *data, uint32_t num);
1389 int32_t Transfer (const void *data_out, void *data_in, uint32_t num);
1393 uint32_t GetDataCount (void);
1397 int32_t Control (uint32_t control, uint32_t arg);
1401 ARM_SPI_STATUS GetStatus (void);
1405 void (*ARM_SPI_SignalEvent_t) (uint32_t event);
1408 All of these tests execute a data exchange and check the result of this data exchange.
1410 Data exchange test procedure when Test Mode <b>SPI Server</b> is selected:
1411 - send command "SET BUF TX,.." to the SPI Server: Set Tx buffer
1412 - send command "SET BUF RX,.." to the SPI Server: Set Rx buffer
1413 - send command "SET COM .." to the SPI Server: Set communication settings for the next XFER command
1414 - send command "XFER .." to the SPI Server: Activate transfer
1415 - driver Control: Configure the SPI interface
1416 - driver Control: Set the default Tx value
1417 - driver Send/Receive/Transfer: Start the requested operation
1418 - driver GetStatus/SignalEvent: Wait for the current operation to finish or time out<br>
1419 (operation is finished when busy flag is 0 and completed event was signaled)
1420 - assert that operation has finished in expected time
1421 - assert that ARM_SPI_EVENT_TRANSFER_COMPLETE event was signaled
1422 - driver GetStatus: Assert that busy flag is 0
1423 - driver GetDataCount: Assert that number of transferred items is same as requested
1424 - if operation has timed out call driver Control function to Abort operation and wait timeout time<br>
1425 to make sure that the SPI Server is ready for the next command
1426 - assert that received content is as expected
1427 - send command "GET BUF RX,.." to the SPI Server: Get Rx buffer
1428 - assert that sent content (read from the SPI Server's receive buffer) is as expected
1430 Data exchange <b>Abort</b> test procedure when Test Mode <b>SPI Server</b> is selected:
1431 - send command "SET BUF TX,.." to the SPI Server: Set Tx buffer
1432 - send command "SET BUF RX,.." to the SPI Server: Set Rx buffer
1433 - send command "SET COM .." to the SPI Server: Set communication settings for the next XFER command
1434 - send command "XFER .." to the SPI Server: Activate transfer
1435 - driver Control: Configure the SPI interface
1436 - driver Control: Set the default Tx value
1437 - driver Send/Receive/Transfer: Start the requested operation
1439 - driver Control: Abort the current operation
1440 - driver GetStatus: Assert that busy flag is 0
1441 - driver GetDataCount: Assert that number of transferred items is less than requested
1443 Data exchange test procedure when Test Mode <b>Loopback</b> is selected:
1444 - driver Control: Configure the SPI interface
1445 - driver Control: Set the default Tx value
1446 - driver Send/Transfer: Start the requested operation
1447 - driver GetStatus/SignalEvent: Wait for the current operation to finish or time out<br>
1448 (operation is finished when busy flag is 0 and completed event was signaled)
1449 - assert that operation has finished in expected time
1450 - assert that ARM_SPI_EVENT_TRANSFER_COMPLETE event was signaled
1451 - driver GetStatus: Assert that busy flag is 0
1452 - driver GetDataCount: Assert that number of transferred items is same as requested
1453 - if operation has timed out call driver Control function to Abort operation
1454 - assert that received content is as expected (for Transfer operation only)
1456 \note Limitations of Data Exchange tests if Test Mode <b>Loopback</b> is selected:
1457 - only Master mode with Slave Select not used can be tested
1458 - Receive function cannot be tested
1459 - format tests are not supported
1460 - only 8, 16, 24 and 32 data bit tests are supported
1461 - bit order tests are not supported
1465 #ifndef __DOXYGEN__ // Exclude form the documentation
1467 \brief Execute SPI data exchange or data exchange abort operation.
1468 \param[in] operation operation (OP_SEND.. OP_ABORT_TRANSFER)
1469 \param[in] mode mode (MODE_MASTER or MODE_SLAVE)
1470 \param[in] format clock/frame format (0 = polarity0/phase0 .. 5 = Microwire)
1471 \param[in] data_bits data bits (1 .. 32)
1472 \param[in] bit_order bit order (BO_MSB_TO_LSB or BO_LSB_TO_MSB)
1473 \param[in] ss_mode Slave Select mode (SS_MODE_xxx)
1474 \param[in] bus_speed bus speed in bits per second (bps)
1475 \param[in] num number of items to send, receive or transfer
1478 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) {
1479 // volatile specifier is used to prevent compiler from optimizing variables
1480 // in a way that they cannot be seen with debugger
1481 volatile int32_t stat, def_tx_stat;
1482 volatile uint32_t drv_mode, drv_format, drv_data_bits, drv_bit_order, drv_ss_mode;
1483 volatile uint32_t srv_mode, srv_ss_mode;
1484 volatile ARM_SPI_STATUS spi_stat;
1485 volatile uint32_t data_count;
1486 uint32_t start_cnt, max_cnt;
1487 uint32_t val, delay, i;
1490 // Prepare parameters for SPI Server and Driver configuration
1493 TEST_FAIL_MESSAGE("[FAILED] Inactive mode! Data exchange operation aborted!");
1496 drv_mode = ARM_SPI_MODE_MASTER;
1501 drv_mode = ARM_SPI_MODE_SLAVE;
1506 TEST_FAIL_MESSAGE("[FAILED] Unknown mode! Data exchange operation aborted!");
1511 case FORMAT_CPOL0_CPHA0:
1512 drv_format = ARM_SPI_CPOL0_CPHA0;
1514 case FORMAT_CPOL0_CPHA1:
1515 drv_format = ARM_SPI_CPOL0_CPHA1;
1517 case FORMAT_CPOL1_CPHA0:
1518 drv_format = ARM_SPI_CPOL1_CPHA0;
1520 case FORMAT_CPOL1_CPHA1:
1521 drv_format = ARM_SPI_CPOL1_CPHA1;
1524 drv_format = ARM_SPI_TI_SSI;
1526 case FORMAT_MICROWIRE:
1527 drv_format = ARM_SPI_MICROWIRE;
1530 TEST_FAIL_MESSAGE("[FAILED] Unknown clock / frame format! Data exchange operation aborted!");
1534 if ((data_bits > 0U) && (data_bits <= 32U)) {
1535 drv_data_bits = ARM_SPI_DATA_BITS(data_bits);
1537 TEST_FAIL_MESSAGE("[FAILED] Data bits not in range 1 to 32! Data exchange operation aborted!");
1541 switch (bit_order) {
1543 drv_bit_order = ARM_SPI_MSB_LSB;
1546 drv_bit_order = ARM_SPI_LSB_MSB;
1549 TEST_FAIL_MESSAGE("[FAILED] Unknown bit order! Data exchange operation aborted!");
1553 if (mode == MODE_MASTER) {
1555 case SS_MODE_MASTER_UNUSED:
1556 drv_ss_mode = ARM_SPI_SS_MASTER_UNUSED;
1559 case SS_MODE_MASTER_SW:
1560 drv_ss_mode = ARM_SPI_SS_MASTER_SW;
1563 case SS_MODE_MASTER_HW_OUTPUT:
1564 drv_ss_mode = ARM_SPI_SS_MASTER_HW_OUTPUT;
1567 case SS_MODE_MASTER_HW_INPUT:
1568 drv_ss_mode = ARM_SPI_SS_MASTER_UNUSED;
1572 TEST_FAIL_MESSAGE("[FAILED] Unknown Slave Select mode! Data exchange operation aborted!");
1577 case SS_MODE_SLAVE_HW:
1578 drv_ss_mode = ARM_SPI_SS_SLAVE_HW;
1581 case SS_MODE_SLAVE_SW:
1582 drv_ss_mode = ARM_SPI_SS_SLAVE_SW;
1586 TEST_FAIL_MESSAGE("[FAILED] Unknown Slave Select mode! Data exchange operation aborted!");
1591 // Check that SPI status is not busy before starting data exchange test
1592 spi_stat = drv->GetStatus(); // Get SPI status
1593 if (spi_stat.busy != 0U) {
1594 // If busy flag is still active
1595 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy active before operation! Data exchange operation aborted!");
1598 TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
1601 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1602 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
1603 if (CmdSetBufTx('S') != EXIT_SUCCESS) { break; }
1604 if (CmdSetBufRx('?') != EXIT_SUCCESS) { break; }
1605 if (CmdSetCom (srv_mode, format, data_bits, bit_order, srv_ss_mode, bus_speed) != EXIT_SUCCESS) { break; }
1606 if (CmdXfer (num, delay, SPI_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
1607 #else // If Test Mode Loopback is selected
1608 // Remove warnings for unused variables
1614 // Initialize buffers
1615 memset(ptr_tx_buf, (int32_t)'!' , SPI_BUF_MAX);
1616 memset(ptr_tx_buf, (int32_t)'T' , num * DataBitsToBytes(data_bits));
1617 memset(ptr_rx_buf, (int32_t)'?' , SPI_BUF_MAX);
1618 memset(ptr_cmp_buf, (int32_t)'?' , SPI_BUF_MAX);
1620 // Configure required communication settings
1621 if (mode == MODE_MASTER) {
1622 stat = drv->Control (drv_mode | drv_format | drv_data_bits | drv_bit_order | drv_ss_mode, bus_speed);
1623 (void)osDelay(10U); // Give time to SPI Server to prepare Slave transfer
1625 // For Slave mode bus speed argument is not used
1626 stat = drv->Control (drv_mode | drv_format | drv_data_bits | drv_bit_order | drv_ss_mode, 0U);
1628 if (stat != ARM_DRIVER_OK) {
1629 // If configuration has failed
1630 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Control function returned", str_ret[-stat]);
1632 // Assert that Control function returned ARM_DRIVER_OK
1633 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1634 if (stat != ARM_DRIVER_OK) {
1635 // If Control function has failed there is no sense to try to execute the data exchange
1636 (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U); // Wait for SPI Server to timeout the XFER command
1640 // Set default Tx value to 'D' byte values (only for master mode)
1641 if (mode == MODE_MASTER) {
1642 val = ((uint32_t)'D' << 24) | ((uint32_t)'D' << 16) | ((uint32_t)'D' << 8) | (uint32_t)'D';
1643 stat = drv->Control (ARM_SPI_SET_DEFAULT_TX_VALUE, val);
1645 if ((stat != ARM_DRIVER_OK) && (stat != ARM_DRIVER_ERROR_UNSUPPORTED)) {
1646 // If set default Tx value has failed
1647 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Set default Tx value returned", str_ret[-stat]);
1649 // Assert that Control function returned ARM_DRIVER_OK or ARM_DRIVER_ERROR_UNSUPPORTED
1650 TEST_ASSERT_MESSAGE((stat == ARM_DRIVER_OK) || (stat == ARM_DRIVER_ERROR_UNSUPPORTED), msg_buf);
1652 if (stat == ARM_DRIVER_ERROR_UNSUPPORTED) {
1653 // If set default Tx value is not supported
1654 (void)snprintf(msg_buf, sizeof(msg_buf), "[WARNING] %s: %s", str_oper[operation], "Set default Tx value is not supported");
1655 TEST_MESSAGE(msg_buf);
1658 // For slave mode default Tx is not tested
1659 def_tx_stat = ARM_DRIVER_ERROR_UNSUPPORTED;
1663 duration = 0xFFFFFFFFUL;
1665 data_count_sample = 0U;
1667 max_cnt = (systick_freq /1024U) * (SPI_CFG_XFER_TIMEOUT + 10U);
1668 start_cnt = osKernelGetSysTimerCount();
1670 if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) ||
1671 ((mode == MODE_SLAVE) && (ss_mode == SS_MODE_SLAVE_SW))) {
1672 // If operation requires software Slave Select driving, activate Slave Select
1673 stat = drv->Control (ARM_SPI_CONTROL_SS, ARM_SPI_SS_ACTIVE);
1674 if (stat != ARM_DRIVER_OK) {
1675 // If driving of Slave Select to active state has failed
1676 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
1678 // Assert that Control function returned ARM_DRIVER_OK
1679 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1682 // Start the data exchange operation
1683 switch (operation & 0x0FU) {
1686 stat = drv->Send(ptr_tx_buf, num);
1687 if (stat != ARM_DRIVER_OK) {
1688 // If Send activation has failed
1689 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Send function returned", str_ret[-stat]);
1691 // Assert that Send function returned ARM_DRIVER_OK
1692 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1695 case OP_ABORT_RECEIVE:
1696 stat = drv->Receive(ptr_rx_buf, num);
1697 if (stat != ARM_DRIVER_OK) {
1698 // If Receive activation has failed
1699 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Receive function returned", str_ret[-stat]);
1701 // Assert that Receive function returned ARM_DRIVER_OK
1702 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1705 case OP_ABORT_TRANSFER:
1706 stat = drv->Transfer(ptr_tx_buf, ptr_rx_buf, num);
1707 if (stat != ARM_DRIVER_OK) {
1708 // If Transfer activation has failed
1709 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s! Data exchange operation aborted!", str_oper[operation], "Transfer function returned", str_ret[-stat]);
1711 // Assert that Transfer function returned ARM_DRIVER_OK
1712 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1715 TEST_FAIL_MESSAGE("[FAILED] Unknown operation! Data exchange operation aborted!");
1718 if (stat != ARM_DRIVER_OK) {
1719 // If Send/Receive/Transfer start has failed there is no sense to try to continue with the data exchange
1720 (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U); // Wait for SPI Server to timeout the XFER command
1724 if ((operation == OP_ABORT_SEND) || // This IF block tests only abort functionality
1725 (operation == OP_ABORT_RECEIVE) ||
1726 (operation == OP_ABORT_TRANSFER)) {
1727 (void)osDelay(1U); // Wait short time before doing Abort
1728 stat = drv->Control (ARM_SPI_ABORT_TRANSFER, 0U);
1729 if (stat != ARM_DRIVER_OK) {
1730 // If Abort has failed
1731 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
1733 // Assert that Control function returned ARM_DRIVER_OK
1734 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1736 if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) ||
1737 ((mode == MODE_SLAVE) && (ss_mode == SS_MODE_SLAVE_SW))) {
1738 // If operation requires software Slave Select driving, deactivate Slave Select
1739 drv->Control(ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE);
1741 spi_stat = drv->GetStatus(); // Get SPI status
1742 if (spi_stat.busy != 0U) {
1743 // If busy flag is still active
1744 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy still active after Abort");
1746 // Assert that busy flag is not active
1747 TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
1749 data_count = drv->GetDataCount(); // Get data count
1750 if (data_count >= num) {
1751 // If data count is more or equal to number of items then Abort has failed
1752 (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");
1754 // Assert data count is less then number of items requested for exchange
1755 TEST_ASSERT_MESSAGE(data_count < num, msg_buf);
1757 (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U); // Wait for SPI Server to timeout aborted operation
1759 return; // Here Abort test is finished, exit
1762 // Wait for operation to finish (status busy is 0 and event complete signaled, or timeout)
1764 if (data_count_sample == 0U) {
1765 // Store first data count different than 0
1766 data_count_sample = drv->GetDataCount(); // Get data count
1768 if ((drv->GetStatus().busy == 0U) && ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) != 0U)) {
1769 duration = osKernelGetSysTimerCount() - start_cnt;
1772 } while ((osKernelGetSysTimerCount() - start_cnt) < max_cnt);
1774 if (duration == 0xFFFFFFFFUL) {
1775 // If operation has timed out
1776 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Operation timed out");
1778 // Assert that operation has finished in expected time
1779 TEST_ASSERT_MESSAGE(duration != 0xFFFFFFFFUL, msg_buf);
1781 if (((mode == MODE_MASTER) && (ss_mode == SS_MODE_MASTER_SW)) ||
1782 ((mode == MODE_SLAVE) && (ss_mode == SS_MODE_SLAVE_SW))) {
1783 // If operation requires software Slave Select driving, deactivate Slave Select
1784 stat = drv->Control (ARM_SPI_CONTROL_SS, ARM_SPI_SS_INACTIVE);
1785 if (stat != ARM_DRIVER_OK) {
1786 // If driving of Slave Select to inactive state has failed
1787 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s %s", str_oper[operation], "Control function returned", str_ret[-stat]);
1789 // Assert that Control function returned ARM_DRIVER_OK
1790 TEST_ASSERT_MESSAGE(stat == ARM_DRIVER_OK, msg_buf);
1793 if ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) == 0U) {
1794 // If transfer complete event was not signaled
1795 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_SPI_EVENT_TRANSFER_COMPLETE was not signaled");
1796 chk_data = 0U; // Do not check transferred content
1798 // Assert that ARM_SPI_EVENT_TRANSFER_COMPLETE was signaled
1799 TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) != 0U, msg_buf);
1801 spi_stat = drv->GetStatus(); // Get SPI status
1802 if (spi_stat.busy != 0U) {
1803 // If busy flag is still active
1804 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "Busy still active after operation");
1805 chk_data = 0U; // Do not check transferred content
1807 // Assert that busy flag is not active
1808 TEST_ASSERT_MESSAGE(spi_stat.busy == 0U, msg_buf);
1810 if ((event & ARM_SPI_EVENT_DATA_LOST) != 0U) {
1811 // If data lost was signaled during the transfer
1812 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] %s: %s", str_oper[operation], "ARM_SPI_EVENT_DATA_LOST was signaled");
1813 chk_data = 0U; // Do not check transferred content
1815 // Assert that ARM_SPI_EVENT_DATA_LOST was not signaled
1816 TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_DATA_LOST) == 0U, msg_buf);
1818 data_count = drv->GetDataCount(); // Get data count
1819 if (data_count != num) {
1820 // If data count is different then number of items, then operation has failed
1821 (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");
1822 chk_data = 0U; // Do not check transferred content
1824 // Assert that data count is equal to number of items requested for exchange
1825 TEST_ASSERT_MESSAGE(data_count == num, msg_buf);
1827 if ((drv->GetStatus().busy != 0U) || ((event & ARM_SPI_EVENT_TRANSFER_COMPLETE) == 0U)) {
1828 // If transfer did not finish in time, abort it
1829 (void)drv->Control(ARM_SPI_ABORT_TRANSFER, 0U);
1830 (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U); // Wait for SPI Server to timeout aborted operation
1833 if (chk_data != 0U) { // If transferred content should be checked
1834 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1835 // Check received content for receive and transfer operations
1836 if ((operation == OP_RECEIVE) || (operation == OP_TRANSFER)) {
1837 memset(ptr_cmp_buf, (int32_t)'S', num * DataBitsToBytes(data_bits));
1838 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
1840 // If data received mismatches
1841 // Find on which byte mismatch starts
1842 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
1843 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
1847 (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]);
1849 // Assert that data received is same as expected
1850 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
1853 // Check sent content (by checking SPI Server's received buffer content)
1854 if ((mode == MODE_MASTER) || (operation != OP_RECEIVE) || (def_tx_stat == ARM_DRIVER_OK)) {
1855 // Check sent data in all cases except Slave mode Receive operation
1856 // with Default Tx not working or unsupported
1857 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
1858 if (CmdGetBufRx(SPI_BUF_MAX) != EXIT_SUCCESS) { break; }
1860 if ((operation == OP_RECEIVE) && (def_tx_stat == ARM_DRIVER_OK)) {
1861 // Expected data received by SPI Server should be default Tx value
1862 memset(ptr_cmp_buf, (int32_t)'D', num * DataBitsToBytes(data_bits));
1864 if ((operation == OP_SEND) || (operation == OP_TRANSFER)) {
1865 // Expected data received by SPI Server should be what was sent
1866 memset(ptr_cmp_buf, (int32_t)'T', num * DataBitsToBytes(data_bits));
1869 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
1871 // If data sent mismatches
1872 // Find on which byte mismatch starts
1873 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
1874 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
1878 if (operation == OP_RECEIVE) {
1879 // If sent was default Tx value, 'D' bytes
1880 (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]);
1882 // If sent was 'T' bytes
1883 (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]);
1886 // Assert data sent is same as expected
1887 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
1890 #else // If Test Mode Loopback is selected
1891 if (operation == OP_TRANSFER) {
1892 memset(ptr_cmp_buf, (int32_t)'T', num * DataBitsToBytes(data_bits));
1893 stat = memcmp(ptr_rx_buf, ptr_cmp_buf, num * DataBitsToBytes(data_bits));
1895 // If data received mismatches
1896 // Find on which byte mismatch starts
1897 for (i = 0U; i < (num * DataBitsToBytes(data_bits)); i++) {
1898 if (ptr_rx_buf[i] != ptr_cmp_buf[i]) {
1902 (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]);
1904 // Assert that data received is same as expected
1905 TEST_ASSERT_MESSAGE(stat == 0, msg_buf);
1913 #if (SPI_SERVER_USED == 1) // If Test Mode SPI Server is selected
1914 TEST_FAIL_MESSAGE("[FAILED] Problems in communication with SPI Server. Test aborted!");
1918 #endif // End of exclude form the documentation
1920 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1922 \brief Function: Function SPI_Mode_Master_SS_Unused
1924 The function \b SPI_Mode_Master_SS_Unused verifies data exchange:
1925 - in <b>Master Mode</b> with <b>Slave Select line not used</b>
1926 - with default clock / frame format
1927 - with default data bits
1928 - with default bit order
1929 - at default bus speed
1930 - for default number of data items
1932 \note In Test Mode <b>Loopback</b> Receive function is not checked
1934 void SPI_Mode_Master_SS_Unused (void) {
1936 if (InitDriver() != EXIT_SUCCESS) { return; }
1937 if (CheckBuffers() != EXIT_SUCCESS) { return; }
1938 #if (SPI_SERVER_USED != 0)
1939 if (CheckServer() != EXIT_SUCCESS) { return; }
1940 if ((spi_serv_cap.mode_mask & 2U) == 0U) { // If SPI Server does not support Slave mode
1941 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
1946 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);
1947 #if (SPI_SERVER_USED != 0)
1948 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);
1950 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);
1953 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1955 \brief Function: Function SPI_Mode_Master_SS_Sw_Ctrl
1957 The function \b SPI_Mode_Master_SS_Sw_Ctrl verifies data exchange:
1958 - in <b>Master Mode</b> with <b>Slave Select line Software Controlled</b>
1959 - with default clock / frame format
1960 - with default data bits
1961 - with default bit order
1962 - at default bus speed
1963 - for default number of data items
1965 \note In Test Mode <b>Loopback</b> this test is skipped
1967 void SPI_Mode_Master_SS_Sw_Ctrl (void) {
1969 #if (SPI_SERVER_USED != 0)
1970 if (InitDriver() != EXIT_SUCCESS) { return; }
1971 if (CheckBuffers() != EXIT_SUCCESS) { return; }
1972 if (CheckServer() != EXIT_SUCCESS) { return; }
1973 if ((spi_serv_cap.mode_mask & 2U) == 0U) { // If SPI Server does not support Slave mode
1974 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
1978 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);
1979 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);
1980 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);
1983 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
1987 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
1989 \brief Function: Function SPI_Mode_Master_SS_Hw_Ctrl_Out
1991 The function \b SPI_Mode_Master_SS_Hw_Ctrl_Out verifies data exchange:
1992 - in <b>Master Mode</b> with <b>Slave Select line Hardware Controlled Output</b>
1993 - with default clock / frame format
1994 - with default data bits
1995 - with default bit order
1996 - at default bus speed
1997 - for default number of data items
1999 \note In Test Mode <b>Loopback</b> this test is skipped
2001 void SPI_Mode_Master_SS_Hw_Ctrl_Out (void) {
2003 #if (SPI_SERVER_USED != 0)
2004 if (InitDriver() != EXIT_SUCCESS) { return; }
2005 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2006 if (CheckServer() != EXIT_SUCCESS) { return; }
2007 if ((spi_serv_cap.mode_mask & 2U) == 0U) { // If SPI Server does not support Slave mode
2008 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2012 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);
2013 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);
2014 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);
2017 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2021 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2023 \brief Function: Function SPI_Mode_Master_SS_Hw_Mon_In
2025 The function \b SPI_Mode_Master_SS_Hw_Mon_In verifies data exchange:
2026 - in <b>Master Mode</b> with <b>Slave Select line Hardware Monitored Input</b>
2027 - with default clock / frame format
2028 - with default data bits
2029 - with default bit order
2030 - at default bus speed
2031 - for default number of data items
2033 \note In Test Mode <b>Loopback</b> this test is skipped
2035 void SPI_Mode_Master_SS_Hw_Mon_In (void) {
2037 #if (SPI_SERVER_USED != 0)
2038 if (InitDriver() != EXIT_SUCCESS) { return; }
2039 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2040 if (CheckServer() != EXIT_SUCCESS) { return; }
2041 if ((spi_serv_cap.mode_mask & 2U) == 0U) { // If SPI Server does not support Slave mode
2042 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2046 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);
2047 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);
2048 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);
2051 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2055 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2057 \brief Function: Function SPI_Mode_Slave_SS_Hw_Mon
2059 The function \b SPI_Mode_Slave_SS_Hw_Mon verifies data exchange:
2060 - in <b>Slave Mode</b> with <b>Slave Select line Hardware Monitored</b>
2061 - with default clock / frame format
2062 - with default data bits
2063 - with default bit order
2064 - at default bus speed
2065 - for default number of data items
2067 \note In Test Mode <b>Loopback</b> this test is skipped
2069 void SPI_Mode_Slave_SS_Hw_Mon (void) {
2071 #if (SPI_SERVER_USED != 0)
2072 if (InitDriver() != EXIT_SUCCESS) { return; }
2073 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2074 if (CheckServer() != EXIT_SUCCESS) { return; }
2075 if ((spi_serv_cap.mode_mask & 1U) == 0U) { // If SPI Server does not support Master mode
2076 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2080 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);
2081 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);
2082 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);
2085 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2089 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2091 \brief Function: Function SPI_Mode_Slave_SS_Sw_Ctrl
2093 The function \b SPI_Mode_Slave_SS_Sw_Ctrl verifies data exchange:
2094 - in <b>Slave Mode</b> with <b>Slave Select line Software Controlled</b>
2095 - with default clock / frame format
2096 - with default data bits
2097 - with default bit order
2098 - at default bus speed
2099 - for default number of data items
2101 \note In Test Mode <b>Loopback</b> this test is skipped
2103 void SPI_Mode_Slave_SS_Sw_Ctrl (void) {
2105 #if (SPI_SERVER_USED != 0)
2106 if (InitDriver() != EXIT_SUCCESS) { return; }
2107 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2108 if (CheckServer() != EXIT_SUCCESS) { return; }
2109 if ((spi_serv_cap.mode_mask & 1U) == 0U) { // If SPI Server does not support Master mode
2110 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2114 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);
2115 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);
2116 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);
2119 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2123 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2125 \brief Function: Function SPI_Format_Clock_Pol0_Pha0
2127 The function \b SPI_Format_Clock_Pol0_Pha0 verifies data exchange:
2128 - in Master Mode with default Slave Select mode
2129 - with clock format: <b>polarity 0 / phase 0</b>
2130 - with default data bits
2131 - with default bit order
2132 - at default bus speed
2133 - for default number of data items
2135 \note In Test Mode <b>Loopback</b> this test is skipped
2137 void SPI_Format_Clock_Pol0_Pha0 (void) {
2139 #if (SPI_SERVER_USED != 0)
2140 if (InitDriver() != EXIT_SUCCESS) { return; }
2141 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2142 if (CheckServer() != EXIT_SUCCESS) { return; }
2143 if ((spi_serv_cap.fmt_mask & 1U) == 0U) { // If SPI Server does not support format
2144 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2148 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);
2149 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);
2150 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);
2153 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2157 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2159 \brief Function: Function SPI_Format_Clock_Pol0_Pha1
2161 The function \b SPI_Format_Clock_Pol0_Pha1 verifies data exchange:
2162 - in Master Mode with default Slave Select mode
2163 - with clock format: <b>polarity 0 / phase 1</b>
2164 - with default data bits
2165 - with default bit order
2166 - at default bus speed
2167 - for default number of data items
2169 \note In Test Mode <b>Loopback</b> this test is skipped
2171 void SPI_Format_Clock_Pol0_Pha1 (void) {
2173 #if (SPI_SERVER_USED != 0)
2174 if (InitDriver() != EXIT_SUCCESS) { return; }
2175 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2176 if (CheckServer() != EXIT_SUCCESS) { return; }
2177 if ((spi_serv_cap.fmt_mask & 2U) == 0U) { // If SPI Server does not support format
2178 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2182 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);
2183 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);
2184 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);
2187 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2191 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2193 \brief Function: Function SPI_Format_Clock_Pol1_Pha0
2195 The function \b SPI_Format_Clock_Pol1_Pha0 verifies data exchange:
2196 - in Master Mode with default Slave Select mode
2197 - with clock format: <b>polarity 1 / phase 0</b>
2198 - with default data bits
2199 - with default bit order
2200 - at default bus speed
2201 - for default number of data items
2203 \note In Test Mode <b>Loopback</b> this test is skipped
2205 void SPI_Format_Clock_Pol1_Pha0 (void) {
2207 #if (SPI_SERVER_USED != 0)
2208 if (InitDriver() != EXIT_SUCCESS) { return; }
2209 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2210 if (CheckServer() != EXIT_SUCCESS) { return; }
2211 if ((spi_serv_cap.fmt_mask & 4U) == 0U) { // If SPI Server does not support format
2212 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2216 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);
2217 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);
2218 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);
2221 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2225 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2227 \brief Function: Function SPI_Format_Clock_Pol0_Pha0
2229 The function \b SPI_Format_Clock_Pol1_Pha1 verifies data exchange:
2230 - in Master Mode with default Slave Select mode
2231 - with clock format: <b>polarity 1 / phase 1</b>
2232 - with default data bits
2233 - with default bit order
2234 - at default bus speed
2235 - for default number of data items
2237 \note In Test Mode <b>Loopback</b> this test is skipped
2239 void SPI_Format_Clock_Pol1_Pha1 (void) {
2241 #if (SPI_SERVER_USED != 0)
2242 if (InitDriver() != EXIT_SUCCESS) { return; }
2243 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2244 if (CheckServer() != EXIT_SUCCESS) { return; }
2245 if ((spi_serv_cap.fmt_mask & 8U) == 0U) { // If SPI Server does not support format
2246 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2250 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);
2251 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);
2252 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);
2255 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2259 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2261 \brief Function: Function SPI_Format_Frame_TI
2263 The function \b SPI_Format_Frame_TI verifies data exchange:
2264 - in Master Mode with default Slave Select mode
2265 - with <b>Texas Instruments frame format</b>
2266 - with default data bits
2267 - with default bit order
2268 - at default bus speed
2269 - for default number of data items
2271 \note In Test Mode <b>Loopback</b> this test is skipped
2273 void SPI_Format_Frame_TI (void) {
2275 #if (SPI_SERVER_USED != 0)
2276 if (InitDriver() != EXIT_SUCCESS) { return; }
2277 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2278 if (CheckServer() != EXIT_SUCCESS) { return; }
2279 if ((spi_serv_cap.fmt_mask & 16U) == 0U) { // If SPI Server does not support format
2280 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2284 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);
2285 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);
2286 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);
2289 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2293 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2295 \brief Function: Function SPI_Format_Clock_Microwire
2297 The function \b SPI_Format_Clock_Microwire verifies data exchange:
2298 - in Master Mode with default Slave Select mode
2299 - with <b>National Semiconductor Microwire frame format</b>
2300 - with default data bits
2301 - with default bit order
2302 - at default bus speed
2303 - for default number of data items
2305 \note In Test Mode <b>Loopback</b> this test is skipped
2307 void SPI_Format_Clock_Microwire (void) {
2309 #if (SPI_SERVER_USED != 0)
2310 if (InitDriver() != EXIT_SUCCESS) { return; }
2311 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2312 if (CheckServer() != EXIT_SUCCESS) { return; }
2313 if ((spi_serv_cap.fmt_mask & 32U) == 0U) { // If SPI Server does not support format
2314 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2318 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);
2319 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);
2320 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);
2323 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2327 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2329 \brief Function: Function SPI_Data_Bits_1
2331 The function \b SPI_Data_Bits_1 verifies data exchange:
2332 - in Master Mode with default Slave Select mode
2333 - with default clock / frame format
2334 - with <b>1 data bits</b> per frame
2335 - with default bit order
2336 - at default bus speed
2337 - for default number of data items
2339 \note In Test Mode <b>Loopback</b> this test is skipped
2341 void SPI_Data_Bits_1 (void) {
2343 #if (SPI_SERVER_USED != 0)
2344 if (InitDriver() != EXIT_SUCCESS) { return; }
2345 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2346 if (CheckServer() != EXIT_SUCCESS) { return; }
2347 if ((spi_serv_cap.db_mask & 1U) == 0U) { // If SPI Server does not support data bits setting
2348 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2352 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);
2353 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);
2354 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);
2357 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2361 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2363 \brief Function: Function SPI_Data_Bits_2
2365 The function \b SPI_Data_Bits_2 verifies data exchange:
2366 - in Master Mode with default Slave Select mode
2367 - with default clock / frame format
2368 - with <b>2 data bits</b> per frame
2369 - with default bit order
2370 - at default bus speed
2371 - for default number of data items
2373 \note In Test Mode <b>Loopback</b> this test is skipped
2375 void SPI_Data_Bits_2 (void) {
2377 #if (SPI_SERVER_USED != 0)
2378 if (InitDriver() != EXIT_SUCCESS) { return; }
2379 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2380 if (CheckServer() != EXIT_SUCCESS) { return; }
2381 if ((spi_serv_cap.db_mask & (1U << 1)) == 0U) { // If SPI Server does not support data bits setting
2382 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2386 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);
2387 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);
2388 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);
2391 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2395 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2397 \brief Function: Function SPI_Data_Bits_3
2399 The function \b SPI_Data_Bits_3 verifies data exchange:
2400 - in Master Mode with default Slave Select mode
2401 - with default clock / frame format
2402 - with <b>3 data bits</b> per frame
2403 - with default bit order
2404 - at default bus speed
2405 - for default number of data items
2407 \note In Test Mode <b>Loopback</b> this test is skipped
2409 void SPI_Data_Bits_3 (void) {
2411 #if (SPI_SERVER_USED != 0)
2412 if (InitDriver() != EXIT_SUCCESS) { return; }
2413 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2414 if (CheckServer() != EXIT_SUCCESS) { return; }
2415 if ((spi_serv_cap.db_mask & (1U << 2)) == 0U) { // If SPI Server does not support data bits setting
2416 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2420 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);
2421 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);
2422 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);
2425 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2429 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2431 \brief Function: Function SPI_Data_Bits_4
2433 The function \b SPI_Data_Bits_4 verifies data exchange:
2434 - in Master Mode with default Slave Select mode
2435 - with default clock / frame format
2436 - with <b>4 data bits</b> per frame
2437 - with default bit order
2438 - at default bus speed
2439 - for default number of data items
2441 \note In Test Mode <b>Loopback</b> this test is skipped
2443 void SPI_Data_Bits_4 (void) {
2445 #if (SPI_SERVER_USED != 0)
2446 if (InitDriver() != EXIT_SUCCESS) { return; }
2447 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2448 if (CheckServer() != EXIT_SUCCESS) { return; }
2449 if ((spi_serv_cap.db_mask & (1U << 3)) == 0U) { // If SPI Server does not support data bits setting
2450 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2454 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);
2455 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);
2456 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);
2459 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2463 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2465 \brief Function: Function SPI_Data_Bits_5
2467 The function \b SPI_Data_Bits_5 verifies data exchange:
2468 - in Master Mode with default Slave Select mode
2469 - with default clock / frame format
2470 - with <b>5 data bits</b> per frame
2471 - with default bit order
2472 - at default bus speed
2473 - for default number of data items
2475 \note In Test Mode <b>Loopback</b> this test is skipped
2477 void SPI_Data_Bits_5 (void) {
2479 #if (SPI_SERVER_USED != 0)
2480 if (InitDriver() != EXIT_SUCCESS) { return; }
2481 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2482 if (CheckServer() != EXIT_SUCCESS) { return; }
2483 if ((spi_serv_cap.db_mask & (1U << 4)) == 0U) { // If SPI Server does not support data bits setting
2484 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2488 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);
2489 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);
2490 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);
2493 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2497 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2499 \brief Function: Function SPI_Data_Bits_6
2501 The function \b SPI_Data_Bits_6 verifies data exchange:
2502 - in Master Mode with default Slave Select mode
2503 - with default clock / frame format
2504 - with <b>6 data bits</b> per frame
2505 - with default bit order
2506 - at default bus speed
2507 - for default number of data items
2509 \note In Test Mode <b>Loopback</b> this test is skipped
2511 void SPI_Data_Bits_6 (void) {
2513 #if (SPI_SERVER_USED != 0)
2514 if (InitDriver() != EXIT_SUCCESS) { return; }
2515 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2516 if (CheckServer() != EXIT_SUCCESS) { return; }
2517 if ((spi_serv_cap.db_mask & (1U << 5)) == 0U) { // If SPI Server does not support data bits setting
2518 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2522 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);
2523 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);
2524 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);
2527 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2531 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2533 \brief Function: Function SPI_Data_Bits_7
2535 The function \b SPI_Data_Bits_7 verifies data exchange:
2536 - in Master Mode with default Slave Select mode
2537 - with default clock / frame format
2538 - with <b>7 data bits</b> per frame
2539 - with default bit order
2540 - at default bus speed
2541 - for default number of data items
2543 \note In Test Mode <b>Loopback</b> this test is skipped
2545 void SPI_Data_Bits_7 (void) {
2547 #if (SPI_SERVER_USED != 0)
2548 if (InitDriver() != EXIT_SUCCESS) { return; }
2549 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2550 if (CheckServer() != EXIT_SUCCESS) { return; }
2551 if ((spi_serv_cap.db_mask & (1U << 6)) == 0U) { // If SPI Server does not support data bits setting
2552 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2556 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);
2557 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);
2558 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);
2561 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2565 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2567 \brief Function: Function SPI_Data_Bits_8
2569 The function \b SPI_Data_Bits_8 verifies data exchange:
2570 - in Master Mode with default Slave Select mode
2571 - with default clock / frame format
2572 - with <b>8 data bits</b> per frame
2573 - with default bit order
2574 - at default bus speed
2575 - for default number of data items
2577 void SPI_Data_Bits_8 (void) {
2579 if (InitDriver() != EXIT_SUCCESS) { return; }
2580 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2581 #if (SPI_SERVER_USED != 0)
2582 if (CheckServer() != EXIT_SUCCESS) { return; }
2583 if ((spi_serv_cap.db_mask & (1U << 7)) == 0U) { // If SPI Server does not support data bits setting
2584 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2589 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);
2590 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);
2591 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);
2594 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2596 \brief Function: Function SPI_Data_Bits_9
2598 The function \b SPI_Data_Bits_9 verifies data exchange:
2599 - in Master Mode with default Slave Select mode
2600 - with default clock / frame format
2601 - with <b>9 data bits</b> per frame
2602 - with default bit order
2603 - at default bus speed
2604 - for default number of data items
2606 \note In Test Mode <b>Loopback</b> this test is skipped
2608 void SPI_Data_Bits_9 (void) {
2610 #if (SPI_SERVER_USED != 0)
2611 if (InitDriver() != EXIT_SUCCESS) { return; }
2612 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2613 if (CheckServer() != EXIT_SUCCESS) { return; }
2614 if ((spi_serv_cap.db_mask & (1U << 8)) == 0U) { // If SPI Server does not support data bits setting
2615 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2619 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);
2620 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);
2621 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);
2624 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2628 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2630 \brief Function: Function SPI_Data_Bits_10
2632 The function \b SPI_Data_Bits_10 verifies data exchange:
2633 - in Master Mode with default Slave Select mode
2634 - with default clock / frame format
2635 - with <b>10 data bits</b> per frame
2636 - with default bit order
2637 - at default bus speed
2638 - for default number of data items
2640 \note In Test Mode <b>Loopback</b> this test is skipped
2642 void SPI_Data_Bits_10 (void) {
2644 #if (SPI_SERVER_USED != 0)
2645 if (InitDriver() != EXIT_SUCCESS) { return; }
2646 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2647 if (CheckServer() != EXIT_SUCCESS) { return; }
2648 if ((spi_serv_cap.db_mask & (1U << 9)) == 0U) { // If SPI Server does not support data bits setting
2649 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2653 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);
2654 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);
2655 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);
2658 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2662 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2664 \brief Function: Function SPI_Data_Bits_11
2666 The function \b SPI_Data_Bits_11 verifies data exchange:
2667 - in Master Mode with default Slave Select mode
2668 - with default clock / frame format
2669 - with <b>11 data bits</b> per frame
2670 - with default bit order
2671 - at default bus speed
2672 - for default number of data items
2674 \note In Test Mode <b>Loopback</b> this test is skipped
2676 void SPI_Data_Bits_11 (void) {
2678 #if (SPI_SERVER_USED != 0)
2679 if (InitDriver() != EXIT_SUCCESS) { return; }
2680 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2681 if (CheckServer() != EXIT_SUCCESS) { return; }
2682 if ((spi_serv_cap.db_mask & (1U << 10)) == 0U) { // If SPI Server does not support data bits setting
2683 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2687 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);
2688 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);
2689 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);
2692 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2696 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2698 \brief Function: Function SPI_Data_Bits_12
2700 The function \b SPI_Data_Bits_12 verifies data exchange:
2701 - in Master Mode with default Slave Select mode
2702 - with default clock / frame format
2703 - with <b>12 data bits</b> per frame
2704 - with default bit order
2705 - at default bus speed
2706 - for default number of data items
2708 \note In Test Mode <b>Loopback</b> this test is skipped
2710 void SPI_Data_Bits_12 (void) {
2712 #if (SPI_SERVER_USED != 0)
2713 if (InitDriver() != EXIT_SUCCESS) { return; }
2714 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2715 if (CheckServer() != EXIT_SUCCESS) { return; }
2716 if ((spi_serv_cap.db_mask & (1U << 11)) == 0U) { // If SPI Server does not support data bits setting
2717 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2721 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);
2722 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);
2723 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);
2726 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2730 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2732 \brief Function: Function SPI_Data_Bits_13
2734 The function \b SPI_Data_Bits_13 verifies data exchange:
2735 - in Master Mode with default Slave Select mode
2736 - with default clock / frame format
2737 - with <b>13 data bits</b> per frame
2738 - with default bit order
2739 - at default bus speed
2740 - for default number of data items
2742 \note In Test Mode <b>Loopback</b> this test is skipped
2744 void SPI_Data_Bits_13 (void) {
2746 #if (SPI_SERVER_USED != 0)
2747 if (InitDriver() != EXIT_SUCCESS) { return; }
2748 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2749 if (CheckServer() != EXIT_SUCCESS) { return; }
2750 if ((spi_serv_cap.db_mask & (1U << 12)) == 0U) { // If SPI Server does not support data bits setting
2751 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2755 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);
2756 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);
2757 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);
2760 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2764 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2766 \brief Function: Function SPI_Data_Bits_14
2768 The function \b SPI_Data_Bits_14 verifies data exchange:
2769 - in Master Mode with default Slave Select mode
2770 - with default clock / frame format
2771 - with <b>14 data bits</b> per frame
2772 - with default bit order
2773 - at default bus speed
2774 - for default number of data items
2776 \note In Test Mode <b>Loopback</b> this test is skipped
2778 void SPI_Data_Bits_14 (void) {
2780 #if (SPI_SERVER_USED != 0)
2781 if (InitDriver() != EXIT_SUCCESS) { return; }
2782 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2783 if (CheckServer() != EXIT_SUCCESS) { return; }
2784 if ((spi_serv_cap.db_mask & (1U << 13)) == 0U) { // If SPI Server does not support data bits setting
2785 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2789 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);
2790 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);
2791 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);
2794 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2798 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2800 \brief Function: Function SPI_Data_Bits_15
2802 The function \b SPI_Data_Bits_15 verifies data exchange:
2803 - in Master Mode with default Slave Select mode
2804 - with default clock / frame format
2805 - with <b>15 data bits</b> per frame
2806 - with default bit order
2807 - at default bus speed
2808 - for default number of data items
2810 \note In Test Mode <b>Loopback</b> this test is skipped
2812 void SPI_Data_Bits_15 (void) {
2814 #if (SPI_SERVER_USED != 0)
2815 if (InitDriver() != EXIT_SUCCESS) { return; }
2816 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2817 if (CheckServer() != EXIT_SUCCESS) { return; }
2818 if ((spi_serv_cap.db_mask & (1U << 14)) == 0U) { // If SPI Server does not support data bits setting
2819 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2823 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);
2824 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);
2825 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);
2828 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2832 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2834 \brief Function: Function SPI_Data_Bits_16
2836 The function \b SPI_Data_Bits_16 verifies data exchange:
2837 - in Master Mode with default Slave Select mode
2838 - with default clock / frame format
2839 - with <b>16 data bits</b> per frame
2840 - with default bit order
2841 - at default bus speed
2842 - for default number of data items
2844 void SPI_Data_Bits_16 (void) {
2846 if (InitDriver() != EXIT_SUCCESS) { return; }
2847 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2848 #if (SPI_SERVER_USED != 0)
2849 if (CheckServer() != EXIT_SUCCESS) { return; }
2850 if ((spi_serv_cap.db_mask & (1U << 15)) == 0U) { // If SPI Server does not support data bits setting
2851 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2856 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);
2857 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);
2858 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);
2861 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2863 \brief Function: Function SPI_Data_Bits_17
2865 The function \b SPI_Data_Bits_17 verifies data exchange:
2866 - in Master Mode with default Slave Select mode
2867 - with default clock / frame format
2868 - with <b>17 data bits</b> per frame
2869 - with default bit order
2870 - at default bus speed
2871 - for default number of data items
2873 \note In Test Mode <b>Loopback</b> this test is skipped
2875 void SPI_Data_Bits_17 (void) {
2877 #if (SPI_SERVER_USED != 0)
2878 if (InitDriver() != EXIT_SUCCESS) { return; }
2879 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2880 if (CheckServer() != EXIT_SUCCESS) { return; }
2881 if ((spi_serv_cap.db_mask & (1U << 16)) == 0U) { // If SPI Server does not support data bits setting
2882 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2886 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);
2887 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);
2888 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);
2891 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2895 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2897 \brief Function: Function SPI_Data_Bits_18
2899 The function \b SPI_Data_Bits_18 verifies data exchange:
2900 - in Master Mode with default Slave Select mode
2901 - with default clock / frame format
2902 - with <b>18 data bits</b> per frame
2903 - with default bit order
2904 - at default bus speed
2905 - for default number of data items
2907 \note In Test Mode <b>Loopback</b> this test is skipped
2909 void SPI_Data_Bits_18 (void) {
2911 #if (SPI_SERVER_USED != 0)
2912 if (InitDriver() != EXIT_SUCCESS) { return; }
2913 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2914 if (CheckServer() != EXIT_SUCCESS) { return; }
2915 if ((spi_serv_cap.db_mask & (1U << 17)) == 0U) { // If SPI Server does not support data bits setting
2916 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2920 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);
2921 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);
2922 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);
2925 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2929 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2931 \brief Function: Function SPI_Data_Bits_19
2933 The function \b SPI_Data_Bits_19 verifies data exchange:
2934 - in Master Mode with default Slave Select mode
2935 - with default clock / frame format
2936 - with <b>19 data bits</b> per frame
2937 - with default bit order
2938 - at default bus speed
2939 - for default number of data items
2941 \note In Test Mode <b>Loopback</b> this test is skipped
2943 void SPI_Data_Bits_19 (void) {
2945 #if (SPI_SERVER_USED != 0)
2946 if (InitDriver() != EXIT_SUCCESS) { return; }
2947 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2948 if (CheckServer() != EXIT_SUCCESS) { return; }
2949 if ((spi_serv_cap.db_mask & (1U << 18)) == 0U) { // If SPI Server does not support data bits setting
2950 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2954 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);
2955 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);
2956 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);
2959 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2963 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2965 \brief Function: Function SPI_Data_Bits_20
2967 The function \b SPI_Data_Bits_20 verifies data exchange:
2968 - in Master Mode with default Slave Select mode
2969 - with default clock / frame format
2970 - with <b>20 data bits</b> per frame
2971 - with default bit order
2972 - at default bus speed
2973 - for default number of data items
2975 \note In Test Mode <b>Loopback</b> this test is skipped
2977 void SPI_Data_Bits_20 (void) {
2979 #if (SPI_SERVER_USED != 0)
2980 if (InitDriver() != EXIT_SUCCESS) { return; }
2981 if (CheckBuffers() != EXIT_SUCCESS) { return; }
2982 if (CheckServer() != EXIT_SUCCESS) { return; }
2983 if ((spi_serv_cap.db_mask & (1U << 19)) == 0U) { // If SPI Server does not support data bits setting
2984 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
2988 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);
2989 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);
2990 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);
2993 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
2997 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
2999 \brief Function: Function SPI_Data_Bits_21
3001 The function \b SPI_Data_Bits_21 verifies data exchange:
3002 - in Master Mode with default Slave Select mode
3003 - with default clock / frame format
3004 - with <b>21 data bits</b> per frame
3005 - with default bit order
3006 - at default bus speed
3007 - for default number of data items
3009 \note In Test Mode <b>Loopback</b> this test is skipped
3011 void SPI_Data_Bits_21 (void) {
3013 #if (SPI_SERVER_USED != 0)
3014 if (InitDriver() != EXIT_SUCCESS) { return; }
3015 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3016 if (CheckServer() != EXIT_SUCCESS) { return; }
3017 if ((spi_serv_cap.db_mask & (1U << 20)) == 0U) { // If SPI Server does not support data bits setting
3018 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3022 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);
3023 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);
3024 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);
3027 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3031 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3033 \brief Function: Function SPI_Data_Bits_22
3035 The function \b SPI_Data_Bits_22 verifies data exchange:
3036 - in Master Mode with default Slave Select mode
3037 - with default clock / frame format
3038 - with <b>22 data bits</b> per frame
3039 - with default bit order
3040 - at default bus speed
3041 - for default number of data items
3043 \note In Test Mode <b>Loopback</b> this test is skipped
3045 void SPI_Data_Bits_22 (void) {
3047 #if (SPI_SERVER_USED != 0)
3048 if (InitDriver() != EXIT_SUCCESS) { return; }
3049 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3050 if (CheckServer() != EXIT_SUCCESS) { return; }
3051 if ((spi_serv_cap.db_mask & (1U << 21)) == 0U) { // If SPI Server does not support data bits setting
3052 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3056 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);
3057 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);
3058 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);
3061 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3065 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3067 \brief Function: Function SPI_Data_Bits_23
3069 The function \b SPI_Data_Bits_23 verifies data exchange:
3070 - in Master Mode with default Slave Select mode
3071 - with default clock / frame format
3072 - with <b>23 data bits</b> per frame
3073 - with default bit order
3074 - at default bus speed
3075 - for default number of data items
3077 \note In Test Mode <b>Loopback</b> this test is skipped
3079 void SPI_Data_Bits_23 (void) {
3081 #if (SPI_SERVER_USED != 0)
3082 if (InitDriver() != EXIT_SUCCESS) { return; }
3083 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3084 if (CheckServer() != EXIT_SUCCESS) { return; }
3085 if ((spi_serv_cap.db_mask & (1U << 22)) == 0U) { // If SPI Server does not support data bits setting
3086 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3090 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);
3091 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);
3092 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);
3095 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3099 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3101 \brief Function: Function SPI_Data_Bits_24
3103 The function \b SPI_Data_Bits_24 verifies data exchange:
3104 - in Master Mode with default Slave Select mode
3105 - with default clock / frame format
3106 - with <b>24 data bits</b> per frame
3107 - with default bit order
3108 - at default bus speed
3109 - for default number of data items
3111 void SPI_Data_Bits_24 (void) {
3113 if (InitDriver() != EXIT_SUCCESS) { return; }
3114 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3115 #if (SPI_SERVER_USED != 0)
3116 if (CheckServer() != EXIT_SUCCESS) { return; }
3117 if ((spi_serv_cap.db_mask & (1U << 23)) == 0U) { // If SPI Server does not support data bits setting
3118 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3123 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);
3124 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);
3125 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);
3128 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3130 \brief Function: Function SPI_Data_Bits_25
3132 The function \b SPI_Data_Bits_25 verifies data exchange:
3133 - in Master Mode with default Slave Select mode
3134 - with default clock / frame format
3135 - with <b>25 data bits</b> per frame
3136 - with default bit order
3137 - at default bus speed
3138 - for default number of data items
3140 \note In Test Mode <b>Loopback</b> this test is skipped
3142 void SPI_Data_Bits_25 (void) {
3144 #if (SPI_SERVER_USED != 0)
3145 if (InitDriver() != EXIT_SUCCESS) { return; }
3146 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3147 if (CheckServer() != EXIT_SUCCESS) { return; }
3148 if ((spi_serv_cap.db_mask & (1U << 24)) == 0U) { // If SPI Server does not support data bits setting
3149 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3153 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);
3154 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);
3155 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);
3158 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3162 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3164 \brief Function: Function SPI_Data_Bits_26
3166 The function \b SPI_Data_Bits_26 verifies data exchange:
3167 - in Master Mode with default Slave Select mode
3168 - with default clock / frame format
3169 - with <b>26 data bits</b> per frame
3170 - with default bit order
3171 - at default bus speed
3172 - for default number of data items
3174 \note In Test Mode <b>Loopback</b> this test is skipped
3176 void SPI_Data_Bits_26 (void) {
3178 #if (SPI_SERVER_USED != 0)
3179 if (InitDriver() != EXIT_SUCCESS) { return; }
3180 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3181 if (CheckServer() != EXIT_SUCCESS) { return; }
3182 if ((spi_serv_cap.db_mask & (1U << 25)) == 0U) { // If SPI Server does not support data bits setting
3183 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3187 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);
3188 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);
3189 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);
3192 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3196 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3198 \brief Function: Function SPI_Data_Bits_27
3200 The function \b SPI_Data_Bits_27 verifies data exchange:
3201 - in Master Mode with default Slave Select mode
3202 - with default clock / frame format
3203 - with <b>27 data bits</b> per frame
3204 - with default bit order
3205 - at default bus speed
3206 - for default number of data items
3208 \note In Test Mode <b>Loopback</b> this test is skipped
3210 void SPI_Data_Bits_27 (void) {
3212 #if (SPI_SERVER_USED != 0)
3213 if (InitDriver() != EXIT_SUCCESS) { return; }
3214 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3215 if (CheckServer() != EXIT_SUCCESS) { return; }
3216 if ((spi_serv_cap.db_mask & (1U << 26)) == 0U) { // If SPI Server does not support data bits setting
3217 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3221 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);
3222 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);
3223 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);
3226 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3230 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3232 \brief Function: Function SPI_Data_Bits_28
3234 The function \b SPI_Data_Bits_28 verifies data exchange:
3235 - in Master Mode with default Slave Select mode
3236 - with default clock / frame format
3237 - with <b>28 data bits</b> per frame
3238 - with default bit order
3239 - at default bus speed
3240 - for default number of data items
3242 \note In Test Mode <b>Loopback</b> this test is skipped
3244 void SPI_Data_Bits_28 (void) {
3246 #if (SPI_SERVER_USED != 0)
3247 if (InitDriver() != EXIT_SUCCESS) { return; }
3248 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3249 if (CheckServer() != EXIT_SUCCESS) { return; }
3250 if ((spi_serv_cap.db_mask & (1U << 27)) == 0U) { // If SPI Server does not support data bits setting
3251 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3255 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);
3256 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);
3257 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);
3260 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3264 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3266 \brief Function: Function SPI_Data_Bits_29
3268 The function \b SPI_Data_Bits_29 verifies data exchange:
3269 - in Master Mode with default Slave Select mode
3270 - with default clock / frame format
3271 - with <b>29 data bits</b> per frame
3272 - with default bit order
3273 - at default bus speed
3274 - for default number of data items
3276 \note In Test Mode <b>Loopback</b> this test is skipped
3278 void SPI_Data_Bits_29 (void) {
3280 #if (SPI_SERVER_USED != 0)
3281 if (InitDriver() != EXIT_SUCCESS) { return; }
3282 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3283 if (CheckServer() != EXIT_SUCCESS) { return; }
3284 if ((spi_serv_cap.db_mask & (1U << 28)) == 0U) { // If SPI Server does not support data bits setting
3285 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3289 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);
3290 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);
3291 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);
3294 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3298 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3300 \brief Function: Function SPI_Data_Bits_30
3302 The function \b SPI_Data_Bits_30 verifies data exchange:
3303 - in Master Mode with default Slave Select mode
3304 - with default clock / frame format
3305 - with <b>30 data bits</b> per frame
3306 - with default bit order
3307 - at default bus speed
3308 - for default number of data items
3310 \note In Test Mode <b>Loopback</b> this test is skipped
3312 void SPI_Data_Bits_30 (void) {
3314 #if (SPI_SERVER_USED != 0)
3315 if (InitDriver() != EXIT_SUCCESS) { return; }
3316 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3317 if (CheckServer() != EXIT_SUCCESS) { return; }
3318 if ((spi_serv_cap.db_mask & (1U << 29)) == 0U) { // If SPI Server does not support data bits setting
3319 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3323 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);
3324 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);
3325 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);
3328 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3332 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3334 \brief Function: Function SPI_Data_Bits_31
3336 The function \b SPI_Data_Bits_31 verifies data exchange:
3337 - in Master Mode with default Slave Select mode
3338 - with default clock / frame format
3339 - with <b>31 data bits</b> per frame
3340 - with default bit order
3341 - at default bus speed
3342 - for default number of data items
3344 \note In Test Mode <b>Loopback</b> this test is skipped
3346 void SPI_Data_Bits_31 (void) {
3348 #if (SPI_SERVER_USED != 0)
3349 if (InitDriver() != EXIT_SUCCESS) { return; }
3350 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3351 if (CheckServer() != EXIT_SUCCESS) { return; }
3352 if ((spi_serv_cap.db_mask & (1U << 30)) == 0U) { // If SPI Server does not support data bits setting
3353 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3357 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);
3358 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);
3359 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);
3362 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3366 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3368 \brief Function: Function SPI_Data_Bits_32
3370 The function \b SPI_Data_Bits_32 verifies data exchange:
3371 - in Master Mode with default Slave Select mode
3372 - with default clock / frame format
3373 - with <b>32 data bits</b> per frame
3374 - with default bit order
3375 - at default bus speed
3376 - for default number of data items
3378 void SPI_Data_Bits_32 (void) {
3380 if (InitDriver() != EXIT_SUCCESS) { return; }
3381 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3382 #if (SPI_SERVER_USED != 0)
3383 if (CheckServer() != EXIT_SUCCESS) { return; }
3384 if ((spi_serv_cap.db_mask & (1UL << 31)) == 0U) { // If SPI Server does not support data bits setting
3385 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3390 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);
3391 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);
3392 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);
3395 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3397 \brief Function: Function SPI_Bit_Order_MSB_LSB
3399 The function \b SPI_Bit_Order_MSB_LSB verifies data exchange:
3400 - in Master Mode with default Slave Select mode
3401 - with default clock / frame format
3402 - with default data bits
3403 - with bit order <b>from MSB to LSB</b>
3404 - at default bus speed
3405 - for default number of data items
3407 \note In Test Mode <b>Loopback</b> this test is skipped
3409 void SPI_Bit_Order_MSB_LSB (void) {
3411 #if (SPI_SERVER_USED != 0)
3412 if (InitDriver() != EXIT_SUCCESS) { return; }
3413 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3414 if (CheckServer() != EXIT_SUCCESS) { return; }
3415 if ((spi_serv_cap.bo_mask & 1U) == 0U) { // If SPI Server does not support bit order setting
3416 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3420 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);
3421 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);
3422 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);
3425 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3429 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3431 \brief Function: Function SPI_Bit_Order_LSB_MSB
3433 The function \b SPI_Bit_Order_LSB_MSB verifies data exchange:
3434 - in Master Mode with default Slave Select mode
3435 - with default clock / frame format
3436 - with default data bits
3437 - with bit order <b>from LSB to MSB</b>
3438 - at default bus speed
3439 - for default number of data items
3441 \note In Test Mode <b>Loopback</b> this test is skipped
3443 void SPI_Bit_Order_LSB_MSB (void) {
3445 #if (SPI_SERVER_USED != 0)
3446 if (InitDriver() != EXIT_SUCCESS) { return; }
3447 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3448 if (CheckServer() != EXIT_SUCCESS) { return; }
3449 if ((spi_serv_cap.bo_mask & 2U) == 0U) { // If SPI Server does not support bit order setting
3450 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3454 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);
3455 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);
3456 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);
3459 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3463 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3465 \brief Function: Function SPI_Bus_Speed_Min
3467 The function \b SPI_Bus_Speed_Min verifies data exchange:
3468 - in Master Mode with default Slave Select mode
3469 - with default clock / frame format
3470 - with default data bits
3471 - with default bit order
3472 - at <b>minimum bus speed</b> (define <c>SPI_CFG_MIN_BUS_SPEED</c> in DV_SPI_Config.h)
3473 - for default number of data items
3475 This test function checks the following requirements:
3476 - measured bus speed is not 25% lower, or higher than requested
3477 - bus speed value returned by the driver is not negative
3478 - bus speed value returned by the driver is not higher then requested
3479 - bus speed value returned by the driver is not lower then 75% of requested
3481 void SPI_Bus_Speed_Min (void) {
3482 volatile uint64_t bps;
3483 volatile int32_t got_bus_speed;
3485 if (InitDriver() != EXIT_SUCCESS) { return; }
3486 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3487 #if (SPI_SERVER_USED != 0)
3488 if (CheckServer() != EXIT_SUCCESS) { return; }
3489 if (spi_serv_cap.bs_min > SPI_CFG_MIN_BUS_SPEED) { // If SPI Server does not support minimum bus speed
3490 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3495 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);
3496 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);
3497 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);
3499 if (duration != 0xFFFFFFFFU) { // If Transfer finished before timeout
3500 if (duration != 0U) { // If duration of transfer was more than 0 SysTick counts
3501 bps = ((uint64_t)systick_freq * SPI_CFG_DEF_DATA_BITS * SPI_CFG_DEF_NUM) / duration;
3502 if ((bps < ((SPI_CFG_MIN_BUS_SPEED * 3) / 4)) ||
3503 (bps > SPI_CFG_MIN_BUS_SPEED)) {
3504 // If measured bus speed is 25% lower, or higher than requested
3505 (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);
3506 TEST_MESSAGE(msg_buf);
3511 drv->Control (ARM_SPI_SET_BUS_SPEED, SPI_CFG_MIN_BUS_SPEED);
3512 got_bus_speed = drv->Control (ARM_SPI_GET_BUS_SPEED, 0U);
3513 if (got_bus_speed < 0) {
3514 // If bus speed value returned by the driver is negative
3515 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned negative value %i", got_bus_speed);
3516 TEST_FAIL_MESSAGE(msg_buf);
3517 } else if ((uint32_t)got_bus_speed > SPI_CFG_MIN_BUS_SPEED) {
3518 // If bus speed value returned by the driver is higher then requested
3519 (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);
3520 TEST_FAIL_MESSAGE(msg_buf);
3521 } else if ((uint32_t)got_bus_speed < ((SPI_CFG_MIN_BUS_SPEED * 3) / 4)) {
3522 // If bus speed value returned by the driver is lower then 75% of requested
3523 (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);
3524 TEST_MESSAGE(msg_buf);
3528 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3530 \brief Function: Function SPI_Bus_Speed_Max
3532 The function \b SPI_Bus_Speed_Max verifies data exchange:
3533 - in Master Mode with default Slave Select mode
3534 - with default clock / frame format
3535 - with default data bits
3536 - with default bit order
3537 - at <b>maximum bus speed</b> (define <c>SPI_CFG_MAX_BUS_SPEED</c> in DV_SPI_Config.h)
3538 - for default number of data items
3540 This test function checks the following requirements:
3541 - measured bus speed is not 25% lower, or higher than requested
3542 - bus speed value returned by the driver is not negative
3543 - bus speed value returned by the driver is not higher then requested
3544 - bus speed value returned by the driver is not lower then 75% of requested
3546 void SPI_Bus_Speed_Max (void) {
3547 volatile uint64_t bps;
3548 volatile int32_t got_bus_speed;
3550 if (InitDriver() != EXIT_SUCCESS) { return; }
3551 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3552 #if (SPI_SERVER_USED != 0)
3553 if (CheckServer() != EXIT_SUCCESS) { return; }
3554 if (spi_serv_cap.bs_max < SPI_CFG_MAX_BUS_SPEED) { // If SPI Server does not support maximum bus speed
3555 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3560 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);
3561 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);
3562 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);
3564 if (duration != 0xFFFFFFFFU) { // If Transfer finished before timeout
3565 if (duration != 0U) { // If duration of transfer was more than 0 SysTick counts
3566 bps = ((uint64_t)systick_freq * SPI_CFG_DEF_DATA_BITS * SPI_CFG_DEF_NUM) / duration;
3567 if ((bps < ((SPI_CFG_MAX_BUS_SPEED * 3) / 4)) ||
3568 (bps > SPI_CFG_MIN_BUS_SPEED)) {
3569 // If measured bus speed is 25% lower, or higher than requested
3570 (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);
3571 TEST_MESSAGE(msg_buf);
3576 drv->Control (ARM_SPI_SET_BUS_SPEED, SPI_CFG_MAX_BUS_SPEED);
3577 got_bus_speed = drv->Control (ARM_SPI_GET_BUS_SPEED, 0U);
3578 if (got_bus_speed < 0) {
3579 // If bus speed value returned by the driver is negative
3580 (void)snprintf(msg_buf, sizeof(msg_buf), "[FAILED] Get bus speed returned negative value %i", got_bus_speed);
3581 TEST_FAIL_MESSAGE(msg_buf);
3582 } else if ((uint32_t)got_bus_speed > SPI_CFG_MAX_BUS_SPEED) {
3583 // If bus speed value returned by the driver is higher then requested
3584 (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);
3585 TEST_FAIL_MESSAGE(msg_buf);
3586 } else if ((uint32_t)got_bus_speed < ((SPI_CFG_MAX_BUS_SPEED * 3) / 4)) {
3587 // If bus speed value returned by the driver is lower then 75% of requested
3588 (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);
3589 TEST_MESSAGE(msg_buf);
3593 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3595 \brief Function: Function SPI_Number_Of_Items
3597 The function \b SPI_Number_Of_Items verifies data exchange:
3598 - in Master Mode with default Slave Select mode
3599 - with default clock / frame format
3600 - with default data bits
3601 - with default bit order
3602 - at default bus speed
3603 - for <b>different number of items</b> (defines <c>SPI_CFG_NUM1 .. SPI_CFG_NUM5</c> in DV_SPI_Config.h)
3605 void SPI_Number_Of_Items (void) {
3607 if (InitDriver() != EXIT_SUCCESS) { return; }
3608 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3609 #if (SPI_SERVER_USED != 0)
3610 if (CheckServer() != EXIT_SUCCESS) { return; }
3611 if ((spi_serv_cap.mode_mask & 2U) == 0U) { // If SPI Server does not support Slave mode
3612 TEST_MESSAGE("[FAILED] Test not supported by SPI Server! Test aborted!");
3617 #if (SPI_CFG_NUM1 != 0U)
3618 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM1);
3619 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM1);
3620 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM1);
3623 #if (SPI_CFG_NUM2 != 0U)
3624 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM2);
3625 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM2);
3626 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM2);
3629 #if (SPI_CFG_NUM3 != 0U)
3630 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM3);
3631 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM3);
3632 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM3);
3635 #if (SPI_CFG_NUM4 != 0U)
3636 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM4);
3637 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM4);
3638 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM4);
3641 #if (SPI_CFG_NUM5 != 0U)
3642 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM5);
3643 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM5);
3644 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_NUM5);
3648 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3650 \brief Function: Function SPI_GetDataCount
3652 The function \b SPI_GetDataCount verifies \b GetDataCount function (count changing) during data exchange:
3653 - in Master Mode with default Slave Select mode
3654 - with default clock / frame format
3655 - with default data bits
3656 - with default bit order
3657 - at default bus speed
3659 void SPI_GetDataCount (void) {
3661 if (InitDriver() != EXIT_SUCCESS) { return; }
3662 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3663 #if (SPI_SERVER_USED != 0)
3664 if (CheckServer() != EXIT_SUCCESS) { return; }
3667 SPI_DataExchange_Operation(OP_SEND, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3668 TEST_ASSERT_MESSAGE((data_count_sample != 0U) && (data_count_sample != SPI_CFG_DEF_NUM), "[FAILED] GetDataCount was not changing during the Send!");
3670 SPI_DataExchange_Operation(OP_RECEIVE, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3671 TEST_ASSERT_MESSAGE((data_count_sample != 0U) && (data_count_sample != SPI_CFG_DEF_NUM), "[FAILED] GetDataCount was not changing during the Receive!");
3673 SPI_DataExchange_Operation(OP_TRANSFER, MODE_MASTER, SPI_CFG_DEF_FORMAT, SPI_CFG_DEF_DATA_BITS, SPI_CFG_DEF_BIT_ORDER, SPI_CFG_DEF_SS_MODE, SPI_CFG_DEF_BUS_SPEED, SPI_CFG_DEF_NUM);
3674 TEST_ASSERT_MESSAGE((data_count_sample != 0U) && (data_count_sample != SPI_CFG_DEF_NUM), "[FAILED] GetDataCount was not changing during the Transfer!");
3677 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3679 \brief Function: Function SPI_Abort
3681 The function \b SPI_Abort verifies \b Abort function abort of data exchange:
3682 - in Master Mode with default Slave Select mode
3683 - with default clock / frame format
3684 - with default data bits
3685 - with default bit order
3686 - at default bus speed
3688 void SPI_Abort (void) {
3690 if (InitDriver() != EXIT_SUCCESS) { return; }
3691 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3692 #if (SPI_SERVER_USED != 0)
3693 if (CheckServer() != EXIT_SUCCESS) { return; }
3696 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);
3697 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);
3698 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);
3704 // End of spi_tests_data_xchg
3706 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3707 /* SPI Error Event tests */
3708 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3710 \defgroup spi_tests_err_evt Error Event
3713 These tests verify API and operation of the SPI error event signaling.
3715 The error event tests verify the following driver function
3716 (<a href="http://www.keil.com/pack/doc/CMSIS/Driver/html/group__spi__interface__gr.html" target="_blank">SPI Driver function documentation</a>):
3719 void (*ARM_SPI_SignalEvent_t) (uint32_t event);
3722 \note In Test Mode <b>Loopback</b> these tests are skipped
3726 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3728 \brief Function: Function SPI_DataLost
3730 The function \b SPI_DataLost verifies signaling of the <b>ARM_SPI_EVENT_DATA_LOST</b> event:
3731 - in <b>Slave Mode</b> with <b>Slave Select line Hardware Monitored</b>
3732 - with default clock / frame format
3733 - with default data bits
3734 - with default bit order
3735 - at default bus speed
3737 void SPI_DataLost (void) {
3739 #if (SPI_SERVER_USED != 0)
3740 if (InitDriver() != EXIT_SUCCESS) { return; }
3741 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3742 if (CheckServer() != EXIT_SUCCESS) { return; }
3745 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3746 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; }
3747 if (CmdXfer (SPI_CFG_DEF_NUM, 20U, SPI_CFG_XFER_TIMEOUT, 0U) != EXIT_SUCCESS) { break; }
3749 (void)drv->Control (ARM_SPI_MODE_SLAVE |
3750 ((SPI_CFG_DEF_FORMAT << ARM_SPI_FRAME_FORMAT_Pos) & ARM_SPI_FRAME_FORMAT_Msk) |
3751 ((SPI_CFG_DEF_DATA_BITS << ARM_SPI_DATA_BITS_Pos) & ARM_SPI_DATA_BITS_Msk) |
3752 ((SPI_CFG_DEF_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos) & ARM_SPI_BIT_ORDER_Msk) |
3753 ARM_SPI_SS_SLAVE_HW ,
3754 SPI_CFG_DEF_BUS_SPEED);
3757 (void)osDelay(SPI_CFG_XFER_TIMEOUT+20U); // Wait for SPI Server to timeout
3759 // Assert that event ARM_SPI_EVENT_DATA_LOST was signaled
3760 TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_DATA_LOST) != 0U, "[FAILED] Event ARM_SPI_EVENT_DATA_LOST was not signaled!");
3766 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3770 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
3772 \brief Function: Function SPI_ModeFault
3774 The function \b SPI_ModeFault verifies signaling of the <b>ARM_SPI_EVENT_MODE_FAULT</b> event:
3775 - in <b>Master Mode</b> with <b>Slave Select line Hardware Monitored Input</b>
3776 - with default clock / frame format
3777 - with default data bits
3778 - with default bit order
3779 - at default bus speed
3781 void SPI_ModeFault (void) {
3783 if (drv->GetCapabilities().event_mode_fault == 0U) {
3784 TEST_MESSAGE("[WARNING] This driver does not support ARM_SPI_EVENT_MODE_FAULT event signaling! Test skipped!");
3788 #if (SPI_SERVER_USED != 0)
3789 if (InitDriver() != EXIT_SUCCESS) { return; }
3790 if (CheckBuffers() != EXIT_SUCCESS) { return; }
3791 if (CheckServer() != EXIT_SUCCESS) { return; }
3794 if (ComConfigDefault() != EXIT_SUCCESS) { break; }
3795 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; }
3796 if (CmdXfer (SPI_CFG_DEF_NUM, 0U, SPI_CFG_XFER_TIMEOUT, SPI_CFG_DEF_NUM / 2U) != EXIT_SUCCESS) { break; }
3798 (void)drv->Control (ARM_SPI_MODE_MASTER |
3799 ((SPI_CFG_DEF_FORMAT << ARM_SPI_FRAME_FORMAT_Pos) & ARM_SPI_FRAME_FORMAT_Msk) |
3800 ((SPI_CFG_DEF_DATA_BITS << ARM_SPI_DATA_BITS_Pos) & ARM_SPI_DATA_BITS_Msk) |
3801 ((SPI_CFG_DEF_BIT_ORDER << ARM_SPI_BIT_ORDER_Pos) & ARM_SPI_BIT_ORDER_Msk) |
3802 ARM_SPI_SS_MASTER_HW_INPUT ,
3803 SPI_CFG_DEF_BUS_SPEED);
3807 TEST_ASSERT(drv->Transfer(ptr_tx_buf, ptr_rx_buf, SPI_CFG_DEF_NUM) == ARM_DRIVER_OK);
3809 (void)osDelay(SPI_CFG_XFER_TIMEOUT+10U); // Wait for SPI Server to timeout
3811 // Assert that event ARM_SPI_EVENT_MODE_FAULT was signaled
3812 TEST_ASSERT_MESSAGE((event & ARM_SPI_EVENT_MODE_FAULT) != 0U, "[FAILED] Event ARM_SPI_EVENT_MODE_FAULT was not signaled!");
3818 TEST_MESSAGE("[WARNING] Test not supported in Loopback Test Mode! Test skipped!");
3825 // End of spi_tests_err_evt