NetBurner 3.5.6
PDF Version
SPI_USART Class Reference

USART in SPI mode Peripheral Module Class. More...

#include <usart.h>

Inherits SPIModule.

Public Member Functions

 SPI_USART (uint8_t USARTModule)
 Create a SPI object.
 
 SPI_USART (uint8_t USARTModule, 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.
 
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) override
 Initialize an existing SPI object.
 
virtual uint32_t SetBusSpeed (uint32_t maxSpeed) override
 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) override
 Start a SPI transfer.
 
virtual uint8_t Tx (uint8_t *transmitBufferPtr, uint32_t byteCount, int csReturnToInactive=DEASSERT_AFTER_LAST) override
 Convenience function for unidirectional transmit.
 
uint8_t Rx (uint8_t *receiveBufferPtr, uint32_t byteCount, int csReturnToInactive=DEASSERT_AFTER_LAST)
 Convenience function for unidirectional receive.
 
virtual bool SetCS (uint8_t CS) override
 Set the chip select configuration for the SPI object's bus transactions.
 
- Public Member Functions inherited from SPIModule
 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 bool RegisterSem (OS_SEM *finishedSem)
 Register a semaphore for the SPI module.
 
virtual bool ClrSem ()
 Clear a semaphore registration.
 
virtual OS_SEM * GetSem ()
 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.
 
 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, 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 bool RegisterSem (OS_SEM *finishedSem)
 Register a semaphore for the SPI module.
 
virtual bool ClrSem ()
 Clear a semaphore registration.
 
virtual OS_SEM * GetSem ()
 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.
 

Additional Inherited Members

- Static Public Member Functions inherited from SPIModule
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

USART in SPI mode Peripheral Module Class.

Class definition for SPI module objects

Constructor & Destructor Documentation

◆ SPI_USART() [1/2]

SPI_USART::SPI_USART ( uint8_t USARTModule)

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
USARTModuleSPI module number (0 or 1)

◆ SPI_USART() [2/2]

SPI_USART::SPI_USART ( uint8_t USARTModule,
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
USARTModuleUSART 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
chipSelectPolarity0 = inactive logic level low, 1 = high
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
csToClockDelayThis option is not supported by the USART peripheral in SPI mode.
delayAfterTransferThis option is not supported by the USART peripheral in SPI mode.

Member Function Documentation

◆ Init()

virtual uint8_t SPI_USART::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 )
overridevirtual

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
chipSelectPolarity0 = inactive logic level low, 1 = high
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
csToClockDelayThis option is not supported by the USART peripheral in SPI mode.
delayAfterTransferThis option is not supported by the USART peripheral in SPI mode.
Returns
The current state of the SPI bus dspiState

Reimplemented from SPIModule.

◆ Rx()

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

Convenience function for unidirectional receive.

Parameters
receiveBufferPtrPointer to the buffer to write the received data
byteCountNumber of bytes to transmit
csReturnToInactiveChip select state
Returns
The current state of the SPI bus dspiState

Reimplemented from SPIModule.

◆ SetBusSpeed()

virtual uint32_t SPI_USART::SetBusSpeed ( uint32_t maxSpeed)
overridevirtual

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 from SPIModule.

◆ SetCS()

virtual bool SPI_USART::SetCS ( uint8_t CS)
inlineoverridevirtual

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 from SPIModule.

◆ Start()

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

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.
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 from SPIModule.

◆ Tx()

virtual uint8_t SPI_USART::Tx ( uint8_t * transmitBufferPtr,
uint32_t byteCount,
int csReturnToInactive = DEASSERT_AFTER_LAST )
inlineoverridevirtual

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 from SPIModule.


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