From 9d791ab56d4eef781a2f20fb24e8389a07f0889e Mon Sep 17 00:00:00 2001 From: ThinkPad-T460P Date: Fri, 18 Dec 2020 12:46:59 +0800 Subject: [PATCH] v0.9.2 --- .cproject | 12 ++-- Core/Inc/FreeRTOSConfig.h | 20 ++++++- Core/Inc/navikit.h | 6 +- Core/Src/freertos.c | 86 +++++++++++++++++---------- Core/Src/main.c | 22 ++----- Core/Src/navikit.c | 8 ++- Core/Src/stm32f1xx_hal_timebase_tim.c | 2 +- Core/Src/stm32f1xx_it.c | 1 - NaviKit_stm32.ioc | 69 +++++++++++---------- USB_DEVICE/App/usb_device.c | 10 ++++ USB_DEVICE/App/usb_device.h | 2 +- 11 files changed, 148 insertions(+), 90 deletions(-) diff --git a/.cproject b/.cproject index 74b66f6..f970a1d 100644 --- a/.cproject +++ b/.cproject @@ -14,18 +14,18 @@ - + diff --git a/Core/Inc/FreeRTOSConfig.h b/Core/Inc/FreeRTOSConfig.h index d4ab828..9e35702 100644 --- a/Core/Inc/FreeRTOSConfig.h +++ b/Core/Inc/FreeRTOSConfig.h @@ -74,6 +74,7 @@ #define configUSE_RECURSIVE_MUTEXES 1 #define configUSE_COUNTING_SEMAPHORES 1 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +#define configUSE_TICKLESS_IDLE 1 /* Co-routine definitions. */ #define configUSE_CO_ROUTINES 0 @@ -90,16 +91,20 @@ to exclude the API function. */ #define INCLUDE_vTaskPrioritySet 1 #define INCLUDE_uxTaskPriorityGet 1 #define INCLUDE_vTaskDelete 1 -#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskCleanUpResources 1 #define INCLUDE_vTaskSuspend 1 #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 #define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_xEventGroupSetBitFromISR 1 #define INCLUDE_xTimerPendFunctionCall 1 #define INCLUDE_xQueueGetMutexHolder 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 +#define INCLUDE_pcTaskGetTaskName 1 #define INCLUDE_uxTaskGetStackHighWaterMark 1 #define INCLUDE_xTaskGetCurrentTaskHandle 1 #define INCLUDE_eTaskGetState 1 +#define INCLUDE_xTaskAbortDelay 1 #define INCLUDE_xTaskGetHandle 1 /* @@ -159,4 +164,17 @@ standard names. */ /* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ /* USER CODE END Defines */ +#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) +void PreSleepProcessing(uint32_t *ulExpectedIdleTime); +void PostSleepProcessing(uint32_t *ulExpectedIdleTime); +#endif /* defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) */ + +/* The configPRE_SLEEP_PROCESSING() and configPOST_SLEEP_PROCESSING() macros +allow the application writer to add additional code before and after the MCU is +placed into the low power state respectively. */ +#if configUSE_TICKLESS_IDLE == 1 +#define configPRE_SLEEP_PROCESSING PreSleepProcessing +#define configPOST_SLEEP_PROCESSING PostSleepProcessing +#endif /* configUSE_TICKLESS_IDLE == 1 */ + #endif /* FREERTOS_CONFIG_H */ diff --git a/Core/Inc/navikit.h b/Core/Inc/navikit.h index f2246cc..c04b81b 100644 --- a/Core/Inc/navikit.h +++ b/Core/Inc/navikit.h @@ -117,9 +117,13 @@ void enter_runing_state(); void enter_shutdown_state(); void enter_sleep_state(); void enter_dfu_state(); - void Beep(uint32_t time_ms); void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc); + + +void osEnterRuningState(); +void osEnterSleepState(); + #endif /* INC_NAVIKIT_H_ */ diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index 09582b0..5ad7326 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -1,10 +1,3 @@ -/* - * @Description: - * @Date: 2020-04-02 21:44:31 - * @LastEditors: CK.Zh - * @LastEditTime: 2020-12-17 20:08:43 - * @FilePath: \NaviKit_stm32\Core\Src\freertos.c - */ /* USER CODE BEGIN Header */ /** ****************************************************************************** @@ -185,6 +178,18 @@ void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName) } /* USER CODE END 4 */ +/* USER CODE BEGIN PREPOSTSLEEP */ +__weak void PreSleepProcessing(uint32_t *ulExpectedIdleTime) +{ +/* place for user code */ +} + +__weak void PostSleepProcessing(uint32_t *ulExpectedIdleTime) +{ +/* place for user code */ +} +/* USER CODE END PREPOSTSLEEP */ + /** * @brief FreeRTOS initialization * @param None @@ -219,7 +224,7 @@ void MX_FREERTOS_Init(void) { LedBlinkTaskHandle = osThreadNew(StartLedBlinkTask, NULL, &LedBlinkTask_attributes); /* creation of IWDGRefreshTask */ - // IWDGRefreshTaskHandle = osThreadNew(StartIWDGRefreshTask, NULL, &IWDGRefreshTask_attributes); +// IWDGRefreshTaskHandle = osThreadNew(StartIWDGRefreshTask, NULL, &IWDGRefreshTask_attributes); /* creation of EventDetect */ EventDetectHandle = osThreadNew(StartEventDetect, NULL, &EventDetect_attributes); @@ -254,7 +259,7 @@ void MX_FREERTOS_Init(void) { void StartDefaultTask(void *argument) { /* init code for USB_DEVICE */ - MX_USB_DEVICE_Init(); +// MX_USB_DEVICE_Init(); /* USER CODE BEGIN StartDefaultTask */ osVersion_t osVersion; char id_buf[20]; @@ -279,11 +284,11 @@ void StartDefaultTask(void *argument) Log(info,"Core initial successfully"); Log(info,"----------------------------------------------"); - osEnterSleepState(); +// osEnterSleepState(); /* Infinite loop */ for(;;) { - osDelay(100); + osDelay(1000); } /* USER CODE END StartDefaultTask */ @@ -535,9 +540,10 @@ void StartStateSwitchTask(void *argument) { case shutdown: {//only from running state - if((NaviKit.sys.sta == running))// && (NaviKit.som.shutdown_req == true) + if((NaviKit.sys.sta == running)){// && (NaviKit.som.shutdown_req == true) enter_shutdown_state(); - osEnterSleepState(); +// osEnterSleepState(); + } }break; case running: {//from sleep and shutdown state @@ -579,22 +585,31 @@ void StartPowerMonitTask(void *argument) /* Infinite loop */ for(;;) { - if(NaviKit.pmb.rails.out_24v > 26.4 || NaviKit.pmb.rails.out_24v < 21.6){ - Log(error,"24V power rail exception:%f",NaviKit.pmb.rails.out_24v); - } - if(NaviKit.pmb.rails.out_5v > 5.5 || NaviKit.pmb.rails.out_5v < 4.5){ - Log(error,"5V power rail exception:%f",NaviKit.pmb.rails.out_5v); - } - if(NaviKit.pmb.rails.out_12v > 13.2 || NaviKit.pmb.rails.out_12v < 10.8){ - Log(error ,"12V power rail exception:%f",NaviKit.pmb.rails.out_12v); - } - if(NaviKit.pmb.rails.bkp_bat < 10){ - Log(warning,"Backup power is not online"); - } - if(NaviKit.pmb.rails.main_pwr < 19){ - Beep(100); - Log(warning,"Main power has been lost, please shutdown computer as soon as possible"); - } + if(NaviKit.sys.sta == running){ + if(NaviKit.pmb.rails.out_24v > 26.4 || NaviKit.pmb.rails.out_24v < 21.6){ + Log(error,"24V(±10%) power rail exception:%dV",NaviKit.pmb.rails.out_24v); + } + if(NaviKit.pmb.rails.out_5v > 5.5 || NaviKit.pmb.rails.out_5v < 4.5){ + Log(error,"5V(±10%) power rail exception:%dV",NaviKit.pmb.rails.out_5v); + } + if(NaviKit.pmb.rails.out_12v > 13.2 || NaviKit.pmb.rails.out_12v < 10.8){ + Log(error ,"12V(±10%) power rail exception:%dV",NaviKit.pmb.rails.out_12v); + } + if(NaviKit.pmb.rails.bkp_bat < 10){ + Log(warning,"Backup power is not online"); + } + if(NaviKit.pmb.rails.main_pwr < 19){ + Beep(100); + Log(warning,"Main power has been lost, please shutdown computer as soon as possible"); + } + } + if(NaviKit.pmb.rails.bkp_bat > 15){ + Log(error,"Backup power is exception:%dV",NaviKit.pmb.rails.bkp_bat); + } + if(NaviKit.pmb.rails.main_pwr > 30){ + Beep(100); + Log(error,"Backup power is exception:%dV",NaviKit.pmb.rails.main_pwr); + } osDelay(5000); } @@ -607,8 +622,11 @@ void StartPowerMonitTask(void *argument) //os enter sleep state for save power void osEnterSleepState(){ Log(info,"EC Enter Sleep State"); + HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_SET);//turn off sys run led vTaskSuspendAll(); +// osKernelLock(); HAL_SuspendTick(); +// MX_USB_DEVICE_DeInit(); HAL_I2C_MspDeInit(&hi2c1); HAL_ADC_MspDeInit(&hadc1); HAL_ADC_Stop_DMA(&hadc1); @@ -617,13 +635,17 @@ void osEnterSleepState(){ } void osEnterRuningState(){ HAL_ResumeTick(); + // MX_USB_DEVICE_Init(); HAL_I2C_MspInit(&hi2c1); HAL_ADC_MspInit(&hadc1); HAL_ADC_Start_DMA(&hadc1, (uint32_t*)&(NaviKit.pmb.rails.adc), ADC_CH_COUNT); - xTaskResumeAll(); + __set_CONTROL(0); + xTaskResumeAll(); +// osKernelUnlock(); + NaviKit.sys.next_sta = running; Log(info,"EC Enter Runing State"); } -//printf redefine +//printf redirect #ifdef __GNUC__ //#define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #define PUTCHAR_PROTOTYPE int putchar(int ch) @@ -634,7 +656,7 @@ void osEnterRuningState(){ PUTCHAR_PROTOTYPE { while(HAL_UART_GetState(&huart1) == HAL_UART_STATE_BUSY_TX){} - HAL_UART_Transmit(&huart1,(uint8_t *)&ch,1,0xffff); + HAL_UART_Transmit(&huart1,(uint8_t *)&ch,1,1); return ch; } diff --git a/Core/Src/main.c b/Core/Src/main.c index 26a9551..b9b9759 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -1,10 +1,3 @@ -/* - * @Description: - * @Date: 2020-02-20 11:40:37 - * @LastEditors: CK.Zh - * @LastEditTime: 2020-12-17 19:24:44 - * @FilePath: \NaviKit_stm32\Core\Src\main.c - */ /* USER CODE BEGIN Header */ /** ****************************************************************************** @@ -157,7 +150,7 @@ void SystemClock_Config(void) RCC_OscInitStruct.Prediv1Source = RCC_PREDIV1_SOURCE_HSE; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL4; + RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL6; RCC_OscInitStruct.PLL2.PLL2State = RCC_PLL_NONE; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { @@ -168,11 +161,11 @@ void SystemClock_Config(void) RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV2; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV4; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV8; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV8; - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) { Error_Handler(); } @@ -180,14 +173,11 @@ void SystemClock_Config(void) |RCC_PERIPHCLK_USB; PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV8; - PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV2; + PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV3; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { Error_Handler(); } - /** Enables the Clock Security System - */ - HAL_RCC_EnableCSS(); /** Configure the Systick interrupt time */ __HAL_RCC_PLLI2S_ENABLE(); diff --git a/Core/Src/navikit.c b/Core/Src/navikit.c index 6ce73d9..11a66c0 100644 --- a/Core/Src/navikit.c +++ b/Core/Src/navikit.c @@ -73,6 +73,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {//Rising edge trigger NaviKit.sys.power_btn = true; Log(debug,"power_btn pushed"); + if(NaviKit.sys.sta==shutdown){ +// osEnterRuningState(); + } } if(HAL_GPIO_ReadPin(SYS_POWER_BTN_GPIO_Port, SYS_POWER_BTN_Pin)==GPIO_PIN_RESET) {//falling edge trigger @@ -95,7 +98,8 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) } } - +__weak void osEnterRuningState(){} +__weak void osEnterSleepState(){} //write "bios update flag" to bkp register, and reset system void enter_isp_state() @@ -163,6 +167,7 @@ void enter_shutdown_state() HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port ,PMB_PS_ON_Pin, GPIO_PIN_RESET); HAL_Delay(100); + MX_USB_DEVICE_DeInit(); } void enter_sleep_state() @@ -231,6 +236,7 @@ void enter_runing_state() HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_SET); HAL_Delay(100); + MX_USB_DEVICE_Init(); } void enter_dfu_state() diff --git a/Core/Src/stm32f1xx_hal_timebase_tim.c b/Core/Src/stm32f1xx_hal_timebase_tim.c index b72345c..2b5469f 100644 --- a/Core/Src/stm32f1xx_hal_timebase_tim.c +++ b/Core/Src/stm32f1xx_hal_timebase_tim.c @@ -57,7 +57,7 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) HAL_RCC_GetClockConfig(&clkconfig, &pFLatency); /* Compute TIM1 clock */ - uwTimclock = HAL_RCC_GetPCLK2Freq(); + uwTimclock = 2*HAL_RCC_GetPCLK2Freq(); /* Compute the prescaler value to have TIM1 counter clock equal to 1MHz */ uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U); diff --git a/Core/Src/stm32f1xx_it.c b/Core/Src/stm32f1xx_it.c index 105ac7e..c4414d8 100644 --- a/Core/Src/stm32f1xx_it.c +++ b/Core/Src/stm32f1xx_it.c @@ -80,7 +80,6 @@ void NMI_Handler(void) /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ /* USER CODE END NonMaskableInt_IRQn 0 */ - HAL_RCC_NMI_IRQHandler(); /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ /* USER CODE END NonMaskableInt_IRQn 1 */ diff --git a/NaviKit_stm32.ioc b/NaviKit_stm32.ioc index be00c5a..7dd286a 100644 --- a/NaviKit_stm32.ioc +++ b/NaviKit_stm32.ioc @@ -67,9 +67,14 @@ Dma.Request0=ADC1 Dma.RequestsNb=1 FREERTOS.FootprintOK=true FREERTOS.HEAP_NUMBER=4 +FREERTOS.INCLUDE_pcTaskGetTaskName=1 +FREERTOS.INCLUDE_vTaskCleanUpResources=1 +FREERTOS.INCLUDE_xEventGroupSetBitFromISR=1 +FREERTOS.INCLUDE_xSemaphoreGetMutexHolder=1 +FREERTOS.INCLUDE_xTaskAbortDelay=1 FREERTOS.INCLUDE_xTaskGetCurrentTaskHandle=1 FREERTOS.INCLUDE_xTaskGetHandle=1 -FREERTOS.IPParameters=Tasks01,configMAX_TASK_NAME_LEN,configUSE_TICKLESS_IDLE,INCLUDE_xTaskGetCurrentTaskHandle,INCLUDE_xTaskGetHandle,configUSE_APPLICATION_TASK_TAG,FootprintOK,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,configGENERATE_RUN_TIME_STATS,configUSE_STATS_FORMATTING_FUNCTIONS,configUSE_TRACE_FACILITY,HEAP_NUMBER,configTOTAL_HEAP_SIZE,configCHECK_FOR_STACK_OVERFLOW,configUSE_TASK_NOTIFICATIONS +FREERTOS.IPParameters=Tasks01,configMAX_TASK_NAME_LEN,configUSE_TICKLESS_IDLE,INCLUDE_xTaskGetCurrentTaskHandle,INCLUDE_xTaskGetHandle,configUSE_APPLICATION_TASK_TAG,FootprintOK,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,configGENERATE_RUN_TIME_STATS,configUSE_STATS_FORMATTING_FUNCTIONS,configUSE_TRACE_FACILITY,HEAP_NUMBER,configTOTAL_HEAP_SIZE,configCHECK_FOR_STACK_OVERFLOW,configUSE_TASK_NOTIFICATIONS,INCLUDE_xTaskAbortDelay,INCLUDE_xEventGroupSetBitFromISR,INCLUDE_xSemaphoreGetMutexHolder,INCLUDE_pcTaskGetTaskName,INCLUDE_vTaskCleanUpResources FREERTOS.Tasks01=defaultTask,24,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL;LedBlinkTask,8,128,StartLedBlinkTask,Default,NULL,Dynamic,NULL,NULL;IWDGRefreshTask,40,128,StartIWDGRefreshTask,Default,NULL,Dynamic,NULL,NULL;EventDetect,8,128,StartEventDetect,Default,NULL,Dynamic,NULL,NULL;CoulombRead,8,128,StartCoulombRead,Default,NULL,Dynamic,NULL,NULL;StateSwitchTask,8,128,StartStateSwitchTask,Default,NULL,Dynamic,NULL,NULL;PowerMonitTask,8,128,StartPowerMonitTask,Default,NULL,Dynamic,NULL,NULL FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1 FREERTOS.configGENERATE_RUN_TIME_STATS=1 @@ -80,7 +85,7 @@ FREERTOS.configUSE_IDLE_HOOK=1 FREERTOS.configUSE_MALLOC_FAILED_HOOK=0 FREERTOS.configUSE_STATS_FORMATTING_FUNCTIONS=0 FREERTOS.configUSE_TASK_NOTIFICATIONS=1 -FREERTOS.configUSE_TICKLESS_IDLE=0 +FREERTOS.configUSE_TICKLESS_IDLE=1 FREERTOS.configUSE_TICK_HOOK=1 FREERTOS.configUSE_TRACE_FACILITY=0 File.Version=6 @@ -198,7 +203,7 @@ NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.I2C1_ER_IRQn=true\:5\:0\:true\:true\:true\:7\:false\:true\:true NVIC.I2C1_EV_IRQn=true\:5\:0\:false\:true\:true\:6\:true\:true\:true NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true +NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.OTG_FS_IRQn=true\:5\:0\:false\:true\:true\:4\:true\:false\:true NVIC.PVD_IRQn=true\:5\:0\:true\:true\:true\:1\:false\:true\:true NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false @@ -556,36 +561,37 @@ ProjectManager.TargetToolchain=STM32CubeIDE ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=true ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-true,4-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,5-MX_I2C1_Init-I2C1-false-HAL-true,6-MX_IWDG_Init-IWDG-false-HAL-true,7-MX_UART4_Init-UART4-false-HAL-true,8-MX_ADC1_Init-ADC1-false-HAL-true,9-MX_USART1_UART_Init-USART1-false-HAL-true,10-MX_RTC_Init-RTC-false-HAL-true -RCC.ADCFreqValue=3000000 +RCC.ADCFreqValue=281250 RCC.ADCPresc=RCC_ADCPCLK2_DIV8 -RCC.AHBCLKDivider=RCC_SYSCLK_DIV2 -RCC.AHBFreq_Value=24000000 -RCC.APB1CLKDivider=RCC_HCLK_DIV2 -RCC.APB1Freq_Value=12000000 -RCC.APB1TimFreq_Value=24000000 -RCC.APB2Freq_Value=24000000 -RCC.APB2TimFreq_Value=24000000 -RCC.EnbaleCSS=true -RCC.FCLKCortexFreq_Value=24000000 +RCC.AHBCLKDivider=RCC_SYSCLK_DIV4 +RCC.AHBFreq_Value=18000000 +RCC.APB1CLKDivider=RCC_HCLK_DIV8 +RCC.APB1Freq_Value=2250000 +RCC.APB1TimFreq_Value=4500000 +RCC.APB2CLKDivider=RCC_HCLK_DIV8 +RCC.APB2Freq_Value=2250000 +RCC.APB2TimFreq_Value=4500000 +RCC.FCLKCortexFreq_Value=18000000 RCC.FamilyName=M -RCC.HCLKFreq_Value=24000000 +RCC.HCLKFreq_Value=18000000 RCC.HSE_VALUE=12000000 -RCC.I2S2Freq_Value=48000000 -RCC.I2S3Freq_Value=48000000 -RCC.IPParameters=ADCFreqValue,ADCPresc,AHBCLKDivider,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,EnbaleCSS,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,I2S2Freq_Value,I2S3Freq_Value,MCOFreq_Value,PLL2CLKoutputFreqValue,PLL2VCOoutputFreqValue,PLL3CLKoutputFreqValue,PLL3VCOoutputFreqValue,PLLCLKFreq_Value,Prediv2,Prediv2FreqValue,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,USBPrescaler,VCOOutput2Freq_Value -RCC.MCOFreq_Value=48000000 -RCC.PLL2CLKoutputFreqValue=48000000 -RCC.PLL2VCOoutputFreqValue=96000000 -RCC.PLL3CLKoutputFreqValue=48000000 -RCC.PLL3VCOoutputFreqValue=96000000 -RCC.PLLCLKFreq_Value=48000000 -RCC.Prediv2=RCC_HSE_PREDIV2_DIV2 -RCC.Prediv2FreqValue=6000000 -RCC.SYSCLKFreq_VALUE=48000000 +RCC.I2S2Freq_Value=72000000 +RCC.I2S3Freq_Value=72000000 +RCC.IPParameters=ADCFreqValue,ADCPresc,AHBCLKDivider,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,I2S2Freq_Value,I2S3Freq_Value,MCOFreq_Value,PLL2CLKoutputFreqValue,PLL2VCOoutputFreqValue,PLL3CLKoutputFreqValue,PLL3VCOoutputFreqValue,PLLCLKFreq_Value,PLLMUL,Prediv2,Prediv2FreqValue,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,TimSys_Div,USBFreq_Value,VCOOutput2Freq_Value +RCC.MCOFreq_Value=72000000 +RCC.PLL2CLKoutputFreqValue=6000000 +RCC.PLL2VCOoutputFreqValue=12000000 +RCC.PLL3CLKoutputFreqValue=6000000 +RCC.PLL3VCOoutputFreqValue=12000000 +RCC.PLLCLKFreq_Value=72000000 +RCC.PLLMUL=RCC_PLL_MUL6 +RCC.Prediv2=RCC_HSE_PREDIV2_DIV16 +RCC.Prediv2FreqValue=750000 +RCC.SYSCLKFreq_VALUE=72000000 RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK -RCC.TimSysFreq_Value=24000000 +RCC.TimSysFreq_Value=2250000 +RCC.TimSys_Div=SYSTICK_CLKSOURCE_HCLK_DIV8 RCC.USBFreq_Value=48000000 -RCC.USBPrescaler=RCC_USBCLKSOURCE_PLL_DIV2 RCC.VCOOutput2Freq_Value=12000000 SH.ADCx_IN3.0=ADC1_IN3,IN3 SH.ADCx_IN3.ConfNb=1 @@ -609,10 +615,13 @@ SH.GPXTI7.0=GPIO_EXTI7 SH.GPXTI7.ConfNb=1 SH.GPXTI8.0=GPIO_EXTI8 SH.GPXTI8.ConfNb=1 -UART4.IPParameters=VirtualMode +UART4.BaudRate=115200 +UART4.IPParameters=VirtualMode,BaudRate +UART4.IPParametersWithoutCheck=BaudRate UART4.VirtualMode=Asynchronous -USART1.IPParameters=VirtualMode +USART1.IPParameters=VirtualMode,WordLength USART1.VirtualMode=VM_ASYNC +USART1.WordLength=WORDLENGTH_8B USB_DEVICE.CLASS_NAME_FS=CDC USB_DEVICE.IPParameters=VirtualMode,VirtualModeFS,CLASS_NAME_FS,USBD_DEBUG_LEVEL USB_DEVICE.USBD_DEBUG_LEVEL=3 diff --git a/USB_DEVICE/App/usb_device.c b/USB_DEVICE/App/usb_device.c index ecf76c2..9d1b39d 100644 --- a/USB_DEVICE/App/usb_device.c +++ b/USB_DEVICE/App/usb_device.c @@ -55,7 +55,17 @@ USBD_HandleTypeDef hUsbDeviceFS; * -- Insert your external function declaration here -- */ /* USER CODE BEGIN 1 */ +void MX_USB_DEVICE_DeInit(void){ + if (USBD_Stop(&hUsbDeviceFS) != USBD_OK) + { + Error_Handler(); + } + if (USBD_DeInit(&hUsbDeviceFS) != USBD_OK) + { + Error_Handler(); + } +} /* USER CODE END 1 */ /** diff --git a/USB_DEVICE/App/usb_device.h b/USB_DEVICE/App/usb_device.h index 3a90deb..29fb1dd 100644 --- a/USB_DEVICE/App/usb_device.h +++ b/USB_DEVICE/App/usb_device.h @@ -82,7 +82,7 @@ void MX_USB_DEVICE_Init(void); * -- Insert functions declaration here -- */ /* USER CODE BEGIN FD */ - +void MX_USB_DEVICE_DeInit(void); /* USER CODE END FD */ /** * @}