diff --git a/src/lib.rs b/src/lib.rs index 75462a6..4a41a46 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -57,6 +57,11 @@ impl UsbBus for UsbDevice { let target_endpoint = &mut self.ep_table[address.index()]; + // Set endpoint parameters. // + + target_endpoint.set_dir(ep_dir); + target_endpoint.set_type(ep_type); + // Get power of two number of endpoint size. // let ep_size = max(8, max_packet_size.next_power_of_two()); @@ -66,14 +71,10 @@ impl UsbBus for UsbDevice { if DPRAM_SIZE - self.dpram_already_used < ep_size { Err(UsbError::EndpointMemoryOverflow) } else { - // Set endpoint parameters. // - - target_endpoint.set_dir(ep_dir); - target_endpoint.set_type(ep_type); - target_endpoint.set_size(ep_size)?; - // Add used dpram memory. // + target_endpoint.set_size(ep_size)?; + target_endpoint.is_allocated = true; self.dpram_already_used += ep_size;