1 | #ifndef __APPLICATION_H
|
---|
2 | #define __APPLICATION_H
|
---|
3 | //-----------------------------------------------------------------------------
|
---|
4 |
|
---|
5 | #include "typedefs.h"
|
---|
6 | //-----------------------------------------------------------------------------
|
---|
7 | // in order to implement the "registers" I work with a quite long
|
---|
8 | // char-array like this:
|
---|
9 | # define FSC_REGISTER_LENGTH 492
|
---|
10 | extern U08 FSCregister[FSC_REGISTER_LENGTH];
|
---|
11 | // but this register is not only accessible by
|
---|
12 | // FSCregister[i], but as well by special pointers like this:
|
---|
13 | extern U32 *status ;
|
---|
14 | extern U32 *time_sec ;
|
---|
15 | extern U16 *time_ms ;
|
---|
16 | extern U16 *FR_period ;
|
---|
17 | extern U16 *ref_resistor ;
|
---|
18 |
|
---|
19 | extern U32 *ad7719_values ;
|
---|
20 | #define AD7719_VALUES_LEN_BYTE 512
|
---|
21 | extern U08 *ad7719_enables ;
|
---|
22 | extern U08 *ad7719_channels_ready ;
|
---|
23 | extern U08 *ad7719_readings_since_last_muxing ;
|
---|
24 | extern U08 *ad7719_current_channel ;
|
---|
25 | extern U32 *ad7719_current_reading ;
|
---|
26 |
|
---|
27 | extern U16 *adc_values ;
|
---|
28 | #define ADC_VALUES_LEN_BYTE 168
|
---|
29 | extern U08 *adc_enables ;
|
---|
30 | extern U08 *adc_channels_ready ;
|
---|
31 | extern U08 *adc_readings_since_last_muxing ;
|
---|
32 | extern U08 *adc_current_channel ;
|
---|
33 | extern U16 *adc_current_reading ;
|
---|
34 | // using these pointers one can manipulate measurement values like this:
|
---|
35 | // res_value[3] = 453212;
|
---|
36 | // and then readout the most significant byte of this same value by accessing:
|
---|
37 | // FSCregister[92];
|
---|
38 | // I like this very much for asking the boards status ... this is just a copy of the registers,
|
---|
39 | // into the W5100 TX FIFO.
|
---|
40 | // submitting the measurement values is just a partial copy...
|
---|
41 |
|
---|
42 | //-----------------------------------------------------------------------------
|
---|
43 |
|
---|
44 | // in order to check the user interface on a hardware near level.
|
---|
45 | // user can issue 'heartbeat command'.
|
---|
46 | // then this üpin is toggled with the 'main-while-loop-frequency'
|
---|
47 | // --> nice check for this frequency as well
|
---|
48 | #define HEARTBEATPIN PB3
|
---|
49 |
|
---|
50 | // SPI DEFINITIONS
|
---|
51 | // Port Definitions
|
---|
52 | #define SPI_PRT PORTB
|
---|
53 | #define SPI_DDR DDRB
|
---|
54 |
|
---|
55 | // Bit Definitions
|
---|
56 | #define SPI_SCLK PB7
|
---|
57 | #define SPI_MOSI PB5
|
---|
58 | #define SPI_MISO PB6
|
---|
59 |
|
---|
60 | #define SPI_E_CS PB4
|
---|
61 | #define SPI_AD_CS PD3
|
---|
62 | #define SPI_M_CS PD4
|
---|
63 | #define SPI_A_CS PD5
|
---|
64 |
|
---|
65 | //#ifdef ____WENNICHSWIRKLICHWILL
|
---|
66 | #ifndef ___MAIN_WORKFLOW_GLOBAL_VARS
|
---|
67 | #define ___MAIN_WORKFLOW_GLOBAL_VARS
|
---|
68 | #define RESISTANCE_CHANNELS 64
|
---|
69 | #define AD7719_READINGS_UNTIL_SETTLED 3 // bei3:480ms
|
---|
70 |
|
---|
71 | #define VOLTAGE_CHANNELS 84
|
---|
72 | #define VOLTAGE_REGS 11
|
---|
73 | #define ADC_READINGS_UNTIL_SETTLED 1
|
---|
74 | #endif
|
---|
75 |
|
---|
76 | #define W5100_INPUT_CHECK_TIME 25 // defines how often the W5100 should be asked if something arrived... in ms
|
---|
77 |
|
---|
78 | // MAIN WORKFLOW GLOBAL VARIABLES
|
---|
79 |
|
---|
80 | extern bool heartbeat_enable;
|
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 | // TIMER global variable
|
---|
85 | extern volatile U32 local_ms;
|
---|
86 |
|
---|
87 | // AD7719 global variables
|
---|
88 | extern bool ad7719_measured_all;
|
---|
89 | extern bool ad7719_values_printed;
|
---|
90 | extern bool ad7719_print_endless;
|
---|
91 |
|
---|
92 | // ATMEGA ADC global variables
|
---|
93 | #define adc_readings_until_mean 40
|
---|
94 | extern bool adc_measured_all;
|
---|
95 | extern bool adc_values_printed;
|
---|
96 | extern bool adc_print_endless;
|
---|
97 |
|
---|
98 | extern bool once_told_you;
|
---|
99 | extern bool debug_mode;
|
---|
100 |
|
---|
101 |
|
---|
102 |
|
---|
103 | //-----------------------------------------------------------------------------
|
---|
104 | extern volatile U08 app_reset_source;
|
---|
105 | //-----------------------------------------------------------------------------
|
---|
106 |
|
---|
107 | void app_init(void); // Initialize application
|
---|
108 | void app_set_watchdog_prescaler(tWDT_PRESCALE wdt_prescale); // Set watchdog prescale
|
---|
109 |
|
---|
110 | //methods in main ... declared here ... don't ask why ...
|
---|
111 | // definition of some functions:
|
---|
112 | // these function are implemented in this file, this is not doog coding style.
|
---|
113 | // sooner or later, they will be moved into more apropriate files.
|
---|
114 | void set_adc_enable_register();
|
---|
115 | void set_ad7719_enable_register();
|
---|
116 | U08 increase_adc (U08 channel);
|
---|
117 | U08 increase_ad7719 (U08 channel);
|
---|
118 | void check_what_measurement_was_finished() ;
|
---|
119 | void check_if_measured_all() ;
|
---|
120 |
|
---|
121 | bool check_if_adc_measurement_done();
|
---|
122 | bool check_if_ad7719_measurement_done();
|
---|
123 | // end of function definition:
|
---|
124 | //-----------------------------------------------------------------------------
|
---|
125 |
|
---|
126 |
|
---|
127 |
|
---|
128 | //-----------------------------------------------------------------------------
|
---|
129 |
|
---|
130 | #endif
|
---|