Merge pull request #2324 from jepler/nrf-i2s-channels-widths
nrf: assign channel width and count correctly
This commit is contained in:
commit
e5dd78d393
@ -245,12 +245,20 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self,
|
|||||||
|
|
||||||
uint32_t max_buffer_length;
|
uint32_t max_buffer_length;
|
||||||
bool single_buffer, samples_signed;
|
bool single_buffer, samples_signed;
|
||||||
audiosample_get_buffer_structure(sample, /* single channel */ false,
|
audiosample_get_buffer_structure(sample, /* single channel */ true,
|
||||||
&single_buffer, &samples_signed, &max_buffer_length,
|
&single_buffer, &samples_signed, &max_buffer_length,
|
||||||
&self->channel_count);
|
&self->channel_count);
|
||||||
self->single_buffer = single_buffer;
|
self->single_buffer = single_buffer;
|
||||||
self->samples_signed = samples_signed;
|
self->samples_signed = samples_signed;
|
||||||
|
|
||||||
|
|
||||||
|
NRF_I2S->CONFIG.SWIDTH = self->bytes_per_sample == 1
|
||||||
|
? I2S_CONFIG_SWIDTH_SWIDTH_8Bit
|
||||||
|
: I2S_CONFIG_SWIDTH_SWIDTH_16Bit;
|
||||||
|
NRF_I2S->CONFIG.CHANNELS = self->channel_count == 1
|
||||||
|
? I2S_CONFIG_CHANNELS_CHANNELS_Left
|
||||||
|
: I2S_CONFIG_CHANNELS_CHANNELS_Stereo;
|
||||||
|
|
||||||
choose_i2s_clocking(self, sample_rate);
|
choose_i2s_clocking(self, sample_rate);
|
||||||
/* Allocate buffers based on a maximum duration
|
/* Allocate buffers based on a maximum duration
|
||||||
* This duration was chosen empirically based on what would
|
* This duration was chosen empirically based on what would
|
||||||
@ -274,9 +282,6 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self,
|
|||||||
self->stopping = false;
|
self->stopping = false;
|
||||||
i2s_buffer_fill(self);
|
i2s_buffer_fill(self);
|
||||||
|
|
||||||
NRF_I2S->CONFIG.CHANNELS = self->channel_count == 1 ? I2S_CONFIG_CHANNELS_CHANNELS_Left : I2S_CONFIG_CHANNELS_CHANNELS_Stereo;
|
|
||||||
|
|
||||||
|
|
||||||
NRF_I2S->RXTXD.MAXCNT = self->buffer_length / 4;
|
NRF_I2S->RXTXD.MAXCNT = self->buffer_length / 4;
|
||||||
NRF_I2S->ENABLE = I2S_ENABLE_ENABLE_Enabled;
|
NRF_I2S->ENABLE = I2S_ENABLE_ENABLE_Enabled;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user