i2ctospi 2.0.0.0

Functions

void i2ctospi_cfg_setup (i2ctospi_cfg_t *cfg)
 Config Object Initialization function.
 
I2CTOSPI_RETVAL i2ctospi_init (i2ctospi_t *ctx, i2ctospi_cfg_t *cfg)
 Initialization function.
 
void i2ctospi_default_cfg (i2ctospi_t *ctx)
 Click Default Configuration function.
 
void i2ctospi_generic_write (i2ctospi_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic write function.
 
void i2ctospi_generic_read (i2ctospi_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
 Generic read function.
 
void i2ctospi_hw_reset (i2ctospi_t *ctx)
 Hardware reset function.
 
uint8_t i2ctospi_get_interrupt (i2ctospi_t *ctx)
 Gets state of the interrupt function.
 
void i2ctospi_spi_write_byte (i2ctospi_t *ctx, i2ctospi_spi_t *spi, uint8_t write_data)
 Generic SPI write the byte of data to data buffer function.
 
uint8_t i2ctospi_spi_read_byte (i2ctospi_t *ctx, i2ctospi_spi_t *spi)
 Generic SPI read the byte of data from data buffer function.
 
void i2ctospi_spi_burst_write (i2ctospi_t *ctx, i2ctospi_spi_t *spi, uint8_t *write_data)
 Generic SPI write - single address burst write function.
 
void i2ctospi_spi_burst_read (i2ctospi_t *ctx, i2ctospi_spi_t *spi, uint8_t *read_data)
 Generic SPI read - single address burst read function.
 
void i2ctospi_read_buffer_bytes (i2ctospi_t *ctx, i2ctospi_spi_t *spi, uint8_t *read_data)
 Generic sequential read from the data buffer function.
 
void i2ctospi_write_command (i2ctospi_t *ctx, i2ctospi_spi_t *spi, uint8_t command_data)
 Generic write command byte of data function.
 
void i2ctospi_write_enable (i2ctospi_t *ctx, uint8_t ss_pin_data)
 SPI EEPROM wite enable function.
 
void i2ctospi_config_spi (i2ctospi_t *ctx, uint8_t config_data)
 Configure SPI Interface function.
 
void i2ctospi_clear_interrupt (i2ctospi_t *ctx)
 Clear interrupt function.
 
void i2ctospi_set_idle_mode (i2ctospi_t *ctx)
 Set Idle mode function.
 
void i2ctospi_set_write_state_of_gpio (i2ctospi_t *ctx, uint8_t gpio_state)
 Set state of the pins defined as GPIO write function.
 
void i2ctospi_set_read_state_of_gpio (i2ctospi_t *ctx, uint8_t gpio_state)
 Set state of the pins defined as GPIO read function.
 
void i2ctospi_enable_gpio (i2ctospi_t *ctx, uint8_t ss_pin_number)
 Enable the pins defined as GPIO function.
 
void i2ctospi_types_gpio (i2ctospi_t *ctx, i2ctospi_gpio_t *gpio)
 Enable the pins defined as GPIO function.
 

Detailed Description

Function Documentation

◆ i2ctospi_cfg_setup()

void i2ctospi_cfg_setup ( i2ctospi_cfg_t * cfg)

Config Object Initialization function.

Parameters
cfgClick configuration structure.

@description This function initializes click configuration structure to init state.

Note
All used pins will be set to unconnected state.

◆ i2ctospi_clear_interrupt()

void i2ctospi_clear_interrupt ( i2ctospi_t * ctx)

Clear interrupt function.

Parameters
ctxClick object.

@description Function clear interrupt is generated by the SC18IS602B after any SPI transmission has been completed.

Note
This interrupt can be cleared ( INT pin HIGH ) by sending a clear interrupt command to the targeted [ I2CTOSPI_CLEAR_INTERRUPT ] register address SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_config_spi()

void i2ctospi_config_spi ( i2ctospi_t * ctx,
uint8_t config_data )

Configure SPI Interface function.

Parameters
ctxClick object.
config_data
               
8-bit configuration data:
- bit [ 7 : 6 ] : reserved
- bit [ 5 ]     : ORDER:
                  - 0 : MSB of the data word is transmitted first
                  - 1 : LSB of the data word is transmitted first
- bit [ 4 ]     : reserved
- bit [ 3 : 2 ] : MODE:
                  - 0 : SPICLK LOW when idle; data clocked in on leading edge ( CPOL = 0, CPHA = 0 );
                  - 1 : SPICLK LOW when idle; data clocked in on trailing edge ( CPOL = 0, CPHA = 1 );
                  - 2 : SPICLK HIGH when idle; data clocked in on trailing edge ( CPOL = 1, CPHA = 0 );
                  - 3 : SPICLK HIGH when idle; data clocked in on leading edge ( CPOL = 1, CPHA = 1 );
- bit [ 1 : 0 ] : SPI clock rate
                  - 0 : 1843 kHz;
                  - 1 :  461 kHz;
                  - 2 :  115 kHz;
                  - 3 :   58 kHz;

<br>description Function configure SPI Interface by write configuration the byte of data to the targeted [ I2CTOSPI_CONFIGURE_SPI ] register address of the SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_default_cfg()

void i2ctospi_default_cfg ( i2ctospi_t * ctx)

Click Default Configuration function.

Parameters
ctxClick object.

@description This function executes default configuration for I2cToSpi click.

◆ i2ctospi_enable_gpio()

void i2ctospi_enable_gpio ( i2ctospi_t * ctx,
uint8_t ss_pin_number )

Enable the pins defined as GPIO function.

Parameters
ctxClick object.
ss_pin_number
  
- 0x01 [ I2CTOSPI_CONFIGURE_GPIO_BIDIRECTIONAL_PORT_ENABLE_SS0 ] : SS0;
- 0x02 [ I2CTOSPI_CONFIGURE_GPIO_BIDIRECTIONAL_PORT_ENABLE_SS1 ] : SS1;
- 0x04 [ I2CTOSPI_CONFIGURE_GPIO_BIDIRECTIONAL_PORT_ENABLE_SS2 ] : SS2;
- 0x08 [ I2CTOSPI_CONFIGURE_GPIO_BIDIRECTIONAL_PORT_ENABLE_SS3 ] : SS3;

@description Function enable the pins defined as GPIO, the Slave Select pins ( SS0, SS1, SS2 and SS3 ) are configured to be used as slave select outputs by write 8-bit ss_pin_number data after write targeted [ I2CTOSPI_GPIO_ENABLE ] functio Id to the SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_generic_read()

void i2ctospi_generic_read ( i2ctospi_t * ctx,
uint8_t reg,
uint8_t * data_buf,
uint8_t len )

Generic read function.

Parameters
ctxClick object.
regRegister address.
data_bufOutput data buf
lenNumber of the bytes to be read

@description This function reads data from the desired register.

◆ i2ctospi_generic_write()

void i2ctospi_generic_write ( i2ctospi_t * ctx,
uint8_t reg,
uint8_t * data_buf,
uint8_t len )

Generic write function.

Parameters
ctxClick object.
regRegister address.
data_bufData buf to be written.
lenNumber of the bytes in data buf.

@description This function writes data to the desired register.

◆ i2ctospi_get_interrupt()

uint8_t i2ctospi_get_interrupt ( i2ctospi_t * ctx)

Gets state of the interrupt function.

Parameters
ctxClick object.
Returns
interrupt state: 0 - No active; 1 - Active;

@description Function gets state of the INT pin on I2C to SPI click board.

◆ i2ctospi_hw_reset()

void i2ctospi_hw_reset ( i2ctospi_t * ctx)

Hardware reset function.

Parameters
ctxClick object.

@description Function hardware reset I2C to SPI click board by cleared to '0' state of the RST pin, wait the 100 ms, sets to '1' state of the RST pin and wait another the 100 ms.

Note
Delay is 200 ms.

◆ i2ctospi_init()

I2CTOSPI_RETVAL i2ctospi_init ( i2ctospi_t * ctx,
i2ctospi_cfg_t * cfg )

Initialization function.

Parameters
ctxClick object.
cfgClick configuration structure.

@description This function initializes all necessary pins and peripherals used for this click.

◆ i2ctospi_read_buffer_bytes()

void i2ctospi_read_buffer_bytes ( i2ctospi_t * ctx,
i2ctospi_spi_t * spi,
uint8_t * read_data )

Generic sequential read from the data buffer function.

Parameters
ctxClick object.
spiSpi object.
Arguments:
 - reg_addr                   8-bit register address.
 - n_bytes                    number of bytes to be written.
read_dataPointer to the memory location where data be stored

@description Function sequential read data starts from the targeted 8-bit buffer register address of the SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_set_idle_mode()

void i2ctospi_set_idle_mode ( i2ctospi_t * ctx)

Set Idle mode function.

Parameters
ctxClick object.

@description Function set Idle mode, a low-power mode may be entered by sending the Idle Mode command to the targeted [ I2CTOSPI_IDLE_MODE ] register address SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_set_read_state_of_gpio()

void i2ctospi_set_read_state_of_gpio ( i2ctospi_t * ctx,
uint8_t gpio_state )

Set state of the pins defined as GPIO read function.

Parameters
ctxClick object.
gpio_state
  
 - 0x01 [ I2CTOSPI_CONFIGURE_GPIO_READ_PORT_ENABLE_SS0 ] : SS0;
 - 0x02 [ I2CTOSPI_CONFIGURE_GPIO_READ_PORT_ENABLE_SS1 ] : SS1;
 - 0x04 [ I2CTOSPI_CONFIGURE_GPIO_READ_PORT_ENABLE_SS2 ] : SS2;
 - 0x08 [ I2CTOSPI_CONFIGURE_GPIO_READ_PORT_ENABLE_SS3 ] : SS3;

@description Function set the state of the pins defined as GPIO may be read into the SC18IS602B data buffer using the GPIO read by write 8-bit gpioState data to the after write targeted [ I2CTOSPI_GPIO_READ ] functio Id to the SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_set_write_state_of_gpio()

void i2ctospi_set_write_state_of_gpio ( i2ctospi_t * ctx,
uint8_t gpio_state )

Set state of the pins defined as GPIO write function.

Parameters
ctxClick object.
gpio_state
  
 - 0x01 [ I2CTOSPI_CONFIGURE_GPIO_WRITE_PORT_ENABLE_SS0 ] : SS0;
 - 0x02 [ I2CTOSPI_CONFIGURE_GPIO_WRITE_PORT_ENABLE_SS1 ] : SS1;
 - 0x04 [ I2CTOSPI_CONFIGURE_GPIO_WRITE_PORT_ENABLE_SS2 ] : SS2;
 - 0x08 [ I2CTOSPI_CONFIGURE_GPIO_WRITE_PORT_ENABLE_SS3 ] : SS3;

@description Function set state of the pins defined as GPIO write determine the state of SS3, SS2, SS1, and SS0, if they are configured as GPIO.

Note
The Port Enable function will define if these pins are used as SPI Slave Selects or if they are GPIO of the SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_spi_burst_read()

void i2ctospi_spi_burst_read ( i2ctospi_t * ctx,
i2ctospi_spi_t * spi,
uint8_t * read_data )

Generic SPI read - single address burst read function.

Parameters
ctxClick object.
spiSpi object.
Arguments:
 - slave_device               slave device ( SS0, SS1, SS2 or SS3 ).
 - function_id                8-bit function id data.
 - reg_addr                   8-bit register address.
 - n_bytes                    number of bytes to be written.
read_dataPointer to the memory location where data be stored

@description Function SPI burst read data from the targeted 8-bit register address of the SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_spi_burst_write()

void i2ctospi_spi_burst_write ( i2ctospi_t * ctx,
i2ctospi_spi_t * spi,
uint8_t * write_data )

Generic SPI write - single address burst write function.

Parameters
ctxClick object.
spiSpi object.
Arguments:
 - slave_device               slave device ( SS0, SS1, SS2 or SS3 ).
 - function_id                8-bit function id data.
 - reg_addr                   8-bit register address.
 - n_bytes                    number of bytes to be written.
write_dataPointer to the data to be written

@description Function SPI burst write data to the targeted 8-bit register address of the SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_spi_read_byte()

uint8_t i2ctospi_spi_read_byte ( i2ctospi_t * ctx,
i2ctospi_spi_t * spi )

Generic SPI read the byte of data from data buffer function.

Parameters
ctxClick object.
spiSpi object.
Arguments:
 - slave_device               slave device ( SS0, SS1, SS2 or SS3 ).
 - function_id                8-bit function id data.
 - reg_addr                   8-bit register address.
Returns
the byte of data from data buffer

@description Function SPI read the byte of data from the targeted 8-bit register address of the SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_spi_write_byte()

void i2ctospi_spi_write_byte ( i2ctospi_t * ctx,
i2ctospi_spi_t * spi,
uint8_t write_data )

Generic SPI write the byte of data to data buffer function.

Parameters
ctxClick object.
spiSpi object.
Arguments:
 - slave_device               slave device ( SS0, SS1, SS2 or SS3 )
 - function_id                8-bit function id data.
 - reg_addr                   8-bit register address.
write_data8-bit data to write

@description Function SPI write the byte of data to the targeted 8-bit register address of the SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_types_gpio()

void i2ctospi_types_gpio ( i2ctospi_t * ctx,
i2ctospi_gpio_t * gpio )

Enable the pins defined as GPIO function.

Parameters
ctxClick object.
gpioGPIO object.
Arguments:
~ ss3_val 
     - 0x00 : quasi-bidirectional;
     - 0x01 : push-pull;
     - 0x02 : input-only (high-impedance);
     - 0x03 : open-drain;
~ ss2_val
     - 0x00 : quasi-bidirectional;
     - 0x01 : push-pull;
     - 0x02 : input-only (high-impedance);
     - 0x03 : open-drain;
~ ss1_val
     - 0x00 : quasi-bidirectional;
     - 0x01 : push-pull;
     - 0x02 : input-only (high-impedance);
     - 0x03 : open-drain;
~ ss0_val
     - 0x00 : quasi-bidirectional;
     - 0x01 : push-pull;
     - 0x02 : input-only (high-impedance);
     - 0x03 : open-drain;

@description Function enable the pins defined as GPIO configured by software to one of four types on a pin-by-pin basis by write types on a selected SS pins basis 8-bit data after write targeted [ _I2CTOSPI_GPIO_CONFIGURATION ] functio Id to the SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_write_command()

void i2ctospi_write_command ( i2ctospi_t * ctx,
i2ctospi_spi_t * spi,
uint8_t command_data )

Generic write command byte of data function.

Parameters
ctxClick object.
spiSpi object.
Argument:
 - function_id                8-bit function id ( from 0xF0 to 0xF7 )
command_data8-bit command data

@description Function write the bytes of data command to the 8-bit register address of the SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.

◆ i2ctospi_write_enable()

void i2ctospi_write_enable ( i2ctospi_t * ctx,
uint8_t ss_pin_data )

SPI EEPROM wite enable function.

Parameters
ctxClick object.
ss_pin_data
- 0x01 : SS0;
- 0x02 : SS1;
- 0x04 : SS2;
- 0x08 : SS3;

@description Function SPI EEPROM wite enable by enable selected SPI port ( SS0, SS1, SS2 or SS3 ) SC18IS602B I2C-bus to SPI bridge on the I2C to SPI click board.