Skip to content

[STM32F4xx] CAN development for STM32F4xx family #1771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ typedef enum {
PWM_14 = (int)TIM14_BASE
} PWMName;

typedef enum {
CAN_1 = (int)CAN1_BASE,
CAN_2 = (int)CAN2_BASE
} CANName;

#ifdef __cplusplus
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,21 @@ const PinMap PinMap_SPI_SSEL[] = {
{PG_8, SPI_6, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI6)},
{NC, NC, 0}
};

const PinMap PinMap_CAN_RD[] = {
{PB_8, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
{PB_12, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
{PD_0, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
{PB_5 , CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
{NC, NC, 0}
};

const PinMap PinMap_CAN_TD[] = {
{PB_9, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
{PB_13, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
{PD_1, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
{PB_6 , CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
{NC, NC, 0}
};
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@

#define DEVICE_SLEEP 1

#define DEVICE_CAN 1

//=======================================

#define DEVICE_SEMIHOST 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ struct pwmout_s {
uint8_t inverted;
};

struct can_s {
CANName can;
int index;
};

#include "gpio_object.h"

#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ typedef enum {
PWM_14 = (int)TIM14_BASE
} PWMName;

typedef enum {
CAN_1 = (int)CAN1_BASE,
CAN_2 = (int)CAN2_BASE
} CANName;

#ifdef __cplusplus
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,13 @@ const PinMap PinMap_SPI_SSEL[] = {
{PI_0, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI2)},
{NC, NC, 0}
};

const PinMap PinMap_CAN_RD[] = {
{PB_8 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
{NC, NC, 0}
};

const PinMap PinMap_CAN_TD[] = {
{PB_9 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
{NC, NC, 0}
};
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@

#define DEVICE_SLEEP 1

#define DEVICE_CAN 1

//=======================================

#define DEVICE_SEMIHOST 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ struct pwmout_s {
uint8_t inverted;
};

struct can_s {
CANName can;
int index;
};

#include "gpio_object.h"

#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ typedef enum {
PWM_14 = (int)TIM14_BASE
} PWMName;

typedef enum {
CAN_1 = (int)CAN1_BASE,
CAN_2 = (int)CAN2_BASE
} CANName;

#ifdef __cplusplus
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,19 @@ const PinMap PinMap_SPI_SSEL[] = {
{PB_12, SPI_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF5_SPI2)},
{NC, NC, 0}
};

const PinMap PinMap_CAN_RD[] = {
{PB_8, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
{PB_12, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
{PB_5 , CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
{NC, NC, 0}
};

const PinMap PinMap_CAN_TD[] = {
{PB_9, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
{PB_13, CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
{PB_6 , CAN_2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN2)},
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN1)},
{NC, NC, 0}
};
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@

#define DEVICE_SLEEP 1

#define DEVICE_CAN 1

//=======================================

#define DEVICE_SEMIHOST 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ struct pwmout_s {
uint8_t inverted;
};

struct can_s {
CANName can;
int index;
};

#include "gpio_object.h"

#ifdef __cplusplus
Expand Down
8 changes: 7 additions & 1 deletion libraries/tests/mbed/can/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ CAN can1(PD_0, PD_1);
#elif defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F072RB) || \
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
defined(TARGET_NUCLEO_F302R8)
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
defined(TARGET_DISCO_F429ZI)
CAN can1(PA_11, PA_12);
#elif defined(TARGET_DISCO_F469NI)
CAN can1(PB_8, PB_9);
#else
CAN can1(p9, p10);
#endif
Expand All @@ -27,6 +30,9 @@ CAN can1(p9, p10);
CAN can2(p34, p33);
#elif defined (TARGET_LPC1768)
CAN can2(p30, p29);
#elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_DISCO_F469NI) || \
defined(TARGET_DISCO_F429ZI)
CAN can2(PB_5, PB_6);
#endif
char counter = 0;

Expand Down
8 changes: 7 additions & 1 deletion libraries/tests/mbed/can_interrupt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ CAN can1(PD_0, PD_1);
#elif defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F072RB) || \
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
defined(TARGET_NUCLEO_F302R8)
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
defined(TARGET_DISCO_F429ZI)
CAN can1(PA_11, PA_12);
#elif defined(TARGET_DISCO_F469NI)
CAN can1(PB_8, PB_9);
#else
CAN can1(p9, p10);
#endif
Expand All @@ -27,6 +30,9 @@ CAN can1(p9, p10);
CAN can2(p34, p33);
#elif defined (TARGET_LPC1768)
CAN can2(p30, p29);
#elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_DISCO_F469NI) || \
defined(TARGET_DISCO_F429ZI)
CAN can2(PB_5, PB_6);
#endif
char counter = 0;

Expand Down
5 changes: 4 additions & 1 deletion libraries/tests/mbed/can_loopback/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ CAN can1(P5_9, P5_10);
#elif defined(TARGET_NUCLEO_F091RC) || defined(TARGET_NUCLEO_F072RB) || \
defined(TARGET_NUCLEO_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
defined(TARGET_NUCLEO_F302R8)
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
defined(TARGET_DISCO_F429ZI)
CAN can1(PA_11, PA_12);
#elif defined(TARGET_DISCO_F469NI)
CAN can1(PB_8, PB_9);
#endif

#define TEST_ITERATIONS 127
Expand Down
12 changes: 9 additions & 3 deletions workspace_tools/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@
* NUCLEO_F303RE: (RX=PA_11, TX=PA_12)
* NUCLEO_F303K8: (RX=PA_11, TX=PA_12)
* NUCLEO_F302R8: (RX=PA_11, TX=PA_12)
* NUCLEO_F446RE: (RX=PA_11, TX=PA_12)
* DISCO_F469NI: (RX=PB_8, TX=PB_9)
* DISCO_F4269ZI: (RX=PA_11, TX=PA_12)

"""
TESTS = [
Expand Down Expand Up @@ -305,7 +308,8 @@
"peripherals": ["can_transceiver"],
"mcu": ["LPC1549", "LPC1768","B96B_F446VE", "VK_RZ_A1H",
"NUCLEO_F091RC", "NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8",
"NUCLEO_F303RE", "NUCLEO_F303K8", "NUCLEO_F302R8"],
"NUCLEO_F303RE", "NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE",
"DISCO_F469NI", "DISCO_F429ZI"],
},
{
"id": "MBED_BLINKY", "description": "Blinky",
Expand Down Expand Up @@ -578,15 +582,17 @@
"dependencies": [MBED_LIBRARIES],
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE",
"NUCLEO_F303K8", "NUCLEO_F302R8"]
"NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE", "DISCO_F469NI",
"DISCO_F429ZI"]
},
{
"id": "MBED_30", "description": "CAN network test using interrupts",
"source_dir": join(TEST_DIR, "mbed", "can_interrupt"),
"dependencies": [MBED_LIBRARIES],
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE",
"NUCLEO_F303K8", "NUCLEO_F302R8"]
"NUCLEO_F303K8", "NUCLEO_F302R8", "NUCLEO_F446RE", "DISCO_F469NI",
"DISCO_F429ZI"]
},
{
"id": "MBED_31", "description": "PWM LED test",
Expand Down