samd/machine_uart: Fix IRQ flag setting and clearing.

Clearing the DRE flag for the transmit interrupt at the end of a
uart.write() also cleared the RXC flag disabling the receive interrupt.

This commit also changes the flag set/clear mechanism in the driver for SPI
as well, even if it did not cause a problem there.  But at least it saves a
few bytes of code.
pull/10021/head
robert-hh 2022-11-19 12:43:34 +01:00 zatwierdzone przez Damien George
rodzic fcd1788937
commit 4199f986ad
2 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -296,7 +296,7 @@ STATIC void machine_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8
if (self->miso == 0xff) {
mp_raise_ValueError(MP_ERROR_TEXT("read is not enabled"));
}
spi->SPI.INTENSET.bit.RXC = 1;
spi->SPI.INTENSET.reg = SERCOM_SPI_INTENSET_RXC;
self->dest = dest;
self->rxlen = len;
}
@ -317,7 +317,7 @@ STATIC void machine_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8
timeout--;
MICROPY_EVENT_POLL_HOOK
}
spi->SPI.INTENCLR.bit.RXC = 1;
spi->SPI.INTENCLR.reg = SERCOM_SPI_INTENCLR_RXC;
} else {
// Wait for the data being shifted out.
while (!spi->SPI.INTFLAG.bit.TXC) {

Wyświetl plik

@ -95,7 +95,7 @@ void common_uart_irq_handler(int uart_id) {
uart->USART.DATA.bit.DATA = ringbuf_get(&self->write_buffer);
} else {
// Stop the interrupt if there is no more data
uart->USART.INTENCLR.bit.DRE = 1;
uart->USART.INTENCLR.reg = SERCOM_USART_INTENCLR_DRE;
}
#endif
} else {
@ -291,7 +291,7 @@ STATIC mp_obj_t machine_uart_init_helper(machine_uart_obj_t *self, size_t n_args
sercom_register_irq(self->id, &common_uart_irq_handler);
// Enable RXC interrupt
uart->USART.INTENSET.bit.RXC = 1;
uart->USART.INTENSET.reg = SERCOM_USART_INTENSET_RXC;
#if defined(MCU_SAMD21)
NVIC_EnableIRQ(SERCOM0_IRQn + self->id);
#elif defined(MCU_SAMD51)
@ -452,7 +452,7 @@ STATIC mp_uint_t machine_uart_read(mp_obj_t self_in, void *buf_in, mp_uint_t siz
MICROPY_EVENT_POLL_HOOK
}
*dest++ = ringbuf_get(&(self->read_buffer));
t = mp_hal_ticks_ms() + timeout_char;
t = mp_hal_ticks_ms_64() + timeout_char;
}
return size;
}
@ -481,7 +481,7 @@ STATIC mp_uint_t machine_uart_write(mp_obj_t self_in, const void *buf_in, mp_uin
}
ringbuf_put(&(self->write_buffer), *src++);
i++;
uart->USART.INTENSET.bit.DRE = 1; // kick off the IRQ
uart->USART.INTENSET.reg = SERCOM_USART_INTENSET_DRE; // kick off the IRQ
}
#else