/*--------------------------------------------------------------------------*/void RxSerial (void) {/*--------------------------------------------------------------------------*//* ;---------------------------------------------------------------------------* ; Receives 1 start bit Lo, 9 data bits and 1 stop bit Hi at 9600 bps ; Byte time = 1.144 mS ; Bit time = 104 uS (0.16% erro w/10 Mhz) ; ; False start bit check ; ; Start bit hunting timeout = 4*1.283ms ; ; Input : none ; Output : Carry = 1 => success ; rxBuf[0,1] = input byte +9th bit ; Carry = 0 => error (timeout or stop bit=0) ;---------------------------------------------------------------------------**/ char idx; rxBuf[0] = 4; // 5.135 ms timeout idx = 0; while (1) { while (RxD_pin) // input "high" { if ((-- idx)==0) { rxBuf[0]--; if (rxBuf[0]==0) { Carry = 0; return; } } } Delay_uSeg(40); // 1/2 bit delay (40*3+7)*0.4us=50.8us if (RxD_pin) continue; // false start bit detection rxBuf[0] = 0x01; // 9 bits counter and reception buffer rxBuf[1] = 0x00; do { Delay_uSeg(81); // (81*3+7)*0.4us=100us nop(); // 0.4us nop(); // 0.4us Carry = RxD_pin; // 1.2us bit read rxBuf[0] = rr(rxBuf[0]); // 0.4us store and count rxBuf[1] = rr(rxBuf[1]); // 0.4us } // 1.2us while (Carry==0); Delay_uSeg(81); // (81*3+7)*0.4us=100us nop(); // 0.4us Carry = RxD_pin; // stop bit read return; // 100 us availiable }}
How long is a tick in CHDK? (eg from get_tick_count) Should it be consistent across all cameras? (DIGIC II/DIGIC III?)
Success! I can now talk to my A640 (one byte at a time) at 4800 baud (faster speeds should be perfectly possible) with moderate reliability ... With a little bit of work this makes an awful lot of applications feasible.
Do you know if any routines call 'gui_kbd_process' , I cannot find any ?
if (kbd_is_key_pressed(KEY_SHOOT_FULL)){ key_pressed = 100; if (!state_kbd_script_run){ script_console_clear(); script_console_add_line(lang_str(LANG_CONSOLE_TEXT_STARTED)); script_start(); } else { script_console_add_line(lang_str(LANG_CONSOLE_TEXT_INTERRUPTED)); script_end(); } } if (state_kbd_script_run) process_script(); else { gui_kbd_process(); }