31
31
#include "common-hal/audiobusio/I2SOut.h"
32
32
#include "shared-bindings/audiobusio/I2SOut.h"
33
33
#include "shared-module/audiocore/__init__.h"
34
+ #include "supervisor/shared/tick.h"
34
35
35
36
#include "py/obj.h"
36
37
#include "py/runtime.h"
@@ -158,7 +159,7 @@ static void i2s_buffer_fill(audiobusio_i2sout_obj_t* self) {
158
159
159
160
// Find the last frame of real audio data and replicate its samples until
160
161
// you have 32 bits worth, which is the fundamental unit of nRF I2S DMA
161
- if (buffer != buffer_start ) {
162
+ if (buffer != buffer_start ) {
162
163
if (self -> bytes_per_sample == 1 && self -> channel_count == 1 ) {
163
164
// For 8-bit mono, 4 copies of the final sample are required
164
165
self -> hold_value = 0x01010101 * * (uint8_t * )(buffer - 1 );
@@ -211,6 +212,8 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t* self,
211
212
NRF_I2S -> CONFIG .ALIGN = I2S_CONFIG_ALIGN_ALIGN_Left ;
212
213
NRF_I2S -> CONFIG .FORMAT = left_justified ? I2S_CONFIG_FORMAT_FORMAT_Aligned
213
214
: I2S_CONFIG_FORMAT_FORMAT_I2S ;
215
+
216
+ supervisor_enable_tick ();
214
217
}
215
218
216
219
bool common_hal_audiobusio_i2sout_deinited (audiobusio_i2sout_obj_t * self ) {
@@ -230,6 +233,7 @@ void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t* self) {
230
233
reset_pin_number (self -> data_pin_number );
231
234
self -> data_pin_number = 0xff ;
232
235
instance = NULL ;
236
+ supervisor_disable_tick ();
233
237
}
234
238
235
239
void common_hal_audiobusio_i2sout_play (audiobusio_i2sout_obj_t * self ,
@@ -340,5 +344,8 @@ void i2s_reset(void) {
340
344
NRF_I2S -> PSEL .LRCK = 0xFFFFFFFF ;
341
345
NRF_I2S -> PSEL .SDOUT = 0xFFFFFFFF ;
342
346
NRF_I2S -> PSEL .SDIN = 0xFFFFFFFF ;
347
+ if (instance ) {
348
+ supervisor_disable_tick ();
349
+ }
343
350
instance = NULL ;
344
351
}
0 commit comments