1 /* 2 * Copyright (c) 2018 STMicroelectronics 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef MPXXDTYY_H 8 #define MPXXDTYY_H 9 10 #include <zephyr/audio/dmic.h> 11 #include <zephyr/kernel.h> 12 #include <zephyr/device.h> 13 #include "OpenPDMFilter.h" 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 #define MPXXDTYY_MIN_PDM_FREQ 1200000 /* 1.2MHz */ 20 #define MPXXDTYY_MAX_PDM_FREQ 3250000 /* 3.25MHz */ 21 22 struct mpxxdtyy_config { 23 const struct device *comm_master; 24 }; 25 26 struct mpxxdtyy_data { 27 enum dmic_state state; 28 TPDMFilter_InitStruct pdm_filter[2]; 29 size_t pcm_mem_size; 30 struct k_mem_slab *pcm_mem_slab; 31 }; 32 33 uint16_t sw_filter_lib_init(const struct device *dev, struct dmic_cfg *cfg); 34 int sw_filter_lib_run(TPDMFilter_InitStruct *pdm_filter, 35 void *pdm_block, void *pcm_block, 36 size_t pdm_size, size_t pcm_size); 37 38 #if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2s) 39 int mpxxdtyy_i2s_read(const struct device *dev, uint8_t stream, void **buffer, 40 size_t *size, int32_t timeout); 41 int mpxxdtyy_i2s_trigger(const struct device *dev, enum dmic_trigger cmd); 42 int mpxxdtyy_i2s_configure(const struct device *dev, struct dmic_cfg *cfg); 43 #endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i2s) */ 44 45 #ifdef __cplusplus 46 } 47 #endif 48 49 #endif /* MPXXDTYY_H */ 50