CROSS Technical Documentation User Manual and Technical Doc.
INFN Milano Bicocca
Loading...
Searching...
No Matches
I2C_to_parallel

Table of Contents

This chip is exploited to set the chips select

SUMMARY:

User use of I2C to Parallel



This chip is the PCA9554 (PCA9554A datasheet).


This chip is exploited to manage the chip select pins of the chips that work with SPI or with a parallel bus. They are 3 chips that are selected, by mean of the user functions by:


The 3 chips are I2C and their addresses, trasparent to the user, are:


There are 2 functions to use. The first is the initialization function: I2C_to_Parallel_ini_PCA9554() with input parameters: uint8_t scheda_su_scheda_giu, uint8_t select_PCA. The second operational function, I2C_to_Parallel_set_PCA9554_outputs_values() with input parameters: uint8_t scheda_su_scheda_giu, uint8_t select_PCA, uint8_t value is the one that allows to set the port.


The PCA9554 has 4 commands listed below. Only the fourth command, which allows to set the chip as an output port, is exploited for our purpose. For diagnostic purpose the first command, the reading command, is exploited.
The 4 commands are implicitily used in the above functions:

  1. I2C_to_Parallel_Command_read_output, Read output pin, either if they are inputs or outpus
  2. I2C_to_Parallel_Command_data_to_write, Data are written in the bits set as output
  3. I2C_to_Parallel_Command_polarity_inversion, Polarity inversion of the read bit, set all 0 in our case
  4. I2C_to_Parallel_Command_configuration_register, Configuration register, set to 0 for ouput of the corresponding bit


The scheme of the PCA9554 is in Figure Figure_I2C_to_parallel.


The first action to do is to initialize all the 3 PCA9554s. Here the case for the first:

void I2C_to_Parallel_ini_PCA9554(uint8_t scheda_su_scheda_giu, uint8_t select_PCA)
The I2C_to_Parallel_ini_PCA9554 inits the I2C_to_Parallel_ini_PCA9554 chips by setting all the output...
#define I2C_to_Parallel_name_1
the first PCA


Every chip select is active low, but one, so the starting output values, all chps off, transparent to user, is not 0xFF for the 3 chpis, but:


To easy the job there is the 4 taps vector I2C_to_Parallel_ini_set that contains the 3 values above in the last 3 positions (the first poition is unusued).


There are also structured vectors of constants that have set the parameters of interest regarding the PCA and its pin to select:

uint8_t I2C_to_parallel_chip_num; //!< This is the I2C to parallel chip to which the driver is connectted, they are 3
uint8_t I2C_to_parallel_chip__pin_num; //!< This is the outputo pin to enable
} ;
uint8_t I2C_to_parallel_chip_num
This is the I2C to parallel chip to which the driver is connectted, they are 3.
uint8_t I2C_to_parallel_chip__pin_num
This is the outputo pin to enable.
This is the struct definition for the selection of the chip select of the relays drivers.


The I2C_to_Parallel_set_PCA9554_outputs_values() allows to set any value at the output port and it is usefull for parallel bus driven chips, such as the analog mux ADG14082. For this latter refer to its specific page.
Whenever we need to manage a SPI driven chip the first think to do is to anable it and the first function to use is the I2C_to_Parallel_set_PCA9554_outputs_values() to enable the chip; after the job is done, do not forget to disable the chip. Here is an example:

speak_with_a_chipX( scheda_su_scheda_giu, #I2C_to_Parallel_name_1 ){
I2C_to_Parallel_set_PCA9554_outputs_values( scheda_su_scheda_giu, select_PCA_of_chipX, select_PCA_of_chipX ) ;
// Do the job
I2C_to_Parallel_set_PCA9554_outputs_values( scheda_su_scheda_giu, select_PCA_of_chipX, I2C_to_Parallel_ini_set[ini_value_for_the_PCA_of_chipX]) ;
}
void I2C_to_Parallel_set_PCA9554_outputs_values(uint8_t scheda_su_scheda_giu, uint8_t select_PCA, uint8_t value)
The function I2C_to_Parallel_set_PCA9554_outputs_values allow to set the output pin of the I2C to par...
const uint8_t I2C_to_Parallel_ini_set[4]
...

See also
A more specific use of the I2C_to_Parallel_set_PCA9554_outputs_values() function can be seen here Relays_driver_set_reset_channel().
The function is used in: Analog_mux_line_to_select_deselect(), instr_inizializza_tutto_da_zero_function(), Relays_driver_set_reset_channel() and PGA_GAIN().
Note
A mnemonic way to refer to the output pins is to use the enum pin_x, x=1,..,8:
pin_1, //!< This is the first pin of the output port
pin_2,
pin_3,
pin_4,
pin_5,
pin_6,
pin_7,
pin_8 //!< This is the last pin of the output port
} ;
I2C_to_Parallel_pin_type
These are the aliases for the I2C to parallel output.
@ pin_1
This is the first pin of the output port.
@ pin_8
This is the last pin of the output port.

Figure I2C_to_parallel 1: I2C to parallel PCA9554

br

The codes for mamnaging the mux are: