|
NetBurner 3.5.6
PDF Version |
DSPIModule is a SPI communications driver. It is an object based driver, which allows for low overhead multiplexing between peripherals with different bus configurations. More...
#include <dspi.h>
Public Member Functions | |
| DSPIModule (uint8_t SPIModule) | |
| The minimum DSPIModule Constructor. Requires that configuration settings be applied after construction before use. | |
| DSPIModule (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) | |
| DSPIModule Full DSPIModule Constructor. Will initialize all hardware settings. | |
| 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) |
| DSPIModule Full DSPIModule Constructor. Will initialize all hardware settings. | |
| uint8_t | Start (uint8_t *transmitBufferPtr, volatile uint8_t *receiveBufferPtr, uint32_t byteCount, int csReturnToInactive=DEASSERT_AFTER_LAST) |
| Start begins a SPI transaction using the provided buffers. | |
| uint8_t | Tx (uint8_t *transmitBufferPtr, uint32_t byteCount, int csReturnToInactive=DEASSERT_AFTER_LAST) |
| Tx begins a transmit only SPI transaction using the provided buffer. Silently discards the received data. | |
| uint8_t | Rx (uint8_t *receiveBufferPtr, uint32_t byteCount, int csReturnToInactive=DEASSERT_AFTER_LAST) |
| Rx begins a receive only SPI transaction using the provided buffer. Holds output line low during transfers. | |
| bool | EnableDMA (bool enableDMA=true) |
| EnableDMA configures whether DMA is allowed for qualifying transactions. | |
| bool | DisableDMA () |
| DisableDMA disables DMA for all transactions. | |
| bool | RegisterSem (OS_SEM *finishedSem) |
| Registers a semaphore to be posted to upon completion of transactions. | |
| bool | ClrSem () |
| Clears the semaphore registration. | |
| OS_SEM * | GetSem () |
| Gets a pointer to the registered Semaphore. | |
| bool | Done () |
| Returns whether the previously started transaction is complete. | |
| uint32_t | GetActualBaudrate () |
| Returns the actual bus speed to be used. | |
| bool | SetCS (uint8_t CS) |
| Modifies the chip select configuration for the driver context such that only the requested chip select is active during transfers. | |
Static Public Member Functions | |
| static BOOL | Done (uint8_t SPIModule) |
| Returns whether the previously started transaction for a given hardware module is complete. | |
Friends | |
| uint8_t | DSPIInit (uint8_t SPIModule=DEFAULT_DSPI_MODULE, uint32_t Baudrate=2000000, uint8_t QueueBitSize=8, uint8_t CS=0x00, uint8_t CSPol=0x0F, uint8_t ClkPolarity=0, uint8_t ClkPhase=1, BOOL DoutHiz=TRUE, uint8_t QCD=0, uint8_t DTL=0) |
| Initialize a DSPI module. | |
DSPIModule is a SPI communications driver. It is an object based driver, which allows for low overhead multiplexing between peripherals with different bus configurations.
| DSPIModule::DSPIModule | ( | uint8_t | SPIModule | ) |
The minimum DSPIModule Constructor. Requires that configuration settings be applied after construction before use.
| SPIModule | The DSPI module to use, from 1 to 3. Default is 1. |
| DSPIModule::DSPIModule | ( | 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 ) |
DSPIModule Full DSPIModule Constructor. Will initialize all hardware settings.
| SPIModule | The DSPI module to use, from 1 to 3. Default is 1. |
| baudRateInBps | Maximum master clock frequency for SPI Bus in bits per second. |
| transferSizeInBits | Bit width of the transfers to be made. |
| peripheralChipSelects | Bit mask of which chipselects are active during transfers. |
| chipSelectPolarity | Bit mask of the inactive state of chipselects. |
| clockPolarity | Inactive level for the clock signal. |
| clockPhase | Clock phase:
|
| doutHiz | Data output is high impedance between transfers (instead of driven). |
| csToClockDelay | Delay from chip select to valid clock. The default of 0 will set the delay as close to 1/2 DSPI_CLK without going under, keeping with the interface to QSPI driver. |
| delayAfterTransfer | Delay between data transfers. The default of 0 is 17/(system clock / 2), in keeping with interface to QSPI |
|
inline |
Clears the semaphore registration.
|
inline |
DisableDMA disables DMA for all transactions.
|
inline |
Returns whether the previously started transaction is complete.
|
static |
Returns whether the previously started transaction for a given hardware module is complete.
| SPIModule | The hardware instance to check the transaction state for. |
| bool DSPIModule::EnableDMA | ( | bool | enableDMA = true | ) |
EnableDMA configures whether DMA is allowed for qualifying transactions.
| enableDMA | Whether DMA is allowed |
|
inline |
Returns the actual bus speed to be used.
|
inline |
Gets a pointer to the registered Semaphore.
| uint8_t DSPIModule::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 ) |
DSPIModule Full DSPIModule Constructor. Will initialize all hardware settings.
param SPIModule The instance number of the hardware module to use with this driver context.
| baudRateInBps | Maximum master clock frequency for SPI Bus |
| transferSizeInBits | Bit width of the transfers to be made |
| peripheralChipSelects | Bit mask of which chipselects are active during transfers |
| chipSelectPolarity | Bit mask of the inactive state of chipselects |
| clockPolarity | Inactive level for the clock signal |
| clockPhase |
|
| doutHiz | Data output is high impedance between transfers (instead of driven) |
| csToClockDelay | Delay form chip select to valid clock. The default of 0 will set the delay as close to 1/2 DSPI_CLK without going under, keeping with the interface to QSPI driver. |
| delayAfterTransfer | Delay between data transfers. The default of 0 is 17/(system clock / 2), in keepin with interface to QSPI |
| bool DSPIModule::RegisterSem | ( | OS_SEM * | finishedSem | ) |
Registers a semaphore to be posted to upon completion of transactions.
| finishedSem | A pointer to the semaphore to be posted to. |
|
inline |
Rx begins a receive only SPI transaction using the provided buffer. Holds output line low during transfers.
| receiveBufferPtr | A pointer to the buffer to write received data to. If the buffer is NULL, then receive data will silently be discarded. |
| byteCount | The number of bytes to send and receive in this transaction. The value must be a multiple of the number of bytes in each individual transfer. |
| csReturnToInactive | Configures when the ChipSelect that is used for the transaction should be deasserted and return to being inactive. |
|
inline |
Modifies the chip select configuration for the driver context such that only the requested chip select is active during transfers.
| CS | The chip select number to assert during transfers. |
| uint8_t DSPIModule::Start | ( | uint8_t * | transmitBufferPtr, |
| volatile uint8_t * | receiveBufferPtr, | ||
| uint32_t | byteCount, | ||
| int | csReturnToInactive = DEASSERT_AFTER_LAST ) |
Start begins a SPI transaction using the provided buffers.
| transmitBufferPtr | A pointer to the buffer containing data to be sent out. If the buffer is NULL, the bus will be held low instead. |
| receiveBufferPtr | A pointer to the buffer to write received data to. If the buffer is NULL, then receive data will silently be discarded. |
| byteCount | The number of bytes to send and receive in this transaction. The value must be a multiple of the number of bytes in each individual transfer. |
| csReturnToInactive | Configures when the ChipSelect that is used for the transaction should be deasserted and return to being inactive. |
|
inline |
Tx begins a transmit only SPI transaction using the provided buffer. Silently discards the received data.
| transmitBufferPtr | A pointer to the buffer containing data to be sent out. If the buffer is NULL, the bus will be held low instead. |
| byteCount | The number of bytes to send and receive in this transaction. The value must be a multiple of the number of bytes in each individual transfer. |
| csReturnToInactive | Configures when the ChipSelect that is used for the transaction should be deasserted and return to being inactive. |
|
friend |
Initialize a DSPI module.
Notes:
| SPIModule | SPI module number, 0 - 1 |
| Baudrate | Maximum baud rate requested |
| QueueBitSize | Number of bits per transfer: 8, 16 or 32 |
| CS | SPI chip selects to use for transfer |
| CSPol | 0 = inactive logic level low, 1 = high |
| ClkPolarity | 0 = inactive logic level low, 1 = high |
| ClkPhase | 0 = data captured leading edge clock, changed following edge. 1 = data changed leading edge clock, captured following edge. |
| DoutHiz | Data output high impedance between transfers |
| QCD | Delay from chip select to valid clock (default is 0). QCD is a value in the QDLYR register and will change the delay between the assertion of the chip select and the start of the DSPI clock. Default setting of one half DSPI clk will be used if parameter is specified as 0x0 or not included. |
| DTL | DTL is a value in the QDLYR register and will change the delay following a tranfer of a single uint16_t in the DSPI queue. Default reset value of 17/(fsys/2) will be used if parameter is specified 0 or not included. |
Notes:
| SPIModule | SPI module number, 0 - 1 |
| Baudrate | Maximum baud rate requested |
| QueueBitSize | Number of bits per transfer: 8, 16 or 32 |
| CS | SPI chip selects to use for transfer |
| CSPol | 0 = inactive logic level low, 1 = high |
| ClkPolarity | 0 = inactive logic level low, 1 = high |
| ClkPhase | 0 = data captured leading edge clock, changed following edge. 1 = data changed leading edge clock, captured following edge. |
| DoutHiz | Data output high impedance between transfers |
| QCD | Delay from chip select to valid clock (default is 0) |
| DTL | Chip select mode dspiChipSelectMode |