Skip to content

Commit b4ada0d

Browse files
joerchancarlescufi
authored andcommitted
samples: stm32: mco: Add disco board which has 2 MCO instances
Add stm32f746g_disco board to MCO sample. This board has 2 MCO instances so useful to show multiple instances as well as checking the implementation. Signed-off-by: Joakim Andersson <[email protected]>
1 parent 438ed89 commit b4ada0d

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/* The clock that is output must be enabled. */
2+
&clk_lse {
3+
status = "okay";
4+
};
5+
6+
&clk_hse {
7+
status = "okay";
8+
};
9+
10+
/* See reference manual (RM0385):
11+
* 0b01: LSE oscillator selected
12+
*/
13+
#define MCO1_SEL_LSE 1
14+
15+
/* See reference manual (RM0385):
16+
* 0b100: division by 2
17+
*/
18+
#define MCO1_PRE_DIV_2 4
19+
20+
&mco1 {
21+
status = "okay";
22+
clocks = <&rcc STM32_SRC_LSE MCO1_SEL(MCO1_SEL_LSE)>;
23+
prescaler = <MCO1_PRE(MCO1_PRE_DIV_2)>;
24+
pinctrl-0 = <&rcc_mco_1_pa8>; /* D10 (CN7) */
25+
pinctrl-names = "default";
26+
};
27+
28+
/* See reference manual (RM0385):
29+
* 0b10: HSE oscillator clock selected
30+
*/
31+
#define MCO2_SEL_HSE 2
32+
33+
/* See reference manual (RM0385):
34+
* 0b111: division by 5
35+
*/
36+
#define MCO2_PRE_DIV_5 7
37+
38+
&mco2 {
39+
status = "okay";
40+
clocks = <&rcc STM32_SRC_HSE MCO2_SEL(MCO2_SEL_HSE)>;
41+
prescaler = <MCO2_PRE(MCO2_PRE_DIV_5)>;
42+
pinctrl-0 = <&rcc_mco_2_pc9>; /* uSD_D1 (CN3 pin 8) */
43+
pinctrl-names = "default";
44+
};

samples/boards/st/mco/sample.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ sample:
22
name: STM32 microcontroller clock output (MCO) example
33
tests:
44
sample.board.stm32.mco:
5-
platform_allow: nucleo_u5a5zj_q
5+
platform_allow: nucleo_u5a5zj_q stm32f746g_disco
66
tags: board

samples/boards/st/mco/src/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ int main(void)
2525
return -1;
2626
}
2727

28+
#if DT_NODE_HAS_STATUS(DT_NODELABEL(mco2), okay)
29+
dev = DEVICE_DT_GET(DT_NODELABEL(mco2));
30+
if (device_is_ready(dev)) {
31+
printk("MCO2 device successfully configured\n");
32+
} else {
33+
printk("MCO2 device not ready\n");
34+
return -1;
35+
}
36+
#endif
37+
2838
printk("\nDisplayed the status of all MCO devices - end of example.\n");
2939
return 0;
3040
}

0 commit comments

Comments
 (0)