-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
66 lines (48 loc) · 981 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<avr/io.h>
#include<avr/interrupt.h>
#include<stdlib.h>
#include "spi.h"
#include "play.h"
#include "sdcard.h"
#include "fat32.h"
volatile BUFFER buffer;
volatile FAT32 fat;
volatile uint8_t playlist, max, state;
int main(void)
{
DDRC = 0xFF;
PORTC = 0xFF;
//Enable Interrupts
sei();
spi_init();
sd_card_init();
config_buttons();
PORTC = 0x00;
fat32_init();
WAVE wav[5];
snd_output_init();
max = list_wav_files(wav);
playlist = 0;
read_wave_info(&wav[playlist]);
start_music(&wav[playlist]);
while(1)
{
if(buffer.play_pos >= BUFFER_SIZE)
{
buffer.play_pos = 0;
fat32_read_half();
}
else if(buffer.play_pos == BUFFER_HALF)
fat32_read_half();
if(state == NEXT)
{
playlist++;
if(playlist == max)
playlist = 0;
read_wave_info(&(wav[playlist]));
start_music(&(wav[playlist]));
state = PLAYING;
}
}
return 0;
}