Skip to content

Commit 88454c2

Browse files
titouanckartben
authored andcommitted
boards: st: stm32f4_disco: add support for audio output
The stm32f4_disco board features an audio codec (cs43l22) connected to an audio jack (TRS) output, and to the stm32f4 via I2S and I2C. To set this up, several peripherals must be configured: - Enable I2S3 and the PLLI2S (tuned for 22.05/44.1/88.2 kHz audio) - Enable DMA1 (used by I2S3) - Enable I2C1, and add definition for the CS43L22 on the bus - Disable USART1 and CAN1 which have conflicting pinctrl with I2C1 This new setting is more appropriate, because this gives access to the audio jack output by default (instead of "bare" pins not connected to anything on the board). Signed-off-by: Titouan Christophe <moiandme@gmail.com>
1 parent d2818c4 commit 88454c2

File tree

3 files changed

+55
-17
lines changed

3 files changed

+55
-17
lines changed

boards/st/stm32f4_disco/doc/index.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ The Zephyr stm32f4_disco board configuration supports the following hardware fea
8989
+-----------+------------+-------------------------------------+
9090
| CAN | on-chip | CAN controller |
9191
+-----------+------------+-------------------------------------+
92+
| I2C | on-chip | i2c controller |
93+
+-----------+------------+-------------------------------------+
94+
| I2S | on-chip | i2s controller |
95+
+-----------+------------+-------------------------------------+
96+
| AUDIO | on-board | audio codec on CS43L22 via I2S3 |
97+
+-----------+------------+-------------------------------------+
9298

9399
.. note:: CAN feature requires CAN transceiver, such as `SK Pang CAN breakout board`_.
94100
Zephyr default configuration uses CAN_2 exclusively, as simultaneous use
@@ -113,8 +119,6 @@ Default Zephyr Peripheral Mapping:
113119

114120
.. rst-class:: rst-columns
115121

116-
- UART_1_TX : PB6
117-
- UART_1_RX : PB7
118122
- UART_2_TX : PA2
119123
- UART_2_RX : PA3
120124
- USER_PB : PA0
@@ -124,10 +128,14 @@ Default Zephyr Peripheral Mapping:
124128
- LD6 : PD15
125129
- USB DM : PA11
126130
- USB DP : PA12
127-
- CAN1_RX : PB8
128-
- CAN1_TX : PB9
129131
- CAN2_RX : PB5
130132
- CAN2_TX : PB13
133+
- I2C1_SDA : PB9
134+
- I2C1_SCL : PB6
135+
- I2S3_MCK : PC7
136+
- I2S3_CK : PC10
137+
- I2S3_SD : PC12
138+
- I2S3_WS : PA4
131139

132140
System Clock
133141
============

boards/st/stm32f4_disco/stm32f4_disco.dts

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,6 @@
8383
};
8484
};
8585

86-
&usart1 {
87-
pinctrl-0 = <&usart1_tx_pb6 &usart1_rx_pb7>;
88-
pinctrl-names = "default";
89-
current-speed = <115200>;
90-
status = "okay";
91-
};
92-
9386
&clk_lsi {
9487
status = "okay";
9588
};
@@ -159,12 +152,6 @@ zephyr_udc0: &usbotg_fs {
159152
status = "okay";
160153
};
161154

162-
&can1 {
163-
pinctrl-0 = <&can1_rx_pb8 &can1_tx_pb9>;
164-
pinctrl-names = "default";
165-
status = "disabled";
166-
};
167-
168155
&can2 {
169156
pinctrl-0 = <&can2_rx_pb5 &can2_tx_pb13>;
170157
pinctrl-names = "default";
@@ -187,3 +174,42 @@ zephyr_udc0: &usbotg_fs {
187174
&vbat {
188175
status = "okay";
189176
};
177+
178+
&dma1 {
179+
status = "okay";
180+
};
181+
182+
&plli2s {
183+
/* Minimize audio clock error (with i2s mck-enabled) for all of:
184+
* - 22.05kHz / 16b, 24b or 32b
185+
* - 44.1kHz / 16b, 24b or 32b
186+
* - 88.2kHz / 16b or 24b
187+
* Note: because the PLLI2S is dependent on the main PLL, the latter
188+
* should not be changed without checking impact on PLLI2S
189+
*/
190+
mul-n = <271>;
191+
div-r = <2>;
192+
status = "okay";
193+
};
194+
195+
&i2s3 {
196+
mck-enabled;
197+
pinctrl-0 = <&i2s3_ws_pa4 &i2s3_ck_pc10 &i2s3_sd_pc12 &i2s3_mck_pc7>;
198+
pinctrl-names = "default";
199+
clocks = <&rcc STM32_CLOCK(APB1, 15U)>,
200+
<&rcc STM32_SRC_PLLI2S_R I2S_SEL(0)>;
201+
status = "okay";
202+
};
203+
204+
&i2c1 {
205+
clock-frequency = <I2C_BITRATE_FAST>;
206+
pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb9>;
207+
pinctrl-names = "default";
208+
status = "okay";
209+
210+
audio_codec: cs43l22@4a {
211+
compatible = "cirrus,cs43l22";
212+
reg = <0x4a>;
213+
reset-gpios = <&gpiod 4 0>;
214+
};
215+
};

doc/releases/migration-guide-4.1.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ Boards
6767
always erase only the sectors of the external flash used by the new firmware,
6868
and the ``nrfutil`` one would always erase the whole external flash.
6969

70+
* CAN1 and USART1 have been disabled on the ``stm32f4_disco``, because of
71+
conflicting pinctrl on I2C1, which is now used to control the audio codec
72+
connected to the audio jack output.
73+
7074
Devicetree
7175
**********
7276

0 commit comments

Comments
 (0)