samd: Rename dma_{allocate,free} channel
These are now used in the (video) parallel capture device as well.
This commit is contained in:
parent
f838ff9528
commit
34c4cc1bd9
@ -53,7 +53,7 @@ uint8_t find_sync_event_channel_raise() {
|
|||||||
return event_channel;
|
return event_channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t audio_dma_allocate_channel(void) {
|
uint8_t dma_allocate_channel(void) {
|
||||||
uint8_t channel;
|
uint8_t channel;
|
||||||
for (channel = 0; channel < AUDIO_DMA_CHANNEL_COUNT; channel++) {
|
for (channel = 0; channel < AUDIO_DMA_CHANNEL_COUNT; channel++) {
|
||||||
if (!audio_dma_allocated[channel]) {
|
if (!audio_dma_allocated[channel]) {
|
||||||
@ -64,7 +64,7 @@ uint8_t audio_dma_allocate_channel(void) {
|
|||||||
return channel; // i.e., return failure
|
return channel; // i.e., return failure
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_dma_free_channel(uint8_t channel) {
|
void dma_free_channel(uint8_t channel) {
|
||||||
assert(channel < AUDIO_DMA_CHANNEL_COUNT);
|
assert(channel < AUDIO_DMA_CHANNEL_COUNT);
|
||||||
assert(audio_dma_allocated[channel]);
|
assert(audio_dma_allocated[channel]);
|
||||||
audio_dma_disable_channel(channel);
|
audio_dma_disable_channel(channel);
|
||||||
@ -188,7 +188,7 @@ audio_dma_result audio_dma_setup_playback(audio_dma_t *dma,
|
|||||||
bool output_signed,
|
bool output_signed,
|
||||||
uint32_t output_register_address,
|
uint32_t output_register_address,
|
||||||
uint8_t dma_trigger_source) {
|
uint8_t dma_trigger_source) {
|
||||||
uint8_t dma_channel = audio_dma_allocate_channel();
|
uint8_t dma_channel = dma_allocate_channel();
|
||||||
if (dma_channel >= AUDIO_DMA_CHANNEL_COUNT) {
|
if (dma_channel >= AUDIO_DMA_CHANNEL_COUNT) {
|
||||||
return AUDIO_DMA_DMA_BUSY;
|
return AUDIO_DMA_DMA_BUSY;
|
||||||
}
|
}
|
||||||
@ -306,7 +306,7 @@ void audio_dma_stop(audio_dma_t *dma) {
|
|||||||
disable_event_channel(dma->event_channel);
|
disable_event_channel(dma->event_channel);
|
||||||
MP_STATE_PORT(playing_audio)[channel] = NULL;
|
MP_STATE_PORT(playing_audio)[channel] = NULL;
|
||||||
audio_dma_state[channel] = NULL;
|
audio_dma_state[channel] = NULL;
|
||||||
audio_dma_free_channel(dma->dma_channel);
|
dma_free_channel(dma->dma_channel);
|
||||||
}
|
}
|
||||||
dma->dma_channel = AUDIO_DMA_CHANNEL_COUNT;
|
dma->dma_channel = AUDIO_DMA_CHANNEL_COUNT;
|
||||||
}
|
}
|
||||||
|
@ -66,8 +66,8 @@ uint8_t audiosample_channel_count(mp_obj_t sample_obj);
|
|||||||
void audio_dma_init(audio_dma_t *dma);
|
void audio_dma_init(audio_dma_t *dma);
|
||||||
void audio_dma_reset(void);
|
void audio_dma_reset(void);
|
||||||
|
|
||||||
uint8_t audio_dma_allocate_channel(void);
|
uint8_t dma_allocate_channel(void);
|
||||||
void audio_dma_free_channel(uint8_t channel);
|
void dma_free_channel(uint8_t channel);
|
||||||
|
|
||||||
// This sets everything up but doesn't start the timer.
|
// This sets everything up but doesn't start the timer.
|
||||||
// Sample is the python object for the sample to play.
|
// Sample is the python object for the sample to play.
|
||||||
|
@ -367,7 +367,7 @@ static uint16_t filter_sample(uint32_t pdm_samples[4]) {
|
|||||||
// output_buffer_length is the number of slots, not the number of bytes.
|
// output_buffer_length is the number of slots, not the number of bytes.
|
||||||
uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* self,
|
uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* self,
|
||||||
uint16_t* output_buffer, uint32_t output_buffer_length) {
|
uint16_t* output_buffer, uint32_t output_buffer_length) {
|
||||||
uint8_t dma_channel = audio_dma_allocate_channel();
|
uint8_t dma_channel = dma_allocate_channel();
|
||||||
uint8_t event_channel = find_sync_event_channel_raise();
|
uint8_t event_channel = find_sync_event_channel_raise();
|
||||||
|
|
||||||
// We allocate two buffers on the stack to use for double buffering.
|
// We allocate two buffers on the stack to use for double buffering.
|
||||||
@ -473,7 +473,7 @@ uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* se
|
|||||||
}
|
}
|
||||||
|
|
||||||
disable_event_channel(event_channel);
|
disable_event_channel(event_channel);
|
||||||
audio_dma_free_channel(dma_channel);
|
dma_free_channel(dma_channel);
|
||||||
// Turn off serializer, but leave clock on, to avoid mic startup delay.
|
// Turn off serializer, but leave clock on, to avoid mic startup delay.
|
||||||
i2s_set_serializer_enable(self->serializer, false);
|
i2s_set_serializer_enable(self->serializer, false);
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ static void setup_dma(DmacDescriptor* descriptor, size_t count, uint32_t *buffer
|
|||||||
void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_parallelimagecapture_obj_t *self, void *buffer, size_t bufsize)
|
void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_parallelimagecapture_obj_t *self, void *buffer, size_t bufsize)
|
||||||
{
|
{
|
||||||
|
|
||||||
uint8_t dma_channel = audio_dma_allocate_channel();
|
uint8_t dma_channel = dma_allocate_channel();
|
||||||
|
|
||||||
uint32_t *dest = buffer;
|
uint32_t *dest = buffer;
|
||||||
size_t count = bufsize / 4; // PCC receives 4 bytes (2 pixels) at a time
|
size_t count = bufsize / 4; // PCC receives 4 bytes (2 pixels) at a time
|
||||||
@ -178,7 +178,7 @@ void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_paralleli
|
|||||||
RUN_BACKGROUND_TASKS;
|
RUN_BACKGROUND_TASKS;
|
||||||
// Allow user to break out of a timeout with a KeyboardInterrupt.
|
// Allow user to break out of a timeout with a KeyboardInterrupt.
|
||||||
if (mp_hal_is_interrupted()) {
|
if (mp_hal_is_interrupted()) {
|
||||||
audio_dma_free_channel(dma_channel);
|
dma_free_channel(dma_channel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,5 +194,5 @@ void common_hal_imagecapture_parallelimagecapture_capture(imagecapture_paralleli
|
|||||||
}
|
}
|
||||||
|
|
||||||
dma_disable_channel(dma_channel);
|
dma_disable_channel(dma_channel);
|
||||||
audio_dma_free_channel(dma_channel);
|
dma_free_channel(dma_channel);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user