summaryrefslogtreecommitdiff
path: root/bootloader
diff options
context:
space:
mode:
Diffstat (limited to 'bootloader')
-rw-r--r--bootloader/e200.c131
1 files changed, 112 insertions, 19 deletions
diff --git a/bootloader/e200.c b/bootloader/e200.c
index 91217f5c70..27b1118a1c 100644
--- a/bootloader/e200.c
+++ b/bootloader/e200.c
@@ -36,33 +36,61 @@
36#include "power.h" 36#include "power.h"
37#include "file.h" 37#include "file.h"
38 38
39void main(void) 39static inline void blink(void)
40{ 40{
41 volatile unsigned int* ptr; 41 volatile unsigned int* ptr;
42 int i; 42 int i;
43 ptr = (volatile unsigned int*)0x70000020;
43 44
44 while(1) 45 *ptr &= ~(1 << 13);
46 for(i = 0; i < 0xfffff; i++)
47 {
48 }
49 *ptr |= (1 << 13);
50 for(i = 0; i < 0xfffff; i++)
45 { 51 {
46 // blink wheel backlight 52 }
47 ptr = (volatile unsigned int*)0x70000020; 53}
48 if((*ptr) & (1 << 13))
49 {
50 *ptr = (*ptr) & ~(1 << 13);
51
52 }
53 else
54 {
55 *ptr = (*ptr) | (1 << 13);
56 }
57
58 // wait a while
59 for(i = 0; i < 0xfffff; i++)
60 {
61 }
62 54
55static inline void slow_blink(void)
56{
57 volatile unsigned int* ptr;
58 int i;
59 ptr = (volatile unsigned int*)0x70000020;
60
61 *ptr &= ~(1 << 13);
62 for(i = 0; i < (0xfffff); i++)
63 {
64 }
65 for(i = 0; i < (0xfffff); i++)
66 {
67 }
68 for(i = 0; i < (0xfffff); i++)
69 {
70 }
71
72 *ptr |= (1 << 13);
73 for(i = 0; i < (0xfffff); i++)
74 {
75 }
76 for(i = 0; i < (0xfffff); i++)
77 {
78 }
79 for(i = 0; i < (0xfffff); i++)
80 {
63 } 81 }
64} 82}
65 83
84static inline unsigned long get_pc(void)
85{
86 unsigned long pc;
87 asm volatile (
88 "mov %0, pc\n"
89 : "=r"(pc)
90 );
91 return pc;
92}
93
66/* These functions are present in the firmware library, but we reimplement 94/* These functions are present in the firmware library, but we reimplement
67 them here because the originals do a lot more than we want */ 95 them here because the originals do a lot more than we want */
68 96
@@ -72,7 +100,62 @@ void reset_poweroff_timer(void)
72 100
73int dbg_ports(void) 101int dbg_ports(void)
74{ 102{
75 return 0; 103 unsigned int gpio_a, gpio_b, gpio_c, gpio_d;
104 unsigned int gpio_e, gpio_f, gpio_g, gpio_h;
105 unsigned int gpio_i, gpio_j, gpio_k, gpio_l;
106
107 char buf[128];
108 int line;
109
110 lcd_setmargins(0, 0);
111 lcd_clear_display();
112 lcd_setfont(FONT_SYSFIXED);
113
114 while(1)
115 {
116 gpio_a = GPIOA_INPUT_VAL;
117 gpio_b = GPIOB_INPUT_VAL;
118 gpio_c = GPIOC_INPUT_VAL;
119
120 gpio_g = GPIOG_INPUT_VAL;
121 gpio_h = GPIOH_INPUT_VAL;
122 gpio_i = GPIOI_INPUT_VAL;
123
124 line = 0;
125 snprintf(buf, sizeof(buf), "GPIO_A: %02x GPIO_G: %02x", gpio_a, gpio_g);
126 lcd_puts(0, line++, buf);
127 snprintf(buf, sizeof(buf), "GPIO_B: %02x GPIO_H: %02x", gpio_b, gpio_h);
128 lcd_puts(0, line++, buf);
129 snprintf(buf, sizeof(buf), "GPIO_C: %02x GPIO_I: %02x", gpio_c, gpio_i);
130 lcd_puts(0, line++, buf);
131 line++;
132
133 gpio_d = GPIOD_INPUT_VAL;
134 gpio_e = GPIOE_INPUT_VAL;
135 gpio_f = GPIOF_INPUT_VAL;
136
137 gpio_j = GPIOJ_INPUT_VAL;
138 gpio_k = GPIOK_INPUT_VAL;
139 gpio_l = GPIOL_INPUT_VAL;
140
141 snprintf(buf, sizeof(buf), "GPIO_D: %02x GPIO_J: %02x", gpio_d, gpio_j);
142 lcd_puts(0, line++, buf);
143 snprintf(buf, sizeof(buf), "GPIO_E: %02x GPIO_K: %02x", gpio_e, gpio_k);
144 lcd_puts(0, line++, buf);
145 snprintf(buf, sizeof(buf), "GPIO_F: %02x GPIO_L: %02x", gpio_f, gpio_l);
146 lcd_puts(0, line++, buf);
147 line++;
148 snprintf(buf, sizeof(buf), "ADC_1: %02x", adc_read(ADC_0));
149 lcd_puts(0, line++, buf);
150 snprintf(buf, sizeof(buf), "ADC_2: %02x", adc_read(ADC_1));
151 lcd_puts(0, line++, buf);
152 snprintf(buf, sizeof(buf), "ADC_3: %02x", adc_read(ADC_2));
153 lcd_puts(0, line++, buf);
154 snprintf(buf, sizeof(buf), "ADC_4: %02x", adc_read(ADC_3));
155 lcd_puts(0, line++, buf);
156 lcd_update();
157 }
158 return 0;
76} 159}
77 160
78void mpeg_stop(void) 161void mpeg_stop(void)
@@ -95,3 +178,13 @@ void system_reboot(void)
95{ 178{
96 179
97} 180}
181
182void main(void)
183{
184 kernel_init();
185 adc_init();
186 lcd_init_device();
187
188 dbg_ports();
189}
190