About USB ddk's sample


in USB ddk sample code, such as keyb.c, there are some codes like this:

int keyb_io_open( resmgr_context_t *ctp, io_open_t *msg, RESMGR_HANDLE_T *handle, void *extra )
keyb_t *keyb;
int status;

keyb	= (keyb_t *)handle;


I don’t know why RESMGR_HANDLE_T *handle can be convert to keyb_t,
I look for RESMGR_HANDLE_T, it is the same as io_funcs_t,
where dose this driver code set handle as keyb_t?
and the same question of keyb_io_read’s ocb->attr .

thank you all :smiley: !


the varialble is a generic pointer that is part of the resource manager framework. What you get it to point to is up the you (or in this case up to the USB ddk).

There are some way to change to type of RESMGR_HANDLE_T to that of your own type to get rid of the extra casting.

Does this answer your question?