Daniel Stenberg | 0fc30d1 | 2006-08-01 22:28:14 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
Daniel Stenberg | f2591d3 | 2006-08-03 09:19:32 +0000 | [diff] [blame] | 10 | * Copyright (C) 2006 Daniel Stenberg |
Daniel Stenberg | 0fc30d1 | 2006-08-01 22:28:14 +0000 | [diff] [blame] | 11 | * |
Daniel Stenberg | 0fc30d1 | 2006-08-01 22:28:14 +0000 | [diff] [blame] | 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 "config.h" |
| 20 | |
| 21 | #include <stdlib.h> |
| 22 | #include <stdio.h> |
| 23 | #include <string.h> |
| 24 | #include "cpu.h" |
| 25 | #include "system.h" |
| 26 | #include "lcd.h" |
| 27 | #include "kernel.h" |
| 28 | #include "thread.h" |
| 29 | #include "ata.h" |
| 30 | #include "fat.h" |
| 31 | #include "disk.h" |
| 32 | #include "font.h" |
| 33 | #include "adc.h" |
| 34 | #include "backlight.h" |
| 35 | #include "panic.h" |
| 36 | #include "power.h" |
| 37 | #include "file.h" |
| 38 | |
Daniel Ankers | d8ef7c5 | 2006-10-16 17:21:36 +0000 | [diff] [blame] | 39 | static inline void blink(void) |
Daniel Stenberg | 0fc30d1 | 2006-08-01 22:28:14 +0000 | [diff] [blame] | 40 | { |
Daniel Ankers | 2740914 | 2006-10-10 19:02:49 +0000 | [diff] [blame] | 41 | volatile unsigned int* ptr; |
Daniel Stenberg | 0fc30d1 | 2006-08-01 22:28:14 +0000 | [diff] [blame] | 42 | int i; |
Daniel Ankers | d8ef7c5 | 2006-10-16 17:21:36 +0000 | [diff] [blame] | 43 | ptr = (volatile unsigned int*)0x70000020; |
Daniel Stenberg | f2591d3 | 2006-08-03 09:19:32 +0000 | [diff] [blame] | 44 | |
Daniel Ankers | d8ef7c5 | 2006-10-16 17:21:36 +0000 | [diff] [blame] | 45 | *ptr &= ~(1 << 13); |
| 46 | for(i = 0; i < 0xfffff; i++) |
Daniel Ankers | 2740914 | 2006-10-10 19:02:49 +0000 | [diff] [blame] | 47 | { |
Daniel Ankers | 2740914 | 2006-10-10 19:02:49 +0000 | [diff] [blame] | 48 | } |
Daniel Ankers | d8ef7c5 | 2006-10-16 17:21:36 +0000 | [diff] [blame] | 49 | *ptr |= (1 << 13); |
| 50 | for(i = 0; i < 0xfffff; i++) |
| 51 | { |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | static 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 | { |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | static 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; |
Daniel Stenberg | 0fc30d1 | 2006-08-01 22:28:14 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | /* These functions are present in the firmware library, but we reimplement |
| 95 | them here because the originals do a lot more than we want */ |
| 96 | |
| 97 | void reset_poweroff_timer(void) |
| 98 | { |
| 99 | } |
| 100 | |
| 101 | int dbg_ports(void) |
| 102 | { |
Daniel Ankers | d8ef7c5 | 2006-10-16 17:21:36 +0000 | [diff] [blame] | 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; |
Daniel Stenberg | 0fc30d1 | 2006-08-01 22:28:14 +0000 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | void mpeg_stop(void) |
| 162 | { |
| 163 | } |
| 164 | |
| 165 | void usb_acknowledge(void) |
| 166 | { |
| 167 | } |
| 168 | |
| 169 | void usb_wait_for_disconnect(void) |
| 170 | { |
| 171 | } |
| 172 | |
| 173 | void sys_poweroff(void) |
| 174 | { |
| 175 | } |
| 176 | |
| 177 | void system_reboot(void) |
| 178 | { |
| 179 | |
| 180 | } |
Daniel Ankers | d8ef7c5 | 2006-10-16 17:21:36 +0000 | [diff] [blame] | 181 | |
| 182 | void main(void) |
| 183 | { |
| 184 | kernel_init(); |
| 185 | adc_init(); |
| 186 | lcd_init_device(); |
| 187 | |
| 188 | dbg_ports(); |
| 189 | } |
| 190 | |