Skip to content

Commit e9ab4b6

Browse files
authored
Merge pull request #1 from grobx-stm/main
Add support for MP23DB01HP
2 parents fd3e5bb + 6e0ea58 commit e9ab4b6

12 files changed

Lines changed: 967 additions & 0 deletions
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: STEVAL-Examples Continuous Integration
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- '*'
8+
- '**.md'
9+
- '**.txt'
10+
pull_request:
11+
paths-ignore:
12+
- '*'
13+
- '**.md'
14+
- '**.txt'
15+
jobs:
16+
astyle_check:
17+
runs-on: ubuntu-latest
18+
name: AStyle check
19+
steps:
20+
# First of all, clone the repo using the checkout action.
21+
- name: Checkout
22+
uses: actions/checkout@main
23+
24+
- name: Astyle check
25+
id: Astyle
26+
uses: stm32duino/actions/astyle-check@main
27+
28+
# Use the output from the `Astyle` step
29+
- name: Astyle Errors
30+
if: failure()
31+
run: |
32+
cat ${{ steps.Astyle.outputs.astyle-result }}
33+
exit 1
34+
spell-check:
35+
runs-on: ubuntu-latest
36+
name: Spell check
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v2
40+
41+
- name: Spell check
42+
uses: codespell-project/actions-codespell@master
43+
with:
44+
ignore_words_file: ./extras/codespell-ignore-words-list.txt
45+
# lib_build:
46+
# runs-on: ubuntu-latest
47+
# name: Library compilation
48+
# steps:
49+
50+
# # First of all, clone the repo using the checkout action.
51+
# - name: Checkout
52+
# uses: actions/checkout@main
53+
54+
# - name: Compilation
55+
# id: compile
56+
# uses: stm32duino/actions/compile-examples@main
57+
# with:
58+
# board-pattern: "NUCLEO_L476RG"
59+
60+
# # Use the output from the `Compilation` step
61+
# - name: Compilation Errors
62+
# if: failure()
63+
# run: |
64+
# cat ${{ steps.compile.outputs.compile-result }}
65+
# exit 1

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# STEVAL Audio
2+
3+
Arduino library to support the [MP23DB01HP](https://www.st.com/en/mems-and-sensors/mp23db01hp.html) digital microphone.
4+
Currently, this library works only with the STEVAL board.
5+
It requires a [STM32 Core](https://github.com/stm32duino/Arduino_Core_STM32) equal to or greater than version X.Y.Z.
6+
7+
## API
8+
9+
This library can be used to record PCM audio on STEVAL board.
10+
11+
After including `PCM.h`, initialize the library by calling `PCM.Begin`:
12+
13+
```cpp
14+
#include <PCM.h>
15+
16+
void setup()
17+
{
18+
// [...]
19+
PCM.Begin();
20+
// [...]
21+
}
22+
```
23+
24+
Register the data processing callback using `PCM.OnReceive`:
25+
26+
```cpp
27+
void process()
28+
{
29+
Serial.write((const uint8_t *)RecBuff, PCM_REC_BUFF_SIZE * 2U);
30+
}
31+
32+
void setup()
33+
{
34+
// [...]
35+
PCM.OnReceive(process);
36+
// [...]
37+
}
38+
```
39+
40+
Start recording PCM audio by passing a non-null pointer of a `uint16_t[PCM_REC_BUFF_SIZE]` buffer to `PCM.Record`:
41+
42+
```cpp
43+
uint16_t RecBuff[PCM_REC_BUFF_SIZE];
44+
45+
void setup()
46+
{
47+
// [...]
48+
PCM.Record(RecvBuff);
49+
// [...]
50+
}
51+
```
52+
53+
You can pause a recording by calling `PCM.Pause`; in order to resume it, just call `PCM.Resume`:
54+
55+
```cpp
56+
void loop()
57+
{
58+
// [...]
59+
if (cmd == '1') PCM.Pause();
60+
if (cmd == '2') PCM.Resume();
61+
// [...]
62+
}
63+
```
64+
65+
In order to deinitialize the library, you can execute `PCM.End` (if recording, you need first to stop it):
66+
67+
```cpp
68+
void loop()
69+
{
70+
// [...]
71+
if (cmd == '3') {
72+
if (PCM.GetState() == PCM_AUDIO_IN_STATE_RECORDING) PCM.Stop();
73+
PCM.End();
74+
while(1);
75+
}
76+
// [...]
77+
}
78+
```
79+
80+
## More Info
81+
82+
Source files can be found at
83+
https://github.com/stm32duino/STEVAL-Audio
84+
85+
Take a look at STEVAL examples applications at
86+
https://github.com/stm32duino/STEVAL-Examples

extras/codespell-ignore-words-list.txt

Whitespace-only changes.

keywords.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#######################################
2+
# Syntax Coloring Map For STEVAL-Audio
3+
#######################################
4+
5+
#######################################
6+
# Datatypes (KEYWORD1)
7+
#######################################
8+
9+
PCM KEYWORD1
10+
11+
#######################################
12+
# Methods and Functions (KEYWORD2)
13+
#######################################
14+
15+
Begin KEYWORD2
16+
End KEYWORD2
17+
SetVolume KEYWORD2
18+
GetVolume KEYWORD2
19+
GetState KEYWORD2
20+
OnReceive KEYWORD2
21+
Record KEYWORD2
22+
Pause KEYWORD2
23+
Resume KEYWORD2
24+
Stop KEYWORD2
25+
26+
#######################################
27+
# Constants (LITERAL1)
28+
#######################################
29+
30+
PCM_OK LITERAL1
31+
PCM_ERROR LITERAL1
32+
PCM_REC_BUFF_SIZE LITERAL1
33+
PCM_AUDIO_IN_STATE_RESET LITERAL1
34+
PCM_AUDIO_IN_STATE_STOP LITERAL1
35+
PCM_AUDIO_IN_STATE_RECORDING LITERAL1
36+
PCM_AUDIO_IN_STATE_PAUSE LITERAL1
37+
PCM_AUDIO_IN_STATE_ERROR LITERAL1

library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=STM32duino STEVAL Audio
2+
version=1.0.0
3+
author=SRA
4+
maintainer=stm32duino
5+
sentence=PCM recording using digital microphone MP23DB01HP on STEVAL.
6+
paragraph=This library provides Arduino support for the MP23DB01HP digital microphone on STM32 STEVAL board.
7+
category=Sensors
8+
url=https://github.com/stm32duino/STEVAL-Audio
9+
architectures=stm32

0 commit comments

Comments
 (0)