Skip to content

Commit 6e77543

Browse files
committed
[NUCLEO_F103RB] Added CAN support
Added CAN API support for NUCLEO_F103RB target. Change-Id: Ib5dac8023917afef683ba0703d732bbf53efdcd9
1 parent 8b44c0d commit 6e77543

File tree

8 files changed

+33
-9
lines changed

8 files changed

+33
-9
lines changed

hal/targets/hal/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/PeripheralNames.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ typedef enum {
6767
PWM_4 = (int)TIM4_BASE
6868
} PWMName;
6969

70+
typedef enum {
71+
CAN_1 = (int)CAN1_BASE
72+
} CANName;
73+
7074
#ifdef __cplusplus
7175
}
7276
#endif

hal/targets/hal/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/PeripheralPins.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,15 @@ const PinMap PinMap_SPI_SSEL[] = {
163163
{PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)},
164164
{NC, NC, 0}
165165
};
166+
167+
const PinMap PinMap_CAN_RD[] = {
168+
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)},
169+
{PB_8 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 1)},
170+
{NC, NC, 0}
171+
};
172+
173+
const PinMap PinMap_CAN_TD[] = {
174+
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 0)},
175+
{PB_9 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, 1)},
176+
{NC, NC, 0}
177+
};

hal/targets/hal/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/device.h

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

4242

4343

44+
#define DEVICE_CAN 1
45+
4446
//=======================================
4547

4648
#define DEVICE_ID_LENGTH 24

hal/targets/hal/TARGET_STM/TARGET_STM32F1/TARGET_NUCLEO_F103RB/objects.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ struct pwmout_s {
9696
uint32_t pulse;
9797
};
9898

99+
struct can_s {
100+
CANName can;
101+
int index;
102+
};
103+
99104
#include "gpio_object.h"
100105

101106
#ifdef __cplusplus

libraries/tests/mbed/can/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CAN can1(PD_0, PD_1);
1818
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
1919
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
2020
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
21-
defined(TARGET_DISCO_F429ZI)
21+
defined(TARGET_DISCO_F429ZI) || defined(TARGET_NUCLEO_F103RB)
2222
CAN can1(PA_11, PA_12);
2323
#elif defined(TARGET_DISCO_F469NI)
2424
CAN can1(PB_8, PB_9);
@@ -63,7 +63,7 @@ int main() {
6363
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
6464
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
6565
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8) && \
66-
!defined(TARGET_NUCLEO_F302R8))
66+
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB))
6767
printf("loop()\n");
6868
if(can2.read(msg)) {
6969
printmsg("Rx message:", &msg);

libraries/tests/mbed/can_interrupt/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CAN can1(PD_0, PD_1);
1818
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
1919
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
2020
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
21-
defined(TARGET_DISCO_F429ZI)
21+
defined(TARGET_DISCO_F429ZI) || defined(TARGET_NUCLEO_F103RB)
2222
CAN can1(PA_11, PA_12);
2323
#elif defined(TARGET_DISCO_F469NI)
2424
CAN can1(PB_8, PB_9);
@@ -58,7 +58,7 @@ void send() {
5858
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
5959
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
6060
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8) && \
61-
!defined(TARGET_NUCLEO_F302R8))
61+
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB))
6262
void read() {
6363
CANMessage msg;
6464
printf("rx()\n");
@@ -76,7 +76,7 @@ int main() {
7676
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
7777
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
7878
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8) && \
79-
!defined(TARGET_NUCLEO_F302R8))
79+
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB))
8080
can2.attach(&read);
8181
#endif
8282
while(1) {

libraries/tests/mbed/can_loopback/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CAN can1(P5_9, P5_10);
1717
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
1818
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
1919
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
20-
defined(TARGET_DISCO_F429ZI)
20+
defined(TARGET_DISCO_F429ZI) || defined(TARGET_NUCLEO_F103RB)
2121
CAN can1(PA_11, PA_12);
2222
#elif defined(TARGET_DISCO_F469NI)
2323
CAN can1(PB_8, PB_9);

workspace_tools/tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
* NUCLEO_F446RE: (RX=PA_11, TX=PA_12)
102102
* DISCO_F469NI: (RX=PB_8, TX=PB_9)
103103
* DISCO_F4269ZI: (RX=PA_11, TX=PA_12)
104+
* NUCLEO_F103RB: (RX=PA_11, TX=PA_12)
104105
105106
"""
106107
TESTS = [
@@ -309,7 +310,7 @@
309310
"mcu": ["LPC1549", "LPC1768","B96B_F446VE", "VK_RZ_A1H",
310311
"NUCLEO_F091RC", "NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8",
311312
"NUCLEO_F303RE", "NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE",
312-
"DISCO_F469NI", "DISCO_F429ZI"],
313+
"DISCO_F469NI", "DISCO_F429ZI", "NUCLEO_F103RB"],
313314
},
314315
{
315316
"id": "MBED_BLINKY", "description": "Blinky",
@@ -583,7 +584,7 @@
583584
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
584585
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE",
585586
"NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE", "DISCO_F469NI",
586-
"DISCO_F429ZI"]
587+
"DISCO_F429ZI", "NUCLEO_F103RB"]
587588
},
588589
{
589590
"id": "MBED_30", "description": "CAN network test using interrupts",
@@ -592,7 +593,7 @@
592593
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
593594
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE",
594595
"NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE", "DISCO_F469NI",
595-
"DISCO_F429ZI"]
596+
"DISCO_F429ZI", "NUCLEO_F103RB"]
596597
},
597598
{
598599
"id": "MBED_31", "description": "PWM LED test",

0 commit comments

Comments
 (0)