Skip to content

Commit e73637a

Browse files
Alexander Wachtercarlescufi
authored andcommitted
boards: stm: Add CAN support for stm32f072b micro controller
This commit adds the can device to the stm32f072b device tree and pinmux Signed-off-by: Alexander Wachter <[email protected]>
1 parent 2976ac3 commit e73637a

File tree

6 files changed

+49
-0
lines changed

6 files changed

+49
-0
lines changed

arch/arm/soc/st_stm32/stm32f0/dts.fixup

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
#define CONFIG_SPI_2_NAME ST_STM32_SPI_FIFO_40003800_LABEL
3737
#define CONFIG_SPI_2_IRQ ST_STM32_SPI_FIFO_40003800_IRQ_0
3838

39+
#define CONFIG_CAN_1_BASE_ADDRESS ST_STM32_CAN_40006400_BASE_ADDRESS
40+
#define CONFIG_CAN_1_BUS_SPEED ST_STM32_CAN_40006400_BUS_SPEED
41+
#define CONFIG_CAN_1_NAME ST_STM32_CAN_40006400_LABEL
42+
#define CONFIG_CAN_1_IRQ ST_STM32_CAN_40006400_IRQ_0
43+
#define CONFIG_CAN_1_IRQ_PRIORITY ST_STM32_CAN_40006400_IRQ_0_PRIORITY
44+
3945
#define FLASH_DEV_BASE_ADDRESS ST_STM32F0_FLASH_CONTROLLER_40022000_BASE_ADDRESS
4046
#define FLASH_DEV_NAME ST_STM32F0_FLASH_CONTROLLER_40022000_LABEL
4147

boards/arm/stm32f072b_disco/pinmux.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ static const struct pin_config pinconf[] = {
3232
{STM32_PIN_PB4, STM32F0_PINMUX_FUNC_PB4_SPI1_MISO},
3333
{STM32_PIN_PB5, STM32F0_PINMUX_FUNC_PB5_SPI1_MOSI},
3434
#endif /* CONFIG_SPI_1 */
35+
#ifdef CONFIG_CAN_1
36+
{STM32_PIN_PB8, STM32F0_PINMUX_FUNC_PB8_CAN_RX},
37+
{STM32_PIN_PB9, STM32F0_PINMUX_FUNC_PB9_CAN_TX},
38+
#endif /* CONFIG_CAN_1 */
39+
3540
};
3641

3742
static int pinmux_stm32_init(struct device *port)

boards/arm/stm32f072b_disco/stm32f072b_disco.dts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,10 @@
7474
&spi1 {
7575
status = "ok";
7676
};
77+
78+
&can1 {
79+
pinctrl-0 = <&can_pins_a>;
80+
pinctrl-names = "default";
81+
bus-speed = <250000>;
82+
status = "ok";
83+
};

drivers/pinmux/stm32/pinmux_stm32f0.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,13 @@
8888
#define STM32F0_PINMUX_FUNC_PC3_SPI2_MOSI \
8989
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL)
9090

91+
#define STM32F0_PINMUX_FUNC_PB8_CAN_RX \
92+
(STM32_PINMUX_ALT_FUNC_4 | STM32_PUSHPULL_NOPULL)
93+
#define STM32F0_PINMUX_FUNC_PB9_CAN_TX \
94+
(STM32_PINMUX_ALT_FUNC_4 | STM32_PUSHPULL_NOPULL)
95+
#define STM32F0_PINMUX_FUNC_PD0_CAN_RX \
96+
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUPDR_PULL_UP)
97+
#define STM32F0_PINMUX_FUNC_PD1_CAN_TX \
98+
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL)
99+
91100
#endif /* _STM32F0_PINMUX_H_ */

dts/arm/st/stm32f0-pinctrl.dtsi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@
3939
tx = <STM32_PIN_PD5 (STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL)>;
4040
};
4141
};
42+
can_pins_a: can@0 {
43+
rx_tx {
44+
rx = <STM32_PIN_PB8 (STM32_PINMUX_ALT_FUNC_4 | STM32_PUPDR_PULL_UP)>;
45+
tx = <STM32_PIN_PB9 (STM32_PINMUX_ALT_FUNC_4 | STM32_PUPDR_NO_PULL)>;
46+
};
47+
};
48+
can_pins_b: can@1 {
49+
rx_tx {
50+
rx = <STM32_PIN_PD0 (STM32_PINMUX_ALT_FUNC_0 | STM32_PUPDR_PULL_UP)>;
51+
tx = <STM32_PIN_PD1 (STM32_PINMUX_ALT_FUNC_0 | STM32_PUPDR_NO_PULL)>;
52+
};
53+
};
4254
};
4355
};
4456
};

dts/arm/st/stm32f072.dtsi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,15 @@
4242
status = "disabled";
4343
label= "USB";
4444
};
45+
46+
can1: can@40006400 {
47+
compatible = "st,stm32-can";
48+
#address-cells = <1>;
49+
#size-cells = <0>;
50+
reg = <0x40006400 0x400>;
51+
interrupts = <30 0>;
52+
status = "disabled";
53+
label = "CAN_1";
54+
};
4555
};
4656
};

0 commit comments

Comments
 (0)