const char d2_txt[]="- alphablend -";
u8 contrast;
t_button button;
+int sample_count;
/*
* functions
}
}
+void __attribute__ ((interrupt("IRQ"))) set_sample(void) {
+
+ uart0_send_byte('S');
+ pwm_update_match(PWM_CHAN2,PWM_SINGLE_EDGE,sinus[sample_count++],0);
+ if(sample_count==0xff)
+ sample_count=0;
+ interrupt_ack();
+ interrupt_tc_ir_set(INTERRUPT_TC0,INTERRUPT_M0);
+}
+
void __attribute__ ((interrupt("IRQ"))) input_event(void) {
u8 noret,tries;
/* variables */
+ /* init */
+ sample_count=0;
+
/* system init */
pll_init();
pin_init();
/* interrupt init */
interrupt_init();
+
+ // ext interrupt
interrupt_ext_ir_config(INTERRUPT_EXT3,INTERRUPT_EXT_NOWAKE,
INTERRUPT_EXT_MODE_EDGE,
INTERRUPT_EXT_POLAR_LOW);
interrupt_ext_ir_set(INTERRUPT_EXT3);
interrupt_enable(INTERRUPT_EINT3,INTERRUPT_MODE_VIRQ,
- 0,(u32)input_event);
+ 0,(u32)&input_event);
+
+ // timer interrupt
+ interrupt_tc_config(INTERRUPT_TC0,INTERRUPT_TC_MODE_T,0,0);
+ interrupt_tc_match_config(INTERRUPT_TC0,INTERRUPT_M0,120,
+ INTERRUPT_TC_MATCH_IR|
+ INTERRUPT_TC_MATCH_RESET);
+ interrupt_tc_ir_set(INTERRUPT_TC0,INTERRUPT_MATCH0);
+ interrupt_enable(INTERRUPT_TIMER0,INTERRUPT_MODE_VIRQ,
+ 1,(u32)&set_sample);
+
+ /* pwm init */
+ pwm_set_rate_and_prescaler(0xff,0);
+ pwm_config(PWM_CHAN2,PWM_SINGLE_EDGE,0,0);
+ pwm_match_ctrl_config(PWM_CHAN2,0);
+ interrupt_pwm_ir_set(PWM_CHAN2);
+ pwm_enable;
+
/*
* start it ...