freeRTOS支持

This commit is contained in:
2026-07-19 13:09:06 +08:00
parent 4eb728583b
commit 9ed4c22022
63 changed files with 45898 additions and 507 deletions

View File

@@ -18,6 +18,7 @@
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "cmsis_os.h"
#include "dma.h"
#include "i2c.h"
#include "spi.h"
@@ -67,6 +68,7 @@ static int s_listen_sock = -1;
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
void MX_FREERTOS_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
@@ -238,6 +240,15 @@ int main(void)
#endif
/* USER CODE END 2 */
/* Init scheduler */
osKernelInitialize(); /* Call init function for freertos objects (in cmsis_os2.c) */
MX_FREERTOS_Init();
/* Start scheduler */
osKernelStart();
/* We should never get here as control is now taken by the scheduler */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
@@ -245,38 +256,10 @@ int main(void)
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
/* 网络轮询(必须在主循环中调用) */
net_poll();
#ifdef ENABLE_PHASE4_TESTS
/* Phase 4: NET 层 TCP Echo */
ch395f_phase4_tests();
#endif
/* Phase 5: NET 层 UDP Echo */
#ifdef ENABLE_PHASE5_TESTS
ch395f_phase5_tests();
#endif
#ifdef ENABLE_PHASE7_TESTS
ch395f_phase7_tests();
#endif
// /* TPAFE5160 中断模式读取 */
// if (tpafe5160_data_ready()) {
// const int16_t *buf = tpafe5160_get_buf();
// printf("[TPAFE5160] CH:");
// for (int i = 0; i < 8; i++) {
// printf(" %d", buf[i]);
// }
// printf("\r\n");
// tpafe5160_clear_ready();
// /* 启动下一次转换 */
// tpafe5160_start_conv_irq();
// }
/* 其他任务 */
// HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin);
// HAL_Delay(10);
}
/* 网络轮询已移到 FreeRTOS netTask 中 */
;
/* USER CODE END 3 */
}
}
/**
@@ -360,6 +343,28 @@ void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
}
/* USER CODE END 4 */
/**
* @brief Period elapsed callback in non blocking mode
* @note This function is called when TIM7 interrupt took place, inside
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
* a global variable "uwTick" used as application time base.
* @param htim : TIM handle
* @retval None
*/
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
/* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */
if (htim->Instance == TIM7)
{
HAL_IncTick();
}
/* USER CODE BEGIN Callback 1 */
/* USER CODE END Callback 1 */
}
/**
* @brief This function is executed in case of error occurrence.
* @retval None