AVR-Blink/main.c

25 lines
467 B
C
Raw Normal View History

2023-11-02 21:53:55 +03:00
#include <avr/io.h>
2023-11-02 22:59:29 +03:00
#define F_CPU 8000000
2023-11-02 21:53:55 +03:00
#include <util/delay.h>
int main(void) {
#if defined(DDRC) && defined(DDRD)
#define BITS 8
DDRC = 0x3f;
DDRD = DDRB = 0xff;
#else
#define BITS 6
DDRB = 0x3f;
#endif
for (;;) {
for (uint8_t i = 0; i < BITS; ++i) {
#if defined(DDRC) && defined(DDRD)
PORTC = (PORTD = PORTB ^= _BV(i))&0x3f;
#else
PORTB ^= _BV(i);
#endif
_delay_ms(36);
}
}
return 0;
}