Skip to content

Commit 02ce61d

Browse files
committed
Merge pull request #1774 from BartSX/can-devel-l4
[STM32L4xx] CAN development for STM32L4xx family
2 parents fc9bd4c + 10cce63 commit 02ce61d

File tree

16 files changed

+548
-11
lines changed

16 files changed

+548
-11
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/cmsis/TARGET_STM/TARGET_STM32L4/TARGET_NUCLEO_L476RG/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/PeripheralPins.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,9 @@ extern const PinMap PinMap_SPI_MISO[];
6565
extern const PinMap PinMap_SPI_SCLK[];
6666
extern const PinMap PinMap_SPI_SSEL[];
6767

68+
//*** CAN ***
69+
70+
extern const PinMap PinMap_CAN_RD[];
71+
extern const PinMap PinMap_CAN_TD[];
72+
6873
#endif

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

hal/targets/hal/TARGET_STM/TARGET_STM32L4/TARGET_NUCLEO_L476RG/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_NUCLEO_L476RG/PeripheralPins.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,15 @@ const PinMap PinMap_SPI_SSEL[] = {
244244
{PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
245245
{NC, NC, 0}
246246
};
247+
248+
const PinMap PinMap_CAN_RD[] = {
249+
{PB_8 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
250+
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
251+
{NC, NC, 0}
252+
};
253+
254+
const PinMap PinMap_CAN_TD[] = {
255+
{PB_9 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
256+
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
257+
{NC, NC, 0}
258+
};

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ struct pwmout_s {
110110
uint32_t inverted;
111111
};
112112

113+
struct can_s {
114+
CANName can;
115+
int index;
116+
};
117+
113118
#include "gpio_object.h"
114119

115120
#ifdef __cplusplus

0 commit comments

Comments
 (0)