Kinetis SDK v.1.3 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

This section describes the programming interface of the DSPI HAL driver.

Files

file  fsl_dspi_hal.h
 

Data Structures

struct  dspi_data_format_config_t
 DSPI data format settings configuration structure. More...
 
struct  dspi_baud_rate_divisors_t
 DSPI baud rate divisors settings configuration structure. More...
 
struct  dspi_command_config_t
 DSPI command and data configuration structure. More...
 

Enumerations

enum  dspi_status_t { ,
  kStatus_DSPI_SlaveTxUnderrun,
  kStatus_DSPI_SlaveRxOverrun,
  kStatus_DSPI_Timeout,
  kStatus_DSPI_Busy,
  kStatus_DSPI_NoTransferInProgress,
  kStatus_DSPI_InvalidBitCount,
  kStatus_DSPI_InvalidInstanceNumber,
  kStatus_DSPI_OutOfRange,
  kStatus_DSPI_InvalidParameter,
  kStatus_DSPI_NonInit,
  kStatus_DSPI_Initialized,
  kStatus_DSPI_DMAChannelInvalid,
  kStatus_DSPI_Error,
  kStatus_DSPI_EdmaStcdUnaligned32Error
}
 Error codes for the DSPI driver. More...
 
enum  dspi_master_slave_mode_t {
  kDspiMaster = 1,
  kDspiSlave = 0
}
 DSPI master or slave configuration. More...
 
enum  dspi_clock_polarity_t {
  kDspiClockPolarity_ActiveHigh = 0,
  kDspiClockPolarity_ActiveLow = 1
}
 DSPI clock polarity configuration for a given CTAR. More...
 
enum  dspi_clock_phase_t {
  kDspiClockPhase_FirstEdge = 0,
  kDspiClockPhase_SecondEdge = 1
}
 DSPI clock phase configuration for a given CTAR. More...
 
enum  dspi_shift_direction_t {
  kDspiMsbFirst = 0,
  kDspiLsbFirst = 1
}
 DSPI data shifter direction options for a given CTAR. More...
 
enum  dspi_ctar_selection_t {
  kDspiCtar0 = 0,
  kDspiCtar1 = 1
}
 DSPI Clock and Transfer Attributes Register (CTAR) selection. More...
 
enum  dspi_pcs_polarity_config_t {
  kDspiPcs_ActiveHigh = 0,
  kDspiPcs_ActiveLow = 1
}
 DSPI Peripheral Chip Select (PCS) Polarity configuration. More...
 
enum  dspi_which_pcs_config_t {
  kDspiPcs0 = 1 << 0,
  kDspiPcs1 = 1 << 1,
  kDspiPcs2 = 1 << 2,
  kDspiPcs3 = 1 << 3,
  kDspiPcs4 = 1 << 4,
  kDspiPcs5 = 1 << 5
}
 DSPI Peripheral Chip Select (PCS) configuration (which PCS to configure) More...
 
enum  dspi_master_sample_point_t {
  kDspiSckToSin_0Clock = 0,
  kDspiSckToSin_1Clock = 1,
  kDspiSckToSin_2Clock = 2
}
 DSPI Sample Point: Controls when the DSPI master samples SIN in Modified Transfer Format. More...
 
enum  dspi_dma_or_int_mode_t {
  kDspiGenerateIntReq = 0,
  kDspiGenerateDmaReq = 1
}
 DSPI Tx FIFO Fill and Rx FIFO Drain DMA or Interrupt configuration. More...
 
enum  dspi_status_and_interrupt_request_t {
  kDspiTxComplete = SPI_RSER_TCF_RE_SHIFT,
  kDspiTxAndRxStatus = SPI_SR_TXRXS_SHIFT,
  kDspiEndOfQueue = SPI_RSER_EOQF_RE_SHIFT,
  kDspiTxFifoUnderflow = SPI_RSER_TFUF_RE_SHIFT,
  kDspiTxFifoFillRequest = SPI_RSER_TFFF_RE_SHIFT,
  kDspiRxFifoOverflow = SPI_RSER_RFOF_RE_SHIFT,
  kDspiRxFifoDrainRequest = SPI_RSER_RFDF_RE_SHIFT
}
 DSPI status flags and interrupt request enable. More...
 
enum  dspi_delay_type_t {
  kDspiPcsToSck = 1,
  kDspiLastSckToPcs = 2,
  kDspiAfterTransfer = 3
}
 DSPI delay type selection. More...
 

Configuration

void DSPI_HAL_Init (SPI_Type *base)
 Restores the DSPI to reset the configuration. More...
 
static void DSPI_HAL_Enable (SPI_Type *base)
 Enables the DSPI peripheral and sets the MCR MDIS to 0. More...
 
static void DSPI_HAL_Disable (SPI_Type *base)
 Disables the DSPI peripheral, sets MCR MDIS to 1. More...
 
uint32_t DSPI_HAL_SetBaudRate (SPI_Type *base, dspi_ctar_selection_t whichCtar, uint32_t bitsPerSec, uint32_t sourceClockInHz)
 Sets the DSPI baud rate in bits per second. More...
 
void DSPI_HAL_SetBaudDivisors (SPI_Type *base, dspi_ctar_selection_t whichCtar, const dspi_baud_rate_divisors_t *divisors)
 Configures the baud rate divisors manually. More...
 
static void DSPI_HAL_SetMasterSlaveMode (SPI_Type *base, dspi_master_slave_mode_t mode)
 Configures the DSPI for master or slave. More...
 
static bool DSPI_HAL_IsMaster (SPI_Type *base)
 Returns whether the DSPI module is in master mode. More...
 
static void DSPI_HAL_SetContinuousSckCmd (SPI_Type *base, bool enable)
 Configures the DSPI for the continuous SCK operation. More...
 
static void DSPI_HAL_SetRxFifoOverwriteCmd (SPI_Type *base, bool enable)
 Configures the DSPI received FIFO overflow overwrite enable. More...
 
void DSPI_HAL_SetPcsPolarityMode (SPI_Type *base, dspi_which_pcs_config_t pcs, dspi_pcs_polarity_config_t activeLowOrHigh)
 Configures the DSPI peripheral chip select polarity. More...
 
void DSPI_HAL_SetFifoCmd (SPI_Type *base, bool enableTxFifo, bool enableRxFifo)
 Enables (or disables) the DSPI FIFOs. More...
 
void DSPI_HAL_SetFlushFifoCmd (SPI_Type *base, bool enableFlushTxFifo, bool enableFlushRxFifo)
 Flushes the DSPI FIFOs. More...
 
static void DSPI_HAL_SetDatainSamplepointMode (SPI_Type *base, dspi_master_sample_point_t samplePnt)
 Configures the time when the DSPI master samples SIN in the Modified Transfer Format. More...
 
static void DSPI_HAL_StartTransfer (SPI_Type *base)
 Starts the DSPI transfers, clears HALT bit in MCR. More...
 
static void DSPI_HAL_StopTransfer (SPI_Type *base)
 Stops (halts) DSPI transfers, sets HALT bit in MCR. More...
 
dspi_status_t DSPI_HAL_SetDataFormat (SPI_Type *base, dspi_ctar_selection_t whichCtar, const dspi_data_format_config_t *config)
 Configures the data format for a particular CTAR. More...
 
void DSPI_HAL_SetDelay (SPI_Type *base, dspi_ctar_selection_t whichCtar, uint32_t prescaler, uint32_t scaler, dspi_delay_type_t whichDelay)
 Manually configures the delay prescaler and scaler for a particular CTAR. More...
 
uint32_t DSPI_HAL_CalculateDelay (SPI_Type *base, dspi_ctar_selection_t whichCtar, dspi_delay_type_t whichDelay, uint32_t sourceClockInHz, uint32_t delayInNanoSec)
 Calculates the delay prescaler and scaler based on the desired delay input in nanoseconds. More...
 
static uint32_t DSPI_HAL_GetMasterPushrRegAddr (SPI_Type *base)
 Gets the DSPI master PUSHR data register address for DMA operation. More...
 
static uint32_t DSPI_HAL_GetSlavePushrRegAddr (SPI_Type *base)
 Gets the DSPI slave PUSHR data register address for DMA operation. More...
 
static uint32_t DSPI_HAL_GetPoprRegAddr (SPI_Type *base)
 Gets the DSPI POPR data register address for DMA operation. More...
 

Interrupts

void DSPI_HAL_SetTxFifoFillDmaIntMode (SPI_Type *base, dspi_dma_or_int_mode_t mode, bool enable)
 Configures the DSPI Tx FIFO fill request to generate DMA or interrupt requests. More...
 
void DSPI_HAL_SetRxFifoDrainDmaIntMode (SPI_Type *base, dspi_dma_or_int_mode_t mode, bool enable)
 Configures the DSPI Rx FIFO Drain request to generate DMA or interrupt requests. More...
 
void DSPI_HAL_SetIntMode (SPI_Type *base, dspi_status_and_interrupt_request_t interruptSrc, bool enable)
 Configures the DSPI interrupts. More...
 
static bool DSPI_HAL_GetIntMode (SPI_Type *base, dspi_status_and_interrupt_request_t interruptSrc)
 Gets DSPI interrupt configuration, returns if interrupt request is enabled or disabled. More...
 

Status

static bool DSPI_HAL_GetStatusFlag (SPI_Type *base, dspi_status_and_interrupt_request_t statusFlag)
 Gets the DSPI status flag state. More...
 
static void DSPI_HAL_ClearStatusFlag (SPI_Type *base, dspi_status_and_interrupt_request_t statusFlag)
 Clears the DSPI status flag. More...
 

Data transfer

static uint32_t DSPI_HAL_ReadData (SPI_Type *base)
 Reads data from the data buffer. More...
 
static void DSPI_HAL_WriteDataSlavemode (SPI_Type *base, uint32_t data)
 Writes data into the data buffer, slave mode. More...
 
void DSPI_HAL_WriteDataSlavemodeBlocking (SPI_Type *base, uint32_t data)
 Writes data into the data buffer, slave mode and waits till data was transmitted and return. More...
 
void DSPI_HAL_WriteDataMastermode (SPI_Type *base, dspi_command_config_t *command, uint16_t data)
 Writes data into the data buffer, master mode. More...
 
void DSPI_HAL_WriteDataMastermodeBlocking (SPI_Type *base, dspi_command_config_t *command, uint16_t data)
 Writes data into the data buffer, master mode and waits till complete to return. More...
 
static void DSPI_HAL_WriteCmdDataMastermode (SPI_Type *base, uint32_t data)
 Writes a 32-bit data word (16-bit command appended with 16-bit data) into the data buffer, master mode. More...
 
void DSPI_HAL_WriteCmdDataMastermodeBlocking (SPI_Type *base, uint32_t data)
 Writes a 32-bit data word (16-bit command appended with 16-bit data) into the data buffer, master mode and waits till complete to return. More...
 
static uint32_t DSPI_HAL_GetTransferCount (SPI_Type *base)
 Gets the transfer count. More...
 
static void DSPI_HAL_PresetTransferCount (SPI_Type *base, uint16_t presetValue)
 Pre-sets the transfer count. More...
 
uint32_t DSPI_HAL_GetFormattedCommand (SPI_Type *base, dspi_command_config_t *command)
 Returns the DSPI command word formatted to the PUSHR data register bit field. More...
 

Data Structure Documentation

struct dspi_data_format_config_t

This structure contains the data format settings. These settings apply to a specific CTARn register, which the user must provide in this structure.

Data Fields

uint32_t bitsPerFrame
 Bits per frame, minimum 4, maximum 16.
 
dspi_clock_polarity_t clkPolarity
 Active high or low clock polarity.
 
dspi_clock_phase_t clkPhase
 Clock phase setting to change and capture data.
 
dspi_shift_direction_t direction
 MSB or LSB data shift direction This setting relevant only in master mode and can be ignored in slave mode.
 
struct dspi_baud_rate_divisors_t

Note: These settings are relevant only in master mode. This structure contains the baud rate divisor settings, which provides the user with the option to explicitly set these baud rate divisors. In addition, the user must also set the CTARn register with the divisor settings.

Data Fields

bool doubleBaudRate
 Double Baud rate parameter setting.
 
uint32_t prescaleDivisor
 Baud Rate Pre-scalar parameter setting.
 
uint32_t baudRateDivisor
 Baud Rate scaler parameter setting.
 
struct dspi_command_config_t

Note: This structure is used with the PUSHR register, which provides the means to write to the Tx FIFO. Data written to this register is transferred to the Tx FIFO. Eight or sixteen-bit write accesses to the PUSHR transfer all 32 register bits to the Tx FIFO. The register structure is different in master and slave modes. In master mode, the register provides 16-bit command and 16-bit data to the Tx FIFO. In slave mode only 16-bit data may be written (this may be contrary to some older documentation which erroneously states that a 32-bit value may be written).

Data Fields

bool isChipSelectContinuous
 Option to enable the continuous assertion of chip select between transfers.
 
dspi_ctar_selection_t whichCtar
 The desired Clock and Transfer Attributes Register (CTAR) to use for CTAS.
 
dspi_which_pcs_config_t whichPcs
 The desired PCS signal to use for the data transfer.
 
bool isEndOfQueue
 Signals that the current transfer is the last in the queue.
 
bool clearTransferCount
 Clears SPI_TCNT field; cleared before transmission starts.
 

Enumeration Type Documentation

Enumerator
kStatus_DSPI_SlaveTxUnderrun 

DSPI Slave Tx Under run error.

kStatus_DSPI_SlaveRxOverrun 

DSPI Slave Rx Overrun error.

kStatus_DSPI_Timeout 

DSPI transfer timed out.

kStatus_DSPI_Busy 

DSPI instance is already busy performing a transfer.

kStatus_DSPI_NoTransferInProgress 

Attempt to abort a transfer when no transfer was in progress.

kStatus_DSPI_InvalidBitCount 

bits-per-frame value not valid

kStatus_DSPI_InvalidInstanceNumber 

DSPI instance number does not match current count.

kStatus_DSPI_OutOfRange 

DSPI out-of-range error.

kStatus_DSPI_InvalidParameter 

DSPI invalid parameter error.

kStatus_DSPI_NonInit 

DSPI driver does not initialize, not ready.

kStatus_DSPI_Initialized 

DSPI driver has initialized, cannot re-initialize.

kStatus_DSPI_DMAChannelInvalid 

DSPI driver could not request DMA channel(s)

kStatus_DSPI_Error 

DSPI driver error.

kStatus_DSPI_EdmaStcdUnaligned32Error 

DSPI Edma driver STCD unaligned to 32byte error.

Enumerator
kDspiMaster 

DSPI peripheral operates in master mode.

kDspiSlave 

DSPI peripheral operates in slave mode.

Enumerator
kDspiClockPolarity_ActiveHigh 

Active-high DSPI clock (idles low)

kDspiClockPolarity_ActiveLow 

Active-low DSPI clock (idles high)

Enumerator
kDspiClockPhase_FirstEdge 

Data is captured on the leading edge of the SCK and changed on the following edge.

kDspiClockPhase_SecondEdge 

Data is changed on the leading edge of the SCK and captured on the following edge.

Enumerator
kDspiMsbFirst 

Data transfers start with most significant bit.

kDspiLsbFirst 

Data transfers start with least significant bit.

Enumerator
kDspiCtar0 

CTAR0 selection option for master or slave mode.

kDspiCtar1 

CTAR1 selection option for master mode only.

Enumerator
kDspiPcs_ActiveHigh 

PCS Active High (idles low)

kDspiPcs_ActiveLow 

PCS Active Low (idles high)

Enumerator
kDspiPcs0 

PCS[0].

kDspiPcs1 

PCS[1].

kDspiPcs2 

PCS[2].

kDspiPcs3 

PCS[3].

kDspiPcs4 

PCS[4].

kDspiPcs5 

PCS[5].

This field is valid only when CPHA bit in CTAR register is 0.

Enumerator
kDspiSckToSin_0Clock 

0 system clocks between SCK edge and SIN sample

kDspiSckToSin_1Clock 

1 system clock between SCK edge and SIN sample

kDspiSckToSin_2Clock 

2 system clocks between SCK edge and SIN sample

Enumerator
kDspiGenerateIntReq 

Desired flag generates an Interrupt request.

kDspiGenerateDmaReq 

Desired flag generates a DMA request.

Enumerator
kDspiTxComplete 

TCF status/interrupt enable.

kDspiTxAndRxStatus 

TXRXS status only, no interrupt.

kDspiEndOfQueue 

EOQF status/interrupt enable.

kDspiTxFifoUnderflow 

TFUF status/interrupt enable.

kDspiTxFifoFillRequest 

TFFF status/interrupt enable.

kDspiRxFifoOverflow 

RFOF status/interrupt enable.

kDspiRxFifoDrainRequest 

RFDF status/interrupt enable.

Enumerator
kDspiPcsToSck 

PCS-to-SCK delay.

kDspiLastSckToPcs 

Last SCK edge to PCS delay.

kDspiAfterTransfer 

Delay between transfers.

Function Documentation

void DSPI_HAL_Init ( SPI_Type *  base)

This function basically resets all of the DSPI registers to their default setting including disabling the module.

Parameters
baseModule base pointer of type SPI_Type.
static void DSPI_HAL_Enable ( SPI_Type *  base)
inlinestatic
Parameters
baseModule base pointer of type SPI_Type.
static void DSPI_HAL_Disable ( SPI_Type *  base)
inlinestatic
Parameters
baseModule base pointer of type SPI_Type.
uint32_t DSPI_HAL_SetBaudRate ( SPI_Type *  base,
dspi_ctar_selection_t  whichCtar,
uint32_t  bitsPerSec,
uint32_t  sourceClockInHz 
)

This function takes in the desired bitsPerSec (baud rate) and calculates the nearest possible baud rate without exceeding the desired baud rate, and returns the calculated baud rate in bits-per-second. It requires that the caller also provide the frequency of the module source clock (in Hertz).

Parameters
baseModule base pointer of type SPI_Type.
whichCtarThe desired Clock and Transfer Attributes Register (CTAR) of the type dspi_ctar_selection_t
bitsPerSecThe desired baud rate in bits per second
sourceClockInHzModule source input clock in Hertz
Returns
The actual calculated baud rate
void DSPI_HAL_SetBaudDivisors ( SPI_Type *  base,
dspi_ctar_selection_t  whichCtar,
const dspi_baud_rate_divisors_t divisors 
)

This function allows the caller to manually set the baud rate divisors in the event that these dividers are known and the caller does not wish to call the DSPI_HAL_SetBaudRate function.

Parameters
baseModule base pointer of type SPI_Type.
whichCtarThe desired Clock and Transfer Attributes Register (CTAR) of type dspi_ctar_selection_t
divisorsPointer to a structure containing the user defined baud rate divisor settings
static void DSPI_HAL_SetMasterSlaveMode ( SPI_Type *  base,
dspi_master_slave_mode_t  mode 
)
inlinestatic
Parameters
baseModule base pointer of type SPI_Type.
modeMode setting (master or slave) of type dspi_master_slave_mode_t
static bool DSPI_HAL_IsMaster ( SPI_Type *  base)
inlinestatic
Parameters
baseModule base pointer of type SPI_Type.
Returns
Returns true if the module is in master mode or false if the module is in slave mode.
static void DSPI_HAL_SetContinuousSckCmd ( SPI_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseModule base pointer of type SPI_Type.
enableEnables (true) or disables(false) continuous SCK operation.
static void DSPI_HAL_SetRxFifoOverwriteCmd ( SPI_Type *  base,
bool  enable 
)
inlinestatic

When enabled, this function allows incoming receive data to overwrite the existing data in the receive shift register when the Rx FIFO is full. Otherwise when disabled, the incoming data is ignored when the RX FIFO is full.

Parameters
baseModule base pointer of type SPI_Type.
enableIf enabled (true), allows incoming data to overwrite Rx FIFO contents when full, else incoming data is ignored.
void DSPI_HAL_SetPcsPolarityMode ( SPI_Type *  base,
dspi_which_pcs_config_t  pcs,
dspi_pcs_polarity_config_t  activeLowOrHigh 
)

This function takes in the desired peripheral chip select (PCS) and it's corresponding desired polarity and configures the PCS signal to operate with the desired characteristic.

Parameters
baseModule base pointer of type SPI_Type.
pcsThe particular peripheral chip select (parameter value is of type dspi_which_pcs_config_t) for which we wish to apply the active high or active low characteristic.
activeLowOrHighThe setting for either "active high, inactive low (0)" or "active low, inactive high(1)" of type dspi_pcs_polarity_config_t.
void DSPI_HAL_SetFifoCmd ( SPI_Type *  base,
bool  enableTxFifo,
bool  enableRxFifo 
)

This function allows the caller to disable/enable the Tx and Rx FIFOs (independently). Note that to disable, the caller must pass in a logic 0 (false) for the particular FIFO configuration. To enable, the caller must pass in a logic 1 (true).

Parameters
baseModule base pointer of type SPI_Type.
enableTxFifoDisables (false) the TX FIFO, else enables (true) the TX FIFO
enableRxFifoDisables (false) the RX FIFO, else enables (true) the RX FIFO
void DSPI_HAL_SetFlushFifoCmd ( SPI_Type *  base,
bool  enableFlushTxFifo,
bool  enableFlushRxFifo 
)
Parameters
baseModule base pointer of type SPI_Type.
enableFlushTxFifoFlushes (true) the Tx FIFO, else do not flush (false) the Tx FIFO
enableFlushRxFifoFlushes (true) the Rx FIFO, else do not flush (false) the Rx FIFO
static void DSPI_HAL_SetDatainSamplepointMode ( SPI_Type *  base,
dspi_master_sample_point_t  samplePnt 
)
inlinestatic

This function controls when the DSPI master samples SIN (data in) in the Modified Transfer Format. Note that this is valid only when the CPHA bit in the CTAR register is 0.

Parameters
baseModule base pointer of type SPI_Type.
samplePntselects when the data in (SIN) is sampled, of type dspi_master_sample_point_t. This value selects either 0, 1, or 2 system clocks between the SCK edge and the SIN (data in) sample.
static void DSPI_HAL_StartTransfer ( SPI_Type *  base)
inlinestatic

This function call called whenever the module is ready to begin data transfers in either master or slave mode.

Parameters
baseModule base pointer of type SPI_Type.
static void DSPI_HAL_StopTransfer ( SPI_Type *  base)
inlinestatic

This function call stops data transfers in either master or slave mode.

Parameters
baseModule base pointer of type SPI_Type.
dspi_status_t DSPI_HAL_SetDataFormat ( SPI_Type *  base,
dspi_ctar_selection_t  whichCtar,
const dspi_data_format_config_t config 
)

This function configures the bits-per-frame, polarity, phase, and shift direction for a particular CTAR. An example use case is as follows:

Parameters
baseModule base pointer of type SPI_Type.
whichCtarThe desired Clock and Transfer Attributes Register (CTAR) of type dspi_ctar_selection_t.
configPointer to structure containing user defined data format configuration settings.
Returns
An error code or kStatus_DSPI_Success
void DSPI_HAL_SetDelay ( SPI_Type *  base,
dspi_ctar_selection_t  whichCtar,
uint32_t  prescaler,
uint32_t  scaler,
dspi_delay_type_t  whichDelay 
)

This function configures the PCS to SCK delay pre-scalar (PCSSCK) and scalar (CSSCK), after SCK delay pre-scalar (PASC) and scalar (ASC), and the delay after transfer pre-scalar (PDT)and scalar (DT).

These delay names are available in type dspi_delay_type_t.

The user passes which delay they want to configure along with the prescaler and scaler value. This allows the user to directly set the prescaler/scaler values if they have pre-calculated them or if they simply wish to manually increment either value.

Parameters
baseModule base pointer of type SPI_Type.
whichCtarThe desired Clock and Transfer Attributes Register (CTAR) of type dspi_ctar_selection_t.
prescalerThe prescaler delay value (can be an integer 0, 1, 2, or 3).
scalerThe scaler delay value (can be any integer between 0 to 15).
whichDelayThe desired delay to configure, must be of type dspi_delay_type_t
uint32_t DSPI_HAL_CalculateDelay ( SPI_Type *  base,
dspi_ctar_selection_t  whichCtar,
dspi_delay_type_t  whichDelay,
uint32_t  sourceClockInHz,
uint32_t  delayInNanoSec 
)

This function calculates the values for: PCS to SCK delay pre-scalar (PCSSCK) and scalar (CSSCK), or After SCK delay pre-scalar (PASC) and scalar (ASC), or Delay after transfer pre-scalar (PDT)and scalar (DT).

These delay names are available in type dspi_delay_type_t.

The user passes which delay they want to configure along with the desired delay value in nanoseconds. The function calculates the values needed for the prescaler and scaler and returning the actual calculated delay as an exact delay match may not be possible. In this case, the closest match is calculated without going below the desired delay value input. It is possible to input a very large delay value that exceeds the capability of the part, in which case the maximum supported delay is returned. It is to the higher level peripheral driver to alert the user of an out of range delay input.

Parameters
baseModule base pointer of type SPI_Type.
whichCtarThe desired Clock and Transfer Attributes Register (CTAR) of type dspi_ctar_selection_t.
whichDelayThe desired delay to configure, must be of type dspi_delay_type_t
sourceClockInHzModule source input clock in Hertz
delayInNanoSecThe desired delay value in nanoseconds.
Returns
The actual calculated delay value.
static uint32_t DSPI_HAL_GetMasterPushrRegAddr ( SPI_Type *  base)
inlinestatic

This function gets the DSPI master PUSHR data register address as this value is needed for DMA operation.

Parameters
baseModule base pointer of type SPI_Type.
Returns
The DSPI master PUSHR data register address.
static uint32_t DSPI_HAL_GetSlavePushrRegAddr ( SPI_Type *  base)
inlinestatic

This function gets the DSPI slave PUSHR data register address as this value is needed for DMA operation.

Parameters
baseModule base pointer of type SPI_Type.
Returns
The DSPI slave PUSHR data register address.
static uint32_t DSPI_HAL_GetPoprRegAddr ( SPI_Type *  base)
inlinestatic

This function gets the DSPI POPR data register address as this value is needed for DMA operation.

Parameters
baseModule base pointer of type SPI_Type.
Returns
The DSPI POPR data register address.
void DSPI_HAL_SetTxFifoFillDmaIntMode ( SPI_Type *  base,
dspi_dma_or_int_mode_t  mode,
bool  enable 
)

This function configures the DSPI Tx FIFO Fill flag to generate either an interrupt or DMA request. The user passes in which request they'd like to generate of type dspi_dma_or_int_mode_t and whether or not they wish to enable this request. Note, when disabling the request, the request type is don't care.

DSPI_HAL_SetTxFifoFillDmaIntMode(base, kDspiGenerateIntReq, true); <- to enable Interrupt
Parameters
baseModule base pointer of type SPI_Type.
modeConfigures the DSPI Tx FIFO Fill to generate an interrupt or DMA request
enableEnable (true) or disable (false) the DSPI Tx FIFO Fill flag to generate requests
void DSPI_HAL_SetRxFifoDrainDmaIntMode ( SPI_Type *  base,
dspi_dma_or_int_mode_t  mode,
bool  enable 
)

This function configures the DSPI Rx FIFO Drain flag to generate either an interrupt or a DMA request. The user passes in which request they'd like to generate of type dspi_dma_or_int_mode_t and whether or not they wish to enable this request. Note, when disabling the request, the request type is don't care.

Parameters
baseModule base pointer of type SPI_Type.
modeConfigures the Rx FIFO Drain to generate an interrupt or DMA request
enableEnable (true) or disable (false) the Rx FIFO Drain flag to generate requests
void DSPI_HAL_SetIntMode ( SPI_Type *  base,
dspi_status_and_interrupt_request_t  interruptSrc,
bool  enable 
)

This function configures the various interrupt sources of the DSPI. The parameters are base, interrupt source, and enable/disable setting. The interrupt source is a typedef enumeration whose value is the bit position of the interrupt source setting within the RSER register. In the DSPI, all interrupt configuration settings are in one register. The typedef enum equates each interrupt source to the bit position defined in the device header file. The function uses these bit positions in its algorithm to enable/disable the interrupt source, where interrupt source is the dspi_status_and_interrupt_request_t type. Note, for Tx FIFO Fill and Rx FIFO Drain requests, use the functions: DSPI_HAL_SetTxFifoFillDmaIntMode and DSPI_HAL_SetRxFifoDrainDmaIntMode respectively as these requests can generate either an interrupt or DMA request.

DSPI_HAL_SetIntMode(base, kDspiTxComplete, true); <- example use-case
Parameters
baseModule base pointer of type SPI_Type.
interruptSrcThe interrupt source, of type dspi_status_and_interrupt_request_t
enableEnable (true) or disable (false) the interrupt source to generate requests
static bool DSPI_HAL_GetIntMode ( SPI_Type *  base,
dspi_status_and_interrupt_request_t  interruptSrc 
)
inlinestatic

This function returns the requested interrupt source setting (enabled or disabled, of type bool). The parameters to pass in are base and interrupt source. It utilizes the same enumeration definitions for the interrupt sources as described in the interrupt config function. The function uses these bit positions in its algorithm to obtain the desired interrupt source setting. Note, for Tx FIFO Fill and Rx FIFO Drain requests, this returns whether or not their requests are enabled.

getInterruptSetting = DSPI_HAL_GetIntMode(base, kDspiTxComplete);
Parameters
baseModule base pointer of type SPI_Type.
interruptSrcThe interrupt source, of type dspi_status_and_interrupt_request_t
Returns
Configuration of interrupt request: enable (true) or disable (false).
static bool DSPI_HAL_GetStatusFlag ( SPI_Type *  base,
dspi_status_and_interrupt_request_t  statusFlag 
)
inlinestatic

The status flag is defined in the same enumeration as the interrupt source enable because the bit position of the interrupt source and corresponding status flag are the same in the RSER and SR registers. The function uses these bit positions in its algorithm to obtain the desired flag state, similar to the dspi_get_interrupt_config function.

Parameters
baseModule base pointer of type SPI_Type.
statusFlagThe status flag, of type dspi_status_and_interrupt_request_t
Returns
State of the status flag: asserted (true) or not-asserted (false)
static void DSPI_HAL_ClearStatusFlag ( SPI_Type *  base,
dspi_status_and_interrupt_request_t  statusFlag 
)
inlinestatic

This function clears the desired status bit by using a write-1-to-clear. The user passes in the base and the desired status bit to clear. The list of status bits is defined in the dspi_status_and_interrupt_request_t. The function uses these bit positions in its algorithm to clear the desired flag state. Example usage:

Parameters
baseModule base pointer of type SPI_Type.
statusFlagThe status flag, of type dspi_status_and_interrupt_request_t
static uint32_t DSPI_HAL_ReadData ( SPI_Type *  base)
inlinestatic
Parameters
baseModule base pointer of type SPI_Type.
Returns
The data from the read data buffer
static void DSPI_HAL_WriteDataSlavemode ( SPI_Type *  base,
uint32_t  data 
)
inlinestatic

In slave mode, up to 16-bit words may be written.

Parameters
baseModule base pointer of type SPI_Type.
dataThe data to send
void DSPI_HAL_WriteDataSlavemodeBlocking ( SPI_Type *  base,
uint32_t  data 
)

In slave mode, up to 16-bit words may be written. The function first clears transmit complete flag then writes data into data register, and finally wait tills the data is transmitted.

Parameters
baseModule base pointer of type SPI_Type.
dataThe data to send
void DSPI_HAL_WriteDataMastermode ( SPI_Type *  base,
dspi_command_config_t command,
uint16_t  data 
)

In master mode, the 16-bit data is appended to the 16-bit command info. The command portion provides characteristics of the data such as: optional continuous chip select operation between transfers, the desired Clock and Transfer Attributes register to use for the associated SPI frame, the desired PCS signal to use for the data transfer, whether the current transfer is the last in the queue, and whether to clear the transfer count (normally needed when sending the first frame of a data packet). This is an example:

dspi_command_config_t commandConfig;
commandConfig.isChipSelectContinuous = true;
commandConfig.whichCtar = kDspiCtar0;
commandConfig.whichPcs = kDspiPcs1;
commandConfig.clearTransferCount = false;
commandConfig.isEndOfQueue = false;
DSPI_HAL_WriteDataMastermode(base, &commandConfig, dataWord);
Parameters
baseModule base pointer of type SPI_Type.
commandPointer to command structure
dataThe data word to be sent
void DSPI_HAL_WriteDataMastermodeBlocking ( SPI_Type *  base,
dspi_command_config_t command,
uint16_t  data 
)

In master mode, the 16-bit data is appended to the 16-bit command info. The command portion provides characteristics of the data such as: optional continuous chip select operation between transfers, the desired Clock and Transfer Attributes register to use for the associated SPI frame, the desired PCS signal to use for the data transfer, whether the current transfer is the last in the queue, and whether to clear the transfer count (normally needed when sending the first frame of a data packet). This is an example:

dspi_command_config_t commandConfig;
commandConfig.isChipSelectContinuous = true;
commandConfig.whichCtar = kDspiCtar0;
commandConfig.whichPcs = kDspiPcs1;
commandConfig.clearTransferCount = false;
commandConfig.isEndOfQueue = false;
DSPI_HAL_WriteDataMastermodeBlocking(base, &commandConfig, dataWord);

Note that this function does not return until after the transmit is complete. Also note that the DSPI must be enabled and running in order to transmit data (MCR[MDIS] & [HALT] = 0). Since the SPI is a synchronous protocol, receive data is available when transmit completes.

Parameters
baseModule base pointer of type SPI_Type.
commandPointer to command structure
dataThe data word to be sent
static void DSPI_HAL_WriteCmdDataMastermode ( SPI_Type *  base,
uint32_t  data 
)
inlinestatic

In this function, the user must append the 16-bit data to the 16-bit command info then provide the total 32-bit word as the data to send. The command portion provides characteristics of the data such as: optional continuous chip select operation between transfers, the desired Clock and Transfer Attributes register to use for the associated SPI frame, the desired PCS signal to use for the data transfer, whether the current transfer is the last in the queue, and whether to clear the transfer count (normally needed when sending the first frame of a data packet). The user is responsible for appending this command with the data to send. This is an example:

dataWord = <16-bit command> | <16-bit data>;
Parameters
baseModule base pointer of type SPI_Type.
dataThe data word (command and data combined) to be sent
void DSPI_HAL_WriteCmdDataMastermodeBlocking ( SPI_Type *  base,
uint32_t  data 
)

In this function, the user must append the 16-bit data to the 16-bit command info then provide the total 32-bit word as the data to send. The command portion provides characteristics of the data such as: optional continuous chip select operation between transfers, the desired Clock and Transfer Attributes register to use for the associated SPI frame, the desired PCS signal to use for the data transfer, whether the current transfer is the last in the queue, and whether to clear the transfer count (normally needed when sending the first frame of a data packet). The user is responsible for appending this command with the data to send. This is an example:

dataWord = <16-bit command> | <16-bit data>;

Note that this function does not return until after the transmit is complete. Also note that the DSPI must be enabled and running in order to transmit data (MCR[MDIS] & [HALT] = 0). Since the SPI is a synchronous protocol, receive data is available when transmit completes.

Parameters
baseModule base pointer of type SPI_Type.
dataThe data word (command and data combined) to be sent
static uint32_t DSPI_HAL_GetTransferCount ( SPI_Type *  base)
inlinestatic

This function returns the current value of the DSPI Transfer Count Register.

Parameters
baseModule base pointer of type SPI_Type.
Returns
The current transfer count
static void DSPI_HAL_PresetTransferCount ( SPI_Type *  base,
uint16_t  presetValue 
)
inlinestatic

This function allows the caller to pre-set the DSI Transfer Count Register to a desired value up to 65535; Incrementing past this resets the counter back to 0.

Parameters
baseModule base pointer of type SPI_Type.
presetValueThe desired pre-set value for the transfer counter
uint32_t DSPI_HAL_GetFormattedCommand ( SPI_Type *  base,
dspi_command_config_t command 
)

This function allows the caller to pass in the data command structure and returns the command word formatted according to the DSPI PUSHR register bit field placement. The user can then "OR" the returned command word with the desired data to send and use the function DSPI_HAL_WriteCmdDataMastermode or DSPI_HAL_WriteCmdDataMastermodeBlocking to write the entire 32-bit command data word to the PUSHR. This helps improve performance in cases where the command structure is constant. For example, the user calls this function before starting a transfer to generate the command word. When they are ready to transmit the data, they would OR this formatted command word with the desired data to transmit. This process increases transmit performance when compared to calling send functions such as DSPI_HAL_WriteDataMastermode which format the command word each time a data word is to be sent.

Parameters
baseModule base pointer of type SPI_Type.
commandPointer to command structure
Returns
The command word formatted to the PUSHR data register bit field