[[Glasgow Notes]]
https://github.com/GlasgowEmbedded/glasgow/blob/1f7f4b109624be984a48d8796336f65c1cb1836d/software/glasgow/access/direct/demultiplexer.py
## 32 packets per transfer
max packets per EP = 1024
packers per xfer = 32
xfers per queue = 16
## tasks and buffers
in_tasks: TaskQueue
out_tasks: TaskQueue
in_buffer: ChunkedFIFO
out_buffer: ChunkedFIFO
### ChunkedFIFO
Uses https://docs.python.org/3/library/collections.html#collections.deque
### TaskQueue
methods
- submit
- cancel
- poll
- wait_one
- wait_all
## DirectDemultiplexer
initializes with two variables
- device
- pipe_count
The number of USB interfaces must be equal to the pipe count
Then it tries to `.setConfiguration()` for each interface
creates an empty set called `self._claimed`
### claim_interface
(I recognize this from applet code)
Arguments:
- applet - a Glasgow applet
- mux_interface
- args - arguments passed with CLI flags - voltage and port spec options
- pull_low, pull_high - lists of pins to pull low or high
Adds the attribute `_pipe_num` of `mux_interface` to the set `self._claimed`, as long as it's not already in there
Creates a `DirectDemultiplexerInterface`, passing `self.device`, `applet`, and `mux_interface`
Does a bunch of stuff configuring the outputs with pull up or pull down resistors
Resets the interface and waits
Returns the interface
## DirectDemultiplexerInterface
Arguments:
- device
- applet
- mux_interface
- kwargs: read_buffer_size, write_buffer_size
Passes `device,applet` to super class or whatever
`self._in_pushback = asyncio.Condition()` not sure what an asyncio Condition is but it's being established here
Does some checking of USB configurations and interface pip numbers
`setting = settings[1] # alt-setting 1 has the actual endpoints` oh ok
Goes through a bunch of endpoints and for each one sets an address as `_endpoint_in` or `_endpoint_out` and sets packet size
Claims interface
Creates an in and out `TaskQueue()`, an in and out `ChunkedFIFO()`, and in and out stall counts