Skip to content

Commit 8577163

Browse files
committed
[NUCLEO_F091RC] Added CAN support
Added CAN API suport for NUCLEO_F091RC target. *stm32f091xc.h* file was changed to avoid compilation errors. Change-Id: I9207575a0e2ad0f8e3a4bb78eb23d1e7b4a94171
1 parent f04377d commit 8577163

File tree

9 files changed

+38
-7
lines changed

9 files changed

+38
-7
lines changed

libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F091RC/stm32f091xc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ typedef struct
708708
#define USART5 ((USART_TypeDef *) USART5_BASE)
709709
#define I2C1 ((I2C_TypeDef *) I2C1_BASE)
710710
#define I2C2 ((I2C_TypeDef *) I2C2_BASE)
711-
#define CAN ((CAN_TypeDef *) CAN_BASE)
711+
#define CAN1 ((CAN_TypeDef *) CAN_BASE)
712712
#define CRS ((CRS_TypeDef *) CRS_BASE)
713713
#define PWR ((PWR_TypeDef *) PWR_BASE)
714714
#define DAC ((DAC_TypeDef *) DAC_BASE)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ typedef enum {
7979
PWM_17 = (int)TIM17_BASE
8080
} PWMName;
8181

82+
typedef enum {
83+
CAN_1 = (int)CAN_BASE
84+
} CANName;
85+
8286
#ifdef __cplusplus
8387
}
8488
#endif

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,15 @@ const PinMap PinMap_SPI_SSEL[] = {
218218
{PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI2)},
219219
{NC, NC, 0}
220220
};
221+
222+
const PinMap PinMap_CAN_RD[] = {
223+
{PB_8 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF4_CAN)},
224+
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF4_CAN)},
225+
{NC, NC, 0}
226+
};
227+
228+
const PinMap PinMap_CAN_TD[] = {
229+
{PB_9 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF4_CAN)},
230+
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF4_CAN)},
231+
{NC, NC, 0}
232+
};

libraries/mbed/targets/hal/TARGET_STM/TARGET_STM32F0/TARGET_NUCLEO_F091RC/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_F091RC/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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ 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)
18+
CAN can1(PA_11, PA_12);
1719
#else
1820
CAN can1(p9, p10);
1921
#endif
@@ -48,7 +50,7 @@ int main() {
4850
ticker.attach(&send, 1);
4951
CANMessage msg;
5052
while(1) {
51-
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE))
53+
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && !defined(TARGET_NUCLEO_F091RC))
5254
printf("loop()\n");
5355
if(can2.read(msg)) {
5456
printmsg("Rx message:", &msg);

libraries/tests/mbed/can_interrupt/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ 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)
18+
CAN can1(PA_11, PA_12);
1719
#else
1820
CAN can1(p9, p10);
1921
#endif
@@ -43,7 +45,7 @@ void send() {
4345
led1 = !led1;
4446
}
4547

46-
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE))
48+
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && !defined(TARGET_NUCLEO_F091RC))
4749
void read() {
4850
CANMessage msg;
4951
printf("rx()\n");
@@ -57,7 +59,7 @@ void read() {
5759
int main() {
5860
printf("main()\n");
5961
ticker.attach(&send, 1);
60-
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE))
62+
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && !defined(TARGET_NUCLEO_F091RC))
6163
can2.attach(&read);
6264
#endif
6365
while(1) {

libraries/tests/mbed/can_loopback/main.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ 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)
17+
CAN can1(PA_11, PA_12);
1618
#endif
1719

1820
#define TEST_ITERATIONS 127

workspace_tools/tests.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
* LPC1549: (RX=D9, TX=D8)
9292
* LPC4088: (RX=p9, TX=p10)
9393
* VK_RZ_A1H:(RX=P5_9, TX=P5_10)
94+
* NUCLEO_F091RC: (RX=PA_11, TX=PA_12)
9495
9596
"""
9697
TESTS = [
@@ -296,7 +297,8 @@
296297
"automated": True,
297298
"duration": 20,
298299
"peripherals": ["can_transceiver"],
299-
"mcu": ["LPC1549", "LPC1768","B96B_F446VE", "VK_RZ_A1H"],
300+
"mcu": ["LPC1549", "LPC1768","B96B_F446VE", "VK_RZ_A1H",
301+
"NUCLEO_F091RC"],
300302
},
301303
{
302304
"id": "MBED_BLINKY", "description": "Blinky",
@@ -567,13 +569,13 @@
567569
"id": "MBED_29", "description": "CAN network test",
568570
"source_dir": join(TEST_DIR, "mbed", "can"),
569571
"dependencies": [MBED_LIBRARIES],
570-
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE"]
572+
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC"]
571573
},
572574
{
573575
"id": "MBED_30", "description": "CAN network test using interrupts",
574576
"source_dir": join(TEST_DIR, "mbed", "can_interrupt"),
575577
"dependencies": [MBED_LIBRARIES],
576-
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE"]
578+
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC"]
577579
},
578580
{
579581
"id": "MBED_31", "description": "PWM LED test",

0 commit comments

Comments
 (0)