fsl_lpspi.h
/*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _FSL_LPSPI_H_
#define _FSL_LPSPI_H_
#include "fsl_common.h"
/**********************************************************************************************************************
* Definitions
*********************************************************************************************************************/
#define FSL_LPSPI_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
#define LPSPI_MASTER_DUMMY_DATA (0x00U)
#define LPSPI_SLAVE_DUMMY_DATA (0x00U)
enum _lpspi_status
{
kStatus_LPSPI_Busy = MAKE_STATUS(kStatusGroup_LPSPI, 0),
kStatus_LPSPI_Error = MAKE_STATUS(kStatusGroup_LPSPI, 1),
kStatus_LPSPI_Idle = MAKE_STATUS(kStatusGroup_LPSPI, 2),
kStatus_LPSPI_OutOfRange = MAKE_STATUS(kStatusGroup_LPSPI, 3)
};
enum _lpspi_flags
{
kLPSPI_TxDataRequestFlag = LPSPI_SR_TDF_MASK,
kLPSPI_RxDataReadyFlag = LPSPI_SR_RDF_MASK,
kLPSPI_WordCompleteFlag = LPSPI_SR_WCF_MASK,
kLPSPI_FrameCompleteFlag = LPSPI_SR_FCF_MASK,
kLPSPI_TransferCompleteFlag = LPSPI_SR_TCF_MASK,
kLPSPI_TransmitErrorFlag = LPSPI_SR_TEF_MASK,
kLPSPI_ReceiveErrorFlag = LPSPI_SR_REF_MASK,
kLPSPI_DataMatchFlag = LPSPI_SR_DMF_MASK,
kLPSPI_ModuleBusyFlag = LPSPI_SR_MBF_MASK,
kLPSPI_AllStatusFlag = (LPSPI_SR_TDF_MASK | LPSPI_SR_RDF_MASK | LPSPI_SR_WCF_MASK | LPSPI_SR_FCF_MASK |
LPSPI_SR_TCF_MASK | LPSPI_SR_TEF_MASK | LPSPI_SR_REF_MASK | LPSPI_SR_DMF_MASK |
LPSPI_SR_MBF_MASK)
};
enum _lpspi_interrupt_enable
{
kLPSPI_TxInterruptEnable = LPSPI_IER_TDIE_MASK,
kLPSPI_RxInterruptEnable = LPSPI_IER_RDIE_MASK,
kLPSPI_WordCompleteInterruptEnable = LPSPI_IER_WCIE_MASK,
kLPSPI_FrameCompleteInterruptEnable = LPSPI_IER_FCIE_MASK,
kLPSPI_TransferCompleteInterruptEnable = LPSPI_IER_TCIE_MASK,
kLPSPI_TransmitErrorInterruptEnable = LPSPI_IER_TEIE_MASK,
kLPSPI_ReceiveErrorInterruptEnable = LPSPI_IER_REIE_MASK,
kLPSPI_DataMatchInterruptEnable = LPSPI_IER_DMIE_MASK,
kLPSPI_AllInterruptEnable =
(LPSPI_IER_TDIE_MASK | LPSPI_IER_RDIE_MASK | LPSPI_IER_WCIE_MASK | LPSPI_IER_FCIE_MASK | LPSPI_IER_TCIE_MASK |
LPSPI_IER_TEIE_MASK | LPSPI_IER_REIE_MASK | LPSPI_IER_DMIE_MASK)
};
enum _lpspi_dma_enable
{
kLPSPI_TxDmaEnable = LPSPI_DER_TDDE_MASK,
kLPSPI_RxDmaEnable = LPSPI_DER_RDDE_MASK
};
typedef enum _lpspi_master_slave_mode
{
kLPSPI_Master = 1U,
kLPSPI_Slave = 0U
} lpspi_master_slave_mode_t;
typedef enum _lpspi_which_pcs_config
{
kLPSPI_Pcs0 = 0U,
kLPSPI_Pcs1 = 1U,
kLPSPI_Pcs2 = 2U,
kLPSPI_Pcs3 = 3U
} lpspi_which_pcs_t;
typedef enum _lpspi_pcs_polarity_config
{
kLPSPI_PcsActiveHigh = 1U,
kLPSPI_PcsActiveLow = 0U
} lpspi_pcs_polarity_config_t;
enum _lpspi_pcs_polarity
{
kLPSPI_Pcs0ActiveLow = 1U << 0,
kLPSPI_Pcs1ActiveLow = 1U << 1,
kLPSPI_Pcs2ActiveLow = 1U << 2,
kLPSPI_Pcs3ActiveLow = 1U << 3,
kLPSPI_PcsAllActiveLow = 0xFU
};
typedef enum _lpspi_clock_polarity
{
kLPSPI_ClockPolarityActiveHigh = 0U,
kLPSPI_ClockPolarityActiveLow = 1U
} lpspi_clock_polarity_t;
typedef enum _lpspi_clock_phase
{
kLPSPI_ClockPhaseFirstEdge = 0U,
kLPSPI_ClockPhaseSecondEdge = 1U
} lpspi_clock_phase_t;
typedef enum _lpspi_shift_direction
{
kLPSPI_MsbFirst = 0U,
kLPSPI_LsbFirst = 1U
} lpspi_shift_direction_t;
typedef enum _lpspi_host_request_select
{
kLPSPI_HostReqExtPin = 0U,
kLPSPI_HostReqInternalTrigger = 1U
} lpspi_host_request_select_t;
typedef enum _lpspi_match_config
{
kLPSI_MatchDisabled = 0x0U,
kLPSI_1stWordEqualsM0orM1 = 0x2U,
kLPSI_AnyWordEqualsM0orM1 = 0x3U,
kLPSI_1stWordEqualsM0and2ndWordEqualsM1 = 0x4U,
kLPSI_AnyWordEqualsM0andNxtWordEqualsM1 = 0x5U,
kLPSI_1stWordAndM1EqualsM0andM1 = 0x6U,
kLPSI_AnyWordAndM1EqualsM0andM1 = 0x7U,
} lpspi_match_config_t;
typedef enum _lpspi_pin_config
{
kLPSPI_SdiInSdoOut = 0U,
kLPSPI_SdoInSdoOut = 1U,
kLPSPI_SdiInSdiOut = 2U,
kLPSPI_SdoInSdiOut = 3U
} lpspi_pin_config_t;
typedef enum _lpspi_data_out_config
{
kLpspiDataOutRetained = 0U,
kLpspiDataOutTristate = 1U
} lpspi_data_out_config_t;
typedef enum _lpspi_transfer_width
{
kLPSPI_SingleBitXfer = 0U,
kLPSPI_TwoBitXfer = 1U,
kLPSPI_FourBitXfer = 2U
} lpspi_transfer_width_t;
typedef enum _lpspi_delay_type
{
kLPSPI_PcsToSck = 1U,
kLPSPI_LastSckToPcs,
kLPSPI_BetweenTransfer
} lpspi_delay_type_t;
#define LPSPI_MASTER_PCS_SHIFT (4U)
#define LPSPI_MASTER_PCS_MASK (0xF0U)
enum _lpspi_transfer_config_flag_for_master
{
kLPSPI_MasterPcs0 = 0U << LPSPI_MASTER_PCS_SHIFT,
kLPSPI_MasterPcs1 = 1U << LPSPI_MASTER_PCS_SHIFT,
kLPSPI_MasterPcs2 = 2U << LPSPI_MASTER_PCS_SHIFT,
kLPSPI_MasterPcs3 = 3U << LPSPI_MASTER_PCS_SHIFT,
kLPSPI_MasterPcsContinuous = 1U << 20,
kLPSPI_MasterByteSwap = 1U << 22
};
#define LPSPI_SLAVE_PCS_SHIFT (4U)
#define LPSPI_SLAVE_PCS_MASK (0xF0U)
enum _lpspi_transfer_config_flag_for_slave
{
kLPSPI_SlavePcs0 = 0U << LPSPI_SLAVE_PCS_SHIFT,
kLPSPI_SlavePcs1 = 1U << LPSPI_SLAVE_PCS_SHIFT,
kLPSPI_SlavePcs2 = 2U << LPSPI_SLAVE_PCS_SHIFT,
kLPSPI_SlavePcs3 = 3U << LPSPI_SLAVE_PCS_SHIFT,
kLPSPI_SlaveByteSwap = 1U << 22
};
enum _lpspi_transfer_state
{
kLPSPI_Idle = 0x0U,
kLPSPI_Busy,
kLPSPI_Error
};
typedef struct _lpspi_master_config
{
uint32_t baudRate;
uint32_t bitsPerFrame;
lpspi_clock_polarity_t cpol;
lpspi_clock_phase_t cpha;
lpspi_shift_direction_t direction;
uint32_t pcsToSckDelayInNanoSec;
uint32_t lastSckToPcsDelayInNanoSec;
uint32_t betweenTransferDelayInNanoSec;
lpspi_which_pcs_t whichPcs;
lpspi_pcs_polarity_config_t pcsActiveHighOrLow;
lpspi_pin_config_t pinCfg;
lpspi_data_out_config_t dataOutConfig;
} lpspi_master_config_t;
typedef struct _lpspi_slave_config
{
uint32_t bitsPerFrame;
lpspi_clock_polarity_t cpol;
lpspi_clock_phase_t cpha;
lpspi_shift_direction_t direction;
lpspi_which_pcs_t whichPcs;
lpspi_pcs_polarity_config_t pcsActiveHighOrLow;
lpspi_pin_config_t pinCfg;
lpspi_data_out_config_t dataOutConfig;
} lpspi_slave_config_t;
typedef struct _lpspi_master_handle lpspi_master_handle_t;
typedef struct _lpspi_slave_handle lpspi_slave_handle_t;
typedef void (*lpspi_master_transfer_callback_t)(LPSPI_Type *base,
lpspi_master_handle_t *handle,
status_t status,
void *userData);
typedef void (*lpspi_slave_transfer_callback_t)(LPSPI_Type *base,
lpspi_slave_handle_t *handle,
status_t status,
void *userData);
typedef struct _lpspi_transfer
{
uint8_t *txData;
uint8_t *rxData;
volatile size_t dataSize;
uint32_t configFlags;
} lpspi_transfer_t;
struct _lpspi_master_handle
{
LPSPI_Type *base;
volatile bool isPcsContinuous;
volatile bool writeTcrInIsr;
volatile bool isByteSwap;
volatile uint8_t fifoSize;
volatile uint8_t rxWatermark;
volatile uint8_t bytesEachWrite;
volatile uint8_t bytesEachRead;
uint8_t *volatile txData;
uint8_t *volatile rxData;
volatile size_t txRemainingByteCount;
volatile size_t rxRemainingByteCount;
volatile uint32_t writeRegRemainingTimes;
volatile uint32_t readRegRemainingTimes;
uint32_t totalByteCount;
uint32_t txBuffIfNull;
volatile uint8_t state;
lpspi_master_transfer_callback_t callback;
void *userData;
};
struct _lpspi_slave_handle
{
LPSPI_Type *base;
volatile bool isByteSwap;
volatile uint8_t fifoSize;
volatile uint8_t rxWatermark;
volatile uint8_t bytesEachWrite;
volatile uint8_t bytesEachRead;
uint8_t *volatile txData;
uint8_t *volatile rxData;
volatile size_t txRemainingByteCount;
volatile size_t rxRemainingByteCount;
volatile uint32_t writeRegRemainingTimes;
volatile uint32_t readRegRemainingTimes;
uint32_t totalByteCount;
volatile uint8_t state;
volatile uint32_t errorCount;
lpspi_slave_transfer_callback_t callback;
void *userData;
};
/**********************************************************************************************************************
* API
*********************************************************************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif /*_cplusplus*/
void LPSPI_MasterInit(LPSPI_Type *base, const lpspi_master_config_t *masterConfig, uint32_t srcClock_Hz);
void LPSPI_MasterGetDefaultConfig(lpspi_master_config_t *masterConfig);
void LPSPI_SlaveInit(LPSPI_Type *base, const lpspi_slave_config_t *slaveConfig);
void LPSPI_SlaveGetDefaultConfig(lpspi_slave_config_t *slaveConfig);
void LPSPI_Deinit(LPSPI_Type *base);
void LPSPI_Reset(LPSPI_Type *base);
static inline void LPSPI_Enable(LPSPI_Type *base, bool enable)
{
if (enable)
{
base->CR |= LPSPI_CR_MEN_MASK;
}
else
{
base->CR &= ~LPSPI_CR_MEN_MASK;
}
}
static inline uint32_t LPSPI_GetStatusFlags(LPSPI_Type *base)
{
return (base->SR);
}
static inline uint32_t LPSPI_GetTxFifoSize(LPSPI_Type *base)
{
return (1U << ((base->PARAM & LPSPI_PARAM_TXFIFO_MASK) >> LPSPI_PARAM_TXFIFO_SHIFT));
}
static inline uint32_t LPSPI_GetRxFifoSize(LPSPI_Type *base)
{
return (1U << ((base->PARAM & LPSPI_PARAM_RXFIFO_MASK) >> LPSPI_PARAM_RXFIFO_SHIFT));
}
static inline uint32_t LPSPI_GetTxFifoCount(LPSPI_Type *base)
{
return ((base->FSR & LPSPI_FSR_TXCOUNT_MASK) >> LPSPI_FSR_TXCOUNT_SHIFT);
}
static inline uint32_t LPSPI_GetRxFifoCount(LPSPI_Type *base)
{
return ((base->FSR & LPSPI_FSR_RXCOUNT_MASK) >> LPSPI_FSR_RXCOUNT_SHIFT);
}
static inline void LPSPI_ClearStatusFlags(LPSPI_Type *base, uint32_t statusFlags)
{
base->SR = statusFlags;
}
static inline void LPSPI_EnableInterrupts(LPSPI_Type *base, uint32_t mask)
{
base->IER |= mask;
}
static inline void LPSPI_DisableInterrupts(LPSPI_Type *base, uint32_t mask)
{
base->IER &= ~mask;
}
static inline void LPSPI_EnableDMA(LPSPI_Type *base, uint32_t mask)
{
base->DER |= mask;
}
static inline void LPSPI_DisableDMA(LPSPI_Type *base, uint32_t mask)
{
base->DER &= ~mask;
}
static inline uint32_t LPSPI_GetTxRegisterAddress(LPSPI_Type *base)
{
return (uint32_t) & (base->TDR);
}
static inline uint32_t LPSPI_GetRxRegisterAddress(LPSPI_Type *base)
{
return (uint32_t) & (base->RDR);
}
static inline void LPSPI_SetMasterSlaveMode(LPSPI_Type *base, lpspi_master_slave_mode_t mode)
{
base->CFGR1 = (base->CFGR1 & (~LPSPI_CFGR1_MASTER_MASK)) | LPSPI_CFGR1_MASTER(mode);
}
static inline bool LPSPI_IsMaster(LPSPI_Type *base)
{
return (bool)((base->CFGR1) & LPSPI_CFGR1_MASTER_MASK);
}
static inline void LPSPI_FlushFifo(LPSPI_Type *base, bool flushTxFifo, bool flushRxFifo)
{
base->CR |= ((uint32_t)flushTxFifo << LPSPI_CR_RTF_SHIFT) | ((uint32_t)flushRxFifo << LPSPI_CR_RRF_SHIFT);
}
static inline void LPSPI_SetFifoWatermarks(LPSPI_Type *base, uint32_t txWater, uint32_t rxWater)
{
base->FCR = LPSPI_FCR_TXWATER(txWater) | LPSPI_FCR_RXWATER(rxWater);
}
static inline void LPSPI_SetAllPcsPolarity(LPSPI_Type *base, uint32_t mask)
{
base->CFGR1 = (base->CFGR1 & ~LPSPI_CFGR1_PCSPOL_MASK) | LPSPI_CFGR1_PCSPOL(~mask);
}
static inline void LPSPI_SetFrameSize(LPSPI_Type *base, uint32_t frameSize)
{
base->TCR = (base->TCR & ~LPSPI_TCR_FRAMESZ_MASK) | LPSPI_TCR_FRAMESZ(frameSize - 1);
}
uint32_t LPSPI_MasterSetBaudRate(LPSPI_Type *base,
uint32_t baudRate_Bps,
uint32_t srcClock_Hz,
uint32_t *tcrPrescaleValue);
void LPSPI_MasterSetDelayScaler(LPSPI_Type *base, uint32_t scaler, lpspi_delay_type_t whichDelay);
uint32_t LPSPI_MasterSetDelayTimes(LPSPI_Type *base,
uint32_t delayTimeInNanoSec,
lpspi_delay_type_t whichDelay,
uint32_t srcClock_Hz);
static inline void LPSPI_WriteDataNonBlocking(LPSPI_Type *base, uint32_t data)
{
base->TDR = data;
}
static inline uint32_t LPSPI_ReadDataNonBlocking(LPSPI_Type *base)
{
return (base->RDR);
}
status_t LPSPI_MasterTransferBlocking(LPSPI_Type *base, lpspi_transfer_t *transfer);
/*Transactional APIs*/
void LPSPI_MasterCreateHandle(LPSPI_Type *base,
lpspi_master_handle_t *handle,
lpspi_master_transfer_callback_t callback,
void *userData);
status_t LPSPI_MasterTransferNonBlocking(LPSPI_Type *base, lpspi_master_handle_t *handle, lpspi_transfer_t *transfer);
status_t LPSPI_MasterGetTransferCount(LPSPI_Type *base, lpspi_master_handle_t *handle, size_t *count);
void LPSPI_MasterAbortTransfer(LPSPI_Type *base, lpspi_master_handle_t *handle);
void LPSPI_MasterHandleInterrupt(LPSPI_Type *base, lpspi_master_handle_t *handle);
void LPSPI_SlaveCreateHandle(LPSPI_Type *base,
lpspi_slave_handle_t *handle,
lpspi_slave_transfer_callback_t callback,
void *userData);
status_t LPSPI_SlaveTransferNonBlocking(LPSPI_Type *base, lpspi_slave_handle_t *handle, lpspi_transfer_t *transfer);
status_t LPSPI_SlaveGetTransferCount(LPSPI_Type *base, lpspi_slave_handle_t *handle, size_t *count);
void LPSPI_SlaveAbortTransfer(LPSPI_Type *base, lpspi_slave_handle_t *handle);
void LPSPI_SlaveHandleInterrupt(LPSPI_Type *base, lpspi_slave_handle_t *handle);
#if defined(__cplusplus)
}
#endif /*_cplusplus*/
#endif /*_FSL_LPSPI_H_*/
kLPSI_1stWordAndM1EqualsM0andM1
Definition: fsl_lpspi.h:171
LPSPI_MasterSetDelayTimes
uint32_t LPSPI_MasterSetDelayTimes(LPSPI_Type *base, uint32_t delayTimeInNanoSec, lpspi_delay_type_t whichDelay, uint32_t srcClock_Hz)
Calculates the delay based on the desired delay input in nanoseconds (module must be disabled to chan...
Definition: fsl_lpspi.c:391
kLPSPI_AllInterruptEnable
Definition: fsl_lpspi.h:88
LPSPI_MasterTransferBlocking
status_t LPSPI_MasterTransferBlocking(LPSPI_Type *base, lpspi_transfer_t *transfer)
LPSPI master transfer data using polling.
Definition: fsl_lpspi.c:493
kLPSPI_TransmitErrorInterruptEnable
Definition: fsl_lpspi.h:85
lpspi_transfer_t::dataSize
volatile size_t dataSize
Definition: fsl_lpspi.h:347
kStatus_LPSPI_OutOfRange
Definition: fsl_lpspi.h:57
kLPSI_AnyWordAndM1EqualsM0andM1
Definition: fsl_lpspi.h:172
kLPSPI_SdiInSdiOut
Definition: fsl_lpspi.h:180
lpspi_delay_type_t
lpspi_delay_type_t
LPSPI delay type selection.
Definition: fsl_lpspi.h:200
lpspi_clock_polarity_t
lpspi_clock_polarity_t
LPSPI clock polarity configuration.
Definition: fsl_lpspi.h:134
kLPSPI_FourBitXfer
Definition: fsl_lpspi.h:196
lpspi_transfer_width_t
lpspi_transfer_width_t
LPSPI transfer width configuration.
Definition: fsl_lpspi.h:192
kLPSPI_Pcs3ActiveLow
Definition: fsl_lpspi.h:129
kLPSPI_Pcs0ActiveLow
Definition: fsl_lpspi.h:126
_lpspi_slave_handle::errorCount
volatile uint32_t errorCount
Definition: fsl_lpspi.h:416
LPSPI_SlaveTransferNonBlocking
status_t LPSPI_SlaveTransferNonBlocking(LPSPI_Type *base, lpspi_slave_handle_t *handle, lpspi_transfer_t *transfer)
LPSPI slave transfer data using interrupt.
Definition: fsl_lpspi.c:1088
LPSPI_EnableDMA
static void LPSPI_EnableDMA(LPSPI_Type *base, uint32_t mask)
Enable the LPSPI DMA request.
Definition: fsl_lpspi.h:652
_lpspi_master_handle::rxData
uint8_t *volatile rxData
Definition: fsl_lpspi.h:372
lpspi_master_config_t::pcsActiveHighOrLow
lpspi_pcs_polarity_config_t pcsActiveHighOrLow
Definition: fsl_lpspi.h:278
kLPSPI_FrameCompleteInterruptEnable
Definition: fsl_lpspi.h:83
lpspi_transfer_t::txData
uint8_t * txData
Definition: fsl_lpspi.h:345
kLPSPI_TwoBitXfer
Definition: fsl_lpspi.h:195
LPSPI_Reset
void LPSPI_Reset(LPSPI_Type *base)
Restores the LPSPI peripheral to reset state, notice that this function will set all the registers to...
Definition: fsl_lpspi.c:264
_lpspi_master_handle::totalByteCount
uint32_t totalByteCount
Definition: fsl_lpspi.h:379
kLPSPI_HostReqExtPin
Definition: fsl_lpspi.h:159
LPSPI_SlaveHandleInterrupt
void LPSPI_SlaveHandleInterrupt(LPSPI_Type *base, lpspi_slave_handle_t *handle)
LPSPI Slave IRQ handler function.
Definition: fsl_lpspi.c:1360
lpspi_master_config_t::cpol
lpspi_clock_polarity_t cpol
Definition: fsl_lpspi.h:266
kLPSPI_MsbFirst
Definition: fsl_lpspi.h:152
kLPSPI_TxDataRequestFlag
Definition: fsl_lpspi.h:63
lpspi_master_config_t::lastSckToPcsDelayInNanoSec
uint32_t lastSckToPcsDelayInNanoSec
Definition: fsl_lpspi.h:272
kLPSPI_Master
Definition: fsl_lpspi.h:103
kLPSPI_SdoInSdiOut
Definition: fsl_lpspi.h:181
kLPSPI_TxInterruptEnable
Definition: fsl_lpspi.h:80
kLPSPI_Pcs1
Definition: fsl_lpspi.h:111
lpspi_master_config_t::direction
lpspi_shift_direction_t direction
Definition: fsl_lpspi.h:268
kLPSPI_Pcs2ActiveLow
Definition: fsl_lpspi.h:128
kLPSPI_ClockPolarityActiveLow
Definition: fsl_lpspi.h:137
lpspi_host_request_select_t
lpspi_host_request_select_t
LPSPI Host Request select configuration.
Definition: fsl_lpspi.h:157
LPSPI_SetFrameSize
static void LPSPI_SetFrameSize(LPSPI_Type *base, uint32_t frameSize)
Configures the frame size .
Definition: fsl_lpspi.h:801
_lpspi_transfer_state
_lpspi_transfer_state
LPSPI transfer state, which is used for LPSPI transactiaonl APIs&#39; state machine.
Definition: fsl_lpspi.h:254
lpspi_master_config_t::baudRate
uint32_t baudRate
Definition: fsl_lpspi.h:264
lpspi_slave_config_t
LPSPI slave config structure.
Definition: fsl_lpspi.h:289
LPSPI_ReadDataNonBlocking
static uint32_t LPSPI_ReadDataNonBlocking(LPSPI_Type *base)
Reads data from the data buffer.
Definition: fsl_lpspi.h:917
kLPSPI_SlavePcs2
Definition: fsl_lpspi.h:239
kLPSPI_Pcs0
Definition: fsl_lpspi.h:110
LPSPI_MasterAbortTransfer
void LPSPI_MasterAbortTransfer(LPSPI_Type *base, lpspi_master_handle_t *handle)
LPSPI master abort transfer which using interrupt.
Definition: fsl_lpspi.c:965
LPSPI_MasterSetDelayScaler
void LPSPI_MasterSetDelayScaler(LPSPI_Type *base, uint32_t scaler, lpspi_delay_type_t whichDelay)
Manually configures a specific LPSPI delay parameter (module must be disabled to change the delay val...
Definition: fsl_lpspi.c:369
lpspi_master_config_t::betweenTransferDelayInNanoSec
uint32_t betweenTransferDelayInNanoSec
Definition: fsl_lpspi.h:274
lpspi_master_config_t
LPSPI master config structure.
Definition: fsl_lpspi.h:262
kLPSPI_SlavePcs0
Definition: fsl_lpspi.h:237
kLPSPI_Idle
Definition: fsl_lpspi.h:256
kLPSPI_Pcs3
Definition: fsl_lpspi.h:113
_lpspi_master_handle::callback
lpspi_master_transfer_callback_t callback
Definition: fsl_lpspi.h:385
kLPSPI_MasterPcsContinuous
Definition: fsl_lpspi.h:218
kLPSPI_ClockPolarityActiveHigh
Definition: fsl_lpspi.h:136
_lpspi_master_handle::rxRemainingByteCount
volatile size_t rxRemainingByteCount
Definition: fsl_lpspi.h:374
kLPSPI_Busy
Definition: fsl_lpspi.h:257
LPSPI_FlushFifo
static void LPSPI_FlushFifo(LPSPI_Type *base, bool flushTxFifo, bool flushRxFifo)
Flushes the LPSPI FIFOs.
Definition: fsl_lpspi.h:743
LPSPI_IsMaster
static bool LPSPI_IsMaster(LPSPI_Type *base)
Returns whether the LPSPI module is in master mode.
Definition: fsl_lpspi.h:731
_lpspi_master_handle::bytesEachRead
volatile uint8_t bytesEachRead
Definition: fsl_lpspi.h:369
LPSPI_SlaveCreateHandle
void LPSPI_SlaveCreateHandle(LPSPI_Type *base, lpspi_slave_handle_t *handle, lpspi_slave_transfer_callback_t callback, void *userData)
Initialize the lpspi slave handle.
Definition: fsl_lpspi.c:1069
_lpspi_master_handle::writeRegRemainingTimes
volatile uint32_t writeRegRemainingTimes
Definition: fsl_lpspi.h:376
_lpspi_master_handle::bytesEachWrite
volatile uint8_t bytesEachWrite
Definition: fsl_lpspi.h:368
_lpspi_master_handle::txBuffIfNull
uint32_t txBuffIfNull
Definition: fsl_lpspi.h:381
LPSPI_SlaveInit
void LPSPI_SlaveInit(LPSPI_Type *base, const lpspi_slave_config_t *slaveConfig)
LPSPI slave configuration.
Definition: fsl_lpspi.c:227
lpspi_pcs_polarity_config_t
lpspi_pcs_polarity_config_t
LPSPI Peripheral Chip Select (Pcs) Polarity configuration.
Definition: fsl_lpspi.h:117
kLPSPI_Slave
Definition: fsl_lpspi.h:104
_lpspi_flags
_lpspi_flags
LPSPI status flags in SPIx_SR register.
Definition: fsl_lpspi.h:61
kLPSPI_AllStatusFlag
Definition: fsl_lpspi.h:72
LPSPI_MasterCreateHandle
void LPSPI_MasterCreateHandle(LPSPI_Type *base, lpspi_master_handle_t *handle, lpspi_master_transfer_callback_t callback, void *userData)
Initialize the lpspi master handle.
Definition: fsl_lpspi.c:673
kLPSPI_ClockPhaseFirstEdge
Definition: fsl_lpspi.h:143
kLPSI_1stWordEqualsM0orM1
Definition: fsl_lpspi.h:167
kLPSPI_TxDmaEnable
Definition: fsl_lpspi.h:96
_lpspi_pcs_polarity
_lpspi_pcs_polarity
LPSPI Peripheral Chip Select (Pcs) Polarity.
Definition: fsl_lpspi.h:124
LPSPI_ClearStatusFlags
static void LPSPI_ClearStatusFlags(LPSPI_Type *base, uint32_t statusFlags)
Clears the LPSPI status flag.
Definition: fsl_lpspi.h:585
kLPSPI_RxInterruptEnable
Definition: fsl_lpspi.h:81
kLPSPI_RxDmaEnable
Definition: fsl_lpspi.h:97
kStatus_LPSPI_Busy
Definition: fsl_lpspi.h:54
LPSPI_GetTxRegisterAddress
static uint32_t LPSPI_GetTxRegisterAddress(LPSPI_Type *base)
Gets the LPSPI Transmit Data Register address for DMA operation.
Definition: fsl_lpspi.h:683
_lpspi_master_handle::writeTcrInIsr
volatile bool writeTcrInIsr
Definition: fsl_lpspi.h:360
lpspi_transfer_t::configFlags
uint32_t configFlags
Definition: fsl_lpspi.h:349
kLPSPI_RxDataReadyFlag
Definition: fsl_lpspi.h:64
kLPSPI_DataMatchFlag
Definition: fsl_lpspi.h:70
lpspi_shift_direction_t
lpspi_shift_direction_t
LPSPI data shifter direction options.
Definition: fsl_lpspi.h:150
LPSPI_MasterTransferNonBlocking
status_t LPSPI_MasterTransferNonBlocking(LPSPI_Type *base, lpspi_master_handle_t *handle, lpspi_transfer_t *transfer)
LPSPI master transfer data using interrupt.
Definition: fsl_lpspi.c:692
_lpspi_interrupt_enable
_lpspi_interrupt_enable
LPSPI interrupt source.
Definition: fsl_lpspi.h:78
kLPSPI_PcsAllActiveLow
Definition: fsl_lpspi.h:130
kLPSPI_SingleBitXfer
Definition: fsl_lpspi.h:194
kLPSPI_HostReqInternalTrigger
Definition: fsl_lpspi.h:160
lpspi_master_transfer_callback_t
void(* lpspi_master_transfer_callback_t)(LPSPI_Type *base, lpspi_master_handle_t *handle, status_t status, void *userData)
Master completion callback function pointer type.
Definition: fsl_lpspi.h:324
lpspi_master_slave_mode_t
lpspi_master_slave_mode_t
LPSPI master or slave mode configuration.
Definition: fsl_lpspi.h:101
kLPSPI_MasterPcs1
Definition: fsl_lpspi.h:214
lpspi_which_pcs_t
lpspi_which_pcs_t
LPSPI Peripheral Chip Select (Pcs) configuration (which Pcs to configure).
Definition: fsl_lpspi.h:108
LPSPI_DisableInterrupts
static void LPSPI_DisableInterrupts(LPSPI_Type *base, uint32_t mask)
Disable the LPSPI interrupts.
Definition: fsl_lpspi.h:627
lpspi_transfer_t::rxData
uint8_t * rxData
Definition: fsl_lpspi.h:346
kLPSI_MatchDisabled
Definition: fsl_lpspi.h:166
lpspi_master_config_t::bitsPerFrame
uint32_t bitsPerFrame
Definition: fsl_lpspi.h:265
kLPSPI_TransmitErrorFlag
Definition: fsl_lpspi.h:68
lpspi_transfer_t
LPSPI master/slave transfer structure.
Definition: fsl_lpspi.h:343
lpspi_master_config_t::pcsToSckDelayInNanoSec
uint32_t pcsToSckDelayInNanoSec
Definition: fsl_lpspi.h:270
kLPSPI_SlavePcs3
Definition: fsl_lpspi.h:240
LPSPI_MasterSetBaudRate
uint32_t LPSPI_MasterSetBaudRate(LPSPI_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz, uint32_t *tcrPrescaleValue)
Sets the LPSPI baud rate in bits per second.
Definition: fsl_lpspi.c:297
LPSPI_MasterGetTransferCount
status_t LPSPI_MasterGetTransferCount(LPSPI_Type *base, lpspi_master_handle_t *handle, size_t *count)
Get the master transfer remaining bytes.
Definition: fsl_lpspi.c:933
lpspi_data_out_config_t
lpspi_data_out_config_t
LPSPI data output configuration.
Definition: fsl_lpspi.h:185
_lpspi_master_handle::txData
uint8_t *volatile txData
Definition: fsl_lpspi.h:371
LPSPI_WriteDataNonBlocking
static void LPSPI_WriteDataNonBlocking(LPSPI_Type *base, uint32_t data)
Writes data into the transmit data buffer.
Definition: fsl_lpspi.h:903
lpspi_clock_phase_t
lpspi_clock_phase_t
LPSPI clock phase configuration.
Definition: fsl_lpspi.h:141
kLPSI_AnyWordEqualsM0andNxtWordEqualsM1
Definition: fsl_lpspi.h:170
kLPSPI_LastSckToPcs
Definition: fsl_lpspi.h:203
kLPSPI_Error
Definition: fsl_lpspi.h:258
kLPSPI_TransferCompleteFlag
Definition: fsl_lpspi.h:67
LPSPI_GetTxFifoSize
static uint32_t LPSPI_GetTxFifoSize(LPSPI_Type *base)
Gets the LPSPI Tx FIFO size.
Definition: fsl_lpspi.h:537
kLPSPI_SlavePcs1
Definition: fsl_lpspi.h:238
LPSPI_GetStatusFlags
static uint32_t LPSPI_GetStatusFlags(LPSPI_Type *base)
Gets the LPSPI status flag state.
Definition: fsl_lpspi.h:527
kLPSPI_TransferCompleteInterruptEnable
Definition: fsl_lpspi.h:84
kLPSPI_ClockPhaseSecondEdge
Definition: fsl_lpspi.h:145
kLPSPI_BetweenTransfer
Definition: fsl_lpspi.h:204
kLPSPI_LsbFirst
Definition: fsl_lpspi.h:153
kLPSPI_ReceiveErrorInterruptEnable
Definition: fsl_lpspi.h:86
LPSPI_MasterInit
void LPSPI_MasterInit(LPSPI_Type *base, const lpspi_master_config_t *masterConfig, uint32_t srcClock_Hz)
LPSPI master Init.
Definition: fsl_lpspi.c:169
kStatus_LPSPI_Error
Definition: fsl_lpspi.h:55
kLPSPI_ModuleBusyFlag
Definition: fsl_lpspi.h:71
LPSPI_MasterGetDefaultConfig
void LPSPI_MasterGetDefaultConfig(lpspi_master_config_t *masterConfig)
Set the lpspi_master_config_t structure to default values.
Definition: fsl_lpspi.c:208
kLPSPI_Pcs2
Definition: fsl_lpspi.h:112
kLPSPI_WordCompleteInterruptEnable
Definition: fsl_lpspi.h:82
LPSPI_SlaveAbortTransfer
void LPSPI_SlaveAbortTransfer(LPSPI_Type *base, lpspi_slave_handle_t *handle)
LPSPI slave abort transfer which using interrupt.
Definition: fsl_lpspi.c:1350
LPSPI_GetRxFifoCount
static uint32_t LPSPI_GetRxFifoCount(LPSPI_Type *base)
Gets the LPSPI Rx FIFO count.
Definition: fsl_lpspi.h:567
kLPSPI_MasterByteSwap
Definition: fsl_lpspi.h:220
lpspi_match_config_t
lpspi_match_config_t
LPSPI Match configuration options.
Definition: fsl_lpspi.h:164
LPSPI_MasterHandleInterrupt
void LPSPI_MasterHandleInterrupt(LPSPI_Type *base, lpspi_master_handle_t *handle)
LPSPI Master IRQ handler function.
Definition: fsl_lpspi.c:973
kLPSI_1stWordEqualsM0and2ndWordEqualsM1
Definition: fsl_lpspi.h:169
kLPSPI_MasterPcs3
Definition: fsl_lpspi.h:216
_lpspi_master_handle
LPSPI master transfer handle structure used for transactional API.
Definition: fsl_lpspi.h:355
lpspi_pin_config_t
lpspi_pin_config_t
LPSPI pin (SDO and SDI) configuration.
Definition: fsl_lpspi.h:176
lpspi_master_config_t::whichPcs
lpspi_which_pcs_t whichPcs
Definition: fsl_lpspi.h:277
LPSPI_GetTxFifoCount
static uint32_t LPSPI_GetTxFifoCount(LPSPI_Type *base)
Gets the LPSPI Tx FIFO count.
Definition: fsl_lpspi.h:557
kLPSPI_MasterPcs2
Definition: fsl_lpspi.h:215
_lpspi_master_handle::isByteSwap
volatile bool isByteSwap
Definition: fsl_lpspi.h:362
LPSPI_EnableInterrupts
static void LPSPI_EnableInterrupts(LPSPI_Type *base, uint32_t mask)
Enable the LPSPI interrupts.
Definition: fsl_lpspi.h:612
LPSPI_DisableDMA
static void LPSPI_DisableDMA(LPSPI_Type *base, uint32_t mask)
Disable the LPSPI DMA request.
Definition: fsl_lpspi.h:668
kLPSPI_WordCompleteFlag
Definition: fsl_lpspi.h:65
_lpspi_master_handle::txRemainingByteCount
volatile size_t txRemainingByteCount
Definition: fsl_lpspi.h:373
LPSPI_SetFifoWatermarks
static void LPSPI_SetFifoWatermarks(LPSPI_Type *base, uint32_t txWater, uint32_t rxWater)
Sets the transmit and receive FIFO watermark values.
Definition: fsl_lpspi.h:759
lpspi_master_config_t::pinCfg
lpspi_pin_config_t pinCfg
Definition: fsl_lpspi.h:280
kLpspiDataOutTristate
Definition: fsl_lpspi.h:188
LPSPI_SlaveGetDefaultConfig
void LPSPI_SlaveGetDefaultConfig(lpspi_slave_config_t *slaveConfig)
Set the lpspi_slave_config_t structure to default values.
Definition: fsl_lpspi.c:250
_lpspi_master_handle::state
volatile uint8_t state
Definition: fsl_lpspi.h:383
kLPSI_AnyWordEqualsM0orM1
Definition: fsl_lpspi.h:168
kLPSPI_ReceiveErrorFlag
Definition: fsl_lpspi.h:69
_lpspi_slave_handle::base
LPSPI_Type * base
Definition: fsl_lpspi.h:392
_lpspi_slave_handle
LPSPI slave transfer handle structure used for transactional API.
Definition: fsl_lpspi.h:390
_lpspi_master_handle::readRegRemainingTimes
volatile uint32_t readRegRemainingTimes
Definition: fsl_lpspi.h:377
LPSPI_GetRxFifoSize
static uint32_t LPSPI_GetRxFifoSize(LPSPI_Type *base)
Gets the LPSPI Rx FIFO size.
Definition: fsl_lpspi.h:547
LPSPI_SlaveGetTransferCount
status_t LPSPI_SlaveGetTransferCount(LPSPI_Type *base, lpspi_slave_handle_t *handle, size_t *count)
Get the slave transfer remaining bytes.
Definition: fsl_lpspi.c:1318
kStatus_LPSPI_Idle
Definition: fsl_lpspi.h:56
kLPSPI_SdiInSdoOut
Definition: fsl_lpspi.h:178
_lpspi_master_handle::rxWatermark
volatile uint8_t rxWatermark
Definition: fsl_lpspi.h:366
LPSPI_Enable
static void LPSPI_Enable(LPSPI_Type *base, bool enable)
Enables the LPSPI peripheral and sets the MCR MDIS to 0.
Definition: fsl_lpspi.h:501
_lpspi_slave_handle::callback
lpspi_slave_transfer_callback_t callback
Definition: fsl_lpspi.h:418
_lpspi_slave_handle::userData
void * userData
Definition: fsl_lpspi.h:419
kLPSPI_PcsActiveHigh
Definition: fsl_lpspi.h:119
lpspi_master_config_t::dataOutConfig
lpspi_data_out_config_t dataOutConfig
Definition: fsl_lpspi.h:283
lpspi_slave_transfer_callback_t
void(* lpspi_slave_transfer_callback_t)(LPSPI_Type *base, lpspi_slave_handle_t *handle, status_t status, void *userData)
Slave completion callback function pointer type.
Definition: fsl_lpspi.h:337
LPSPI_GetRxRegisterAddress
static uint32_t LPSPI_GetRxRegisterAddress(LPSPI_Type *base)
Gets the LPSPI Receive Data Register address for DMA operation.
Definition: fsl_lpspi.h:698
_lpspi_master_handle::isPcsContinuous
volatile bool isPcsContinuous
Definition: fsl_lpspi.h:359
kLPSPI_SdoInSdoOut
Definition: fsl_lpspi.h:179
_lpspi_dma_enable
_lpspi_dma_enable
LPSPI DMA source.
Definition: fsl_lpspi.h:94
kLpspiDataOutRetained
Definition: fsl_lpspi.h:187
status_t
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:121
LPSPI_Deinit
void LPSPI_Deinit(LPSPI_Type *base)
De-initialize the LPSPI peripheral, call this API to disbale the lpspi clock.
Definition: fsl_lpspi.c:276
kLPSPI_MasterPcs0
Definition: fsl_lpspi.h:213
kLPSPI_Pcs1ActiveLow
Definition: fsl_lpspi.h:127
_lpspi_master_handle::fifoSize
volatile uint8_t fifoSize
Definition: fsl_lpspi.h:364
LPSPI_SetMasterSlaveMode
static void LPSPI_SetMasterSlaveMode(LPSPI_Type *base, lpspi_master_slave_mode_t mode)
Configures the LPSPI for master or slave.
Definition: fsl_lpspi.h:720
kStatusGroup_LPSPI
Definition: fsl_common.h:69
kLPSPI_FrameCompleteFlag
Definition: fsl_lpspi.h:66
kLPSPI_PcsActiveLow
Definition: fsl_lpspi.h:120
kLPSPI_PcsToSck
Definition: fsl_lpspi.h:202
kLPSPI_SlaveByteSwap
Definition: fsl_lpspi.h:242
LPSPI_SetAllPcsPolarity
static void LPSPI_SetAllPcsPolarity(LPSPI_Type *base, uint32_t mask)
Configures all the LPSPI peripheral chip select polarity simultaneously.
Definition: fsl_lpspi.h:778
lpspi_master_config_t::cpha
lpspi_clock_phase_t cpha
Definition: fsl_lpspi.h:267
kLPSPI_DataMatchInterruptEnable
Definition: fsl_lpspi.h:87