SPI Slave Interface

Some DLN-series adapters support the SPI Slave Interface.

Rating: 
Голосов пока нет

Configuring the Slave for Communication

To configure the slave for the communication, follow these steps:

  1. Configure SS idle timeout. When you enable the SPI slave, the SS line may be busy. The DLN adapter waits until the SS line drives high. If the SS line is not released during the SS idle timeout, the SPI slave cannot be enabled. Read SS Idle Timeout.

  2. Configure the transmission mode (clock polarity and clock phase). The clock polarity (CPOL) and clock phase (CPHA) configuration must be the same for both SPI master and SPI slave devices.

  3. Configure loading data to the reply buffer. The reply mode and reply type parameters can prevent from losing data if the frame size, configured by you for the SPI slave, does not correspond the frame size set on the SPI master. Read SPI Slave Reply Buffer.

  4. If needed, configure events. DLN adapters provide event-driven interface for SPI slave devices. Read SPI Slave Events.

Rating: 
Голосов пока нет

SS Idle Timeout

When you try to enable the SPI slave module, the SS line can appear busy. To prevent transmitting incorrect data, the DLN adapter idles until the SS line is released (drives high). Only then, the SPI slave can be enabled.

To limit the idle time, you can specify the idle timeout value in milliseconds (ms) by calling the DlnSpiSlaveSetSSIdleTimeout() function. The default value is 100ms. The idle timeout can be from 1ms to 1000ms. If during the specified idle timeout the SS line was not released, the DlnSpiSlaveEnable() function returns the DLN_RES_SPI_SLAVE_SS_IDLE_TIMEOUT error.

Do not mix SS idle timeout and idle event timeout.

For details about idle event timeout, read DLN_SPI_SLAVE_EVENT_IDLE Events.

Rating: 
Голосов пока нет

SPI Slave Reply Buffer

When the master initiates transmission, the DLN adapter-slave fills the reply buffer with data that should be sent to the master. To fill the reply buffer, you can use the following functions: DlnSpiSlaveLoadReply() or DlnSpiSlaveEnqueueReply(). The DlnSpiSlaveLoadReply() function clears the buffer and makes the current reply the first in the queue. In contrast, the DlnSpiSlaveEnqueueReply() function puts the current reply to the end of the queue.

Transmitted data is limited to the number of frames received by the master. The sizes of slave buffer (reply buffer) and master buffer (received buffer) may differ.

If the reply buffer size exceeds the received buffer size, the last bytes of the reply buffer can be lost or sent with the following transmission. It depends on the reply mode you configure. For more information, read Reply Modes.

If the reply buffer size is less than the received buffer size, the last bytes can be filled by zeroes or by repeated reply bytes. It depends on the shortage action you configure. For details, read Reply Shortage Actions.

Rating: 
Голосов пока нет

Reply Modes

If the reply buffer size exceeds the size of the buffer received by the master, the following options are possible:

  • If the last bytes of the reply are not weighty, they can be rejected. In this case, the master receives the bytes from the reply buffer until the SS line rises. The last bytes of the reply buffer are lost. This mode is called DLN_SPI_SLAVE_REPLY_MODE_SS_BASED.

  • If you do not want to lose any data, the last buffers can be added to the queue. In this case, the master receives the bytes from the reply buffer until the SS line rises. The last bytes of the reply buffer are not lost, they are added to the queue and the master receives them with the next transmission. This mode is called DLN_SPI_SLAVE_REPLY_MODE_COUNT_BASED.

You have two loaded replies: ABCD and EF12. The master initiates two transmissions of 3 words in each. From the slave, the master receives the following:

  • In the DLN_SPI_SLAVE_REPLY_MODE_SS_BASED mode, the master receives ABC and EF1. The last bytes of every reply are lost.

    DLN_SPI_SLAVE_REPLY_MODE_SS_BASED mode

  • In the DLN_SPI_SLAVE_REPLY_MODE_COUNT_BASED mode, the master receives ABC and DEF. The last bytes of the second reply is queued for the following transmissions.

    DLN_SPI_SLAVE_REPLY_MODE_COUNT_BASED

To configure the reply mode, use the DlnSpiSlaveSetReplyMode() function. The DlnSpiSlaveGetSupportedReplyModes() function retrieves all supported reply modes.

Rating: 
Голосов пока нет

Reply Shortage Actions

If the reply buffer size is less than the size of the buffer received by the master, the missed bytes can be filled by zeroes (the DLN_SPI_SLAVE_REPLY_SHORTAGE_SEND_ZEROES reply type) or by repeating the reply bytes (the DLN_SPI_SLAVE_REPLY_SHORTAGE_REUSE reply type).

You have a loaded reply: ABCD. The master initiates a transmission of 6 words. From the slave, the master receives the following:

  • If the DLN_SPI_SLAVE_REPLY_SHORTAGE_SEND_ZEROES reply type is set, the master receives ABCD00. The last bytes are filled with zeroes.

    DLN_SPI_SLAVE_REPLY_SHORTAGE_SEND_ZEROES reply type

  • If the DLN_SPI_SLAVE_REPLY_SHORTAGE_REUSE reply type is set, the master receives ABCDAB. The last bytes are filled by repeating the first bytes of the reply.

    DLN_SPI_SLAVE_REPLY_SHORTAGE_REUSE reply type

Rating: 
Голосов пока нет

SPI Slave Events

DLN adapters-slaves can be configured to send events. The events are generated when the slave meets the certain predefined conditions.

DLN adapters-slaves support the following events:

Event TypeDescription

DLN_SPI_SLAVE_EVENT_NONE

A DLN adapter does not generate any events.

DLN_SPI_SLAVE_EVENT_SS_RISE

A DLN adapter generates events when the level on the SS line rises. For details, read DLN_SPI_SLAVE_EVENT_SS_RISE Events.

DLN_SPI_SLAVE_EVENT_BUFFER_FULL

A DLN adapter generates events when the buffer is full. For details, read DLN_SPI_SLAVE_EVENT_BUFFER_FULL Events.

DLN_SPI_SLAVE_EVENT_IDLE

A DLN adapter generates events when the slave idles for the configured time. For details, read DLN_SPI_SLAVE_EVENT_IDLE Events.

When an event occurs, your application is notified (see the Notifications section). Call the DlnGetMessage() function to obtain the event details. The DLN_SPI_SLAVE_DATA_RECEIVED_EV structure describes this information.

By default, event generation is disabled (DLN_SPI_SLAVE_EVENT_NONE).

Rating: 
Средняя: 5 (1 оценка)

DLN_SPI_SLAVE_EVENT_SS_RISE Events

A DLN adapter generates the DLN_SPI_SLAVE_EVENT_SS_RISE events each time the level on the SS line rises.

DLN_SPI_SLAVE_EVENT_SS_RISE event

When the transmission from/to the SPI master completes, the master rises the level on the SS line. At this moment, a DLN adapter-slave generates the DLN_SPI_SLAVE_EVENT_SS_RISE event. After receiving this event, your application can perform certain actions, for example, show received data or start processing them.

The eventCount field of the first event is set to zero. For every new DLN_SPI_SLAVE_EVENT_SS_RISE event, the eventCount field increments. When you reset the slave or change its configuration, the eventCount filed is reset to zero.

Use the DlnSpiSlaveEnableSSRiseEvent() function to enable generating these events. To disable this event, use the DlnSpiSlaveDisableSSRiseEvent() function. The DlnSpiSlaveIsSSRiseEventEnabled() function allows to check whether this event is enabled.

The DLN_SPI_SLAVE_EVENT_SS_RISE and DLN_SPI_SLAVE_EVENT_IDLE events are conflicting; therefore when you enable one of these events, check that the other one is disabled.
Rating: 
Голосов пока нет

DLN_SPI_SLAVE_EVENT_BUFFER_FULL Events

A DLN adapter generates the DLN_SPI_SLAVE_EVENT_BUFFER_FULL events each time the buffer becomes full.

DLN_SPI_SLAVE_EVENT_BUFFER_FULL event

You can configure the buffer size by calling the DlnSpiSlaveSetEventSize() function. The supported values are from 1 to 256 bytes. By default, the size parameter is set to 256 bytes. To check the current value, use the DlnSpiSlaveGetEventSize() function.

During the transmission from the SPI master, if the buffer is overfilled, a DLN adapter-slave generates the DLN_SPI_SLAVE_EVENT_BUFFER_FULL event.

The eventCount field of the first event is set to zero. For every new DLN_SPI_SLAVE_EVENT_SS_RISE event, the eventCount field increments. When you reset the slave or change its configuration, the eventCount filed is reset to zero.

Use the DlnSpiSlaveEnableEvent() function to enable generating these events. To disable this event, use the DlnSpiSlaveDisableEvent() function. The DlnSpiSlaveIsEventEnabled() function allows to check whether this event is enabled.

The DLN_SPI_SLAVE_EVENT_BUFFER_FULL event does not conflict with other events.

Rating: 
Голосов пока нет

DLN_SPI_SLAVE_EVENT_IDLE Events

A DLN adapter generates the DLN_SPI_SLAVE_EVENT_IDLE events each time the SS line stays raised for a certain time.

DLN_SPI_SLAVE_EVENT_IDLE event

When the transmission from/to the SPI master completes, the master rises the level on the SS line. If the level stays high for the time set in the timeout parameter, a DLN adapter-slave generates the DLN_SPI_SLAVE_EVENT_IDLE event. If the SS line stays in the high level less than the required idle timeout, the event does not occur.

To configure the timeout parameter, use the DlnSpiSlaveSetIdleEventTimeout() function. The DlnSpiSlaveSetIdleEventTimeout() function allows to check the current value of this parameter.

Use the DlnSpiSlaveEnableIdleEvent() function to enable generating DLN_SPI_SLAVE_EVENT_IDLE events. To disable this event, use the DlnSpiSlaveDisableIdleEvent() function. The DlnSpiSlaveIsIdleEventEnabled() function allows to check whether this event is enabled.

Rating: 
Голосов пока нет

SPI Slave Functions

The default configuration for the SPI slave port is as 8-bit SPI slave with CPOL=0 and CPHA=0 transmission parameters. By default, no events are generated.

Using the SPI slave functions allows you to change and check the current SPI slave configuration, to control data transmission.

The SPI slave functions include the following:

General port information:

DlnSpiSlaveGetPortCount()

Retrieves the number of SPI slave ports available in the DLN adapter.

DlnSpiSlaveEnable()

Assigns the selected port to the SPI slave module.

DlnSpiSlaveDisable()

Releases the selected SPI slave port.

DlnSpiSlaveIsEnabled()

Retrieves whether the selected port is assigned to the SPI slave module.

Configuration functions:

DlnSpiSlaveSetSSIdleTimeout()

Specifies idle timeout for releasing the SS line.

DlnSpiSlaveGetSSIdleTimeout()

Retrieves the idle timeout setting.

DlnSpiSlaveSetFrameSize()

Specifies the data frame size for the selected SPI slave port.

DlnSpiSlaveGetFrameSize()

Retrieves the current frame size for the selected SPI slave port.

DlnSpiSlaveGetSupportedFrameSizes()

Retrieves the supported frame sizes.

DlnSpiSlaveSetMode()

Specifies transmission parameters (CPOL and CPHA) for the selected SPI slave port.

DlnSpiSlaveGetMode()

Retrieves the current transmission parameters (CPOL and CPHA) for the selected SPI slave port.

DlnSpiSlaveGetSupportedModes()

Retrieves the supported transmission parameters (CPOL and CPHA).

DlnSpiSlaveSetCpha()

Specifies CPHA value for the selected SPI slave port.

DlnSpiSlaveGetCpha()

Retrieves the current CPHA value for the selected SPI slave port.

DlnSpiSlaveGetSupportedCphaValues()

Retrieves the supported CPHA values.

DlnSpiSlaveSetCpol()

Specifies CPOL value for the selected SPI slave port.

DlnSpiSlaveGetCpol()

Retrieves the current CPOL value for the selected SPI slave port.

DlnSpiSlaveGetSupportedCpolValues()

Retrieves the supported CPOL values.

Reply functions:

DlnSpiSlaveLoadReply()

Clears the buffer and makes the current reply the first in the queue.

DlnSpiSlaveEnqueueReply()

Puts the current reply to the end of the queue.

DlnSpiSlaveSetReplyMode()

Specifies actions if the reply buffer size exceeds the size of the buffer received by the master.

DlnSpiSlaveGetReplyMode()

Retrieves the current reply configuration.

DlnSpiSlaveGetSupportedReplyModes()

Retrieves the supported reply modes.

DlnSpiSlaveSetReplyShortageAction()

Specifies actions if the reply buffer size is less than the size of the buffer received by the master.

DlnSpiSlaveGetReplyShortageAction()

Retrieves the current for reply shortage action settings.

DlnSpiSlaveGetSupportedShortageActions()

Retrieves the supported reply shortage actions.

Event configuration:

DlnSpiSlaveEnableSSRiseEvent()

Enables generating events when the level on the SS line rises.

DlnSpiSlaveDisableSSRiseEvent()

Disables generating events when the level on the SS line rises.

DlnSpiSlaveIsSSRiseEventEnabled()

Retrieves the current configuration for generating events when the level on the SS line rises.

DlnSpiSlaveEnableEvent()

Enables generating events when the buffer is full.

DlnSpiSlaveDisableEvent()

Disables generating events when the buffer is full.

DlnSpiSlaveIsEventEnabled()

Retrieves the current configuration for generating events when the buffer is full.

DlnSpiSlaveSetEventSize()

Specifies the buffer size.

DlnSpiSlaveGetEventSize()

Retrieves the current buffer size.

DlnSpiSlaveEnableIdleEvent()

Enables generating events when the slave idles for the configured time.

DlnSpiSlaveDisableEvent()

Disables generating events when the slave idles for the configured time.

DlnSpiSlaveIsEventEnabled()

Retrieves the current configuration for generating events when the slave idles for the configured time.

DlnSpiSlaveSetIdleEventTimeout()

Specifies the timeout value.

DlnSpiSlaveGetIdleEventTimeout()

Retrieves the current timeout value.

DlnSpiSlaveGetMinIdleEventTimeout()

Retrieves the minimum timeout value.

DlnSpiSlaveGetMaxIdleEventTimeout()

Retrieves the maximum timeout value.

The dln_spi_slave.h file declares the SPI Salve Interface functions.

Rating: 
Голосов пока нет

DlnSpiSlaveGetPortCount() Function

The DlnSpiSlaveGetPortCount() function retrieves the total number of SPI slave ports available at your DLN-series adapter.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetPortCount(
   HDLN handle,
   uint8_t* count
);
Parameters
handle

A handle to the DLN-series adapter.

count

A pointer to an unsigned 8-bit integer that receives the number of the available SPI slave ports.

Return Value
DLN_RES_SUCCESS (0x00)

The function retrieved the port count successfully.

Remarks

The DlnSpiSlaveGetPortCount() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveEnable() Function

The DlnSpiSlaveEnable() function activates the specified SPI slave port at your DLN-series adapter.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveEnable(
   HDLN handle,
   uint8_t port,
   uint16_t* conflict
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

conflict

A pointer to an unsigned 16-bit integer that receives a number of the conflicted pin, if any.

A conflict arises if a pin is already assigned to another module of the DLN-series adapter and cannot be used by the SPI slave module. To fix this, check which module uses the pin (call the DlnGetPinCfg()function), disconnect the pin from that module and call the DlnSpiSlaveEnable() function once again. If there is another conflicting pin, its number will be returned.

Return Value
DLN_RES_SUCCESS (0x00)

The function enabled the SPI slave module successfully.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_PIN_IN_USE (0xA5)

The port cannot be activated as the SPI slave port because one or more pins of the port are assigned to another module. The conflict parameter contains the number of a conflicting pin.

DLN_RES_SPI_SLAVE_SS_IDLE_TIMEOUT (0xCB)

The port cannot be activated as the SPI slave port because its SS line is busy transmitting some data and was not released for time defined by the DlnSpiSlaveSetSSIdleTimeout() function.

Remarks

The DlnSpiSlaveEnable() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveDisable() Function

The DlnSpiSlaveDisable() function deactivates the specified SPI slave port on your DLN adapter.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveDisable(
   HDLN handle,
   uint8_t port,
   uint8_t waitForTransferCompletion
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

waitForTransferCompletion

Used to choose whether the device should wait for current data transmissions complete before disabling as SPI slave. The following values are available:

  • 1 or DLN_SPI_SLAVE_WAIT_FOR_TRANSFERS - wait until transmissions complete.

  • 0 or DLN_SPI_SLAVE_CANCEL_TRANSFERS - cancel all pending data transmissions and release the port.

Return Value
DLN_RES_SUCCESS (0x00)

The function disabled the SPI slave module successfully.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_TRANSFER_CANCELLED (0x20)

The pending transmissions were cancelled.

Remarks

The DlnSpiSlaveDisable() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveIsEnabled() Function

The DlnSpiSlaveIsEnabled() function retrieves information whether the specified SPI slave port is active or not.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveIsEnabled(
   HDLN handle,
   uint8_t port,
   uint8_t* enabled
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

enabled

A pointer to an unsigned 8-bit integer that receives information whether the specified SPI slave port is activated after the function execution. There are two possible values:

  • 0 or DLN_SPI_SLAVE_DISABLED - the port is not configured as a SPI slave.

  • 1 or DLN_SPI_SLAVE_ENABLED - the port is configured as a SPI slave.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved information about the port.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveIsEnabled() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveSetSSIdleTimeout() Function

The DlnSpiSlaveSetSSIdleTimeout() function sets SS idle timeout. For details, read SS Idle Timeout.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveSetSSIdleTimeout(
    HDLN handle, 
    uint8_t port, 
    uint32_t timeout
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

timeout

The SS idle timeout value specified in milliseconds (ms). The minimum value is 1ms, the maximum value - 1000ms.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured SS idle timeout.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_INVALID_TIMEOUT_VALUE (0xCA)

The SS idle timeout value is not valid.

Remarks

The default SS idle timeout value is set to 100ms.

The DlnSpiSlaveSetSSIdleTimeout() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetSSIdleTimeout() Function

The DlnSpiSlaveGetSSIdleTimeout() function retrieves the current value of SS idle timeout.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetSSIdleTimeout(
    HDLN handle, 
    uint8_t port, 
    uint32_t *timeout
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

timeout

A pointer to an unsigned 32 bit integer that receives the current SS idle timeout value.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the current SS idle timeout value.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetSSIdleTimeout() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveSetFrameSize() Function

The DlnSpiSlaveSetFrameSize() function sets the size of a single SPI data frame.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveSetFrameSize(
   HDLN handle,
   uint8_t port,
   uint8_t frameSize
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

frameSize

A number of bits to be transmitted during the single frame. The DLN-series adapter supports 8 to 16 bits per frame.

The frameSize parameter does not limit the size of the buffer transmitted to/from the SPI slave device, it only defines the minimum portion of data in this buffer.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully specified the frame size.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_SPI_INVALID_FRAME_SIZE (0xB8)

The frame size is not valid. The DLN-series adapters support 8 to 16 bits per transmission.

DLN_RES_BUSY (0xB6)

The SPI slave is busy transmitting. The frame size cannot be changed.

Remarks

The DlnSpiSlaveSetFrameSize() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetFrameSize() Function

The DlnSpiSlaveGetFrameSize() function retrieves the current size setting for SPI data frames.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetFrameSize(
   HDLN handle,
   uint8_t port,
   uint8_t* frameSize
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

frameSize

A pointer to unsigned 8-bit integer that receives the number of bits transmitted in a single frame. The DLN-series adapter supports 8 to 16 bits per frame.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the current frame size.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetFrameSize() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetSupportedFrameSizes() Function

The DlnSpiSlaveGetSupportedFrameSizes() function returns all supported frame size values.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetSupportedFrameSizes(
    HDLN handle, 
    uint8_t port, 
    DLN_SPI_SLAVE_FRAME_SIZES *supportedSizes
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

supportedSizes

The pointer to the DLN_SPI_SLAVE_FRAME_SIZES structure that receives supported frame size values.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved supported frame size values.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetSupportedFrameSizes() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveSetMode() Function

The DlnSpiSlaveSetMode() function sets SPI transmission parameters (CPOL and CPHA). For more information, read Clock Phase and Polarity.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveSetMode(
    HDLN handle,
    uint8_t port,
    uint8_t mode
 );
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

mode

A bit field consisting of 8 bits. The bits 0 and 1 correspond to CPOL and CPHA parameters respectively and define the SPI mode. The rest of the bits are not used. You can also use special constants, defined in the dln_spi_slave.h file for each of the bits.

BitValueDescriptionConstant

0

0

CPOL=0

DLN_SPI_SLAVE_CPOL_0

0

1

CPOL=1

DLN_SPI_SLAVE_CPOL_1

1

0

CPHA=0

DLN_SPI_SLAVE_CPHA_0

1

1

CPHA=1

DLN_SPI_SLAVE_CPHA_1

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the slave port mode.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_INVALID_MODE (0xC7)

The mode value is not valid. Use the DlnSpiSlaveGetSupportedModes() function to check the supported modes for the current SPI slave port.

DLN_RES_MUST_BE_DISABLED (0x95)

These configuration changes are allowed only when the module is disabled. Use the DlnSpiSlaveDisable() function to disable the SPI module before configuring the slave port.

Remarks

The DlnSpiSlaveSetMode() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetMode() Function

The DlnSpiSlaveGetMode() function retrieves the current transmission parameters (CPOL and CPHA) for the specified SPI slave port. For details, read Clock Phase and Polarity.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetMode(
   HDLN handle,
   uint8_t port,
   uint8_t* mode
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

mode

A pointer to an unsigned 8 bit integer that receives the SPI mode value. The bits 0 and 1 of this value correspond to CPOL and CPHA parameters respectively. The rest of the bits are not used.

BitValueDescriptionConstant

0

0

CPOL=0

DLN_SPI_SLAVE_CPOL_0

0

1

CPOL=1

DLN_SPI_SLAVE_CPOL_1

1

0

CPHA=0

DLN_SPI_SLAVE_CPHA_0

1

1

CPHA=1

DLN_SPI_SLAVE_CPHA_1

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the slave port mode.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetMode() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetSupportedModes() Function

The DlnSpiSlaveGetSupportedModes() function retrieves all supported SPI slave modes.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetSupportedModes(
    HDLN handle, 
    uint8_t port, 
    DLN_SPI_SLAVE_MODE_VALUES *values
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

values

The pointer to DLN_SPI_SLAVE_MODE_VALUES structure that receives all supported SPI slave mode values.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the supported reply modes.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetSupportedModes() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveSetCpha() Function

The DlnSpiSlaveSetCpha() function allows to set the clock phase (CPHA) value.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveSetCpha(
    HDLN handle, 
    uint8_t port, 
    uint8_t cpha
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

cpha

The clock phase (CPHA) value. Can be 0 or 1.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the slave port mode.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_MUST_BE_DISABLED (0x95)

These configuration changes are allowed only when the module is disabled. Use the DlnSpiSlaveDisable() function to disable the SPI module before configuring the slave port.

DLN_RES_INVALID_CPHA (0xC9)

The provided CPHA value is not valid. Use the DlnSpiSlaveGetSupportedCphaValues() function to check the supported CPHA values for the current SPI slave port.

Remarks

The DlnSpiSlaveSetCpha() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetCpha() Function

The DlnSpiSlaveGetCpha() function retrieves the current value of clock phase (CPHA).

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetCpha(
    HDLN handle, 
    uint8_t port, 
    uint8_t *cpha
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

cpha

The pointer to uint8_t variable that receives the current CPHA value.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the slave port mode.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetCpha() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetSupportedCphaValues() Function

The DlnSpiSlaveGetSupportedCphaValues() function retrieves all supported CPHA (clock phase) values.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetSupportedCphaValues(
   HDLN handle, 
   uint8_t port, 
   DLN_SPI_SLAVE_CPHA_VALUES *values
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

values

The pointer to DLN_SPI_SLAVE_CPHA_VALUES structure that receives all supported SPI slave CPHA values.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the slave port mode.

Remarks

The DlnSpiSlaveGetSupportedCphaValues() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveSetCpol() Function

The DlnSpiSlaveSetCpol() function allows to set the clock polarity (CPOL) value.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveSetCpol(
    HDLN handle, 
    uint8_t port, 
    uint8_t cpol
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

cpol

The clock polarity (CPOL) value. Can be 0 or 1.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the slave port mode.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_MUST_BE_DISABLED (0x95)

These configuration changes are allowed only when the module is disabled. Use the DlnSpiSlaveDisable() function to disable the SPI module before configuring the slave port.

DLN_RES_INVALID_CPOL (0xC8)

The provided CPOL value is not valid. Use the DlnSpiSlaveGetSupportedCpolValues() function to check the supported CPOL values for the current SPI slave port.

Remarks

The DlnSpiSlaveSetCpol() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetCpol() Function

The DlnSpiSlaveGetCpol() function retrieves the current value of clock polarity (CPOL).

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetCpol(
    HDLN handle, 
    uint8_t port, 
    uint8_t *cpol
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI-slave port.

cpol

The pointer to uint8_t variable that receives the current CPOL value.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the slave port mode.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetCpol() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetSupportedCpolValues() Function

The DlnSpiSlaveGetSupportedCpolValues() function retrieves all supported CPOL (clock polarity) values.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetSupportedCpolValues(
    HDLN handle, 
    uint8_t port, 
    DLN_SPI_SLAVE_CPOL_VALUES *values
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

values

The pointer to DLN_SPI_SLAVE_CPOL_VALUES structure that receives all supported CPOL values.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the slave port mode.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetSupportedCpolValues() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveLoadReply() Function

The DlnSpiSlaveLoadReply() function loads data (loads a number of bytes to reply buffer) to be transmitted to an SPI-master device. This function clears the buffer and makes the current reply the first in the queue.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveLoadReply(
   HDLN handle,
   uint8_t port,
   uint16_t size,
   uint8_t* buffer
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

size

A size of the message buffer. This parameter is specified in bytes. The maximum value is 256 bytes.

buffer

A pointer to an array of unsigned 8-bit integers (max 256-elements array). The buffer must contain the data to send to the SPI bus master.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully loaded data to reply buffer.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_INVALID_BUFFER_SIZE (0xAE)

The buffer size is not valid. The DLN-series adapters support up to 256 bytes of the buffer.

DLN_RES_BUSY (0xB6)

The SPI slave is busy transmitting. Data cannot be loaded to the buffer.

Remarks

The DlnSpiSlaveLoadReply() function removes all replies from the queue and makes the current reply the first in the queue. In contrast, the DlnSpiSlaveEnqueueReply() function adds the reply to the queue.

The type of reply is configurable: it can be based on the SS line or based on the byte count. For details, read Reply Modes. To configure the reply mode, use the DlnSpiSlaveSetReplyMode() function.

The DlnSpiSlaveLoadReply() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveEnqueueReply() Function

The DlnSpiSlaveEnqueueReply() function adds a buffer to queue.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveEnqueueReply(
    HDLN handle, 
    uint8_t port, 
    uint16_t size, 
    uint8_t *buffer
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI-slave port.

size

A size of the message buffer. This parameter is specified in bytes. The maximum value is 256 bytes.

buffer

A pointer to an array of unsigned 8-bit integers (max 256-elements array). The buffer must contain the data to be sent to an SPI bus master.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully added data to reply queue.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_INVALID_BUFFER_SIZE (0xAE)

The buffer size is not valid. The DLN-series adapters support up to 256 bytes of the buffer.

Remarks

If the queue is empty (after enabling), the DlnSpiSlaveEnqueueReply() function is equal to the DlnSpiSlaveLoadReply() function. If the queue is not empty, the DlnSpiSlaveEnqueueReply() function does not remove replies from the queue.

The DlnSpiSlaveEnqueueReply() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveSetReplyMode() Function

The DlnSpiSlaveSetReplyMode() function sets SPI slave reply mode.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveSetReplyMode(
    HDLN handle, 
    uint8_t port, 
    uint8_t replyMode
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

replyMode

Reply mode value. The following values are possible:

  • 0 or DLN_SPI_SLAVE_REPLY_MODE_OFF - No reply, transmitter is disabled.

  • 1 or DLN_SPI_SLAVE_REPLY_MODE_SS_BASED - Transmitting the reply stops when the SS line releases. If the reply was not transmitted completely, the rest part of the reply is lost. The next reply transmission starts after the new SS line assertion.

  • 2 or DLN_SPI_SLAVE_REPLY_MODE_COUNT_BASED - Only after the reply transmission is completed, the next reply can start. Transmission occurs regardless of the SS line state.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the reply mode.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_INVALID_REPLY_TYPE (0xC5)

The specified reply type is not valid.

Remarks

The DLN_SPI_SLAVE_REPLY_MODE_COUNT_BASED reply mode allows to send data regardless of how many (or few) words are framed by the SS line. The DLN_SPI_SLAVE_REPLY_MODE_SS_BASED reply mode is set by default, it begins new data transmission/reply regardless of the data length. The DLN_SPI_SLAVE_REPLY_MODE_OFF mode disables transmission, it can be set for half-duplex write communication (for details, read SPI Data Transmission).

The DlnSpiSlaveSetReplyMode() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetReplyMode() Function

The DlnSpiSlaveGetReplyMode() function retrieves the current SPI slave reply mode.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetReplyMode(
    HDLN handle, 
    uint8_t port, 
    uint8_t *replyMode
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

replyMode

The pointer to an unsigned 8 bit integer that receives the SPI reply mode value after the function execution.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the current reply mode.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetReplyMode() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetSupportedReplyModes() Function

The DlnSpiSlaveGetSupportedReplyModes() function retrieves the supported SPI slave reply modes.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetReplyMode(
    HDLN handle, 
    uint8_t port, 
    DLN_SPI_SLAVE_REPLY_MODES *supportedReplyModes
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

supportedReplyModes

The pointer to DLN_SPI_SLAVE_REPLY_MODES structure that receives all supported reply modes.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the supported reply mode.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetSupportedReplyModes() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveSetReplyShortageAction() Function

The DlnSpiSlaveSetReplyShortageAction() function sets the reply shortage action value. When the master sends a data block that is larger than the loaded reply, this function specifies how to fill empty bytes (repeat the reply bytes or send zeroes).

Syntax
C/C++
DLN_RESULT DlnSpiSlaveSetReplyShortageAction(
    HDLN handle, 
    uint8_t port,
    uint8_t action
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

action

Shortage action value to be set. There are 2 possible values:

  • DLN_SPI_SLAVE_REPLY_SHORTAGE_SEND_ZEROES - To fill the missed bytes with 0.

  • DLN_SPI_SLAVE_REPLY_SHORTAGE_REUSE - To fill the missed bytes repeating the reply.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the shortage action.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_BUSY (0xB6)

The SPI slave is busy transmitting. The reply shortage action cannot be changed. To change configuration, use the DlnSpiSlaveDisable() function.

Remarks

When the master sends a data block that is larger than the loaded reply, this function specifies how to fill empty bytes (repeat the reply bytes or send zeroes). For example, the loaded reply includes 3 bytes (11 22 33), but the master sends 5 bytes. If the function sets the DLN_SPI_SLAVE_REPLY_SHORTAGE_SEND_ZEROES value, the slave sends 11 22 33 00 00. If the function sets the DLN_SPI_SLAVE_REPLY_SHORTAGE_REUSE value, the slave sends 11 22 33 11 22. For details, read Reply Shortage Actions.

The DlnSpiSlaveSetReplyShortageAction() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetReplyShortageAction() Function

The DlnSpiSlaveGetReplyShortageAction() functions retrieves the current value of reply shortage action.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetReplyShortageAction(
    HDLN handle, 
    uint8_t port, 
    uint8_t *action
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

action

A pointer to unsigned 8-bit integer that receives the current reply shortage configuration.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the current shortage configuration.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetReplyShortageAction() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetSupportedShortageActions() Function

The DlnSpiSlaveGetSupportedShortageActions() function retrieves supported shortage action values.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetSupportedShortageActions(
    HDLN handle, 
    uint8_t port, 
    DLN_SPI_SLAVE_SHORTAGE_ACTIONS *supportedSizes
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI-slave port.

supportedSizes

The pointer to DLN_SPI_SLAVE_SHORTAGE_ACTIONS structure that receives all the supported shortage action values.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the supported shortage action values.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetSupportedShortageActions() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveEnableSSRiseEvent() Function

The DlnSpiSlaveEnableSSRiseEvent() function activates event on SS rising edge.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveEnableSSRiseEvent(
    HDLN handle, 
    uint8_t port
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully activated the event on SS rising edge.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveEnableSSRiseEvent() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveDisableSSRiseEvent() Function

The DlnSpiSlaveDisableSSRiseEvent() function deactivates SS rise events.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveDisableSSRiseEvent(
    HDLN handle, 
    uint8_t port
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully deactivated the event on SS rising edge.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveDisableSSRiseEvent() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveIsSSRiseEventEnabled() Function

The DlnSpiSlaveIsSSRiseEventEnabled() function retrieves information whether the SS rise events are active or not.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveIsSSRiseEventEnabled(
    HDLN handle, 
    uint8_t port, 
    uint8_t *enabled
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port to retrieve the information from.

enabled

A pointer to an unsigned 8-bit integer that receives information whether the SS rise events are enabled.There are two possible values:

  • 0 or DLN_SPI_SLAVE_EVENT_DISABLED - SS rise events are not enabled.

  • 1 or DLN_SPI_SLAVE_EVENT_ENABLED - SS rise events are enabled.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the event on SS rising edge configuration.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveIsSSRiseEventEnabled() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveEnableEvent() Function

The DlnSpiSlaveEnableEvent() function activates SPI slave buffer full event.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveEnableEvent(
    HDLN handle, 
    uint8_t port
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully activated the SPI slave buffer full event.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveEnableEvent() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveDisableEvent() Function

The DlnSpiSlaveDisableEvent() function deactivates SPI slave buffer full event.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveDisableEvent(
    HDLN handle, 
    uint8_t port
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully deactivated the SPI slave buffer full event.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveDisableEvent() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveIsEventEnabled() Function

The DlnSpiSlaveIsEventEnabled() function retrieves information whether the SPI slave events are active or not.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveIsEventEnabled(
    HDLN handle, 
    uint8_t port, 
    uint8_t *enabled
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port to retrieve the information from.

enabled

A pointer to an unsigned 8-bit integer that receives information whether the SPI slave port events are activated or not. There are two possible values:

  • 0 or DLN_SPI_SLAVE_EVENT_DISABLED - SPI slave events are enabled.

  • 1 or DLN_SPI_SLAVE_EVENT_ENABLED - SPI slave events are disabled.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieves the SPI slave buffer full event.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveIsEventEnabled() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveSetEventSize() Function

The DlnSpiSlaveSetEventSize() function sets the event buffer size.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveSetEventSize(
    HDLN handle, 
    uint8_t port, 
    uint16_t size
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port to be configured.

size

Event buffer size parameter. Its value can vary from 1 to 256 bytes.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the event buffer size.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_INVALID_BUFFER_SIZE (0xAE)

The buffer size is not valid. The DLN-series adapters support up to 256 bytes of the buffer.

Remarks

The DlnSpiSlaveSetEventSize() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetEventSize() Function

The DlnSpiSlaveGetEventSize() function retrieves value of current event buffer size.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetEventSize(
    HDLN handle, 
    uint8_t port, 
    uint16_t *size
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port to retrieve the SPI buffer size value from.

size

A pointer to an unsigned 16 bit integer that receives the current event buffer size value. The value varies from 1 to 256.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the current event buffer size.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetEventSize() function is defined in dln_spi_slave.h file.

DlnSpiSlaveEnableIdleEvent() Function

The DlnSpiSlaveEnableIdleEvent() function activates the SPI slave idle event.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveEnableIdleEvent(
    HDLN handle, 
    uint8_t port
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully activated the SPI slave idle event.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_INVALID_EVENT_TYPE (0xA9)

The idle event conflicts with the SS rise event. To enable the idle event, disable the SS rise event by using the DlnSpiSlaveDisableSSRiseEvent() function.

Remarks

The DlnSpiSlaveEnableIdleEvent() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveDisableIdleEvent() Function

The DlnSpiSlaveDisableIdleEvent() function deactivates the SPI slave idle event.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveDisableIdleEvent(
    HDLN handle, 
    uint8_t port
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully deactivated the SPI slave idle event.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveDisableIdleEvent() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveIsIdleEventEnabled() Function

The DlnSpiSlaveIsIdleEventEnabled() function activates the SPI slave idle event.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveIsIdleEventEnabled(
    HDLN handle, 
    uint8_t port,
    uint8_t *enabled
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

enabled

A pointer to an unsigned 8-bit integer that receives information whether the idle events are activated or not.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully activated the SPI slave idle event.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveIsIdleEventEnabled() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveSetIdleEventTimeout() Function

The DlnSpiSlaveSetIdleEventTimeout() function sets idle event timeout.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveSetIdleEventTimeout(
    HDLN handle, 
    uint8_t port, 
    uint32_t timeout
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

timeout

The idle event timeout value specified in milliseconds (ms).

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured idle event timeout.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

DLN_RES_INVALID_TIMEOUT_VALUE (0xCA)

The idle event timeout value is not valid.

Remarks

The default idle event timeout value is set to 0ms.

The DlnSpiSlaveSetIdleEventTimeout() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetIdleEventTimeout() Function

The DlnSpiSlaveGetIdleEventTimeout() function retrieves the current value of idle event timeout.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetIdleEventTimeout(
    HDLN handle, 
    uint8_t port, 
    uint32_t *timeout
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

timeout

A pointer to an unsigned 32 bit integer that receives the current idle event timeout value.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the minimum idle event timeout value.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetIdleEventTimeout() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetMinIdleEventTimeout() Function

The DlnSpiSlaveGetMinIdleEventTimeout() function retrieves the minimum value of idle event timeout.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetMinIdleEventTimeout(
    HDLN handle, 
    uint8_t port, 
    uint32_t *timeout
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

timeout

A pointer to an unsigned 32 bit integer that receives the minimum idle event timeout value.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the maximum idle event timeout value.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetMinIdleEventTimeout() function is defined in the dln_spi_slave.h file.

DlnSpiSlaveGetMaxIdleEventTimeout() Function

The DlnSpiSlaveGetMaxIdleEventTimeout() function retrieves the maximum value of idle event timeout.

Syntax
C/C++
DLN_RESULT DlnSpiSlaveGetMaxIdleEventTimeout(
    HDLN handle, 
    uint8_t port, 
    uint32_t *timeout
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI slave port.

timeout

A pointer to an unsigned 32 bit integer that receives the minimum idle event timeout value.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the maximum idle event timeout value.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnSpiSlaveGetPortCount() function to find the maximum possible port number.

Remarks

The DlnSpiSlaveGetMaxIdleEventTimeout() function is defined in the dln_spi_slave.h file.