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

Last change on this file since 17689 was 17629, checked in by dneise, 11 years ago
a lot of changes for the new firmware version. Mostly the global registers were changed
File size: 2.9 KB
Line 
1#ifndef __APPLICATION_H
2#define __APPLICATION_H
3//-----------------------------------------------------------------------------
4
5#include "typedefs.h"
6//-----------------------------------------------------------------------------
7
8#define RESISTANCE_CHANNELS 64
9#define RESISTANCE_REGS 8
10#define AD7719_READINGS_UNTIL_SETTLED 3 // when set to 3 --> we wait 480ms per sensor reading
11#define VOLTAGE_CHANNELS 84
12#define VOLTAGE_REGS 11
13#define ADC_READINGS_UNTIL_SETTLED 1
14#define ADC_VALUES_LEN_BYTE 168
15#define AD7719_VALUES_LEN_BYTE 512
16
17typedef struct {
18 U08 ad7719_readings_since_last_muxing;
19 U08 ad7719_current_channel;
20 U32 ad7719_current_reading;
21 U08 ad7719_enables[RESISTANCE_REGS];
22 U08 ad7719_channels_ready[RESISTANCE_REGS];
23 U32 ad7719_values[RESISTANCE_CHANNELS];
24 U16 ad7719_values_checksum;
25
26 U08 adc_readings_since_last_muxing;
27 U08 adc_current_channel;
28 U16 adc_current_reading;
29 U08 adc_enables[VOLTAGE_REGS];
30 U08 adc_channels_ready[VOLTAGE_REGS];
31 U16 adc_values[VOLTAGE_CHANNELS];
32 U16 adc_values_checksum;
33
34 // ----- NEW --------
35 bool ad7719_measured_all;
36 bool adc_measured_all;
37
38} FSCRegisterType;
39
40typedef struct {
41 U08 app_reset_source;
42 U32 time_sec;
43 U16 time_ms;
44} VolatileRegisterType;
45
46extern FSCRegisterType gReg;
47extern volatile VolatileRegisterType gVolReg;
48
49
50//-----------------------------------------------------------------------------
51
52// in order to check the user interface on a hardware near level.
53// user can issue 'heartbeat command'.
54// then this üpin is toggled with the 'main-while-loop-frequency'
55// --> nice check for this frequency as well
56#define HEARTBEATPIN PB3
57
58// SPI DEFINITIONS
59// Port Definitions
60#define SPI_PRT PORTB
61#define SPI_DDR DDRB
62
63// Bit Definitions
64#define SPI_SCLK PB7
65#define SPI_MOSI PB5
66#define SPI_MISO PB6
67
68#define SPI_E_CS PB4
69#define SPI_AD_CS PD3
70#define SPI_M_CS PD4
71#define SPI_A_CS PD5
72
73#define W5100_INPUT_CHECK_TIME 25 // defines how often the W5100 should be asked if something arrived... in ms
74#define ADC_READINGS_UNTIL_MEAN 40
75
76
77void app_init(void); // Initialize application
78void app_set_watchdog_prescaler(tWDT_PRESCALE wdt_prescale); // Set watchdog prescale
79
80// definition of some functions:
81// these function are implemented in this file, this is not good coding style.
82// sooner or later, they will be moved into more apropriate files.
83void set_adc_enable_register();
84void set_ad7719_enable_register();
85U08 increase_adc (U08 channel);
86U08 increase_ad7719 (U08 channel);
87void check_what_measurement_was_finished() ;
88
89
90bool check_if_adc_measurement_done();
91bool check_if_ad7719_measurement_done();
92bool check_if_measured_all();
93
94void reset_resistance_done();
95void reset_resistance_values();
96void reset_voltage_done();
97void reset_voltage_values();
98void reset_done();
99
100void write_status_via_eth();
101U16 fletcher16( U08 const *data, U16 bytes );
102
103#endif
Note: See TracBrowser for help on using the repository browser.