USB callback
Colin (478) 2433 posts |
I’ve just discovered _kernel_current_stack_chunk() in kernel.h and thought of a way of implementing callbacks without using assembler. So I have 2 schemes shown below. cb_construct would be how you set up the callback in your module and cb_call is called from the usb module when transfer is complete. I was wondering if anyone has a preference I keep flip flopping between the 2. SchemeA has no assembler so may be better for future maintainability but it’s slightly more complicated to set up. SchemeB I suppose is a more traditional way of doing things but needs veneers from CMHG Any thoughts? SchemeA
SchemeB
|
Jeffrey Lee (213) 6048 posts |
I’d say scheme B is better – scheme A is too tied down to the SCL stack format and would run into lots of compatibility issues if the stack format was changed in future or if you had to support non-SCL code (e.g. GCC with UnixLib). |
Colin (478) 2433 posts |
Ok seems sensible except a variation of schemeA is required to write USB controller modules already. |
Jeffrey Lee (213) 6048 posts |
Yeah, I’m not quite sure why the controller modules are set up that way. AFAIK there’s nothing stopping them from using generic veneers. |
Jeffrey Lee (213) 6048 posts |
Actually – the USB modules are more akin to scheme B, not scheme A. With scheme A it’s the caller’s responsibility to set up the magic words on the stack ready for the target, while with scheme B (CMHG/USB) it’s the target’s responsibility to set everything up for himself. |