1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-26 07:08:28 +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:
Werner Almesberger 2011-06-10 21:50:42 -03:00
parent 7a2c785e29
commit bbe27fc357
5 changed files with 6 additions and 8 deletions

View File

@ -209,5 +209,5 @@ static int my_setup(const struct setup_request *setup)
void ep0_init(void) void ep0_init(void)
{ {
user_setups[0] = my_setup; user_setup = my_setup;
} }

View File

@ -190,7 +190,6 @@ void usb_poll(void)
if (flags & (1 << EORSTI)) { if (flags & (1 << EORSTI)) {
if (user_reset) if (user_reset)
user_reset(); user_reset();
user_setup = NULL;
ep_init(); ep_init();
UDINT &= ~(1 << EORSTI); UDINT &= ~(1 << EORSTI);
} }

View File

@ -280,7 +280,7 @@ static void my_reset(void)
void dfu_init(void) void dfu_init(void)
{ {
user_setups[0] = my_setup; user_setup = my_setup;
user_get_descriptor = my_descr; user_get_descriptor = my_descr;
user_reset = my_reset; user_reset = my_reset;
} }

View File

@ -36,7 +36,7 @@ extern void panic(void);
#endif #endif
int (*user_setup)(const struct setup_request *setup); 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, int (*user_get_descriptor)(uint8_t type, uint8_t index,
const uint8_t **reply, uint8_t *size); const uint8_t **reply, uint8_t *size);
void (*user_reset)(void); void (*user_reset)(void);
@ -145,7 +145,8 @@ int handle_setup(const struct setup_request *setup)
p += p[0]) { p += p[0]) {
if (p[2] == setup->wIndex && if (p[2] == setup->wIndex &&
p[3] == setup->wValue) { p[3] == setup->wValue) {
user_setup = user_setups[i]; if (user_set_interface)
user_set_interface(i);
return 1; return 1;
} }
i++; i++;
@ -170,8 +171,6 @@ int handle_setup(const struct setup_request *setup)
default: default:
if (user_setup) if (user_setup)
return user_setup(setup); return user_setup(setup);
if (user_setups[0])
return user_setups[0](setup);
return 0; return 0;
} }

View File

@ -133,7 +133,7 @@ extern const uint8_t config_descriptor[];
extern struct ep_descr eps[]; extern struct ep_descr eps[];
extern int (*user_setup)(const struct setup_request *setup); 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, extern int (*user_get_descriptor)(uint8_t type, uint8_t index,
const uint8_t **reply, uint8_t *size); const uint8_t **reply, uint8_t *size);
extern void (*user_reset)(void); extern void (*user_reset)(void);