(packet: &UsbEndpointTransferDescriptor)
| 135 | } |
| 136 | |
| 137 | fn rx_callback(packet: &UsbEndpointTransferDescriptor) { |
| 138 | if unsafe { CONFIGURED } == false { |
| 139 | return; |
| 140 | } |
| 141 | |
| 142 | let qh = usb_get_queuehead(CDC_RX_ENDPOINT as usize, false); |
| 143 | let len = (RX_BUFFER_SIZE as u32) - (packet.status >> 16) & 0x7FFF; |
| 144 | |
| 145 | // // Read the bytes |
| 146 | for index in 0..len { |
| 147 | unsafe { |
| 148 | BUFFER.enqueue(RX_BUFFER.bytes[index as usize]); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | // If the queueheads have been reset, let's |
| 153 | // re-initialize it all. |
| 154 | // |
| 155 | // IDK if this is a good idea?? |
| 156 | // What is the benefit of this vs. just having 1 descriptor? |
| 157 | // I'm assuming multiple pages will give us some amount of |
| 158 | // concurrency resilience but not really sure. |
| 159 | if qh.first_transfer == qh.last_transfer && qh.first_transfer == 0 { |
| 160 | // Process |
| 161 | rx_queue_transfer(); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | /// Returns how many bytes are available to read from |
| 166 | /// the buffer. |
nothing calls this directly
no test coverage detected