Extend control hook framework
This commits adds a new error code that can be return from a registered control callback: USBD_REQ_NEXT_CALLBACK. This return code signifies that the callback is done processing the data successfully, but user would like to have all matching callbacks down the callback chain to be executed too. This change allows for example to intercept standard requests like GET_DESCRIPTOR, do some small action upon receiving of one, but still have the standard callback executed and do it's job. This way user doesn't have to re-implement standard GET_DESCRIPTOR functionality if they want to intercept that request to do some small thing.
This commit is contained in:
parent
12e1786863
commit
c5c4db0196
@ -24,6 +24,13 @@
|
||||
|
||||
BEGIN_DECLS
|
||||
|
||||
|
||||
enum usbd_request_return_codes {
|
||||
USBD_REQ_NOTSUPP = 0,
|
||||
USBD_REQ_HANDLED = 1,
|
||||
USBD_REQ_NEXT_CALLBACK = 2,
|
||||
};
|
||||
|
||||
typedef struct _usbd_driver usbd_driver;
|
||||
extern const usbd_driver stm32f103_usb_driver;
|
||||
extern const usbd_driver stm32f107_usb_driver;
|
||||
|
@ -102,7 +102,8 @@ static int usb_control_request_dispatch(struct usb_setup_data *req)
|
||||
result = cb[i].cb(req, &control_state.ctrl_buf,
|
||||
&control_state.ctrl_len,
|
||||
&control_state.complete);
|
||||
if (result)
|
||||
if (result == USBD_REQ_HANDLED ||
|
||||
result == USBD_REQ_NOTSUPP)
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user