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

◆ I2C_mux_select_ch()

void I2C_mux_select_ch ( uint8_t  scheda_su_scheda_giu,
uint8_t  mainboard_postmainboard,
uint8_t  canale_da_abilitare 
)

The I2C mux.

Parameters
[in]scheda_su_scheda_giuone of the 2 boards that the postfrontend manages
[in]mainboard_postmainboardfor selecting the I2C mux on mainboard, if I2C_mainboard, or postmainboard, if I2C_postmainboard
[in]canale_da_abilitarethe channel of the mux to be enabled
Returns
No Parameters
100void I2C_mux_select_ch( uint8_t scheda_su_scheda_giu, uint8_t mainboard_postmainboard , uint8_t canale_da_abilitare){
101 tappo=0;
102 if (scheda_su_scheda_giu==I2C_mux_Scheda_giu){ /* Determine which I2C to use for one board or the other */
103 I2C_mux = &Driver_I2C1; //board down
104 GPIO_PinWrite(Reset_I2C_mux_down.porta_num, Reset_I2C_mux_down.pin_num, 0); //Let's reset the mux
105 GPIO_PinWrite(Reset_I2C_mux_postfrontend_down.porta_num, Reset_I2C_mux_postfrontend_down.pin_num, 0); //Let's reset the mux of the postfrontend
107 GPIO_PinWrite(Reset_I2C_mux_down.porta_num, Reset_I2C_mux_down.pin_num, 1);
108 GPIO_PinWrite(Reset_I2C_mux_postfrontend_down.porta_num, Reset_I2C_mux_postfrontend_down.pin_num, 1); //Let's reset the mux of the postfrontend
109 }else if (scheda_su_scheda_giu>=I2C_mux_Scheda_su){
110 I2C_mux = &Driver_I2C0; //board up
111 GPIO_PinWrite(Reset_I2C_mux_up.porta_num, Reset_I2C_mux_up.pin_num, 0); //Let's reset the mux
112 GPIO_PinWrite(Reset_I2C_mux_postfrontend_up.porta_num, Reset_I2C_mux_postfrontend_up.pin_num, 0); //Let's reset the mux of the postfrontend
114 GPIO_PinWrite(Reset_I2C_mux_up.porta_num, Reset_I2C_mux_up.pin_num, 1);
115 GPIO_PinWrite(Reset_I2C_mux_postfrontend_up.porta_num, Reset_I2C_mux_postfrontend_up.pin_num, 1); //Let's reset the mux of the postfrontend
116 }
117
118 //I2C_mux_address
119 if ( (scheda_su_scheda_giu==I2C_mux_Scheda_giu)||(scheda_su_scheda_giu>=I2C_mux_Scheda_su)){
120 if(mainboard_postmainboard==I2C_mainboard){
121 I2C_mux -> MasterTransmit( I2C_mux_address_mainboard, &canale_da_abilitare, 1,false);
122 while( I2C_mux -> GetStatus().busy); // White transmission complete
124 I2C_mux -> MasterReceive( I2C_mux_address_mainboard, &tappo, 1,false); //Read back, not needed
125 while( I2C_mux -> GetStatus().busy);
126 }else if(mainboard_postmainboard==I2C_postmainboard){
127 if(scheda_su_scheda_giu == I2C_mux_Scheda_giu){
128 //! <!-- [error_example] -->
129 I2C_mux -> MasterTransmit( I2C_mux_address_postmainboard_down, &canale_da_abilitare, 1,false);
130 while( I2C_mux -> GetStatus().busy); // White transmission complete
132 //! <!-- [error_example] -->
133 I2C_mux -> MasterReceive( I2C_mux_address_postmainboard_down, &tappo, 1,false); //Read back, not needed
134 while( I2C_mux -> GetStatus().busy);
135 }else{
136 I2C_mux -> MasterTransmit( I2C_mux_address_postmainboard_up, &canale_da_abilitare, 1,false);
137 while( I2C_mux -> GetStatus().busy); // White transmission complete
139 I2C_mux -> MasterReceive( I2C_mux_address_postmainboard_up, &tappo, 1,false); //Read back, not needed
140 while( I2C_mux -> GetStatus().busy);
141 }
142 }
143 }
144
145}
volatile uint32_t Error_bad_operation
exploited to mark the errors
void ERROR_codifica_errore(uint8_t scheda_su_scheda_giu, unsigned char error_addres, unsigned char code_to_shift, uint8_t reset_count_se_0)
If an error is found its flag is codified here.
@ I2C_Error_I2C_mux
Trouble with I2C mux communication.
@ error_address_I2C0
Error register A for I2C0.
const porta_pin_def Reset_I2C_mux_down
location of the reset pin of the I2C_mux of frontend board su or giu
Definition: Gpio.c:109
const porta_pin_def Reset_I2C_mux_up
location of the reset pin of the I2C_mux of frontend board su or giu
Definition: Gpio.c:108
const porta_pin_def Reset_I2C_mux_postfrontend_up
location of the reset pin of the I2C_mux of post-frontend board su or giu
Definition: Gpio.c:158
const porta_pin_def Reset_I2C_mux_postfrontend_down
location of the reset pin of the I2C_mux of post-frontend board su or giu
Definition: Gpio.c:159
void I2C_mux_select_ch(uint8_t scheda_su_scheda_giu, uint8_t mainboard_postmainboard, uint8_t canale_da_abilitare)
The I2C mux.
Definition: I2C_mux.c:100
#define I2C_mux_address_postmainboard_down
I2C 7 bits address of the postmainboard up I2C_mux.
Definition: I2C_mux.h:9
#define I2C_mux_Scheda_giu
Selection of the I2C1 for lower board (purtroppo \'e contorto)
Definition: I2C_mux.h:16
#define I2C_mux_address_postmainboard_up
I2C 7 bits address of the postmainboard down I2C_mux.
Definition: I2C_mux.h:8
#define I2C_mux_address_mainboard
I2C 7 bits address of the mainboard I2C_mux.
Definition: I2C_mux.h:7
#define I2C_mux_Scheda_su
Selection of the I2C0 for the upper board (purtroppo \'e contorto)
Definition: I2C_mux.h:15
void Aspetta_tanti_ms(int millisecondi)
The timing function.
Definition: Timer.c:52

Definition at line 100 of file I2C_mux.c.