Hanna
Sourcecode Batteriemanagementsystem
ad7997.h
gehe zur Dokumentation dieser Datei
1 
14 #include <stdint.h>
15 #include "twi_master_driver.h"
16 
17 #ifndef AD7997_H_
18 #define AD7997_H_
19 
21 
22 #define TWI_BAUDRATE 100000
23 #define TWI_BAUDSETTING TWI_BAUD(F_CPU, TWI_BAUDRATE)
24 #define TWI_AD7997_MASTER_PORT PORTC
25 
26 #define AD7997_ADC2_I 0x22
27 #define AD7997_ADC1_V 0x21
28 
29 
30 
32 #define AD7997_CONFIG_REG 0x02
33 #define AD7997_CONFIG_MSB 0x0F
34 #define AD7997_CONFIG_LSB 0xFB
35 
36 
37 
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)
44 
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
54 
55 
57 
58 #define AD7997_CTIMER_REG 0x03
59 #define AD7997_CTIMER_bm 0x00
60 #define AD7997_CONVST_CMD 0x00
61 
62 
63 
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
73 
74 
76 
77 #define AD7997_ADC1_CONVST_PIN_bm PIN4_bm
78 #define AD7997_ADC1_CONVST_PIN_CTRL PIN4CTRL
79 #define AD7997_ADC1_CONVST_PORT PORTE
80 
81 
83 
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
92 
93 
95 
96 #define REF_VOLTAGE 3.213
97 #define ADC_RES 1024.0
98 #define R_MESS 0.015
99 #define SPANNUNGSTELER_1 2.613
100 #define SPANNUNGSTELER_2 1.3
101 
102 
103 uint8_t bat_nummer2channel[8];
104 
105 extern int16_t current[];
106 extern float voltage[];
107 extern TWI_Master_t twiAD7997;
108 
109 void AD7997_init ( void );
110 
111 void AD7997_current_get_data ( void );
112 float AD7997_current_calculate_value ( uint16_t bit_code, uint8_t sensor_nummer );
113 int AD7997_current_vorzeichen ( uint8_t sensor_nummer );
114 
115 void AD7997_voltage_get_data ( void );
116 void AD7997_CONVST_voltage_get_data ( void );
117 
118 void leerlauf_voltage_get_data ( void );
119 
120 #endif /* AD7997_H_ */
void AD7997_current_get_data(void)
Ermittelt die Stromstärke in den Batteriestromkreisen.
Definition: ad7997.c:128
void AD7997_init(void)
TWI (I2C) und ADC 1/2 werden initialisiert.
Definition: ad7997.c:75
XMEGA TWI master driver header file.
TWI master driver struct.
void AD7997_voltage_get_data(void)
Ermittelt die Spannungen der Batterien.
Definition: ad7997.c:211
int AD7997_current_vorzeichen(uint8_t sensor_nummer)
Ermittelt die Stromrichtung der abgefragten Batterie.
Definition: ad7997.c:168