fix 303, now works with usb

sipo
Ondřej Hruška 7 years ago
parent f15b907f5d
commit 9e45f4e6ec
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 33
      USB/usb_device.c
  2. 2
      USB/usbd_conf.c
  3. 5
      platform/debug_uart.c

@ -86,32 +86,33 @@ void MX_USB_DEVICE_Init(void)
}
/* USER CODE BEGIN USB_IRQ */
/**
* @brief This function handles USB low priority or CAN RX0 interrupts.
* Common USB handler
*/
static void __attribute__((used)) BASE_USB_IRQHandler(void)
{
HAL_PCD_IRQHandler(&hpcd_USB_FS);
}
// Function from F103
void USB_LP_CAN1_RX0_IRQHandler(void) __attribute__((alias("USB_IRQHandler")));
/**
* @brief This function handles USB low priority or CAN RX0 interrupts.
*/
void USB_LP_CAN1_RX0_IRQHandler(void) __attribute__((alias("BASE_USB_IRQHandler")));
// Function for F303
void USB_LP_CAN_RX0_IRQHandler(void) __attribute__((alias("USB_IRQHandler")));
/**
* @brief This function handles USB low priority or CAN_RX0 interrupts.
*/
void USB_LP_CAN_RX0_IRQHandler(void) __attribute__((alias("BASE_USB_IRQHandler")));
// Function for F072
/**
* @brief This function handles USB global interrupt / USB wake-up interrupt through EXTI line 18.
*/
// Function from F072
void USB_IRQHandler(void)
{
/* USER CODE BEGIN USB_IRQn 0 */
/* USER CODE END USB_IRQn 0 */
HAL_PCD_IRQHandler(&hpcd_USB_FS);
/* USER CODE BEGIN USB_IRQn 1 */
/* USER CODE END USB_IRQn 1 */
}
void USB_IRQHandler(void) __attribute__((alias("BASE_USB_IRQHandler")));
/**
* @}

@ -96,6 +96,8 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
PA12 ------> USB_DP
*/
__HAL_RCC_GPIOA_CLK_ENABLE();
LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_11, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetPinMode(GPIOA, LL_GPIO_PIN_12, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetAFPin_8_15(GPIOA, LL_GPIO_PIN_11, LL_GPIO_AF_14);
LL_GPIO_SetAFPin_8_15(GPIOA, LL_GPIO_PIN_12, LL_GPIO_AF_14);
HAL_NVIC_SetPriority(USB_LP_CAN_RX0_IRQn, 5, 0);

@ -43,7 +43,10 @@ void DebugUart_PreInit(void)
#elif GEX_PLAT_F103_BLUEPILL
LL_USART_SetBaudRate(USART2, SystemCoreClock/2, 115200); // This is not great, let's hope it's like this on all platforms...
#elif GEX_PLAT_F303_DISCOVERY
LL_USART_SetBaudRate(USART2, SystemCoreClock/2, LL_USART_OVERSAMPLING_16, 115200); // FIXME better way to determine frequency?
LL_USART_SetBaudRate(USART2,
LL_RCC_GetUSARTClockFreq(LL_RCC_USART2_CLKSOURCE),
LL_USART_OVERSAMPLING_16,
115200);
LL_GPIO_SetAFPin_0_7(GPIOA, LL_GPIO_PIN_2, LL_GPIO_AF_7); // uart2 is AF7 here
#else
#error "BAD PLATFORM!"

Loading…
Cancel
Save