source: firmware/FSC/src/application.h@ 10902

Last change on this file since 10902 was 10705, checked in by neise, 14 years ago
File size: 4.1 KB
Line 
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 254
10extern 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:
13extern U32 *status ;
14extern U32 *time_sec ;
15extern U16 *time_ms ;
16extern U16 *FR_period ;
17extern U16 *ref_resistor ;
18
19extern U32 *ad7719_values ;
20#define AD7719_VALUES_LEN_BYTE 512
21extern U08 *ad7719_enables ;
22extern U08 *ad7719_channels_ready ;
23extern U08 *ad7719_readings_since_last_muxing ;
24extern U08 *ad7719_current_channel ;
25extern U32 *ad7719_current_reading ;
26
27extern U16 *adc_values ;
28#define ADC_VALUES_LEN_BYTE 152
29extern U08 *adc_enables ;
30extern U08 *adc_channels_ready ;
31extern U08 *adc_readings_since_last_muxing ;
32extern U08 *adc_current_channel ;
33extern 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 ADC_READINGS_UNTIL_SETTLED 1
73#endif
74
75#define W5100_INPUT_CHECK_TIME 25 // defines how often the W5100 should be asked if something arrived... in ms
76
77// MAIN WORKFLOW GLOBAL VARIABLES
78
79 extern bool heartbeat_enable;
80
81
82
83// TIMER global variable
84 extern volatile U32 local_ms;
85
86// AD7719 global variables
87 extern bool ad7719_measured_all;
88 extern bool ad7719_values_printed;
89 extern bool ad7719_print_endless;
90
91// ATMEGA ADC global variables
92 #define adc_readings_until_mean 250
93 extern bool adc_measured_all;
94 extern bool adc_values_printed;
95 extern bool adc_print_endless;
96
97 extern bool once_told_you;
98 extern bool debug_mode;
99
100
101
102//-----------------------------------------------------------------------------
103extern volatile U08 app_reset_source;
104//-----------------------------------------------------------------------------
105
106void app_init(void); // Initialize application
107void app_set_watchdog_prescaler(tWDT_PRESCALE wdt_prescale); // Set watchdog prescale
108
109//methods in main ... declared here ... don't ask why ...
110// definition of some functions:
111// these function are implemented in this file, this is not doog coding style.
112// sooner or later, they will be moved into more apropriate files.
113void set_adc_enable_register();
114void set_ad7719_enable_register();
115U08 increase_adc (U08 channel);
116U08 increase_ad7719 (U08 channel);
117void check_what_measurement_was_finished() ;
118void check_if_measured_all() ;
119
120bool check_if_adc_measurement_done();
121bool check_if_ad7719_measurement_done();
122// end of function definition:
123//-----------------------------------------------------------------------------
124
125
126
127//-----------------------------------------------------------------------------
128
129#endif
Note: See TracBrowser for help on using the repository browser.