Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of CANnucleo by
Revision 12:c45310ff2233, committed 2015-12-22
- Comitter:
- hudakz
- Date:
- Tue Dec 22 20:46:47 2015 +0000
- Parent:
- 11:439f3a34c42e
- Child:
- 13:a3e2be3d49a2
- Commit message:
- Support for NUCLEO-F302R8, NUCLEO-F303K8, NUCLEO-F334R8 and DISCO-F334C8 added.
Changed in this revision
--- a/can_api.c Tue Dec 22 18:19:16 2015 +0000
+++ b/can_api.c Tue Dec 22 20:46:47 2015 +0000
@@ -27,7 +27,11 @@
*/
#if defined(TARGET_NUCLEO_F103RB)
#include "stm32f1xx_hal.h"
-#elif defined(TARGET_NUCLEO_F303RE)
+#elif defined(TARGET_NUCLEO_F302R8) || \
+ defined(TARGET_NUCLEO_F303RE) || \
+ defined(TARGET_NUCLEO_F303K8) || \
+ defined(TARGET_NUCLEO_F334R8) || \
+ defined(TARGET_DISCO_F334C8)
#include "stm32f3xx_hal.h"
#endif
#include "can_api.h"
@@ -67,7 +71,11 @@
int can_frequency(can_t* obj, int hz) {
#if defined(TARGET_NUCLEO_F103RB)
HAL_NVIC_DisableIRQ(USB_LP_CAN1_RX0_IRQn);
-#elif defined(TARGET_NUCLEO_F303RB)
+#elif defined(TARGET_NUCLEO_F302R8) || \
+ defined(TARGET_NUCLEO_F303RE) || \
+ defined(TARGET_NUCLEO_F303K8) || \
+ defined(TARGET_NUCLEO_F334R8) || \
+ defined(TARGET_DISCO_F334C8)
HAL_NVIC_DisableIRQ(CAN_RX1_IRQn);
#endif
@@ -120,8 +128,12 @@
HAL_CAN_Init(&_canHandle);
#if defined(TARGET_NUCLEO_F103RB)
- HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
-#elif defined(TARGET_NUCLEO_F303RB)
+ HAL_NVIC_EnableIRQ(USB_LP_CAN1_RX0_IRQn);
+#elif defined(TARGET_NUCLEO_F302R8) || \
+ defined(TARGET_NUCLEO_F303RE) || \
+ defined(TARGET_NUCLEO_F303K8) || \
+ defined(TARGET_NUCLEO_F334R8) || \
+ defined(TARGET_DISCO_F334C8)
HAL_NVIC_EnableIRQ(CAN_RX1_IRQn);
#endif
@@ -316,3 +328,4 @@
+
--- a/stm32f1xx_hal_msp.c Tue Dec 22 18:19:16 2015 +0000
+++ b/stm32f1xx_hal_msp.c Tue Dec 22 20:46:47 2015 +0000
@@ -166,10 +166,10 @@
/* Disable peripherals and GPIO Clocks */
if((_rxPin == PA_11) && (_txPin == PA_12)) {
- /* De-initialize the CAN1 TX GPIO pin */
+ /* De-initialize the CAN1 RX GPIO pin */
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11);
- /* De-initialize the CAN1 RX GPIO pin */
+ /* De-initialize the CAN1 TX GPIO pin */
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12);
}
else {
@@ -177,7 +177,7 @@
/* De-initialize the CAN1 TX GPIO pin */
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8);
- /* De-initialize the CAN1 RX GPIO pin */
+ /* De-initialize the CAN1 TX GPIO pin */
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_9);
}
--- a/stm32f3xx_hal_msp.c Tue Dec 22 18:19:16 2015 +0000
+++ b/stm32f3xx_hal_msp.c Tue Dec 22 20:46:47 2015 +0000
@@ -38,7 +38,12 @@
*
******************************************************************************
*/
-#if defined(TARGET_NUCLEO_F303RE)
+#if defined(TARGET_NUCLEO_F302R8) || \
+ defined(TARGET_NUCLEO_F303RE) || \
+ defined(TARGET_NUCLEO_F303K8) || \
+ defined(TARGET_NUCLEO_F334R8) || \
+ defined(TARGET_DISCO_F334C8)
+
#include "stm32f3xx_hal.h"
#include "can_api.h"
#include "pinmap.h"
@@ -106,7 +111,14 @@
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Pull = GPIO_PULLUP;
+#if defined(TARGET_NUCLEO_F302R8) || \
+ defined(TARGET_NUCLEO_F303RE) || \
+ defined(TARGET_NUCLEO_F303K8)
GPIO_InitStruct.Alternate = GPIO_AF7_CAN;
+#elif defined(TARGET_NUCLEO_F334R8) || \
+ defined(TARGET_DISCO_F334C8)
+ GPIO_InitStruct.Alternate = GPIO_AF9_CAN;
+#endif
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* CAN1 TX GPIO pin configuration */
@@ -114,7 +126,14 @@
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Pull = GPIO_PULLUP;
+#if defined(TARGET_NUCLEO_F302R8) || \
+ defined(TARGET_NUCLEO_F303RE) || \
+ defined(TARGET_NUCLEO_F303K8)
GPIO_InitStruct.Alternate = GPIO_AF7_CAN;
+#elif defined(TARGET_NUCLEO_F334R8) || \
+ defined(TARGET_DISCO_F334C8)
+ GPIO_InitStruct.Alternate = GPIO_AF9_CAN;
+#endif
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
else
@@ -130,16 +149,30 @@
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Pull = GPIO_PULLUP;
+#if defined(TARGET_NUCLEO_F302R8) || \
+ defined(TARGET_NUCLEO_F303RE) || \
+ defined(TARGET_NUCLEO_F303K8)
GPIO_InitStruct.Alternate = GPIO_AF7_CAN;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+#elif defined(TARGET_NUCLEO_F334R8) || \
+ defined(TARGET_DISCO_F334C8)
+ GPIO_InitStruct.Alternate = GPIO_AF9_CAN;
+#endif
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* CAN1 TX GPIO pin configuration */
GPIO_InitStruct.Pin = GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Pull = GPIO_PULLUP;
+#if defined(TARGET_NUCLEO_F302R8) || \
+ defined(TARGET_NUCLEO_F303RE) || \
+ defined(TARGET_NUCLEO_F303K8)
GPIO_InitStruct.Alternate = GPIO_AF7_CAN;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+#elif defined(TARGET_NUCLEO_F334R8) || \
+ defined(TARGET_DISCO_F334C8)
+ GPIO_InitStruct.Alternate = GPIO_AF9_CAN;
+#endif
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
else
return;
@@ -171,6 +204,15 @@
/* De-initialize the CAN1 TX GPIO pin */
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12);
}
+ else {
+
+ /* De-initialize the CAN1 RX GPIO pin */
+ HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8);
+
+ /* De-initialize the CAN1 TX GPIO pin */
+ HAL_GPIO_DeInit(GPIOB, GPIO_PIN_9);
+ }
+
/* Disable the NVIC for CAN reception */
HAL_NVIC_DisableIRQ(USB_LP_CAN_RX0_IRQn);
