-
Notifications
You must be signed in to change notification settings - Fork 12
feat(firmware/c_board): Migrate USB stack from HAL CDC to TinyUSB #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| [submodule "firmware/bsp/hpm_sdk"] | ||
| path = firmware/rmcs_board/bsp/hpm_sdk | ||
| url = https://github.com/Alliance-Algorithm/hpm_sdk.git | ||
| [submodule "firmware/c_board/bsp/tinyusb"] | ||
| path = firmware/c_board/bsp/tinyusb | ||
| url = https://github.com/qzhhhi/tinyusb.git | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* USER CODE BEGIN Header */ | ||
| /** | ||
| ****************************************************************************** | ||
| * @file usb_otg.h | ||
| * @brief This file contains all the function prototypes for | ||
| * the usb_otg.c file | ||
| ****************************************************************************** | ||
| * @attention | ||
| * | ||
| * Copyright (c) 2026 STMicroelectronics. | ||
| * All rights reserved. | ||
| * | ||
| * This software is licensed under terms that can be found in the LICENSE file | ||
| * in the root directory of this software component. | ||
| * If no LICENSE file comes with this software, it is provided AS-IS. | ||
| * | ||
| ****************************************************************************** | ||
| */ | ||
| /* USER CODE END Header */ | ||
| /* Define to prevent recursive inclusion -------------------------------------*/ | ||
| #ifndef __USB_OTG_H__ | ||
| #define __USB_OTG_H__ | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /* Includes ------------------------------------------------------------------*/ | ||
| #include "main.h" | ||
|
|
||
| /* USER CODE BEGIN Includes */ | ||
|
|
||
| /* USER CODE END Includes */ | ||
|
|
||
| extern PCD_HandleTypeDef hpcd_USB_OTG_FS; | ||
|
|
||
| /* USER CODE BEGIN Private defines */ | ||
|
|
||
| /* USER CODE END Private defines */ | ||
|
|
||
| void MX_USB_OTG_FS_PCD_Init(void); | ||
|
|
||
| /* USER CODE BEGIN Prototypes */ | ||
|
|
||
| /* USER CODE END Prototypes */ | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif /* __USB_OTG_H__ */ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| /* USER CODE BEGIN Header */ | ||
| /** | ||
| ****************************************************************************** | ||
| * @file usb_otg.c | ||
| * @brief This file provides code for the configuration | ||
| * of the USB_OTG instances. | ||
| ****************************************************************************** | ||
| * @attention | ||
| * | ||
| * Copyright (c) 2026 STMicroelectronics. | ||
| * All rights reserved. | ||
| * | ||
| * This software is licensed under terms that can be found in the LICENSE file | ||
| * in the root directory of this software component. | ||
| * If no LICENSE file comes with this software, it is provided AS-IS. | ||
| * | ||
| ****************************************************************************** | ||
| */ | ||
| /* USER CODE END Header */ | ||
| /* Includes ------------------------------------------------------------------*/ | ||
| #include "usb_otg.h" | ||
|
|
||
| /* USER CODE BEGIN 0 */ | ||
|
|
||
| /* USER CODE END 0 */ | ||
|
|
||
| PCD_HandleTypeDef hpcd_USB_OTG_FS; | ||
|
|
||
| /* USB_OTG_FS init function */ | ||
|
|
||
| void MX_USB_OTG_FS_PCD_Init(void) | ||
| { | ||
|
|
||
| /* USER CODE BEGIN USB_OTG_FS_Init 0 */ | ||
|
|
||
| /* USER CODE END USB_OTG_FS_Init 0 */ | ||
|
|
||
| /* USER CODE BEGIN USB_OTG_FS_Init 1 */ | ||
|
|
||
| /* USER CODE END USB_OTG_FS_Init 1 */ | ||
| hpcd_USB_OTG_FS.Instance = USB_OTG_FS; | ||
| hpcd_USB_OTG_FS.Init.dev_endpoints = 4; | ||
| hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL; | ||
| hpcd_USB_OTG_FS.Init.dma_enable = DISABLE; | ||
| hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED; | ||
| hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE; | ||
| hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE; | ||
| hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE; | ||
| hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE; | ||
| hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE; | ||
| if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) | ||
| { | ||
| Error_Handler(); | ||
| } | ||
| /* USER CODE BEGIN USB_OTG_FS_Init 2 */ | ||
|
|
||
| /* USER CODE END USB_OTG_FS_Init 2 */ | ||
|
|
||
| } | ||
|
|
||
| void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle) | ||
| { | ||
|
|
||
| GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||
| if(pcdHandle->Instance==USB_OTG_FS) | ||
| { | ||
| /* USER CODE BEGIN USB_OTG_FS_MspInit 0 */ | ||
|
|
||
| /* USER CODE END USB_OTG_FS_MspInit 0 */ | ||
|
|
||
| __HAL_RCC_GPIOA_CLK_ENABLE(); | ||
| /**USB_OTG_FS GPIO Configuration | ||
| PA12 ------> USB_OTG_FS_DP | ||
| PA11 ------> USB_OTG_FS_DM | ||
| */ | ||
| GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11; | ||
| GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||
| GPIO_InitStruct.Pull = GPIO_NOPULL; | ||
| GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||
| GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS; | ||
| HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||
|
|
||
| /* USB_OTG_FS clock enable */ | ||
| __HAL_RCC_USB_OTG_FS_CLK_ENABLE(); | ||
|
|
||
| /* USB_OTG_FS interrupt Init */ | ||
| HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0); | ||
| HAL_NVIC_EnableIRQ(OTG_FS_IRQn); | ||
| /* USER CODE BEGIN USB_OTG_FS_MspInit 1 */ | ||
|
|
||
| /* USER CODE END USB_OTG_FS_MspInit 1 */ | ||
| } | ||
| } | ||
|
|
||
| void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle) | ||
| { | ||
|
|
||
| if(pcdHandle->Instance==USB_OTG_FS) | ||
| { | ||
| /* USER CODE BEGIN USB_OTG_FS_MspDeInit 0 */ | ||
|
|
||
| /* USER CODE END USB_OTG_FS_MspDeInit 0 */ | ||
| /* Peripheral clock disable */ | ||
| __HAL_RCC_USB_OTG_FS_CLK_DISABLE(); | ||
|
|
||
| /**USB_OTG_FS GPIO Configuration | ||
| PA12 ------> USB_OTG_FS_DP | ||
| PA11 ------> USB_OTG_FS_DM | ||
| */ | ||
| HAL_GPIO_DeInit(GPIOA, GPIO_PIN_12|GPIO_PIN_11); | ||
|
|
||
| /* USB_OTG_FS interrupt Deinit */ | ||
| HAL_NVIC_DisableIRQ(OTG_FS_IRQn); | ||
| /* USER CODE BEGIN USB_OTG_FS_MspDeInit 1 */ | ||
|
|
||
| /* USER CODE END USB_OTG_FS_MspDeInit 1 */ | ||
| } | ||
| } | ||
|
|
||
| /* USER CODE BEGIN 1 */ | ||
|
|
||
| /* USER CODE END 1 */ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.