mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Update audio to use common macros.
This commit is contained in:
parent
52ed1f6586
commit
e5d37c945a
@ -19,11 +19,11 @@
|
|||||||
#include "omv_boardconfig.h"
|
#include "omv_boardconfig.h"
|
||||||
#include "py/obj.h"
|
#include "py/obj.h"
|
||||||
#include "py/objarray.h"
|
#include "py/objarray.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#if MICROPY_PY_AUDIO
|
#if MICROPY_PY_AUDIO
|
||||||
|
|
||||||
#define RAISE_OS_EXCEPTION(msg) nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, msg))
|
#define RAISE_OS_EXCEPTION(msg) nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, msg))
|
||||||
#define SAI_MIN(a,b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a < _b ? _a : _b; })
|
|
||||||
|
|
||||||
static CRC_HandleTypeDef hcrc;
|
static CRC_HandleTypeDef hcrc;
|
||||||
static SAI_HandleTypeDef hsai;
|
static SAI_HandleTypeDef hsai;
|
||||||
@ -43,7 +43,7 @@ static volatile uint32_t xfer_status = 0;
|
|||||||
|
|
||||||
#define PDM_BUFFER_SIZE (16384)
|
#define PDM_BUFFER_SIZE (16384)
|
||||||
// BDMA can only access D3 SRAM4 memory.
|
// BDMA can only access D3 SRAM4 memory.
|
||||||
uint8_t PDM_BUFFER[PDM_BUFFER_SIZE] __attribute__ ((aligned (32))) __attribute__((section(".d3_sram_buffer")));
|
uint8_t OMV_ATTR_SECTION(OMV_ATTR_ALIGNED(PDM_BUFFER[PDM_BUFFER_SIZE], 32), ".d3_sram_buffer");
|
||||||
|
|
||||||
// Pendsv dispatch callback.
|
// Pendsv dispatch callback.
|
||||||
static void audio_pendsv_callback(void);
|
static void audio_pendsv_callback(void);
|
||||||
@ -279,7 +279,7 @@ static mp_obj_t py_audio_read_pdm(mp_obj_t buf_in)
|
|||||||
|
|
||||||
// Copy samples to pdm output buffer.
|
// Copy samples to pdm output buffer.
|
||||||
// Note: samples are copied as bytes for 1 and 2 channels.
|
// Note: samples are copied as bytes for 1 and 2 channels.
|
||||||
uint32_t samples = SAI_MIN(n_samples, PDM_BUFFER_SIZE);
|
uint32_t samples = OMV_MIN(n_samples, PDM_BUFFER_SIZE);
|
||||||
for (int i=0; i<samples; i++, n_samples--, xfer_samples++) {
|
for (int i=0; i<samples; i++, n_samples--, xfer_samples++) {
|
||||||
((uint8_t*)pdmbuf.buf)[xfer_samples] = ((uint8_t *)PDM_BUFFER)[i];
|
((uint8_t*)pdmbuf.buf)[xfer_samples] = ((uint8_t *)PDM_BUFFER)[i];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user