1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
-
- #include <stdlib.h>
- #include <stdint.h>
- #include <avr/io.h>
- #include <util/delay.h>
- #include <avr/wdt.h>
-
- #include "adc.h"
- #include "eq.h"
- #include "twislave.h"
-
- #ifndef F_CPU
- #define F_CPU 16000000L
- #endif
-
- void blinkStatus(void) {
- PORTB |= (1 << PB2);
- PORTB &= ~(1 << PB1);
- _delay_ms(250);
- PORTB &= ~(1 << PB2);
- PORTB |= (1 << PB1);
- _delay_ms(250);
- }
-
- int main(void) {
- uint8_t *music;
-
- MCUCSR = 0;
- wdt_disable();
-
- DDRB = 6;
- DDRC = 12;
- DDRD = 0;
-
- twiInit(0x42);
- adcInit();
- equalizerInit();
-
- blinkStatus();
- blinkStatus();
-
- wdt_enable(WDTO_500MS);
-
- music = equalizerGet();
- twiSetDataToSend(music);
- free(music);
-
- while (1) {
- if (twiDataWasSent()) {
- PORTB ^= (1 << PB2);
- music = equalizerGet();
- twiSetDataToSend(music);
- free(music);
- }
-
-
- PORTB ^= (1 << PB1);
- _delay_ms(1);
-
-
- wdt_reset();
- }
-
- return 0;
- }
|