foxBMS  1.3.0
The foxBMS Battery Management System API Documentation
spi.c
Go to the documentation of this file.
1 /**
2  *
3  * @copyright © 2010 - 2022, Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  * list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright notice,
15  * this list of conditions and the following disclaimer in the documentation
16  * and/or other materials provided with the distribution.
17  *
18  * 3. Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from
20  * this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * We kindly request you to use one or more of the following phrases to refer to
34  * foxBMS in your hardware, software, documentation or advertising materials:
35  *
36  * - ″This product uses parts of foxBMS®″
37  * - ″This product includes parts of foxBMS®″
38  * - ″This product is derived from foxBMS®″
39  *
40  */
41 
42 /**
43  * @file spi.c
44  * @author foxBMS Team
45  * @date 2019-12-12 (date of creation)
46  * @updated 2022-05-30 (date of last update)
47  * @version v1.3.0
48  * @ingroup DRIVERS
49  * @prefix SPI
50  *
51  * @brief Driver for the SPI module.
52  *
53  */
54 
55 /*========== Includes =======================================================*/
56 #include "spi.h"
57 
58 #include "HL_reg_spi.h"
59 #include "HL_spi.h"
60 #include "HL_sys_common.h"
61 
62 #include "dma.h"
63 #include "fsystem.h"
64 #include "io.h"
65 #include "os.h"
66 
68 
69 /*========== Macros and Definitions =========================================*/
70 /** Bitfield to check for transmission errors in SPI FLAG register */
71 #define SPI_FLAG_REGISTER_TRANSMISSION_ERRORS (0x5Fu)
72 
73 /*========== Static Constant and Variable Definitions =======================*/
74 
75 /*========== Extern Constant and Variable Definitions =======================*/
76 
77 /*========== Static Function Prototypes =====================================*/
78 
79 /*========== Static Function Implementations ================================*/
80 
81 /*========== Extern Function Implementations ================================*/
82 
83 extern STD_RETURN_TYPE_e SPI_TransmitDummyByte(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint32_t delay) {
84  FAS_ASSERT(pSpiInterface != NULL_PTR);
85  /* AXIVION Routine Generic-MissingParameterAssert: delay: parameter accepts whole range */
86 
87  uint16_t txDummy[1] = {0x00};
88  STD_RETURN_TYPE_e retVal = SPI_TransmitData(pSpiInterface, txDummy, 1u);
89  MCU_Delay_us(delay);
90  return retVal;
91 }
92 
93 extern STD_RETURN_TYPE_e SPI_TransmitData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint32 frameLength) {
94  FAS_ASSERT(pSpiInterface != NULL_PTR);
95  FAS_ASSERT(pTxBuff != NULL_PTR);
96  FAS_ASSERT(frameLength > 0u);
98 
99  /* Lock SPI hardware to prevent concurrent read/write commands */
100  if (STD_OK == SPI_Lock(SPI_GetSpiIndex(pSpiInterface->pNode))) {
101  pSpiInterface->pNode->GCR1 |= SPIEN_BIT;
102 
103  /** SW Chip Select */
104  if (pSpiInterface->csType == SPI_CHIP_SELECT_SOFTWARE) {
105  /** Set SPI Chip Select pins as GIOs */
106  pSpiInterface->pNode->PC0 &= SPI_PC0_CLEAR_HW_CS_MASK;
107  /** Activate Chip Select */
108  IO_PinReset(pSpiInterface->pGioPort, pSpiInterface->csPin);
109  }
110  /** HW Chip Select */
111  if (pSpiInterface->csType == SPI_CHIP_SELECT_HARDWARE) {
112  /**
113  * Activate HW Chip Select according to bitmask register CSNR
114  * by setting pins as SPI functional pins
115  */
116  /** First deactivate all HW Chip Selects */
117  pSpiInterface->pNode->PC0 &= SPI_PC0_CLEAR_HW_CS_MASK;
118  for (uint8_t csNumber = 0u; csNumber < SPI_MAX_NUMBER_HW_CS; csNumber++) {
119  if (((pSpiInterface->pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
120  /** Bitmask = 0 --> HW CS active
121  * --> write to PC0 to set pin as SPI pin (and not GIO)
122  */
123  pSpiInterface->pNode->PC0 |= (uint32_t)1u << csNumber;
124  }
125  }
126  }
127  uint32_t spiRetval = spiTransmitData(pSpiInterface->pNode, pSpiInterface->pConfig, frameLength, pTxBuff);
128  /** SW Chip Select */
129  if (pSpiInterface->csType == SPI_CHIP_SELECT_SOFTWARE) {
130  /** Deactivate Chip Select */
131  IO_PinSet(pSpiInterface->pGioPort, pSpiInterface->csPin);
132  }
133 
134  /* Unlock SPI hardware */
135  SPI_Unlock(SPI_GetSpiIndex(pSpiInterface->pNode));
136 
137  /* Transmission successful */
138  if ((spiRetval & SPI_FLAG_REGISTER_TRANSMISSION_ERRORS) == 0u) {
139  retval = STD_OK;
140  }
141  }
142  return retval;
143 }
144 
146  SPI_INTERFACE_CONFIG_s *pSpiInterface,
147  uint16 *pTxBuff,
148  uint16 *pRxBuff,
149  uint32 frameLength) {
150  FAS_ASSERT(pSpiInterface != NULL_PTR);
151  FAS_ASSERT(pTxBuff != NULL_PTR);
152  FAS_ASSERT(pRxBuff != NULL_PTR);
153  FAS_ASSERT(frameLength > 0u);
154  STD_RETURN_TYPE_e retval = STD_NOT_OK;
155 
156  /* Lock SPI hardware to prevent concurrent read/write commands */
157  if (STD_OK == SPI_Lock(SPI_GetSpiIndex(pSpiInterface->pNode))) {
158  pSpiInterface->pNode->GCR1 |= SPIEN_BIT;
159 
160  /** SW Chip Select */
161  if (pSpiInterface->csType == SPI_CHIP_SELECT_SOFTWARE) {
162  /** Set SPI Chip Select pins as GIOs */
163  pSpiInterface->pNode->PC0 &= SPI_PC0_CLEAR_HW_CS_MASK;
164  /** Activate Chip Select */
165  IO_PinReset(pSpiInterface->pGioPort, pSpiInterface->csPin);
166  }
167  /** HW Chip Select */
168  if (pSpiInterface->csType == SPI_CHIP_SELECT_HARDWARE) {
169  /**
170  * Activate HW Chip Select according to bitmask register CSNR
171  * by setting pins as SPI functional pins
172  */
173  /** First deactivate all HW Chip Selects */
174  pSpiInterface->pNode->PC0 &= SPI_PC0_CLEAR_HW_CS_MASK;
175  for (uint8_t csNumber = 0u; csNumber < SPI_MAX_NUMBER_HW_CS; csNumber++) {
176  if (((pSpiInterface->pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
177  /** Bitmask = 0 --> HW CS active
178  * --> write to PC0 to set pin as SPI pin (and not GIO)
179  */
180  pSpiInterface->pNode->PC0 |= (uint32_t)1u << csNumber;
181  }
182  }
183  }
184  uint32_t spiRetval =
185  spiTransmitAndReceiveData(pSpiInterface->pNode, pSpiInterface->pConfig, frameLength, pTxBuff, pRxBuff);
186  /** SW Chip Select */
187  if (pSpiInterface->csType == SPI_CHIP_SELECT_SOFTWARE) {
188  /** Deactivate Chip Select */
189  IO_PinSet(pSpiInterface->pGioPort, pSpiInterface->csPin);
190  }
191 
192  /* Unlock SPI hardware */
193  SPI_Unlock(SPI_GetSpiIndex(pSpiInterface->pNode));
194 
195  /* Transmission successful */
196  if ((spiRetval & SPI_FLAG_REGISTER_TRANSMISSION_ERRORS) == 0u) {
197  retval = STD_OK;
198  }
199  }
200  return retval;
201 }
202 
204  SPI_INTERFACE_CONFIG_s *pSpiInterface,
205  uint16 *pTxBuff,
206  uint16 *pRxBuff,
207  uint32 frameLength) {
208  FAS_ASSERT(pSpiInterface != NULL_PTR);
209  FAS_ASSERT(pTxBuff != NULL_PTR);
210  FAS_ASSERT(pRxBuff != NULL_PTR);
211  FAS_ASSERT(frameLength > 0u);
212 
213  (void)spiTransmitAndReceiveData(pSpiInterface->pNode, pSpiInterface->pConfig, frameLength, pTxBuff, pRxBuff);
214 }
215 
217  SPI_INTERFACE_CONFIG_s *pSpiInterface,
218  uint16_t *pTxBuff,
219  uint16_t *pRxBuff,
220  uint32_t frameLength) {
221  FAS_ASSERT(frameLength > 2u);
222  FAS_ASSERT(pSpiInterface != NULL_PTR);
223  FAS_ASSERT(pTxBuff != NULL_PTR);
224  FAS_ASSERT(pRxBuff != NULL_PTR);
225  /** SPI over DMA currently only compatible with HW Chip Select */
226  FAS_ASSERT(pSpiInterface->csType == SPI_CHIP_SELECT_HARDWARE);
227  const uint8_t spiIndex = SPI_GetSpiIndex(pSpiInterface->pNode);
228  FAS_ASSERT(spiIndex < spi_nrBusyFlags);
229 
230  STD_RETURN_TYPE_e retVal = STD_NOT_OK;
231 
233  /* Lock SPI hardware to prevent concurrent read/write commands */
234  if (spi_busyFlags[spiIndex] == SPI_IDLE) {
235  spi_busyFlags[spiIndex] = SPI_BUSY;
236 
237  /* Check that not SPI transmission over DMA is taking place */
238  if ((pSpiInterface->pNode->INT0 & DMAREQEN_BIT) == 0x0) {
239  /**
240  * Activate HW Chip Select according to bitmask register CSNR
241  * by setting pins as SPI functional pins
242  */
243  /** First deactivate all HW Chip Selects */
244  pSpiInterface->pNode->PC0 &= SPI_PC0_CLEAR_HW_CS_MASK;
245  for (uint8_t csNumber = 0u; csNumber < SPI_MAX_NUMBER_HW_CS; csNumber++) {
246  if (((pSpiInterface->pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
247  /** Bitmask = 0 --> HW CS active
248  * --> write to PC0 to set pin as SPI pin (and not GIO)
249  */
250  pSpiInterface->pNode->PC0 |= (uint32_t)1u << csNumber;
251  }
252  }
253 
254  /* The upper 16 bits will be written in the SPI DAT1 register where they serve as configuration */
255  uint32 Chip_Select_Hold = 0u;
256  if (pSpiInterface->pConfig->CS_HOLD == TRUE) {
257  Chip_Select_Hold = SPI_CSHOLD_BIT;
258  } else {
259  Chip_Select_Hold = 0U;
260  }
261  uint32 WDelay = 0u;
262  if (pSpiInterface->pConfig->WDEL == TRUE) {
263  WDelay = SPI_WDEL_BIT;
264  } else {
265  WDelay = 0U;
266  }
267  SPIDATAFMT_t DataFormat = pSpiInterface->pConfig->DFSEL;
268  uint8 ChipSelect = pSpiInterface->pConfig->CSNR;
269 
270  /* Go to privilege mode to write DMA config registers */
271  (void)FSYS_RaisePrivilege();
272 
273  spi_txLastWord[spiIndex] = pTxBuff[frameLength - 1u];
274  spi_txLastWord[spiIndex] |= ((uint32)DataFormat << SPI_DATA_FORMAT_FIELD_POSITION) |
275  ((uint32)ChipSelect << SPI_HARDWARE_CHIP_SELECT_FIELD_POSITION) | (WDelay);
276 
277  /* Set Tx buffer address */
278  dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[spiIndex].txChannel].ISADDR =
279  (uint32_t)(&pTxBuff[1u]); /* First word sent manually to write configuration in SPIDAT1 register */
280  /**
281  * Set number of Tx words to send
282  * Last word sent in ISR to set CSHOLD = 0
283  */
284  dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[spiIndex].txChannel].ITCOUNT =
285  ((frameLength - 2u) << 16U) | 1U; /* Last word sent manually to write CSHOLD in SPIDAT1 register */
286 
287  /* Set Rx buffer address */
288  dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[spiIndex].rxChannel].IDADDR = (uint32_t)pRxBuff;
289  /* Set number of Rx words to receive */
290  dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[spiIndex].rxChannel].ITCOUNT = (frameLength << 16U) | 1U;
291 
292  /* Re-enable channels; because auto-init is disabled */
293  /* Disable otherwise transmission is constantly ongoing */
294  dmaSetChEnable((dmaChannel_t)dma_spiDmaChannels[spiIndex].txChannel, (dmaTriggerType_t)DMA_HW);
295  dmaSetChEnable((dmaChannel_t)dma_spiDmaChannels[spiIndex].rxChannel, (dmaTriggerType_t)DMA_HW);
296 
297  /* DMA config registers written, leave privilege mode */
299 
300  /* DMA_REQ_Enable */
301  /* Starts DMA requests if SPIEN is also set to 1 */
302  pSpiInterface->pNode->GCR1 |= SPIEN_BIT;
303  uint32_t txBuffer = pTxBuff[0u];
304  txBuffer |= ((uint32)DataFormat << 24U) | ((uint32)ChipSelect << 16U) | (WDelay) | (Chip_Select_Hold);
305  /**
306  * Send first word without DMA because when writing config to DAT1
307  * the HW CS pin are asserted immediately, even if SPIEN bit in GCR1 is 0.
308  * The C2TDELAY is then taken into account before the transmission.
309  */
310  pSpiInterface->pNode->DAT1 = txBuffer;
311  uint32_t timeoutIterations = SPI_TX_EMPTY_TIMEOUT_ITERATIONS;
312  while (((pSpiInterface->pNode->FLG & (uint32)((uint32_t)1u << SPI_TX_BUFFER_EMPTY_FLAG_POSITION)) == 0u) &&
313  (timeoutIterations > 0u)) {
314  timeoutIterations--;
315  }
316  pSpiInterface->pNode->INT0 |= DMAREQEN_BIT;
317 
318  retVal = STD_OK;
319  }
320  }
322 
323  return retVal;
324 }
325 
326 extern STD_RETURN_TYPE_e SPI_Lock(uint8_t spi) {
327  /* AXIVION Routine Generic-MissingParameterAssert: spi: parameter accepts whole range */
328 
329  STD_RETURN_TYPE_e retVal = STD_NOT_OK;
330 
332  if ((spi < spi_nrBusyFlags) && (spi_busyFlags[spi] == SPI_IDLE)) {
333  spi_busyFlags[spi] = SPI_BUSY;
334  retVal = STD_OK;
335  } else {
336  retVal = STD_NOT_OK;
337  }
339 
340  return retVal;
341 }
342 
343 extern void SPI_Unlock(uint8_t spi) {
344  /* AXIVION Routine Generic-MissingParameterAssert: spi: parameter accepts whole range */
345 
347  if (spi < spi_nrBusyFlags) {
348  spi_busyFlags[spi] = SPI_IDLE;
349  }
351 }
352 
353 extern void SPI_SetFunctional(spiBASE_t *pNode, enum spiPinSelect bit, bool hardwareControlled) {
354  FAS_ASSERT(pNode != NULL_PTR);
355  FAS_ASSERT(bit <= (enum spiPinSelect)LARGEST_PIN_NUMBER);
356 
357  /* retrieve current configuration */
358  spi_config_reg_t configRegisterBuffer = {0};
359  if (pNode == spiREG1) {
360  spi1GetConfigValue(&configRegisterBuffer, CurrentValue);
361  } else if (pNode == spiREG2) {
362  spi2GetConfigValue(&configRegisterBuffer, CurrentValue);
363  } else if (pNode == spiREG3) {
364  spi3GetConfigValue(&configRegisterBuffer, CurrentValue);
365  } else if (pNode == spiREG4) {
366  spi4GetConfigValue(&configRegisterBuffer, CurrentValue);
367  } else if (pNode == spiREG5) {
368  spi5GetConfigValue(&configRegisterBuffer, CurrentValue);
369  } else {
370  /* invalid SPI node */
372  }
373  uint32_t newPc0 = configRegisterBuffer.CONFIG_PC0;
374 
375  if (hardwareControlled == false) {
376  /* bit has to be cleared */
377  newPc0 &= ~(uint32_t)((uint32_t)1u << (uint8_t)(bit));
378  } else {
379  /* bit has to be set */
380  newPc0 |= (uint32_t)((uint32_t)1u << (uint8_t)(bit));
381  }
382 
383  /* set new port value */
384  spiSetFunctional(pNode, newPc0);
385 }
386 
388  SPI_INTERFACE_CONFIG_s *pSpiInterface,
389  uint16_t *pTxBuff,
390  uint16_t *pRxBuff,
391  uint32_t frameLength) {
392  FAS_ASSERT(pSpiInterface != NULL_PTR);
393  FAS_ASSERT(pTxBuff != NULL_PTR);
394  FAS_ASSERT(pRxBuff != NULL_PTR);
395  FAS_ASSERT(frameLength > 0u);
396  /** SPI receive works only with HW Chip Select */
397  FAS_ASSERT(pSpiInterface->csType == SPI_CHIP_SELECT_HARDWARE);
398 
399  STD_RETURN_TYPE_e retVal = STD_OK;
400 
402  /* Go to privilege mode to write DMA config registers */
403  (void)FSYS_RaisePrivilege();
404 
405  /* DMA_REQ Disable */
406  pSpiInterface->pNode->INT0 &= ~DMAREQEN_BIT;
407  pSpiInterface->pNode->GCR1 &= ~SPIEN_BIT;
408 
409  /* Set Tx buffer address */
410  dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].txChannel].ISADDR =
411  (uint32_t)pTxBuff;
412  /* Set number of Tx bytes to send */
413  dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].txChannel].ITCOUNT =
414  (frameLength << 16U) | 1U;
415 
416  /* Set Rx buffer address */
417  dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].rxChannel].IDADDR =
418  (uint32_t)pRxBuff;
419  /* Set number of Rx bytes to receive */
420  dmaRAMREG->PCP[(dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].rxChannel].ITCOUNT =
421  (frameLength << 16U) | 1U;
422 
423  /* Re-enable channels; because auto-init is disabled */
424  /* Disable otherwise transmission is constantly on going */
425  dmaSetChEnable(
426  (dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].txChannel, (dmaTriggerType_t)DMA_HW);
427  dmaSetChEnable(
428  (dmaChannel_t)dma_spiDmaChannels[SPI_GetSpiIndex(pSpiInterface->pNode)].rxChannel, (dmaTriggerType_t)DMA_HW);
429 
430  /* DMA config registers written, leave privilege mode */
432 
434 
435  /* Activate chip selects according to bitmask register CSNR */
436  for (uint8_t csNumber = 0u; csNumber < SPI_MAX_NUMBER_HW_CS; csNumber++) {
437  if (((pSpiInterface->pConfig->CSNR >> csNumber) & 0x1u) == 0u) {
438  /* Bitmask = 0 --> HW CS active --> set pin as SPI functional pin */
439  pSpiInterface->pNode->PC0 |= (uint32_t)1u << csNumber;
440  }
441  }
442 
443  /* DMA_REQ Enable */
444  /* Starts DMA requests if SPIEN is also set to 1 */
445  pSpiInterface->pNode->GCR1 |= SPIEN_BIT;
446  pSpiInterface->pNode->INT0 |= DMAREQEN_BIT;
447 
448  return retVal;
449 }
450 
451 extern void SPI_DmaSendLastByte(uint8_t spiIndex) {
453  dma_spiInterfaces[spiIndex]->DAT1 = spi_txLastWord[spiIndex];
454 }
455 
456 /* AXIVION Next Line Style Linker-Multiple_Definition: TI HAL only provides a weak implementation */
457 void UNIT_TEST_WEAK_IMPL spiNotification(spiBASE_t *spi, uint32 flags) {
458 }
459 
461  FAS_ASSERT(pNode != NULL_PTR);
462  const SpiDataStatus_t spiStatus = SpiTxStatus(pNode);
463  STD_RETURN_TYPE_e retval = STD_OK;
464  if (spiStatus == SPI_PENDING) {
465  retval = STD_NOT_OK;
466  }
467  return retval;
468 }
469 
470 extern uint8_t SPI_GetSpiIndex(spiBASE_t *pNode) {
471  FAS_ASSERT(pNode != NULL_PTR);
472  uint8_t spiIndex = 0u;
473 
474  if (pNode == spiREG1) {
475  spiIndex = SPI_SPI1_INDEX;
476  } else if (pNode == spiREG2) {
477  spiIndex = SPI_SPI2_INDEX;
478  } else if (pNode == spiREG3) {
479  spiIndex = SPI_SPI3_INDEX;
480  } else if (pNode == spiREG4) {
481  spiIndex = SPI_SPI4_INDEX;
482  } else if (pNode == spiREG5) {
483  spiIndex = SPI_SPI5_INDEX;
484  } else {
485  /** Invalid SPI node */
487  }
488 
489  return spiIndex;
490 }
491 
492 /*========== Externalized Static Function Implementations (Unit Test) =======*/
Headers for the driver for the DMA module.
spiBASE_t * dma_spiInterfaces[DMA_NUMBER_SPI_INTERFACES]
Definition: dma_cfg.c:87
DMA_CHANNEL_CONFIG_s dma_spiDmaChannels[DMA_NUMBER_SPI_INTERFACES]
Definition: dma_cfg.c:69
#define SPIEN_BIT
Definition: dma_cfg.h:111
#define DMA_NUMBER_SPI_INTERFACES
Definition: dma_cfg.h:107
#define DMAREQEN_BIT
Definition: dma_cfg.h:109
#define FAS_ASSERT(x)
Assertion macro that asserts that x is true.
Definition: fassert.h:241
#define FAS_TRAP
Define that evaluates to essential boolean false thus tripping an assert.
Definition: fassert.h:115
STD_RETURN_TYPE_e
Definition: fstd_types.h:81
@ STD_NOT_OK
Definition: fstd_types.h:83
@ STD_OK
Definition: fstd_types.h:82
#define NULL_PTR
Null pointer.
Definition: fstd_types.h:76
Function to switch between user mode and privilege mode.
#define FSYS_SwitchToUserMode()
Switch back to user mode.
Definition: fsystem.h:114
long FSYS_RaisePrivilege(void)
raise privilege
#define UNIT_TEST_WEAK_IMPL
Definition: general.h:97
void IO_PinSet(volatile uint32_t *pRegisterAddress, uint32_t pin)
Set pin by writing in pin output register.
Definition: io.c:87
void IO_PinReset(volatile uint32_t *pRegisterAddress, uint32_t pin)
Reset pin by writing in pin output register.
Definition: io.c:94
Header for the driver for the IO module.
void MCU_Delay_us(uint32_t delay_us)
Wait blocking a certain time in microseconds.
Definition: mcu.c:86
#define LARGEST_PIN_NUMBER
largest pin number that exists in TMS570LC4357
Definition: mcu.h:70
Declaration of the OS wrapper interface.
void OS_ExitTaskCritical(void)
Exit Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os_freertos.c:135
void OS_EnterTaskCritical(void)
Enter Critical interface function for use in FreeRTOS-Tasks and FreeRTOS-ISR.
Definition: os_freertos.c:131
STD_RETURN_TYPE_e SPI_TransmitReceiveDataDma(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength)
Transmits and receives data on SPI with DMA.
Definition: spi.c:216
void SPI_SetFunctional(spiBASE_t *pNode, enum spiPinSelect bit, bool hardwareControlled)
Sets the functional of a SPI pin.
Definition: spi.c:353
STD_RETURN_TYPE_e SPI_CheckInterfaceAvailable(spiBASE_t *pNode)
Returns STD_OK if the SPI interface can be used again.
Definition: spi.c:460
void SPI_DmaSendLastByte(uint8_t spiIndex)
Used to send last byte per SPI.
Definition: spi.c:451
STD_RETURN_TYPE_e SPI_TransmitDummyByte(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint32_t delay)
Sends a dummy byte to wake up the SPI interface.
Definition: spi.c:83
void SPI_FramTransmitReceiveData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint16 *pRxBuff, uint32 frameLength)
Transmits and receives data on SPI without DMA, wrappe for FRAM.
Definition: spi.c:203
STD_RETURN_TYPE_e SPI_Lock(uint8_t spi)
Locks SPI interfaces.
Definition: spi.c:326
STD_RETURN_TYPE_e SPI_SlaveSetReceiveDataDma(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16_t *pTxBuff, uint16_t *pRxBuff, uint32_t frameLength)
Transmits and receives data on SPI with DMA.
Definition: spi.c:387
void SPI_Unlock(uint8_t spi)
Unlocks SPI interfaces.
Definition: spi.c:343
STD_RETURN_TYPE_e SPI_TransmitData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint32 frameLength)
Transmits data on SPI without DMA.
Definition: spi.c:93
void UNIT_TEST_WEAK_IMPL spiNotification(spiBASE_t *spi, uint32 flags)
Definition: spi.c:457
STD_RETURN_TYPE_e SPI_TransmitReceiveData(SPI_INTERFACE_CONFIG_s *pSpiInterface, uint16 *pTxBuff, uint16 *pRxBuff, uint32 frameLength)
Transmits and receives data on SPI without DMA.
Definition: spi.c:145
uint8_t SPI_GetSpiIndex(spiBASE_t *pNode)
Returns index of SPI node.
Definition: spi.c:470
#define SPI_FLAG_REGISTER_TRANSMISSION_ERRORS
Definition: spi.c:71
static uint32_t spi_txLastWord[DMA_NUMBER_SPI_INTERFACES]
Definition: spi.c:67
Headers for the driver for the SPI module.
SPI_BUSY_STATE_e spi_busyFlags[]
Definition: spi_cfg.c:262
const uint8_t spi_nrBusyFlags
Definition: spi_cfg.c:271
#define SPI_SPI5_INDEX
Definition: spi_cfg.h:74
#define SPI_HARDWARE_CHIP_SELECT_FIELD_POSITION
Definition: spi_cfg.h:84
#define SPI_SPI2_INDEX
Definition: spi_cfg.h:71
@ SPI_IDLE
Definition: spi_cfg.h:126
@ SPI_BUSY
Definition: spi_cfg.h:127
#define SPI_DATA_FORMAT_FIELD_POSITION
Definition: spi_cfg.h:87
#define SPI_WDEL_BIT
Definition: spi_cfg.h:81
#define SPI_TX_EMPTY_TIMEOUT_ITERATIONS
Definition: spi_cfg.h:96
#define SPI_CSHOLD_BIT
Definition: spi_cfg.h:78
#define SPI_MAX_NUMBER_HW_CS
Definition: spi_cfg.h:99
#define SPI_SPI4_INDEX
Definition: spi_cfg.h:73
#define SPI_TX_BUFFER_EMPTY_FLAG_POSITION
Definition: spi_cfg.h:90
#define SPI_SPI1_INDEX
Definition: spi_cfg.h:70
#define SPI_PC0_CLEAR_HW_CS_MASK
Definition: spi_cfg.h:93
@ SPI_CHIP_SELECT_SOFTWARE
Definition: spi_cfg.h:134
@ SPI_CHIP_SELECT_HARDWARE
Definition: spi_cfg.h:133
#define SPI_SPI3_INDEX
Definition: spi_cfg.h:72
dmaChannel_t rxChannel
Definition: dma_cfg.h:128
dmaChannel_t txChannel
Definition: dma_cfg.h:127
SPI_CHIP_SELECT_TYPE_e csType
Definition: spi_cfg.h:145
volatile uint32_t * pGioPort
Definition: spi_cfg.h:143
spiDAT1_t * pConfig
Definition: spi_cfg.h:141
spiBASE_t * pNode
Definition: spi_cfg.h:142