Skip to content

Commit d140e99

Browse files
committed
[NUCLEO_F072RB] Added CAN support
Added CAN API support for NUCLEO_F072RB target. *stm32f072xb.h* file was changed to avoid compilation errors. Change-Id: I9da75fde29fd19f0326d554acc1dbb5386b08317
1 parent 8577163 commit d140e99

File tree

9 files changed

+39
-10
lines changed

9 files changed

+39
-10
lines changed

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F072RB/stm32f072xb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ typedef struct
732732
#define USART4 ((USART_TypeDef *) USART4_BASE)
733733
#define I2C1 ((I2C_TypeDef *) I2C1_BASE)
734734
#define I2C2 ((I2C_TypeDef *) I2C2_BASE)
735-
#define CAN ((CAN_TypeDef *) CAN_BASE)
735+
#define CAN1 ((CAN_TypeDef *) CAN_BASE)
736736
#define CRS ((CRS_TypeDef *) CRS_BASE)
737737
#define PWR ((PWR_TypeDef *) PWR_BASE)
738738
#define DAC ((DAC_TypeDef *) DAC_BASE)

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F072RB/PeripheralNames.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ typedef enum {
7575
PWM_17 = (int)TIM17_BASE
7676
} PWMName;
7777

78+
typedef enum {
79+
CAN_1 = (int)CAN_BASE
80+
} CANName;
81+
7882
#ifdef __cplusplus
7983
}
8084
#endif

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F072RB/PeripheralPins.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,3 +196,15 @@ const PinMap PinMap_SPI_SSEL[] = {
196196
{PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)},
197197
{NC, NC, 0}
198198
};
199+
200+
const PinMap PinMap_CAN_RD[] = {
201+
{PB_8 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF4_CAN)},
202+
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF4_CAN)},
203+
{NC, NC, 0}
204+
};
205+
206+
const PinMap PinMap_CAN_TD[] = {
207+
{PB_9 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF4_CAN)},
208+
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF4_CAN)},
209+
{NC, NC, 0}
210+
};

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F072RB/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

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F072RB/objects.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ struct pwmout_s {
100100
uint32_t pulse;
101101
};
102102

103+
struct can_s {
104+
CANName can;
105+
int index;
106+
};
107+
103108
#include "gpio_object.h"
104109

105110
#ifdef __cplusplus

libraries/tests/mbed/can/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CAN can1(D2, D3);
1414
#elif defined(TARGET_B96B_F446VE)
1515
// B96B_F446VE support only single CAN channel
1616
CAN can1(PD_0, PD_1);
17-
#elif defined(TARGET_NUCLEO_F091RC)
17+
#elif defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F072RB)
1818
CAN can1(PA_11, PA_12);
1919
#else
2020
CAN can1(p9, p10);
@@ -50,7 +50,8 @@ int main() {
5050
ticker.attach(&send, 1);
5151
CANMessage msg;
5252
while(1) {
53-
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && !defined(TARGET_NUCLEO_F091RC))
53+
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && \
54+
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB))
5455
printf("loop()\n");
5556
if(can2.read(msg)) {
5657
printmsg("Rx message:", &msg);

libraries/tests/mbed/can_interrupt/main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CAN can1(D2, D3);
1414
#elif defined(TARGET_B96B_F446VE)
1515
// B96B_F446VE support only single CAN channel
1616
CAN can1(PD_0, PD_1);
17-
#elif defined(TARGET_NUCLEO_F091RC)
17+
#elif defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F072RB)
1818
CAN can1(PA_11, PA_12);
1919
#else
2020
CAN can1(p9, p10);
@@ -45,7 +45,8 @@ void send() {
4545
led1 = !led1;
4646
}
4747

48-
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && !defined(TARGET_NUCLEO_F091RC))
48+
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && \
49+
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB))
4950
void read() {
5051
CANMessage msg;
5152
printf("rx()\n");
@@ -59,7 +60,8 @@ void read() {
5960
int main() {
6061
printf("main()\n");
6162
ticker.attach(&send, 1);
62-
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && !defined(TARGET_NUCLEO_F091RC))
63+
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && \
64+
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB))
6365
can2.attach(&read);
6466
#endif
6567
while(1) {

libraries/tests/mbed/can_loopback/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ CAN can1(p9, p10);
1313
CAN can1(PD_0, PD_1);
1414
#elif defined(TARGET_VK_RZ_A1H)
1515
CAN can1(P5_9, P5_10);
16-
#elif defined(TARGET_NUCLEO_F091RC)
16+
#elif defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F072RB)
1717
CAN can1(PA_11, PA_12);
1818
#endif
1919

workspace_tools/tests.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
* LPC4088: (RX=p9, TX=p10)
9393
* VK_RZ_A1H:(RX=P5_9, TX=P5_10)
9494
* NUCLEO_F091RC: (RX=PA_11, TX=PA_12)
95+
* NUCLEO_F072RB: (RX=PA_11, TX=PA_12)
9596
9697
"""
9798
TESTS = [
@@ -298,7 +299,7 @@
298299
"duration": 20,
299300
"peripherals": ["can_transceiver"],
300301
"mcu": ["LPC1549", "LPC1768","B96B_F446VE", "VK_RZ_A1H",
301-
"NUCLEO_F091RC"],
302+
"NUCLEO_F091RC", "NUCLEO_F072RB"],
302303
},
303304
{
304305
"id": "MBED_BLINKY", "description": "Blinky",
@@ -569,13 +570,15 @@
569570
"id": "MBED_29", "description": "CAN network test",
570571
"source_dir": join(TEST_DIR, "mbed", "can"),
571572
"dependencies": [MBED_LIBRARIES],
572-
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC"]
573+
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
574+
"NUCLEO_F072RB"]
573575
},
574576
{
575577
"id": "MBED_30", "description": "CAN network test using interrupts",
576578
"source_dir": join(TEST_DIR, "mbed", "can_interrupt"),
577579
"dependencies": [MBED_LIBRARIES],
578-
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC"]
580+
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
581+
"NUCLEO_F072RB"]
579582
},
580583
{
581584
"id": "MBED_31", "description": "PWM LED test",

0 commit comments

Comments
 (0)