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 audio_mute_toggle(void) {
49 #define AUDIO_TONE_C (7500000/(262*256))
50 #define AUDIO_TONE_D (7500000/(294*256))
51 #define AUDIO_TONE_E (7500000/(330*256))
52 #define AUDIO_TONE_F (7500000/(349*256))
53 #define AUDIO_TONE_G (7500000/(392*256))
54 //#define AUDIO_TONE_A (7500000/(440*256))
55 #define AUDIO_TONE_A 120
56 #define AUDIO_TONE_H (7500000/(494*256))
58 void __attribute__ ((interrupt("IRQ"))) set_sample(void) {
60 //uart0_send_byte('S');
61 pwm_update_match(PWM_CHAN2,PWM_SINGLE_EDGE,sinus[sample_count++],0);
62 if(sample_count==0xff)
65 interrupt_tc_ir_set(INTERRUPT_TC0,INTERRUPT_MATCH0);
68 void __attribute__ ((interrupt("IRQ"))) input_event(void) {
73 if(button_get_event(&button)) {
74 switch(button.key[0]) {
76 display_logo((u8 *)default_logo);
81 DISPLAY_SET_CONTRAST(contrast);
86 DISPLAY_SET_CONTRAST(contrast);
89 display_fill_screen(DISPLAY_FILL_W);
92 display_fill_screen(DISPLAY_FILL_LG);
95 display_fill_screen(DISPLAY_FILL_DG);
98 display_fill_screen(DISPLAY_FILL_B);
101 display_rectangle_page(4,2,60,5,
102 DISPLAY_FILL_B,0xff);
105 display_rectangle_page(40,5,50,5,
106 DISPLAY_FILL_LG,0x7f);
111 display_font_page(42,18,
112 (u8 *)default_font+(0x34<<3),
116 display_font_page(50,18,
117 (u8 *)default_font+(0x35<<3),
121 display_font_page(58,18,
122 (u8 *)default_font+(0x36<<3),
130 display_string_page(50,13,(u8 *)d1_txt,
134 display_string_page(10,8,(u8 *)d2_txt,
141 display_clear_screen();
146 /* resume the interrupt at button release */
152 noret=IOPIN0&(1<<30)?0:1;
158 interrupt_ext_ir_set(INTERRUPT_EXT3);
177 /* memory mapping - dirty! */
178 if((void *)announce<(void *)FLASH_BANK0)
179 mmap_init(MEMTYPE_RAM);
181 mmap_init(MEMTYPE_EXT);
190 button.mode=BUTTON_INT;
191 button_init(&button);
192 button_set_retries(&button,30);
205 interrupt_ext_ir_config(INTERRUPT_EXT3,INTERRUPT_EXT_NOWAKE,
206 INTERRUPT_EXT_MODE_EDGE,
207 INTERRUPT_EXT_POLAR_LOW);
208 interrupt_ext_ir_set(INTERRUPT_EXT3);
209 interrupt_enable(INTERRUPT_EINT3,INTERRUPT_MODE_VIRQ,
210 0,(u32)&input_event);
213 interrupt_tc_config(INTERRUPT_TC0,INTERRUPT_TC_MODE_T,0,0);
214 interrupt_tc_match_config(INTERRUPT_TC0,INTERRUPT_M0,AUDIO_TONE_A,
215 INTERRUPT_TC_MATCH_IR|
216 INTERRUPT_TC_MATCH_RESET);
217 interrupt_tc_ir_set(INTERRUPT_TC0,INTERRUPT_MATCH0);
218 interrupt_enable(INTERRUPT_TIMER0,INTERRUPT_MODE_VIRQ,
220 interrupt_tc_enable(INTERRUPT_TC0);
224 pwm_set_rate_and_prescaler(0xff,0);
225 pwm_config(PWM_CHAN2,PWM_SINGLE_EDGE,0,0);
226 pwm_match_ctrl_config(PWM_CHAN2,PWM_MATCH_RESET);
234 /* toggle the display back light */
238 uart0_send_string((char *)announce);
243 uart0_send_string((char *)announce);