2 * betty.c - alternative firmware for the betty tv ;)
4 * author: hackbard@hackdaworld.org
15 const char announce[]="betty - live from flash at 0x80000000! ;)\r\n";
16 const char d1_txt[]="betty";
17 const char d2_txt[]="- alphablend -";
26 #define cc1100_init spi1_init(8,SPI_MASTER,8)
28 void display_string_page(u8 x,u8 p,u8 *s,u8 f,u8 o,u8 sp) {
35 display_font_page(x,p,(u8 *)default_font+(*(s)<<3),f);
41 void __attribute__ ((interrupt("IRQ"))) set_sample(void) {
44 pwm_update_match(PWM_CHAN2,PWM_SINGLE_EDGE,sinus[sample_count++],0);
45 if(sample_count==0xff)
48 interrupt_tc_ir_set(INTERRUPT_TC0,INTERRUPT_M0);
51 void __attribute__ ((interrupt("IRQ"))) input_event(void) {
56 if(button_get_event(&button)) {
57 switch(button.key[0]) {
59 display_logo((u8 *)default_logo);
64 DISPLAY_SET_CONTRAST(contrast);
69 DISPLAY_SET_CONTRAST(contrast);
72 display_fill_screen(DISPLAY_FILL_W);
75 display_fill_screen(DISPLAY_FILL_LG);
78 display_fill_screen(DISPLAY_FILL_DG);
81 display_fill_screen(DISPLAY_FILL_B);
84 display_rectangle_page(4,2,60,5,
88 display_rectangle_page(40,5,50,5,
89 DISPLAY_FILL_LG,0x7f);
94 display_font_page(42,18,
95 (u8 *)default_font+(0x34<<3),
99 display_font_page(50,18,
100 (u8 *)default_font+(0x35<<3),
104 display_font_page(58,18,
105 (u8 *)default_font+(0x36<<3),
113 display_string_page(50,13,(u8 *)d1_txt,
117 display_string_page(10,8,(u8 *)d2_txt,
121 display_clear_screen();
126 /* resume the interrupt at button release */
132 noret=IOPIN0&(1<<30)?0:1;
138 interrupt_ext_ir_set(INTERRUPT_EXT3);
157 /* memory mapping - dirty! */
158 if((void *)announce<(void *)FLASH_BANK0)
159 mmap_init(MEMTYPE_RAM);
161 mmap_init(MEMTYPE_EXT);
170 button.mode=BUTTON_INT;
171 button_init(&button);
172 button_set_retries(&button,30);
185 interrupt_ext_ir_config(INTERRUPT_EXT3,INTERRUPT_EXT_NOWAKE,
186 INTERRUPT_EXT_MODE_EDGE,
187 INTERRUPT_EXT_POLAR_LOW);
188 interrupt_ext_ir_set(INTERRUPT_EXT3);
189 interrupt_enable(INTERRUPT_EINT3,INTERRUPT_MODE_VIRQ,
190 0,(u32)&input_event);
193 interrupt_tc_config(INTERRUPT_TC0,INTERRUPT_TC_MODE_T,0,0);
194 interrupt_tc_match_config(INTERRUPT_TC0,INTERRUPT_M0,120,
195 INTERRUPT_TC_MATCH_IR|INTERRUPT_TC_MATCH_RESET);
196 interrupt_tc_ir_set(INTERRUPT_TC0,INTERRUPT_M0);
197 interrupt_enable(INTERRUPT_PWM,INTERRUPT_MODE_VIRQ,1,(u32)&set_sample);
200 pwm_set_rate_and_prescaler(0xff,0);
201 pwm_config(PWM_CHAN2,PWM_SINGLE_EDGE,0,0);
202 pwm_match_ctrl_config(PWM_CHAN2,0);
203 interrupt_pwm_ir_set(PWM_CHAN2);
211 /* toggle the display back light */
215 uart0_send_string((char *)announce);
220 uart0_send_string((char *)announce);