Wait for complete transmission of PRE
.. by looking for the related state machine to enter txstall h/t @tannewt for doing a protocol trace and noticing that there was no LS packet transmitted after the PRE. I don't know what those words mean but it led to me conjecturing a fix. I also moved the clear of the IRQ complete flag above the start of the transfer, just in case the transfer could complete before the flag was cleared. But, I don't think this was a cause of the problem. it may be worth looking at the other sites where IRQ_TX_EOP_MASK is used to see whether similar treatment is necessary. With this, a LS keyboard & LS gamepad will enumerate on my FruitJam at 240MHz (via tools menu) & at 268MHz with HDMI display (dvhstx hard-coded overclock)
This commit is contained in:
parent
6c6e4e0634
commit
44208b33b4
1 changed files with 8 additions and 2 deletions
|
|
@ -50,14 +50,20 @@ static void __no_inline_not_in_flash_func(send_pre)(pio_port_t *pp) {
|
|||
SM_SET_CLKDIV(pp->pio_usb_tx, pp->sm_tx, pp->clk_div_fs_tx);
|
||||
|
||||
pio_sm_exec(pp->pio_usb_tx, pp->sm_tx, pp->tx_start_instr);
|
||||
pp->pio_usb_tx->irq = IRQ_TX_ALL_MASK; // clear complete flag
|
||||
dma_channel_transfer_from_buffer_now(pp->tx_ch, pre_encoded,
|
||||
sizeof(pre_encoded));
|
||||
pp->pio_usb_tx->irq = IRQ_TX_ALL_MASK; // clear complete flag
|
||||
|
||||
while ((pp->pio_usb_tx->irq & IRQ_TX_EOP_MASK) == 0) {
|
||||
continue;
|
||||
}
|
||||
pio_sm_clear_fifos(pp->pio_usb_tx, pp->sm_tx);
|
||||
|
||||
// wait for complete transmission of the PRE packet
|
||||
uint32_t stall_mask = 1 << (PIO_FDEBUG_TXSTALL_LSB + pp->sm_tx);
|
||||
pp->pio_usb_tx->fdebug = stall_mask; // clear sticky stall mask bit
|
||||
while (!(pp->pio_usb_tx->fdebug & stall_mask)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// change bus speed to low-speed
|
||||
pp->low_speed = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue