mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-22 14:04:59 +02:00
atusb/fw: revert most of the user_setups change and use simple callback instead
This allows us to do other things as well, e.g., change state. - ep0.c (ep0_init), usb/dfu.c (dfu_init): use user_setup - usb/atu2.c (usb_poll): no need to reset user_setup - the user's reset function can do that - usb/usb.h (user_setups), usb/usb.c (handle_setup): removed user_setups - usb/usb.h (user_set_interface), usb/usb.c (user_set_interface, handle_setup): callback for SET_INTERFACE
This commit is contained in:
parent
7a2c785e29
commit
bbe27fc357
@ -209,5 +209,5 @@ static int my_setup(const struct setup_request *setup)
|
||||
|
||||
void ep0_init(void)
|
||||
{
|
||||
user_setups[0] = my_setup;
|
||||
user_setup = my_setup;
|
||||
}
|
||||
|
@ -190,7 +190,6 @@ void usb_poll(void)
|
||||
if (flags & (1 << EORSTI)) {
|
||||
if (user_reset)
|
||||
user_reset();
|
||||
user_setup = NULL;
|
||||
ep_init();
|
||||
UDINT &= ~(1 << EORSTI);
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ static void my_reset(void)
|
||||
|
||||
void dfu_init(void)
|
||||
{
|
||||
user_setups[0] = my_setup;
|
||||
user_setup = my_setup;
|
||||
user_get_descriptor = my_descr;
|
||||
user_reset = my_reset;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ extern void panic(void);
|
||||
#endif
|
||||
|
||||
int (*user_setup)(const struct setup_request *setup);
|
||||
int (*user_setups[2])(const struct setup_request *setup);
|
||||
void (*user_set_interface)(int nth);
|
||||
int (*user_get_descriptor)(uint8_t type, uint8_t index,
|
||||
const uint8_t **reply, uint8_t *size);
|
||||
void (*user_reset)(void);
|
||||
@ -145,7 +145,8 @@ int handle_setup(const struct setup_request *setup)
|
||||
p += p[0]) {
|
||||
if (p[2] == setup->wIndex &&
|
||||
p[3] == setup->wValue) {
|
||||
user_setup = user_setups[i];
|
||||
if (user_set_interface)
|
||||
user_set_interface(i);
|
||||
return 1;
|
||||
}
|
||||
i++;
|
||||
@ -170,8 +171,6 @@ int handle_setup(const struct setup_request *setup)
|
||||
default:
|
||||
if (user_setup)
|
||||
return user_setup(setup);
|
||||
if (user_setups[0])
|
||||
return user_setups[0](setup);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ extern const uint8_t config_descriptor[];
|
||||
extern struct ep_descr eps[];
|
||||
|
||||
extern int (*user_setup)(const struct setup_request *setup);
|
||||
extern int (*user_setups[2])(const struct setup_request *setup);
|
||||
extern void (*user_set_interface)(int nth);
|
||||
extern int (*user_get_descriptor)(uint8_t type, uint8_t index,
|
||||
const uint8_t **reply, uint8_t *size);
|
||||
extern void (*user_reset)(void);
|
||||
|
Loading…
Reference in New Issue
Block a user