2 * betty.c - alternative firmware for the betty tv ;)
4 * author: hackbard@hackdaworld.org
18 /* bank 0/2 and boootloader addr/size */
19 #define BANK0 0x80000000
20 #define BANK2 0x82000000
21 #define BANK_SIZE 0x00100000
22 #define BOOTLOADER 0x7fffe000
23 #define BL_SIZE 0x00002000
25 /* flash cmd addresses - flash[0-18] <--> arm[1-19]*/
26 #define B0F555 (*((volatile unsigned short *)(BANK0|0xaaa))) // 0x555
27 #define B0F2AA (*((volatile unsigned short *)(BANK0|0x554))) // 0x2aa
28 #define B0F (*((volatile unsigned short *)(BANK0)))
29 #define B2F555 (*((volatile unsigned short *)(BANK2|0xaaa))) // 0x555
30 #define B2F2AA (*((volatile unsigned short *)(BANK2|0x554))) // 0x2aa
31 #define B2F (*((volatile unsigned short *)(BANK2)))
37 typedef unsigned char u8;
38 typedef unsigned short u16;
39 typedef unsigned int u32;
45 void mmap_init(u8 memtype) {
53 PLLCFG=0x42; // multiplier = 3 (for cclk), dividor = 4 (for f_cco)
54 PLLCON=0x03; // enable and set as clk source for the lpc
59 while(!(PLLSTAT&(1<<10)))
63 void ext_mem_bank_init(void) {
65 BCFG0=0x10000420; // flash 1
66 BCFG1=0x00000c42; // lcd
67 BCFG2=0x10000420; // flash 2
71 void pin_select_init() {
74 * a[19:2] -> address lines
80 void uart0_init(void) {
82 PINSEL0=0x05; // pin select -> tx, rx
83 UART0_FCR=0x07; // enable fifo
84 UART0_LCR=0x83; // set dlab + word length
85 UART0_DLL=0x04; // br: 38400 @ 10/4 mhz
87 UART0_LCR=0x03; // unset dlab
90 void uart0_send_string(char *txbuf) {
98 /* flush if tx buffer maximum reached */
100 while(!(UART0_LSR&(1<<6)))
104 /* flush if \n and \r do not fit in the tx buffer */
106 while(!(UART0_LSR&(1<<6)))
112 /* flush uart0 anyways */
113 while(!(UART0_LSR&(1<<6)))
117 void uart0_send_buf16(u16 *buf,int len) {
123 for(i=0;i<len/2;i++) {
125 while(!(UART0_LSR&(1<<6)))
127 UART0_THR=buf[i]&0xff;
128 UART0_THR=(buf[i]>>8)&0xff;
132 void uart0_send_buf32(u32 *buf,int len) {
138 for(i=0;i<len/4;i++) {
140 while(!(UART0_LSR&(1<<6)))
142 UART0_THR=buf[i]&0xff;
143 UART0_THR=(buf[i]>>8)&0xff;
144 UART0_THR=(buf[i]>>16)&0xff;
145 UART0_THR=(buf[i]>>24)&0xff;
149 void uart0_send_byte(u8 send) {
151 while(!(UART0_LSR&(1<<5)))
157 u8 uart0_get_byte(void) {
161 while(!(UART0_LSR&(1<<0)))
175 char buf="betty - live from the flash at 0x80000000! ;)\r\n";
183 uart0_send_string(buf);