mirror of https://github.com/ARMmbed/mbed-os.git
[NUCLEO_F303RE] Added CAN support
Added CAN API support for NUCLEO_F303RE target. *stm32f303xe.h* file was changed to avoid compilation errors. Change-Id: Ia6519c982261d43165dbce73cab7cfc0617474e2pull/1762/head
parent
656d1953d9
commit
9a78b010a0
|
@ -924,7 +924,7 @@ typedef struct
|
|||
#define UART5 ((USART_TypeDef *) UART5_BASE)
|
||||
#define I2C1 ((I2C_TypeDef *) I2C1_BASE)
|
||||
#define I2C2 ((I2C_TypeDef *) I2C2_BASE)
|
||||
#define CAN ((CAN_TypeDef *) CAN_BASE)
|
||||
#define CAN1 ((CAN_TypeDef *) CAN_BASE)
|
||||
#define PWR ((PWR_TypeDef *) PWR_BASE)
|
||||
#define DAC ((DAC_TypeDef *) DAC_BASE)
|
||||
#define DAC1 ((DAC_TypeDef *) DAC1_BASE)
|
||||
|
|
|
@ -82,6 +82,10 @@ typedef enum {
|
|||
PWM_17 = (int)TIM17_BASE
|
||||
} PWMName;
|
||||
|
||||
typedef enum {
|
||||
CAN_1 = (int)CAN_BASE
|
||||
} CANName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -255,3 +255,15 @@ const PinMap PinMap_SPI_SSEL[] = {
|
|||
{PF_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_CAN)},
|
||||
{PA_11, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
||||
const PinMap PinMap_CAN_TD[] = {
|
||||
{PB_9 , CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
|
||||
{PA_12, CAN_1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF9_CAN)},
|
||||
{NC, NC, 0}
|
||||
};
|
||||
|
|
|
@ -54,6 +54,8 @@
|
|||
|
||||
#define DEVICE_SLEEP 1
|
||||
|
||||
#define DEVICE_CAN 1
|
||||
|
||||
//=======================================
|
||||
|
||||
#define DEVICE_SEMIHOST 0
|
||||
|
|
|
@ -106,6 +106,11 @@ struct pwmout_s {
|
|||
uint32_t inverted;
|
||||
};
|
||||
|
||||
struct can_s {
|
||||
CANName can;
|
||||
int index;
|
||||
};
|
||||
|
||||
#include "gpio_object.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -15,7 +15,8 @@ CAN can1(D2, D3);
|
|||
// B96B_F446VE support only single CAN channel
|
||||
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_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
|
||||
defined(TARGET_NUCLEO_F303RE)
|
||||
CAN can1(PA_11, PA_12);
|
||||
#else
|
||||
CAN can1(p9, p10);
|
||||
|
@ -53,7 +54,8 @@ int main() {
|
|||
while(1) {
|
||||
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && \
|
||||
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
|
||||
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8))
|
||||
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
|
||||
!defined(TARGET_NUCLEO_F303RE))
|
||||
printf("loop()\n");
|
||||
if(can2.read(msg)) {
|
||||
printmsg("Rx message:", &msg);
|
||||
|
|
|
@ -15,7 +15,8 @@ CAN can1(D2, D3);
|
|||
// B96B_F446VE support only single CAN channel
|
||||
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_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
|
||||
defined(TARGET_NUCLEO_F303RE)
|
||||
CAN can1(PA_11, PA_12);
|
||||
#else
|
||||
CAN can1(p9, p10);
|
||||
|
@ -48,7 +49,8 @@ void send() {
|
|||
|
||||
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && \
|
||||
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
|
||||
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8))
|
||||
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
|
||||
!defined(TARGET_NUCLEO_F303RE))
|
||||
void read() {
|
||||
CANMessage msg;
|
||||
printf("rx()\n");
|
||||
|
@ -64,7 +66,8 @@ int main() {
|
|||
ticker.attach(&send, 1);
|
||||
#if (!defined (TARGET_LPC1549) && !defined(TARGET_B96B_F446VE) && \
|
||||
!defined(TARGET_NUCLEO_F091RC) && !defined(TARGET_NUCLEO_F072RB) && \
|
||||
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8))
|
||||
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
|
||||
!defined(TARGET_NUCLEO_F303RE))
|
||||
can2.attach(&read);
|
||||
#endif
|
||||
while(1) {
|
||||
|
|
|
@ -14,7 +14,8 @@ CAN can1(PD_0, PD_1);
|
|||
#elif defined(TARGET_VK_RZ_A1H)
|
||||
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_F042K6) || defined(TARGET_NUCLEO_F334R8) || \
|
||||
defined(TARGET_NUCLEO_F303RE)
|
||||
CAN can1(PA_11, PA_12);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -95,6 +95,7 @@ Wiring:
|
|||
* NUCLEO_F072RB: (RX=PA_11, TX=PA_12)
|
||||
* NUCLEO_F042K6: (RX=PA_11, TX=PA_12)
|
||||
* NUCLEO_F334R8: (RX=PA_11, TX=PA_12)
|
||||
* NUCLEO_F303RE: (RX=PA_11, TX=PA_12)
|
||||
|
||||
"""
|
||||
TESTS = [
|
||||
|
@ -301,7 +302,8 @@ TESTS = [
|
|||
"duration": 20,
|
||||
"peripherals": ["can_transceiver"],
|
||||
"mcu": ["LPC1549", "LPC1768","B96B_F446VE", "VK_RZ_A1H",
|
||||
"NUCLEO_F091RC", "NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8"],
|
||||
"NUCLEO_F091RC", "NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8",
|
||||
"NUCLEO_F303RE"],
|
||||
},
|
||||
{
|
||||
"id": "MBED_BLINKY", "description": "Blinky",
|
||||
|
@ -573,14 +575,14 @@ TESTS = [
|
|||
"source_dir": join(TEST_DIR, "mbed", "can"),
|
||||
"dependencies": [MBED_LIBRARIES],
|
||||
"mcu": ["LPC1768", "LPC4088", "LPC1549", "RZ_A1H", "B96B_F446VE", "NUCLEO_F091RC",
|
||||
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8"]
|
||||
"NUCLEO_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE"]
|
||||
},
|
||||
{
|
||||
"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_F072RB", "NUCLEO_F042K6", "NUCLEO_F334R8", "NUCLEO_F303RE"]
|
||||
},
|
||||
{
|
||||
"id": "MBED_31", "description": "PWM LED test",
|
||||
|
|
Loading…
Reference in New Issue