S32 SDK
lpspi_shared_function.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
3  * Copyright 2016 NXP
4  * All rights reserved.
5  *
6  * THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
7  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
8  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
9  * IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
10  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
11  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
12  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
13  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
14  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
15  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
16  * THE POSSIBILITY OF SUCH DAMAGE.
17  */
18 
34 #ifndef LPSPI_SHARED_FUNCTION_H
35 #define LPSPI_SHARED_FUNCTION_H
36 
37 #include <stdbool.h>
38 #include "lpspi_hal.h"
39 #include "edma_driver.h"
40 #include "osif.h"
41 #include "status.h"
42 
49 /*******************************************************************************
50  * Definitions
51  ******************************************************************************/
52 
53 /* Extern for the LPSPI master driver's interrupt handler.*/
54 extern void LPSPI_DRV_MasterIRQHandler(uint32_t instance);
55 
56 /* Extern for the LPSPI slave driver's interrupt handler.*/
57 extern void LPSPI_DRV_SlaveIRQHandler(uint32_t instance);
58 
62 typedef enum
63 {
67 
68 typedef enum
69 {
74 
85 typedef struct
86 {
87  uint16_t bitsPerFrame;
89  uint16_t bytesPerFrame;
92  bool isBlocking;
93  uint32_t lpspiSrcClk;
94  volatile bool isTransferInProgress;
95  const uint8_t * txBuff;
96  uint8_t * rxBuff;
97  volatile uint16_t txCount;
98  volatile uint16_t rxCount;
99  volatile uint16_t txFrameCnt;
100  volatile uint16_t rxFrameCnt;
101  volatile bool lsb;
102  uint8_t fifoSize;
103  uint8_t rxDMAChannel;
104  uint8_t txDMAChannel;
106  semaphore_t lpspiSemaphore;
108 } lpspi_state_t;
109 
110 /*******************************************************************************
111  * Variables
112  ******************************************************************************/
115 
118 
119 /* Pointer to runtime state structure.*/
121 
122 /*******************************************************************************
123  * Prototypes
124  ******************************************************************************/
125 
136 void LPSPI_DRV_IRQHandler(uint32_t instance);
137 
142 void LPSPI_DRV_FillupTxBuffer(uint32_t instance);
143 
148 void LPSPI_DRV_ReadRXBuffer(uint32_t instance);
149 
154 void LPSPI_DRV_DisableTEIEInterrupts(uint32_t instance);
158 #endif /* __LPSPI_SHARED_FUNCTION_H__*/
159 /*******************************************************************************
160  * EOF
161  ******************************************************************************/
162 
volatile uint16_t rxFrameCnt
#define LPSPI_INSTANCE_COUNT
Definition: S32K144.h:6194
volatile uint16_t txFrameCnt
Runtime state structure for the LPSPI master driver.
void LPSPI_DRV_ReadRXBuffer(uint32_t instance)
The function LPSPI_DRV_ReadRXBuffer reads data from RX hardware buffer and writes this data in RX sof...
lpspi_transfer_type transferType
lpspi_state_t * g_lpspiStatePtr[LPSPI_INSTANCE_COUNT]
IRQn_Type
Defines the Interrupt Numbers definitions.
Definition: S32K144.h:269
void LPSPI_DRV_FillupTxBuffer(uint32_t instance)
The function LPSPI_DRV_FillupTxBuffer writes data in TX hardware buffer depending on driver state and...
volatile uint16_t rxCount
void LPSPI_DRV_MasterIRQHandler(uint32_t instance)
Interrupt handler for LPSPI master mode. This handler uses the buffers stored in the lpspi_master_sta...
volatile uint16_t txCount
void LPSPI_DRV_IRQHandler(uint32_t instance)
The function LPSPI_DRV_IRQHandler passes IRQ control to either the master or slave driver...
lpspi_transfer_type
Type of LPSPI transfer (based on interrupts or DMA). Implements : lpspi_transfer_type_Class.
IRQn_Type g_lpspiIrqId[LPSPI_INSTANCE_COUNT]
Table to save LPSPI IRQ enumeration numbers defined in the CMSIS header file.
void LPSPI_DRV_DisableTEIEInterrupts(uint32_t instance)
Disable the TEIE interrupts at the end of a transfer. Disable the interrupts and clear the status for...
volatile bool isTransferInProgress
LPSPI_Type * g_lpspiBase[LPSPI_INSTANCE_COUNT]
Table of base pointers for SPI instances.
const uint8_t * txBuff
void LPSPI_DRV_SlaveIRQHandler(uint32_t instance)
Interrupt handler for LPSPI slave mode. This handler uses the buffers stored in the lpspi_master_stat...
semaphore_t lpspiSemaphore
transfer_status_t
transfer_status_t status