Skip to content

Commit 5ac648f

Browse files
committed
Merge pull request #1762 from BartSX/can-devel-f3
[STM32F3xx] CAN development for STM32F3xx family
2 parents f68cdcb + f1c42bf commit 5ac648f

File tree

26 files changed

+605
-13
lines changed

26 files changed

+605
-13
lines changed

hal/targets/cmsis/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F302R8/stm32f302x8.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ typedef struct
792792
#define I2C1 ((I2C_TypeDef *) I2C1_BASE)
793793
#define I2C2 ((I2C_TypeDef *) I2C2_BASE)
794794
#define I2C3 ((I2C_TypeDef *) I2C3_BASE)
795-
#define CAN ((CAN_TypeDef *) CAN_BASE)
795+
#define CAN1 ((CAN_TypeDef *) CAN_BASE)
796796
#define PWR ((PWR_TypeDef *) PWR_BASE)
797797
#define DAC ((DAC_TypeDef *) DAC_BASE)
798798
#define DAC1 ((DAC_TypeDef *) DAC1_BASE)

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/cmsis/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/stm32f303xe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ typedef struct
924924
#define UART5 ((USART_TypeDef *) UART5_BASE)
925925
#define I2C1 ((I2C_TypeDef *) I2C1_BASE)
926926
#define I2C2 ((I2C_TypeDef *) I2C2_BASE)
927-
#define CAN ((CAN_TypeDef *) CAN_BASE)
927+
#define CAN1 ((CAN_TypeDef *) CAN_BASE)
928928
#define PWR ((PWR_TypeDef *) PWR_BASE)
929929
#define DAC ((DAC_TypeDef *) DAC_BASE)
930930
#define DAC1 ((DAC_TypeDef *) DAC1_BASE)

hal/targets/cmsis/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F334R8/stm32f334x8.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ typedef struct
872872
#define USART2 ((USART_TypeDef *) USART2_BASE)
873873
#define USART3 ((USART_TypeDef *) USART3_BASE)
874874
#define I2C1 ((I2C_TypeDef *) I2C1_BASE)
875-
#define CAN ((CAN_TypeDef *) CAN_BASE)
875+
#define CAN1 ((CAN_TypeDef *) CAN_BASE)
876876
#define PWR ((PWR_TypeDef *) PWR_BASE)
877877
#define DAC1 ((DAC_TypeDef *) DAC1_BASE)
878878
#define DAC2 ((DAC_TypeDef *) DAC2_BASE)

hal/targets/hal/TARGET_STM/TARGET_STM32F3/PeripheralPins.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,8 @@ extern const PinMap PinMap_SPI_MISO[];
6363
extern const PinMap PinMap_SPI_SCLK[];
6464
extern const PinMap PinMap_SPI_SSEL[];
6565

66+
//*** CAN ***
67+
extern const PinMap PinMap_CAN_RD[];
68+
extern const PinMap PinMap_CAN_TD[];
69+
6670
#endif

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

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

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

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,15 @@ const PinMap PinMap_SPI_SSEL[] = {
204204
{PF_0, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
205205
{NC, NC, 0}
206206
};
207+
208+
const PinMap PinMap_CAN_RD[] = {
209+
// {PB_8 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)}, // Not available in 32 pins package
210+
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
211+
{NC, NC, 0}
212+
};
213+
214+
const PinMap PinMap_CAN_TD[] = {
215+
// {PB_9 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)}, // Not available in 32 pins package
216+
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
217+
{NC, NC, 0}
218+
};

hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F302R8/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_F302R8/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

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
@@ -73,6 +73,10 @@ typedef enum {
7373
PWM_17 = (int)TIM17_BASE
7474
} PWMName;
7575

76+
typedef enum {
77+
CAN_1 = (int)CAN_BASE
78+
} CANName;
79+
7680
#ifdef __cplusplus
7781
}
7882
#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

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

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

85+
typedef enum {
86+
CAN_1 = (int)CAN_BASE
87+
} CANName;
88+
8589
#ifdef __cplusplus
8690
}
8791
#endif

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,15 @@ const PinMap PinMap_SPI_SSEL[] = {
255255
{PF_0, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
256256
{NC, NC, 0}
257257
};
258+
259+
const PinMap PinMap_CAN_RD[] = {
260+
{PB_8 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
261+
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
262+
{NC, NC, 0}
263+
};
264+
265+
const PinMap PinMap_CAN_TD[] = {
266+
{PB_9 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
267+
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
268+
{NC, NC, 0}
269+
};

hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/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_F303RE/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

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

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

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

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,15 @@ const PinMap PinMap_SPI_SSEL[] = {
210210
{PA_15, SPI_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)},
211211
{NC, NC, 0}
212212
};
213+
214+
const PinMap PinMap_CAN_RD[] = {
215+
{PB_8 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
216+
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
217+
{NC, NC, 0}
218+
};
219+
220+
const PinMap PinMap_CAN_TD[] = {
221+
{PB_9 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
222+
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
223+
{NC, NC, 0}
224+
};

hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F334R8/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_F334R8/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

0 commit comments

Comments
 (0)