Skip to content

Commit 155d38e

Browse files
committed
[DISCO_L476VG] Added CAN support
Added CAN API support for DISCO_L476VG target. *stm32l476xx.h* file was changed to avoid compilation errors. NOTE: MBED_29 or MBED_30 cannot be tested on this platform because CAN pins are soldered to USB, GYRO and others. Change-Id: I2e85bd36dc45872b1ab617f072de98164f2c96f8
1 parent 7a262f1 commit 155d38e

File tree

9 files changed

+33
-6
lines changed

9 files changed

+33
-6
lines changed

hal/targets/cmsis/TARGET_STM/TARGET_STM32L4/TARGET_DISCO_L476VG/stm32l476xx.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,6 @@ typedef struct
13361336
#define I2C1 ((I2C_TypeDef *) I2C1_BASE)
13371337
#define I2C2 ((I2C_TypeDef *) I2C2_BASE)
13381338
#define I2C3 ((I2C_TypeDef *) I2C3_BASE)
1339-
#define CAN ((CAN_TypeDef *) CAN1_BASE)
13401339
#define CAN1 ((CAN_TypeDef *) CAN1_BASE)
13411340
#define LPTIM1 ((LPTIM_TypeDef *) LPTIM1_BASE)
13421341
#define PWR ((PWR_TypeDef *) PWR_BASE)

hal/targets/hal/TARGET_STM/TARGET_STM32L4/TARGET_DISCO_L476VG/PeripheralNames.h

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

86+
typedef enum {
87+
CAN_1 = (int)CAN1_BASE
88+
} CANName;
89+
8690
#ifdef __cplusplus
8791
}
8892
#endif

hal/targets/hal/TARGET_STM/TARGET_STM32L4/TARGET_DISCO_L476VG/PeripheralPins.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,3 +234,15 @@ const PinMap PinMap_SPI_SSEL[] = {
234234
{PE_12, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
235235
{NC, NC, 0}
236236
};
237+
238+
const PinMap PinMap_CAN_RD[] = {
239+
{PB_8 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
240+
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
241+
{NC, NC, 0}
242+
};
243+
244+
const PinMap PinMap_CAN_TD[] = {
245+
{PB_9 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
246+
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
247+
{NC, NC, 0}
248+
};

hal/targets/hal/TARGET_STM/TARGET_STM32L4/TARGET_DISCO_L476VG/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_STM32L4/TARGET_DISCO_L476VG/objects.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ struct pwmout_s {
105105
uint32_t inverted;
106106
};
107107

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

110116
#ifdef __cplusplus

libraries/tests/mbed/can/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ int main() {
6565
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
6666
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
6767
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8) && \
68-
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB))
68+
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB) && \
69+
!defined(TARGET_DISCO_L476VG))
6970
printf("loop()\n");
7071
if(can2.read(msg)) {
7172
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
@@ -60,7 +60,8 @@ void send() {
6060
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
6161
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
6262
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8) && \
63-
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB))
63+
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB) && \
64+
!defined(TARGET_DISCO_L476VG))
6465
void read() {
6566
CANMessage msg;
6667
printf("rx()\n");
@@ -78,7 +79,8 @@ int main() {
7879
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
7980
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
8081
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8) && \
81-
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB))
82+
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB) && \
83+
!defined(TARGET_DISCO_L476VG))
8284
can2.attach(&read);
8385
#endif
8486
while(1) {

libraries/tests/mbed/can_loopback/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CAN can1(P5_9, P5_10);
1818
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
1919
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
2020
defined(TARGET_DISCO_F429ZI) || defined(TARGET_NUCLEO_F103RB) || \
21-
defined(TARGET_NUCLEO_F746ZG)
21+
defined(TARGET_NUCLEO_F746ZG) || defined(TARGET_DISCO_L476VG)
2222
CAN can1(PA_11, PA_12);
2323
#elif defined(TARGET_DISCO_F469NI) || defined(TARGET_DISCO_F746NG)
2424
CAN can1(PB_8, PB_9);

workspace_tools/tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
* NUCLEO_F103RB: (RX=PA_11, TX=PA_12)
105105
* NUCLEO_F746ZG: (RX=PA_11, TX=PA_12)
106106
* DISCO_F746NG: (RX=PB_8, TX=PB_9)
107+
* DISCO_L476VG: (RX=PA_11, TX=PA_12)
107108
108109
"""
109110
TESTS = [
@@ -313,7 +314,7 @@
313314
"NUCLEO_F091RC", "NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8",
314315
"NUCLEO_F303RE", "NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE",
315316
"DISCO_F469NI", "DISCO_F429ZI", "NUCLEO_F103RB", "NUCLEO_F746ZG",
316-
"DISCO_F746NG"]
317+
"DISCO_F746NG", "DISCO_L476VG"]
317318
},
318319
{
319320
"id": "MBED_BLINKY", "description": "Blinky",

0 commit comments

Comments
 (0)