12 #include "backlight.h"
13 #include "backlight-target.h"
18 // 441 Hz samples table, 44100 Hz and 441 Hz -> 100 samples
19 const int16_t samples
[] = {
20 0, 2057, 4106, 6139, 8148, 10125, 12062, 13951, 15785, 17557,
21 19259, 20886, 22430, 23886, 25247, 26509, 27666, 28713, 29648, 30465,
22 31163, 31737, 32186, 32508, 32702, 32767, 32702, 32508, 32186, 31737,
23 31163, 30465, 29648, 28713, 27666, 26509, 25247, 23886, 22430, 20886,
24 19259, 17557, 15785, 13951, 12062, 10125, 8148, 6139, 4106, 2057,
25 0, -2057, -4106, -6139, -8148, -10125, -12062, -13951, -15785, -17557,
26 -19259, -20886, -22430, -23886, -25247, -26509, -27666, -28713, -29648, -30465,
27 -31163, -31737, -32186, -32508, -32702, -32767, -32702, -32508, -32186, -31737,
28 -31163, -30465, -29648, -28713, -27666, -26509, -25247, -23886, -22430, -20886,
29 -19259, -17557, -15785, -13951, -12062, -10125, -8148, -6139, -4106, -2057 };
31 extern void show_logo( void );
37 // printf("hdma int: %d", i++);
39 HDMA_ISRC0
= (uint32_t)&samples
;
40 HDMA_IDST0
= (uint32_t)&I2S_TXR
;
41 HDMA_ICNT0
= (sizeof(samples
)/4) - 1;
42 HDMA_CON0
= (1<<22)| // slice mode
43 (1<<21)| // channel enable
44 (1<<18)| // interrupt mode
45 (5<<13)| // transfer mode inc8
46 (6<<9) | // hdreq from i2s tx
47 (0<<7) | // source address increment
48 (1<<5) | // destination address fixed
49 (2<<3) | // data size word
50 (1<<0); // enable hardware triggered dma
52 HDMA_ISR
= (1<<13) | // mask ch1 page overflow
53 (1<<11) | // mask ch1 page count down
54 (1<<9); // mask ch1 interrupts
59 static int codec_write(uint8_t reg
, uint8_t data
)
62 return i2c_write(0x27<<1, reg
<<1, 1, &tmp
);
78 lcd_setfont(FONT_SYSFIXED
);
83 printf("show logo passed");
85 SCU_CLKCFG
&= ~((1<<17) | (1<<16)); // enable i2s, i2c pclk
86 //SCU_CLKCFG |= ((1<<17) | (1<<16));
87 I2S_OPR
= (1<<17) | // reset Tx
89 (1<<6) | // disable HDMA Req1
90 (1<<5); // disable HDMA Req2
92 I2S_TXCTL
= (1<<16) | // LRCK/SCLK = 64
93 (4<<8) | // MCLK/SCK = 4
94 (1<<4) | // 16bit samples
95 (0<<3) | // stereo mode
98 I2S_RXCTL
= (1<<16) | // LRCK/SCLK = 64
99 (4<<8) | // MCLK/SCK = 4
100 (1<<4) | // 16bit samples
101 (0<<3) | // stereo mode
104 I2S_FIFOSTS
= (1<<18) | // Tx int trigger half full
105 (1<<16); // Rx int trigger half full
108 I2S_OPR
= (1<<17) | (1<<16);
111 I2S_OPR
= (0<<6) | // req channel 1 enable
112 (1<<5) | // req channel 2 disable
113 (0<<4) | // HDMA req channel 1 Tx
114 (0<<2) | // normal I2S operation (no loopback)
117 printf("I2S config passed");
119 HDMA_ISRC0
= (uint32_t)&samples
;
120 HDMA_IDST0
= (uint32_t)&I2S_TXR
;
121 HDMA_ICNT0
= (sizeof(samples
)/4) - 1;
124 HDMA_CON0
= (1<<22)| // slice mode
125 (1<<21)| // channel enable
126 (1<<18)| // interrupt mode
127 (5<<13)| // transfer mode inc8
128 (6<<9) | // hdreq from i2s tx
129 (0<<7) | // source address increment
130 (1<<5) | // destination address fixed
131 (2<<3) | // data size word
132 (1<<0); // enable hardware triggered dma
134 HDMA_ISR
= (1<<13) | // mask ch1 page overflow
135 (1<<11) | // mask ch1 page count down
136 (1<<9); // mask ch1 interrupts
139 INTC_IECR
|= (1<<12);
141 printf("HDMA config passed");
145 printf("I2C config passed");
148 codec_write(0x00, (1<<3)|(1<<2)|(1<<1)|(1<<0)); // AICR
149 codec_write(0x01, (1<<7)|(1<<5)|(1<<3)); // CR1
150 codec_write(0x02, (1<<2)); // CR2
151 codec_write(0x03, 0); // CCR1
152 codec_write(0x04, (2<<4)|(2<<0)); // CCR2
153 codec_write(0x07, (3<<5)|(3<<0)); // CCR
156 codec_write(0x0f, 0x1f|(2<<6)); // CGR6
157 codec_write(0x14, (1<<1)); // TR1
158 codec_write(0x05, (1<<6)|(1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|(1<<0)); // PMR1
161 codec_write(0x06, (1<<3)|(1<<2)|(1<<0)); // PMR2
164 codec_write(0x05, (1<<6)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|(1<<0)); // PMR1
165 codec_write(0x05, (1<<4)|(1<<3)|(1<<2)|(1<<1)|(1<<0)); // PMR1
169 codec_write(0x01, (1<<7)|(1<<3)|(1<<5)|(1<<4)); // CR1
170 codec_write(0x05, (1<<4)|(1<<3)|(1<<2)|(1<<1)|(1<<0)); //PMR1
171 // codec_write(0x06, (1<<3)|(1<<2)); // PMR2
173 printf("codec init passed");
175 codec_write(0x01, (1<<7)|(1<<3)); // CR1
177 codec_write(0x0a, 0); // 0dB digital gain
178 codec_write(0x11, 15|(2<<6)); //
182 printf("HDMA_CCNT0: 0x%0x FIFOSTS: 0x%0x", HDMA_CCNT0
, I2S_FIFOSTS
);