pub
Fork of CANnucleo by
Diff: stm32f3xx_hal_msp.c
- Revision:
- 12:c45310ff2233
- Parent:
- 11:439f3a34c42e
- Child:
- 13:a3e2be3d49a2
diff -r 439f3a34c42e -r c45310ff2233 stm32f3xx_hal_msp.c --- 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);