diff options
Diffstat (limited to 'firmware/test')
-rw-r--r-- | firmware/test/i2c/Makefile | 44 | ||||
-rw-r--r-- | firmware/test/i2c/app.lds | 23 | ||||
-rw-r--r-- | firmware/test/i2c/crt0.S | 49 | ||||
-rw-r--r-- | firmware/test/i2c/main.c | 128 |
4 files changed, 244 insertions, 0 deletions
diff --git a/firmware/test/i2c/Makefile b/firmware/test/i2c/Makefile new file mode 100644 index 0000000000..831299f787 --- /dev/null +++ b/firmware/test/i2c/Makefile | |||
@@ -0,0 +1,44 @@ | |||
1 | CC = sh-elf-gcc | ||
2 | LD = sh-elf-ld | ||
3 | AR = sh-elf-ar | ||
4 | AS = sh-elf-as | ||
5 | OC = sh-elf-objcopy | ||
6 | |||
7 | INCLUDES=-I../../ | ||
8 | |||
9 | CFLAGS = -g -Wall -m1 -nostdlib -Wstrict-prototypes -fomit-frame-pointer -fschedule-insns -fno-builtin $(INCLUDES) | ||
10 | AFLAGS += -small -relax | ||
11 | |||
12 | OBJS= crt0.o main.o ../../lcd.o ../../i2c.o ../../mas.o ../../debug.o | ||
13 | |||
14 | %.o: %.S | ||
15 | $(CC) -o $@ $(CFLAGS) $(INCLUDES) $(DEFS) -c $< | ||
16 | |||
17 | |||
18 | all : archos.mod | ||
19 | |||
20 | main.o: main.c | ||
21 | |||
22 | archos.elf : $(OBJS) app.lds | ||
23 | $(CC) -nostartfiles -o archos.elf $(OBJS) -lgcc -Tapp.lds -Wl,-Map,archos.map | ||
24 | |||
25 | archos.bin : archos.elf | ||
26 | $(OC) -O binary archos.elf archos.bin | ||
27 | |||
28 | archos.asm: archos.bin | ||
29 | sh2d -sh1 archos.bin > archos.asm | ||
30 | |||
31 | archos.mod : archos.bin | ||
32 | scramble archos.bin archos.mod | ||
33 | |||
34 | archos.mod.gz : archos.mod | ||
35 | gzip -f archos.mod | ||
36 | |||
37 | dist: | ||
38 | tar czvf dist.tar.gz Makefile main.c start.s app.lds | ||
39 | |||
40 | clean: | ||
41 | -rm -f *.x *.i *.o *.elf *.bin *.map *.mod *.bak *~ | ||
42 | |||
43 | install: | ||
44 | mount /mnt/archos; cp archos.mod /mnt/archos; umount /mnt/archos | ||
diff --git a/firmware/test/i2c/app.lds b/firmware/test/i2c/app.lds new file mode 100644 index 0000000000..4b7e5f4c6f --- /dev/null +++ b/firmware/test/i2c/app.lds | |||
@@ -0,0 +1,23 @@ | |||
1 | ENTRY(start) | ||
2 | OUTPUT_FORMAT(elf32-sh) | ||
3 | SECTIONS | ||
4 | { | ||
5 | .text 0x09018000 : | ||
6 | { | ||
7 | *(.rodata) | ||
8 | *(.text) | ||
9 | } | ||
10 | |||
11 | .data : | ||
12 | { | ||
13 | *(.data) | ||
14 | } | ||
15 | |||
16 | .bss : | ||
17 | { | ||
18 | *(.bss) | ||
19 | _end = . + 0x8000; | ||
20 | _stack = . + 0x9000; | ||
21 | _edata = .; | ||
22 | } | ||
23 | } | ||
diff --git a/firmware/test/i2c/crt0.S b/firmware/test/i2c/crt0.S new file mode 100644 index 0000000000..5f0ef2d64e --- /dev/null +++ b/firmware/test/i2c/crt0.S | |||
@@ -0,0 +1,49 @@ | |||
1 | .section .text | ||
2 | .global start | ||
3 | start: | ||
4 | mov.l stack_k,r15 | ||
5 | |||
6 | ! zero out bss | ||
7 | mov.l edata_k,r0 | ||
8 | mov.l end_k,r1 | ||
9 | mov #0,r2 | ||
10 | start_l: | ||
11 | mov.l r2,@r0 | ||
12 | add #4,r0 | ||
13 | cmp/ge r0,r1 | ||
14 | bt start_l | ||
15 | nop | ||
16 | |||
17 | #if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY) | ||
18 | mov.l set_fpscr_k, r1 | ||
19 | jsr @r1 | ||
20 | mov #0,r4 | ||
21 | lds r3,fpscr | ||
22 | #endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) */ | ||
23 | |||
24 | ! call the mainline | ||
25 | mov.l main_k,r0 | ||
26 | jsr @r0 | ||
27 | nop | ||
28 | .hoo: | ||
29 | bra .hoo | ||
30 | |||
31 | .align 2 | ||
32 | #if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) | ||
33 | set_fpscr_k: | ||
34 | .long ___set_fpscr | ||
35 | #endif /* defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(SH4_SINGLE_ONLY) */ | ||
36 | stack_k: | ||
37 | .long _stack | ||
38 | edata_k: | ||
39 | .long _edata | ||
40 | end_k: | ||
41 | .long _end | ||
42 | main_k: | ||
43 | .long _main | ||
44 | |||
45 | #ifdef __ELF__ | ||
46 | .section .stack,"aw" | ||
47 | #else | ||
48 | .section .stack | ||
49 | #endif | ||
diff --git a/firmware/test/i2c/main.c b/firmware/test/i2c/main.c new file mode 100644 index 0000000000..588236aff1 --- /dev/null +++ b/firmware/test/i2c/main.c | |||
@@ -0,0 +1,128 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "i2c.h" | ||
20 | #include "mas.h" | ||
21 | #include "sh7034.h" | ||
22 | #include "debug.h" | ||
23 | |||
24 | int strlen(unsigned char* str) | ||
25 | { | ||
26 | int i=0; | ||
27 | while (*str++) | ||
28 | i++; | ||
29 | return i; | ||
30 | } | ||
31 | |||
32 | int main(void) | ||
33 | { | ||
34 | char buf[40]; | ||
35 | char str[32]; | ||
36 | int i=0; | ||
37 | |||
38 | /* Clear it all! */ | ||
39 | SSR1 &= ~(SCI_RDRF | SCI_ORER | SCI_PER | SCI_FER); | ||
40 | |||
41 | /* This enables the serial Rx interrupt, to be able to exit into the | ||
42 | debugger when you hit CTRL-C */ | ||
43 | SCR1 |= 0x40; | ||
44 | SCR1 &= ~0x80; | ||
45 | asm ("ldc\t%0,sr" : : "r"(0<<4)); | ||
46 | |||
47 | debugf("Olle: %d\n", 7); | ||
48 | |||
49 | i2c_init(); | ||
50 | debug("I2C Init done\n"); | ||
51 | i=mas_readmem(MAS_BANK_D1,0xff6,(unsigned long*)buf,2); | ||
52 | if (i) { | ||
53 | debugf("Error - mas_readmem() returned %d\n", i); | ||
54 | while(1); | ||
55 | } | ||
56 | |||
57 | i = buf[0] | buf[1] << 8; | ||
58 | debugf("MAS version: %x\n", i); | ||
59 | i = buf[4] | buf[5] << 8; | ||
60 | debugf("MAS revision: %x\n", i); | ||
61 | |||
62 | i=mas_readmem(MAS_BANK_D1,0xff9,(unsigned long*)buf,7); | ||
63 | if (i) { | ||
64 | debugf("Error - mas_readmem() returned %d\n", i); | ||
65 | while(1); | ||
66 | } | ||
67 | |||
68 | for(i = 0;i < 7;i++) | ||
69 | { | ||
70 | str[i*2+1] = buf[i*4]; | ||
71 | str[i*2] = buf[i*4+1]; | ||
72 | } | ||
73 | str[i*2] = 0; | ||
74 | debugf("Description: %s\n", str); | ||
75 | |||
76 | i=mas_readreg(0xe6); | ||
77 | if (i < 0) { | ||
78 | debugf("Error - mas_readreg() returned %d\n", i); | ||
79 | while(1); | ||
80 | } | ||
81 | |||
82 | debugf("Register 0xe6: %x\n", i); | ||
83 | |||
84 | |||
85 | debugf("Writing register 0xaa\n"); | ||
86 | |||
87 | i=mas_writereg(0xaa, 0x1); | ||
88 | if (i < 0) { | ||
89 | debugf("Error - mas_writereg() returned %d\n", i); | ||
90 | while(1); | ||
91 | } | ||
92 | |||
93 | i=mas_readreg(0xaa); | ||
94 | if (i < 0) { | ||
95 | debugf("Error - mas_readreg() returned %d\n", i); | ||
96 | while(1); | ||
97 | } | ||
98 | |||
99 | debugf("Register 0xaa: %x\n", i); | ||
100 | |||
101 | debugf("Writing register 0xaa again\n"); | ||
102 | |||
103 | i=mas_writereg(0xaa, 0); | ||
104 | if (i < 0) { | ||
105 | debugf("Error - mas_writereg() returned %d\n", i); | ||
106 | while(1); | ||
107 | } | ||
108 | |||
109 | i=mas_readreg(0xaa); | ||
110 | if (i < 0) { | ||
111 | debugf("Error - mas_readreg() returned %d\n", i); | ||
112 | while(1); | ||
113 | } | ||
114 | |||
115 | debugf("Register 0xaa: %x\n", i); | ||
116 | |||
117 | while(1); | ||
118 | } | ||
119 | |||
120 | extern const void stack(void); | ||
121 | |||
122 | const void* vectors[] __attribute__ ((section (".vectors"))) = | ||
123 | { | ||
124 | main, /* Power-on reset */ | ||
125 | stack, /* Power-on reset (stack pointer) */ | ||
126 | main, /* Manual reset */ | ||
127 | stack /* Manual reset (stack pointer) */ | ||
128 | }; | ||