Skip to content

Commit 463bf57

Browse files
authored
Merge pull request #475 from tgruetzm/PDM_end
added end method to PDM to facilitate stopping PDM
2 parents 9f3dc4d + 3cf3611 commit 463bf57

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Diff for: libraries/PDM/src/PDM.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,26 @@ bool AP3_PDM::begin(pin_size_t pinPDMData, pin_size_t pinPDMClock)
3737
return (true);
3838
}
3939

40+
bool AP3_PDM::end()
41+
{
42+
uint32_t retval = am_hal_pdm_disable(_PDMhandle);
43+
if (retval != AP3_OK)
44+
{
45+
return false;
46+
}
47+
retval = (uint32_t)am_hal_pdm_power_control(_PDMhandle, AM_HAL_PDM_POWER_OFF, false);
48+
if (retval != AP3_OK)
49+
{
50+
return retval;
51+
}
52+
retval = am_hal_pdm_deinitialize(_PDMhandle);
53+
if (retval != AP3_OK)
54+
{
55+
return false;
56+
}
57+
return true;
58+
}
59+
4060
bool AP3_PDM::available(void)
4161
{
4262
if (buff1New || buff2New)

Diff for: libraries/PDM/src/PDM.h

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class AP3_PDM
9696
//AP3_PDM(uint16_t *userBuffer, uint32_t bufferSize);
9797

9898
bool begin(pin_size_t pinPDMData = MIC_DATA, pin_size_t pinPDMClock = MIC_CLOCK);
99+
bool end();
99100
bool available(void); //Goes true if circular buffer is not empty
100101
bool isOverrun(void); //Goes true if head crosses tail
101102

0 commit comments

Comments
 (0)