sw: usb: set the usb address

When we get a SET_ADDRESS command, set the USB address.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2019-08-20 14:01:24 +08:00
parent 90bb71a77e
commit b95791dd23
2 changed files with 7 additions and 0 deletions

View File

@ -1,6 +1,8 @@
#ifndef __USB_H
#define __USB_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -22,6 +24,7 @@ void usb_err(void);
int usb_recv(void *buffer, unsigned int buffer_len);
void usb_poll(void);
void usb_wait_for_send_done(void);
void usb_set_address(uint8_t new_address);
#ifdef __cplusplus
}

View File

@ -5,6 +5,7 @@
#include <system.h>
#include <usb-desc.h>
#include <generated/csr.h>
static uint8_t reply_buffer[8];
static uint8_t usb_configuration = 0;
@ -20,6 +21,9 @@ void usb_setup(const struct usb_setup_request *setup)
switch (setup->wRequestAndType)
{
case 0x0500: // SET_ADDRESS
usb_set_address(((uint8_t *)setup)[2]);
break;
case 0x0b01: // SET_INTERFACE
dfu_clrstatus();
break;