]> hackdaworld.org Git - my-code/arm.git/commitdiff
bullshit commit, sync for travel (to zn00H!) :) master
authorhackbard <hackbard@staubsauger.localdomain>
Fri, 12 Oct 2007 12:52:32 +0000 (14:52 +0200)
committerhackbard <hackbard@staubsauger.localdomain>
Fri, 12 Oct 2007 12:52:32 +0000 (14:52 +0200)
betty/betty.c
betty/interrupts.c
betty/interrupts.h
betty/pffs.c
betty/pffs.h
betty/pwm.h
betty/system.c

index 24ea2eb7ce415f0268b5d5da2ee8ab842db7802f..3a3e7a51313d9f398055ad43ce54508b5abffd0a 100644 (file)
@@ -38,14 +38,31 @@ void display_string_page(u8 x,u8 p,u8 *s,u8 f,u8 o,u8 sp) {
        }
 }
 
        }
 }
 
+void audio_mute_toggle(void) {
+
+       if(IOPIN0&(1<<11))
+               IOCLR0=(1<<11);
+       else
+               IOSET0=(1<<11);
+}
+
+#define AUDIO_TONE_C   (7500000/(262*256))
+#define AUDIO_TONE_D   (7500000/(294*256))
+#define AUDIO_TONE_E   (7500000/(330*256))
+#define AUDIO_TONE_F   (7500000/(349*256))
+#define AUDIO_TONE_G   (7500000/(392*256))
+//#define AUDIO_TONE_A (7500000/(440*256))
+#define AUDIO_TONE_A   120
+#define AUDIO_TONE_H   (7500000/(494*256))
+
 void __attribute__ ((interrupt("IRQ"))) set_sample(void) {
 
 void __attribute__ ((interrupt("IRQ"))) set_sample(void) {
 
-       uart0_send_byte('S');
+       //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();
        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);
+       interrupt_tc_ir_set(INTERRUPT_TC0,INTERRUPT_MATCH0);
 }
 
 void __attribute__ ((interrupt("IRQ"))) input_event(void) {
 }
 
 void __attribute__ ((interrupt("IRQ"))) input_event(void) {
@@ -117,6 +134,9 @@ void __attribute__ ((interrupt("IRQ"))) input_event(void) {
                                display_string_page(10,8,(u8 *)d2_txt,
                                                    DISPLAY_FILL_B,0,8);
                                break;
                                display_string_page(10,8,(u8 *)d2_txt,
                                                    DISPLAY_FILL_B,0,8);
                                break;
+                       case BUTTON_MUTE:
+                               audio_mute_toggle();
+                               break;
                        default:
                                display_clear_screen();
                                break;
                        default:
                                display_clear_screen();
                                break;
@@ -191,18 +211,19 @@ int main() {
 
        // timer interrupt
        interrupt_tc_config(INTERRUPT_TC0,INTERRUPT_TC_MODE_T,0,0);
 
        // 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_config(INTERRUPT_TC0,INTERRUPT_M0,AUDIO_TONE_A,
                                  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);
                                  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);
+       interrupt_tc_enable(INTERRUPT_TC0);
 
        /* pwm init */
 
        /* pwm init */
+       pwm_reset;
        pwm_set_rate_and_prescaler(0xff,0);
        pwm_config(PWM_CHAN2,PWM_SINGLE_EDGE,0,0);
        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_match_ctrl_config(PWM_CHAN2,PWM_MATCH_RESET);
        pwm_enable;
        
 
        pwm_enable;
        
 
index 24159c005515be363d4dd0f7ab700ac032ecfab8..7d319dbaadb7bf665e3ce3db91c8a5ef78107cff 100644 (file)
@@ -211,14 +211,21 @@ void interrupt_tc_ir_set(u8 tcnum,u8 tcmc) {
        if(tcnum>1)
                return;
 
        if(tcnum>1)
                return;
 
-       if(tcnum==0) {
+       if(tcnum==0)
                T0IR=tcmc;
                T0IR=tcmc;
-               T0TCR=0x01;
-       }
-       else {
+       else
                T1IR=tcmc;
                T1IR=tcmc;
+}
+
+void interrupt_tc_enable(u8 tcnum) {
+
+       if(tcnum>1)
+               return;
+
+       if(tcnum==0)
+               T0TCR=0x01;
+       else
                T1TCR=0x01;
                T1TCR=0x01;
-       }
 }
 
 // pwm interrupts
 }
 
 // pwm interrupts
index 0ce073bb71f4fa8ec8b7ab0e3cc23ce5f9a27c13..9da41e0068c428e44281868ceaafecf145319dd4 100644 (file)
 #define INTERRUPT_CAP2                 0x40
 #define INTERRUPT_CAP3                 0x80
 
 #define INTERRUPT_CAP2                 0x40
 #define INTERRUPT_CAP3                 0x80
 
+#define INTERRUPT_PWM0                 0x01
+#define INTERRUPT_PWM1                 0x02
+#define INTERRUPT_PWM2                 0x04
+#define INTERRUPT_PWM3                 0x08
+#define INTERRUPT_PWM4                 0x10
+#define INTERRUPT_PWM5                 0x20
+#define INTERRUPT_PWM6                 0x40
+
 #define INTERRUPT_SET                  0x00
 #define INTERRUPT_USED                 0x01
 #define INTERRUPT_PRIORITY_USED                0x02
 #define INTERRUPT_SET                  0x00
 #define INTERRUPT_USED                 0x01
 #define INTERRUPT_PRIORITY_USED                0x02
@@ -118,6 +126,7 @@ void interrupt_tc_config(u8 tcnum,u8 mode,u8 cap,u32 psc);
 void interrupt_tc_match_config(u8 tcnum,u8 mnum,u32 val,u8 mode);
 void interrupt_tc_capt_config(u8 tcnum,u8 cnum,u8 mode);
 void interrupt_tc_ir_set(u8 tcnum,u8 tcmc);
 void interrupt_tc_match_config(u8 tcnum,u8 mnum,u32 val,u8 mode);
 void interrupt_tc_capt_config(u8 tcnum,u8 cnum,u8 mode);
 void interrupt_tc_ir_set(u8 tcnum,u8 tcmc);
+void interrupt_tc_enable(u8 tcnum);
 
 void interrupt_pwm_ir_set(u8 pwm_channel);
 
 
 void interrupt_pwm_ir_set(u8 pwm_channel);
 
index 7ba223245ace7581662cfaba64600ba9f2692acb..93351bd7cbaf921711149ae185374a36e94d0c7a 100644 (file)
@@ -148,9 +148,7 @@ int pffs_rearrange(t_pffs *pffs) {
        return 0;
 }
 
        return 0;
 }
 
-int pffs_flash_register(t_pffs *pffs,u32 base_addr,u32 *sec_addr,
-                        u8 sec_num_data_min,u8 sec_num_data_max,
-                       u8 sec_num_index0,u8 sec_num_index1,
+int pffs_flash_register(t_pffs *pffs,u32 base_addr,u32 *sec_addr,u8 sec_num,
                         int (*fw)(u32 addr,u16 *buf,int len),
                        int (*fr)(u32 addr,u16 *buf,int len),
                        int (*fe)(u32 addr)) {
                         int (*fw)(u32 addr,u16 *buf,int len),
                        int (*fr)(u32 addr,u16 *buf,int len),
                        int (*fe)(u32 addr)) {
@@ -158,12 +156,7 @@ int pffs_flash_register(t_pffs *pffs,u32 base_addr,u32 *sec_addr,
        /* assign physical flash specs */
        pffs->base_addr=base_addr;
        pffs->sec_addr=sec_addr;
        /* assign physical flash specs */
        pffs->base_addr=base_addr;
        pffs->sec_addr=sec_addr;
-
-       /* specified index and data sectors */
-       pffs->sec_num_data[0]=sec_num_data_min;
-       pffs->sec_num_data[1]=sec_num_data_max;
-       pffs->sec_num_index[0]=sec_num_index0;
-       pffs->sec_num_index[1]=sec_num_index1;
+       pffs->sec_num=sec_num;
 
        /* flash acccess function pointers */
        pffs->fw=fw;
 
        /* flash acccess function pointers */
        pffs->fw=fw;
index 98ddd50d93346b53cdd4c368a433469ab1d5804b..5849fa7576b8de07c972c50ee96ac95fcfede1af 100644 (file)
 
 typedef struct s_pffs {
        /* flash specs */
 
 typedef struct s_pffs {
        /* flash specs */
-       u32 base_addr;
-       u32 *sec_addr;
-       u8 sec_num_data[2];             // first/last sector used for data
-       u8 sec_num_index[2];            // 2 sectors used as an index
+       u32 base_addr;                  // base flash access address
+       u32 *sec_addr;                  // pointer to sector addresses
+       u8 sec_num;                     // number of sectors
 
        /* flash write, read and sector erase function pointers */
        int (*fw)(u32 addr,u16 *buf,int len);
 
        /* flash write, read and sector erase function pointers */
        int (*fw)(u32 addr,u16 *buf,int len);
@@ -78,7 +77,6 @@ typedef struct s_pffs {
 
        /* pffs internal variables */
        u8 state;
 
        /* pffs internal variables */
        u8 state;
-       u8 index_sec;                   // current index sector
        u8 data_tmp_sec;                // current temp data sector
 } t_pffs;
 
        u8 data_tmp_sec;                // current temp data sector
 } t_pffs;
 
@@ -105,9 +103,7 @@ typedef struct s_pffs_file_header {
 }
 
 /* function prototypes (only the ones applications should use!) */
 }
 
 /* function prototypes (only the ones applications should use!) */
-int pffs_flash_register(t_pffs *pffs,u32 base_addr,u32 *sec_addr,
-                        u8 sec_num_data_min,u8 sec_num_data_max,
-                        u8 sec_num_index0,u8 sec_num_index1,
+int pffs_flash_register(t_pffs *pffs,u32 base_addr,u32 *sec_addr,u8 sec_num,
                         int (*fw)(u32 addr,u16 *buf,int len),
                         int (*fr)(u32 addr,u16 *buf,int len),
                         int (*fe)(u32 addr));
                         int (*fw)(u32 addr,u16 *buf,int len),
                         int (*fr)(u32 addr,u16 *buf,int len),
                         int (*fe)(u32 addr));
index 9d1903f82b30018f206a37632c584915c62f3e0c..0d70f2d997fcbb3608006900597d52c0fdfcfbd3 100644 (file)
@@ -12,7 +12,9 @@
 #include "types.h"
 
 /* macros */
 #include "types.h"
 
 /* macros */
-#define pwm_enable PWMTCR=0x0b
+#define pwm_enable PWMTCR=0x09
+#define pwm_reset PWMTCR=0x03
+#define pwm_disable PWMTCR=0x00
 
 /* defines */
 #define PWM_SINGLE_EDGE                0x00
 
 /* defines */
 #define PWM_SINGLE_EDGE                0x00
index 755437358528a8ec953b3b08b50ab29bba5c5f04..b181733006531a71109448dd790a3156a76b8e56 100644 (file)
@@ -65,6 +65,7 @@ void pin_init(void) {
         *
         * uart0: tx, rx
         * p0.7: pwm2
         *
         * uart0: tx, rx
         * p0.7: pwm2
+        * p0.11: gpio -> audio (leave as is)
         *
         */
 
         *
         */
 
@@ -108,8 +109,14 @@ void pin_init(void) {
         * out: p2.18 - p2.24 (+ pull high)
         * in: p0.30, p0.{27,28}, p3.{20,21}, p0.22, p0.13
         *
         * out: p2.18 - p2.24 (+ pull high)
         * in: p0.30, p0.{27,28}, p3.{20,21}, p0.22, p0.13
         *
+        * audio:
+        *
+        * p0.11: out
+        *
         */
 
         */
 
+       //IODIR0=(1<<11);
+
        // nothing to do for inputs (default: 0x00000000)
        IODIR2=((1<<18)|(1<<19)|(1<<20)|(1<<21)|(1<<22)|(1<<23)|(1<<24));
        IOSET2=((1<<18)|(1<<19)|(1<<20)|(1<<21)|(1<<22)|(1<<23)|(1<<24));
        // nothing to do for inputs (default: 0x00000000)
        IODIR2=((1<<18)|(1<<19)|(1<<20)|(1<<21)|(1<<22)|(1<<23)|(1<<24));
        IOSET2=((1<<18)|(1<<19)|(1<<20)|(1<<21)|(1<<22)|(1<<23)|(1<<24));