Ignore:
Timestamp:
01/16/12 06:46:19 (16 months ago)
Author:
reyalp
Message:

new usb remote system from waterwings http://chdk.setepontos.com/index.php?topic=7127.msg79948#msg79948
draft documentation http://chdk.wikia.com/wiki/User:Waterwingz/USB_Remote_V2
note ixus230 kbd.c not updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/platform/ixus870_sd880/kbd.c

    r1344 r1568  
    1212 
    1313 
    14 static long kbd_new_state[3]; 
    15 static long kbd_prev_state[3]; 
    16 static long kbd_mod_state[3]; 
     14long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; 
     15static long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; 
     16static long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF }; 
    1717 
    1818static long last_kbd_key = 0; 
    1919static long alt_mode_key_mask = 0x00000800; // key_print 
    20 static int usb_power=0; 
    21 static int remote_key, remote_count; 
    22 static int shoot_counter=0; 
     20 
    2321extern void _platformsub_kbd_fetch_data(long*); 
    24  
    25 #define DELAY_TIMEOUT 10000 
    2622 
    2723// each mask should be the xor of all key values in the corresponding group 
     
    4844 
    4945#define USB_MASK (0x40000) 
    50 #define USB_REG 2               // idx in physw_status 
     46#define USB_IDX  2 
     47 
     48extern void usb_remote_key( int ) ; 
     49int get_usb_bit()  
     50{ 
     51        long usb_physw[3]; 
     52        usb_physw[USB_IDX] = 0; 
     53        _kbd_read_keys_r2(usb_physw); 
     54        return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ;  
     55} 
    5156 
    5257 
     
    8489long __attribute__((naked)) wrap_kbd_p1_f() ; 
    8590 
    86 void wait_until_remote_button_is_released(void) 
    87 { 
    88  
    89 long x[3]; 
    90 int count1; 
    91 int count2; 
    92 int tick,tick2,tick3; 
    93 int nSW; 
    94 int prev_usb_power,cur_usb_power; 
    95  // ------ add by Masuji SUTO (start) -------------- 
    96     static int nMode; 
    97  // ------ add by Masuji SUTO (end)   -------------- 
    98  
    99 asm volatile ("STMFD SP!, {R0-R11,LR}\n"); // store R0-R11 and LR in stack 
    100 debug_led(1); 
    101 tick = get_tick_count(); 
    102 tick2 = tick; 
    103 static long usb_physw[3]; 
    104 if (conf.synch_enable && conf.ricoh_ca1_mode && conf.remote_enable && (!shooting_get_drive_mode()|| ((shooting_get_drive_mode()==2) && state_shooting_progress != SHOOTING_PROGRESS_PROCESSING)))  // synch mode enable so wait for USB to disconnect 
    105   { 
    106 // ------ add by Masuji SUTO (start) -------------- 
    107         nMode=0; 
    108         usb_physw[USB_REG] = 0;                                             // makes sure USB bit is cleared. 
    109         _kbd_read_keys_r2(usb_physw); 
    110         if((usb_physw[USB_REG] & USB_MASK)==USB_MASK) nMode=1; 
    111 // ------ add by Masuji SUTO (end)   -------------- 
    112      if(conf.ricoh_ca1_mode && conf.remote_enable) 
    113      { 
    114         if(shooting_get_drive_mode()==1 && state_shooting_progress == SHOOTING_PROGRESS_PROCESSING){                    //continuous-shooting mode 
    115                 if(conf.bracket_type>2){ 
    116                         if(shoot_counter<2) shutter_int=3; 
    117                         shoot_counter--; 
    118                         } 
    119                 else{ 
    120                         prev_usb_power=0; 
    121                         nSW = 0; 
    122                         do 
    123                                 {      
    124                                 usb_physw[USB_REG] = 0;                                             // makes sure USB bit is cleared. 
    125                                 _kbd_read_keys_r2(usb_physw); 
    126                                 cur_usb_power = (usb_physw[USB_REG] & USB_MASK)==USB_MASK; 
    127                                 if(cur_usb_power){ 
    128                                         if(!prev_usb_power){ 
    129                                                 tick2 = get_tick_count(); 
    130                                                 prev_usb_power=cur_usb_power; 
    131                                                 } 
    132                                         else{ 
    133                                                 if((int)get_tick_count()-tick2>1000) {debug_led(0);} 
    134                                                 } 
    135                                         } 
    136                                 else{ 
    137                                         if(prev_usb_power){ 
    138                                                 tick3 = (int)get_tick_count()-tick2; 
    139                                                 if(nSW==10) { 
    140                                                         if(tick3>50) shutter_int=1; 
    141                                                         nSW=20; 
    142                                                         } 
    143                                                 if(nSW==0 && tick3>0) { 
    144                                                         if(tick3<50) { 
    145                                                         nSW=10; 
    146                                                         } 
    147                                                 else{ 
    148                                                         if(tick3>1000) shutter_int=1; 
    149                                                                 nSW=20; 
    150                                                         } 
    151                                                 } 
    152                                                 prev_usb_power=cur_usb_power; 
    153                                                 } 
    154                                         } 
    155                                 if((int)get_tick_count()-tick >= DELAY_TIMEOUT) {nSW=20;shutter_int=2;} 
    156                                 } 
    157                          while(nSW<20); 
    158                          } 
    159                 }               //continuous-shooting mode  
    160                 else{           // normal mode 
    161                         shoot_counter=0; 
    162                         if(conf.bracket_type>2){ 
    163                                 shoot_counter=(conf.bracket_type-2)*2; 
    164                                 } 
    165         do 
    166            { 
    167          //  _platformsub_kbd_fetch_data(x); 
    168            usb_physw[USB_REG] = 0; 
    169           _kbd_read_keys_r2(usb_physw);             
    170            } 
    171  
    172 // ------ modif by Masuji SUTO (start) -------------- 
    173     while(((((usb_physw[USB_REG] & USB_MASK)!=USB_MASK) && (nMode==0)) || (((usb_physw[USB_REG] & USB_MASK)==USB_MASK) && (nMode==1))) && ((int)get_tick_count()-tick < DELAY_TIMEOUT)); 
    174 // ------ modif by Masuji SUTO (end)   -------------- 
    175         } 
    176        } // ricoh ca-1 mode 
    177  
    178 else 
    179  
    180        { 
    181          do 
    182           { 
    183          //  _platformsub_kbd_fetch_data(x); 
    184            usb_physw[USB_REG] = 0; 
    185           _kbd_read_keys_r2(usb_physw);            
    186            } 
    187         while((usb_physw[USB_REG]&USB_MASK) &&  ((int)get_tick_count()-tick < DELAY_TIMEOUT)); 
    188  
    189         } 
    190  
    191   } // synch enable 
    192  
    193  
    194 if (conf.synch_delay_enable && conf.synch_delay_value>0)       // if delay is switched on and greater than 0 
    195   { 
    196     for (count1=0;count1<conf.synch_delay_value+(conf.synch_delay_coarse_value*1000);count1++) // wait delay_value * 0.1ms 
    197     { 
    198       for (count2=0;count2<1400;count2++)            // delay approx. 0.1ms 
    199         { 
    200         } 
    201      } 
    202   } 
    203  
    204 debug_led(0); 
    205  
    206 asm volatile ("LDMFD SP!, {R0-R11,LR}\n"); // restore R0-R11 and LR from stack 
    207 } 
    208  
    209  
    210  
    21191 
    21292static void __attribute__((noinline)) mykbd_task_proceed() 
     
    309189        _kbd_read_keys_r2(physw_status); 
    310190 
    311         remote_key = (physw_status[USB_REG] & USB_MASK)==USB_MASK; 
    312                 if (remote_key)  
    313                         remote_count += 1; 
    314                 else if (remote_count) { 
    315                         usb_power = remote_count; 
    316                         remote_count = 0; 
    317                 } 
     191        usb_remote_key(physw_status[USB_IDX]) ; 
     192 
    318193        if (conf.remote_enable) { 
    319 #if USB_REG == SD_READONLY_REG 
    320                 physw_status[USB_REG] = physw_status[USB_REG] & ~(SD_READONLY_FLAG | USB_MASK); 
    321 #else 
    322                 physw_status[USB_REG] = physw_status[USB_REG] & ~USB_MASK; 
    323                 physw_status[SD_READONLY_REG] = physw_status[SD_READONLY_REG] & ~SD_READONLY_FLAG; 
    324 #endif 
     194                physw_status[USB_IDX] = physw_status[USB_IDX] & ~(SD_READONLY_FLAG | USB_MASK); 
    325195        } else { 
    326                 physw_status[SD_READONLY_REG] = physw_status[SD_READONLY_REG] & ~SD_READONLY_FLAG; 
     196                physw_status[USB_IDX] = physw_status[USB_IDX] & ~SD_READONLY_FLAG; 
    327197        } 
    328198 
     
    452322} 
    453323 
    454  
    455 int get_usb_power(int edge) 
    456 { 
    457         int x; 
    458  
    459         if (edge) return remote_key; 
    460         x = usb_power; 
    461         usb_power = 0; 
    462         return x; 
    463 } 
    464  
    465324long kbd_use_zoom_as_mf() { 
    466325 return 0; 
Note: See TracChangeset for help on using the changeset viewer.