ADC Wakeup and 24 bits reading.
433long int ADC_lettura_24bit(
char line_to_read_to_select_ADCch0_ADCch1 , uint8_t up_down, uint8_t cosa_fare){
442 ARM_SPI_STATUS errorone;
443 unsigned int risultato_= 0xffffffff;
445 if (up_down>1) up_down=1;
448 long int risultato=0;
449 if (
ADC_node_map[line_to_read_to_select_ADCch0_ADCch1] < 16) ADC_0_o_1=0;
450 if ( (
ADC_node_map[line_to_read_to_select_ADCch0_ADCch1] >=16) ) ADC_0_o_1=1;
452 uint8_t ii=0,scelta_ADC=ADC_mode_reg_ch0, valore_da_trasmettere[4]={0,0,0,0};
453 uint8_t indirizzo_registro_lettura=read_from_CH0 ;
454 uint8_t valore_da_ricevere[4];
455 const porta_pin_def *ref_locale, *ref_locale_ADCready, *ref_locale_ResBuffer, *ref_locale_ResBuffer_;
479 scelta_ADC=ADC_mode_reg_ch1;
480 indirizzo_registro_lettura=read_from_CH1;
485 GPIO_PinWrite(ref_locale->porta_num, ref_locale->pin_num, 0);
492 valore_da_trasmettere[0]= scelta_ADC; valore_da_trasmettere[1]= ADC_mode_reg_set_single_24bit;
494 SPIdrv->Send ( &valore_da_trasmettere ,2);
502 errorone=SPIdrv->GetStatus();
503 status = SPIdrv->Control(ARM_SPI_ABORT_TRANSFER,0);
506 GPIO_PinWrite(ref_locale->porta_num, ref_locale->pin_num, 1);
511 if ( registro38 != 0x70){
514 while (( GPIO_PinRead(ref_locale_ADCready->porta_num,ref_locale_ADCready->pin_num) == 1 ) && (limite<10)){
520 GPIO_PinWrite(ref_locale->porta_num, ref_locale->pin_num, 0);
522 uint8_t dati_da_trasmettere[]={indirizzo_registro_lettura,0,0,0};
523 SPIdrv->Transfer (&dati_da_trasmettere, &valore_da_ricevere ,4);
525 while( (SPIdrv->GetStatus().busy) && (limite<10) ){
530 errorone=SPIdrv->GetStatus();
531 status = SPIdrv->Control(ARM_SPI_ABORT_TRANSFER,0);
535 GPIO_PinWrite(ref_locale->porta_num, ref_locale->pin_num, 1);
537 risultato_ =(valore_da_ricevere[1]<<16) + (valore_da_ricevere[2]<<8 )+( valore_da_ricevere[3] );
539 GPIO_PinWrite(ref_locale->porta_num, ref_locale->pin_num, 1);
547 risultato = ( (
long long int) ( (
int)(risultato_ << 1) - (1 << 24) ) * 78125 ) >> 17 ;
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.
long int ADC_lettura_24bit(char line_to_read_to_select_ADCch0_ADCch1, uint8_t up_down, uint8_t cosa_fare)
ADC Wakeup and 24 bits reading.
uint32_t ADC_lettura_registro(char ADC_0_o_1, uint8_t up_down, uint8_t registro_ch0)
This function allows to read a whatver regsiter of the ADC.
volatile uint8_t ADC_sleep_off
if 0 ADC in sleep when not working, ADC>1 ADC never sleep
#define spi_clock_for_relais
[ref_spi_clock_for_relais]
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.
@ ADC_RDY_pin_fault
ADC ready not received.
@ error_address_reg_ADC0
Error register for ADC0.
@ error_address_SPI
Error register for SPI.
const porta_pin_def ADC_ready_down
Configuration ADC pin.
const porta_pin_def ADC_Chip_Sel_up
Configuration ADC pin.
const uint8_t ADC_node_map[]
Mapping to mux's on postmainboard. Its syntax: bits 0 to 3 are common to all the MUXs and select one ...
const porta_pin_def ADC_ready_up
Configuration ADC pin.
const porta_pin_def ADC_ResIn_A_buffer_down
Refernce to fgnd of theADC input buffer, if 1 there is a 10kOhm connected to GND.
const porta_pin_def ADC_ResIn_A_buffer_up
Refernce to fgnd of theADC input buffer, if 1 there is a 10kOhm connected to GND.
const porta_pin_def ADC_Chip_Sel_down
Configuration ADC pin.
const porta_pin_def ADC_ResIn_B_buffer_down
Refernce to fgnd of theADC input buffer, if 1 there is a 10kOhm connected to GND.
const porta_pin_def ADC_ResIn_B_buffer_up
Refernce to fgnd of theADC input buffer, if 1 there is a 10kOhm connected to GND.
#define I2C_mux_Scheda_giu
Selection of the I2C1 for lower board (purtroppo \'e contorto)
uint32_t evento_SPI
This is the variable which resembles the flags from the communication.
#define SPI_control_for_relay_driver
[ref_SPI_control_for_relay_driver]
void Aspetta_tanti_ms(int millisecondi)
The timing function.