ports: In machine_i2s.c, rename uasyncio to asyncio.
Mostly updates comments, but also renames the UASYNCIO enum value to ASYNCIO. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
committed by
Damien George
parent
d975bb1f27
commit
7979a4d267
@@ -60,9 +60,9 @@
|
||||
// - non-blocking mode is enabled when a callback is set with the irq() method
|
||||
// - the DMA callback is used to implement the asynchronous background operations
|
||||
//
|
||||
// Mode3: Uasyncio
|
||||
// Mode3: Asyncio
|
||||
// - implements the stream protocol
|
||||
// - uasyncio mode is enabled when the ioctl() function is called
|
||||
// - asyncio mode is enabled when the ioctl() function is called
|
||||
// - the state of the internal ring buffer is used to detect that I2S samples can be read or written
|
||||
//
|
||||
// The samples contained in the app buffer supplied for the readinto() and write() methods have the following convention:
|
||||
@@ -122,7 +122,7 @@ typedef enum {
|
||||
typedef enum {
|
||||
BLOCKING,
|
||||
NON_BLOCKING,
|
||||
UASYNCIO
|
||||
ASYNCIO
|
||||
} io_mode_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -441,7 +441,7 @@ STATIC uint32_t fill_appbuf_from_ringbuf(machine_i2s_obj_t *self, mp_buffer_info
|
||||
|
||||
// copy audio samples from the ring buffer to the app buffer
|
||||
// loop, copying samples until the app buffer is filled
|
||||
// For uasyncio mode, the loop will make an early exit if the ring buffer becomes empty
|
||||
// For asyncio mode, the loop will make an early exit if the ring buffer becomes empty
|
||||
// Example:
|
||||
// a MicroPython I2S object is configured for 16-bit mono (2 bytes per audio sample).
|
||||
// For every frame coming from the ring buffer (8 bytes), 2 bytes are "cherry picked" and
|
||||
@@ -467,7 +467,7 @@ STATIC uint32_t fill_appbuf_from_ringbuf(machine_i2s_obj_t *self, mp_buffer_info
|
||||
;
|
||||
}
|
||||
num_bytes_copied_to_appbuf++;
|
||||
} else if (self->io_mode == UASYNCIO) {
|
||||
} else if (self->io_mode == ASYNCIO) {
|
||||
if (ringbuf_pop(&self->ring_buffer, app_p + r_to_a_mapping) == false) {
|
||||
// ring buffer is empty, exit
|
||||
goto exit;
|
||||
@@ -484,7 +484,7 @@ STATIC uint32_t fill_appbuf_from_ringbuf(machine_i2s_obj_t *self, mp_buffer_info
|
||||
while (ringbuf_pop(&self->ring_buffer, &discard_byte) == false) {
|
||||
;
|
||||
}
|
||||
} else if (self->io_mode == UASYNCIO) {
|
||||
} else if (self->io_mode == ASYNCIO) {
|
||||
if (ringbuf_pop(&self->ring_buffer, &discard_byte) == false) {
|
||||
// ring buffer is empty, exit
|
||||
goto exit;
|
||||
@@ -547,7 +547,7 @@ STATIC uint32_t copy_appbuf_to_ringbuf(machine_i2s_obj_t *self, mp_buffer_info_t
|
||||
|
||||
// copy audio samples from the app buffer to the ring buffer
|
||||
// loop, reading samples until the app buffer is emptied
|
||||
// for uasyncio mode, the loop will make an early exit if the ring buffer becomes full
|
||||
// for asyncio mode, the loop will make an early exit if the ring buffer becomes full
|
||||
|
||||
uint32_t a_index = 0;
|
||||
|
||||
@@ -558,7 +558,7 @@ STATIC uint32_t copy_appbuf_to_ringbuf(machine_i2s_obj_t *self, mp_buffer_info_t
|
||||
;
|
||||
}
|
||||
a_index++;
|
||||
} else if (self->io_mode == UASYNCIO) {
|
||||
} else if (self->io_mode == ASYNCIO) {
|
||||
if (ringbuf_push(&self->ring_buffer, ((uint8_t *)appbuf->buf)[a_index]) == false) {
|
||||
// ring buffer is full, exit
|
||||
break;
|
||||
@@ -1185,7 +1185,7 @@ STATIC mp_uint_t machine_i2s_stream_read(mp_obj_t self_in, void *buf_in, mp_uint
|
||||
self->non_blocking_descriptor.index = 0;
|
||||
self->non_blocking_descriptor.copy_in_progress = true;
|
||||
return size;
|
||||
} else { // blocking or uasyncio mode
|
||||
} else { // blocking or asyncio mode
|
||||
mp_buffer_info_t appbuf;
|
||||
appbuf.buf = (void *)buf_in;
|
||||
appbuf.len = size;
|
||||
@@ -1212,7 +1212,7 @@ STATIC mp_uint_t machine_i2s_stream_write(mp_obj_t self_in, const void *buf_in,
|
||||
self->non_blocking_descriptor.index = 0;
|
||||
self->non_blocking_descriptor.copy_in_progress = true;
|
||||
return size;
|
||||
} else { // blocking or uasyncio mode
|
||||
} else { // blocking or asyncio mode
|
||||
mp_buffer_info_t appbuf;
|
||||
appbuf.buf = (void *)buf_in;
|
||||
appbuf.len = size;
|
||||
@@ -1225,7 +1225,7 @@ STATIC mp_uint_t machine_i2s_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_
|
||||
machine_i2s_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
mp_uint_t ret;
|
||||
uintptr_t flags = arg;
|
||||
self->io_mode = UASYNCIO; // a call to ioctl() is an indication that uasyncio is being used
|
||||
self->io_mode = ASYNCIO; // a call to ioctl() is an indication that asyncio is being used
|
||||
|
||||
if (request == MP_STREAM_POLL) {
|
||||
ret = 0;
|
||||
|
||||
Reference in New Issue
Block a user