foxBMS-UnitTests  1.0.0
The foxBMS Unit Tests API Documentation
test_dma.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2021, Fraunhofer-Gesellschaft zur Foerderung der
4  * angewandten Forschung e.V. All rights reserved.
5  *
6  * BSD 3-Clause License
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  *
30  * We kindly request you to use one or more of the following phrases to refer
31  * to foxBMS in your hardware, software, documentation or advertising
32  * materials:
33  *
34  * ″This product uses parts of foxBMS®″
35  *
36  * ″This product includes parts of foxBMS®″
37  *
38  * ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file test_dma.c
44  * @author foxBMS Team
45  * @date 2020-04-01 (date of creation)
46  * @updated 2021-03-24 (date of last update)
47  * @ingroup UNIT_TEST_IMPLEMENTATION
48  * @prefix TEST
49  *
50  * @brief Tests for the dma module
51  *
52  */
53 
54 /*========== Includes =======================================================*/
55 #include "unity.h"
56 #include "MockHL_spi.h"
57 #include "MockHL_sys_dma.h"
58 #include "Mockio.h"
59 #include "Mockmic_dma.h"
60 #include "Mockspi.h"
61 
62 #include "dma.h"
63 
64 TEST_FILE("dma.c")
65 
66 /*========== Definitions and Implementations for Unit Test ==================*/
67 static const spiDAT1_t spi_kLtcDataConfig = {
68  /* struct is implemented in the TI HAL and uses uppercase true and false */
69  .CS_HOLD = FALSE, /* The HW chip select signal is deactivated */
70  .WDEL = TRUE, /* No delay will be inserted */
71  .DFSEL = SPI_FMT_0, /* Data word format select: Data format 0 (SPI1) */
72  .CSNR = 0x0, /* Chip select (CS) number, 0x01h for CS[0] */
73 };
74 
75 uint32_t spi_saveFmt0[] = {
76  0U,
77  0U,
78  0U,
79  0U,
80  0U,
81  0U,
82 };
83 
85  SPI_IDLE,
86  SPI_IDLE,
87  SPI_IDLE,
88  SPI_IDLE,
89  SPI_IDLE,
90 };
91 
92 const uint8_t spi_nrBusyFlags = sizeof(spi_busyFlags) / sizeof(SPI_BUSY_STATE_e);
93 
95  {
97  .pConfig = &spi_kLtcDataConfig,
98  .pNode = spiREG1,
99  .pGioPort = &(spiREG1->PC3),
100  .csPin = 2u,
101  },
102  {
103  .channel = SPI_Interface1,
104  .pConfig = &spi_kLtcDataConfig,
105  .pNode = spiREG1,
106  .pGioPort = &(spiREG1->PC3),
107  .csPin = 2u,
108  },
109  {
110  .channel = SPI_Interface1,
111  .pConfig = &spi_kLtcDataConfig,
112  .pNode = spiREG1,
113  .pGioPort = &(spiREG1->PC3),
114  .csPin = 2u,
115  },
116  {
117  .channel = SPI_Interface1,
118  .pConfig = &spi_kLtcDataConfig,
119  .pNode = spiREG1,
120  .pGioPort = &(spiREG1->PC3),
121  .csPin = 2u,
122  },
123  {
124  .channel = SPI_Interface1,
125  .pConfig = &spi_kLtcDataConfig,
126  .pNode = spiREG1,
127  .pGioPort = &(spiREG1->PC3),
128  .csPin = 2u,
129  },
130 };
131 
133  {DMA_CH0, DMA_CH1}, /* SPI1 */
134  {DMA_CH2, DMA_CH3}, /* SPI2 */
135  {DMA_CH4, DMA_CH5}, /* SPI3 */
136  {DMA_CH6, DMA_CH7}, /* SPI4 */
137  {DMA_CH8, DMA_CH9}, /* SPI5 */
138 };
139 
146 };
147 
149  spiREG1, /* SPI1 */
150  spiREG2, /* SPI2 */
151  spiREG3, /* SPI3 */
152  spiREG4, /* SPI4 */
153  spiREG5, /* SPI5 */
154 };
155 
156 /*========== Setup and Teardown =============================================*/
157 void setUp(void) {
158 }
159 
160 void tearDown(void) {
161 }
162 
163 /*========== Test Cases =====================================================*/
164 
165 void testDummy(void) {
166 }
spi_saveFmt0
uint32_t spi_saveFmt0[]
Definition: test_dma.c:75
SPI_IDLE
@ SPI_IDLE
Definition: spi_cfg.h:93
SPI_INTERFACE_CONFIG::channel
SPI_INTERFACE_e channel
Definition: spi_cfg.h:108
dma_spiDmaChannels
DMA_CHANNEL_CONFIG_s dma_spiDmaChannels[DMA_NUMBER_SPI_INTERFACES]
Definition: test_dma.c:132
spi_dmaTransmission
SPI_INTERFACE_CONFIG_s spi_dmaTransmission[]
Variable used for SPI over DMA transmission. Retains the CS pin to deactivate in DMA callback.
Definition: test_dma.c:94
DMA_REQ_LINE_SPI3_TX
#define DMA_REQ_LINE_SPI3_TX
Definition: dma_cfg.h:77
DMA_REQ_LINE_SPI2_RX
#define DMA_REQ_LINE_SPI2_RX
Definition: dma_cfg.h:76
dma_spiDmaRequests
DMA_REQUEST_CONFIG_s dma_spiDmaRequests[DMA_NUMBER_SPI_INTERFACES]
Definition: test_dma.c:140
testDummy
void testDummy(void)
Definition: test_dma.c:165
DMA_REQ_LINE_SPI1_RX
#define DMA_REQ_LINE_SPI1_RX
Definition: dma_cfg.h:74
DMA_REQ_LINE_SPI1_TX
#define DMA_REQ_LINE_SPI1_TX
Definition: dma_cfg.h:73
spi_kLtcDataConfig
static const spiDAT1_t spi_kLtcDataConfig
Definition: test_dma.c:67
SPI_Interface1
@ SPI_Interface1
Definition: spi_cfg.h:99
dma_spiInterfaces
spiBASE_t * dma_spiInterfaces[DMA_NUMBER_SPI_INTERFACES]
Definition: test_dma.c:148
SPI_INTERFACE_CONFIG
Definition: spi_cfg.h:107
DMA_REQ_LINE_SPI4_TX
#define DMA_REQ_LINE_SPI4_TX
Definition: dma_cfg.h:79
DMA_REQ_LINE_SPI5_TX
#define DMA_REQ_LINE_SPI5_TX
Definition: dma_cfg.h:81
DMA_REQ_LINE_SPI2_TX
#define DMA_REQ_LINE_SPI2_TX
Definition: dma_cfg.h:75
DMA_NUMBER_SPI_INTERFACES
#define DMA_NUMBER_SPI_INTERFACES
Definition: dma_cfg.h:69
tearDown
void tearDown(void)
Definition: test_dma.c:160
DMA_REQ_LINE_SPI5_RX
#define DMA_REQ_LINE_SPI5_RX
Definition: dma_cfg.h:82
DMA_REQ_LINE_SPI3_RX
#define DMA_REQ_LINE_SPI3_RX
Definition: dma_cfg.h:78
DMA_CHANNEL_CONFIG
Definition: dma_cfg.h:107
spi_busyFlags
SPI_BUSY_STATE_e spi_busyFlags[]
Definition: test_dma.c:84
DMA_REQ_LINE_SPI4_RX
#define DMA_REQ_LINE_SPI4_RX
Definition: dma_cfg.h:80
spi_nrBusyFlags
const uint8_t spi_nrBusyFlags
Definition: test_dma.c:92
SPI_BUSY_STATE_e
enum SPI_BUSY_STATE SPI_BUSY_STATE_e
setUp
void setUp(void)
Definition: test_dma.c:157
DMA_REQUEST_CONFIG
Definition: dma_cfg.h:113
dma.h
Headers for the driver for the DMA module.