#ifndef __APPLICATION_H #define __APPLICATION_H //----------------------------------------------------------------------------- #include "typedefs.h" //----------------------------------------------------------------------------- #define RESISTANCE_CHANNELS 64 #define RESISTANCE_REGS 8 #define AD7719_READINGS_UNTIL_SETTLED 3 // when set to 3 --> we wait 480ms per sensor reading #define VOLTAGE_CHANNELS 84 #define VOLTAGE_REGS 11 #define ADC_READINGS_UNTIL_SETTLED 1 #define ADC_VALUES_LEN_BYTE 168 #define AD7719_VALUES_LEN_BYTE 512 typedef struct { U08 ad7719_readings_since_last_muxing; U08 ad7719_current_channel; U32 ad7719_current_reading; U08 ad7719_enables[RESISTANCE_REGS]; U08 ad7719_channels_ready[RESISTANCE_REGS]; U32 ad7719_values[RESISTANCE_CHANNELS]; U16 ad7719_values_checksum; U08 adc_readings_since_last_muxing; U08 adc_current_channel; U16 adc_current_reading; U08 adc_enables[VOLTAGE_REGS]; U08 adc_channels_ready[VOLTAGE_REGS]; U16 adc_values[VOLTAGE_CHANNELS]; U16 adc_values_checksum; // ----- NEW -------- bool ad7719_measured_all; bool adc_measured_all; } FSCRegisterType; typedef struct { U08 app_reset_source; U32 time_sec; U16 time_ms; } VolatileRegisterType; extern FSCRegisterType gReg; extern volatile VolatileRegisterType gVolReg; //----------------------------------------------------------------------------- // in order to check the user interface on a hardware near level. // user can issue 'heartbeat command'. // then this üpin is toggled with the 'main-while-loop-frequency' // --> nice check for this frequency as well #define HEARTBEATPIN PB3 // SPI DEFINITIONS // Port Definitions #define SPI_PRT PORTB #define SPI_DDR DDRB // Bit Definitions #define SPI_SCLK PB7 #define SPI_MOSI PB5 #define SPI_MISO PB6 #define SPI_E_CS PB4 #define SPI_AD_CS PD3 #define SPI_M_CS PD4 #define SPI_A_CS PD5 #define W5100_INPUT_CHECK_TIME 25 // defines how often the W5100 should be asked if something arrived... in ms #define ADC_READINGS_UNTIL_MEAN 40 void app_init(void); // Initialize application void app_set_watchdog_prescaler(tWDT_PRESCALE wdt_prescale); // Set watchdog prescale // definition of some functions: // these function are implemented in this file, this is not good coding style. // sooner or later, they will be moved into more apropriate files. void set_adc_enable_register(); void set_ad7719_enable_register(); U08 increase_adc (U08 channel); U08 increase_ad7719 (U08 channel); void check_what_measurement_was_finished() ; bool check_if_adc_measurement_done(); bool check_if_ad7719_measurement_done(); bool check_if_measured_all(); void reset_resistance_done(); void reset_resistance_values(); void reset_voltage_done(); void reset_voltage_values(); void reset_done(); void write_status_via_eth(); U16 fletcher16( U08 const *data, U16 bytes ); #endif