//----------------------------------------------------------------------------- #include "typedefs.h" #include "application.h" #include "spi_master.h" #include "ad7719_adc.h" #include "atmega_adc.h" #include "usart.h" #include "macros.h" #include "muxer_fsc.h" #include "output.h" #include "parser.h" #include "interpol.h" #include "w5100_spi_interface.h" #include #include #include //----------------------------------------------------------------------------- // 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 parse(); //doesn't do anything at the moment // end of function definition: //----------------------------------------------------------------------------- // MAIN WORKFLOW GLOBAL VARIABLES bool verbose; bool heartbeat_enable; // USART global variables U08 usart_rx_buffer[USART_RX_BUFFER_SIZE]; U08 usart_tx_buffer[USART_TX_BUFFER_SIZE]; U08 usart_rx_buffer_index = 0; U08 usart_tx_buffer_index = 0; U08 usart_last_char; // last received char // USART FLAGS bool usart_tx_buffer_overflow = false; // true if usart_tx_buffer was full. // TIMER global variable volatile U32 local_ms = 0; // AD7719 global variables U32 ad7719_values[TEMP_CHANNELS]; U08 ad7719_enables[CHANNEL_BITMAP]; U08 ad7719_channels_ready[CHANNEL_BITMAP]; U08 ad7719_readings_since_last_muxing = 0; U08 ad7719_current_channel = 0; U32 ad7719_current_reading = 0; bool ad7719_measured_all = false; // ATMEGA ADC global variables U08 adc_values[V_CHANNELS + I_CHANNELS + H_CHANNELS]; // stores measured voltage in steps of 16mV U08 adc_enables[V_BITMAP + I_BITMAP + H_BITMAP]; U08 adc_channels_ready[V_BITMAP + I_BITMAP + H_BITMAP]; U08 adc_readings_since_last_muxing = 0; U08 adc_current_channel = 0; U08 adc_current_reading = 0; bool adc_measured_all = false; bool once_told_you = true; bool debug_mode = false; #ifndef ___MAIN_WORKFLOW_GLOBAL_VARS #define ___MAIN_WORKFLOW_GLOBAL_VARS #define TEMP_CHANNELS 64 #define CHANNEL_BITMAP 8 #define AD7719_READINGS_UNTIL_SETTLED 1 // bei3:480ms #define V_CHANNELS 40 #define I_CHANNELS 40 #define H_CHANNELS 4 #define V_BITMAP 5 #define I_BITMAP 5 #define H_BITMAP 1 #define ADC_READINGS_UNTIL_SETTLED 1 #endif // ___MAIN_WORKFLOW_GLOBAL_VARS //----------------------------------------------------------------------------- // M A I N --- M A I N --- M A I N --- M A I N --- M A I N //----------------------------------------------------------------------------- int main(void) { app_init(); // Setup: Watchdog and I/Os usart_init(); spi_init(); // Initialize SPI interface as master // TIMER2 is used as local clock: // configure timer 2 TCCR2 = (1< counts up every 8us OCR2 = 125-1; // --> output compare interrupt occurs every 125 x 8us = 1ms // Compare Interrupt erlauben TIMSK |= (1< W5100 is in reset ... _delay_ms(50); //reset PORTB |= 1< W5100 is active _delay_ms(5); // give it 5ms to accomodate. /* PORTB |= (1< heartbeat //---------------------------------------------------------------------------- //IF we need to send away one byte, and ready to send if ( (usart_tx_buffer_index > 0) && (UCSRA & (1<