Loading...
Searching...
No Matches
pdm.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Inria
3 * SPDX-FileCopyrightText: 2024-2026 HAW Hamburg
4 * SPDX-License-Identifier: LGPL-2.1-only
5 */
6
7#pragma once
8
21
22#include <stdint.h>
23
24#include "periph_cpu.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
34#ifndef HAVE_PDM_MODE_T
39#endif
41
45#ifndef PDM_GAIN_MIN
46# define PDM_GAIN_MIN (-20)
47#endif
48
52#ifndef PDM_GAIN_MAX
53# define PDM_GAIN_MAX (20)
54#endif
55
59#ifndef PDM_BUF_SIZE
60# define PDM_BUF_SIZE (64U)
61#endif
62
69typedef void (*pdm_data_cb_t)(void *arg, int16_t *buf);
70
74#ifndef HAVE_PDM_ISR_CTX_T
75typedef struct {
77 void *arg;
79#endif
80
97int32_t pdm_init(pdm_mode_t mode, uint32_t rate, int8_t gain,
98 pdm_data_cb_t cb, void *arg);
99
111void pdm_start(void);
112
116void pdm_stop(void);
117
121void pdm_deinit(void);
122
123#ifdef __cplusplus
124}
125#endif
126
void pdm_deinit(void)
Disable the PDM peripheral.
int32_t pdm_init(pdm_mode_t mode, uint32_t rate, int8_t gain, pdm_data_cb_t cb, void *arg)
Initialize and enable the PDM peripheral.
void pdm_stop(void)
Stop the PDM peripheral.
void(* pdm_data_cb_t)(void *arg, int16_t *buf)
Signature for data received interrupt callback.
Definition pdm.h:69
pdm_mode_t
PDM operation modes.
Definition pdm.h:35
void pdm_start(void)
Start the PDM peripheral.
@ PDM_MODE_STEREO
Stereo mode.
Definition pdm.h:37
@ PDM_MODE_MONO
Mono mode.
Definition pdm.h:36
Interrupt context for a PDM device.
Definition pdm.h:75
pdm_data_cb_t cb
data received interrupt callback
Definition pdm.h:76
void * arg
context passed to the callback
Definition pdm.h:77