moved pin/bank configuration to global init routines to system.c + added
[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         u8 contrast;
26         int cnt;
27
28         /* system init */
29         pll_init();
30         pin_init();
31         ext_mem_init();
32         
33         /* uart init */
34         uart0_init();
35
36         /* display init */
37         display_bl_init();
38
39         /* button init */
40         button_init(&button);
41         button_set_retries(&button,100);
42
43         /* flash init */
44         flash_init();
45
46         /*
47          * start it ...
48          */
49
50         /* pause - seems to not work if running from flash! (?) */
51         pause(0xffffff);
52
53         /* display init */
54         display_init();
55         contrast=0x38;
56
57         /* pasue again */
58
59         /* announce */
60         uart0_send_string(announce);
61
62         
63         while(1) {
64                 pause(0x0fffff);
65
66                 /* button test! */
67                 if(button_get_event(&button)) {
68                         uart0_send_string(announce);
69                         switch(button.key[0]) {
70                                 case BUTTON_POWER:
71                                         display_load_logo(0);
72                                         break;
73                                 case BUTTON_DOWN:
74                                         if(contrast>0x00)
75                                                 contrast-=1;
76                                         DISPLAY_SET_CONTRAST(contrast);
77                                         break;
78                                 case BUTTON_UP:
79                                         if(contrast<0x3f)
80                                                 contrast+=1;
81                                         DISPLAY_SET_CONTRAST(contrast);
82                                         break;
83                                 default:
84                                         DISPLAY_SET_C_ADDR(0);
85                                         DISPLAY_SET_PAGE_ADDR(0);
86                                         for(cnt=0;cnt<DISPLAY_RAM_CONTENT;cnt++)
87                                                 DISPLAY_DATA=button.key[0];
88                                         break;
89                         }
90                 }
91         }
92
93         return 0;
94 }
95