nrf/drivers/usb: Probe for interrupt char in USB CDC task.
And ensure that the input queue is empty when scheduling the interrupt.
This commit is contained in:
parent
30c7f1790b
commit
60539ea162
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue