diff --git a/Core/Inc/FreeRTOSConfig.h b/Core/Inc/FreeRTOSConfig.h index 738e99a..d49f4bb 100644 --- a/Core/Inc/FreeRTOSConfig.h +++ b/Core/Inc/FreeRTOSConfig.h @@ -54,7 +54,7 @@ #define configUSE_PREEMPTION 1 #define configSUPPORT_STATIC_ALLOCATION 1 #define configSUPPORT_DYNAMIC_ALLOCATION 1 -#define configUSE_IDLE_HOOK 1 +#define configUSE_IDLE_HOOK 0 #define configUSE_TICK_HOOK 0 #define configCPU_CLOCK_HZ ( SystemCoreClock ) #define configTICK_RATE_HZ ((TickType_t)1000) @@ -62,11 +62,9 @@ #define configMINIMAL_STACK_SIZE ((uint16_t)128) #define configTOTAL_HEAP_SIZE ((size_t)8192) #define configMAX_TASK_NAME_LEN ( 32 ) -#define configUSE_TRACE_FACILITY 1 #define configUSE_16_BIT_TICKS 0 #define configUSE_MUTEXES 1 #define configQUEUE_REGISTRY_SIZE 8 -#define configCHECK_FOR_STACK_OVERFLOW 1 #define configUSE_RECURSIVE_MUTEXES 1 #define configUSE_COUNTING_SEMAPHORES 1 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index 8ec1874..d6c7b5f 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -104,16 +104,18 @@ const osThreadAttr_t PowerMonitTask_attributes = { .priority = (osPriority_t) osPriorityLow, .stack_size = 128 * 4 }; +/* Definitions for uartQueueTask */ +osThreadId_t uartQueueTaskHandle; +const osThreadAttr_t uartQueueTask_attributes = { + .name = "uartQueueTask", + .priority = (osPriority_t) osPriorityLow, + .stack_size = 128 * 4 +}; /* Definitions for uartQueue */ osMessageQueueId_t uartQueueHandle; const osMessageQueueAttr_t uartQueue_attributes = { .name = "uartQueue" }; -/* Definitions for uartMutex */ -osMutexId_t uartMutexHandle; -const osMutexAttr_t uartMutex_attributes = { - .name = "uartMutex" -}; /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN FunctionPrototypes */ @@ -126,38 +128,11 @@ void StartEventDetect(void *argument); void StartCoulombRead(void *argument); void StartStateSwitchTask(void *argument); void StartPowerMonitTask(void *argument); +void StartUartQueueTask(void *argument); extern void MX_USB_DEVICE_Init(void); void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */ -/* Hook prototypes */ -void vApplicationIdleHook(void); -void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName); - -/* USER CODE BEGIN 2 */ -__weak void vApplicationIdleHook( void ) -{ - /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set - to 1 in FreeRTOSConfig.h. It will be called on each iteration of the idle - task. It is essential that code added to this hook function never attempts - to block in any way (for example, call xQueueReceive() with a block time - specified, or call vTaskDelay()). If the application makes use of the - vTaskDelete() API function (as this demo application does) then it is also - important that vApplicationIdleHook() is permitted to return to its calling - function, because it is the responsibility of the idle task to clean up - memory allocated by the kernel to any task that has since been deleted. */ -} -/* USER CODE END 2 */ - -/* USER CODE BEGIN 4 */ -__weak void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName) -{ - /* Run time stack overflow checking is performed if - configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is - called if a stack overflow is detected. */ -} -/* USER CODE END 4 */ - /** * @brief FreeRTOS initialization * @param None @@ -167,9 +142,6 @@ void MX_FREERTOS_Init(void) { /* USER CODE BEGIN Init */ /* USER CODE END Init */ - /* Create the mutex(es) */ - /* creation of uartMutex */ - uartMutexHandle = osMutexNew(&uartMutex_attributes); /* USER CODE BEGIN RTOS_MUTEX */ /* add mutexes, ... */ @@ -185,7 +157,7 @@ void MX_FREERTOS_Init(void) { /* Create the queue(s) */ /* creation of uartQueue */ - uartQueueHandle = osMessageQueueNew (256, sizeof(uint8_t), &uartQueue_attributes); + uartQueueHandle = osMessageQueueNew (128, sizeof(uint8_t), &uartQueue_attributes); /* USER CODE BEGIN RTOS_QUEUES */ /* add queues, ... */ @@ -213,6 +185,9 @@ void MX_FREERTOS_Init(void) { /* creation of PowerMonitTask */ PowerMonitTaskHandle = osThreadNew(StartPowerMonitTask, NULL, &PowerMonitTask_attributes); + /* creation of uartQueueTask */ + uartQueueTaskHandle = osThreadNew(StartUartQueueTask, NULL, &uartQueueTask_attributes); + /* USER CODE BEGIN RTOS_THREADS */ /* add threads, ... */ @@ -232,6 +207,7 @@ void StartDefaultTask(void *argument) /* init code for USB_DEVICE */ MX_USB_DEVICE_Init(); /* USER CODE BEGIN StartDefaultTask */ + uint8_t count,temp[256]; HAL_GPIO_WritePin(USB2_FS_ENUM_CTL_GPIO_Port,USB2_FS_ENUM_CTL_Pin, GPIO_PIN_SET); Beep(50); @@ -239,8 +215,16 @@ void StartDefaultTask(void *argument) /* Infinite loop */ for(;;) { - osDelay(1000); - printf("Time:[%f s]; OUT_24:[%f V]; OUT_5:[%f V]; OUT_12:[%f V]; BKP_BAT:[%f V]; MAIN_PWR:[%f V]\n",(float)(osKernelGetTickCount()/1000.0),NaviKit.pmb.rails.out_24v,NaviKit.pmb.rails.out_5v,NaviKit.pmb.rails.out_12v,NaviKit.pmb.rails.bkp_bat,NaviKit.pmb.rails.main_pwr); + osDelay(100); +// count = osMessageQueueGetCount(uartQueueHandle); +// if(count){ +// for(uint8_t i=0;i - + - + - + - + diff --git a/NaviKit_stm32.ioc b/NaviKit_stm32.ioc index d4e131b..a120ba0 100644 --- a/NaviKit_stm32.ioc +++ b/NaviKit_stm32.ioc @@ -70,21 +70,21 @@ FREERTOS.FootprintOK=true FREERTOS.HEAP_NUMBER=4 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,Queues01,Mutexes01 -FREERTOS.Mutexes01=uartMutex,Dynamic,NULL -FREERTOS.Queues01=uartQueue,256,uint8_t,0,Dynamic,NULL,NULL -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.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,Queues01,configUSE_TASK_NOTIFICATIONS +FREERTOS.Queues01=uartQueue,128,uint8_t,0,Dynamic,NULL,NULL +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;uartQueueTask,8,128,StartUartQueueTask,Default,NULL,Dynamic,NULL,NULL +FREERTOS.configCHECK_FOR_STACK_OVERFLOW=0 FREERTOS.configGENERATE_RUN_TIME_STATS=0 FREERTOS.configMAX_TASK_NAME_LEN=32 FREERTOS.configTOTAL_HEAP_SIZE=8192 FREERTOS.configUSE_APPLICATION_TASK_TAG=0 -FREERTOS.configUSE_IDLE_HOOK=1 +FREERTOS.configUSE_IDLE_HOOK=0 FREERTOS.configUSE_MALLOC_FAILED_HOOK=0 FREERTOS.configUSE_STATS_FORMATTING_FUNCTIONS=0 +FREERTOS.configUSE_TASK_NOTIFICATIONS=1 FREERTOS.configUSE_TICKLESS_IDLE=0 FREERTOS.configUSE_TICK_HOOK=0 -FREERTOS.configUSE_TRACE_FACILITY=1 +FREERTOS.configUSE_TRACE_FACILITY=0 File.Version=6 GPIO.groupedBy=Group By Peripherals IWDG.IPParameters=Prescaler,Reload @@ -207,7 +207,7 @@ NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.RCC_IRQn=true\:5\:0\:false\:true\:true\:3\:true\:true\:false NVIC.RTC_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true -NVIC.SVCall_IRQn=true\:5\:0\:false\:false\:false\:true\:false\:false +NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false NVIC.TIM1_UP_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true NVIC.TimeBase=TIM1_UP_IRQn @@ -416,8 +416,9 @@ PD4.GPIOParameters=GPIO_Label PD4.GPIO_Label=SOM_POWER_EN PD4.Locked=true PD4.Signal=GPIO_Output -PD5.GPIOParameters=GPIO_Label +PD5.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI PD5.GPIO_Label=SOM_SHUTDOWN_REQ +PD5.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING_FALLING PD5.Locked=true PD5.Signal=GPXTI5 PD6.GPIOParameters=PinState,GPIO_Label @@ -500,7 +501,7 @@ ProjectManager.DeviceId=STM32F107VCTx ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.0 ProjectManager.FreePins=false ProjectManager.HalAssertFull=false -ProjectManager.HeapSize=0x200 +ProjectManager.HeapSize=0x400 ProjectManager.KeepUserCode=true ProjectManager.LastFirmware=true ProjectManager.LibraryCopy=1 @@ -510,7 +511,7 @@ ProjectManager.PreviousToolchain= ProjectManager.ProjectBuild=false ProjectManager.ProjectFileName=NaviKit_stm32.ioc ProjectManager.ProjectName=NaviKit_stm32 -ProjectManager.StackSize=0x400 +ProjectManager.StackSize=0x800 ProjectManager.TargetToolchain=STM32CubeIDE ProjectManager.ToolChainLocation= ProjectManager.UnderRoot=true diff --git a/README.md b/README.md index 692c72e..314c096 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ 1. 关机状态; 2. 按下`重启`按钮; 3. 按下`电源`按钮; - 4. 听到滴声后,松开两个按钮。 + 4. 听到`3次滴声`后,松开两个按钮。(电源灯表示为闪烁状态) 5. 检查Host PC是否有一个名为Nvidia的设备 @@ -58,6 +58,6 @@ * 进入方法: 1. 断开主板的主电源和备用电源,并将主板BIOS的USB typeC接口和Host PC连接; - 3. 按下`重启`按钮,插入主板的主电源,听到滴声后,松开`重启`按钮; + 3. 按下`重启`按钮,插入主板的主电源,听到`5次滴声`后,松开`重启`按钮; 4. 打开STM32CubeProgrammer,选择UART模式,点击Connect; 5. 点击Open,选择新固件,点击Download \ No newline at end of file diff --git a/STM32F107VCTX_FLASH.ld b/STM32F107VCTX_FLASH.ld index c339861..37b3bc0 100644 --- a/STM32F107VCTX_FLASH.ld +++ b/STM32F107VCTX_FLASH.ld @@ -55,8 +55,8 @@ ENTRY(Reset_Handler) /* Highest address of the user mode stack */ _estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ -_Min_Heap_Size = 0x200 ; /* required amount of heap */ -_Min_Stack_Size = 0x400 ; /* required amount of stack */ +_Min_Heap_Size = 0x400 ; /* required amount of heap */ +_Min_Stack_Size = 0x800 ; /* required amount of stack */ /* Memories definition */ MEMORY