From 067f24cff08ee6ad767f4a1ca0010dbcfd368a6c Mon Sep 17 00:00:00 2001 From: wmano Date: Mon, 13 Oct 2025 22:21:43 +0800 Subject: [PATCH] using usb as console --- apps/chrg/.config | 80 +--- apps/chrg/applications/bsp/chrg_usbd.c | 39 -- apps/chrg/applications/bsp/chrg_vcom.c | 43 ++ apps/chrg/applications/bsp/chrg_vcom.h | 11 + apps/chrg/applications/main.c | 6 + .../board/CubeMX_Config/CubeMX_Config.ioc | 80 ++-- .../CubeMX_Config/Src/stm32f4xx_hal_msp.c | 79 +++- apps/chrg/board/board.c | 42 +- apps/chrg/chrg.uvprojx | 407 ++++++++---------- apps/chrg/rtconfig.h | 18 +- .../HAL_Drivers/drivers/drv_soft_i2c.h | 16 +- 11 files changed, 431 insertions(+), 390 deletions(-) delete mode 100644 apps/chrg/applications/bsp/chrg_usbd.c create mode 100644 apps/chrg/applications/bsp/chrg_vcom.c create mode 100644 apps/chrg/applications/bsp/chrg_vcom.h diff --git a/apps/chrg/.config b/apps/chrg/.config index cafe1aa..6cf8d0c 100644 --- a/apps/chrg/.config +++ b/apps/chrg/.config @@ -286,60 +286,7 @@ CONFIG_RT_USING_WDT=y CONFIG_RT_USING_PIN=y # CONFIG_RT_USING_KTIME is not set CONFIG_RT_USING_HWTIMER=y -CONFIG_RT_USING_CHERRYUSB=y -CONFIG_RT_CHERRYUSB_DEVICE=y -CONFIG_RT_CHERRYUSB_DEVICE_SPEED_FS=y -# CONFIG_RT_CHERRYUSB_DEVICE_SPEED_HS is not set -# CONFIG_RT_CHERRYUSB_DEVICE_SPEED_AUTO is not set -# CONFIG_RT_CHERRYUSB_DEVICE_CUSTOM is not set -# CONFIG_RT_CHERRYUSB_DEVICE_FSDEV_ST is not set -# CONFIG_RT_CHERRYUSB_DEVICE_FSDEV_CUSTOM is not set -CONFIG_RT_CHERRYUSB_DEVICE_DWC2_ST=y -# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_ESP is not set -# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_KENDRYTE is not set -# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_AT is not set -# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_HC is not set -# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_NATION is not set -# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_GD is not set -# CONFIG_RT_CHERRYUSB_DEVICE_DWC2_CUSTOM is not set -# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_ES is not set -# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_SUNXI is not set -# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_BK is not set -# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_SIFLI is not set -# CONFIG_RT_CHERRYUSB_DEVICE_MUSB_CUSTOM is not set -# CONFIG_RT_CHERRYUSB_DEVICE_CHIPIDEA_MCX is not set -# CONFIG_RT_CHERRYUSB_DEVICE_CHIPIDEA_CUSTOM is not set -# CONFIG_RT_CHERRYUSB_DEVICE_KINETIS_MCX is not set -# CONFIG_RT_CHERRYUSB_DEVICE_KINETIS_MM32 is not set -# CONFIG_RT_CHERRYUSB_DEVICE_KINETIS_CUSTOM is not set -# CONFIG_RT_CHERRYUSB_DEVICE_BL is not set -# CONFIG_RT_CHERRYUSB_DEVICE_HPM is not set -# CONFIG_RT_CHERRYUSB_DEVICE_AIC is not set -# CONFIG_RT_CHERRYUSB_DEVICE_RP2040 is not set -# CONFIG_RT_CHERRYUSB_DEVICE_CH32 is not set -# CONFIG_RT_CHERRYUSB_DEVICE_PUSB2 is not set -# CONFIG_RT_CHERRYUSB_DEVICE_NRF5X is not set -CONFIG_RT_CHERRYUSB_DEVICE_CDC_ACM=y -# CONFIG_RT_CHERRYUSB_DEVICE_HID is not set -# CONFIG_RT_CHERRYUSB_DEVICE_MSC is not set -# CONFIG_RT_CHERRYUSB_DEVICE_AUDIO is not set -# CONFIG_RT_CHERRYUSB_DEVICE_VIDEO is not set -# CONFIG_RT_CHERRYUSB_DEVICE_CDC_RNDIS is not set -# CONFIG_RT_CHERRYUSB_DEVICE_CDC_ECM is not set -# CONFIG_RT_CHERRYUSB_DEVICE_CDC_NCM is not set -# CONFIG_RT_CHERRYUSB_DEVICE_MTP is not set -# CONFIG_RT_CHERRYUSB_DEVICE_ADB is not set -# CONFIG_RT_CHERRYUSB_DEVICE_DFU is not set -# CONFIG_RT_CHERRYUSB_DEVICE_CDC_ACM_CHARDEV is not set -CONFIG_CONFIG_USBDEV_REQUEST_BUFFER_LEN=512 -CONFIG_CONFIG_USBDEV_MSC_MAX_BUFSIZE=512 -# CONFIG_CONFIG_USBDEV_RNDIS_USING_LWIP is not set -# CONFIG_CONFIG_USBDEV_CDC_ECM_USING_LWIP is not set -# CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_NONE is not set -CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM=y -# CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_WINUSBV1 is not set -# CONFIG_RT_CHERRYUSB_DEVICE_TEMPLATE_WINUSBV2_CDC is not set -# CONFIG_RT_CHERRYUSB_HOST is not set +# CONFIG_RT_USING_CHERRYUSB is not set # end of Device Drivers # @@ -426,14 +373,19 @@ CONFIG_RT_USING_USB_DEVICE=y CONFIG_RT_USBD_THREAD_STACK_SZ=4096 CONFIG_USB_VENDOR_ID=0x0483 CONFIG_USB_PRODUCT_ID=0x5740 -# CONFIG_RT_USB_DEVICE_COMPOSITE is not set -CONFIG__RT_USB_DEVICE_NONE=y -# CONFIG__RT_USB_DEVICE_CDC is not set -# CONFIG__RT_USB_DEVICE_MSTORAGE is not set -# CONFIG__RT_USB_DEVICE_HID is not set -# CONFIG__RT_USB_DEVICE_WINUSB is not set -# CONFIG__RT_USB_DEVICE_AUDIO is not set +CONFIG_RT_USB_DEVICE_COMPOSITE=y +CONFIG_RT_USB_DEVICE_CDC=y CONFIG_RT_USB_DEVICE_NONE=y +# CONFIG_RT_USB_DEVICE_MSTORAGE is not set +# CONFIG_RT_USB_DEVICE_HID is not set +# CONFIG_RT_USB_DEVICE_WINUSB is not set +# CONFIG_RT_USB_DEVICE_AUDIO is not set +CONFIG_RT_VCOM_TASK_STK_SIZE=512 +CONFIG_RT_CDC_RX_BUFSIZE=128 +# CONFIG_RT_VCOM_TX_USE_DMA is not set +CONFIG_RT_VCOM_SERNO="32021919830108" +CONFIG_RT_VCOM_SER_LEN=14 +CONFIG_RT_VCOM_TX_TIMEOUT=1000 # end of Using USB legacy version # CONFIG_RT_USING_FDT is not set @@ -1504,9 +1456,7 @@ CONFIG_BSP_USING_UART3=y CONFIG_BSP_UART3_RX_USING_DMA=y CONFIG_BSP_UART3_TX_USING_DMA=y # CONFIG_BSP_USING_UART4 is not set -CONFIG_BSP_USING_UART5=y -# CONFIG_BSP_UART5_RX_USING_DMA is not set -# CONFIG_BSP_UART5_TX_USING_DMA is not set +# CONFIG_BSP_USING_UART5 is not set CONFIG_BSP_USING_UART6=y CONFIG_BSP_UART6_RX_USING_DMA=y CONFIG_BSP_UART6_TX_USING_DMA=y @@ -1519,7 +1469,7 @@ CONFIG_BSP_USING_I2C4=y # CONFIG_BSP_USING_ADC is not set # CONFIG_BSP_USING_ONCHIP_RTC is not set CONFIG_BSP_USING_WDT=y -# CONFIG_BSP_USING_USBD is not set +CONFIG_BSP_USING_USBD=y # CONFIG_BSP_USING_USBH is not set CONFIG_BSP_USING_ON_CHIP_FLASH=y CONFIG_BSP_USING_TIM=y diff --git a/apps/chrg/applications/bsp/chrg_usbd.c b/apps/chrg/applications/bsp/chrg_usbd.c deleted file mode 100644 index 28958a3..0000000 --- a/apps/chrg/applications/bsp/chrg_usbd.c +++ /dev/null @@ -1,39 +0,0 @@ - -#include -#include - -#if 0 -void usb_dc_low_level_init (uint8_t busid) -{ - extern void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd); - HAL_PCD_MspInit(&(PCD_HandleTypeDef){ - .Instance = USB_OTG_FS - }); -} - -void OTG_FS_IRQHandler (void) -{ - extern void USBD_IRQHandler(uint8_t busid); - USBD_IRQHandler(0); -} - -int usbd_init(void) -{ - usb_dc_low_level_init(0); - return 0; -} - -INIT_BOARD_EXPORT(usbd_init); - - -int chrg_usbd_init (void) -{ - extern void cdc_acm_init(uint8_t busid, uintptr_t reg_base); - cdc_acm_init(0, USB_OTG_FS_PERIPH_BASE); - - return 0; -} -#endif -//INIT_COMPONENT_EXPORT(chrg_usbd_init); - - diff --git a/apps/chrg/applications/bsp/chrg_vcom.c b/apps/chrg/applications/bsp/chrg_vcom.c new file mode 100644 index 0000000..c4a974b --- /dev/null +++ b/apps/chrg/applications/bsp/chrg_vcom.c @@ -0,0 +1,43 @@ + +#include +#include + +#include "chrg_vcom.h" + +#define DBG_TAG "chrg.vcom" +#include + +int chrg_vcom_init (void) +{ + rt_err_t ret = RT_EOK; + rt_device_t dev = RT_NULL; + + dev = rt_device_find(DEV_NAME_VCOM); + if (RT_NULL == dev) { + LOG_E("device 'vcom' not found."); + return -1; + } + + ret = rt_device_open(dev, RT_DEVICE_FLAG_RDWR); + if (RT_EOK != ret) { + LOG_E("open 'vcom' failed."); + return -1; + } + + return 0; +} + +//INIT_COMPONENT_EXPORT(chrg_vcom_init); + + +int chrg_vcom_console_init (void) +{ + rt_console_set_device(DEV_NAME_VCOM); + + return 0; +} + +INIT_ENV_EXPORT(chrg_vcom_console_init); + + + diff --git a/apps/chrg/applications/bsp/chrg_vcom.h b/apps/chrg/applications/bsp/chrg_vcom.h new file mode 100644 index 0000000..92517fc --- /dev/null +++ b/apps/chrg/applications/bsp/chrg_vcom.h @@ -0,0 +1,11 @@ +#ifndef __CHRG_VCOM_H__ +#define __CHRG_VCOM_H__ + + +#define DEV_NAME_VCOM "vcom" + + + + +#endif + diff --git a/apps/chrg/applications/main.c b/apps/chrg/applications/main.c index a2a97a2..dd3f21c 100644 --- a/apps/chrg/applications/main.c +++ b/apps/chrg/applications/main.c @@ -3,6 +3,8 @@ #include #include +#include +#include #include "shell.h" #include "main.h" @@ -21,6 +23,8 @@ void show_app_version (void) int main(void) { + //rt_uint32_t tick = 0; + #if defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) finsh_set_prompt("chrg "); #endif @@ -28,6 +32,8 @@ int main(void) while (1) { rt_thread_mdelay(1000); chrg_wdt_feed(); + + //rt_kprintf("%d\r\n", ++tick); } } diff --git a/apps/chrg/board/CubeMX_Config/CubeMX_Config.ioc b/apps/chrg/board/CubeMX_Config/CubeMX_Config.ioc index 8ae3a1b..522bf3b 100644 --- a/apps/chrg/board/CubeMX_Config/CubeMX_Config.ioc +++ b/apps/chrg/board/CubeMX_Config/CubeMX_Config.ioc @@ -1,6 +1,10 @@ #MicroXplorer Configuration settings - do not modify +CAD.formats= +CAD.pinconfig= +CAD.provider= File.Version=6 KeepUserPlacement=false +Mcu.CPN=STM32F405RGT6 Mcu.Family=STM32F4 Mcu.IP0=NVIC Mcu.IP1=RCC @@ -20,18 +24,19 @@ Mcu.PinsNb=7 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F405RGTx -MxCube.Version=5.0.0 -MxDb.Version=DB.5.0.0 -NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false +MxCube.Version=6.12.1 +MxDb.Version=DB.6.0.121 +NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.ForceEnableDMAVector=true +NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 -NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false -NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false +NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false +NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false PA2.GPIOParameters=GPIO_PuPd PA2.GPIO_PuPd=GPIO_PULLUP PA2.Mode=Asynchronous @@ -44,14 +49,6 @@ PC14-OSC32_IN.Mode=LSE-External-Oscillator PC14-OSC32_IN.Signal=RCC_OSC32_IN PC15-OSC32_OUT.Mode=LSE-External-Oscillator PC15-OSC32_OUT.Signal=RCC_OSC32_OUT -PCC.Checker=false -PCC.Line=STM32F405/415 -PCC.MCU=STM32F405RGTx -PCC.PartNumber=STM32F405RGTx -PCC.Seq0=0 -PCC.Series=STM32F4 -PCC.Temperature=25 -PCC.Vdd=3.3 PH0-OSC_IN.Mode=HSE-External-Oscillator PH0-OSC_IN.Signal=RCC_OSC_IN PH1-OSC_OUT.Mode=HSE-External-Oscillator @@ -66,7 +63,7 @@ ProjectManager.CustomerFirmwarePackage= ProjectManager.DefaultFWLocation=true ProjectManager.DeletePrevious=true ProjectManager.DeviceId=STM32F405RGTx -ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.23.0 +ProjectManager.FirmwarePackage=STM32Cube FW_F4 V1.28.3 ProjectManager.FreePins=false ProjectManager.HalAssertFull=false ProjectManager.HeapSize=0x200 @@ -79,30 +76,47 @@ ProjectManager.PreviousToolchain= ProjectManager.ProjectBuild=false ProjectManager.ProjectFileName=CubeMX_Config.ioc ProjectManager.ProjectName=CubeMX_Config +ProjectManager.ProjectStructure= +ProjectManager.RegisterCallBack= ProjectManager.StackSize=0x400 ProjectManager.TargetToolchain=EWARM V8 ProjectManager.ToolChainLocation= +ProjectManager.UAScriptAfterPath= +ProjectManager.UAScriptBeforePath= ProjectManager.UnderRoot=false ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART2_UART_Init-USART2-false-HAL-true -RCC.AHBFreq_Value=16000000 -RCC.APB1Freq_Value=16000000 -RCC.APB2Freq_Value=16000000 -RCC.CortexFreq_Value=16000000 +RCC.48MHZClocksFreq_Value=84000000 +RCC.AHBFreq_Value=168000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV4 +RCC.APB1Freq_Value=42000000 +RCC.APB1TimFreq_Value=84000000 +RCC.APB2CLKDivider=RCC_HCLK_DIV2 +RCC.APB2Freq_Value=84000000 +RCC.APB2TimFreq_Value=168000000 +RCC.CortexFreq_Value=168000000 +RCC.EthernetFreq_Value=168000000 +RCC.FCLKCortexFreq_Value=168000000 RCC.FamilyName=M +RCC.HCLKFreq_Value=168000000 RCC.HSE_VALUE=8000000 RCC.HSI_VALUE=16000000 -RCC.I2SClocksFreq_Value=96000000 -RCC.IPParameters=AHBFreq_Value,APB1Freq_Value,APB2Freq_Value,CortexFreq_Value,FamilyName,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSI_VALUE,PLLCLKFreq_Value,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S +RCC.I2SClocksFreq_Value=192000000 +RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSI_VALUE,MCO2PinFreq_Value,PLLCLKFreq_Value,PLLM,PLLN,PLLQCLKFreq_Value,PLLSourceVirtual,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOOutputFreq_Value,VcooutputI2S RCC.LSI_VALUE=32000 -RCC.PLLCLKFreq_Value=96000000 -RCC.PLLQCLKFreq_Value=48000000 +RCC.MCO2PinFreq_Value=168000000 +RCC.PLLCLKFreq_Value=168000000 +RCC.PLLM=4 +RCC.PLLN=168 +RCC.PLLQCLKFreq_Value=84000000 +RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE RCC.RTCFreq_Value=32000 RCC.RTCHSEDivFreq_Value=4000000 -RCC.SYSCLKFreq_VALUE=16000000 -RCC.VCOI2SOutputFreq_Value=192000000 -RCC.VCOInputFreq_Value=1000000 -RCC.VCOOutputFreq_Value=192000000 -RCC.VcooutputI2S=96000000 +RCC.SYSCLKFreq_VALUE=168000000 +RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK +RCC.VCOI2SOutputFreq_Value=384000000 +RCC.VCOInputFreq_Value=2000000 +RCC.VCOOutputFreq_Value=336000000 +RCC.VcooutputI2S=192000000 USART2.IPParameters=VirtualMode USART2.VirtualMode=VM_ASYNC VP_SYS_VS_Systick.Mode=SysTick diff --git a/apps/chrg/board/CubeMX_Config/Src/stm32f4xx_hal_msp.c b/apps/chrg/board/CubeMX_Config/Src/stm32f4xx_hal_msp.c index 0ed354c..faf4e4e 100644 --- a/apps/chrg/board/CubeMX_Config/Src/stm32f4xx_hal_msp.c +++ b/apps/chrg/board/CubeMX_Config/Src/stm32f4xx_hal_msp.c @@ -333,16 +333,6 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) PB11 ------> USART3_RX */ HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10|GPIO_PIN_11); - } else if(huart->Instance==UART5) { - /* Peripheral clock disable */ - __HAL_RCC_UART5_CLK_DISABLE(); - - /**UART5 GPIO Configuration - PC12 ------> UART5_TX - PD2 ------> UART5_RX - */ - HAL_GPIO_DeInit(GPIOC, GPIO_PIN_12); - HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2); } else if(huart->Instance==USART6) { /* Peripheral clock disable */ __HAL_RCC_USART6_CLK_DISABLE(); @@ -357,7 +347,76 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) } +/** +* @brief PCD MSP Initialization +* This function configures the hardware resources used in this example +* @param hpcd: PCD handle pointer +* @retval None +*/ +void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd) +{ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(hpcd->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 + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12; + 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); + + /* Peripheral 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 */ + + } + +} + +/** +* @brief PCD MSP De-Initialization +* This function freeze the hardware resources used in this example +* @param hpcd: PCD handle pointer +* @retval None +*/ +void HAL_PCD_MspDeInit(PCD_HandleTypeDef* hpcd) +{ + if(hpcd->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 + PA11 ------> USB_OTG_FS_DM + PA12 ------> USB_OTG_FS_DP + */ + HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12); + + /* 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 */ + } + +} diff --git a/apps/chrg/board/board.c b/apps/chrg/board/board.c index b55cdbd..7d2d7e3 100644 --- a/apps/chrg/board/board.c +++ b/apps/chrg/board/board.c @@ -2,6 +2,38 @@ #include #include + +void MX_USB_OTG_FS_PCD_Init(void) +{ + PCD_HandleTypeDef hpcd_USB_OTG_FS; + /* 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 SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {0}; @@ -17,10 +49,10 @@ void SystemClock_Config(void) RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 8; - RCC_OscInitStruct.PLL.PLLN = 192; + RCC_OscInitStruct.PLL.PLLM = 4; + RCC_OscInitStruct.PLL.PLLN = 168; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; - RCC_OscInitStruct.PLL.PLLQ = 4; + RCC_OscInitStruct.PLL.PLLQ = 7; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); @@ -34,10 +66,12 @@ void SystemClock_Config(void) RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { Error_Handler(); } + + MX_USB_OTG_FS_PCD_Init(); } diff --git a/apps/chrg/chrg.uvprojx b/apps/chrg/chrg.uvprojx index dff27b3..665372b 100644 --- a/apps/chrg/chrg.uvprojx +++ b/apps/chrg/chrg.uvprojx @@ -337,9 +337,9 @@ 0 - __CLK_TCK=RT_TICK_PER_SECOND, STM32F405xx, RT_USING_ARMLIBC, __RTTHREAD__, USE_HAL_DRIVER, __STDC_LIMIT_MACROS, RT_USING_LIBC + USE_HAL_DRIVER, __RTTHREAD__, RT_USING_LIBC, RT_USING_ARMLIBC, __CLK_TCK=RT_TICK_PER_SECOND, STM32F405xx, __STDC_LIMIT_MACROS - ..\..\rt-thread\components\libc\compilers\common\include;..\..\rt-thread\components\libc\posix\io\eventfd;..\..\rt-thread\components\libc\posix\ipc;..\..\rt-thread\components\drivers\include;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\usb\cherryusb;..\..\rt-thread\components\drivers\usb\cherryusb\class\audio;..\..\rt-thread\components\drivers\usb\cherryusb\class\vendor\net;..\..\rt-thread\components\drivers\smp_call;..\..\rt-thread\components\drivers\usb\cherryusb\class\vendor\serial;applications\bsp;..\..\rt-thread\components\fal\inc;..\..\rt-thread\components\libc\posix\io\epoll;..\..\rt-thread\components\drivers\usb\cherryusb\class\midi;..\..\rt-thread\components\legacy\usb\usbdevice;..\..\rt-thread\components\drivers\usb\cherryusb\class\cdc;applications\thread;..\..\rt-thread\components\libc\compilers\common\extension;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\components\drivers\include;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\components\finsh;..\..\rt-thread\include;..\..\rt-thread\components\drivers\usb\cherryusb\class\hub;..\..\rt-thread\components\drivers\usb\cherryusb\class\vendor\wifi;..\..\rt-thread\components\drivers\include;applications\utils;..\..\rt-thread\libcpu\arm\common;..\..\libs\cmsis-core\Include;board;..\..\rt-thread\components\drivers\phy;..\..\rt-thread\components\drivers\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_flash;board\CubeMX_Config\Inc;..\..\rt-thread\components\drivers\usb\cherryusb\class\msc;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\components\drivers\usb\cherryusb\osal;..\..\rt-thread\components\drivers\include;applications;..\..\rt-thread\components\drivers\usb\cherryusb\class\hid;..\..\rt-thread\components\drivers\include;board\ports;.;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\usb\cherryusb\class\video;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\rt-thread\components\drivers\usb\cherryusb\class\dfu;..\..\rt-thread\components\libc\posix\io\poll;..\..\rt-thread\components\drivers\usb\cherryusb\class\adb;..\..\rt-thread\components\drivers\usb\cherryusb\common;..\..\rt-thread\libcpu\arm\cortex-m4;..\..\rt-thread\components\drivers\usb\cherryusb\class\wireless;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\usb\cherryusb\core + ..\..\rt-thread\components\drivers\include;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers;..\..\libs\stm32f4\STM32F4_HAL\Inc\Legacy;..\..\libs\stm32f4\STM32F4_HAL\Inc;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\config;.;board;..\..\rt-thread\include;..\..\rt-thread\components\drivers\include;board\ports;applications;..\..\rt-thread\components\drivers\phy;..\..\libs\cmsis-core\Include;..\..\rt-thread\components\libc\posix\io\poll;..\..\rt-thread\components\libc\compilers\common\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\smp_call;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_flash;..\..\rt-thread\components\libc\posix\io\epoll;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\ipc;..\..\rt-thread\components\libc\compilers\common\extension\fcntl\octal;..\..\rt-thread\components\fal\inc;applications\utils;..\..\rt-thread\components\drivers\include;applications\thread;board\CubeMX_Config\Inc;..\..\libs\stm32f4\STM32F4_CMSIS\Include;..\..\rt-thread\components\legacy\usb\usbdevice;..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers;..\..\rt-thread\components\finsh;applications\bsp;..\..\rt-thread\libcpu\arm\common;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\posix\io\eventfd;..\..\rt-thread\components\drivers\include;..\..\rt-thread\components\libc\compilers\common\extension;..\..\rt-thread\libcpu\arm\cortex-m4;..\..\rt-thread\components\drivers\include @@ -394,39 +394,24 @@ Applications/bsp - chrg_wdt.c + chrg_fal.c 1 - applications\bsp\chrg_wdt.c + applications\bsp\chrg_fal.c chrg_switch.c 1 applications\bsp\chrg_switch.c - - chrg_fal.c - 1 - applications\bsp\chrg_fal.c - - - chrg_i2c.c - 1 - applications\bsp\chrg_i2c.c - - - chrg_usbd.c - 1 - applications\bsp\chrg_usbd.c - chrg_pin.c 1 applications\bsp\chrg_pin.c - chrg_clk.c + chrg_vcom.c 1 - applications\bsp\chrg_clk.c + applications\bsp\chrg_vcom.c chrg_tmr.c @@ -438,36 +423,51 @@ 1 applications\bsp\chrg_tty.c + + chrg_i2c.c + 1 + applications\bsp\chrg_i2c.c + + + chrg_wdt.c + 1 + applications\bsp\chrg_wdt.c + chrg_intr.c 1 applications\bsp\chrg_intr.c + + chrg_clk.c + 1 + applications\bsp\chrg_clk.c + Applications/thread - - chrg_north.c - 1 - applications\thread\chrg_north.c - chrg_lcd.c 1 applications\thread\chrg_lcd.c - - chrg_comm.c - 1 - applications\thread\chrg_comm.c - chrg_south.c 1 applications\thread\chrg_south.c + + chrg_north.c + 1 + applications\thread\chrg_north.c + + + chrg_comm.c + 1 + applications\thread\chrg_comm.c + chrg_roll.c 1 @@ -479,15 +479,20 @@ Applications/utils - chrg_pkg.c + chrg_sink.c 1 - applications\utils\chrg_pkg.c + applications\utils\chrg_sink.c chrg_utils.c 1 applications\utils\chrg_utils.c + + chrg_pkg.c + 1 + applications\utils\chrg_pkg.c + chrg_pcf8574.c 1 @@ -498,56 +503,6 @@ 1 applications\utils\chrg_source.c - - chrg_sink.c - 1 - applications\utils\chrg_sink.c - - - - - CherryUSB - - - usbd_cdc_acm.c - 1 - ..\..\rt-thread\components\drivers\usb\cherryusb\class\cdc\usbd_cdc_acm.c - - - usb_msh.c - 1 - ..\..\rt-thread\components\drivers\usb\cherryusb\platform\rtthread\usb_msh.c - - - usb_osal_rtthread.c - 1 - ..\..\rt-thread\components\drivers\usb\cherryusb\osal\usb_osal_rtthread.c - - - usb_check.c - 1 - ..\..\rt-thread\components\drivers\usb\cherryusb\platform\rtthread\usb_check.c - - - usbd_core.c - 1 - ..\..\rt-thread\components\drivers\usb\cherryusb\core\usbd_core.c - - - usb_glue_st.c - 1 - ..\..\rt-thread\components\drivers\usb\cherryusb\port\dwc2\usb_glue_st.c - - - usb_dc_dwc2.c - 1 - ..\..\rt-thread\components\drivers\usb\cherryusb\port\dwc2\usb_dc_dwc2.c - - - cdc_acm_template.c - 1 - ..\..\rt-thread\components\drivers\usb\cherryusb\demo\cdc_acm_template.c - @@ -1651,6 +1606,11 @@ 1 ..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_usart.c + + drv_usbd.c + 1 + ..\..\rt-thread\bsp\stm32\libraries\HAL_Drivers\drivers\drv_usbd.c + drv_wdt.c 1 @@ -1671,16 +1631,16 @@ 1 ..\..\rt-thread\components\fal\src\fal_partition.c - - fal_flash.c - 1 - ..\..\rt-thread\components\fal\src\fal_flash.c - fal_rtt.c 1 ..\..\rt-thread\components\fal\src\fal_rtt.c + + fal_flash.c + 1 + ..\..\rt-thread\components\fal\src\fal_flash.c + fal.c 1 @@ -1692,9 +1652,9 @@ Finsh - msh_parse.c + shell.c 1 - ..\..\rt-thread\components\finsh\msh_parse.c + ..\..\rt-thread\components\finsh\shell.c cmd.c @@ -1702,9 +1662,9 @@ ..\..\rt-thread\components\finsh\cmd.c - shell.c + msh_parse.c 1 - ..\..\rt-thread\components\finsh\shell.c + ..\..\rt-thread\components\finsh\msh_parse.c msh.c @@ -2562,9 +2522,9 @@ klibc - kstring.c + kstdio.c 1 - ..\..\rt-thread\src\klibc\kstring.c + ..\..\rt-thread\src\klibc\kstdio.c rt_vsnprintf_tiny.c @@ -2576,16 +2536,16 @@ 1 ..\..\rt-thread\src\klibc\kerrno.c + + kstring.c + 1 + ..\..\rt-thread\src\klibc\kstring.c + rt_vsscanf.c 1 ..\..\rt-thread\src\klibc\rt_vsscanf.c - - kstdio.c - 1 - ..\..\rt-thread\src\klibc\kstdio.c - @@ -2622,125 +2582,40 @@ rt_usbd - usbdevice.c + cdc_vcom.c 1 - ..\..\rt-thread\components\legacy\usb\usbdevice\core\usbdevice.c + ..\..\rt-thread\components\legacy\usb\usbdevice\class\cdc_vcom.c usbdevice_core.c 1 ..\..\rt-thread\components\legacy\usb\usbdevice\core\usbdevice_core.c + + usbdevice.c + 1 + ..\..\rt-thread\components\legacy\usb\usbdevice\core\usbdevice.c + STM32F4-CMSIS - - system_stm32f4xx.c - 1 - ..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\system_stm32f4xx.c - startup_stm32f405xx.s 2 ..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\arm\startup_stm32f405xx.s + + system_stm32f4xx.c + 1 + ..\..\libs\stm32f4\STM32F4_CMSIS\Source\Templates\system_stm32f4xx.c + STM32F4-HAL - - stm32f4xx_hal_dma_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c - - - stm32f4xx_hal_iwdg.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_iwdg.c - - - stm32f4xx_hal_cryp.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c - - - stm32f4xx_hal_dma.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c - - - stm32f4xx_hal.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal.c - - - stm32f4xx_hal_lptim.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_lptim.c - - - stm32f4xx_hal_pcd.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd.c - - - stm32f4xx_hal_flash.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash.c - - - stm32f4xx_hal_i2c_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c_ex.c - - - stm32f4xx_hal_pccard.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pccard.c - - - stm32f4xx_ll_usb.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_ll_usb.c - - - stm32f4xx_hal_pwr_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c - - - stm32f4xx_hal_usart.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_usart.c - - - stm32f4xx_hal_cryp_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp_ex.c - - - stm32f4xx_hal_pcd_ex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd_ex.c - - - stm32f4xx_hal_rcc.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.c - - - stm32f4xx_hal_wwdg.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_wwdg.c - - - stm32f4xx_hal_i2c.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c.c - stm32f4xx_hal_tim.c 1 @@ -2751,40 +2626,45 @@ 1 ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ramfunc.c + + stm32f4xx_hal_pwr_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr_ex.c + + + stm32f4xx_hal_cryp_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp_ex.c + + + stm32f4xx_hal_rcc.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc.c + + + stm32f4xx_hal_flash.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash.c + stm32f4xx_hal_tim_ex.c 1 ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_tim_ex.c - stm32f4xx_hal_uart.c + stm32f4xx_hal.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_uart.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal.c - stm32f4xx_hal_crc.c + stm32f4xx_hal_dma_ex.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma_ex.c - stm32f4xx_hal_can.c + stm32f4xx_hal_pccard.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_can.c - - - stm32f4xx_hal_cortex.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cortex.c - - - stm32f4xx_hal_rng.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c - - - stm32f4xx_hal_cec.c - 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pccard.c stm32f4xx_hal_flash_ex.c @@ -2792,25 +2672,110 @@ ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_flash_ex.c - stm32f4xx_hal_gpio.c + stm32f4xx_hal_dma.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_gpio.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_dma.c - stm32f4xx_hal_pwr.c + stm32f4xx_ll_usb.c 1 - ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_ll_usb.c + + + stm32f4xx_hal_wwdg.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_wwdg.c + + + stm32f4xx_hal_rng.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rng.c stm32f4xx_hal_hcd.c 1 ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_hcd.c + + stm32f4xx_hal_cec.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cec.c + + + stm32f4xx_hal_pwr.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pwr.c + + + stm32f4xx_hal_uart.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_uart.c + + + stm32f4xx_hal_lptim.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_lptim.c + + + stm32f4xx_hal_pcd_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd_ex.c + + + stm32f4xx_hal_gpio.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_gpio.c + + + stm32f4xx_hal_usart.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_usart.c + + + stm32f4xx_hal_pcd.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_pcd.c + + + stm32f4xx_hal_crc.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_crc.c + + + stm32f4xx_hal_cryp.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cryp.c + stm32f4xx_hal_rcc_ex.c 1 ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_rcc_ex.c + + stm32f4xx_hal_can.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_can.c + + + stm32f4xx_hal_iwdg.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_iwdg.c + + + stm32f4xx_hal_i2c.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c.c + + + stm32f4xx_hal_i2c_ex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_i2c_ex.c + + + stm32f4xx_hal_cortex.c + 1 + ..\..\libs\stm32f4\STM32F4_HAL\Src\stm32f4xx_hal_cortex.c + diff --git a/apps/chrg/rtconfig.h b/apps/chrg/rtconfig.h index d487adf..94a379a 100644 --- a/apps/chrg/rtconfig.h +++ b/apps/chrg/rtconfig.h @@ -163,14 +163,6 @@ #define RT_USING_WDT #define RT_USING_PIN #define RT_USING_HWTIMER -#define RT_USING_CHERRYUSB -#define RT_CHERRYUSB_DEVICE -#define RT_CHERRYUSB_DEVICE_SPEED_FS -#define RT_CHERRYUSB_DEVICE_DWC2_ST -#define RT_CHERRYUSB_DEVICE_CDC_ACM -#define CONFIG_USBDEV_REQUEST_BUFFER_LEN 512 -#define CONFIG_USBDEV_MSC_MAX_BUFSIZE 512 -#define RT_CHERRYUSB_DEVICE_TEMPLATE_CDC_ACM /* end of Device Drivers */ /* C/C++ and POSIX layer */ @@ -217,8 +209,14 @@ #define RT_USBD_THREAD_STACK_SZ 4096 #define USB_VENDOR_ID 0x0483 #define USB_PRODUCT_ID 0x5740 -#define _RT_USB_DEVICE_NONE +#define RT_USB_DEVICE_COMPOSITE +#define RT_USB_DEVICE_CDC #define RT_USB_DEVICE_NONE +#define RT_VCOM_TASK_STK_SIZE 512 +#define RT_CDC_RX_BUFSIZE 128 +#define RT_VCOM_SERNO "32021919830108" +#define RT_VCOM_SER_LEN 14 +#define RT_VCOM_TX_TIMEOUT 1000 /* end of Using USB legacy version */ /* end of RT-Thread Components */ @@ -445,7 +443,6 @@ #define BSP_USING_UART3 #define BSP_UART3_RX_USING_DMA #define BSP_UART3_TX_USING_DMA -#define BSP_USING_UART5 #define BSP_USING_UART6 #define BSP_UART6_RX_USING_DMA #define BSP_UART6_TX_USING_DMA @@ -455,6 +452,7 @@ #define BSP_USING_I2C3 #define BSP_USING_I2C4 #define BSP_USING_WDT +#define BSP_USING_USBD #define BSP_USING_ON_CHIP_FLASH #define BSP_USING_TIM #define BSP_USING_TIM2 diff --git a/rt-thread/bsp/stm32/libraries/HAL_Drivers/drivers/drv_soft_i2c.h b/rt-thread/bsp/stm32/libraries/HAL_Drivers/drivers/drv_soft_i2c.h index 05ab687..b3171db 100644 --- a/rt-thread/bsp/stm32/libraries/HAL_Drivers/drivers/drv_soft_i2c.h +++ b/rt-thread/bsp/stm32/libraries/HAL_Drivers/drivers/drv_soft_i2c.h @@ -17,17 +17,17 @@ #include "drv_gpio.h" -#define BSP_I2C1_SCL_PIN GET_PIN(C, 0) -#define BSP_I2C1_SDA_PIN GET_PIN(C, 1) +#define BSP_I2C1_SCL_PIN GET_PIN(C, 2) +#define BSP_I2C1_SDA_PIN GET_PIN(C, 3) -#define BSP_I2C2_SCL_PIN GET_PIN(A, 0) -#define BSP_I2C2_SDA_PIN GET_PIN(A, 1) +#define BSP_I2C2_SCL_PIN GET_PIN(A, 4) +#define BSP_I2C2_SDA_PIN GET_PIN(A, 5) -#define BSP_I2C3_SCL_PIN GET_PIN(A, 6) -#define BSP_I2C3_SDA_PIN GET_PIN(A, 7) +#define BSP_I2C3_SCL_PIN GET_PIN(C, 4) +#define BSP_I2C3_SDA_PIN GET_PIN(C, 5) -#define BSP_I2C4_SCL_PIN GET_PIN(B, 12) -#define BSP_I2C4_SDA_PIN GET_PIN(B, 13) +#define BSP_I2C4_SCL_PIN GET_PIN(B, 14) +#define BSP_I2C4_SDA_PIN GET_PIN(B, 15) /* stm32 config class */ struct stm32_soft_i2c_config