/* Copyright © 2020 tyrolyean * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #define F_CPU 16000000UL #include #include #include #include #include #include uint8_t mcusr_mirror __attribute__ ((section (".noinit"))); void get_mcusr(void) \ __attribute__((naked)) \ __attribute__((section(".init3"))); void get_mcusr(void) { mcusr_mirror = MCUSR; MCUSR = 0; wdt_disable(); } int routine(); int main(){ /* Disable interrupts during initialisation phase */ cli(); DDRF = 0xFF; DDRK |= (0x01<<0); DDRK |= (0x01<<1); PORTF = 0x00; PORTK |= (0x01<<0); PORTK |= (0x01<<1); PORTK &= ~(0x01<<1); _delay_us(10); PORTK |= (0x01<<1); _delay_us(10); sei(); /* Enable the hardware watchdog. In case the microcontroller fails to * finish it's task within the specified time, the watchdog will reset * the atmel cookie. */ wdt_enable(WDTO_1S); while(1){ wdt_reset(); if(routine() < 0){ } } return 0; } int routine(){ for(size_t i = 0; i < 256; i++){ PORTF = (0xFF & i); PORTK &= ~(0x01<<0); PORTK |= (0x01<<0); } _delay_ms(10); return 0; }