U2C-11 USB-I2C/SPI/GPIO Interface Adapter

 
Main Page   Modules   Compound List   File List   Compound Members   File Members  

SPI configuration routines


Functions

U2C_RESULT U2C_SpiSetConfig (HANDLE hDevice, BYTE CPOL, BYTE CPHA)
 Configure SPI. More...

U2C_RESULT U2C_SpiGetConfig (HANDLE hDevice, BYTE *pCPOL, BYTE *pCPHA)
 Get SPI configuration. More...

U2C_RESULT U2C_SpiSetFreq (HANDLE hDevice, BYTE Frequency)
 Set SPI speed. More...

U2C_RESULT U2C_SpiGetFreq (HANDLE hDevice, BYTE *pFrequency)
 Get SPI speed. More...


Function Documentation

U2C_RESULT _stdcall U2C_SpiGetConfig ( HANDLE hDevice,
BYTE * pCPOL,
BYTE * pCPHA )
 

Get SPI configuration.

The U2C_SpiGetConfig function obtains SPI bus configuration (clock polarity and phase).

Parameters:
hDevice   Handle to the I2CBridge device
pCPOL   A pointer to the byte to be filled with current SPI bus clock polarity setting Clock polarity determines the CLK line idle state, where:
  • 0 corresponds to "idle low"
  • 1 corresponds to "idle high"
pCPHA   A pointer to byte to be filled with current SPI bus clock phase setting Clock phase value determines the clock edge when the data is valid on the bus, where:
  • 0 corresponds to valid data available on leading edge
  • 1 corresponds to valid data available on trailing edge
  • Returns:
    • U2C_SUCCESS - The SPI bus configuration was successfully obtained.
    • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found

    U2C_RESULT _stdcall U2C_SpiGetFreq ( HANDLE hDevice,
    BYTE * pFrequency )
     

    Get SPI speed.

    The U2C_SpiGetFreq function obtains SPI bus speed

    Parameters:
    hDevice   Handle to the I2CBridge device
    pFrequency   A pointer to byte to be filled with the current SPI bus frequency, where:
    • 0 corresponds to SPI bus frequency of 200 kHz
    • 1 corresponds to SPI bus frequency of 100 kHz
    • 1+n corresponds to the SPI bus clock period equal to uS
    For convenience following constants were introduced:
    • U2C_SPI_FREQ_200KHZ 200 kHz
    • U2C_SPI_FREQ_100KHZ 100 kHz
    • U2C_SPI_FREQ_83KHZ 83 kHz
    • U2C_SPI_FREQ_71KHZ 71 kHz
    • U2C_SPI_FREQ_62KHZ 62 kHz
    • U2C_SPI_FREQ_50KHZ 50 kHz
    • U2C_SPI_FREQ_25KHZ 25 kHz
    • U2C_SPI_FREQ_10KHZ 10 kHz
    • U2C_SPI_FREQ_5KHZ 5 kHz
    • U2C_SPI_FREQ_2KHZ 2 kHz
    Returns:
    • U2C_SUCCESS - The frequency value was successfully retrieved.
      • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found

    U2C_RESULT _stdcall U2C_SpiSetConfig ( HANDLE hDevice,
    BYTE CPOL,
    BYTE CPHA )
     

    Configure SPI.

    The U2C_SpiSetConfig function configures SPI bus clock polarity and phase.

    Parameters:
    hDevice   Handle to the I2CBridge device
    CPOL   Clock polarity value determines the CLK line idle state, where:
    • 0 corresponds to "idle low"
    • 1 corresponds to "idle high"
    CPHA   Clock phase value determines the clock edge when the data is valid on the bus, where:
  • 0 corresponds to valid data available on leading edge
  • 1 corresponds to valid data available on trailing edge
  • Returns:
    • U2C_SUCCESS - The SPI bus was successfully configured.
    • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found

    U2C_RESULT _stdcall U2C_SpiSetFreq ( HANDLE hDevice,
    BYTE Frequency )
     

    Set SPI speed.

    The U2C_SpiSetFreq function configures SPI bus speed

    Parameters:
    hDevice   Handle to the I2CBridge device
    Frequency   The frequency of SPI bus, where:
    • 0 corresponds to SPI bus frequency of 200 kHz
    • 1 corresponds to SPI bus frequency of 100 kHz
    • 1+n corresponds to the SPI bus clock period equal to uS
    For convenience following constants were introduced:
    • U2C_SPI_FREQ_200KHZ 200 kHz
    • U2C_SPI_FREQ_100KHZ 100 kHz
    • U2C_SPI_FREQ_83KHZ 83 kHz
    • U2C_SPI_FREQ_71KHZ 71 kHz
    • U2C_SPI_FREQ_62KHZ 62 kHz
    • U2C_SPI_FREQ_50KHZ 50 kHz
    • U2C_SPI_FREQ_25KHZ 25 kHz
    • U2C_SPI_FREQ_10KHZ 10 kHz
    • U2C_SPI_FREQ_5KHZ 5 kHz
    • U2C_SPI_FREQ_2KHZ 2 kHz
    Returns:
    • U2C_SUCCESS - The frequency value was successfully set.
    • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found

    Copyright DiMAX 2002-2004