Wait for two tx packets before startup, and make sure one of those
packets is acked before sending a third tx packet.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Commit cd8d57c2 added USB double buffering mode on transmits.
However, when enabling double buffering mode, the hardware seems to
always send at least two packets. Spurious transmissions could cause
the Linux gs_usb driver to get confused, which could lead to the can0
device becoming unavailable on restarts. Fix by waiting for two USB
packets to be available before enabling the endpoint.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The bulk out endpoint should not be enabled in tx mode, and the bulk
in endpoint should not be enabled in rx mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Implement the usbfs fast buffer switching mechanism on the "bulk in"
endpoint. This can improve the overall USB throughput and bus
utilization.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Implement the usbfs fast buffer switching mechanism on the "bulk out"
endpoint. This can improve the overall USB throughput and bus
utilization.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The usbfs device supports two buffers for each endpoint - typically
one for rx and one for tx. Add support for explicit handling of both
buffers. This is in preparation for improved "double buffering"
support.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Replace the set_stat_x_bits() functions with a single calc_epr_bits()
function. This new function supports setting bits other than the stat
field in the epr register.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use a fixed layout for the USB transfer memory and remove the ep_mem
struct definition.
This is in preparation for stm32g0 support.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The stm32f0 line uses 16bit packet memory reads/writes (as opposed to
the goofy 32bit accesses required on the stm32f103).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The usbfs receive buffers must also have space for the 2 byte crc at
the end of a transmission. This fixes an error that could lead to
lost messages from mcu to host (resulting in bytes_invalid increasing
in stats) on the stm32f103.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Now that the code in stm32f4/ can handle both stm32f1 and stm32f4
chips, rename the directory to just "stm32".
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>