v0.9.2
parent
f91a03e740
commit
9d791ab56d
12
.cproject
12
.cproject
|
@ -14,18 +14,18 @@
|
|||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.502298629" name="Debug" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug">
|
||||
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.502298629" name="Debug" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug">
|
||||
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.502298629." name="/" resourcePath="">
|
||||
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.217041015" name="MCU ARM GCC" nonInternalBuilderId="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug">
|
||||
<option id="com.st.stm32cube.ide.mcu.option.internal.toolchain.type.265410504" name="Internal Toolchain Type" superClass="com.st.stm32cube.ide.mcu.option.internal.toolchain.type" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.base.gnu-tools-for-stm32" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.option.internal.toolchain.version.1736166454" name="Internal Toolchain Version" superClass="com.st.stm32cube.ide.mcu.option.internal.toolchain.version" useByScannerDiscovery="false" value="7-2018-q2-update" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.option.internal.toolchain.version.1736166454" name="Internal Toolchain Version" superClass="com.st.stm32cube.ide.mcu.option.internal.toolchain.version" useByScannerDiscovery="false" value="9-2020-q2-update" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.604074274" name="Mcu" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32F107VCTx" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.433736509" name="CpuId" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.276377927" name="CpuCoreId" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid" useByScannerDiscovery="false" value="0" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1980681105" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="genericBoard" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1465740073" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.3 || Debug || true || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.base.gnu-tools-for-stm32 || STM32F107VCTx || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Middlewares/Third_Party/FreeRTOS/Source/include | ../USB_DEVICE/Target | ../Drivers/CMSIS/Device/ST/STM32F1xx/Include | ../Drivers/CMSIS/Include | ../Core/Inc | ../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc | ../USB_DEVICE/App | ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy | ../Drivers/STM32F1xx_HAL_Driver/Inc | ../Middlewares/ST/STM32_USB_Device_Library/Core/Inc | ../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 | ../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3 || || || USE_HAL_DRIVER | STM32F107xC || || Drivers | CMSIS | Core/Startup | Middlewares | Core | USB_DEVICE || || || ${workspace_loc:/${ProjName}/STM32F107VCTX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || " valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat.1573745116" name="Use float with printf from newlib-nano (-u _printf_float)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoscanffloat.142703396" name="Use float with scanf from newlib-nano (-u _scanf_float)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoscanffloat" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat.1573745116" name="Use float with printf from newlib-nano (-u _printf_float)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoscanffloat.142703396" name="Use float with scanf from newlib-nano (-u _scanf_float)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoscanffloat" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c.1187387752" name="Runtime library" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.runtimelibrary_c.value.standard_c" valueType="enumerated"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.1986680919" name="Convert to Intel Hex file (-O ihex)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary.1096157515" name="Convert to binary file (-O binary)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
|
@ -43,7 +43,7 @@
|
|||
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
|
||||
<listOptionValue builtIn="false" value="STM32F107xC"/>
|
||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||
<listOptionValue builtIn="false" value="APP_VERSION="V0.9.1""/>
|
||||
<listOptionValue builtIn="false" value="APP_VERSION="V0.9.2""/>
|
||||
</option>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.186388616" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="../Core/Inc"/>
|
||||
|
@ -98,8 +98,8 @@
|
|||
<sourceEntries>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="CMSIS"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_DEVICE"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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
|
||||
|
@ -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,14 +585,15 @@ void StartPowerMonitTask(void *argument)
|
|||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
if(NaviKit.sys.sta == running){
|
||||
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);
|
||||
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 power rail exception:%f",NaviKit.pmb.rails.out_5v);
|
||||
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 power rail exception:%f",NaviKit.pmb.rails.out_12v);
|
||||
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");
|
||||
|
@ -595,6 +602,14 @@ void StartPowerMonitTask(void *argument)
|
|||
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);
|
||||
__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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 */
|
||||
/**
|
||||
* @}
|
||||
|
|
Loading…
Reference in New Issue