Skip to content

Commit 96787cd

Browse files
committed
[NUCLEO_F446RE] Added CAN support
Added CAN API support for NUCLEO_F446RE target. Change-Id: I6e585fd5ef9e5395c1dc5b9c31d09427927a0021
1 parent bddce7c commit 96787cd

File tree

8 files changed

+39
-6
lines changed

8 files changed

+39
-6
lines changed

hal/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F446RE/PeripheralNames.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ typedef enum {
8787
PWM_14 = (int)TIM14_BASE
8888
} PWMName;
8989

90+
typedef enum {
91+
CAN_1 = (int)CAN1_BASE,
92+
CAN_2 = (int)CAN2_BASE
93+
} CANName;
94+
9095
#ifdef __cplusplus
9196
}
9297
#endif

hal/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F446RE/PeripheralPins.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,19 @@ const PinMap PinMap_SPI_SSEL[] = {
232232
{PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)},
233233
{NC, NC, 0}
234234
};
235+
236+
const PinMap PinMap_CAN_RD[] = {
237+
{PB_8, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
238+
{PB_12, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
239+
{PB_5 , CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
240+
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
241+
{NC, NC, 0}
242+
};
243+
244+
const PinMap PinMap_CAN_TD[] = {
245+
{PB_9, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
246+
{PB_13, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
247+
{PB_6 , CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
248+
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
249+
{NC, NC, 0}
250+
};

hal/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F446RE/device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454

5555
#define DEVICE_SLEEP 1
5656

57+
#define DEVICE_CAN 1
58+
5759
//=======================================
5860

5961
#define DEVICE_SEMIHOST 0

hal/targets/hal/TARGET_STM/TARGET_STM32F4/TARGET_NUCLEO_F446RE/objects.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ struct pwmout_s {
104104
uint8_t inverted;
105105
};
106106

107+
struct can_s {
108+
CANName can;
109+
int index;
110+
};
111+
107112
#include "gpio_object.h"
108113

109114
#ifdef __cplusplus

libraries/tests/mbed/can/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CAN can1(PD_0, PD_1);
1717
#elif defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F072RB) || \
1818
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
1919
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
20-
defined(TARGET_NUCLEO_F302R8)
20+
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE)
2121
CAN can1(PA_11, PA_12);
2222
#else
2323
CAN can1(p9, p10);
@@ -27,6 +27,8 @@ CAN can1(p9, p10);
2727
CAN can2(p34, p33);
2828
#elif defined (TARGET_LPC1768)
2929
CAN can2(p30, p29);
30+
#elif defined(TARGET_NUCLEO_F446RE)
31+
CAN can2(PB_5, PB_6);
3032
#endif
3133
char counter = 0;
3234

libraries/tests/mbed/can_interrupt/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CAN can1(PD_0, PD_1);
1717
#elif defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F072RB) || \
1818
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
1919
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
20-
defined(TARGET_NUCLEO_F302R8)
20+
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE)
2121
CAN can1(PA_11, PA_12);
2222
#else
2323
CAN can1(p9, p10);
@@ -27,6 +27,8 @@ CAN can1(p9, p10);
2727
CAN can2(p34, p33);
2828
#elif defined (TARGET_LPC1768)
2929
CAN can2(p30, p29);
30+
#elif defined(TARGET_NUCLEO_F446RE)
31+
CAN can2(PB_5, PB_6);
3032
#endif
3133
char counter = 0;
3234

libraries/tests/mbed/can_loopback/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CAN can1(P5_9, P5_10);
1616
#elif defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F072RB) || \
1717
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
1818
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
19-
defined(TARGET_NUCLEO_F302R8)
19+
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE)
2020
CAN can1(PA_11, PA_12);
2121
#endif
2222

workspace_tools/tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
* NUCLEO_F303RE: (RX=PA_11, TX=PA_12)
9999
* NUCLEO_F303K8: (RX=PA_11, TX=PA_12)
100100
* NUCLEO_F302R8: (RX=PA_11, TX=PA_12)
101+
* NUCLEO_F446RE: (RX=PA_11, TX=PA_12)
101102
102103
"""
103104
TESTS = [
@@ -305,7 +306,7 @@
305306
"peripherals": ["can_transceiver"],
306307
"mcu": ["LPC1549", "LPC1768","B96B_F446VE", "VK_RZ_A1H",
307308
"NUCLEO_F091RC", "NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8",
308-
"NUCLEO_F303RE", "NUCLEO_F303K8", "NUCLEO_F302R8"],
309+
"NUCLEO_F303RE", "NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE"],
309310
},
310311
{
311312
"id": "MBED_BLINKY", "description": "Blinky",
@@ -578,15 +579,15 @@
578579
"dependencies": [MBED_LIBRARIES],
579580
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
580581
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE",
581-
"NUCLEO_F303K8", "NUCLEO_F302R8"]
582+
"NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE"]
582583
},
583584
{
584585
"id": "MBED_30", "description": "CAN network test using interrupts",
585586
"source_dir": join(TEST_DIR, "mbed", "can_interrupt"),
586587
"dependencies": [MBED_LIBRARIES],
587588
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
588589
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE",
589-
"NUCLEO_F303K8", "NUCLEO_F302R8"]
590+
"NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE"]
590591
},
591592
{
592593
"id": "MBED_31", "description": "PWM LED test",

0 commit comments

Comments
 (0)