Skip to content

Commit 61336cf

Browse files
NeilChen93henrikbrixandersen
authored andcommitted
boards: nxp/frdm_mcxn236: Support Flexcan for NXP frdm_mcxn236 board
Support Flexcan for NXP frdm_mcxn236 board Signed-off-by: Neil Chen <[email protected]>
1 parent bb76262 commit 61336cf

File tree

6 files changed

+49
-0
lines changed

6 files changed

+49
-0
lines changed

boards/nxp/frdm_mcxn236/board.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,27 @@ static int frdm_mcxn236_init(void)
8888
/* Set AHBCLKDIV divider to value 1 */
8989
CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U);
9090

91+
CLOCK_SetupExtClocking(BOARD_XTAL0_CLK_HZ);
92+
93+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcan1))
94+
/* Set up PLL1 for 80 MHz FlexCAN clock */
95+
const pll_setup_t pll1Setup = {
96+
.pllctrl = SCG_SPLLCTRL_SOURCE(1U) | SCG_SPLLCTRL_SELI(27U) |
97+
SCG_SPLLCTRL_SELP(13U),
98+
.pllndiv = SCG_SPLLNDIV_NDIV(3U),
99+
.pllpdiv = SCG_SPLLPDIV_PDIV(1U),
100+
.pllmdiv = SCG_SPLLMDIV_MDIV(10U),
101+
.pllRate = 80000000U
102+
};
103+
104+
/* Configure PLL1 to the desired values */
105+
CLOCK_SetPLL1Freq(&pll1Setup);
106+
/* PLL1 Monitor is disabled */
107+
CLOCK_SetPll1MonitorMode(kSCG_Pll1MonitorDisable);
108+
/* Set PLL1 CLK0 divider to value 1 */
109+
CLOCK_SetClkDiv(kCLOCK_DivPLL1Clk0, 1U);
110+
#endif
111+
91112
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm1))
92113
CLOCK_SetClkDiv(kCLOCK_DivFlexcom1Clk, 1u);
93114
CLOCK_AttachClk(kFRO12M_to_FLEXCOMM1);
@@ -170,6 +191,11 @@ static int frdm_mcxn236_init(void)
170191
CLOCK_AttachClk(kPLL0_to_CTIMER4);
171192
#endif
172193

194+
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcan1))
195+
CLOCK_SetClkDiv(kCLOCK_DivFlexcan1Clk, 1U);
196+
CLOCK_AttachClk(kPLL1_CLK0_to_FLEXCAN1);
197+
#endif
198+
173199
#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(vref))
174200
CLOCK_EnableClock(kCLOCK_Vref);
175201
SPC_EnableActiveModeAnalogModules(SPC0, kSPC_controlVref);

boards/nxp/frdm_mcxn236/doc/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ The FRDM-MCXN236 board configuration supports the following hardware features:
7474
+-----------+------------+-------------------------------------+
7575
| LPCMP | on-chip | sensor(comparator) |
7676
+-----------+------------+-------------------------------------+
77+
| FLEXCAN | on-chip | CAN |
78+
+-----------+------------+-------------------------------------+
7779

7880
Targets available
7981
==================

boards/nxp/frdm_mcxn236/frdm_mcxn236-pinctrl.dtsi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,14 @@
109109
bias-pull-up;
110110
};
111111
};
112+
113+
pinmux_flexcan1: pinmux_flexcan1 {
114+
group0 {
115+
pinmux = <CAN1_TXD_PIO4_16>,
116+
<CAN1_RXD_PIO4_15>;
117+
slew-rate = "fast";
118+
drive-strength = "low";
119+
input-enable;
120+
};
121+
};
112122
};

boards/nxp/frdm_mcxn236/frdm_mcxn236.dts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
zephyr,uart-mcumgr = &flexcomm4_lpuart4;
2222
zephyr,console = &flexcomm4_lpuart4;
2323
zephyr,shell-uart = &flexcomm4_lpuart4;
24+
zephyr,canbus = &flexcan1;
2425
};
2526

2627
aliases{
@@ -110,6 +111,10 @@
110111
status = "okay";
111112
};
112113

114+
&flexcan1 {
115+
status = "okay";
116+
};
117+
113118
&ctimer0 {
114119
status = "okay";
115120
};

boards/nxp/frdm_mcxn236/frdm_mcxn236.dtsi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,8 @@
128128
pinctrl-0 = <&pinmux_lpcmp0>;
129129
pinctrl-names = "default";
130130
};
131+
132+
&flexcan1 {
133+
pinctrl-0 = <&pinmux_flexcan1>;
134+
pinctrl-names = "default";
135+
};

boards/nxp/frdm_mcxn236/frdm_mcxn236.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ toolchain:
1515
- gnuarmemb
1616
- xtools
1717
supported:
18+
- can
1819
- dma
1920
- gpio
2021
- spi

0 commit comments

Comments
 (0)