-
Notifications
You must be signed in to change notification settings - Fork 39
PDM library with examples #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Based on make file from PDM example from SDK, -larm_cortexM4l_math needs to be -larm_cortexM4lf_math
Cool! Looks like you solved the HAL exposure with
and similar for the MIC_DATA. I added a header file just for this called ap3_post_variant.h which is included after the variant to allow the variants definitions to override. |
I'm hesitant to build in ifndefs. They should be in the variant and if they're not, the compilation should throw some warning or fail. If we quietly assign pins it will likely lead to a lot of lost time by the person writing code . I can put the following in pdm.h
This compiles but currently platform.txt has the -w compiler setting which inhibits all warnings. Removing -w we get the following output which I think is pretty good: Which I think is awesome! Note that this output is limited to just our warning because my sketch is precompiled. If we recompile the entire system we get additional warnings, some of which are really interesting (I need to look into the ap3_analog.cpp warning). Do you know of a way to change compiler flags based on verbose selection? I don't think there's a way. So I'm on the fence as to whether we remove the -w flag from platform.txt. Exposing more scary output to the IDE is poor for a large number of users. |
… header if pins not defined.
This branch now removes -w flag so merge with caution. But it will let you see what the output looks like. |
Aha! Nice idea, and also I wonder if that could be why we did not get a warning about the lack of a return value? (However I feel like that should have been an error - anyway...) I'm fairly sure we can add a menu option that controls this behavior -- however maybe it is not necessary? If a user checks the 'verbose output' option then they likely are either advanced enough to understand or they have been instructed to do so in order to get the maximum amount of debug info for someone else. For now I will merge this PR because AFAIK all warnings will have been sorted out in the main branch. |
Ahh.... hmm I actually prefer removing the |
This adds PDM library support for the mics on the three main carriers (ATP, Nano, and R3) as well as the Edge2.
Library requires user to create an array and pass that array into the
.getData()
function. This allows the user to locally manipulate the PDM data once it has been obtained from DMA.Currently the library is only built for single channel mic setups.
I've included a few examples to demo how to get PDM working. The examples are not as simple as I'd like but the FFT function has to be there. Loudest freq works very well! Tested using https://www.szynalski.com/tone-generator/ and holding mic up to speaker.
This PR adds MIC_CLOCK and MIC_DATA to the carrier variant.h files so that the myPDM.begin() can be called without options. However, .begin can be called with Data and Clock pins (not pads) if the user has their own variant without MIC_CLOCK and MIC_DATA defined.
I'm not sure what the policy is on hiding HAL functions from sketches but the examples call
am_hal_interrupt_master_disable()
,am_hal_sysctrl_sleep(AM_HAL_SYSCTRL_SLEEP_DEEP)
, etc. We could repackage (redefine) these if we wanted but I'm okay leaving them as they are.