22 #define TWI_BAUDRATE 100000 23 #define TWI_BAUDSETTING TWI_BAUD(F_CPU, TWI_BAUDRATE) 24 #define TWI_AD7997_MASTER_PORT PORTC 26 #define AD7997_ADC2_I 0x22 27 #define AD7997_ADC1_V 0x21 32 #define AD7997_CONFIG_REG 0x02 33 #define AD7997_CONFIG_MSB 0x0F 34 #define AD7997_CONFIG_LSB 0xFB 39 #define AD7997_RESULT_REG 0x00 40 #define AD7997_CHANNEL_FLT 0x70 41 #define AD7997_RESULT_FLT 0x3FF 42 #define AD7997_READ_SEQUENCE 0x70 43 #define AD7997_SEQUENCE_RESULT (AD7997_RESULT_REG | AD7997_READ_SEQUENCE) 45 #define AD7997_READ_SINGLE 0x80 46 #define AD7997_READ_SINGLE_V1 0x80 47 #define AD7997_READ_SINGLE_V2 0x90 48 #define AD7997_READ_SINGLE_V3 0xA0 49 #define AD7997_READ_SINGLE_V4 0xB0 50 #define AD7997_READ_SINGLE_V5 0xC0 51 #define AD7997_READ_SINGLE_V6 0xD0 52 #define AD7997_READ_SINGLE_V7 0xE0 53 #define AD7997_READ_SINGLE_V8 0xF0 58 #define AD7997_CTIMER_REG 0x03 59 #define AD7997_CTIMER_bm 0x00 60 #define AD7997_CONVST_CMD 0x00 65 #define I_SGN_1_1 PIN0_bm 66 #define I_SGN_1_2 PIN1_bm 67 #define I_SGN_1_3 PIN2_bm 68 #define I_SGN_1_4 PIN3_bm 69 #define I_SGN_2_1 PIN4_bm 70 #define I_SGN_2_2 PIN5_bm 71 #define I_SGN_2_3 PIN6_bm 72 #define I_SGN_2_4 PIN7_bm 77 #define AD7997_ADC1_CONVST_PIN_bm PIN4_bm 78 #define AD7997_ADC1_CONVST_PIN_CTRL PIN4CTRL 79 #define AD7997_ADC1_CONVST_PORT PORTE 84 #define BAT_NUMMER2CHANNEL_1_1 0 85 #define BAT_NUMMER2CHANNEL_1_2 2 86 #define BAT_NUMMER2CHANNEL_1_3 4 87 #define BAT_NUMMER2CHANNEL_1_4 6 88 #define BAT_NUMMER2CHANNEL_2_1 1 89 #define BAT_NUMMER2CHANNEL_2_2 3 90 #define BAT_NUMMER2CHANNEL_2_3 5 91 #define BAT_NUMMER2CHANNEL_2_4 7 96 #define REF_VOLTAGE 3.213 97 #define ADC_RES 1024.0 99 #define SPANNUNGSTELER_1 2.613 100 #define SPANNUNGSTELER_2 1.3 103 uint8_t bat_nummer2channel[8];
105 extern int16_t current[];
106 extern float voltage[];
112 float AD7997_current_calculate_value ( uint16_t bit_code, uint8_t sensor_nummer );
116 void AD7997_CONVST_voltage_get_data (
void );
118 void leerlauf_voltage_get_data (
void );
void AD7997_current_get_data(void)
Ermittelt die Stromstärke in den Batteriestromkreisen.
void AD7997_init(void)
TWI (I2C) und ADC 1/2 werden initialisiert.
XMEGA TWI master driver header file.
TWI master driver struct.
void AD7997_voltage_get_data(void)
Ermittelt die Spannungen der Batterien.
int AD7997_current_vorzeichen(uint8_t sensor_nummer)
Ermittelt die Stromrichtung der abgefragten Batterie.