4#include "tutti_gli_header.h"
114 int32_t mio_SCS_Val ;
115 int32_t mio_CCLKCFG_Val;
116 int32_t mio_PCLKSEL0_Val;
117 int32_t mio_PCLKSEL1_Val;
118 int32_t mio_CLKSRCSEL_Val;
119 int32_t mio_PLL0CFG_Val;
120 int32_t mio_PLL0_SETUP;
132 uint8_t canale_, trimmer_,dati_letti[4];
142 SystemCoreClockUpdate();
143 SysTick_Config(SystemCoreClock/1000);
147 LED_remote_control=
false;
149 if(
rx_data[6]) NVIC_SystemReset();
153 scheda_su_scheda_giu=0;
157 LPC_SC->PCONP |= 1 <<15 ;
233 for( canale_=0; canale_ <6; canale_ ++ ){
250 for( canale_=0; canale_ <6; canale_ ++ ){
255 for( canale_=0; canale_ <6; canale_ ++ ){
256 for(trimmer_=0; trimmer_<4;trimmer_++){
262 for( canale_=0; canale_ <6; canale_ ++ ){
267 for( canale_=0; canale_ <6; canale_ ++ ){
273 for( canale_=0; canale_ <6; canale_ ++ ){
274 for( trimmer_=0; trimmer_ <4; trimmer_ ++ ){
283 for( canale_=0; canale_ <6; canale_ ++ ){
289 for( canale_=0; canale_ <6; canale_ ++ ){
295 uint8_t scheda_su_scheda_giu_;
296 for(scheda_su_scheda_giu_=0;scheda_su_scheda_giu_ <2;scheda_su_scheda_giu_++){
297 for (canale_=0; canale_<6;canale_++){
299 if( *(uint32_t *)dati_letti == 0){
301 preamplifier_fine_step_trimmer[canale_ + scheda_su_scheda_giu_ *6] = *(int32_t *)dati_letti;
303 preamplifier_coarse_step_trimmer[canale_ + scheda_su_scheda_giu_ *6] = *(int32_t *)dati_letti;
310 for( canale_=0; canale_ <6; canale_ ++ ){
323 mio_SCS_Val = LPC_SC->SCS;
324 mio_CCLKCFG_Val= LPC_SC->CCLKCFG;
325 mio_PCLKSEL0_Val=LPC_SC->PCLKSEL0;
326 mio_PCLKSEL1_Val=LPC_SC->PCLKSEL1;
327 mio_CLKSRCSEL_Val=LPC_SC->CLKSRCSEL;
328 mio_PLL0CFG_Val=LPC_SC->PLL0CFG;
329 mio_PLL0_SETUP=LPC_SC->PLL0CON;
353 if( chi_resettare & 2){
void ADC_sleep_ON_OFF(uint8_t up_down, uint8_t ADC_ON_1_OFF_0_NOP_GT1)
ADC is set to sleep or awake.
void ADC_Wakeup(uint8_t up_down)
ADC Wakeup and 24 bits reading.
volatile uint8_t ADC_sleep_off
if 0 ADC in sleep when not working, ADC>1 ADC never sleep
void ADC_selfcal_zero_scale(uint8_t up_down)
ADC self-calibration. ADC needs to be pre-selected.
void ADC_scrittura_registro(char ADC_0_o_1, uint8_t up_down, uint8_t indirizzo_registro_ch0, int32_t value_to_write)
This function allows to read a whatver regsiter of the ADC.
volatile uint8_t rx_data[8]
Received data vector.
void CAN_Inizialize(void)
The CAN initialization function.
void PGA_GAIN_CROSS(uint8_t scheda_su_scheda_giu, uint8_t canale, uint8_t PGA_gain_to_set)
Here the 2 digital signals from the trimmer are exploited to set the gain of the input stage of the P...
void Relays_driver_set_reset_channel(uint8_t scheda_su_giu, uint8_t numero_canale, uint8_t valore_da_trasmettere)
Setting the state of the detector realis: pre connected to detector or intrnal resistor,...
#define Detector_prea_to_GND
#define Detector_bias_diretto
#define Detector_large_RLOAD
void LED_pin_configuration(void)
Red and Green LED pin configuration and reset.
void ADC_pin_configurations(void)
ADc pins are initialized here.
void Configure_Reset_selection_port_analog_mux_ResIn_ADC_buffer(void)
Set the reset pins of te analog mux's. Take care: reset=0 means output off.
void Configure_Reset_I2C_mux(void)
Set the reset pins of te I2C mux, reset the I2C mux and put them into operation.
void Configure_Bit_Address_for_CAN(void)
Switches for the selection of the hw CAN bus address. Pin are set as input with internal pull-up.
void I2C_0_Initialize(void)
The I2C_0 initialize.
void I2C_1_Initialize(void)
The I2C_1 initialize.
#define I2C_mux_Scheda_giu
Selection of the I2C1 for lower board (purtroppo \'e contorto)
#define I2C_mux_Scheda_su
Selection of the I2C0 for the upper board (purtroppo \'e contorto)
void termometro_sht_down(uint8_t scheda_su_scheda_giu, uint8_t canale)
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]
...
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_3
the third PCA
#define I2C_to_Parallel_name_1
the first PCA
#define I2C_to_Parallel_name_2
the second PCA
void Setting_of_the_pointer_for_command_parser(void)
The pointer to the instruction functions is constructed here.
void LED_accendi_spegni(uint8_t LED, uint8_t accendi_1_spegni_0)
This function turns ON or OFF any of the selcted LED.
void EPROM_lettura_M24C32_64(uint8_t scheda_su_scheda_giu_, uint8_t mainboard_postmainboard, uint8_t canale, short indirizzo_memoria, uint8_t *dati_letti)
Read from preamplifier and on-board flashes.
void EPROM_scrittura_M24C32_64(uint8_t scheda_su_scheda_giu, uint8_t mainboard_postmainboard, uint8_t canale, short indirizzo_memoria, uint8_t *dati_da_scrivere)
Wriring the EEPROM.
void EPROM_store_recover_state_M24C32_64(uint8_t scheda_su_scheda_giu, uint8_t canali_da_regolare, uint8_t set_1_store_0, uint8_t startup_1_user_0)
Store the system state or recover and apply the system state.
void EPROM_restore_detector_slopes_in_pream(uint8_t scheda_su_scheda_giu, uint8_t canale)
[fun_EPROM_store_recover_detector_voltage_M24C32_64]
@ Memory_mainboard_address_fw
Mainboard fw version.
@ Memory_postmainboard_ADCs_always_ON_0_powerdown_1
ADCs powerdown ON if 0, always ON if >1.
@ Memory_postmainboard_micro_PD_wait_time_in_sec
wait time before microcontroller power down since last operation
@ Memory_postmainboard_micro_powdown_active_1_alwaysON_0
microntroller aoutopower OFF if true, always ON if false
@ Memory_preamplifier_slope_calibration_ON_0_OFF_ff
slope trimmer active if zero
@ Memory_preamplifier_address_fine_trimmer_slope_offset
fine slope for trimmer offset
@ Memory_preamplifier_address_coarse_trimmer_slope_offset
coarse slope for trimmer offset
void PGA_trimmer_gain(uint8_t scheda_su_scheda_giu, uint8_t canale)
Here the PGA on mainboard implemented with trimmers in feedback is managed.
volatile uint32_t POWER_DOWN_MAX_ATTESA
upper limit for POWER_DOWN_TEMPO_ATTESA
#define preamplifier_scrivi_il_trimmer
void SPI_Inizialize(void)
SPI is initialized here. Its ise t at 8 bits and 100 KHz, as default.
void Aspetta_tanti_ms(int millisecondi)
The timing function.
void detector_scrittura_lettura_trimmer_bias(uint8_t scheda_su_scheda_giu, uint8_t canale, uint8_t trimmer, uint8_t valore, uint8_t scrivi_1_leggi_0)
Setting the value of any trimmer for detector biasing, the contents of the trimmers are stored in the...
void preamplifier_scrittura_lettura_trimmer(uint8_t scheda_su_scheda_giu, uint8_t canale, uint8_t trimmer, uint8_t valore, uint8_t scrivi_1_leggi_0)
Setting the value of any trimmer for preamplifier trimmer, the contents of the trimmers are stored in...
void instr_inizializza_tutto_da_zero_function(void)
Start-up function.
void instr_periferal_reset_function(void)
I2C, SPI and CAN can be rest.
#define __INT_DATE__
Here the fw version is created that coincides with the date of compilation.
bool flag_power_down
if flag_power_down is true the u-controller goes in power down after a while
volatile int8_t vettore_istruzioni[8]
This is a copy of the received 8 bytes from the CAN.
unsigned int FW_version
This is where the FW version is stored.
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.