diff options
author | robert-hh <robert@hammelrath.com> | 2022-11-19 12:43:34 +0100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-12-14 12:42:34 +1100 |
commit | 4199f986ad7873f51aee5e9e51bffead775b06a1 (patch) | |
tree | aa2d7abd0ba63789a06671486336be884d4240b1 | |
parent | fcd1788937c267da7eddea1925391b906a49e9e6 (diff) |
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.
-rw-r--r-- | ports/samd/machine_spi.c | 4 | ||||
-rw-r--r-- | ports/samd/machine_uart.c | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/ports/samd/machine_spi.c b/ports/samd/machine_spi.c index d2cdf2cd4..bbd7031e9 100644 --- a/ports/samd/machine_spi.c +++ b/ports/samd/machine_spi.c @@ -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) { diff --git a/ports/samd/machine_uart.c b/ports/samd/machine_uart.c index 4b8fa3b60..eb1415789 100644 --- a/ports/samd/machine_uart.c +++ b/ports/samd/machine_uart.c @@ -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 |