Skip to content
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

Implement a driver for the Microphone / audio sensor (MP23ABS1) in Sensotile.Box #32098

Closed
jimakos96 opened this issue Feb 8, 2021 · 5 comments
Assignees
Labels
area: Audio Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32

Comments

@jimakos96
Copy link

Is your feature request related to a problem? Please describe.
I would like to develop an application which can do audio sampling from the audio sensor in the Sensotile Box

Describe the solution you'd like
I simply like to use the Zephyr ADC API for audio receiving .

Describe alternatives you've considered
I tried to use the STM32HAL drivers functions for the ADC but i wasn't succesful

@erwango
Copy link
Member

erwango commented Feb 9, 2021

@jimakos96 I think this is already available using I2S. @avisconti do you confirm ?

@avisconti
Copy link
Collaborator

@jimakos96 I think this is already available using I2S. @avisconti do you confirm ?

Unfortnately not. Th Sensortile.box board has a MP23ABS1 microphone with an analog output. All the work I have done was on STM digital microphone with pdm output (like MP34DT05). In the latter case the pdm output can be interfaced to I2S and there is a sample here: zephyr/samples/shields/x_nucleo_iks02a1/microphone

In case of analog microphone I think that the only way is infact to use the ADC to convert from analog to digital, but I do not have much experience on it. So, it would be an interesting exercise for @jimakos96

@erwango
Copy link
Member

erwango commented Feb 9, 2021

@jimakos96 instead of the HAL driver, I'd suggest using the ADC zephyr driver

@jimakos96
Copy link
Author

ok I will try to implement it using the adc driver for getting audio out of the internal microphone .

@MaureenHelm MaureenHelm added area: Audio Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32 labels Feb 25, 2021
@jimakos96
Copy link
Author

jimakos96 commented Mar 31, 2021

Hello
I am trying to get some samples from the microphone using the zephyr adc driver using the following code

#include <zephyr.h>
#include <sys/printk.h>

#include <drivers/gpio.h>
#include <usb/usb_device.h>
#include <drivers/uart.h>
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

#include <drivers/adc.h>
#include <string.h>
uint16_t temp_data[8];

static const struct adc_channel_cfg channel_cfg_0 = {
.channel_id = 8,
};

const struct adc_sequence sequence = {
.channels = BIT(0),
.buffer = temp_data,
.buffer_size = sizeof(temp_data),
.resolution = 12,
};

void main(void)
{

if (usb_enable(NULL)) {
	return;
}
    int ret;
    const struct device *adc_dev = device_get_binding(DT_LABEL(DT_ALIAS(mic)));
    adc_channel_setup(adc_dev, &channel_cfg_0);

    while (1) {
            ret = adc_read(adc_dev, &sequence);
            if (ret != 0) {
                    printk("adc_read() failed with code %d", ret);
            } else {
                    printk("adc_read() value %d\n", temp_data[0]);
            }
    }

}

aliases {
mic= &adc1;
};
&adc1 {
pinctrl-0 = <&adc1_in8_pa3>;
status = "okay";
};

But i am not getting anything .In the board folder i have added the above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Audio Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32
Projects
None yet
Development

No branches or pull requests

4 participants