Skip to content

Commit 7979a4d

Browse files
jimmodpgeorge
authored andcommitted
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 <[email protected]>
1 parent d975bb1 commit 7979a4d

File tree

4 files changed

+45
-45
lines changed

4 files changed

+45
-45
lines changed

ports/esp32/machine_i2s.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@
6161
// - a FreeRTOS task is created to implement the asynchronous background operations
6262
// - a FreeRTOS queue is used to transfer the supplied buffer to the background task
6363
//
64-
// Mode3: Uasyncio
64+
// Mode3: Asyncio
6565
// - implements the stream protocol
66-
// - uasyncio mode is enabled when the ioctl() function is called
66+
// - asyncio mode is enabled when the ioctl() function is called
6767
// - the I2S event queue is used to detect that I2S samples can be read or written from/to DMA memory
6868
//
6969
// The samples contained in the app buffer supplied for the readinto() and write() methods have the following convention:
@@ -102,7 +102,7 @@ typedef enum {
102102
typedef enum {
103103
BLOCKING,
104104
NON_BLOCKING,
105-
UASYNCIO
105+
ASYNCIO
106106
} io_mode_t;
107107

108108
typedef enum {
@@ -240,7 +240,7 @@ STATIC uint32_t fill_appbuf_from_dma(machine_i2s_obj_t *self, mp_buffer_info_t *
240240
// copy audio samples from DMA memory to the app buffer
241241
// audio samples are read from DMA memory in chunks
242242
// loop, reading and copying chunks until the app buffer is filled
243-
// For uasyncio mode, the loop will make an early exit if DMA memory becomes empty
243+
// For asyncio mode, the loop will make an early exit if DMA memory becomes empty
244244
// Example:
245245
// a MicroPython I2S object is configured for 16-bit mono (2 bytes per audio sample).
246246
// For every frame coming from DMA (8 bytes), 2 bytes are "cherry picked" and
@@ -257,7 +257,7 @@ STATIC uint32_t fill_appbuf_from_dma(machine_i2s_obj_t *self, mp_buffer_info_t *
257257
size_t num_bytes_received_from_dma = 0;
258258

259259
TickType_t delay;
260-
if (self->io_mode == UASYNCIO) {
260+
if (self->io_mode == ASYNCIO) {
261261
delay = 0; // stop i2s_read() operation if DMA memory becomes empty
262262
} else {
263263
delay = portMAX_DELAY; // block until supplied buffer is filled
@@ -307,7 +307,7 @@ STATIC uint32_t fill_appbuf_from_dma(machine_i2s_obj_t *self, mp_buffer_info_t *
307307

308308
num_bytes_needed_from_dma -= num_bytes_received_from_dma;
309309

310-
if ((self->io_mode == UASYNCIO) && (num_bytes_received_from_dma < num_bytes_requested_from_dma)) {
310+
if ((self->io_mode == ASYNCIO) && (num_bytes_received_from_dma < num_bytes_requested_from_dma)) {
311311
// Unable to fill the entire app buffer from DMA memory. This indicates all DMA RX buffers are empty.
312312
// Clear the I2S event queue so ioctl() indicates that the I2S object cannot currently
313313
// supply more audio samples
@@ -327,7 +327,7 @@ STATIC size_t copy_appbuf_to_dma(machine_i2s_obj_t *self, mp_buffer_info_t *appb
327327
size_t num_bytes_written = 0;
328328

329329
TickType_t delay;
330-
if (self->io_mode == UASYNCIO) {
330+
if (self->io_mode == ASYNCIO) {
331331
delay = 0; // stop i2s_write() operation if DMA memory becomes full
332332
} else {
333333
delay = portMAX_DELAY; // block until supplied buffer is emptied
@@ -345,14 +345,14 @@ STATIC size_t copy_appbuf_to_dma(machine_i2s_obj_t *self, mp_buffer_info_t *appb
345345

346346
check_esp_err(ret);
347347

348-
if ((self->io_mode == UASYNCIO) && (num_bytes_written < appbuf->len)) {
348+
if ((self->io_mode == ASYNCIO) && (num_bytes_written < appbuf->len)) {
349349
// Unable to empty the entire app buffer into DMA memory. This indicates all DMA TX buffers are full.
350350
// Clear the I2S event queue so ioctl() indicates that the I2S object cannot currently
351351
// accept more audio samples
352352
xQueueReset(self->i2s_event_queue);
353353

354354
// Undo the swap transformation as the buffer has not been completely emptied.
355-
// The uasyncio stream writer will use the same buffer in a future write call.
355+
// The asyncio stream writer will use the same buffer in a future write call.
356356
if ((self->bits == I2S_BITS_PER_SAMPLE_32BIT) && (self->format == STEREO)) {
357357
swap_32_bit_stereo_channels(appbuf);
358358
}
@@ -729,7 +729,7 @@ STATIC mp_uint_t machine_i2s_stream_read(mp_obj_t self_in, void *buf_in, mp_uint
729729
// send the descriptor to the task that handles non-blocking mode
730730
xQueueSend(self->non_blocking_mode_queue, &descriptor, 0);
731731
return size;
732-
} else { // blocking or uasyncio mode
732+
} else { // blocking or asyncio mode
733733
mp_buffer_info_t appbuf;
734734
appbuf.buf = (void *)buf_in;
735735
appbuf.len = size;
@@ -759,7 +759,7 @@ STATIC mp_uint_t machine_i2s_stream_write(mp_obj_t self_in, const void *buf_in,
759759
// send the descriptor to the task that handles non-blocking mode
760760
xQueueSend(self->non_blocking_mode_queue, &descriptor, 0);
761761
return size;
762-
} else { // blocking or uasyncio mode
762+
} else { // blocking or asyncio mode
763763
mp_buffer_info_t appbuf;
764764
appbuf.buf = (void *)buf_in;
765765
appbuf.len = size;
@@ -772,7 +772,7 @@ STATIC mp_uint_t machine_i2s_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_
772772
machine_i2s_obj_t *self = MP_OBJ_TO_PTR(self_in);
773773
mp_uint_t ret;
774774
mp_uint_t flags = arg;
775-
self->io_mode = UASYNCIO; // a call to ioctl() is an indication that uasyncio is being used
775+
self->io_mode = ASYNCIO; // a call to ioctl() is an indication that asyncio is being used
776776

777777
if (request == MP_STREAM_POLL) {
778778
ret = 0;

ports/mimxrt/machine_i2s.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
// - non-blocking mode is enabled when a callback is set with the irq() method
6161
// - the DMA callback is used to implement the asynchronous background operations
6262
//
63-
// Mode3: Uasyncio
63+
// Mode3: Asyncio
6464
// - implements the stream protocol
65-
// - uasyncio mode is enabled when the ioctl() function is called
65+
// - asyncio mode is enabled when the ioctl() function is called
6666
// - the state of the internal ring buffer is used to detect that I2S samples can be read or written
6767
//
6868
// The samples contained in the app buffer supplied for the readinto() and write() methods have the following convention:
@@ -122,7 +122,7 @@ typedef enum {
122122
typedef enum {
123123
BLOCKING,
124124
NON_BLOCKING,
125-
UASYNCIO
125+
ASYNCIO
126126
} io_mode_t;
127127

128128
typedef enum {
@@ -441,7 +441,7 @@ STATIC uint32_t fill_appbuf_from_ringbuf(machine_i2s_obj_t *self, mp_buffer_info
441441

442442
// copy audio samples from the ring buffer to the app buffer
443443
// loop, copying samples until the app buffer is filled
444-
// For uasyncio mode, the loop will make an early exit if the ring buffer becomes empty
444+
// For asyncio mode, the loop will make an early exit if the ring buffer becomes empty
445445
// Example:
446446
// a MicroPython I2S object is configured for 16-bit mono (2 bytes per audio sample).
447447
// 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
467467
;
468468
}
469469
num_bytes_copied_to_appbuf++;
470-
} else if (self->io_mode == UASYNCIO) {
470+
} else if (self->io_mode == ASYNCIO) {
471471
if (ringbuf_pop(&self->ring_buffer, app_p + r_to_a_mapping) == false) {
472472
// ring buffer is empty, exit
473473
goto exit;
@@ -484,7 +484,7 @@ STATIC uint32_t fill_appbuf_from_ringbuf(machine_i2s_obj_t *self, mp_buffer_info
484484
while (ringbuf_pop(&self->ring_buffer, &discard_byte) == false) {
485485
;
486486
}
487-
} else if (self->io_mode == UASYNCIO) {
487+
} else if (self->io_mode == ASYNCIO) {
488488
if (ringbuf_pop(&self->ring_buffer, &discard_byte) == false) {
489489
// ring buffer is empty, exit
490490
goto exit;
@@ -547,7 +547,7 @@ STATIC uint32_t copy_appbuf_to_ringbuf(machine_i2s_obj_t *self, mp_buffer_info_t
547547

548548
// copy audio samples from the app buffer to the ring buffer
549549
// loop, reading samples until the app buffer is emptied
550-
// for uasyncio mode, the loop will make an early exit if the ring buffer becomes full
550+
// for asyncio mode, the loop will make an early exit if the ring buffer becomes full
551551

552552
uint32_t a_index = 0;
553553

@@ -558,7 +558,7 @@ STATIC uint32_t copy_appbuf_to_ringbuf(machine_i2s_obj_t *self, mp_buffer_info_t
558558
;
559559
}
560560
a_index++;
561-
} else if (self->io_mode == UASYNCIO) {
561+
} else if (self->io_mode == ASYNCIO) {
562562
if (ringbuf_push(&self->ring_buffer, ((uint8_t *)appbuf->buf)[a_index]) == false) {
563563
// ring buffer is full, exit
564564
break;
@@ -1185,7 +1185,7 @@ STATIC mp_uint_t machine_i2s_stream_read(mp_obj_t self_in, void *buf_in, mp_uint
11851185
self->non_blocking_descriptor.index = 0;
11861186
self->non_blocking_descriptor.copy_in_progress = true;
11871187
return size;
1188-
} else { // blocking or uasyncio mode
1188+
} else { // blocking or asyncio mode
11891189
mp_buffer_info_t appbuf;
11901190
appbuf.buf = (void *)buf_in;
11911191
appbuf.len = size;
@@ -1212,7 +1212,7 @@ STATIC mp_uint_t machine_i2s_stream_write(mp_obj_t self_in, const void *buf_in,
12121212
self->non_blocking_descriptor.index = 0;
12131213
self->non_blocking_descriptor.copy_in_progress = true;
12141214
return size;
1215-
} else { // blocking or uasyncio mode
1215+
} else { // blocking or asyncio mode
12161216
mp_buffer_info_t appbuf;
12171217
appbuf.buf = (void *)buf_in;
12181218
appbuf.len = size;
@@ -1225,7 +1225,7 @@ STATIC mp_uint_t machine_i2s_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_
12251225
machine_i2s_obj_t *self = MP_OBJ_TO_PTR(self_in);
12261226
mp_uint_t ret;
12271227
uintptr_t flags = arg;
1228-
self->io_mode = UASYNCIO; // a call to ioctl() is an indication that uasyncio is being used
1228+
self->io_mode = ASYNCIO; // a call to ioctl() is an indication that asyncio is being used
12291229

12301230
if (request == MP_STREAM_POLL) {
12311231
ret = 0;

ports/rp2/machine_i2s.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
// - non-blocking mode is enabled when a callback is set with the irq() method
5858
// - the DMA IRQ handler is used to implement the asynchronous background operations
5959
//
60-
// Mode3: Uasyncio
60+
// Mode3: Asyncio
6161
// - implements the stream protocol
62-
// - uasyncio mode is enabled when the ioctl() function is called
62+
// - asyncio mode is enabled when the ioctl() function is called
6363
// - the state of the internal ring buffer is used to detect that I2S samples can be read or written
6464
//
6565
// The samples contained in the app buffer supplied for the readinto() and write() methods have the following convention:
@@ -112,7 +112,7 @@ typedef enum {
112112
typedef enum {
113113
BLOCKING,
114114
NON_BLOCKING,
115-
UASYNCIO
115+
ASYNCIO
116116
} io_mode_t;
117117

118118
typedef enum {
@@ -307,7 +307,7 @@ STATIC uint32_t fill_appbuf_from_ringbuf(machine_i2s_obj_t *self, mp_buffer_info
307307

308308
// copy audio samples from the ring buffer to the app buffer
309309
// loop, copying samples until the app buffer is filled
310-
// For uasyncio mode, the loop will make an early exit if the ring buffer becomes empty
310+
// For asyncio mode, the loop will make an early exit if the ring buffer becomes empty
311311
// Example:
312312
// a MicroPython I2S object is configured for 16-bit mono (2 bytes per audio sample).
313313
// For every frame coming from the ring buffer (8 bytes), 2 bytes are "cherry picked" and
@@ -333,7 +333,7 @@ STATIC uint32_t fill_appbuf_from_ringbuf(machine_i2s_obj_t *self, mp_buffer_info
333333
;
334334
}
335335
num_bytes_copied_to_appbuf++;
336-
} else if (self->io_mode == UASYNCIO) {
336+
} else if (self->io_mode == ASYNCIO) {
337337
if (ringbuf_pop(&self->ring_buffer, app_p + r_to_a_mapping) == false) {
338338
// ring buffer is empty, exit
339339
goto exit;
@@ -350,7 +350,7 @@ STATIC uint32_t fill_appbuf_from_ringbuf(machine_i2s_obj_t *self, mp_buffer_info
350350
while (ringbuf_pop(&self->ring_buffer, &discard_byte) == false) {
351351
;
352352
}
353-
} else if (self->io_mode == UASYNCIO) {
353+
} else if (self->io_mode == ASYNCIO) {
354354
if (ringbuf_pop(&self->ring_buffer, &discard_byte) == false) {
355355
// ring buffer is empty, exit
356356
goto exit;
@@ -413,7 +413,7 @@ STATIC uint32_t copy_appbuf_to_ringbuf(machine_i2s_obj_t *self, mp_buffer_info_t
413413

414414
// copy audio samples from the app buffer to the ring buffer
415415
// loop, reading samples until the app buffer is emptied
416-
// for uasyncio mode, the loop will make an early exit if the ring buffer becomes full
416+
// for asyncio mode, the loop will make an early exit if the ring buffer becomes full
417417

418418
uint32_t a_index = 0;
419419

@@ -424,7 +424,7 @@ STATIC uint32_t copy_appbuf_to_ringbuf(machine_i2s_obj_t *self, mp_buffer_info_t
424424
;
425425
}
426426
a_index++;
427-
} else if (self->io_mode == UASYNCIO) {
427+
} else if (self->io_mode == ASYNCIO) {
428428
if (ringbuf_push(&self->ring_buffer, ((uint8_t *)appbuf->buf)[a_index]) == false) {
429429
// ring buffer is full, exit
430430
break;
@@ -1056,7 +1056,7 @@ STATIC mp_uint_t machine_i2s_stream_read(mp_obj_t self_in, void *buf_in, mp_uint
10561056
self->non_blocking_descriptor.index = 0;
10571057
self->non_blocking_descriptor.copy_in_progress = true;
10581058
return size;
1059-
} else { // blocking or uasyncio mode
1059+
} else { // blocking or asyncio mode
10601060
mp_buffer_info_t appbuf;
10611061
appbuf.buf = (void *)buf_in;
10621062
appbuf.len = size;
@@ -1083,7 +1083,7 @@ STATIC mp_uint_t machine_i2s_stream_write(mp_obj_t self_in, const void *buf_in,
10831083
self->non_blocking_descriptor.index = 0;
10841084
self->non_blocking_descriptor.copy_in_progress = true;
10851085
return size;
1086-
} else { // blocking or uasyncio mode
1086+
} else { // blocking or asyncio mode
10871087
mp_buffer_info_t appbuf;
10881088
appbuf.buf = (void *)buf_in;
10891089
appbuf.len = size;
@@ -1096,7 +1096,7 @@ STATIC mp_uint_t machine_i2s_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_
10961096
machine_i2s_obj_t *self = MP_OBJ_TO_PTR(self_in);
10971097
mp_uint_t ret;
10981098
uintptr_t flags = arg;
1099-
self->io_mode = UASYNCIO; // a call to ioctl() is an indication that uasyncio is being used
1099+
self->io_mode = ASYNCIO; // a call to ioctl() is an indication that asyncio is being used
11001100

11011101
if (request == MP_STREAM_POLL) {
11021102
ret = 0;

ports/stm32/machine_i2s.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@
5555
// - non-blocking mode is enabled when a callback is set with the irq() method
5656
// - the DMA callbacks (1/2 complete and complete) are used to implement the asynchronous background operations
5757
//
58-
// Mode3: Uasyncio
58+
// Mode3: Asyncio
5959
// - implements the stream protocol
60-
// - uasyncio mode is enabled when the ioctl() function is called
60+
// - asyncio mode is enabled when the ioctl() function is called
6161
// - the state of the internal ring buffer is used to detect that I2S samples can be read or written
6262
//
6363
// The samples contained in the app buffer supplied for the readinto() and write() methods have the following convention:
@@ -104,7 +104,7 @@ typedef enum {
104104
typedef enum {
105105
BLOCKING,
106106
NON_BLOCKING,
107-
UASYNCIO
107+
ASYNCIO
108108
} io_mode_t;
109109

110110
typedef enum {
@@ -287,7 +287,7 @@ STATIC uint32_t fill_appbuf_from_ringbuf(machine_i2s_obj_t *self, mp_buffer_info
287287

288288
// copy audio samples from the ring buffer to the app buffer
289289
// loop, copying samples until the app buffer is filled
290-
// For uasyncio mode, the loop will make an early exit if the ring buffer becomes empty
290+
// For asyncio mode, the loop will make an early exit if the ring buffer becomes empty
291291
// Example:
292292
// a MicroPython I2S object is configured for 16-bit mono (2 bytes per audio sample).
293293
// For every frame coming from the ring buffer (8 bytes), 2 bytes are "cherry picked" and
@@ -313,7 +313,7 @@ STATIC uint32_t fill_appbuf_from_ringbuf(machine_i2s_obj_t *self, mp_buffer_info
313313
;
314314
}
315315
num_bytes_copied_to_appbuf++;
316-
} else if (self->io_mode == UASYNCIO) {
316+
} else if (self->io_mode == ASYNCIO) {
317317
if (ringbuf_pop(&self->ring_buffer, app_p + r_to_a_mapping) == false) {
318318
// ring buffer is empty, exit
319319
goto exit;
@@ -330,7 +330,7 @@ STATIC uint32_t fill_appbuf_from_ringbuf(machine_i2s_obj_t *self, mp_buffer_info
330330
while (ringbuf_pop(&self->ring_buffer, &discard_byte) == false) {
331331
;
332332
}
333-
} else if (self->io_mode == UASYNCIO) {
333+
} else if (self->io_mode == ASYNCIO) {
334334
if (ringbuf_pop(&self->ring_buffer, &discard_byte) == false) {
335335
// ring buffer is empty, exit
336336
goto exit;
@@ -393,7 +393,7 @@ STATIC uint32_t copy_appbuf_to_ringbuf(machine_i2s_obj_t *self, mp_buffer_info_t
393393

394394
// copy audio samples from the app buffer to the ring buffer
395395
// loop, reading samples until the app buffer is emptied
396-
// for uasyncio mode, the loop will make an early exit if the ring buffer becomes full
396+
// for asyncio mode, the loop will make an early exit if the ring buffer becomes full
397397

398398
uint32_t a_index = 0;
399399

@@ -404,7 +404,7 @@ STATIC uint32_t copy_appbuf_to_ringbuf(machine_i2s_obj_t *self, mp_buffer_info_t
404404
;
405405
}
406406
a_index++;
407-
} else if (self->io_mode == UASYNCIO) {
407+
} else if (self->io_mode == ASYNCIO) {
408408
if (ringbuf_push(&self->ring_buffer, ((uint8_t *)appbuf->buf)[a_index]) == false) {
409409
// ring buffer is full, exit
410410
break;
@@ -1033,7 +1033,7 @@ STATIC mp_uint_t machine_i2s_stream_read(mp_obj_t self_in, void *buf_in, mp_uint
10331033
self->non_blocking_descriptor.index = 0;
10341034
self->non_blocking_descriptor.copy_in_progress = true;
10351035
return size;
1036-
} else { // blocking or uasyncio mode
1036+
} else { // blocking or asyncio mode
10371037
mp_buffer_info_t appbuf;
10381038
appbuf.buf = (void *)buf_in;
10391039
appbuf.len = size;
@@ -1060,7 +1060,7 @@ STATIC mp_uint_t machine_i2s_stream_write(mp_obj_t self_in, const void *buf_in,
10601060
self->non_blocking_descriptor.index = 0;
10611061
self->non_blocking_descriptor.copy_in_progress = true;
10621062
return size;
1063-
} else { // blocking or uasyncio mode
1063+
} else { // blocking or asyncio mode
10641064
mp_buffer_info_t appbuf;
10651065
appbuf.buf = (void *)buf_in;
10661066
appbuf.len = size;
@@ -1073,7 +1073,7 @@ STATIC mp_uint_t machine_i2s_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_
10731073
machine_i2s_obj_t *self = MP_OBJ_TO_PTR(self_in);
10741074
mp_uint_t ret;
10751075
uintptr_t flags = arg;
1076-
self->io_mode = UASYNCIO; // a call to ioctl() is an indication that uasyncio is being used
1076+
self->io_mode = ASYNCIO; // a call to ioctl() is an indication that asyncio is being used
10771077

10781078
if (request == MP_STREAM_POLL) {
10791079
ret = 0;

0 commit comments

Comments
 (0)