37
37
#include "fsl_edma.h"
38
38
#include "fsl_sai.h"
39
39
40
- #if MICROPY_PY_MACHINE_I2S
41
- // The I2S module has 3 modes of operation:
42
- //
43
- // Mode1: Blocking
44
- // - readinto() and write() methods block until the supplied buffer is filled (read) or emptied (write)
45
- // - this is the default mode of operation
46
- //
47
- // Mode2: Non-Blocking
48
- // - readinto() and write() methods return immediately
49
- // - buffer filling and emptying happens asynchronously to the main MicroPython task
50
- // - a callback function is called when the supplied buffer has been filled (read) or emptied (write)
51
- // - non-blocking mode is enabled when a callback is set with the irq() method
52
- // - the DMA callback is used to implement the asynchronous background operations
53
- //
54
- // Mode3: Asyncio
55
- // - implements the stream protocol
56
- // - asyncio mode is enabled when the ioctl() function is called
57
- // - the state of the internal ring buffer is used to detect that I2S samples can be read or written
58
- //
59
- // The samples contained in the app buffer supplied for the readinto() and write() methods have the following convention:
60
- // Mono: little endian format
61
- // Stereo: little endian format, left channel first
62
- //
63
- // I2S terms:
64
- // "frame": consists of two audio samples (Left audio sample + Right audio sample)
65
- //
66
- // Misc:
67
- // - for Mono configuration:
68
- // - readinto method: samples are gathered from the L channel only
69
- // - write method: every sample is output to both the L and R channels
70
- // - for readinto method the I2S hardware is read using 8-byte frames
71
- // (this is standard for almost all I2S hardware, such as MEMS microphones)
40
+ // Notes on this port's specific implementation of I2S:
41
+ // - the DMA callback is used to implement the asynchronous background operations, for non-blocking mode
72
42
// - all 3 Modes of operation are implemented using the peripheral drivers in the NXP MCUXpresso SDK
73
43
// - all sample data transfers use DMA
74
44
// - the DMA ping-pong buffer needs to be aligned to a cache line size of 32 bytes. 32 byte
88
58
#define NON_BLOCKING_RATE_MULTIPLIER (4)
89
59
#define SIZEOF_NON_BLOCKING_COPY_IN_BYTES (SIZEOF_HALF_DMA_BUFFER_IN_BYTES * NON_BLOCKING_RATE_MULTIPLIER)
90
60
91
- #define NUM_I2S_USER_FORMATS (4)
92
- #define I2S_RX_FRAME_SIZE_IN_BYTES (8)
93
61
#define SAI_CHANNEL_0 (0)
94
62
#define SAI_NUM_AUDIO_CHANNELS (2U)
95
63
@@ -105,17 +73,6 @@ typedef enum {
105
73
TX ,
106
74
} i2s_mode_t ;
107
75
108
- typedef enum {
109
- MONO ,
110
- STEREO
111
- } format_t ;
112
-
113
- typedef enum {
114
- BLOCKING ,
115
- NON_BLOCKING ,
116
- ASYNCIO
117
- } io_mode_t ;
118
-
119
76
typedef enum {
120
77
TOP_HALF ,
121
78
BOTTOM_HALF
@@ -766,5 +723,3 @@ STATIC void mp_machine_i2s_irq_update(machine_i2s_obj_t *self) {
766
723
}
767
724
768
725
MP_REGISTER_ROOT_POINTER (struct _machine_i2s_obj_t * machine_i2s_obj [MICROPY_HW_I2S_NUM ]);
769
-
770
- #endif // MICROPY_PY_MACHINE_I2S
0 commit comments