# betty deps
BETTY_DEPS = system.o uart.o buttons.o spi.o display.o flash.o functions.o
-BETTY_DEPS += interrupts.o #pffs.o
+BETTY_DEPS += interrupts.o pwm.o #pffs.o
# all projects
all: $(HOST_TARGET) $(CROSS_TARGET)
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_M0);
+ interrupt_enable(INTERRUPT_PWM,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 ...
#include "flash.h"
#include "pffs.h"
#include "interrupts.h"
+#include "pwm.h"
// font/logo
#include "default_font.h"
#include "default_logo.h"
+// sinus
+#include "sinus.h"
+
/*
* defines
*/
if(tcnum==0) {
T0MCR=(T0MCR&0x0fff)|(mode<<(3*mnum));
- mrddr=&T0MR0
+ mraddr=(u32 *)&T0MR0;
}
else {
T1MCR=(T1MCR&0x0fff)|(mode<<(3*mnum));
- mrddr=&T1MR0
+ mraddr=(u32 *)&T1MR0;
}
- mraddr[mnum]=val;
+ *((volatile u32 *)(mraddr+mnum))=val;
}
void interrupt_tc_capt_config(u8 tcnum,u8 cnum,u8 mode) {
}
// pwm interrupts
-void interrupt_pwm_set_rate(u32 rate) {
-
- PWMMR0=rate;
-}
-
-void interrupt_pwm_match_config(u8 mnum,u8 op,u8 mode,u32 val1,u32 val2) {
-
- u32 *addr=&PWMR0;
-
- *((volatile u32 *)(addr+mnum))=mval;
- PWMMCR=(PWMMCR&0x1fffff)|(mode<<(op*3));
-}
-
-void interrupt_pwm_enable(u8 mode,u32 ps_val) {
-
- PWMPR=ps_val;
- PWMTCR=0x0b;
-}
-
void interrupt_pwm_ir_set(u8 pwm_channel) {
PWMIR=(pwm_channel&0x0f)|((pwm_channel&0x70)<<4);
- PWMTCR=0x09;
}
/*
#define INTERRUPT_C2 0x40
#define INTERRUPT_C3 0x80
+#define INTERRUPT_TC0 0
+#define INTERRUPT_TC1 1
+
#define INTERRUPT_SET 0x00
#define INTERRUPT_USED 0x01
#define INTERRUPT_PRIORITY_USED 0x02
void interrupt_tc_capt_config(u8 tcnum,u8 cnum,u8 mode);
void interrupt_tc_ir_set(u8 tcnum,u8 tcmc);
+void interrupt_pwm_ir_set(u8 pwm_channel);
+
void interrupt_handler_reset(void);
void interrupt_handler_undef_instruction(void);
void interrupt_handler_soft_ir(void);
* pinsel 0
*
* uart0: tx, rx
+ * p0.7: pwm2
*
*/
- PINSEL0=0x00000005;
+ PINSEL0=0x00008005;
/*
* pinsel 1