//----------------------------------------------------------------------------- #include "application.h" #include //----------------------------------------------------------------------------- volatile U08 app_reset_source; //----------------------------------------------------------------------------- void app_init(void) { app_reset_source = MCUSR; // Save last reset source MCUSR = 0x00; // Clear reset source for next reset cycle // Dangerous here: I still do not know much about the watchdog. // This code is still from Udo Juerss. // The watchdog timer is disabled by default ("startup.asm") #ifdef USE_WATCHDOG WDTCSR = WDTOE | (1 << WDE); // Enable watchdog reset (~16ms) #endif // define PORTS // USART DDRD &= ~(1< output DDRC |= 0x7F; // SB-pins -> output // SPI // set all CS's: output DDRB |= (1 << SPI_E_CS); DDRD |= (1 << SPI_AD_CS) |(1 << SPI_M_CS) |(1 << SPI_A_CS); // set all Chips selects HIGH PORTB |= (1 << SPI_E_CS); PORTD |= (1 << SPI_AD_CS) |(1 << SPI_M_CS) |(1 << SPI_A_CS); // set MOSI and SCK: output & // set MISO: input SPI_DDR |= (1 << SPI_MOSI); SPI_DDR |= (1 << SPI_SCLK); SPI_DDR &= ~(1 << SPI_MISO); // set MOSI, SCK: HIGH. MISO leave alone. SPI_PRT |= (1 << SPI_MOSI); SPI_PRT |= (1 << SPI_SCLK); //SPI_PRT |= (1 << SPI_MISO); // ADC DDRD &= ~(1<