diff options
Diffstat (limited to 'src/inc/spi/dev/audio_vs1011.h')
-rwxr-xr-x | src/inc/spi/dev/audio_vs1011.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/inc/spi/dev/audio_vs1011.h b/src/inc/spi/dev/audio_vs1011.h new file mode 100755 index 0000000..ec97550 --- /dev/null +++ b/src/inc/spi/dev/audio_vs1011.h | |||
@@ -0,0 +1,91 @@ | |||
1 | #ifndef AUDIO_VS1011_H | ||
2 | #define AUDIO_VS1011_H | ||
3 | |||
4 | #include <avr/io.h> | ||
5 | #include <util/delay.h> | ||
6 | #include <inttypes.h> | ||
7 | #include <avr/eeprom.h> | ||
8 | |||
9 | #include "../spi.h" | ||
10 | /// #include "../../uart/uart.h" | ||
11 | /// #include "../../stdout.h" | ||
12 | |||
13 | |||
14 | #define audio_vs1011_enable() PORTC &= ~(1<<PC6); // <XDCS> | ||
15 | #define audio_vs1011_disable() PORTC |= (1<<PC6); // </XDCS> | ||
16 | #define audio_vs1011_isDREQ() (PIND & (1<<PD5)) | ||
17 | #define audio_vs1011_waitDREQ(); loop_until_bit_is_set(PIND, PD5); | ||
18 | |||
19 | |||
20 | // [OPERATIONS] | ||
21 | #define VS_WRITE 0x2 | ||
22 | #define VS_READ 0x3 | ||
23 | |||
24 | |||
25 | // [SCI REGISTERS] - page 29 | ||
26 | #define SCI_MODE 0x0 // Mode control | ||
27 | #define SCI_STATUS 0x1 // Status of VS1011e | ||
28 | #define SCI_BASS 0x2 // Built-in bass/treble enhancer | ||
29 | #define SCI_CLOCKF 0x3 // Clock freq + multiplier | ||
30 | #define SCI_DECODE_TIME 0x4 // Decode time in seconds | ||
31 | #define SCI_AUDATA 0x5 // Misc. audio data | ||
32 | #define SCI_WRAM 0x6 // RAM write/read | ||
33 | #define SCI_WRAMADDR 0x7 // Base address for RAM write/read | ||
34 | #define SCI_HDAT0 0x8 // Stream header data 0 | ||
35 | #define SCI_HDAT1 0x9 // Stream header data 1 | ||
36 | #define SCI_AIADDR 0xA // Start address of application | ||
37 | #define SCI_VOL 0xB // Volume control | ||
38 | #define SCI_AICTRL0 0xC // Application control register 0 | ||
39 | #define SCI_AICTRL1 0xD // Application control register 1 | ||
40 | #define SCI_AICTRL2 0xE // Application control register 2 | ||
41 | #define SCI_AICTRL3 0xF // Application control register 3 | ||
42 | |||
43 | // [VALUES::SCI_MODE] | ||
44 | #define SM_DIFF 0x1 // Differential | ||
45 | #define SM_LAYER12 0x2 // Allow MPEG layers I & II | ||
46 | #define SM_RESET 0x4 // Soft reset | ||
47 | #define SM_OUTOFWAV 0x8 // Jump out of WAV decoding | ||
48 | #define SM_SETTOZERO1 0x10 // set to zero | ||
49 | #define SM_TESTS 0x20 // Allow SDI tests | ||
50 | #define SM_STREAM 0x40 // Stream mode | ||
51 | #define SM_SETTOZERO2 0x80 // set to zero | ||
52 | |||
53 | #define SM_DACT 0x100 // DCLK active edge | ||
54 | #define SM_SDIORD 0x200 // SDI bit order | ||
55 | #define SM_SDISHARE 0x400 // Share SPI chip select | ||
56 | #define SM_SDINEW 0x800 // VS1002 native SPI modes | ||
57 | #define SM_SETTOZERO3 0x1000 // set to zero | ||
58 | |||
59 | // [VALUES::SCI_CLOCKF] | ||
60 | #define SC_CLK2X 0x8000 // clock doubler | ||
61 | |||
62 | #define audio_vs1011_init_xcs() PORTC &= ~(1<<PC1) // <XCS> | ||
63 | #define audio_vs1011_exit_xcs() PORTC |= (1<<PC1); // </XCS> | ||
64 | |||
65 | #define audio_vs1011_init_xdcs() PORTC &= ~(1<<PC2) // <XCS> | ||
66 | #define audio_vs1011_exit_xdcs() PORTC |= (1<<PC2); // </XCS> | ||
67 | |||
68 | #define wait4dreq() loop_until_bit_is_set(PINC, PC3); // <DREQ></DREQ> | ||
69 | |||
70 | |||
71 | /// void audio_vs1011_cmd(const unsigned char sci_cmd, const unsigned char hdata, | ||
72 | /// const unsigned char ldata); | ||
73 | void audio_vs1011_init(); | ||
74 | void audio_vs1011_cmd(const unsigned char cmd, uint16_t dat); | ||
75 | void audio_vs1011_setVolume(const unsigned char left, const unsigned char right); | ||
76 | |||
77 | //void audio_vs1011_dat(const unsigned char dat[32]); | ||
78 | void audio_vs1011_dat(const unsigned char* dat, const unsigned char size); | ||
79 | /// unsigned char audio_vs1011_stream(unsigned char (*readfn)()); | ||
80 | void audio_vs1011_test_sine(); | ||
81 | void audio_vs1011_test_volume(); | ||
82 | /// void audio_vs1011_test_eeprom(); | ||
83 | /// void audio_vs1011_enable(); | ||
84 | /// void audio_vs1011_disable(); | ||
85 | /// char audio_vs1011_isDREQ(); | ||
86 | |||
87 | |||
88 | /// void audio_vs1011_test_softreset(); | ||
89 | |||
90 | |||
91 | #endif | ||