26#ifndef LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX78002_SPI_H_
27#define LIBRARIES_PERIPHDRIVERS_INCLUDE_MAX78002_SPI_H_
31#include "mxc_assert.h"
32#include "mxc_device.h"
58 MXC_SPI_TYPE_SLAVE = 0,
59 MXC_SPI_TYPE_TARGET = 0,
60 MXC_SPI_TYPE_MASTER = 1,
61 MXC_SPI_TYPE_CONTROLLER = 1
69 MXC_SPI_TSCONTROL_HW_AUTO = 0,
70 MXC_SPI_TSCONTROL_SW_APP = 1
77 MXC_SPI_STATE_READY = 0,
78 MXC_SPI_STATE_BUSY = 1
85 MXC_SPI_INTERFACE_STANDARD = 0,
86 MXC_SPI_INTERFACE_4WIRE = 0,
87 MXC_SPI_INTERFACE_QUAD = 1,
88 MXC_SPI_INTERFACE_3WIRE = 2,
89 MXC_SPI_INTERFACE_DUAL = 3
103 MXC_SPI_CLKMODE_0 = 0,
104 MXC_SPI_CLKMODE_1 = 1,
105 MXC_SPI_CLKMODE_2 = 2,
106 MXC_SPI_CLKMODE_3 = 3
141typedef struct _mxc_spi_req_t mxc_spi_req_t;
152typedef struct _mxc_spi_pins_t mxc_spi_pins_t;
153struct _mxc_spi_pins_t {
182struct _mxc_spi_req_t {
193 uint16_t txDummyValue;
240 int numTargets, uint8_t ts_active_pol_mask, uint32_t freq, mxc_spi_pins_t pins);
Registers, Bit Masks and Bit Positions for the DMA Peripheral Module.
mxc_gpio_drvstr_t
Enumeration type for drive strength on a given pin. This represents what the two GPIO_DS[2] (Drive St...
Definition: gpio.h:144
Definition: spi_regs.h:76
int MXC_SPI_ControllerTransaction(mxc_spi_req_t *req)
Set up a blocking, non-interrupt-driven SPI controller transaction.
void MXC_SPI_DMA_TX_Handler(mxc_spi_regs_t *spi)
The processing function for DMA TX transactions.
int MXC_SPI_SetFrequency(mxc_spi_regs_t *spi, unsigned int hz)
Set the frequency of the SPI interface.
int MXC_SPI_Init(mxc_spi_regs_t *spi, mxc_spi_type_t controller_target, mxc_spi_interface_t if_mode, int numTargets, uint8_t ts_active_pol_mask, uint32_t freq, mxc_spi_pins_t pins)
Initialize and enable SPI peripheral.
unsigned int MXC_SPI_GetFlags(mxc_spi_regs_t *spi)
Gets the interrupt flags that are currently set.
int MXC_SPI_GetSlave(mxc_spi_regs_t *spi)
Gets the slave select (SS) line used for transmissions.
int MXC_SPI_DMA_SetRequestSelect(mxc_spi_regs_t *spi, bool use_dma_tx, bool use_dma_rx)
Sets the SPI instance's DMA TX/RX request select.
bool MXC_SPI_DMA_GetInitialized(mxc_spi_regs_t *spi)
Helper function that checks whether the MXC_SPI_Init function cfgalized DMA for SPI DMA transactons.
unsigned int MXC_SPI_GetTXFIFOAvailable(mxc_spi_regs_t *spi)
Get the amount of free space available in the transmit FIFO.
void MXC_SPI_EnableInt(mxc_spi_regs_t *spi, unsigned int intEn)
Enables specific interrupts.
void MXC_SPI_ClearFlags(mxc_spi_regs_t *spi)
Clears the interrupt flags that are currently set.
mxc_spi_interface_t
The list of supported SPI Interface Modes.
Definition: spi.h:84
unsigned int MXC_SPI_ReadRXFIFO(mxc_spi_regs_t *spi, unsigned char *bytes, unsigned int len)
Unloads bytes from the receive FIFO.
int MXC_SPI_SetRXThreshold(mxc_spi_regs_t *spi, unsigned int numBytes)
Set the receive threshold level.
int MXC_SPI_SetTSControl(mxc_spi_regs_t *spi, mxc_spi_tscontrol_t ts_control)
Configures the Pre-defined SPI Target Select pins for a specific instance.
mxc_spi_interface_t MXC_SPI_GetInterface(mxc_spi_regs_t *spi)
Gets the SPI interface mode used for transmissions.
int MXC_SPI_SetWidth(mxc_spi_regs_t *spi, mxc_spi_width_t spiWidth)
Sets the SPI width used for transmissions.
int MXC_SPI_SetSlave(mxc_spi_regs_t *spi, int ssIdx)
Sets the slave select (SS) line used for transmissions.
int MXC_SPI_GetDataSize(mxc_spi_regs_t *spi)
Gets the number of bits per character.
unsigned int MXC_SPI_GetTXThreshold(mxc_spi_regs_t *spi)
Get the current transmit threshold level.
int MXC_SPI_GetPeripheralClock(mxc_spi_regs_t *spi)
Returns the frequency of the clock used as the bit rate generator for a given SPI instance.
int MXC_SPI_SetDataSize(mxc_spi_regs_t *spi, int dataSize)
Sets the number of bits per character.
mxc_spi_tscontrol_t
The list of Target Select Control Scheme Options for target assertion/deassertion.
Definition: spi.h:68
int MXC_SPI_ReadyForSleep(mxc_spi_regs_t *spi)
Checks whether the SPI instance is ready for sleep.
int MXC_SPI_SetInterface(mxc_spi_regs_t *spi, mxc_spi_interface_t if_mode)
Sets the SPI interface mode used for transmissions.
mxc_spi_type_t
The list of types for the SPI peripheral.
Definition: spi.h:57
mxc_spi_mode_t MXC_SPI_GetMode(mxc_spi_regs_t *spi)
Gets the spi mode.
unsigned int MXC_SPI_GetRXFIFOAvailable(mxc_spi_regs_t *spi)
Get the number of bytes currently available in the receive FIFO.
int MXC_SPI_ControllerTransactionAsync(mxc_spi_req_t *req)
Set up a non-blocking, interrupt-driven SPI controller transaction.
int MXC_SPI_GetFrameSize(mxc_spi_regs_t *spi)
Gets the number of bits per frame.
int MXC_SPI_DMA_Init(mxc_spi_regs_t *spi, mxc_dma_regs_t *dma, bool use_dma_tx, bool use_dma_rx)
This function initializes the DMA for SPI DMA transactions.
mxc_spi_mode_t
The list of SPI modes.
Definition: spi.h:133
int MXC_SPI_SlaveTransactionAsync(mxc_spi_req_t *req)
Setup an interrupt-driven SPI transaction.
unsigned int MXC_SPI_GetFrequency(mxc_spi_regs_t *spi)
Get the frequency of the SPI interface.
void MXC_SPI_ClearTXFIFO(mxc_spi_regs_t *spi)
Removes and discards all bytes currently in the transmit FIFO.
void MXC_SPI_Handler(mxc_spi_regs_t *spi)
The processing function for asynchronous transactions.
int MXC_SPI_MasterTransactionAsync(mxc_spi_req_t *req)
Setup an interrupt-driven SPI transaction.
int MXC_SPI_Config(mxc_spi_cfg_t *cfg)
Configure the SPI peripheral.
int MXC_SPI_ControllerTransactionDMA(mxc_spi_req_t *req)
Set up a non-blocking, DMA-driven SPI controller transaction.
mxc_spi_width_t
Definition: spi.h:115
int MXC_SPI_SetTXThreshold(mxc_spi_regs_t *spi, unsigned int numBytes)
Set the transmit threshold level.
int MXC_SPI_SetFrameSize(mxc_spi_regs_t *spi, int frame_size)
Sets the number of bits per frame.
int MXC_SPI_Shutdown(mxc_spi_regs_t *spi)
Disable and shutdown the SPI instance.
int MXC_SPI_SlaveTransactionDMA(mxc_spi_req_t *req)
Setup a DMA driven SPI transaction.
mxc_spi_width_t MXC_SPI_GetWidth(mxc_spi_regs_t *spi)
Gets the SPI width used for transmissions.
int MXC_SPI_SlaveTransaction(mxc_spi_req_t *req)
Performs a blocking SPI transaction.
int MXC_SPI_SetCallback(mxc_spi_regs_t *spi, mxc_spi_callback_t callback, void *data)
Sets the SPI instance's callback function.
void MXC_SPI_DMA_RX_Handler(mxc_spi_regs_t *spi)
The processing function for DMA RX transactions.
int MXC_SPI_SetMode(mxc_spi_regs_t *spi, mxc_spi_mode_t spiMode)
Sets the spi mode using clock polarity and clock phase.
void MXC_SPI_AsyncHandler(mxc_spi_regs_t *spi)
The processing function for asynchronous transactions.
int MXC_SPI_GetActive(mxc_spi_regs_t *spi)
Checks the SPI instance for an ongoing transmission.
void MXC_SPI_ClearRXFIFO(mxc_spi_regs_t *spi)
Removes and discards all bytes currently in the receive FIFO.
int MXC_SPI_AbortTransmission(mxc_spi_regs_t *spi)
Aborts an ongoing SPI Transmission.
int MXC_SPI_DMA_GetRXChannel(mxc_spi_regs_t *spi)
Retreive the DMA RX Channel associated with SPI instance.
void MXC_SPI_DisableInt(mxc_spi_regs_t *spi, unsigned int intDis)
Disables specific interrupts.
int MXC_SPI_TargetTransactionDMA(mxc_spi_req_t *req)
Setup a DMA-driven SPI Target transaction.
int MXC_SPI_ControllerTransactionDMAB(mxc_spi_req_t *req)
Set up a blocking, DMA-driven SPI controller transaction.
void(* mxc_spi_callback_t)(void *, int result)
The callback routine used to indicate the transaction has terminated.
Definition: spi.h:149
unsigned int MXC_SPI_WriteTXFIFO(mxc_spi_regs_t *spi, unsigned char *bytes, unsigned int len)
Loads bytes into the transmit FIFO.
int MXC_SPI_SetDefaultTXData(mxc_spi_regs_t *spi, unsigned int defaultTXData)
Sets the TX data to transmit as a 'dummy' byte.
void MXC_SPI_AbortAsync(mxc_spi_regs_t *spi)
Abort any asynchronous requests in progress.
int MXC_SPI_DMA_GetTXChannel(mxc_spi_regs_t *spi)
Retreive the DMA TX Channel associated with SPI instance.
int MXC_SPI_TargetTransaction(mxc_spi_req_t *req)
Setup a blocking SPI Target transaction.
int MXC_SPI_SetClkMode(mxc_spi_regs_t *spi, mxc_spi_clkmode_t clk_mode)
Sets the SPI clock mode (clock polarity and clock phase).
int MXC_SPI_TargetTransactionAsync(mxc_spi_req_t *req)
Setup an interrupt-driven, non-blocking SPI Target transaction.
mxc_spi_clkmode_t
The list of SPI clock modes.
Definition: spi.h:102
unsigned int MXC_SPI_GetRXThreshold(mxc_spi_regs_t *spi)
Get the current receive threshold level.
mxc_spi_state_t
The list of possible states for an SPI instance.
Definition: spi.h:76
int MXC_SPI_StartTransmission(mxc_spi_regs_t *spi)
Starts a SPI Transmission.
int MXC_SPI_MasterTransactionDMA(mxc_spi_req_t *req)
Setup a DMA driven SPI transaction.
int MXC_SPI_MasterTransaction(mxc_spi_req_t *req)
Performs a blocking SPI transaction.
mxc_spi_clkmode_t MXC_SPI_GetClkMode(mxc_spi_regs_t *spi)
Gets the SPI clock mode (clock polarity and clock phase).
void MXC_SPI_HWSSControl(mxc_spi_regs_t *spi, int state)
Enable/Disable HW CS control feature.
int MXC_SPI_ConfigStruct(mxc_spi_cfg_t *cfg, bool use_dma_tx, bool use_dma_rx)
Overwrite the cfg struct with default values.
@ SPI_MODE_0
clock phase = 0, clock polarity = 0
Definition: spi.h:134
@ SPI_MODE_2
clock phase = 1, clock polarity = 0
Definition: spi.h:136
@ SPI_MODE_1
clock phase = 0, clock polarity = 1
Definition: spi.h:135
@ SPI_MODE_3
clock phase = 1, clock polarity = 1
Definition: spi.h:137
@ SPI_WIDTH_QUAD
4 Data lines, half duplex
Definition: spi.h:119
@ SPI_WIDTH_STANDARD
MISO/MOSI, full duplex.
Definition: spi.h:117
@ SPI_WIDTH_3WIRE
1 Data line, half duplex
Definition: spi.h:116
@ SPI_WIDTH_DUAL
2 Data lines, half duplex
Definition: spi.h:118
System level header file.
Registers, Bit Masks and Bit Positions for the SPI Peripheral Module.