summaryrefslogtreecommitdiff
path: root/firmware/test/i2c/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/test/i2c/main.c')
-rw-r--r--firmware/test/i2c/main.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/firmware/test/i2c/main.c b/firmware/test/i2c/main.c
index 13eaacef7a..825de73788 100644
--- a/firmware/test/i2c/main.c
+++ b/firmware/test/i2c/main.c
@@ -21,6 +21,56 @@
21#include "sh7034.h" 21#include "sh7034.h"
22#include "debug.h" 22#include "debug.h"
23 23
24extern char mp3data[];
25extern int mp3datalen;
26
27unsigned char *mp3dataptr;
28
29void setup_sci0(void)
30{
31 /* set PB12 to output */
32 PBIOR |= 0x1000;
33
34 /* Disable serial port */
35 SCR0 = 0x00;
36
37 /* Syncronous, 8N1, no prescale */
38 SMR0 = 0x80;
39
40 /* Set baudrate 1Mbit/s */
41 BRR0 = 0x03;
42
43 /* use SCK as serial clock output */
44 SCR0 = 0x01;
45
46 /* Clear FER and PER */
47 SSR0 &= 0xe7;
48
49 /* Set interrupt D priority to 0 */
50// IPRD &= 0x0ff0;
51
52 /* set IRQ6 and IRQ7 to edge detect */
53// ICR |= 0x03;
54
55 /* set PB15 and PB14 to inputs */
56 PBIOR &= 0x7fff;
57 PBIOR &= 0xbfff;
58
59 /* set IRQ6 prio 8 and IRQ7 prio 0 */
60// IPRB = ( IPRB & 0xff00 ) | 0x80;
61
62 IPRB = 0;
63
64 /* Enable Tx (only!) */
65 SCR0 = 0x20;
66}
67
68int mas_tx_ready(void)
69{
70 return (SSR0 & SCI_TDRE);
71}
72
73
24int main(void) 74int main(void)
25{ 75{
26 char buf[40]; 76 char buf[40];
@@ -105,6 +155,44 @@ int main(void)
105 } 155 }
106 156
107 debugf("Register 0xaa: %x\n", i); 157 debugf("Register 0xaa: %x\n", i);
158
159 i=mas_writereg(0x3b, 0x20);
160 if (i < 0) {
161 debugf("Error - mas_writereg() returned %d\n", i);
162 while(1);
163 }
164
165 i = mas_run(1);
166 if (i < 0) {
167 debugf("Error - mas_run() returned %d\n", i);
168 while(1);
169 }
170
171
172 setup_sci0();
173
174 mp3dataptr = mp3data;
175 i = 0;
176
177 while(1)
178 {
179 if(PBDR & 0x4000)
180 {
181 if(i < mp3datalen)
182 {
183 while(!mas_tx_ready()){};
184 /*
185 * Write data into TDR and clear TDRE
186 */
187 TDR0 = mp3dataptr[i++];
188 SSR0 &= ~SCI_TDRE;
189 }
190 }
191 else
192 {
193 debugf("MAS not ready\n");
194 }
195 }
108 196
109 while(1); 197 while(1);
110} 198}