The default configuration for the SPI master port is as 8-bit SPI master with CPOL=0 and CPHA=0 transmission parameters. By default, the clock is selected with a frequency of 1Mhz.
Using the SPI master functions allows you to change and check the current SPI master configuration, to control data transmission.
The SPI master functions include the following:
General port information:
Retrieves the number of SPI master ports available in the DLN adapter.
Assigns the selected port to the SPI master module.
Releases the selected SPI master port.
Retrieves whether the selected port is assigned to the SPI master module.
Configuration functions:
Configures the clock frequency for the selected SPI master port.
Retrieves the clock frequency configuration for the SPI master port.
Configures the size of a single data frame for the selected SPI master port.
Retrieves the data frame configuration for the selected SPI master port.
Configures the transmission mode based on CPOL and CPHA values.
Retrieves the transmission mode configuration for the selected SPI master port.
Configures the CPOL value for the selected SPI master port.
Retrieves the CPOL value for the selected SPI master port.
Configures the CPHA value for the selected SPI master port.
Retrieves the CPHA value for the selected SPI master port.
Retrieves the supported transmission modes for the selected SPI master port.
Retrieves the supported CPOL values for the selected SPI master port.
Retrieves the supported CPHA values for the selected SPI master port.
Slave selection functions:
Retrieves the available number of SS lines for the selected SPI master port.
Selects a Slave Select (SS) line.
Retrieves the selected SS line.
Activates the selected SS line.
Disables the selected SS line.
Retrieves whether the selected SS line is activated.
Activates several selected SS lines.
Disables several selected SS lines.
Retrieves whether several selected SS lines are activated.
Releases the selected SS line.
Activates releasing SS line between data frames exchanged with a single slave device.
Disables releasing SS line between data frames exchanged with a single slave device.
Retrieves whether releasing SS line between data frames is activated.
Transmission functions:
Provides SPI communication in a full-duplex mode with arrays of 8-bit frames.
Provides SPI communication in a full-duplex mode with arrays of frames up to 16 bits.
Provides SPI communication in a full-duplex mode with arrays of 8-bit frames; can release the SS line after transmission.
Provides SPI communication in a full-duplex mode with arrays of 8-bit frames; releases the SS line after transmission.
Provides SPI communication in a half-duplex read mode with arrays of 8-bit frames.
Provides SPI communication in a half-duplex read mode with arrays of 8-bit frames; can release the SS line after transmission.
Provides SPI communication in a half-duplex write mode with arrays of 8-bit frames.
Provides SPI communication in a half-duplex write mode with arrays of 8-bit frames; can release the SS line after transmission.
Delay functions:
Configures a delay between data frames exchanged with a single slave device.
Retrieves current delay between data frames exchanged with a single slave device.
Configures a delay between activating SS line and the first data frame.
Retrieves current delay between activating SS line and the first data frame.
Configures a minimum delay between releasing one SS line and activating another SS line.
Retrieves current delay between releasing one SS line and activating another SS line.
The dln_spi_master.h
file declares the SPI Master Interface functions.
The DlnSpiMasterGetPortCount()
function retrieves the total number of SPI master ports available in your DLN-series adapter.
The DlnSpiMasterEnable()
function activates the selected SPI master port on your DLN-series adapter.
The DlnSpiMasterDisable()
function releases the selected SPI master port on your DLN-series adapter.
The DlnSpiMasterIsEnabled()
function retrieves whether the specified SPI master port is activated.
The DlnSpiMasterSetFrequency()
function sets the clock frequency on the SCK line, used to synchronize data transmission between master and slave devices.
The DlnSpiMasterGetFrequency()
function retrieves the current setting for SPI clock frequency.
The DlnSpiMasterSetFrameSize()
function sets the size of a single SPI data frame.
The DlnSpiMasterGetFrameSize()
function retrieves the current size setting for SPI data frame.
The DlnSpiMasterSetMode()
function sets SPI transmission parameters (CPOL and CPHA).
The DlnSpiMasterGetMode()
function retrieves current configuration of the selected SPI master port.
The DlnSpiMasterSetCpol()
function sets the clock polarity value.
The DlnSpiMasterGetCpol()
function retrieves the current value of clock polarity (CPOL).
The DlnSpiMasterSetCpha()
function allows to set clock phase (CPHA) value.
The DlnSpiMasterGetCpha()
function retrieves the current value of clock phase (CPHA).
The DlnSpiMasterGetSupportedModes()
function retrieves all supported SPI master modes (CPOL and CPHA values). For more information, read Clock Phase and Polarity.
The DlnSpiMasterGetSupportedCpolValues()
function retrieves supported CPOL values.
The DlnSpiMasterGetSupportedCphaValues()
function retrieves the available CPHA values.
The DlnSpiMasterGetSSCount()
function returns the available number of SS lines.
The DlnSpiMasterSetSS()
function selects a Slave Select (SS) line.
The DlnSpiMasterGetSS()
function retrieves current Slave Select (SS) line.
The DlnSpiMasterSSEnable()
function enables the specified SS line.
The DlnSpiMasterSSDisable()
function disables the specified SS line.
The DlnSpiMasterSSIsEnabled()
function enables the specified SS line.
The DlnSpiMasterSSMultiEnable()
function enables the specified SS lines.
The DlnSpiMasterSSMultiDisable()
function enables the specified SS lines.
The DlnSpiMasterSSMultiIsEnabled()
function enables the specified SS lines.
The DlnSpiMasterReleaseSS()
function releases SS lines.
The DlnSpiMasterSSBetweenFramesEnable()
function enables release of an SS line between data frames exchanged with a single slave device.
The DlnSpiMasterSSBetweenFramesDisable()
function disables release of an SS line between data frames exchanged with a single slave device.
The DlnSpiMasterSSBetweenFramesIsEnabled()
function checks whether the DLN-series adapter releases SS line between successive SPI frames transmission.
The DlnSpiMasterReadWrite()
function sends and receives data via SPI bus. The received and sent data are arrays of 1-byte elements. This function is suited to transmit data frames of 8 bits or less. In case you set a frame size more than 8 bits, it is advised to use the DlnSpiMasterReadWrite16() function.
The DlnSpiMasterReadWrite16()
function sends and receives 2-byte frames via SPI bus.
The DlnSpiMasterReadWriteSS()
function selects the specified SS line, transmits data via SPI bus and releases the SS line.
The DlnSpiMasterReadWriteEx()
function sends and receives data via SPI bus. The data is transmitted as an array of 1-byte elements. In this function you can use additional attributes to configure the SS line state after data transmission.
The DlnSpiMasterRead()
function receives data via SPI bus. The received data is an array of 1-byte elements.
The DlnSpiMasterReadEx()
function receives data via SPI bus. The received data is an array of 1-byte elements. In this function you can use additional attributes to configure the SS line state after data transmission.
The DlnSpiMasterWrite()
function sends data via SPI bus. The data is sent as an array of 1-byte elements.
The DlnSpiMasterWriteEx()
function sends data via SPI bus. The data is sent as an array of 1-byte elements. By using this function you can use additional attributes.
The DlnSpiMasterSetDelayBetweenFrames()
function sets a delay between data frames exchanged with a single slave device. For more information, read SPI Delays.
The DlnSpiMasterGetDelayBetweenFrames()
function retrieves current setting for delay between data frames exchanged with a single slave device.
The DlnSpiMasterSetDelayAfterSS()
function sets a delay duration between assertion of an SS line and first data frame. For more information, read SPI Delays.
The DlnSpiMasterGetDelayAfterSS()
function retrieves the current setting for minimum delay between assertion of an SS line and the first data frame.
The DlnSpiMasterSetDelayBetweenSS()
function sets a minimum delay between release of an SS line and assertion of another SS line. For more information, read SPI Delays.
The DlnSpiMasterGetDelayBetweenSS()
function retrieves the current setting for minimum delay after one SS line is released and before another SS line is asserted.