Quote from: philmoz on 23 / March / 2014, 19:22:40I can suggest two approaches:- put all the callback code in wrappers.c so it is always compiled as ARM- put an ARM wrapper for the callback code in wrappers.c with the main thumb code in the usb_remote fileIf the callback function is simple then it can probably live in wrappers.c, otherwise the second option is probably better.So here's a patch file that I've been playing with. It adds an enable_highspeed_usb() function to Lua that switches the USB remote pulse counting & width measurement to work from an HP timer. If you don't make the function call from a script, all the USB remote code works as before. At some point we might want to limit how short a timer interval the user can try but for now it "caveat emptor".I don't have a VxWorks camera to test it with but it works a charm on my DryOS cameras.There is a little test script (pwm_test.lua) in the CHDK/SCRIPTS directory. I've experimented with rate as fast as 100 uSec but that tends to be so fast it catches switch bounce Will it work this way under VxWorks ?
I can suggest two approaches:- put all the callback code in wrappers.c so it is always compiled as ARM- put an ARM wrapper for the callback code in wrappers.c with the main thumb code in the usb_remote fileIf the callback function is simple then it can probably live in wrappers.c, otherwise the second option is probably better.
extern int usb_HPtimer_bad(int, int);extern int usb_HPtimer_good(int, int);int usb_HPtimer_handle=0;int usb_HPtimer_error_count=0;static int ARM_usb_HPtimer_good(int time, int interval) { return usb_HPtimer_good(time, interval); }static int ARM_usb_HPtimer_bad(int time, int interval)) { return usb_HPtimer_bad(time, interval); }int start_usb_HPtimer(int interval) // return 0 if timer already running or error, 1 if successful{ if ( usb_HPtimer_handle == 0 ) { usb_HPtimer_handle = _SetHPTimerAfterNow(interval,ARM_usb_HPtimer_good,ARM_usb_HPtimer_bad,interval); if (!(usb_HPtimer_handle & 0x01)) return 1 ; usb_HPtimer_handle = 0 ; } return 0;}
At some point soon, it would be nice to get those two function added to stubs_entry.S (they are already in the funcs_by_name.csv & funcs_by_address.csv)
updated patch attached
So, I would recommend getting the USB bit directly if possible, and perhaps only enabling the high speed routine on those cameras.
+result=enable_highspeed_usb(s)+print("enable highspeed status=",result)+result=enable_highspeed_usb(s)+print("enable highspeed status=",result)+repeat+ x=get_usb_power(0)+ if ( x > 0 ) then + print("width="..x) + end+ wait_click(100)+until is_pressed("menu")+result=enable_highspeed_usb(0)+print("disable highspeed status=",result)+result=enable_highspeed_usb(0)+print("disable highspeed status=",result)
+result=enable_highspeed_usb(s)+print("enable highspeed status=",result)
+result=enable_highspeed_usb(0)+print("disable highspeed status=",result)
I would recommend getting the USB bit directly if possible
Could you please tell me why you call two times each? Thanks a lot!
What would be the benefit compared to the HP_timer solution?
I come back to my project where I want to have a microcontroller to generate some pulses and CHDK should detect this pulses and trigger different actions depending on pulse pattern.This actions I also need in rec mode e.g. for shooting an image, zoom etc..So I personally need it in both modes. For my purpose I need this function run all the time since an extern pulse from the microcontroller can happen now, in 1 seconde or even in 3 minutes or whatever. If possible the implementation should take care that the camera functions in rec and play mode are not disturbed.
...When your microcontroller wants to communicate, send a 30 mSec pulse first. The communication code can detect that and switch to high speed mode only for as long as it takes to receive the data packet. It then switches back to normal task mode.
Since we have to be carefull and should reduce the time using HP-Timer I still think about the solution which is based on the middle battery contact.E.g.100 Ohm = zoom in200 Ohm = zoom out300 Ohm = shutter half press400 Ohm = shutter full press...With this I can trigger an action by only one pulse or maybe two if one is not enough to trigger all actions.Which means I can drastically reduce the number of pulses. Can HP-Timer be combined with middle battery contact detection? The battery middle contact solution would reduce the time the HP-Timer is used. Do you think this is the better aproach?
Started by fudgey General Discussion and Assistance
Started by reyalp General Discussion and Assistance
Started by flarn2006 Feature Requests
Started by ccanon Feature Requests
Started by waterwingz « 1 2 ... 6 7 » General Discussion and Assistance