SPI Flash Functions

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

DlnSpiFlashGetPortCount() Function

The DlnSpiFlashGetPortCount() function retrieves the total number of SPI flash ports available in your DLN-series adapter.

Syntax
C/C++
DLN_RESULT DlnSpiFlashGetPortCount(
  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 available SPI flash ports.

Return Value
DLN_RES_SUCCESS (0x00)

The operation completed successfully and total number of SPI flash ports were retrieved.

Remarks

The DlnSpiFlashGetPortCount() function is defined in the dln_spi_flash.h file.

DlnSpiFlashEnable() Function

The DlnSpiFlashEnable() function activates the specified SPI flash port on your DLN-series adapter.

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

A handle to the DLN-series adapter.

port

A number of the SPI flash 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 flash module. To fix this, check which module uses the pin (call the DlnGetPinCfg()function), disconnect the pin from that module and call the DlnSpiMasterEnable() function once again. If there is another conflicting pin, its number will be returned.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully activated the SPI flash port.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

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

Remarks

The DlnSpiFlashEnable() function is defined in the dln_spi_flash.h file.

DlnSpiFlashDisable() Function

The DlnSpiFlashDisable() function deactivates the specified SPI flash port on your DLN-series adapter.

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

A handle to the DLN-series adapter.

port

A number of the SPI flash port.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully deactivated the SPI flash port.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

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

Remarks

The DlnSpiFlashDisable() function is defined in the dln_spi_flash.h file.

DlnSpiFlashIsEnabled() Function

The DlnSpiFlashIsEnabled() function retrieves information whether the specified SPI flash port is activated.

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

A handle to the DLN-series adapter.

port

A number of the SPI flash port.

enabled

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

  • 0 or DLN_SPI_FLASH_DISABLED - the port is not configured as SPI master.

  • 1 or DLN_SPI_FLASH_ENABLED - the port is configured as SPI master.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the SPI flash port status.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

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

Remarks

The DlnSpiFlashIsEnabled() function is defined in the dln_spi_flash.h file.

DlnSpiFlashSetFrequency() Function

The DlnSpiFlashSetFrequency() function sets the clock frequency on the SCK line.

Syntax
C/C++
DLN_RESULT DlnSpiFlashSetFrequency(
  HDLN handle, 
  uint8_t port, 
  uint32_t frequency
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI flash port.

frequency

SCK line frequency value, specified in Hz. You can specify any value within the range, supported by the DLN-series adapter.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully configured the clock frequency.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

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

Remarks

The DlnSpiFlashSetFrequency() function is defined in dln_spi_flash.h file.

DlnSpiFlashGetFrequency() Function

The DlnSpiFlashGetFrequency() function retrieves the current setting for SPI clock frequency.

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

A handle to the DLN-series adapter.

port

A number of the SPI flash port.

frequency

A pointer to an unsigned 32-bit integer that receives the current SPI clock frequency value in Hz.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the current clock frequency.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

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

Remarks

The DlnSpiFlashGetFrequency() function is defined in the dln_spi_flash.h file.

DlnSpiFlashSetSS() Function

The DlnSpiFlashSetSS() function selects a Slave Select (SS) line.

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

A handle to the DLN-series adapter.

port

A number of the SPI flash port.

ss

The value on the SS lines. The bits 4-7 are reserved and must be set to 1.

If you expect slaves to output data, you must ensure that only one slave is activated. If several slaves start outputting data simultaneously, the equipment can be damaged.
Return Value
DLN_RES_SUCCESS (0x00)

The function successfully selected the SS line.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

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

Remarks

The DlnSpiFlashSetSS() function is defined in dln_spi_flash.h file.

DlnSpiFlashGetSS() Function

The DlnSpiFlashGetSS() function retrieves the current Slave Select (SS) line.

Syntax
C/C++
DLN_RESULT DlnSpiFlashGetSS(
  HDLN handle, 
  uint8_t port, 
  uint8_t *ss
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI flash port.

ss

A pointer to an unsigned 8-bit integer that receives the value on the SS lines.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieves the selected SS line.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

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

Remarks

The DlnSpiFlashGetSS() function is defined in dln_spi_flash.h file.

DlnSpiFlashSetSSMask() Function

The DlnSpiFlashSetSSMask() function selects a required Slave Select (SS) lines by using mask value.

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

A handle to the DLN-series adapter.

port

A number of the SPI flash port.

ssMask

The mask value to set the SS lines. The bits 4-7 are reserved and must be set to 1.

If you expect slaves to output data, you must ensure that only one slave is activated. If several slaves start outputting data simultaneously, the equipment can be damaged.
Return Value
DLN_RES_SUCCESS (0x00)

The function successfully selected SS lines.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

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

Remarks

The DlnSpiFlashSetSSMask() function is defined in dln_spi_flash.h file.

DlnSpiFlashGetSSMask() Function

The DlnSpiFlashGetSSMask() function retrieves the mask value of current selected Slave Select (SS) lines.

Syntax
C/C++
DLN_RESULT DlnSpiFlashGetSSMask(
  HDLN handle, 
  uint8_t port, 
  uint8_t *ssMask
);
Parameters
handle

A handle to the DLN-series adapter.

port

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

ssMask

A pointer to an unsigned 8-bit integer that receives the mask value.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the selected SS lines.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

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

Remarks

The DlnSpiFlashGetSSMask() function is defined in the dln_spi_flash.h file.

DlnSpiFlashProgramPage() Function

The DlnSpiFlashProgramPage() function transfers data by using SPI flash interface.

Syntax
C/C++
DLN_RESULT DlnSpiFlashProgramPage(
  HDLN handle, 
  uint8_t port, 
  uint32_t address, 
  uint8_t *buffer, 
  uint16_t size, 
  uint32_t timeout
);
Parameters
handle

A handle to the DLN-series adapter.

port

A number of the SPI flash port.

address

Address value.

buffer

Pointer to byte variable with data to be sent.

size

Buffer size.

timeout

Timeout value.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the selected SS lines.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

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

DLN_RES_INVALID_BUFFER_SIZE (0xAE)

The buffer size is not valid. This value cannot exceed 256 bytes.

DLN_RES_DISABLED (0xB7)

The SPI flash port is disabled. Use the DlnSpiFlashEnable() function to activate the SPI flash port.

Remarks

The DlnSpiFlashProgramPage() function is defined in dln_spi_flash.h file.

DlnSpiFlashReadPage() Function

The DlnSpiFlashReadPage() function receives data via SPI flash interface. The data is received as an array of 1-byte elements.

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

A handle to the DLN-series adapter.

port

A number of the SPI flash port.

address

Device address for reading data from.

buffer

A pointer to an array of unsigned 8-bit integers. This array will be filled with data received.

size

Read data size.

Return Value
DLN_RES_SUCCESS (0x00)

The function successfully retrieved the selected SS lines.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

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

DLN_RES_INVALID_BUFFER_SIZE (0xAE)

The buffer size is not valid. This value cannot exceed 256 bytes.

DLN_RES_DISABLED (0xB7)

The SPI flash port is disabled. Use the DlnSpiFlashEnable() function to activate the SPI flash port.

Remarks

The DlnSpiFlashReadPage() function is defined in the dln_spi_flash.h file.