MCPcopy Create free account
hub / github.com/SharpCoder/teensycore / rx_callback

Function rx_callback

src/usb_serial.rs:137–163  ·  view source on GitHub ↗
(packet: &UsbEndpointTransferDescriptor)

Source from the content-addressed store, hash-verified

135}
136
137fn 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.

Callers

nothing calls this directly

Calls 3

usb_get_queueheadFunction · 0.85
rx_queue_transferFunction · 0.85
enqueueMethod · 0.45

Tested by

no test coverage detected