Hilscher netX microcontroller driver  V0.0.5.0
Documentation of the netX driver package

The SPI driver, defined by DRV_SPI_HANDLE_T. More...

Collaboration diagram for SPI:

Data Structures

struct  DRV_SPI_MODE_T
 Bitfield for the spi mode. More...
 
union  DRV_SPI_MODE_U
 Union for the spi mode. More...
 
struct  DRV_SPI_CONFIGURATION_T
 The configuration structure of the SPI device driver. More...
 
struct  DRV_SPI_HANDLE_T
 The handle of the driver. More...
 

Macros

#define DRV_HANDLE_CHECK(handle)
 
#define DRV_SPI_IRQHandler_Generator(id, _)   DRV_Default_IRQHandler_Function_Generator(DRV_SPI_IRQ_HANDLER ## id,DRV_SPI_IRQ_Inline_Handler,(DRV_SPI_DEVICE_ID_E)(DRV_SPI_DEVICE_ID_MIN + id))
 

Enumerations

enum  DRV_SPI_MISO_E {
  DRV_SPI_MISO_ACTIVE = 0x0u,
  DRV_SPI_MISO_INACTIVE = 0x1u
}
 Enumeration of the mosi drive state as slave. More...
 
enum  DRV_SPI_FSS_E {
  DRV_SPI_FSS_NONE = 0x00u,
  DRV_SPI_FSS_0 = 0x1u,
  DRV_SPI_FSS_1 = 0x2u,
  DRV_SPI_FSS_2 = 0x4u,
  DRV_SPI_FSS_ALL = 0x7u
}
 Enumeration of the frame or slave select (FSS) signal pin mask. More...
 
enum  DRV_SPI_FREQUENCY_E {
  DRV_SPI_FREQUENCY_STOPPED = 0x000u,
  DRV_SPI_FREQUENCY_24_4KHz = 0x001u,
  DRV_SPI_FREQUENCY_48_8KHz = 0x002u,
  DRV_SPI_FREQUENCY_97_6KHz = 0x004u,
  DRV_SPI_FREQUENCY_195KHz = 0x008u,
  DRV_SPI_FREQUENCY_390KHz = 0x010u,
  DRV_SPI_FREQUENCY_781KHz = 0x020u,
  DRV_SPI_FREQUENCY_1_56MHz = 0x040u,
  DRV_SPI_FREQUENCY_3_125MHz = 0x080u,
  DRV_SPI_FREQUENCY_6_25MHz = 0x100u,
  DRV_SPI_FREQUENCY_12_5MHz = 0x200u,
  DRV_SPI_FREQUENCY_25MHz = 0x400u,
  DRV_SPI_FREQUENCY_50MHz = 0x800u,
  DRV_SPI_FREQUENCY_99MHz = 0xFFFu,
  DRV_SPI_FREQUENCY_MAX = DRV_SPI_FREQUENCY_99MHz,
  DRV_SPI_FREQUENCY_MIN = DRV_SPI_FREQUENCY_STOPPED
}
 Enumeration of useful spi frequencies. More...
 
enum  DRV_SPI_BEHAVIOUR_E {
  DRV_SPI_BEHAVIOUR_MASTER = 0x0u,
  DRV_SPI_BEHAVIOUR_SLAVE = 0x1u
}
 Enumeration of the master/slave mode. More...
 
enum  DRV_SPI_MODE_E {
  DRV_SPI_MODE_0 = 0x0u,
  DRV_SPI_MODE_1 = 0x1u,
  DRV_SPI_MODE_2 = 0x2u,
  DRV_SPI_MODE_3 = 0x3u,
  DRV_SPI_MODE_MIN = DRV_SPI_MODE_0,
  DRV_SPI_MODE_MAX = DRV_SPI_MODE_3
}
 Enumeration of the sampling mode. More...
 
enum  DRV_SPI_SPH_E {
  DRV_SPI_SPH_SAMPLE_AT_FIRST_EDGE = 0x0u,
  DRV_SPI_SPH_SAMPLE_AT_SECOND_EDGE = 0x1u
}
 Enumeration of the serial clock phase. More...
 
enum  DRV_SPI_DUPLEX_E {
  DRV_SPI_DUPLEX_HALF = 0x1u,
  DRV_SPI_DUPLEX_FULL = 0x0u
}
 Enumeration of the duplex mode. More...
 
enum  DRV_SPI_PARALLELISM_E {
  DRV_SPI_PARALLELISM_1BIT = 0x0u,
  DRV_SPI_PARALLELISM_2BIT = 0x1u,
  DRV_SPI_PARALLELISM_4BIT = 0x2u,
  DRV_SPI_PARALLELISM_MAX = DRV_SPI_PARALLELISM_4BIT,
  DRV_SPI_PARALLELISM_MIN = DRV_SPI_PARALLELISM_1BIT
}
 Enumeration of the parallelism. More...
 
enum  DRV_SPI_SPO_E {
  DRV_SPI_SPO_CLOCK_INACTIVE_LOW = 0x0u,
  DRV_SPI_SPO_CLOCK_ACTIVE_LOW = 0x1u,
  DRV_SPI_SPO_CLOCK_INACTIVE_HIGH = 0x1u,
  DRV_SPI_SPO_CLOCK_ACTIVE_HIGH = 0x0u
}
 Enumeration of the serial clock polarity. More...
 
enum  DRV_SPI_ENDIANESS_E {
  DRV_SPI_ENDIANESS_LITTLE = 0x0u,
  DRV_SPI_ENDIANESS_BIG = 0x1u
}
 Enumeration of the Endianess used. More...
 
enum  DRV_SPI_FSS_STATIC_E {
  DRV_SPI_FSS_STATIC_HARDWARE = 0x0u,
  DRV_SPI_FSS_STATIC_DRIVER = 0x1u,
  DRV_SPI_FSS_STATIC_CALLER = 0x11u
}
 Enumeration of the frame/chip select modes. More...
 
enum  DRV_SPI_FIFO_WM_E {
  DRV_SPI_FIFO_WM_RESET = 0x0u,
  DRV_SPI_FIFO_WM_MIN = 0x1u,
  DRV_SPI_FIFO_WM_DEFAULT = 0x9u,
  DRV_SPI_FIFO_WM_MAX = 0x10u
}
 Enumeration of the water mark level of the fifos. More...
 
enum  DRV_SPI_FRAME_FORMAT_E {
  DRV_SPI_FRAME_FORMAT_MOTOROLA = 0x0u,
  DRV_SPI_FRAME_FORMAT_RESERVED0 = 0x1u,
  DRV_SPI_FRAME_FORMAT_RESERVED1 = 0x2u,
  DRV_SPI_FRAME_FORMAT_RESERVED2 = 0x3u,
  DRV_SPI_FRAME_FORMAT_MAX = DRV_SPI_FRAME_FORMAT_MOTOROLA
}
 Enumeration of the available frame formats of the spi. More...
 
enum  DRV_SPI_SLV_SIG_EARLY_E {
  DRV_SPI_SLV_SIG_NOT_EARLY = 0x0u,
  DRV_SPI_SLV_SIG_EARLY = 0x1u
}
 Enumeration of the modes of the early response bit generation. More...
 
enum  DRV_SPI_FILTER_E {
  DRV_SPI_FILTER_INACTIVE = 0x0u,
  DRV_SPI_FILTER_ACTIVE = 0x1u
}
 Enumeration of the filter state. More...
 
enum  DRV_SPI_LOOP_BACK_MODE_E {
  DRV_SPI_LOOP_BACK_MODE_INACTIVE = 0x0u,
  DRV_SPI_LOOP_BACK_MODE_ACTIVE = 0x1u
}
 Enumeration of the loop back mode. More...
 
enum  DRV_SPI_DUMMYPATTERN_E {
  DRV_SPI_DUMMYPATTERN_NULL = 0x0u,
  DRV_SPI_DUMMYPATTERN_ALTERNATING_0 = 0xAAAAu,
  DRV_SPI_DUMMYPATTERN_ALTERNATING_1 = 0x5555u,
  DRV_SPI_DUMMYPATTERN_FULL = 0xFFFFu
}
 Enumeration of dummy patterns available to send when only one of the full duplex lines are used. More...
 
enum  DRV_SPI_DATA_SIZE_SELECT_E {
  DRV_SPI_DATA_SIZE_SELECT_RESET = 0x0ul,
  DRV_SPI_DATA_SIZE_SELECT_4b = 0x03ul,
  DRV_SPI_DATA_SIZE_SELECT_MIN = DRV_SPI_DATA_SIZE_SELECT_4b,
  DRV_SPI_DATA_SIZE_SELECT_5b = 0x04ul,
  DRV_SPI_DATA_SIZE_SELECT_6b = 0x05ul,
  DRV_SPI_DATA_SIZE_SELECT_7b = 0x06ul,
  DRV_SPI_DATA_SIZE_SELECT_8b = 0x07ul,
  DRV_SPI_DATA_SIZE_SELECT_DEFAULT = DRV_SPI_DATA_SIZE_SELECT_8b,
  DRV_SPI_DATA_SIZE_SELECT_9b = 0x08ul,
  DRV_SPI_DATA_SIZE_SELECT_10b = 0x09ul,
  DRV_SPI_DATA_SIZE_SELECT_11b = 0x0aul,
  DRV_SPI_DATA_SIZE_SELECT_12b = 0x0bul,
  DRV_SPI_DATA_SIZE_SELECT_13b = 0x0cul,
  DRV_SPI_DATA_SIZE_SELECT_14b = 0x0dul,
  DRV_SPI_DATA_SIZE_SELECT_15b = 0x0eul,
  DRV_SPI_DATA_SIZE_SELECT_16b = 0x0ful,
  DRV_SPI_DATA_SIZE_SELECT_MAX = DRV_SPI_DATA_SIZE_SELECT_16b
}
 Enumeration of the data size of a word transmitted. Has no impact on SQI devices. More...
 
enum  DRV_SPI_STATE_E {
  DRV_SPI_STATE_RX_FIFO_UNDERRUN = 0x1u << 31u,
  DRV_SPI_STATE_RX_FIFO_OVERFLOW = 0x1u << 30u,
  DRV_SPI_STATE_RX_FIFO_LVL_16b = 0x10u << 24u,
  DRV_SPI_STATE_RX_FIFO_LVL_08b = 0x8u << 24u,
  DRV_SPI_STATE_RX_FIFO_LVL_04b = 0x4u << 24u,
  DRV_SPI_STATE_RX_FIFO_LVL_02b = 0x2u << 24u,
  DRV_SPI_STATE_RX_FIFO_LVL_01b = 0x1u << 24u,
  DRV_SPI_STATE_TX_FIFO_UNDERRUN = 0x1u << 23u,
  DRV_SPI_STATE_TX_FIFO_OVERFLOW = 0x1u << 22u,
  DRV_SPI_STATE_TX_FIFO_LVL_16b = 0x10u << 16u,
  DRV_SPI_STATE_TX_FIFO_LVL_08b = 0x8u << 16u,
  DRV_SPI_STATE_TX_FIFO_LVL_04b = 0x4u << 16u,
  DRV_SPI_STATE_TX_FIFO_LVL_02b = 0x2u << 16u,
  DRV_SPI_STATE_TX_FIFO_LVL_01b = 0x1u << 16u,
  DRV_SPI_STATE_BUSY = 0x1u << 4u,
  DRV_SPI_STATE_RX_FIFO_FULL = 0x1u << 3u,
  DRV_SPI_STATE_RX_FIFO_NOT_EMPTY = 0x1u << 2u,
  DRV_SPI_STATE_TX_FIFO_NOT_FULL = 0x1u << 1u,
  DRV_SPI_STATE_TX_FIFO_EMPTY = 0x1u << 0
}
 Enumeration of the spi state informations. More...
 

Functions

static void DRV_SPI_Flush_DMA_Callback_Rx (void *ptDriverHandle, DRV_SPI_HANDLE_T *const ptDriver)
 
static void DRV_SPI_Flush_DMA_Callback_Tx (void *ptDriverHandle, DRV_SPI_HANDLE_T *const ptDriver)
 
DRV_STATUS_E DRV_SPI_HANDLE_T::DRV_SPI_Init (DRV_SPI_HANDLE_T *const ptDriver)
 This function initializes the DRV_SPI_HANDLE_T object. More...
 
DRV_STATUS_E DRV_SPI_HANDLE_T::DRV_SPI_DeInit (DRV_SPI_HANDLE_T *const ptDriver)
 This function disables the DRV_SPI_HANDLE_T object. More...
 
DRV_STATUS_E DRV_SPI_HANDLE_T::DRV_SPI_Transmit (DRV_SPI_HANDLE_T *const ptDriver, uint8_t *pcData, size_t size)
 Function for transmitting data of given size via the SPI device. More...
 
DRV_STATUS_E DRV_SPI_HANDLE_T::DRV_SPI_Receive (DRV_SPI_HANDLE_T *const ptDriver, uint8_t *pcData, size_t size)
 Function for receiveing data of given size by the SPI device. More...
 
DRV_STATUS_E DRV_SPI_HANDLE_T::DRV_SPI_TransmitReceive (DRV_SPI_HANDLE_T *const ptDriver, uint8_t *txData, uint8_t *rxData, size_t size)
 Function for transmitting and receiveing data at the same time of given size by the SPI device. More...
 
DRV_STATUS_E DRV_SPI_HANDLE_T::DRV_SPI_ChangeFss (DRV_SPI_HANDLE_T *const ptDriver, DRV_SPI_FSS_E eFss)
 Function for changing the fss between transactions. More...
 
DRV_STATUS_E DRV_SPI_HANDLE_T::DRV_SPI_Abort (DRV_SPI_HANDLE_T *const ptDriver)
 Function for aborting the current data transfer on the SPI device. More...
 
DRV_STATUS_E DRV_SPI_HANDLE_T::DRV_SPI_GetState (DRV_SPI_HANDLE_T *const ptDriver, DRV_SPI_STATE_E *const ptState)
 Function returning a driver spi state enumeration and a return code. More...
 
__STATIC_INLINE DRV_STATUS_E DRV_SPI_HANDLE_T::DRV_SPI_Flush_Buffers (DRV_SPI_HANDLE_T *const ptDriver)
 This function shall flush the software and hardware buffers of the device. More...
 
static DRV_STATUS_E DRV_SPI_HANDLE_T::DRV_SPI_Flush_POLL (DRV_SPI_HANDLE_T *const ptDriver)
 This method shall perform a flush by polling mode. More...
 
static DRV_STATUS_E DRV_SPI_HANDLE_T::DRV_SPI_Flush_IRQ (DRV_SPI_HANDLE_T *const ptDriver)
 This method shall perform a flush by interrupt mode. More...
 
static DRV_STATUS_E DRV_SPI_HANDLE_T::DRV_SPI_Flush_DMA (DRV_SPI_HANDLE_T *const ptDriver)
 This method shall perform a flush by dma mode. More...
 
__STATIC_INLINE void DRV_SPI_HANDLE_T::DRV_SPI_IRQ_Inline_Handler (DRV_SPI_DEVICE_ID_E const eDeviceID)
 

Variables

static DRV_SPI_DEVICE_U const s_apDeviceAddressTable [DRV_SPI_DEVICE_COUNT] = DRV_SPI_DEVICE_LIST
 Table of the device addresses. More...
 
static DRV_DMAC_PERIPHERAL_E const s_apDeviceDmacTable [DRV_SPI_DEVICE_COUNT] = DRV_SPI_DEVICE_DMA_LIST
 Table of the dma channels of the devices. More...
 
static IRQn_Type const s_apHandleIRQnTable [DRV_SPI_DEVICE_COUNT] = DRV_SPI_DEVICE_IRQ_LIST
 Table of the IRQ vector numbers. More...
 
static DRV_SPI_HANDLE_Ts_apHandleAddressTable [DRV_SPI_DEVICE_COUNT] = { 0 }
 Used for mapping the handle to an interrupt. More...
 

Detailed Description

The SPI driver, defined by DRV_SPI_HANDLE_T.

Macro Definition Documentation

#define DRV_HANDLE_CHECK (   handle)
Value:
;\
if((handle)==0){ \
return DRV_ERROR_PARAM; \
}\
if((handle)->ptDevice.ptSPI==0){ \
return DRV_ERROR_PARAM; \
}

Define for checking the consistency of the handle or static representation of the driver.

Definition at line 92 of file netx_drv_spi.c.

#define DRV_SPI_IRQHandler_Generator (   id,
 
)    DRV_Default_IRQHandler_Function_Generator(DRV_SPI_IRQ_HANDLER ## id,DRV_SPI_IRQ_Inline_Handler,(DRV_SPI_DEVICE_ID_E)(DRV_SPI_DEVICE_ID_MIN + id))

The generator define for generating irq handler source code.

Definition at line 1262 of file netx_drv_spi.c.

Enumeration Type Documentation

Enumeration of the master/slave mode.

Enumerator
DRV_SPI_BEHAVIOUR_MASTER 

Behaves as master.

DRV_SPI_BEHAVIOUR_SLAVE 

Behaves as slave

Definition at line 90 of file netx_drv_spi.h.

Enumeration of the data size of a word transmitted. Has no impact on SQI devices.

Enumerator
DRV_SPI_DATA_SIZE_SELECT_RESET 

Default value will be 8 bits

DRV_SPI_DATA_SIZE_SELECT_4b 

Size of 4 bits

DRV_SPI_DATA_SIZE_SELECT_MIN 

Smallest size is 4 bits

DRV_SPI_DATA_SIZE_SELECT_5b 

Size of 5 bits

DRV_SPI_DATA_SIZE_SELECT_6b 

Size of 6 bits

DRV_SPI_DATA_SIZE_SELECT_7b 

Size of 7 bits

DRV_SPI_DATA_SIZE_SELECT_8b 

Size of 8 bits

DRV_SPI_DATA_SIZE_SELECT_DEFAULT 

Default value will be 8 bits

DRV_SPI_DATA_SIZE_SELECT_9b 

Size of 9 bits

DRV_SPI_DATA_SIZE_SELECT_10b 

Size of 10 bits

DRV_SPI_DATA_SIZE_SELECT_11b 

Size of 11 bits

DRV_SPI_DATA_SIZE_SELECT_12b 

Size of 12 bits

DRV_SPI_DATA_SIZE_SELECT_13b 

Size of 13 bits

DRV_SPI_DATA_SIZE_SELECT_14b 

Size of 14 bits

DRV_SPI_DATA_SIZE_SELECT_15b 

Size of 15 bits

DRV_SPI_DATA_SIZE_SELECT_16b 

Size of 16 bits

DRV_SPI_DATA_SIZE_SELECT_MAX 

Largest dynamic size is 16 bits

Definition at line 264 of file netx_drv_spi.h.

Enumeration of dummy patterns available to send when only one of the full duplex lines are used.

Enumerator
DRV_SPI_DUMMYPATTERN_NULL 

nothing at all, just 0s

DRV_SPI_DUMMYPATTERN_ALTERNATING_0 

alternating starting with 0 (not available in QSPI)

DRV_SPI_DUMMYPATTERN_ALTERNATING_1 

alternating starting with 1 (not available in QSPI)

DRV_SPI_DUMMYPATTERN_FULL 

just 1s

Definition at line 252 of file netx_drv_spi.h.

Enumeration of the duplex mode.

Full duplex is only available for SPI mode. QSPI with 1/2/4 bit is only half duplex.

Enumerator
DRV_SPI_DUPLEX_HALF 

First edge

DRV_SPI_DUPLEX_FULL 

Second edge

Definition at line 126 of file netx_drv_spi.h.

Enumeration of the Endianess used.

This is necessary if more than 8 bit data size is selected.

Enumerator
DRV_SPI_ENDIANESS_LITTLE 

Little Endian

DRV_SPI_ENDIANESS_BIG 

Big Endian

Definition at line 182 of file netx_drv_spi.h.

Enumeration of the water mark level of the fifos.

Enumerator
DRV_SPI_FIFO_WM_RESET 

Water mark default level of 8 will be used.

DRV_SPI_FIFO_WM_MIN 

Minimal water mark level of 0

DRV_SPI_FIFO_WM_DEFAULT 

Default water mark level of 8

DRV_SPI_FIFO_WM_MAX 

Maximum water mark level of 16

Definition at line 201 of file netx_drv_spi.h.

Enumeration of the filter state.

Enumerator
DRV_SPI_FILTER_INACTIVE 

Disabled

DRV_SPI_FILTER_ACTIVE 

Enabled

Definition at line 233 of file netx_drv_spi.h.

Enumeration of the available frame formats of the spi.

Enumerator
DRV_SPI_FRAME_FORMAT_MOTOROLA 

The motorola spi format.

DRV_SPI_FRAME_FORMAT_RESERVED0 

Reserved

DRV_SPI_FRAME_FORMAT_RESERVED1 

Reserved

DRV_SPI_FRAME_FORMAT_RESERVED2 

Reserved

DRV_SPI_FRAME_FORMAT_MAX 

Used for boundary checking

Definition at line 212 of file netx_drv_spi.h.

Enumeration of useful spi frequencies.

The value is a clock divider.

Enumerator
DRV_SPI_FREQUENCY_STOPPED 

The SPI is stopped.

DRV_SPI_FREQUENCY_24_4KHz 

24KHz

DRV_SPI_FREQUENCY_48_8KHz 

48KHz

DRV_SPI_FREQUENCY_97_6KHz 

97KHz

DRV_SPI_FREQUENCY_195KHz 

195KHz

DRV_SPI_FREQUENCY_390KHz 

390KHz

DRV_SPI_FREQUENCY_781KHz 

0.8MHz

DRV_SPI_FREQUENCY_1_56MHz 

1.5MHz

DRV_SPI_FREQUENCY_3_125MHz 

3.125MHz

DRV_SPI_FREQUENCY_6_25MHz 

6.25MHz

DRV_SPI_FREQUENCY_12_5MHz 

12.5MHz

DRV_SPI_FREQUENCY_25MHz 

25MHz

DRV_SPI_FREQUENCY_50MHz 

50MHz

DRV_SPI_FREQUENCY_99MHz 

99MHz

DRV_SPI_FREQUENCY_MAX 

SPI maximum frequency

DRV_SPI_FREQUENCY_MIN 

SPI minimum frequency

Definition at line 67 of file netx_drv_spi.h.

Enumeration of the frame or slave select (FSS) signal pin mask.

This signal is commonly known as frame select FS, slave select SS or SSEL, chip select CS, chip enable CE or slave transmit enable STE.

Enumerator
DRV_SPI_FSS_NONE 

No fss selected

DRV_SPI_FSS_0 

Drive pin 0

DRV_SPI_FSS_1 

Drive pin 1

DRV_SPI_FSS_2 

Drive pin 2

DRV_SPI_FSS_ALL 

Drive all pins

Definition at line 53 of file netx_drv_spi.h.

Enumeration of the frame/chip select modes.

Enumerator
DRV_SPI_FSS_STATIC_HARDWARE 

FSS will be toggled after each word.

DRV_SPI_FSS_STATIC_DRIVER 

FSS is driver controlled. It is low while IO is performed. Otherwise a DIO should been used.

DRV_SPI_FSS_STATIC_CALLER 

FSS is controlled manually by the caller. Driver will not alter FSS on its own.

Definition at line 191 of file netx_drv_spi.h.

Enumeration of the loop back mode.

Enumerator
DRV_SPI_LOOP_BACK_MODE_INACTIVE 

Disabled

DRV_SPI_LOOP_BACK_MODE_ACTIVE 

Enabled

Definition at line 242 of file netx_drv_spi.h.

Enumeration of the mosi drive state as slave.

Enumerator
DRV_SPI_MISO_ACTIVE 

MISO activated

DRV_SPI_MISO_INACTIVE 

MISO deactivated

Definition at line 42 of file netx_drv_spi.h.

Enumeration of the sampling mode.

Enumerator
DRV_SPI_MODE_0 

CPOL 0 CPHA 0

DRV_SPI_MODE_1 

CPOL 0 CPHA 1

DRV_SPI_MODE_2 

CPOL 1 CPHA 0

DRV_SPI_MODE_3 

CPOL 1 CPHA 1

DRV_SPI_MODE_MIN 

Minimum value

DRV_SPI_MODE_MAX 

Maximum value

Definition at line 99 of file netx_drv_spi.h.

Enumeration of the parallelism.

It defines how many bits will be transmitted in parallel on each clock. 2/4 Bit are only available as QSPI half duplex mode.

Enumerator
DRV_SPI_PARALLELISM_1BIT 

Send one bit on MOSI and receive one on MISO. Regarding duplex configuration.

DRV_SPI_PARALLELISM_2BIT 

Send or receive on both MOSI and MISO simultaneously. Only half duplex allowed.

DRV_SPI_PARALLELISM_4BIT 

Send or receive on all four MOSI, MISO, IO2 and IO3 simultaneously. Only half duplex allowed.

DRV_SPI_PARALLELISM_MAX 

Max value.

DRV_SPI_PARALLELISM_MIN 

Min value.

Definition at line 138 of file netx_drv_spi.h.

Enumeration of the modes of the early response bit generation.

Enumerator
DRV_SPI_SLV_SIG_NOT_EARLY 

Generate first bit not early

DRV_SPI_SLV_SIG_EARLY 

Generate first bit early

Definition at line 224 of file netx_drv_spi.h.

Enumeration of the serial clock phase.

If the data is sampled at the rising/first or falling/second edge. (DRV_SPI_SPO_CLOCK_INACTIVE_LOW)

Enumerator
DRV_SPI_SPH_SAMPLE_AT_FIRST_EDGE 

First edge

DRV_SPI_SPH_SAMPLE_AT_SECOND_EDGE 

Second edge

Definition at line 115 of file netx_drv_spi.h.

Enumeration of the serial clock polarity.

Enumerator
DRV_SPI_SPO_CLOCK_INACTIVE_LOW 

low when inactive high when active

DRV_SPI_SPO_CLOCK_ACTIVE_LOW 

high when inactive low when active

DRV_SPI_SPO_CLOCK_INACTIVE_HIGH 

high when inactive low when active

DRV_SPI_SPO_CLOCK_ACTIVE_HIGH 

low when inactive high when active

Definition at line 151 of file netx_drv_spi.h.

Enumeration of the spi state informations.

Enumerator
DRV_SPI_STATE_RX_FIFO_UNDERRUN 

Rx fifo had an underrun

DRV_SPI_STATE_RX_FIFO_OVERFLOW 

Tx fifo had an overflow

DRV_SPI_STATE_RX_FIFO_LVL_16b 

Rx fifo level mask 16Bytes

DRV_SPI_STATE_RX_FIFO_LVL_08b 

Rx fifo level mask 8Bytes

DRV_SPI_STATE_RX_FIFO_LVL_04b 

Rx fifo level mask 4Bytes

DRV_SPI_STATE_RX_FIFO_LVL_02b 

Rx fifo level mask 2Bytes

DRV_SPI_STATE_RX_FIFO_LVL_01b 

Rx fifo level mask 1Bytes

DRV_SPI_STATE_TX_FIFO_UNDERRUN 

Tx fifo had an underrun

DRV_SPI_STATE_TX_FIFO_OVERFLOW 

Tx fifo had an overflow

DRV_SPI_STATE_TX_FIFO_LVL_16b 

Tx fifo level mask 16Bytes

DRV_SPI_STATE_TX_FIFO_LVL_08b 

Tx fifo level mask 8Bytes

DRV_SPI_STATE_TX_FIFO_LVL_04b 

Tx fifo level mask 4Bytes

DRV_SPI_STATE_TX_FIFO_LVL_02b 

Tx fifo level mask 2Bytes

DRV_SPI_STATE_TX_FIFO_LVL_01b 

Tx fifo level mask 1Bytes

DRV_SPI_STATE_BUSY 

Set if the device is not idle

DRV_SPI_STATE_RX_FIFO_FULL 

The Rx fifo is full

DRV_SPI_STATE_RX_FIFO_NOT_EMPTY 

The Rx fifo is not empty

DRV_SPI_STATE_TX_FIFO_NOT_FULL 

The Tx fifo is not full

DRV_SPI_STATE_TX_FIFO_EMPTY 

The Tx fifo is empty

Definition at line 288 of file netx_drv_spi.h.

Function Documentation

DRV_STATUS_E DRV_SPI_Abort ( DRV_SPI_HANDLE_T *const  ptDriver)

Function for aborting the current data transfer on the SPI device.

The abort function shall end pending interactions and reset any transaction. It forces the bus speed to zero and stops the device first, then sets the FSS to zero so that no peripheral is selected and masks all interrupts out or if dma is used calls the dma abort functionality. All buffers will then be reset and the device deactivated to reset its internal states. At last, the FSS and and bus speeds are set as configured again and the device is activated again.

Parameters
[in,out]ptDriverThe given handle of the drivers class
Returns
DRV_ERROR_PARAM DRV_LOCKED DRV_NSUPP DRV_OK

Definition at line 1068 of file netx_drv_spi.c.

Here is the call graph for this function:

DRV_STATUS_E DRV_SPI_ChangeFss ( DRV_SPI_HANDLE_T *const  ptDriver,
DRV_SPI_FSS_E  eFss 
)

Function for changing the fss between transactions.

The change fss function checks only if the driver is not locked and the device is not busy. If that is true the configuration attribute is changed like in the init method specified.

Parameters
[in,out]ptDriverThe given handle of the drivers class
[in]eFssThe new FSS state
Returns
DRV_ERROR_PARAM DRV_ERROR DRV_LOCKED DRV_BUSY DRV_NSUPP DRV_NIMPL DRV_OK

Definition at line 1031 of file netx_drv_spi.c.

Here is the call graph for this function:

DRV_STATUS_E DRV_SPI_DeInit ( DRV_SPI_HANDLE_T *const  ptDriver)

This function disables the DRV_SPI_HANDLE_T object.

The de-initialize function is supposed to reset the handle, the device and disable the interrupt signaling. The handle might be used afterwards again for initializing a SPI device driver handle.

Parameters
[in,out]ptDriverThe ptDriver to be deinitialized
Returns
DRV_OK DRV_LOCKED DRV_ERROR_PARAM

Definition at line 397 of file netx_drv_spi.c.

Here is the call graph for this function:

__STATIC_INLINE DRV_STATUS_E DRV_SPI_Flush_Buffers ( DRV_SPI_HANDLE_T *const  ptDriver)
private

This function shall flush the software and hardware buffers of the device.

This function is the hardware closest layer of the spi driver. The handle contains some variables defining the software buffer state. This state shall be equalized in this function. The transmit buffer is transfered to the transmit fifo of the device from the actual counter position to the given size. The receive fifo of the device is written to the current counter position until the given size is reached. If there is no buffer given, the function will transmit the dummy pattern specified in the attributes, and receives what is contained in the receive fifo but discard it.

Parameters
[in,out]ptDriverThe given handle of the drivers class
Returns
DRV_OK always, because there is no error condition occurring

Definition at line 424 of file netx_drv_spi.c.

Here is the caller graph for this function:

static DRV_STATUS_E DRV_SPI_Flush_DMA ( DRV_SPI_HANDLE_T *const  ptDriver)
private

This method shall perform a flush by dma mode.

It is the middle layer between the api calls and the flush itself.

Parameters
[in,out]ptDriverThe given handle of the drivers class
Returns
DRV_ERROR_PARAM DRV_ERROR DRV_LOCKED DRV_BUSY DRV_OK

Definition at line 624 of file netx_drv_spi.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void DRV_SPI_Flush_DMA_Callback_Rx ( void *  ptDriverHandle,
DRV_SPI_HANDLE_T *const  ptDriver 
)
static

This callback is used in dma operation mode. It is registered in the dmac api to get informed if the dma finished copying.

Definition at line 107 of file netx_drv_spi.c.

Here is the caller graph for this function:

static void DRV_SPI_Flush_DMA_Callback_Tx ( void *  ptDriverHandle,
DRV_SPI_HANDLE_T *const  ptDriver 
)
static

This callback is used in dma operation mode. It is registered in the dmac api to get informed if the dma finished copying.

Definition at line 130 of file netx_drv_spi.c.

Here is the caller graph for this function:

static DRV_STATUS_E DRV_SPI_Flush_IRQ ( DRV_SPI_HANDLE_T *const  ptDriver)
private

This method shall perform a flush by interrupt mode.

It is the middle layer between the api calls and the flush itself. Because every flow is handled in the interrupt handler this method only modifies the interrupt masks.

Parameters
[in,out]ptDriverThe given handle of the drivers class
Returns
DRV_OK

Definition at line 582 of file netx_drv_spi.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static DRV_STATUS_E DRV_SPI_Flush_POLL ( DRV_SPI_HANDLE_T *const  ptDriver)
private

This method shall perform a flush by polling mode.

This method is the middle layer between the api calls and the hardware close flushing. It contains the polling method specific functionalities. After calling the hardware near flushing function DRV_SPI_Flush_Buffers() and waiting, that all data has been flushed, it waits until the driver has transmitted everything on the media and is finished. Then the FSS can be reset if it is software controlled and the software buffers can be reset again.

Parameters
[in,out]ptDriverThe given handle of the drivers class
Returns
DRV_OK DRV_TOUT

Definition at line 532 of file netx_drv_spi.c.

Here is the call graph for this function:

Here is the caller graph for this function:

DRV_STATUS_E DRV_SPI_GetState ( DRV_SPI_HANDLE_T *const  ptDriver,
DRV_SPI_STATE_E *const  ptState 
)

Function returning a driver spi state enumeration and a return code.

The state of the driver is written to the ptSpiState pointer and an indicating status of the driver is returned. The returned status is the same as the other functions use to indicate a correct configure and idle driver and device ready for transmission. Because the error states depend mostly on the used transaction the spi state has to be checked by the caller. If a Tx buffer overflow occurs the function will return a DRV_ERROR because it is always an error.

Tx data has to be written to the spi device in master mode for reading data and TxBuffer underruns might occur. Rx data can be discarded in master mode for sending only but a RxBuffer overflow is produced. Rx data can be discarded in slave mode for sending only but a RxBuffer overflow is produced. Tx data might not be provided if a slave is reading only but a buffer underrun is produced.

Parameters
[in,out]ptDriverThe given handle of the drivers class.
[out]ptStatePointer to a DRV_SPI_STATE_E where the state is written to.
Returns
DRV_ERROR_PARAM DRV_ERROR_BUFFER DRV_BUSY DRV_OK

Definition at line 1159 of file netx_drv_spi.c.

Here is the caller graph for this function:

DRV_STATUS_E DRV_SPI_Init ( DRV_SPI_HANDLE_T *const  ptDriver)

This function initializes the DRV_SPI_HANDLE_T object.

The function takes a DRV_SPI_HANDLE_T pointer which contains a DRV_SPI_ATTRIBUTES_T structure. Those structure contains the configuration/initialization parameters of the device. While most attributes have valid default behavior, it is necessary to configure a bus speed and the DRV_SPI_DEVICE_ID_E

It is not possible to support all bus speeds by the driver. In future, there will be a matrix with configuration options and build options followed by possible speeds. At the moment we recommend to use DRV_SPI_Frequency_1_5625MHz as value for ulFrequency.

The SPIs initialize function forces the initialization of the SPI peripheral and the handle. The driver lock is set and the given parameters in the DRV_SPI_ATTRIBUTES_T structure are checked if there are parameter combinations not feasible. If everything is ok, the Buffers will be reset and the configuration registers are written, regarding the given attributes. At last the lock will be released.

Parameters
[out]ptDriverThe ptDriver to be
Returns
DRV_OK DRV_ERROR_PARAM DRV_NSUPP

Definition at line 167 of file netx_drv_spi.c.

Here is the call graph for this function:

__STATIC_INLINE void DRV_SPI_IRQ_Inline_Handler ( DRV_SPI_DEVICE_ID_E const  eDeviceID)
private

This function is the true interrupt service routine or interrupt handler of the SPI device interrupts. The interrupt handlers called by the controller should inline this handler and the constant eSPIDeviceID should define the specific device in compile time. For debug and development purposes a check of the pointers is performed in front that is not necessary for release. It is necessary because a debugger stopped controller does not perform a reset of the interrupt vector and so the ISR shall cope with the not initialized handle pointer.

After that the buffer flush is performed to transmit and receive data pending and then checks for the frame end are performed. If the frame has ended, the buffers and the FFS (if static) are reset.

Parameters
[in,out]eDeviceIDThe given id of the drivers class
Returns
void

Definition at line 1199 of file netx_drv_spi.c.

Here is the call graph for this function:

DRV_STATUS_E DRV_SPI_Receive ( DRV_SPI_HANDLE_T *const  ptDriver,
uint8_t *  pcData,
size_t  size 
)

Function for receiveing data of given size by the SPI device.

The receive function takes besides the this handle a data pointer and a size to perform the receiving of the given data. It will check consistency of the handle, the lockage of the driver api and checks if the driver is busy. After everything is ready for transmission the software buffers are configured and the FSS static is set if it is software controlled and the device is master. At last, the flushing is performed regarding the chosen control flow method, the driver is unlocked and the function returns.

Warning
In 2 and 4 byte parallelism the trailing bytes e.g. the fourth byte on a three byte receive might be overwritten.
Parameters
[in,out]ptDriverThe given handle of the drivers class
[out]pcDataPointer to the data to receive
[in]sizeAmount of chars to receive
Returns
DRV_ERROR_PARAM DRV_ERROR_BUFFER DRV_ERROR DRV_LOCKED DRV_BUSY DRV_NSUPP DRV_NIMPL DRV_OK

Definition at line 840 of file netx_drv_spi.c.

Here is the call graph for this function:

DRV_STATUS_E DRV_SPI_Transmit ( DRV_SPI_HANDLE_T *const  ptDriver,
uint8_t *  pcData,
size_t  size 
)

Function for transmitting data of given size via the SPI device.

The Transmit function takes besides the this handle a data pointer and a size to perform the transmission of the given data. It will check consistency of the handle, the locking of the driver api and checks if the driver is busy. After everything is ready for transmission the software buffers are set and the FSS static is set if it is software controlled and the device is master. At last, the flushing is performed regarding the chosen control flow method, the driver is unlocked and the function returns.

Parameters
[in,out]ptDriverThe given handle of the drivers class
[in]pcDataPointer to the data to transmit
[in]sizeAmount of chars to transmit
Returns
DRV_ERROR_PARAM DRV_ERROR_BUFFER DRV_ERROR DRV_LOCKED DRV_BUSY DRV_NSUPP DRV_NIMPL DRV_OK

Definition at line 723 of file netx_drv_spi.c.

Here is the call graph for this function:

DRV_STATUS_E DRV_SPI_TransmitReceive ( DRV_SPI_HANDLE_T *const  ptDriver,
uint8_t *  pcTxData,
uint8_t *  pcRxData,
size_t  size 
)

Function for transmitting and receiveing data at the same time of given size by the SPI device.

The receive and transmit function takes besides the this handle a data pointer and a size to perform the receiving and transmitting of the given data. It will check consistency of the handle, the lockage of the driver api and checks if the driver is busy. After everything is ready for transmission the software buffers are configured and the FSS static is set if it is software controlled and the device is master. At last, the flushing is performed regarding the chosen control flow method, the driver is unlocked and the function returns.

Parameters
[in,out]ptDriverThe given handle of the drivers class
[out]pcTxDataPointer to the data to transmit
[in]pcRxDataPointer to the data to receive
[in]sizeAmount of chars to receive
Returns
DRV_ERROR_PARAM DRV_ERROR_BUFFER DRV_ERROR DRV_LOCKED DRV_BUSY DRV_NSUPP DRV_NIMPL DRV_OK

Definition at line 956 of file netx_drv_spi.c.

Here is the call graph for this function:

Variable Documentation

DRV_SPI_DEVICE_U const s_apDeviceAddressTable[DRV_SPI_DEVICE_COUNT] = DRV_SPI_DEVICE_LIST
static

Table of the device addresses.

Used to identify the device addresses by the device id.

Definition at line 69 of file netx_drv_spi.c.

Table of the dma channels of the devices.

Definition at line 74 of file netx_drv_spi.c.

DRV_SPI_HANDLE_T* s_apHandleAddressTable[DRV_SPI_DEVICE_COUNT] = { 0 }
static

Used for mapping the handle to an interrupt.

Threadsafe and reentrant because its is only written in normal context an used in interrupt context of the specific interrupt.

Definition at line 86 of file netx_drv_spi.c.

IRQn_Type const s_apHandleIRQnTable[DRV_SPI_DEVICE_COUNT] = DRV_SPI_DEVICE_IRQ_LIST
static

Table of the IRQ vector numbers.

Used to identify the interrupt channels by the device id.

Definition at line 80 of file netx_drv_spi.c.