Skip to content

Commit 347a5e6

Browse files
committed
[NUCLEO_F303K8] Added CAN support
Added CAN API support for NUCLEO_F303K8 target. *stm32f303x8.h* file was changed to avoid compilation errors. Change-Id: If093c84f19c5a5ef68938af4653a25271c1108ba
1 parent 9a78b01 commit 347a5e6

File tree

9 files changed

+34
-10
lines changed

9 files changed

+34
-10
lines changed

hal/targets/cmsis/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303K8/stm32f303x8.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ typedef struct
758758
#define USART2 ((USART_TypeDef *) USART2_BASE)
759759
#define USART3 ((USART_TypeDef *) USART3_BASE)
760760
#define I2C1 ((I2C_TypeDef *) I2C1_BASE)
761-
#define CAN ((CAN_TypeDef *) CAN_BASE)
761+
#define CAN1 ((CAN_TypeDef *) CAN_BASE)
762762
#define PWR ((PWR_TypeDef *) PWR_BASE)
763763
#define DAC1 ((DAC_TypeDef *) DAC1_BASE)
764764
#define DAC2 ((DAC_TypeDef *) DAC2_BASE)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ typedef enum {
7272
PWM_17 = (int)TIM17_BASE
7373
} PWMName;
7474

75+
typedef enum {
76+
CAN_1 = (int)CAN_BASE
77+
} CANName;
78+
7579
#ifdef __cplusplus
7680
}
7781
#endif

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,13 @@ const PinMap PinMap_SPI_SSEL[] = {
169169
{PA_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
170170
{NC, NC, 0}
171171
};
172+
173+
const PinMap PinMap_CAN_RD[] = {
174+
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
175+
{NC, NC, 0}
176+
};
177+
178+
const PinMap PinMap_CAN_TD[] = {
179+
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
180+
{NC, NC, 0}
181+
};

hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303K8/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_F303K8/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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CAN can1(D2, D3);
1616
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) || \
19-
defined(TARGET_NUCLEO_F303RE)
19+
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8)
2020
CAN can1(PA_11, PA_12);
2121
#else
2222
CAN can1(p9, p10);
@@ -55,7 +55,7 @@ int main() {
5555
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && \
5656
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
5757
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
58-
!defined(TARGET_NUCLEO_F303RE))
58+
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8))
5959
printf("loop()\n");
6060
if(can2.read(msg)) {
6161
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
@@ -16,7 +16,7 @@ CAN can1(D2, D3);
1616
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) || \
19-
defined(TARGET_NUCLEO_F303RE)
19+
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8)
2020
CAN can1(PA_11, PA_12);
2121
#else
2222
CAN can1(p9, p10);
@@ -50,7 +50,7 @@ void send() {
5050
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && \
5151
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
5252
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
53-
!defined(TARGET_NUCLEO_F303RE))
53+
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8))
5454
void read() {
5555
CANMessage msg;
5656
printf("rx()\n");
@@ -67,7 +67,7 @@ int main() {
6767
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && \
6868
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
6969
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
70-
!defined(TARGET_NUCLEO_F303RE))
70+
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8))
7171
can2.attach(&read);
7272
#endif
7373
while(1) {

libraries/tests/mbed/can_loopback/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CAN can1(PD_0, PD_1);
1515
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) || \
18-
defined(TARGET_NUCLEO_F303RE)
18+
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8)
1919
CAN can1(PA_11, PA_12);
2020
#endif
2121

workspace_tools/tests.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
* NUCLEO_F042K6: (RX=PA_11, TX=PA_12)
9797
* NUCLEO_F334R8: (RX=PA_11, TX=PA_12)
9898
* NUCLEO_F303RE: (RX=PA_11, TX=PA_12)
99+
* NUCLEO_F303K8: (RX=PA_11, TX=PA_12)
99100
100101
"""
101102
TESTS = [
@@ -303,7 +304,7 @@
303304
"peripherals": ["can_transceiver"],
304305
"mcu": ["LPC1549", "LPC1768","B96B_F446VE", "VK_RZ_A1H",
305306
"NUCLEO_F091RC", "NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8",
306-
"NUCLEO_F303RE"],
307+
"NUCLEO_F303RE", "NUCLEO_F303K8"],
307308
},
308309
{
309310
"id": "MBED_BLINKY", "description": "Blinky",
@@ -575,14 +576,16 @@
575576
"source_dir": join(TEST_DIR, "mbed", "can"),
576577
"dependencies": [MBED_LIBRARIES],
577578
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
578-
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE"]
579+
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE",
580+
"NUCLEO_F303K8"]
579581
},
580582
{
581583
"id": "MBED_30", "description": "CAN network test using interrupts",
582584
"source_dir": join(TEST_DIR, "mbed", "can_interrupt"),
583585
"dependencies": [MBED_LIBRARIES],
584586
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
585-
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE"]
587+
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE",
588+
"NUCLEO_F303K8"]
586589
},
587590
{
588591
"id": "MBED_31", "description": "PWM LED test",

0 commit comments

Comments
 (0)