#ifndef __APPLICATION_H #define __APPLICATION_H //----------------------------------------------------------------------------- #include "typedefs.h" //----------------------------------------------------------------------------- // in order to implement the "registers" I work with a quite long // char-array like this: # define FSC_REGISTER_LENGTH 492 extern U08 FSCregister[FSC_REGISTER_LENGTH]; // but this register is not only accessible by // FSCregister[i], but as well by special pointers like this: extern U32 *status ; extern U32 *time_sec ; extern U16 *time_ms ; extern U16 *FR_period ; extern U16 *ref_resistor ; extern U32 *ad7719_values ; #define AD7719_VALUES_LEN_BYTE 512 extern U08 *ad7719_enables ; extern U08 *ad7719_channels_ready ; extern U08 *ad7719_readings_since_last_muxing ; extern U08 *ad7719_current_channel ; extern U32 *ad7719_current_reading ; extern U16 *adc_values ; #define ADC_VALUES_LEN_BYTE 168 extern U08 *adc_enables ; extern U08 *adc_channels_ready ; extern U08 *adc_readings_since_last_muxing ; extern U08 *adc_current_channel ; extern U16 *adc_current_reading ; // using these pointers one can manipulate measurement values like this: // res_value[3] = 453212; // and then readout the most significant byte of this same value by accessing: // FSCregister[92]; // I like this very much for asking the boards status ... this is just a copy of the registers, // into the W5100 TX FIFO. // submitting the measurement values is just a partial copy... //----------------------------------------------------------------------------- // 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 //#ifdef ____WENNICHSWIRKLICHWILL #ifndef ___MAIN_WORKFLOW_GLOBAL_VARS #define ___MAIN_WORKFLOW_GLOBAL_VARS #define RESISTANCE_CHANNELS 64 #define AD7719_READINGS_UNTIL_SETTLED 3 // bei3:480ms #define VOLTAGE_CHANNELS 84 #define VOLTAGE_REGS 11 #define ADC_READINGS_UNTIL_SETTLED 1 #endif #define W5100_INPUT_CHECK_TIME 25 // defines how often the W5100 should be asked if something arrived... in ms // MAIN WORKFLOW GLOBAL VARIABLES extern bool heartbeat_enable; // TIMER global variable extern volatile U32 local_ms; // AD7719 global variables extern bool ad7719_measured_all; extern bool ad7719_values_printed; extern bool ad7719_print_endless; // ATMEGA ADC global variables #define adc_readings_until_mean 40 extern bool adc_measured_all; extern bool adc_values_printed; extern bool adc_print_endless; extern bool once_told_you; extern bool debug_mode; //----------------------------------------------------------------------------- extern volatile U08 app_reset_source; //----------------------------------------------------------------------------- void app_init(void); // Initialize application void app_set_watchdog_prescaler(tWDT_PRESCALE wdt_prescale); // Set watchdog prescale //methods in main ... declared here ... don't ask why ... // definition of some functions: // these function are implemented in this file, this is not doog 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() ; void check_if_measured_all() ; bool check_if_adc_measurement_done(); bool check_if_ad7719_measurement_done(); // end of function definition: //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- #endif