diff --git a/hal/targets/cmsis/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/stm32f303xe.h b/hal/targets/cmsis/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/stm32f303xe.h index 521e35014e..31bd2fd1d7 100644 --- a/hal/targets/cmsis/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/stm32f303xe.h +++ b/hal/targets/cmsis/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/stm32f303xe.h @@ -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) diff --git a/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/PeripheralNames.h b/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/PeripheralNames.h index 903555601c..1b2dd8f02d 100644 --- a/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/PeripheralNames.h +++ b/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/PeripheralNames.h @@ -82,6 +82,10 @@ typedef enum { PWM_17 = (int)TIM17_BASE } PWMName; +typedef enum { + CAN_1 = (int)CAN_BASE +} CANName; + #ifdef __cplusplus } #endif diff --git a/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/PeripheralPins.c b/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/PeripheralPins.c index 813a9a9553..13c33f170f 100644 --- a/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/PeripheralPins.c +++ b/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/PeripheralPins.c @@ -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} +}; diff --git a/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/device.h b/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/device.h index 8b1f3d7ca2..63b22fe216 100644 --- a/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/device.h +++ b/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/device.h @@ -54,6 +54,8 @@ #define DEVICE_SLEEP 1 +#define DEVICE_CAN 1 + //======================================= #define DEVICE_SEMIHOST 0 diff --git a/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/objects.h b/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/objects.h index a1cba7d583..81ebc1d371 100644 --- a/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/objects.h +++ b/hal/targets/hal/TARGET_STM/TARGET_STM32F3/TARGET_NUCLEO_F303RE/objects.h @@ -106,6 +106,11 @@ struct pwmout_s { uint32_t inverted; }; +struct can_s { + CANName can; + int index; +}; + #include "gpio_object.h" #ifdef __cplusplus diff --git a/libraries/tests/mbed/can/main.cpp b/libraries/tests/mbed/can/main.cpp index 6a01cc9b68..7366f9fafc 100644 --- a/libraries/tests/mbed/can/main.cpp +++ b/libraries/tests/mbed/can/main.cpp @@ -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); diff --git a/libraries/tests/mbed/can_interrupt/main.cpp b/libraries/tests/mbed/can_interrupt/main.cpp index 5d18bf40c8..8a9679bcb3 100644 --- a/libraries/tests/mbed/can_interrupt/main.cpp +++ b/libraries/tests/mbed/can_interrupt/main.cpp @@ -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) { diff --git a/libraries/tests/mbed/can_loopback/main.cpp b/libraries/tests/mbed/can_loopback/main.cpp index d036352aac..6c3917d1e5 100644 --- a/libraries/tests/mbed/can_loopback/main.cpp +++ b/libraries/tests/mbed/can_loopback/main.cpp @@ -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 diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 4f6a8b2395..656a059ce9 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -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",