Skip to content

Commit edbcf11

Browse files
committed
mimxrt10xx: stub implementation of i2sout
Builds, does nothing useful
1 parent d58a606 commit edbcf11

File tree

9 files changed

+183
-1
lines changed

9 files changed

+183
-1
lines changed

ports/mimxrt10xx/background.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
#include "supervisor/port.h"
2929

30+
#include "audio_dma.h"
31+
3032
void port_background_task(void) {
3133
#if CIRCUITPY_AUDIOIO || CIRCUITPY_AUDIOBUSIO
3234
audio_dma_background();
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2021 Jeff Epler for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "common-hal/audiobusio/I2SOut.h"
28+
#include "shared-bindings/audiobusio/I2SOut.h"
29+
30+
void i2sout_reset(void) {}
31+
void audio_dma_background(void) {}
32+
33+
void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self,
34+
const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select, const mcu_pin_obj_t *data,
35+
bool left_justified)
36+
{
37+
}
38+
39+
void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t *self)
40+
{
41+
}
42+
43+
bool common_hal_audiobusio_i2sout_deinited(audiobusio_i2sout_obj_t *self)
44+
{
45+
return true;
46+
}
47+
48+
void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self, mp_obj_t sample, bool loop)
49+
{
50+
self->playing = 1;
51+
}
52+
53+
void common_hal_audiobusio_i2sout_stop(audiobusio_i2sout_obj_t *self)
54+
{
55+
self->playing = 0;
56+
}
57+
58+
bool common_hal_audiobusio_i2sout_get_playing(audiobusio_i2sout_obj_t *self)
59+
{
60+
return self->playing;
61+
}
62+
63+
void common_hal_audiobusio_i2sout_pause(audiobusio_i2sout_obj_t *self)
64+
{
65+
self->paused = 1;
66+
}
67+
68+
void common_hal_audiobusio_i2sout_resume(audiobusio_i2sout_obj_t *self)
69+
{
70+
self->paused = 0;
71+
}
72+
73+
bool common_hal_audiobusio_i2sout_get_paused(audiobusio_i2sout_obj_t *self)
74+
{
75+
return self->paused;
76+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#pragma once
28+
29+
#include "common-hal/microcontroller/Pin.h"
30+
31+
#include "py/obj.h"
32+
33+
// Some boards don't implement I2SOut, so suppress any routines from here.
34+
#if CIRCUITPY_AUDIOBUSIO_I2SOUT
35+
36+
// We don't bit pack because we'll only have two at most. Its better to save code size instead.
37+
typedef struct {
38+
mp_obj_base_t base;
39+
bool left_justified;
40+
const mcu_pin_obj_t *bit_clock;
41+
const mcu_pin_obj_t *word_select;
42+
const mcu_pin_obj_t *data;
43+
uint8_t clock_unit;
44+
uint8_t serializer;
45+
uint8_t gclk;
46+
bool playing, paused;
47+
} audiobusio_i2sout_obj_t;
48+
49+
void i2sout_reset(void);
50+
51+
#endif // CIRCUITPY_AUDIOBUSIO_I2SOUT

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

Whitespace-only changes.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#pragma once
28+
29+
#include "common-hal/microcontroller/Pin.h"
30+
31+
#include "py/obj.h"
32+
33+
typedef struct {
34+
mp_obj_base_t base;
35+
const mcu_pin_obj_t *clock_pin;
36+
const mcu_pin_obj_t *data_pin;
37+
uint32_t sample_rate;
38+
uint8_t serializer;
39+
uint8_t clock_unit;
40+
uint8_t bytes_per_sample;
41+
uint8_t bit_depth;
42+
uint8_t gclk;
43+
} audiobusio_pdmin_obj_t;
44+
45+
void pdmin_reset(void);
46+
47+
void pdmin_background(void);

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

Whitespace-only changes.

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

Whitespace-only changes.

ports/mimxrt10xx/mpconfigport.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ USB_NUM_EP = 8
2323
INTERNAL_FLASH_FILESYSTEM = 1
2424

2525
CIRCUITPY_AUDIOIO = 0
26-
CIRCUITPY_AUDIOBUSIO = 0
26+
CIRCUITPY_AUDIOBUSIO = 1
27+
CIRCUITPY_AUDIOBUSIO_PDMIN = 0
28+
CIRCUITPY_AUDIOCORE = 1
29+
CIRCUITPY_AUDIOMIXER = 1
30+
CIRCUITPY_AUDIOMP3 = 1
2731
CIRCUITPY_FREQUENCYIO = 0
2832
CIRCUITPY_I2CPERIPHERAL = 0
2933
CIRCUITPY_NVM = 0

ports/mimxrt10xx/supervisor/port.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
#include "fsl_device_registers.h"
3838

39+
#include "common-hal/audiobusio/PDMIn.h"
40+
#include "common-hal/audiobusio/I2SOut.h"
3941
#include "common-hal/microcontroller/Pin.h"
4042
#include "common-hal/pulseio/PulseIn.h"
4143
#include "common-hal/pulseio/PulseOut.h"

0 commit comments

Comments
 (0)