avr/tron-bag/main.c

67 lines
1.3 KiB
C

#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <dio.h>
/*
#include <simavr/avr/avr_mcu_section.h>
AVR_MCU(F_CPU, "attiny85");
const struct avr_mmcu_vcd_trace_t _mytrace[] _MMCU_ = {
{ AVR_MCU_VCD_SYMBOL("GTCCR"), .what = (void *)&GTCCR, },
{ AVR_MCU_VCD_SYMBOL("TCCR0A"), .what = (void *)&TCCR0A, },
{ AVR_MCU_VCD_SYMBOL("TCCR0B"), .what = (void *)&TCCR0B, },
{ AVR_MCU_VCD_SYMBOL("PORTB"), .what = (void *)&PORTB, },
{ AVR_MCU_VCD_SYMBOL("TCNT0"), .what = (void *)&TCNT0, },
};
*/
#define FPS 10
#define FPS_MS 1000 / FPS
#define MULT 5
/*
typedef struct {
uint8_t value;
int8_t inc;
} counter_t;
void counter_update(counter_t *self) {
int16_t value = self->value;
value += self->inc;
if (value >= 255) {
self->value = 255;
self->inc = -1;
} else if (value <= 0) {
self->value = 0;
self->inc = 1;
} else {
self->value = value;
}
}
*/
int main(void) {
DDRB = 0xff;
PORTB = 0;
TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM01) | _BV(WGM00);
TCCR0B = _BV(CS00);
uint8_t brightness = 1;
GTCCR = 0;
while(1) {
OCR0A = brightness;
OCR0B = brightness;
_delay_ms(100);
brightness += 1;
}
return 0;
}