Skip to content

Commit ee2207d

Browse files
authored
Merge pull request micropython#8291 from tannewt/i2s_mclk
Add I2S MCLK support to iMX RT
2 parents af91625 + ab70f8e commit ee2207d

File tree

23 files changed

+124
-11
lines changed

23 files changed

+124
-11
lines changed

ports/atmel-samd/common-hal/audiobusio/I2SOut.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ void i2sout_reset(void) {
9898
// Caller validates that pins are free.
9999
void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
100100
const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select,
101-
const mcu_pin_obj_t *data, bool left_justified) {
101+
const mcu_pin_obj_t *data, const mcu_pin_obj_t *main_clock, bool left_justified) {
102+
if (main_clock != NULL) {
103+
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_main_clock);
104+
}
102105
uint8_t serializer = 0xff;
103106
uint8_t bc_clock_unit = 0xff;
104107
uint8_t ws_clock_unit = 0xff;

ports/espressif/common-hal/audiobusio/I2SOut.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@
4949
// Caller validates that pins are free.
5050
void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
5151
const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select,
52-
const mcu_pin_obj_t *data, bool left_justified) {
53-
52+
const mcu_pin_obj_t *data, const mcu_pin_obj_t *main_clock, bool left_justified) {
53+
if (main_clock != NULL) {
54+
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_main_clock);
55+
}
5456
port_i2s_allocate_init(&self->peripheral, left_justified);
5557

5658
i2s_pin_config_t i2s_pin_config = {

ports/mimxrt10xx/common-hal/audiobusio/I2SOut.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,22 @@ STATIC void config_periph_pin(const mcu_periph_obj_t *periph) {
7474
// Caller validates that pins are free.
7575
void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
7676
const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select,
77-
const mcu_pin_obj_t *data, bool left_justified) {
77+
const mcu_pin_obj_t *data, const mcu_pin_obj_t *main_clock, bool left_justified) {
7878

7979
int instance = -1;
8080
const mcu_periph_obj_t *bclk_periph = find_pin_function(mcu_i2s_tx_bclk_list, bit_clock, &instance, MP_QSTR_bit_clock);
8181
const mcu_periph_obj_t *sync_periph = find_pin_function(mcu_i2s_tx_sync_list, word_select, &instance, MP_QSTR_word_select);
8282
const mcu_periph_obj_t *data_periph = find_pin_function(mcu_i2s_tx_data0_list, data, &instance, MP_QSTR_data);
8383

84+
if (main_clock != NULL) {
85+
const mcu_periph_obj_t *mclk_periph = find_pin_function(mcu_i2s_mclk_list, main_clock, &instance, MP_QSTR_main_clock);
86+
self->mclk = main_clock;
87+
claim_pin(main_clock);
88+
config_periph_pin(mclk_periph);
89+
IOMUXC_GPR->GPR1 |= IOMUXC_GPR_GPR1_SAI1_MCLK_DIR_MASK << (instance - 1);
90+
}
91+
self->instance = instance;
92+
8493
sai_transceiver_t config;
8594
SAI_GetClassicI2SConfig(&config, 16, kSAI_Stereo, 1);
8695
config.syncMode = kSAI_ModeAsync;
@@ -121,6 +130,13 @@ void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t *self) {
121130

122131
common_hal_reset_pin(self->data);
123132
self->data = NULL;
133+
134+
if (self->mclk != NULL) {
135+
IOMUXC_GPR->GPR1 &= ~(IOMUXC_GPR_GPR1_SAI1_MCLK_DIR_MASK << (self->instance - 1));
136+
137+
common_hal_reset_pin(self->mclk);
138+
self->mclk = NULL;
139+
}
124140
}
125141

126142
void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self,

ports/mimxrt10xx/common-hal/audiobusio/I2SOut.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ typedef struct {
3939
const mcu_pin_obj_t *bit_clock;
4040
const mcu_pin_obj_t *word_select;
4141
const mcu_pin_obj_t *data;
42+
const mcu_pin_obj_t *mclk;
43+
uint8_t instance;
4244
} audiobusio_i2sout_obj_t;
4345

4446
#endif

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ const mcu_periph_obj_t mcu_i2s_tx_sync_list[2] = {
174174
PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_SD_00),
175175
};
176176

177+
const mcu_periph_obj_t mcu_i2s_mclk_list[2] = {
178+
PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_08),
179+
180+
PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_00),
181+
};
182+
177183
const mcu_periph_obj_t mcu_mqs_left_list[1] = {
178184
PERIPH_PIN(3, 4, 0, 0, &pin_GPIO_AD_01),
179185
};

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1011/periph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extern const mcu_periph_obj_t mcu_i2s_rx_sync_list[2];
5656
extern const mcu_periph_obj_t mcu_i2s_tx_bclk_list[2];
5757
extern const mcu_periph_obj_t mcu_i2s_tx_data0_list[2];
5858
extern const mcu_periph_obj_t mcu_i2s_tx_sync_list[2];
59+
extern const mcu_periph_obj_t mcu_i2s_mclk_list[2];
5960

6061
extern const mcu_periph_obj_t mcu_mqs_left_list[1];
6162
extern const mcu_periph_obj_t mcu_mqs_right_list[1];

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1015/periph.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ const mcu_periph_obj_t mcu_i2s_tx_sync_list[4] = {
159159
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_SD_B1_07),
160160
};
161161

162+
const mcu_periph_obj_t mcu_i2s_mclk_list[5] = {
163+
PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_EMC_20),
164+
PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B0_03),
165+
166+
PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_EMC_16),
167+
168+
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_17),
169+
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_SD_B1_05),
170+
};
171+
162172
const mcu_periph_obj_t mcu_mqs_left_list[2] = {
163173
PERIPH_PIN(3, 2, 0, 0, &pin_GPIO_EMC_17),
164174
PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_AD_B0_07),

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1015/periph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extern const mcu_periph_obj_t mcu_i2s_rx_sync_list[3];
5656
extern const mcu_periph_obj_t mcu_i2s_tx_bclk_list[4];
5757
extern const mcu_periph_obj_t mcu_i2s_tx_data0_list[4];
5858
extern const mcu_periph_obj_t mcu_i2s_tx_sync_list[4];
59+
extern const mcu_periph_obj_t mcu_i2s_mclk_list[5];
5960

6061
extern const mcu_periph_obj_t mcu_mqs_left_list[2];
6162
extern const mcu_periph_obj_t mcu_mqs_right_list[2];

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,20 @@ const mcu_periph_obj_t mcu_i2s_tx_sync_list[7] = {
268268
PERIPH_PIN(3, 3, kIOMUXC_SAI3_TX_SYNC_SELECT_INPUT, 1, &pin_GPIO_EMC_34),
269269
};
270270

271+
const mcu_periph_obj_t mcu_i2s_mclk_list[9] = {
272+
PERIPH_PIN(1, 2, kIOMUXC_SAI1_MCLK_SELECT_INPUT, 0, &pin_GPIO_SD_B0_00),
273+
PERIPH_PIN(1, 3, kIOMUXC_SAI1_MCLK_SELECT_INPUT, 1, &pin_GPIO_AD_B0_03),
274+
PERIPH_PIN(1, 3, kIOMUXC_SAI1_MCLK_SELECT_INPUT, 2, &pin_GPIO_AD_B1_00),
275+
PERIPH_PIN(1, 3, kIOMUXC_SAI1_MCLK_SELECT_INPUT, 3, &pin_GPIO_EMC_20),
276+
277+
PERIPH_PIN(2, 3, kIOMUXC_SAI2_MCLK_SELECT_INPUT, 0, &pin_GPIO_SD_B0_00),
278+
PERIPH_PIN(2, 3, kIOMUXC_SAI2_MCLK_SELECT_INPUT, 1, &pin_GPIO_EMC_16),
279+
280+
PERIPH_PIN(3, 3, kIOMUXC_SAI3_MCLK_SELECT_INPUT, 0, &pin_GPIO_SD_B1_05),
281+
PERIPH_PIN(3, 3, kIOMUXC_SAI3_MCLK_SELECT_INPUT, 1, &pin_GPIO_EMC_17),
282+
PERIPH_PIN(3, 3, kIOMUXC_SAI3_MCLK_SELECT_INPUT, 2, &pin_GPIO_EMC_28),
283+
};
284+
271285
const mcu_periph_obj_t mcu_mqs_left_list[3] = {
272286
PERIPH_PIN(3, 2, 0, 0, &pin_GPIO_EMC_17),
273287
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_38),

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1021/periph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extern const mcu_periph_obj_t mcu_i2s_rx_sync_list[7];
5656
extern const mcu_periph_obj_t mcu_i2s_tx_bclk_list[7];
5757
extern const mcu_periph_obj_t mcu_i2s_tx_data0_list[7];
5858
extern const mcu_periph_obj_t mcu_i2s_tx_sync_list[7];
59+
extern const mcu_periph_obj_t mcu_i2s_mclk_list[9];
5960

6061
extern const mcu_periph_obj_t mcu_mqs_left_list[3];
6162
extern const mcu_periph_obj_t mcu_mqs_right_list[3];

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1042/periph.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ const mcu_periph_obj_t mcu_i2s_tx_sync_list[6] = {
254254
PERIPH_PIN(3, 8, 0, 0, &pin_GPIO_SD_B1_02),
255255
};
256256

257+
const mcu_periph_obj_t mcu_i2s_mclk_list[6] = {
258+
PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_B0_13),
259+
PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_SD_B1_03),
260+
261+
PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_EMC_07),
262+
PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_AD_B0_10),
263+
264+
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_37),
265+
PERIPH_PIN(3, 8, 0, 0, &pin_GPIO_SD_B1_04),
266+
};
267+
257268
const mcu_periph_obj_t mcu_mqs_left_list[3] = {
258269
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_14),
259270
PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_AD_B0_05),

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1042/periph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extern const mcu_periph_obj_t mcu_i2s_rx_sync_list[6];
5656
extern const mcu_periph_obj_t mcu_i2s_tx_bclk_list[6];
5757
extern const mcu_periph_obj_t mcu_i2s_tx_data0_list[6];
5858
extern const mcu_periph_obj_t mcu_i2s_tx_sync_list[6];
59+
extern const mcu_periph_obj_t mcu_i2s_mclk_list[6];
5960

6061
extern const mcu_periph_obj_t mcu_mqs_left_list[3];
6162
extern const mcu_periph_obj_t mcu_mqs_right_list[3];

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1052/periph.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,17 @@ const mcu_periph_obj_t mcu_i2s_tx_sync_list[6] = {
267267
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_39),
268268
};
269269

270+
const mcu_periph_obj_t mcu_i2s_mclk_list[6] = {
271+
PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_09),
272+
PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_B0_13),
273+
PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_SD_B1_03),
274+
275+
PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_EMC_07),
276+
PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_AD_B0_10),
277+
278+
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_37),
279+
};
280+
270281
const mcu_periph_obj_t mcu_mqs_left_list[3] = {
271282
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_14),
272283
PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_AD_B0_05),

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1052/periph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extern const mcu_periph_obj_t mcu_i2s_rx_sync_list[6];
5656
extern const mcu_periph_obj_t mcu_i2s_tx_bclk_list[6];
5757
extern const mcu_periph_obj_t mcu_i2s_tx_data0_list[6];
5858
extern const mcu_periph_obj_t mcu_i2s_tx_sync_list[6];
59+
extern const mcu_periph_obj_t mcu_i2s_mclk_list[6];
5960

6061
extern const mcu_periph_obj_t mcu_mqs_left_list[3];
6162
extern const mcu_periph_obj_t mcu_mqs_right_list[3];

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,18 @@ const mcu_periph_obj_t mcu_i2s_tx_sync_list[7] = {
272272
PERIPH_PIN(3, 8, 0, 0, &pin_GPIO_SD_B1_02),
273273
};
274274

275+
const mcu_periph_obj_t mcu_i2s_mclk_list[7] = {
276+
PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_AD_B1_09),
277+
PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_B0_13),
278+
PERIPH_PIN(1, 3, 0, 0, &pin_GPIO_SD_B1_03),
279+
280+
PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_EMC_07),
281+
PERIPH_PIN(2, 3, 0, 0, &pin_GPIO_AD_B0_10),
282+
283+
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_37),
284+
PERIPH_PIN(3, 8, 0, 0, &pin_GPIO_SD_B1_04),
285+
};
286+
275287
const mcu_periph_obj_t mcu_mqs_left_list[3] = {
276288
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_14),
277289
PERIPH_PIN(3, 1, 0, 0, &pin_GPIO_AD_B0_05),

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1062/periph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extern const mcu_periph_obj_t mcu_i2s_rx_sync_list[7];
5656
extern const mcu_periph_obj_t mcu_i2s_tx_bclk_list[7];
5757
extern const mcu_periph_obj_t mcu_i2s_tx_data0_list[7];
5858
extern const mcu_periph_obj_t mcu_i2s_tx_sync_list[7];
59+
extern const mcu_periph_obj_t mcu_i2s_mclk_list[7];
5960

6061
extern const mcu_periph_obj_t mcu_mqs_left_list[3];
6162
extern const mcu_periph_obj_t mcu_mqs_right_list[3];

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1176/periph.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,15 @@ const mcu_periph_obj_t mcu_i2s_tx_sync_list[4] = {
237237
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_B2_16),
238238
};
239239

240+
const mcu_periph_obj_t mcu_i2s_mclk_list[4] = {
241+
PERIPH_PIN(1, 0, 0, 0, &pin_GPIO_AD_17),
242+
PERIPH_PIN(1, 4, 0, 0, &pin_GPIO_DISP_B2_03),
243+
244+
PERIPH_PIN(2, 2, 0, 0, &pin_GPIO_EMC_B2_04),
245+
246+
PERIPH_PIN(3, 3, 0, 0, &pin_GPIO_EMC_B2_17),
247+
};
248+
240249
const mcu_periph_obj_t mcu_mqs_left_list[2] = {
241250
PERIPH_PIN(3, 2, 0, 0, &pin_GPIO_EMC_B1_41),
242251
PERIPH_PIN(3, 2, 0, 0, &pin_GPIO_DISP_B2_01),

ports/mimxrt10xx/peripherals/mimxrt10xx/MIMXRT1176/periph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extern const mcu_periph_obj_t mcu_i2s_rx_sync_list[4];
5656
extern const mcu_periph_obj_t mcu_i2s_tx_bclk_list[4];
5757
extern const mcu_periph_obj_t mcu_i2s_tx_data0_list[4];
5858
extern const mcu_periph_obj_t mcu_i2s_tx_sync_list[4];
59+
extern const mcu_periph_obj_t mcu_i2s_mclk_list[4];
5960

6061
extern const mcu_periph_obj_t mcu_mqs_left_list[2];
6162
extern const mcu_periph_obj_t mcu_mqs_right_list[2];

ports/mimxrt10xx/tools/gen_peripherals_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"LPI2C": ["SDA", "SCL"],
77
"LPSPI": ["SCK", "SDO", "SDI"],
88
"LPUART": ["RX", "TX", "RTS", "CTS"],
9-
"I2S": ["RX_DATA0", "RX_SYNC", "TX_BCLK", "TX_DATA0", "TX_SYNC"],
9+
"I2S": ["RX_DATA0", "RX_SYNC", "TX_BCLK", "TX_DATA0", "TX_SYNC", "MCLK"],
1010
"MQS": ["LEFT", "RIGHT"],
1111
}
1212

ports/nrf/common-hal/audiobusio/I2SOut.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,10 @@ static void i2s_buffer_fill(audiobusio_i2sout_obj_t *self) {
202202

203203
void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
204204
const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select,
205-
const mcu_pin_obj_t *data, bool left_justified) {
205+
const mcu_pin_obj_t *data, const mcu_pin_obj_t *main_clock, bool left_justified) {
206+
if (main_clock != NULL) {
207+
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_main_clock);
208+
}
206209
if (instance) {
207210
mp_raise_RuntimeError(translate("Device in use"));
208211
}

ports/raspberrypi/common-hal/audiobusio/I2SOut.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ void i2sout_reset(void) {
103103
// Caller validates that pins are free.
104104
void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
105105
const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select,
106-
const mcu_pin_obj_t *data, bool left_justified) {
106+
const mcu_pin_obj_t *data, const mcu_pin_obj_t *main_clock, bool left_justified) {
107+
if (main_clock != NULL) {
108+
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_main_clock);
109+
}
107110
if (bit_clock->number != word_select->number - 1) {
108111
mp_raise_ValueError(translate("Bit clock and word select must be sequential pins"));
109112
}

shared-bindings/audiobusio/I2SOut.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@
4444
//| word_select: microcontroller.Pin,
4545
//| data: microcontroller.Pin,
4646
//| *,
47-
//| left_justified: bool
47+
//| main_clock: Optional[microcontroller.Pin] = None,
48+
//| left_justified: bool = False
4849
//| ) -> None:
4950
//| """Create a I2SOut object associated with the given pins.
5051
//|
5152
//| :param ~microcontroller.Pin bit_clock: The bit clock (or serial clock) pin
5253
//| :param ~microcontroller.Pin word_select: The word select (or left/right clock) pin
5354
//| :param ~microcontroller.Pin data: The data pin
55+
//| :param ~microcontroller.Pin main_clock: The main clock pin
5456
//| :param bool left_justified: True when data bits are aligned with the word select clock. False
5557
//| when they are shifted by one to match classic I2S protocol.
5658
//|
@@ -100,11 +102,12 @@ STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a
100102
mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_I2SOut);
101103
return NULL; // Not reachable.
102104
#else
103-
enum { ARG_bit_clock, ARG_word_select, ARG_data, ARG_left_justified };
105+
enum { ARG_bit_clock, ARG_word_select, ARG_data, ARG_main_clock, ARG_left_justified };
104106
static const mp_arg_t allowed_args[] = {
105107
{ MP_QSTR_bit_clock, MP_ARG_OBJ | MP_ARG_REQUIRED },
106108
{ MP_QSTR_word_select, MP_ARG_OBJ | MP_ARG_REQUIRED },
107109
{ MP_QSTR_data, MP_ARG_OBJ | MP_ARG_REQUIRED },
110+
{ MP_QSTR_main_clock, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
108111
{ MP_QSTR_left_justified, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_bool = false} },
109112
};
110113
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
@@ -113,10 +116,11 @@ STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a
113116
const mcu_pin_obj_t *bit_clock = validate_obj_is_free_pin(args[ARG_bit_clock].u_obj, MP_QSTR_bit_clock);
114117
const mcu_pin_obj_t *word_select = validate_obj_is_free_pin(args[ARG_word_select].u_obj, MP_QSTR_word_select);
115118
const mcu_pin_obj_t *data = validate_obj_is_free_pin(args[ARG_data].u_obj, MP_QSTR_data);
119+
const mcu_pin_obj_t *main_clock = validate_obj_is_free_pin_or_none(args[ARG_main_clock].u_obj, MP_QSTR_main_clock);
116120

117121
audiobusio_i2sout_obj_t *self = m_new_obj_with_finaliser(audiobusio_i2sout_obj_t);
118122
self->base.type = &audiobusio_i2sout_type;
119-
common_hal_audiobusio_i2sout_construct(self, bit_clock, word_select, data, args[ARG_left_justified].u_bool);
123+
common_hal_audiobusio_i2sout_construct(self, bit_clock, word_select, data, main_clock, args[ARG_left_justified].u_bool);
120124

121125
return MP_OBJ_FROM_PTR(self);
122126
#endif

shared-bindings/audiobusio/I2SOut.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ extern const mp_obj_type_t audiobusio_i2sout_type;
3737

3838
void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
3939
const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select, const mcu_pin_obj_t *data,
40-
bool left_justified);
40+
const mcu_pin_obj_t *main_clock, bool left_justified);
4141

4242
void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t *self);
4343
bool common_hal_audiobusio_i2sout_deinited(audiobusio_i2sout_obj_t *self);

0 commit comments

Comments
 (0)