summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/test/i2c/main.c59
1 files changed, 51 insertions, 8 deletions
diff --git a/firmware/test/i2c/main.c b/firmware/test/i2c/main.c
index 7df80d5ecd..bf4786d989 100644
--- a/firmware/test/i2c/main.c
+++ b/firmware/test/i2c/main.c
@@ -22,6 +22,11 @@
22#include "sh7034.h" 22#include "sh7034.h"
23#include "debug.h" 23#include "debug.h"
24#include "kernel.h" 24#include "kernel.h"
25#include "ata.h"
26#include "disk.h"
27#include "fat.h"
28#include "file.h"
29#include "dir.h"
25 30
26unsigned char fliptable[] = 31unsigned char fliptable[] =
27{ 32{
@@ -59,8 +64,11 @@ unsigned char fliptable[] =
59 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff 64 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
60}; 65};
61 66
62extern unsigned char mp3data[]; 67extern unsigned int stack[];
63extern int mp3datalen; 68/* Place the MP3 data right after the stack */
69unsigned char *mp3buf = (unsigned char *)stack;
70int mp3datalen;
71
64unsigned char *mp3dataptr; 72unsigned char *mp3dataptr;
65int mp3_transmitted; 73int mp3_transmitted;
66 74
@@ -116,7 +124,7 @@ int mas_tx_ready(void)
116 124
117void init_dma(void) 125void init_dma(void)
118{ 126{
119 SAR3 = (unsigned int) mp3data; 127 SAR3 = (unsigned int) mp3buf;
120 DAR3 = 0x5FFFEC3; 128 DAR3 = 0x5FFFEC3;
121 CHCR3 &= ~0x0002; /* Clear interrupt */ 129 CHCR3 &= ~0x0002; /* Clear interrupt */
122 CHCR3 = 0x1504; /* Single address destination, TXI0, IE=1 */ 130 CHCR3 = 0x1504; /* Single address destination, TXI0, IE=1 */
@@ -153,7 +161,10 @@ int main(void)
153 char buf[40]; 161 char buf[40];
154 char str[32]; 162 char str[32];
155 int i=0; 163 int i=0;
156 164 DIR *d;
165 struct dirent *dent;
166 int f;
167
157 /* Clear it all! */ 168 /* Clear it all! */
158 SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER); 169 SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER);
159 170
@@ -210,10 +221,42 @@ int main(void)
210 while(1); 221 while(1);
211 } 222 }
212 223
213 224 i = ata_init();
225 debugf("ata_init() returned %d\n", i);
226
227 i = disk_init();
228 debugf("disk_init() returned %d\n", i);
229
230 debugf("part[0] starts at sector %d\n", part[0].start);
231
232 i = fat_mount(part[0].start);
233 debugf("fat_mount() returned %d\n", i);
234
235 if((d = opendir("/")))
236 {
237 while((dent = readdir(d)))
238 {
239 debugf("%s\n", dent->d_name);
240 }
241 closedir(d);
242 }
243
244 f = open("/machinae_supremacy_-_arcade.mp3", O_RDONLY);
245 if(f < 0)
246 {
247 debugf("Couldn't open file\n");
248 }
249
250 i = read(f, mp3buf, 200000);
251 debugf("Read %d bytes\n", i);
252
253 mp3datalen = i;
254
255 ata_spindown(-1);
256
214 for(i = 0;i < mp3datalen;i++) 257 for(i = 0;i < mp3datalen;i++)
215 { 258 {
216 mp3data[i] = fliptable[mp3data[i]]; 259 mp3buf[i] = fliptable[mp3buf[i]];
217 } 260 }
218 261
219 while(1) 262 while(1)
@@ -221,7 +264,7 @@ int main(void)
221 debugf("let's play...\n"); 264 debugf("let's play...\n");
222 init_dma(); 265 init_dma();
223 266
224 mp3dataptr = mp3data; 267 mp3dataptr = mp3buf;
225 mp3_transmitted = 0; 268 mp3_transmitted = 0;
226 269
227 dma_on = TRUE; 270 dma_on = TRUE;
@@ -232,7 +275,7 @@ int main(void)
232 CHCR3 |= 1; 275 CHCR3 |= 1;
233 276
234 debugf("sleeping...\n"); 277 debugf("sleeping...\n");
235 sleep(10000); 278 sleep(1000000);
236 } 279 }
237} 280}
238 281