mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-22 18:50:37 +02:00
atusb/fw/: SET_INTERFACE can now select among interfaces (changes user_setup)
- ep0.c (ep0_init), usb/dfu.c (dfu_init): set user_setups[0] instead of user_setup - usb/atu2.c (usb_poll): reset user_setup on bus reset - usb/usb.h (user_setups), usb/usb.c (user_setups): array of interface-specific setup functions - usb/usb.c (handle_setup): in SET_INTERFACE, select setup function from user_setups according to interface - usb/usb.c (handle_setup): if user_setup is not set (e.g., the optional SET_INTERFACE was never issued), fall back to user_setups[0]
This commit is contained in:
parent
4d4e132f0a
commit
89d13ce8f8
@ -209,5 +209,5 @@ static int my_setup(const struct setup_request *setup)
|
|||||||
|
|
||||||
void ep0_init(void)
|
void ep0_init(void)
|
||||||
{
|
{
|
||||||
user_setup = my_setup;
|
user_setups[0] = my_setup;
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ static void my_reset(void)
|
|||||||
|
|
||||||
void dfu_init(void)
|
void dfu_init(void)
|
||||||
{
|
{
|
||||||
user_setup = my_setup;
|
user_setups[0] = my_setup;
|
||||||
user_get_descriptor = my_descr;
|
user_get_descriptor = my_descr;
|
||||||
user_reset = my_reset;
|
user_reset = my_reset;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +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);
|
||||||
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);
|
||||||
@ -135,9 +136,20 @@ int handle_setup(const struct setup_request *setup)
|
|||||||
{
|
{
|
||||||
const uint8_t *interface_descriptor =
|
const uint8_t *interface_descriptor =
|
||||||
config_descriptor+9;
|
config_descriptor+9;
|
||||||
|
const uint8_t *p;
|
||||||
|
int i;
|
||||||
|
|
||||||
if (setup->wIndex != interface_descriptor[2] ||
|
i = 0;
|
||||||
setup->wValue != interface_descriptor[3])
|
for (p = interface_descriptor;
|
||||||
|
p != config_descriptor+config_descriptor[2];
|
||||||
|
p += p[0]) {
|
||||||
|
if (p[2] == setup->wIndex &&
|
||||||
|
p[3] == setup->wValue) {
|
||||||
|
user_setup = user_setups[i];
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -156,9 +168,11 @@ int handle_setup(const struct setup_request *setup)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (!user_setup)
|
if (user_setup)
|
||||||
return 0;
|
|
||||||
return user_setup(setup);
|
return user_setup(setup);
|
||||||
|
if (user_setups[0])
|
||||||
|
return user_setups[0](setup);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -133,6 +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 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);
|
||||||
|
Loading…
Reference in New Issue
Block a user