Ignore:
Timestamp:
01/16/12 06:46:19 (17 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/g10/kbd.c

    r1344 r1568  
    1212 
    1313 
    14 //static long kbd_new_state[3]; 
    15 long kbd_new_state[3]; 
    16  
    17 static long kbd_prev_state[3]; 
    18 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 }; 
    1917 
    2018static long last_kbd_key = 0; 
    2119static long alt_mode_key_mask = 0x00000400;     // G10 
    2220 
    23 static int usb_power=0; 
    24 static int remote_key, remote_count; 
    25 static int shoot_counter=0; 
    2621extern void _GetKbdState(long*); 
    27  
    28 #define DELAY_TIMEOUT 10000 
     22extern void usb_remote_key( int ) ; 
    2923 
    3024#define LED_ISO  (void*) 0xC02200D0 // G10 ISO select dial LED 
     
    3529#define SD_READONLY_FLAG        0x00020000              // Found @0xffb0f940, levent 0x90a 
    3630#define SD_READONLY_IDX     2          
    37 #define USB_FLAG            0x00040000  // Found @0xffb0f94c, levent 0x902 
     31#define USB_MASK            0x00040000  // Found @0xffb0f94c, levent 0x902 
    3832#define USB_IDX             2     
     33 
     34extern void usb_remote_key( int ) ; 
     35int get_usb_bit()  
     36{ 
     37        long usb_physw[3]; 
     38        usb_physw[USB_IDX] = 0; 
     39        _kbd_read_keys_r2(usb_physw); 
     40        return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ;  
     41} 
    3942 
    4043#define KEYS_MASK0 (0x00000003) 
     
    7174long __attribute__((naked)) wrap_kbd_p1_f() ; 
    7275 
    73 void wait_until_remote_button_is_released(void) 
    74 { 
    75  
    76  
    77 int count1; 
    78 int count2; 
    79 int tick,tick2,tick3; 
    80 int nSW; 
    81 int prev_usb_power,cur_usb_power; 
    82  // ------ add by Masuji SUTO (start) -------------- 
    83     static int nMode; 
    84  // ------ add by Masuji SUTO (end)   -------------- 
    85  
    86 asm volatile ("STMFD SP!, {R0-R11,LR}\n"); // store R0-R11 and LR in stack 
    87 debug_led(1); 
    88 tick = get_tick_count(); 
    89 tick2 = tick; 
    90 static long usb_physw[3]; 
    91 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 
    92   { 
    93 // ------ add by Masuji SUTO (start) -------------- 
    94         nMode=0; 
    95         usb_physw[USB_IDX] = 0;                                             // makes sure USB bit is cleared. 
    96         _kbd_read_keys_r2(usb_physw); 
    97         if((usb_physw[USB_IDX] & USB_FLAG)==USB_FLAG) nMode=1; 
    98 // ------ add by Masuji SUTO (end)   -------------- 
    99      if(conf.ricoh_ca1_mode && conf.remote_enable) 
    100      { 
    101         if(shooting_get_drive_mode()==1 && state_shooting_progress == SHOOTING_PROGRESS_PROCESSING){                    //continuous-shooting mode 
    102                 if(conf.bracket_type>2){ 
    103                         if(shoot_counter<2) shutter_int=3; 
    104                         shoot_counter--; 
    105                         } 
    106                 else{ 
    107                         prev_usb_power=0; 
    108                         nSW = 0; 
    109                         do 
    110                                 { 
    111                                 usb_physw[USB_IDX] = 0;                                             // makes sure USB bit is cleared. 
    112                                 _kbd_read_keys_r2(usb_physw); 
    113                                 cur_usb_power = (usb_physw[USB_IDX] & USB_FLAG)==USB_FLAG; 
    114                                 if(cur_usb_power){ 
    115                                         if(!prev_usb_power){ 
    116                                                 tick2 = get_tick_count(); 
    117                                                 prev_usb_power=cur_usb_power; 
    118                                                 } 
    119                                         else{ 
    120                                                 if((int)get_tick_count()-tick2>1000) {debug_led(0);} 
    121                                                 } 
    122                                         } 
    123                                 else{ 
    124                                         if(prev_usb_power){ 
    125                                                 tick3 = (int)get_tick_count()-tick2; 
    126                                                 if(nSW==10) { 
    127                                                         if(tick3>50) shutter_int=1; 
    128                                                         nSW=20; 
    129                                                         } 
    130                                                 if(nSW==0 && tick3>0) { 
    131                                                         if(tick3<50) { 
    132                                                         nSW=10; 
    133                                                         } 
    134                                                 else{ 
    135                                                         if(tick3>1000) shutter_int=1; 
    136                                                                 nSW=20; 
    137                                                         } 
    138                                                 } 
    139                                                 prev_usb_power=cur_usb_power; 
    140                                                 } 
    141                                         } 
    142                                 if((int)get_tick_count()-tick >= DELAY_TIMEOUT) {nSW=20;shutter_int=2;} 
    143                                 } 
    144                          while(nSW<20); 
    145                          } 
    146                 }               //continuous-shooting mode 
    147                 else{           // normal mode 
    148                         shoot_counter=0; 
    149                         if(conf.bracket_type>2){ 
    150                                 shoot_counter=(conf.bracket_type-2)*2; 
    151                                 } 
    152         do 
    153            { 
    154          //  _platformsub_kbd_fetch_data(x); 
    155            usb_physw[USB_IDX] = 0; 
    156           _kbd_read_keys_r2(usb_physw); 
    157            } 
    158  
    159 // ------ modif by Masuji SUTO (start) -------------- 
    160     while(((((usb_physw[USB_IDX] & USB_FLAG)!=USB_FLAG) && (nMode==0)) || (((usb_physw[USB_IDX] & USB_FLAG)==USB_FLAG) && (nMode==1))) && ((int)get_tick_count()-tick < DELAY_TIMEOUT)); 
    161 // ------ modif by Masuji SUTO (end)   -------------- 
    162         } 
    163        } // ricoh ca-1 mode 
    164  
    165 else 
    166  
    167        { 
    168          do 
    169           { 
    170          //  _platformsub_kbd_fetch_data(x); 
    171            usb_physw[USB_IDX] = 0; 
    172           _kbd_read_keys_r2(usb_physw); 
    173            } 
    174         while((usb_physw[USB_IDX]&USB_FLAG) &&  ((int)get_tick_count()-tick < DELAY_TIMEOUT)); 
    175  
    176         } 
    177  
    178   } // synch enable 
    179  
    180  
    181 if (conf.synch_delay_enable && conf.synch_delay_value>0)       // if delay is switched on and greater than 0 
    182   { 
    183     for (count1=0;count1<conf.synch_delay_value+(conf.synch_delay_coarse_value*1000);count1++) // wait delay_value * 0.1ms 
    184     { 
    185       for (count2=0;count2<1400;count2++)            // delay approx. 0.1ms 
    186         { 
    187         } 
    188      } 
    189   } 
    190  
    191 debug_led(0); 
    192 asm volatile ("LDMFD SP!, {R0-R11,LR}\n"); // restore R0-R11 and LR from stack 
    193 } 
    194  
    19576static void __attribute__((noinline)) mykbd_task_proceed() 
    19677{ 
     
    272153        } 
    273154         
    274         remote_key = (physw_status[USB_IDX] & USB_FLAG)==USB_FLAG; 
    275                 if (remote_key) 
    276                         remote_count += 1; 
    277                 else if (remote_count) { 
    278                         usb_power = remote_count; 
    279                         remote_count = 0; 
    280                 } 
     155        usb_remote_key(physw_status[USB_IDX]) ; 
     156 
    281157        if (conf.remote_enable) { 
    282                 physw_status[USB_IDX] = physw_status[USB_IDX] & ~(SD_READONLY_FLAG | USB_FLAG); 
     158                physw_status[USB_IDX] = physw_status[USB_IDX] & ~(SD_READONLY_FLAG | USB_MASK); 
    283159        } else { 
    284160                physw_status[USB_IDX] = physw_status[USB_IDX] & ~SD_READONLY_FLAG; 
    285161        } 
     162 
    286163} 
    287164 
     
    407284} 
    408285 
    409 int get_usb_power(int edge) 
    410 { 
    411         int x; 
    412  
    413         if (edge) return remote_key; 
    414         x = usb_power; 
    415         usb_power = 0; 
    416         return x; 
    417 } 
    418  
    419286 
    420287static int new_jogdial=0, old_jogdial=0; 
Note: See TracChangeset for help on using the changeset viewer.