AVR1631 - Energy Meter Reference Design with ATxmega32A4  Rev 1.0
 All Data Structures Files Functions Variables Typedefs Macros
meter.h
Go to the documentation of this file.
1 /* This file has been prepared for Doxygen automatic documentation generation.*/
49 #ifndef METER_H
50 #define METER_H
51 
52 #include <ioavr.h>
53 #include <math.h>
54 #include "clksys_driver.h"
55 #include "adc_driver.h"
56 #include "rtc_driver.h"
57 #include "meter_calculations.h"
58 #include "meter_calibration.h"
59 #include "meter_initialisation.h"
60 #include "meter_lcd_module.h"
61 #include "meter_rtc.h"
62 #include "avr_compiler.h"
63 
64 #define RTC_CYCLES_1S 1024
65 #define TAMPER_CURRENT_REVERSAL PIN0_bm
66 #define TAMPER_EARTH_FAULT PIN1_bm
67 #define TAMPER_NEUTRAL_CUT PIN3_bm
68 #define F_CPU 32000000UL
69 #define F_TIMER 500000UL //F_TIMER = (F_CPU/64)
70 #define F_SAMPLING 124 //PER = F_TIMER/Sampling_freq - 1
71 
72 #define POWERED_UP 0
73 #define POWER_OFF_DETECTED 1
74 #define POWER_OFF 2
75 #define POWER_ON_DETECTED 2
76 
77 extern uint8_t rtc_flag;
78 extern uint8_t cover_open_flag;
79 
80 
81 void tamper_check(void);
82 
83 
85 {
87  uint16_t volt_const;
89  uint16_t shunt_offset[7];
91  int32_t watt_offset[7];
93  float kwh;
95  uint16_t shunt_const[7];
97  float watt_const[7];
99  float A1[7];
101  float B1[7];
102 };
103 __eeprom extern struct coefficient eeprom_t;
104 extern struct coefficient meter_t;
105 #define eeprom eeprom_t
106 #define meter meter_t
107 
109 int16_t adc_iadc_debug(void);
110 int16_t adc_vadc_debug(void);
111 extern int16_t debug_count, debug_count1;
112 
113 
114 #endif