nrf/drivers/usb: Probe for interrupt char in USB CDC task.

And ensure that the input queue is empty when scheduling the interrupt.
pull/8849/head
robert-hh 2022-07-07 21:19:28 +02:00 zatwierdzone przez Damien George
rodzic 30c7f1790b
commit 60539ea162
3 zmienionych plików z 12 dodań i 2 usunięć

Wyświetl plik

@ -193,9 +193,9 @@ STATIC void gatts_event_handler(mp_obj_t self_in, uint16_t event_id, uint16_t at
for (uint16_t i = 0; i < length; i++) {
#if MICROPY_KBD_EXCEPTION
if (data[i] == mp_interrupt_char) {
mp_sched_keyboard_interrupt();
m_rx_ring_buffer.start = 0;
m_rx_ring_buffer.end = 0;
mp_sched_keyboard_interrupt();
} else
#endif
{

Wyświetl plik

@ -35,6 +35,8 @@
#include "nrfx_uart.h"
#include "py/ringbuf.h"
#include "py/stream.h"
#include "py/runtime.h"
#include "shared/runtime/interrupt_char.h"
#ifdef BLUETOOTH_SD
#include "nrf_sdm.h"
@ -127,7 +129,13 @@ static void cdc_task(void)
int c;
uint32_t count = tud_cdc_read(&c, 1);
(void)count;
ringbuf_put((ringbuf_t*)&rx_ringbuf, c);
if (c == mp_interrupt_char) {
rx_ringbuf.iget = 0;
rx_ringbuf.iput = 0;
mp_sched_keyboard_interrupt();
} else {
ringbuf_put((ringbuf_t*)&rx_ringbuf, c);
}
}
int chars = 0;

Wyświetl plik

@ -128,6 +128,8 @@ STATIC void uart_event_handler(nrfx_uart_event_t const *p_event, void *p_context
nrfx_uart_rx(self->p_uart, &self->buf->rx_buf[0], 1);
#if !MICROPY_PY_BLE_NUS && MICROPY_KBD_EXCEPTION
if (chr == mp_interrupt_char) {
self->buf->rx_ringbuf.iget = 0;
self->buf->rx_ringbuf.iput = 0;
mp_sched_keyboard_interrupt();
} else
#endif