Disallow ctrl-C interrupts of RP2040 SPI and PIO
This commit is contained in:
parent
a843b8a0d4
commit
ab52a92704
@ -212,15 +212,6 @@ static bool _transfer(busio_spi_obj_t *self,
|
|||||||
while (dma_channel_is_busy(chan_rx) || dma_channel_is_busy(chan_tx)) {
|
while (dma_channel_is_busy(chan_rx) || dma_channel_is_busy(chan_tx)) {
|
||||||
// TODO: We should idle here until we get a DMA interrupt or something else.
|
// TODO: We should idle here until we get a DMA interrupt or something else.
|
||||||
RUN_BACKGROUND_TASKS;
|
RUN_BACKGROUND_TASKS;
|
||||||
if (mp_hal_is_interrupted()) {
|
|
||||||
if (dma_channel_is_busy(chan_rx)) {
|
|
||||||
dma_channel_abort(chan_rx);
|
|
||||||
}
|
|
||||||
if (dma_channel_is_busy(chan_tx)) {
|
|
||||||
dma_channel_abort(chan_tx);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +224,7 @@ static bool _transfer(busio_spi_obj_t *self,
|
|||||||
dma_channel_unclaim(chan_tx);
|
dma_channel_unclaim(chan_tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!use_dma && !mp_hal_is_interrupted()) {
|
if (!use_dma) {
|
||||||
// Use software for small transfers, or if couldn't claim two DMA channels
|
// Use software for small transfers, or if couldn't claim two DMA channels
|
||||||
// Never have more transfers in flight than will fit into the RX FIFO,
|
// Never have more transfers in flight than will fit into the RX FIFO,
|
||||||
// else FIFO will overflow if this code is heavily interrupted.
|
// else FIFO will overflow if this code is heavily interrupted.
|
||||||
@ -241,7 +232,7 @@ static bool _transfer(busio_spi_obj_t *self,
|
|||||||
size_t rx_remaining = len;
|
size_t rx_remaining = len;
|
||||||
size_t tx_remaining = len;
|
size_t tx_remaining = len;
|
||||||
|
|
||||||
while (!mp_hal_is_interrupted() && (rx_remaining || tx_remaining)) {
|
while (rx_remaining || tx_remaining) {
|
||||||
if (tx_remaining && spi_is_writable(self->peripheral) && rx_remaining - tx_remaining < fifo_depth) {
|
if (tx_remaining && spi_is_writable(self->peripheral) && rx_remaining - tx_remaining < fifo_depth) {
|
||||||
spi_get_hw(self->peripheral)->dr = (uint32_t)*data_out;
|
spi_get_hw(self->peripheral)->dr = (uint32_t)*data_out;
|
||||||
// Increment only if the buffer is the transfer length. It's 1 otherwise.
|
// Increment only if the buffer is the transfer length. It's 1 otherwise.
|
||||||
|
@ -654,15 +654,6 @@ static bool _transfer(rp2pio_statemachine_obj_t *self,
|
|||||||
(tx && dma_channel_is_busy(chan_tx))) {
|
(tx && dma_channel_is_busy(chan_tx))) {
|
||||||
// TODO: We should idle here until we get a DMA interrupt or something else.
|
// TODO: We should idle here until we get a DMA interrupt or something else.
|
||||||
RUN_BACKGROUND_TASKS;
|
RUN_BACKGROUND_TASKS;
|
||||||
if (mp_hal_is_interrupted()) {
|
|
||||||
if (rx && dma_channel_is_busy(chan_rx)) {
|
|
||||||
dma_channel_abort(chan_rx);
|
|
||||||
}
|
|
||||||
if (tx && dma_channel_is_busy(chan_tx)) {
|
|
||||||
dma_channel_abort(chan_tx);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Clear the stall bit so we can detect when the state machine is done transmitting.
|
// Clear the stall bit so we can detect when the state machine is done transmitting.
|
||||||
self->pio->fdebug = stall_mask;
|
self->pio->fdebug = stall_mask;
|
||||||
@ -677,7 +668,7 @@ static bool _transfer(rp2pio_statemachine_obj_t *self,
|
|||||||
dma_channel_unclaim(chan_tx);
|
dma_channel_unclaim(chan_tx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!use_dma && !mp_hal_is_interrupted()) {
|
if (!use_dma) {
|
||||||
// Use software for small transfers, or if couldn't claim two DMA channels
|
// Use software for small transfers, or if couldn't claim two DMA channels
|
||||||
size_t rx_remaining = in_len / in_stride_in_bytes;
|
size_t rx_remaining = in_len / in_stride_in_bytes;
|
||||||
size_t tx_remaining = out_len / out_stride_in_bytes;
|
size_t tx_remaining = out_len / out_stride_in_bytes;
|
||||||
@ -706,9 +697,6 @@ static bool _transfer(rp2pio_statemachine_obj_t *self,
|
|||||||
--rx_remaining;
|
--rx_remaining;
|
||||||
}
|
}
|
||||||
RUN_BACKGROUND_TASKS;
|
RUN_BACKGROUND_TASKS;
|
||||||
if (mp_hal_is_interrupted()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Clear the stall bit so we can detect when the state machine is done transmitting.
|
// Clear the stall bit so we can detect when the state machine is done transmitting.
|
||||||
self->pio->fdebug = stall_mask;
|
self->pio->fdebug = stall_mask;
|
||||||
@ -719,9 +707,6 @@ static bool _transfer(rp2pio_statemachine_obj_t *self,
|
|||||||
while (!pio_sm_is_tx_fifo_empty(self->pio, self->state_machine) ||
|
while (!pio_sm_is_tx_fifo_empty(self->pio, self->state_machine) ||
|
||||||
(self->wait_for_txstall && (self->pio->fdebug & stall_mask) == 0)) {
|
(self->wait_for_txstall && (self->pio->fdebug & stall_mask) == 0)) {
|
||||||
RUN_BACKGROUND_TASKS;
|
RUN_BACKGROUND_TASKS;
|
||||||
if (mp_hal_is_interrupted()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user