NetBurner 3.5.6
PDF Version
SPIModule Class Reference

SPI Peripheral Module Class. More...

#include <dspi.h>

Inherited by SPI_QSPI, and SPI_USART.

Public Member Functions

 SPIModule (uint8_t SPIModule)
 Create a SPI object.
 
 SPIModule (uint8_t SPIModule, uint32_t baudRateInBps, uint8_t transferSizeInBits=8, uint8_t peripheralChipSelects=0x00, uint8_t chipSelectPolarity=0x0F, uint8_t clockPolarity=0, uint8_t clockPhase=1, BOOL doutHiz=TRUE, uint8_t csToClockDelay=0, uint8_t delayAfterTransfer=0, uint8_t delayBetweenTransfer=0)
 Create a SPI object and Initialize with parameters.
 
virtual uint8_t Init (uint32_t baudRateInBps=2000000, uint8_t transferSizeInBits=8, uint8_t peripheralChipSelects=0x00, uint8_t chipSelectPolarity=0x0F, uint8_t clockPolarity=0, uint8_t clockPhase=1, BOOL doutHiz=TRUE, uint8_t csToClockDelay=0, uint8_t delayAfterTransfer=0)
 Initialize an existing SPI object.
 
virtual uint32_t SetBusSpeed (uint32_t maxSpeed)
 Set the SPI bus speed Will attempt to set the desired bus speed. It may be different based on the available system characteristics.
 
virtual uint8_t Start (uint8_t *transmitBufferPtr, volatile uint8_t *receiveBufferPtr, uint32_t byteCount, int csReturnToInactive=DEASSERT_AFTER_LAST)
 Start a SPI transfer.
 
virtual uint8_t Tx (uint8_t *transmitBufferPtr, uint32_t byteCount, int csReturnToInactive=DEASSERT_AFTER_LAST)
 Convenience function for unidirectional transmit.
 
virtual uint8_t Rx (uint8_t *receiveBufferPtr, uint32_t byteCount, int csReturnToInactive=DEASSERT_AFTER_LAST)
 Convenience function for unidirectional receive.
 
virtual bool RegisterSem (OS_SEM *finishedSem)
 Register a semaphore for the SPI module.
 
virtual bool ClrSem ()
 Clear a semaphore registration.
 
virtual OS_SEMGetSem ()
 Obtain a pointer to the SPI finished semaphore.
 
virtual bool Done ()
 Function to check SPI status.
 
virtual uint32_t GetActualBaudrate ()
 Returns the active baud rate.
 
virtual bool SetCS (uint8_t CS)
 Set the chip select configuration for the SPI object's bus transactions.
 
 SPIModule (uint8_t SPIModule)
 Create a SPI object.
 
 SPIModule (uint8_t SPIModule, uint32_t baudRateInBps, uint8_t transferSizeInBits=8, uint8_t peripheralChipSelects=0x00, uint8_t chipSelectPolarity=0x0F, uint8_t clockPolarity=0, uint8_t clockPhase=1, BOOL doutHiz=TRUE, uint8_t csToClockDelay=0, uint8_t delayAfterTransfer=0)
 Create a SPI object and Initialize with parameters.
 
 SPIModule (uint8_t SPIModule, uint32_t baudRateInBps, uint8_t transferSizeInBits=8, PinIO gpioChipSelect=PinDef_INVALID, uint8_t chipSelectPolarity=0x0F, uint8_t clockPolarity=0, uint8_t clockPhase=1, BOOL doutHiz=TRUE, uint8_t csToClockDelay=0, uint8_t delayAfterTransfer=0)
 Create a SPI object and Initialize with parameters.
 
virtual uint8_t Init (uint32_t baudRateInBps=2000000, uint8_t transferSizeInBits=8, uint8_t peripheralChipSelects=0x00, uint8_t chipSelectPolarity=0x0F, uint8_t clockPolarity=0, uint8_t clockPhase=1, BOOL doutHiz=TRUE, uint8_t csToClockDelay=0, uint8_t delayAfterTransfer=0)
 Initialize an existing SPI object.
 
virtual uint8_t Init (uint32_t baudRateInBps=2000000, uint8_t transferSizeInBits=8, PinIO gpioChipSelect=PinDef_INVALID, uint8_t chipSelectPolarity=0x0F, uint8_t clockPolarity=0, uint8_t clockPhase=1, BOOL doutHiz=TRUE, uint8_t csToClockDelay=0, uint8_t delayAfterTransfer=0)
 Initialize an existing SPI object.
 
virtual uint32_t SetBusSpeed (uint32_t maxSpeed)
 Set the SPI bus speed Will attempt to set the desired bus speed. It may be different based on the available system characteristics.
 
virtual uint8_t Start (uint8_t *transmitBufferPtr, volatile uint8_t *receiveBufferPtr, uint32_t byteCount, int csReturnToInactive=DEASSERT_AFTER_LAST)
 Start a SPI transfer.
 
virtual uint8_t Tx (uint8_t *transmitBufferPtr, uint32_t byteCount, int csReturnToInactive=DEASSERT_AFTER_LAST)
 Convenience function for unidirectional transmit.
 
virtual uint8_t Rx (uint8_t *receiveBufferPtr, uint32_t byteCount, int csReturnToInactive=DEASSERT_AFTER_LAST)
 Convenience function for unidirectional receive.
 
virtual bool RegisterSem (OS_SEM *finishedSem)
 Register a semaphore for the SPI module.
 
virtual bool ClrSem ()
 Clear a semaphore registration.
 
virtual OS_SEMGetSem ()
 Obtain a pointer to the SPI finished semaphore.
 
virtual bool Done ()
 Function to check SPI status.
 
virtual uint32_t GetActualBaudrate ()
 Returns the active baud rate.
 
virtual bool SetCS (uint8_t CS)
 Set the chip select configuration for the SPI object's bus transactions.
 

Static Public Member Functions

static BOOL Done (uint8_t SPIModule)
 Static function to check SPI status.
 
static BOOL Done (uint8_t SPIModule)
 Static function to check SPI status.
 

Detailed Description

SPI Peripheral Module Class.

Class definition for SPI module objects

Constructor & Destructor Documentation

◆ SPIModule() [1/5]

SPIModule::SPIModule ( uint8_t SPIModule)

Create a SPI object.

This constructor will create the object, but will not initialize the SPI module. You must call the Init() member function to initialize.

Parameters
SPIModuleSPI module number (0 or 1)

◆ SPIModule() [2/5]

SPIModule::SPIModule ( uint8_t SPIModule,
uint32_t baudRateInBps,
uint8_t transferSizeInBits = 8,
uint8_t peripheralChipSelects = 0x00,
uint8_t chipSelectPolarity = 0x0F,
uint8_t clockPolarity = 0,
uint8_t clockPhase = 1,
BOOL doutHiz = TRUE,
uint8_t csToClockDelay = 0,
uint8_t delayAfterTransfer = 0,
uint8_t delayBetweenTransfer = 0 )

Create a SPI object and Initialize with parameters.

Creaets a SPI object and initializes the SPI module. You do not need to call the Init() member function.

Parameters
SPIModuleSPI module number (0 or 1)
baudRateInBpsMaximum baud rate requested
transferSizeInBitsNumber of bits per transfer: 8, 16 or 32
peripheralChipSelectsSPI chip selects to use for transfer spiChipSelect
chipSelectPolarityParameter not supported on the MODM7AE70. Chip select asserts with logic level low. spiChipSelectPolarity
clockPolarity0 = inactive logic level low, 1 = high
clockPhase0 = data captured leading edge clock, changed following edge. 1 = data changed leading edge clock, captured following edge.
doutHizData output high impedance between transfers
csToClockDelayDelay from chip select to valid clock (default is 0)
delayAfterTransferChip select mode dspiChipSelectMode
delayBetweenTransferMin Delay between transfers

◆ SPIModule() [3/5]

SPIModule::SPIModule ( uint8_t SPIModule)

Create a SPI object.

This constructor will create the object, but will not initialize the SPI module. You must call the Init() member function to initialize.

Parameters
SPIModuleSPI module number

◆ SPIModule() [4/5]

SPIModule::SPIModule ( uint8_t SPIModule,
uint32_t baudRateInBps,
uint8_t transferSizeInBits = 8,
uint8_t peripheralChipSelects = 0x00,
uint8_t chipSelectPolarity = 0x0F,
uint8_t clockPolarity = 0,
uint8_t clockPhase = 1,
BOOL doutHiz = TRUE,
uint8_t csToClockDelay = 0,
uint8_t delayAfterTransfer = 0 )

Create a SPI object and Initialize with parameters.

Creaets a SPI object and initializes the SPI module. You do not need to call the Init() member function.

Parameters
SPIModuleSPI module number (0 or 1)
baudRateInBpsMaximum baud rate requested
transferSizeInBitsNumber of bits per transfer: 8, 16 or 32
peripheralChipSelectsSPI chip selects to use for transfer spiChipSelect
chipSelectPolarityParameter not supported on the SOMRT1061. Chip select asserts with logic level low. spiChipSelectPolarity
clockPolarity0 = inactive logic level low, 1 = high
clockPhase0 = data captured leading edge clock, changed following edge. 1 = data changed leading edge clock, captured following edge.
doutHizData output high impedance between transfers
csToClockDelayDelay from chip select to valid clock (default is 0)
delayAfterTransferChip select mode dspiChipSelectMode

◆ SPIModule() [5/5]

SPIModule::SPIModule ( uint8_t SPIModule,
uint32_t baudRateInBps,
uint8_t transferSizeInBits = 8,
PinIO gpioChipSelect = PinDef_INVALID,
uint8_t chipSelectPolarity = 0x0F,
uint8_t clockPolarity = 0,
uint8_t clockPhase = 1,
BOOL doutHiz = TRUE,
uint8_t csToClockDelay = 0,
uint8_t delayAfterTransfer = 0 )

Create a SPI object and Initialize with parameters.

Creaets a SPI object and initializes the SPI module. You do not need to call the Init() member function.

Parameters
SPIModuleSPI module number (0 or 1)
baudRateInBpsMaximum baud rate requested
transferSizeInBitsNumber of bits per transfer: 8, 16 or 32
gpioChipSelectPinIO to be configured as GPIO and used as chip select. Only supports spiDriverStruct::csReturnToInactive values of DEASSERT_AFTER_LAST and DEASSERT_NEVER
chipSelectPolarityParameter not supported on the SOMRT1061. Chip select asserts with logic level low. spiChipSelectPolarity
clockPolarity0 = inactive logic level low, 1 = high
clockPhase0 = data captured leading edge clock, changed following edge. 1 = data changed leading edge clock, captured following edge.
doutHizData output high impedance between transfers
csToClockDelayDelay from chip select to valid clock (default is 0)
delayAfterTransferChip select mode dspiChipSelectMode

Member Function Documentation

◆ ClrSem() [1/2]

virtual bool SPIModule::ClrSem ( )
inlinevirtual

Clear a semaphore registration.

Returns
true if the clear was successful, false if a SPI transaction is in progress

◆ ClrSem() [2/2]

virtual bool SPIModule::ClrSem ( )
inlinevirtual

Clear a semaphore registration.

Returns
true if the clear was successful, false if a SPI transaction is in progress

◆ Done() [1/4]

virtual bool SPIModule::Done ( )
inlinevirtual

Function to check SPI status.

Called as a class method on a specific SPI object. For example: MySpi.Done()

Returns
true if SPI is finished, false if active

◆ Done() [2/4]

virtual bool SPIModule::Done ( )
inlinevirtual

Function to check SPI status.

Called as a class method on a specific SPI object. For example: MySpi.Done()

Returns
true if SPI is finished, false if active

◆ Done() [3/4]

static BOOL SPIModule::Done ( uint8_t SPIModule)
static

Static function to check SPI status.

Is called as a class wide static method. For example: SPIModule::Done(0)

Parameters
SPIModuleThe SPI module to check, 0, 1 or 2
Returns
true if SPI is finished, false if active

◆ Done() [4/4]

static BOOL SPIModule::Done ( uint8_t SPIModule)
static

Static function to check SPI status.

Is called as a class wide static method. For example: SPIModule::Done(0)

Parameters
SPIModuleThe SPI module to check, 0, 1 or 2
Returns
true if SPI is finished, false if active

◆ GetActualBaudrate() [1/2]

virtual uint32_t SPIModule::GetActualBaudrate ( )
inlinevirtual

Returns the active baud rate.

The baud rate will be set to the value specified when the SPI module is initialized. If that value is not possible, the next lowest baud rate will be chosen.

Returns
The actual SPI module baud rate

◆ GetActualBaudrate() [2/2]

virtual uint32_t SPIModule::GetActualBaudrate ( )
inlinevirtual

Returns the active baud rate.

The baud rate will be set to the value specified when the SPI module is initialized. If that value is not possible, the next lowest baud rate will be chosen.

Returns
The actual SPI module baud rate

◆ GetSem() [1/2]

virtual OS_SEM * SPIModule::GetSem ( )
inlinevirtual

Obtain a pointer to the SPI finished semaphore.

Returns
A pointer to the semaphore

◆ GetSem() [2/2]

virtual OS_SEM * SPIModule::GetSem ( )
inlinevirtual

Obtain a pointer to the SPI finished semaphore.

Returns
A pointer to the semaphore

◆ Init() [1/3]

virtual uint8_t SPIModule::Init ( uint32_t baudRateInBps = 2000000,
uint8_t transferSizeInBits = 8,
PinIO gpioChipSelect = PinDef_INVALID,
uint8_t chipSelectPolarity = 0x0F,
uint8_t clockPolarity = 0,
uint8_t clockPhase = 1,
BOOL doutHiz = TRUE,
uint8_t csToClockDelay = 0,
uint8_t delayAfterTransfer = 0 )
virtual

Initialize an existing SPI object.

Parameters
baudRateInBpsMaximum baud rate requested
transferSizeInBitsNumber of bits per transfer: 8, 16 or 32
gpioChipSelectPinIO to be configured as GPIO and used as chip select. Only supports spiDriverStruct::csReturnToInactive values of DEASSERT_AFTER_LAST and DEASSERT_NEVER
chipSelectPolarityParameter not supported on the SOMRT1061. Chip select asserts with logic level low. spiChipSelectPolarity
clockPolarity0 = inactive logic level low, 1 = high
clockPhase0 = data captured leading edge clock, changed following edge. 1 = data changed leading edge clock, captured following edge.
doutHizData output high impedance between transfers
csToClockDelayDelay from chip select to valid clock (default is 0)
delayAfterTransferChip select mode dspiChipSelectMode
Returns
The current state of the SPI bus dspiState

◆ Init() [2/3]

virtual uint8_t SPIModule::Init ( uint32_t baudRateInBps = 2000000,
uint8_t transferSizeInBits = 8,
uint8_t peripheralChipSelects = 0x00,
uint8_t chipSelectPolarity = 0x0F,
uint8_t clockPolarity = 0,
uint8_t clockPhase = 1,
BOOL doutHiz = TRUE,
uint8_t csToClockDelay = 0,
uint8_t delayAfterTransfer = 0 )
virtual

Initialize an existing SPI object.

Parameters
baudRateInBpsMaximum baud rate requested
transferSizeInBitsNumber of bits per transfer: 8, 16 or 32
peripheralChipSelectsSPI chip selects to use for transfer spiChipSelect
chipSelectPolarityParameter not supported on the SOMRT1061. Chip select asserts with logic level low. spiChipSelectPolarity
clockPolarity0 = inactive logic level low, 1 = high
clockPhase0 = data captured leading edge clock, changed following edge. 1 = data changed leading edge clock, captured following edge.
doutHizData output high impedance between transfers
csToClockDelayDelay from chip select to valid clock (default is 0)
delayAfterTransferChip select mode dspiChipSelectMode
Returns
The current state of the SPI bus dspiState

Reimplemented in SPI_QSPI, and SPI_USART.

◆ Init() [3/3]

virtual uint8_t SPIModule::Init ( uint32_t baudRateInBps = 2000000,
uint8_t transferSizeInBits = 8,
uint8_t peripheralChipSelects = 0x00,
uint8_t chipSelectPolarity = 0x0F,
uint8_t clockPolarity = 0,
uint8_t clockPhase = 1,
BOOL doutHiz = TRUE,
uint8_t csToClockDelay = 0,
uint8_t delayAfterTransfer = 0 )
virtual

Initialize an existing SPI object.

Parameters
baudRateInBpsMaximum baud rate requested
transferSizeInBitsNumber of bits per transfer: 8, 16 or 32
peripheralChipSelectsSPI chip selects to use for transfer spiChipSelect
chipSelectPolarityParameter not supported on the MODM7AE70. Chip select asserts with logic level low. spiChipSelectPolarity
clockPolarity0 = inactive logic level low, 1 = high
clockPhase0 = data captured leading edge clock, changed following edge. 1 = data changed leading edge clock, captured following edge.
doutHizData output high impedance between transfers
csToClockDelayDelay from chip select to valid clock (default is 0)
delayAfterTransferChip select mode dspiChipSelectMode
Returns
The current state of the SPI bus dspiState

Reimplemented in SPI_QSPI, and SPI_USART.

◆ RegisterSem() [1/2]

virtual bool SPIModule::RegisterSem ( OS_SEM * finishedSem)
virtual

Register a semaphore for the SPI module.

The SPI module will post to this semaphore when a transaction is complete

Parameters
finishedSemPointer to the semaphore
Returns
true if the registration was successful, false if a SPI transaction is in progress

◆ RegisterSem() [2/2]

virtual bool SPIModule::RegisterSem ( OS_SEM * finishedSem)
virtual

Register a semaphore for the SPI module.

The SPI module will post to this semaphore when a transaction is complete

Parameters
finishedSemPointer to the semaphore
Returns
true if the registration was successful, false if a SPI transaction is in progress

◆ Rx() [1/2]

virtual uint8_t SPIModule::Rx ( uint8_t * receiveBufferPtr,
uint32_t byteCount,
int csReturnToInactive = DEASSERT_AFTER_LAST )
inlinevirtual

Convenience function for unidirectional receive.

Parameters
*receiveBufferPtrPointer to the buffer to store incomeing data
byteCountNumber of bytes to transmit
csReturnToInactiveChip select state
Returns
The current state of the SPI bus dspiState

Reimplemented in SPI_QSPI, and SPI_USART.

◆ Rx() [2/2]

virtual uint8_t SPIModule::Rx ( uint8_t * receiveBufferPtr,
uint32_t byteCount,
int csReturnToInactive = DEASSERT_AFTER_LAST )
inlinevirtual

Convenience function for unidirectional receive.

Parameters
*receiveBufferPtrPointer to the buffer to store incomeing data
byteCountNumber of bytes to transmit
csReturnToInactiveChip select state
Returns
The current state of the SPI bus dspiState

Reimplemented in SPI_QSPI, and SPI_USART.

◆ SetBusSpeed() [1/2]

virtual uint32_t SPIModule::SetBusSpeed ( uint32_t maxSpeed)
virtual

Set the SPI bus speed Will attempt to set the desired bus speed. It may be different based on the available system characteristics.

Parameters
maxSpeedThe maximum desired bus speed
Returns
The actual bus speed

Reimplemented in SPI_QSPI, and SPI_USART.

◆ SetBusSpeed() [2/2]

virtual uint32_t SPIModule::SetBusSpeed ( uint32_t maxSpeed)
virtual

Set the SPI bus speed Will attempt to set the desired bus speed. It may be different based on the available system characteristics.

Parameters
maxSpeedThe maximum desired bus speed
Returns
The actual bus speed

Reimplemented in SPI_QSPI, and SPI_USART.

◆ SetCS() [1/2]

virtual bool SPIModule::SetCS ( uint8_t CS)
inlinevirtual

Set the chip select configuration for the SPI object's bus transactions.

If an invalid CS number is given, a default chip select of 0 is used.

Parameters
CSChip select to set, 0 - 3.
Returns
true if successful, false if SPI is currently active

Reimplemented in SPI_QSPI, and SPI_USART.

◆ SetCS() [2/2]

virtual bool SPIModule::SetCS ( uint8_t CS)
inlinevirtual

Set the chip select configuration for the SPI object's bus transactions.

Parameters
CSChip select to set, 0 - 3.
Returns
true if successful, false if SPI is currently active

Reimplemented in SPI_QSPI, and SPI_USART.

◆ Start() [1/2]

virtual uint8_t SPIModule::Start ( uint8_t * transmitBufferPtr,
volatile uint8_t * receiveBufferPtr,
uint32_t byteCount,
int csReturnToInactive = DEASSERT_AFTER_LAST )
virtual

Start a SPI transfer.

  • If configured for 8 bits per transfer then the data must be uint8_t aligned
  • If configured for > than 8 bits per transfer then the data must be uint16_t aligned
  • If configured for > than 16 bits per transfer then the data must be uint32_t aligned
  • If either RX or TX pointer is assigned 'null' then that communication direction will not occur.
  • If DSPI_Finished points to a semaphore, then the DSPI will POST to it when the transfer is complete.
  • The semaphore is optional, but it can increase efficiency.
Parameters
transmitBufferPtrPointer to the buffer containing the data to transmit
receiveBufferPtrPointer to the buffer to store the received data
byteCountNumber of bytes to transmit
csReturnToInactiveChip select state
Returns
The current state of the SPI bus dspiState

Reimplemented in SPI_QSPI, and SPI_USART.

◆ Start() [2/2]

virtual uint8_t SPIModule::Start ( uint8_t * transmitBufferPtr,
volatile uint8_t * receiveBufferPtr,
uint32_t byteCount,
int csReturnToInactive = DEASSERT_AFTER_LAST )
virtual

Start a SPI transfer.

  • If configured for 8 bits per transfer then the data must be uint8_t aligned
  • If configured for > than 8 bits per transfer then the data must be uint16_t aligned
  • If configured for > than 16 bits per transfer then the data must be uint32_t aligned
  • If either RX or TX pointer is assigned 'null' then that communication direction will not occur.
  • If DSPI_Finished points to a semaphore, then the DSPI will POST to it when the transfer is complete.
  • The semaphore is optional, but it can increase efficiency.
Parameters
transmitBufferPtrPointer to the buffer containing the data to transmit
receiveBufferPtrPointer to the buffer to store the received data
byteCountNumber of bytes to transmit
csReturnToInactiveChip select state
Returns
The current state of the SPI bus dspiState

Reimplemented in SPI_QSPI, and SPI_USART.

◆ Tx() [1/2]

virtual uint8_t SPIModule::Tx ( uint8_t * transmitBufferPtr,
uint32_t byteCount,
int csReturnToInactive = DEASSERT_AFTER_LAST )
inlinevirtual

Convenience function for unidirectional transmit.

Parameters
*transmitBufferPtrPointer to the buffer containing the data to transmit
byteCountNumber of bytes to transmit
csReturnToInactiveChip select state
Returns
The current state of the SPI bus dspiState

Reimplemented in SPI_QSPI, and SPI_USART.

◆ Tx() [2/2]

virtual uint8_t SPIModule::Tx ( uint8_t * transmitBufferPtr,
uint32_t byteCount,
int csReturnToInactive = DEASSERT_AFTER_LAST )
inlinevirtual

Convenience function for unidirectional transmit.

Parameters
*transmitBufferPtrPointer to the buffer containing the data to transmit
byteCountNumber of bytes to transmit
csReturnToInactiveChip select state
Returns
The current state of the SPI bus dspiState

Reimplemented in SPI_QSPI, and SPI_USART.


The documentation for this class was generated from the following files: