mirror of
https://github.com/im-tomu/foboot.git
synced 2024-09-20 02:40:09 +00:00
src: epfifo: add address support
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
a9a75fb02f
commit
3ea66a7689
@ -22,6 +22,9 @@ static volatile int data_offset;
|
||||
static volatile int data_to_send;
|
||||
static int next_packet_is_empty;
|
||||
|
||||
static int have_new_address;
|
||||
static uint8_t new_address;
|
||||
|
||||
// Note that our PIDs are only bits 2 and 3 of the token,
|
||||
// since all other bits are effectively redundant at this point.
|
||||
enum USB_PID {
|
||||
@ -192,6 +195,10 @@ void usb_isr(void) {
|
||||
if (ep0i_pending) {
|
||||
usb_ep_0_in_respond_write(EPF_NAK);
|
||||
usb_ep_0_in_ev_pending_write(ep0i_pending);
|
||||
if (have_new_address) {
|
||||
have_new_address = 0;
|
||||
usb_address_write(new_address);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
@ -209,7 +216,8 @@ void usb_ack_out(void) {
|
||||
usb_ep_0_out_respond_write(EPF_ACK);
|
||||
}
|
||||
|
||||
void usb_err(void) {
|
||||
void usb_err(uint8_t epdir) {
|
||||
(void)epdir;
|
||||
usb_ep_0_out_respond_write(EPF_STALL);
|
||||
usb_ep_0_in_respond_write(EPF_STALL);
|
||||
}
|
||||
@ -238,6 +246,11 @@ int usb_recv(void *buffer, unsigned int buffer_len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void usb_set_address(uint8_t new_address_) {
|
||||
new_address = new_address_;
|
||||
have_new_address = 1;
|
||||
}
|
||||
|
||||
void usb_poll(void) {
|
||||
// If some data was received, then process it.
|
||||
while (usb_ep0out_rd_ptr != usb_ep0out_wr_ptr) {
|
||||
|
Loading…
Reference in New Issue
Block a user