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

Add x_nucleo_cca02m1 microphone shield #17140

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions boards/arm/nucleo_f411re/Kconfig.defconfig
Expand Up @@ -34,4 +34,37 @@ config SPI_STM32_INTERRUPT

endif # SPI

if I2S

config I2S_STM32
default y

# configure PLLI2S to generate a I2SxCLK=128MHz
config I2S_STM32_USE_PLLI2S_ENABLE
default y

config I2S_STM32_PLLI2S_PLLM
default 8

config I2S_STM32_PLLI2S_PLLN
default 192

config I2S_STM32_PLLI2S_PLLR
default 3

config I2S_1
default y

config USE_STM32_LL_TIM
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If required, this should not be there.
A path like boards/shields/wnc_m14a2a/boards/frdm_k64f.conf would be best suited

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you mean something like that:
CONFIG_I2S_STM32=y
CONFIG_I2S_STM32_USE_PLLI2S_ENABLE=y
CONFIG_I2S_STM32_PLLI2S_PLLM=8
CONFIG_I2S_STM32_PLLI2S_PLLN=192
CONFIG_I2S_STM32_PLLI2S_PLLR=3
CONFIG_I2S_1=y
CONFIG_USE_STM32_LL_TIM=y
CONFIG_DMA_STM32F4X=y

I tried but there is one problem, i.e. CONFIG_USE_STM32_LL_TIM is a symbole with no
prompt, which means that can be set ONLY in a defconfig file. But I think that in shield it is not
possible to have defconfig, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As reported in sample file, main issue is that code proposed in sample is not using zephyr API and tries to access directly cube HAL.
Otherwise, most of this should be done in shield Kconfig.defconfig (which misses today and should be re-instantiated)

default y

endif # I2S

if DMA

config DMA_STM32F4X
default y

endif # DMA

endif # BOARD_NUCLEO_F411RE
8 changes: 8 additions & 0 deletions boards/arm/nucleo_f411re/nucleo_f411re.dts
Expand Up @@ -71,6 +71,14 @@ arduino_spi: &spi1 {
status = "okay";
};

arduino_i2s: &i2s1 {
status = "ok";
};

&timers3 {
status = "ok";
};

&rtc {
status = "okay";
};
8 changes: 8 additions & 0 deletions boards/arm/nucleo_f411re/pinmux.c
Expand Up @@ -40,6 +40,14 @@ static const struct pin_config pinconf[] = {
{STM32_PIN_PA6, STM32F4_PINMUX_FUNC_PA6_SPI1_MISO},
{STM32_PIN_PA7, STM32F4_PINMUX_FUNC_PA7_SPI1_MOSI},
#endif /* CONFIG_SPI_1 */
#ifdef CONFIG_I2S_1
{STM32_PIN_PA4, STM32F4_PINMUX_FUNC_PA4_I2S1_WS},
{STM32_PIN_PA5, STM32F4_PINMUX_FUNC_PA5_I2S1_CK},
{STM32_PIN_PA7, STM32F4_PINMUX_FUNC_PA7_I2S1_SD},
#endif /* CONFIG_I2S_1 */
/* TBD ???? */
{STM32_PIN_PB4, (STM32_PINMUX_ALT_FUNC_2 | STM32_PUSHPULL_NOPULL | STM32_OSPEEDR_VERY_HIGH_SPEED)},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you trying to do here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erwango
You touched the point. As I highlighted in the notes this changes to the board are not
proper and must be fixed. But I prepared the PR anyway so that it is evident what is my
intention.

Basically, to make the x_nucleo_cca02m1 shield working fine (and in both mono and
stereo mode) there are few things that must be configured, but the only way I found
was in the board itself, which is not proper.

The shield needs:

  • I2S configuration (PLL and so on)
  • DMA configuration
  • timer configuration for proper microphone clocking in stereo mode (timer generates clock which
    goes out on pins)

In this file the PB4 and PB5 are the pins where a 2x clock is generated using timer as explained
in AN5027.

I guess this part should be either in board/sheilds or in sample/shields.
Or maybe here under ifdef. Any suggestion?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any suggestion?

What about using gpio map and do this configuration inside the sample code?
define in dts:

gpio-d2 = <&arduino_header 7 0>;

Then, in sample code, use gpio-d2 generated define to do the gpio configuration?
This is basically what is done for cs-gpio for SPI controllers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avisconti , did you checked above proposal?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erwango, no, not yet.
I did try to understand the steps to do that looking at the example, but stopped after few
doubts. I'll be back on this later on.

{STM32_PIN_PB5, (STM32_PINMUX_ALT_FUNC_2 | STM32_PUSHPULL_NOPULL | STM32_OSPEEDR_VERY_HIGH_SPEED)},
};

static int pinmux_stm32_init(struct device *port)
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions boards/shields/x_nucleo_cca02m1/doc/index.rst
@@ -0,0 +1,54 @@
.. _x-nucleo-cca02m1:

X-NUCLEO-CCA02M1: Digital MEMS microphones shield for STM32 Nucleo
##################################################################

Overview
********
The X-NUCLEO-CCA02M1 is an evaluation board based on digital MEMS microphones
compatible with the ST morpho connector layout.
It has two microphones soldered onto the board and is compatible with digital microphone
coupon boards such as STEVAL-MKI129Vx and STEVAL-MKI155Vx.

The X-NUCLEO-CCA02M1 allows synchronized acquisition and streaming of up to 4
microphones through I2S, SPI or DFSDM peripherals.

.. image:: img/x-nucleo-cca02m1.jpg
:width: 340px
:height: 410px
:align: center
:alt: X-NUCLEO-CCA02M1

For more information about the board, see the `X-NUCLEO-CCA02M1 website`_

Hardware
********

X-NUCLEO-CCA02M1 provides the following key features:

- 2 x MP34DT01 on-board microphones
- 4 x header (3x2) to connect up to 4 external microphones
- Equipped with ST morpho connector
- Equipped with Arduino UNO R3 connector
- RoHS compliant


For more information about this shield, see the `X-NUCLEO-CCA02M1 data brief`_

Programming
***********

The X-NUCLEO-CCA02M1 can be connected to the SoC through I2S, SPI, or DFSDM peripherals,
but only I2S has been tested in Zephyr using a nucleo_f411re board.

References
**********

.. target-notes::

.. _X-NUCLEO-CCA02M1 website:
https://www.st.com/en/ecosystems/x-nucleo-cca02m1.html

.. _X-NUCLEO-CCA02M1 data brief:
https://www.st.com/resource/en/data_brief/x-nucleo-cca02m1.pdf

19 changes: 19 additions & 0 deletions boards/shields/x_nucleo_cca02m1/x_nucleo_cca02m1.overlay
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2019 STMicroelectronics
*
* SPDX-License-Identifier: Apache-2.0
*/

&arduino_i2s {
mp34dt01@0 {
compatible = "st,mpxxdtyy";
reg = <0>;
label = "MP34DT01";
};

mp34dt01@1 {
compatible = "st,mpxxdtyy";
reg = <1>;
label = "MP34DT01";
};
};