Skip to content

Commit 9a78b01

Browse files
committed
[NUCLEO_F303RE] Added CAN support
Added CAN API support for NUCLEO_F303RE target. *stm32f303xe.h* file was changed to avoid compilation errors. Change-Id: Ia6519c982261d43165dbce73cab7cfc0617474e2
1 parent 656d195 commit 9a78b01

File tree

9 files changed

+41
-10
lines changed

9 files changed

+41
-10
lines changed

hal/targets/cmsis/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/stm32f303xe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ typedef struct
924924
#define UART5 ((USART_TypeDef *) UART5_BASE)
925925
#define I2C1 ((I2C_TypeDef *) I2C1_BASE)
926926
#define I2C2 ((I2C_TypeDef *) I2C2_BASE)
927-
#define CAN ((CAN_TypeDef *) CAN_BASE)
927+
#define CAN1 ((CAN_TypeDef *) CAN_BASE)
928928
#define PWR ((PWR_TypeDef *) PWR_BASE)
929929
#define DAC ((DAC_TypeDef *) DAC_BASE)
930930
#define DAC1 ((DAC_TypeDef *) DAC1_BASE)

hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/PeripheralNames.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ typedef enum {
8282
PWM_17 = (int)TIM17_BASE
8383
} PWMName;
8484

85+
typedef enum {
86+
CAN_1 = (int)CAN_BASE
87+
} CANName;
88+
8589
#ifdef __cplusplus
8690
}
8791
#endif

hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/PeripheralPins.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,15 @@ const PinMap PinMap_SPI_SSEL[] = {
255255
{PF_0, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
256256
{NC, NC, 0}
257257
};
258+
259+
const PinMap PinMap_CAN_RD[] = {
260+
{PB_8 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
261+
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
262+
{NC, NC, 0}
263+
};
264+
265+
const PinMap PinMap_CAN_TD[] = {
266+
{PB_9 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
267+
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
268+
{NC, NC, 0}
269+
};

hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/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_STM32F3/TARGET_NUCLEO_F303RE/objects.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ struct pwmout_s {
106106
uint32_t inverted;
107107
};
108108

109+
struct can_s {
110+
CANName can;
111+
int index;
112+
};
113+
109114
#include "gpio_object.h"
110115

111116
#ifdef __cplusplus

libraries/tests/mbed/can/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ CAN can1(D2, D3);
1515
// B96B_F446VE support only single CAN channel
1616
CAN can1(PD_0, PD_1);
1717
#elif defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F072RB) || \
18-
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8)
18+
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
19+
defined(TARGET_NUCLEO_F303RE)
1920
CAN can1(PA_11, PA_12);
2021
#else
2122
CAN can1(p9, p10);
@@ -53,7 +54,8 @@ int main() {
5354
while(1) {
5455
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && \
5556
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
56-
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8))
57+
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
58+
!defined(TARGET_NUCLEO_F303RE))
5759
printf("loop()\n");
5860
if(can2.read(msg)) {
5961
printmsg("Rx message:", &msg);

libraries/tests/mbed/can_interrupt/main.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ CAN can1(D2, D3);
1515
// B96B_F446VE support only single CAN channel
1616
CAN can1(PD_0, PD_1);
1717
#elif defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F072RB) || \
18-
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8)
18+
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
19+
defined(TARGET_NUCLEO_F303RE)
1920
CAN can1(PA_11, PA_12);
2021
#else
2122
CAN can1(p9, p10);
@@ -48,7 +49,8 @@ void send() {
4849

4950
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && \
5051
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
51-
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8))
52+
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
53+
!defined(TARGET_NUCLEO_F303RE))
5254
void read() {
5355
CANMessage msg;
5456
printf("rx()\n");
@@ -64,7 +66,8 @@ int main() {
6466
ticker.attach(&send, 1);
6567
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && \
6668
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
67-
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8))
69+
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
70+
!defined(TARGET_NUCLEO_F303RE))
6871
can2.attach(&read);
6972
#endif
7073
while(1) {

libraries/tests/mbed/can_loopback/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ CAN can1(PD_0, PD_1);
1414
#elif defined(TARGET_VK_RZ_A1H)
1515
CAN can1(P5_9, P5_10);
1616
#elif defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F072RB) || \
17-
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8)
17+
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
18+
defined(TARGET_NUCLEO_F303RE)
1819
CAN can1(PA_11, PA_12);
1920
#endif
2021

workspace_tools/tests.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
* NUCLEO_F072RB: (RX=PA_11, TX=PA_12)
9696
* NUCLEO_F042K6: (RX=PA_11, TX=PA_12)
9797
* NUCLEO_F334R8: (RX=PA_11, TX=PA_12)
98+
* NUCLEO_F303RE: (RX=PA_11, TX=PA_12)
9899
99100
"""
100101
TESTS = [
@@ -301,7 +302,8 @@
301302
"duration": 20,
302303
"peripherals": ["can_transceiver"],
303304
"mcu": ["LPC1549", "LPC1768","B96B_F446VE", "VK_RZ_A1H",
304-
"NUCLEO_F091RC", "NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8"],
305+
"NUCLEO_F091RC", "NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8",
306+
"NUCLEO_F303RE"],
305307
},
306308
{
307309
"id": "MBED_BLINKY", "description": "Blinky",
@@ -573,14 +575,14 @@
573575
"source_dir": join(TEST_DIR, "mbed", "can"),
574576
"dependencies": [MBED_LIBRARIES],
575577
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
576-
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8"]
578+
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE"]
577579
},
578580
{
579581
"id": "MBED_30", "description": "CAN network test using interrupts",
580582
"source_dir": join(TEST_DIR, "mbed", "can_interrupt"),
581583
"dependencies": [MBED_LIBRARIES],
582584
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
583-
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8"]
585+
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE"]
584586
},
585587
{
586588
"id": "MBED_31", "description": "PWM LED test",

0 commit comments

Comments
 (0)