added low level flash support
[my-code/arm.git] / betty / betty.c
1 /*
2  * betty.c - alternative firmware for the betty tv ;)
3  *
4  * author: hackbard@hackdaworld.org
5  *
6  */
7
8 /* includes */
9 #include "betty.h"
10
11 /*
12  * functions
13  */
14
15 #define cc1100_init     spi1_init(8,SPI_MASTER,8)
16
17 /*
18  * main function
19  */
20
21 int main() {
22
23         char announce[]="betty - live from flash at 0x80000000! ;)\r\n";
24         t_button button;
25         u32 addr;
26
27         /* system init */
28         pll_init();
29
30         /* uart init */
31         uart0_init();
32
33         /* display init */
34         bl_init();
35
36         /* button init */
37         button_init(&button);
38         button_set_retries(&button,100);
39
40         /* flash init */
41         flash_init();
42
43         /*
44          * start it ...
45          */
46
47         /* pause - seems to not work if running from flash! (?) */
48         pause(0xffffff);
49
50         /* announce */
51         uart0_send_string(announce);
52
53         /* toggle backlight */
54         bl_toggle();
55
56         //addr=0x82000000;
57         flash_sector_erase(BANK2,0);
58         addr=FLASH_BANK2;
59
60         while(1) {
61                 pause(0x0fffff);
62
63                 /* button test! */
64                 if(button_get_event(&button)) {
65                         uart0_send_string(announce);
66                         if(button.key[0]==BUTTON_POWER) {
67                                 bl_toggle();
68                                 flash_write_buf(addr,(u16 *)announce,42);
69                                 addr+=64;
70                         }
71                 }
72         }
73
74         return 0;
75 }
76