1 | #ifndef __APPLICATION_H
|
---|
2 | #define __APPLICATION_H
|
---|
3 | //-----------------------------------------------------------------------------
|
---|
4 |
|
---|
5 | #include "typedefs.h"
|
---|
6 | //-----------------------------------------------------------------------------
|
---|
7 |
|
---|
8 |
|
---|
9 | //-----------------------------------------------------------------------------
|
---|
10 |
|
---|
11 | // SPI DEFINITIONS
|
---|
12 | // Port Definitions
|
---|
13 | #define SPI_PRT PORTB
|
---|
14 | #define SPI_DDR DDRB
|
---|
15 |
|
---|
16 | // Bit Definitions
|
---|
17 | #define SPI_SCLK PB7
|
---|
18 | #define SPI_MOSI PB5
|
---|
19 | #define SPI_MISO PB6
|
---|
20 |
|
---|
21 | #define SPI_E_CS PB4
|
---|
22 | #define SPI_AD_CS PD3
|
---|
23 | #define SPI_M_CS PD4
|
---|
24 | #define SPI_A_CS PD5
|
---|
25 |
|
---|
26 | //#ifdef ____WENNICHSWIRKLICHWILL
|
---|
27 | #ifndef ___MAIN_WORKFLOW_GLOBAL_VARS
|
---|
28 | #define ___MAIN_WORKFLOW_GLOBAL_VARS
|
---|
29 | #define TEMP_CHANNELS 64
|
---|
30 | #define CHANNEL_BITMAP 8
|
---|
31 | #define AD7719_READINGS_UNTIL_SETTLED 3 // bei3:480ms
|
---|
32 |
|
---|
33 | #define V_CHANNELS 40
|
---|
34 | #define I_CHANNELS 40
|
---|
35 | #define H_CHANNELS 4
|
---|
36 | #define V_BITMAP 5
|
---|
37 | #define I_BITMAP 5
|
---|
38 | #define H_BITMAP 1
|
---|
39 | #define ADC_READINGS_UNTIL_SETTLED 1
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | // MAIN WORKFLOW GLOBAL VARIABLES
|
---|
43 |
|
---|
44 | extern bool heartbeat_enable;
|
---|
45 |
|
---|
46 |
|
---|
47 |
|
---|
48 | // TIMER global variable
|
---|
49 | extern volatile U32 local_ms;
|
---|
50 |
|
---|
51 | // AD7719 global variables
|
---|
52 | extern U32 ad7719_values[TEMP_CHANNELS];
|
---|
53 | extern U08 ad7719_enables[CHANNEL_BITMAP];
|
---|
54 | extern U08 ad7719_channels_ready[CHANNEL_BITMAP];
|
---|
55 | extern U08 ad7719_readings_since_last_muxing;
|
---|
56 | extern U08 ad7719_current_channel;
|
---|
57 | extern U32 ad7719_current_reading;
|
---|
58 | extern bool ad7719_measured_all;
|
---|
59 | // ATMEGA ADC global variables
|
---|
60 | extern U08 adc_values[V_CHANNELS + I_CHANNELS + H_CHANNELS]; // stores measured voltage in steps of 16mV
|
---|
61 | extern U08 adc_enables[V_BITMAP + I_BITMAP + H_BITMAP];
|
---|
62 | extern U08 adc_channels_ready[V_BITMAP + I_BITMAP + H_BITMAP];
|
---|
63 | extern U08 adc_readings_since_last_muxing;
|
---|
64 | extern U08 adc_current_channel;
|
---|
65 | extern U08 adc_current_reading;
|
---|
66 | extern bool adc_measured_all;
|
---|
67 |
|
---|
68 | extern bool once_told_you;
|
---|
69 | extern bool debug_mode;
|
---|
70 |
|
---|
71 |
|
---|
72 |
|
---|
73 | //-----------------------------------------------------------------------------
|
---|
74 | extern volatile U08 app_reset_source;
|
---|
75 | //-----------------------------------------------------------------------------
|
---|
76 |
|
---|
77 | void app_init(void); // Initialize application
|
---|
78 | void app_set_watchdog_prescaler(tWDT_PRESCALE wdt_prescale); // Set watchdog prescale
|
---|
79 |
|
---|
80 | //methods in main ... declared here ... don't ask why ...
|
---|
81 | // definition of some functions:
|
---|
82 | // these function are implemented in this file, this is not doog coding style.
|
---|
83 | // sooner or later, they will be moved into more apropriate files.
|
---|
84 | void set_adc_enable_register();
|
---|
85 | void set_ad7719_enable_register();
|
---|
86 | U08 increase_adc (U08 channel);
|
---|
87 | U08 increase_ad7719 (U08 channel);
|
---|
88 | void check_what_measurement_was_finished() ;
|
---|
89 | void check_if_measured_all() ;
|
---|
90 | // end of function definition:
|
---|
91 | //-----------------------------------------------------------------------------
|
---|
92 |
|
---|
93 |
|
---|
94 |
|
---|
95 | //-----------------------------------------------------------------------------
|
---|
96 |
|
---|
97 | #endif
|
---|