understand freertos logging
This commit is contained in:
parent
b82393d4a2
commit
862fc8da97
@ -60,11 +60,11 @@ unsigned long getRunTimeCounterValue(void);
|
||||
/* Functions needed when configGENERATE_RUN_TIME_STATS is on */
|
||||
__weak void configureTimerForRunTimeStats(void) {
|
||||
// Configure TIM2 as a free-running timer at 1 MHz
|
||||
// __HAL_RCC_TIM2_CLK_ENABLE();
|
||||
// TIM2->PSC = (SystemCoreClock / 1000000) - 1; // 1 MHz
|
||||
// TIM2->ARR = 0xFFFFFFFF;
|
||||
// TIM2->CNT = 0;
|
||||
// TIM2->CR1 = TIM_CR1_CEN;
|
||||
__HAL_RCC_TIM2_CLK_ENABLE();
|
||||
TIM2->PSC = (SystemCoreClock / 1000000) - 1; // 1 MHz
|
||||
TIM2->ARR = 0xFFFFFFFF;
|
||||
TIM2->CNT = 0;
|
||||
TIM2->CR1 = TIM_CR1_CEN;
|
||||
}
|
||||
|
||||
__weak unsigned long getRunTimeCounterValue(void) {
|
||||
|
||||
167
Core/Src/main.c
167
Core/Src/main.c
@ -61,42 +61,26 @@ UART_HandleTypeDef huart6;
|
||||
|
||||
/* Definitions for touchhistory */
|
||||
osThreadId_t touchhistoryHandle;
|
||||
const osThreadAttr_t touchhistory_attributes = {
|
||||
.name = "touchhistory",
|
||||
.stack_size = 128 * 4,
|
||||
.priority = (osPriority_t) osPriorityNormal,
|
||||
};
|
||||
const osThreadAttr_t touchhistory_attributes = { .name = "touchhistory",
|
||||
.stack_size = 128 * 4, .priority = (osPriority_t) osPriorityNormal, };
|
||||
/* Definitions for draw */
|
||||
osThreadId_t drawHandle;
|
||||
const osThreadAttr_t draw_attributes = {
|
||||
.name = "draw",
|
||||
.stack_size = 1024 * 4,
|
||||
.priority = (osPriority_t) osPriorityLow,
|
||||
};
|
||||
const osThreadAttr_t draw_attributes = { .name = "draw", .stack_size = 1024 * 4,
|
||||
.priority = (osPriority_t) osPriorityLow, };
|
||||
/* Definitions for reactiongame */
|
||||
osThreadId_t reactiongameHandle;
|
||||
const osThreadAttr_t reactiongame_attributes = {
|
||||
.name = "reactiongame",
|
||||
.stack_size = 128 * 4,
|
||||
.priority = (osPriority_t) osPriorityLow,
|
||||
};
|
||||
const osThreadAttr_t reactiongame_attributes = { .name = "reactiongame",
|
||||
.stack_size = 128 * 4, .priority = (osPriority_t) osPriorityLow, };
|
||||
/* Definitions for gamepicker */
|
||||
osThreadId_t gamepickerHandle;
|
||||
const osThreadAttr_t gamepicker_attributes = {
|
||||
.name = "gamepicker",
|
||||
.stack_size = 128 * 4,
|
||||
.priority = (osPriority_t) osPriorityLow,
|
||||
};
|
||||
const osThreadAttr_t gamepicker_attributes = { .name = "gamepicker",
|
||||
.stack_size = 128 * 4, .priority = (osPriority_t) osPriorityLow, };
|
||||
/* Definitions for presses */
|
||||
osMessageQueueId_t pressesHandle;
|
||||
const osMessageQueueAttr_t presses_attributes = {
|
||||
.name = "presses"
|
||||
};
|
||||
const osMessageQueueAttr_t presses_attributes = { .name = "presses" };
|
||||
/* Definitions for display */
|
||||
osMutexId_t displayHandle;
|
||||
const osMutexAttr_t display_attributes = {
|
||||
.name = "display"
|
||||
};
|
||||
const osMutexAttr_t display_attributes = { .name = "display" };
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
@ -496,8 +480,7 @@ void GameRender() {
|
||||
* @brief The application entry point.
|
||||
* @retval int
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
int main(void) {
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
@ -557,7 +540,6 @@ int main(void)
|
||||
/* Create the queue(s) */
|
||||
/* creation of presses */
|
||||
//pressesHandle = osMessageQueueNew (16, sizeof(char), &presses_attributes);
|
||||
|
||||
/* USER CODE BEGIN RTOS_QUEUES */
|
||||
/* add queues, ... */
|
||||
/* USER CODE END RTOS_QUEUES */
|
||||
@ -565,16 +547,13 @@ int main(void)
|
||||
/* Create the thread(s) */
|
||||
/* creation of touchhistory */
|
||||
//touchhistoryHandle = osThreadNew(StartTouchHist, NULL, &touchhistory_attributes);
|
||||
|
||||
/* creation of draw */
|
||||
drawHandle = osThreadNew(snakegame, NULL, &draw_attributes);
|
||||
|
||||
/* creation of reactiongame */
|
||||
//reactiongameHandle = osThreadNew(startreactiongame, NULL, &reactiongame_attributes);
|
||||
|
||||
/* creation of gamepicker */
|
||||
//gamepickerHandle = osThreadNew(gamepicker_entry, NULL, &gamepicker_attributes);
|
||||
|
||||
/* USER CODE BEGIN RTOS_THREADS */
|
||||
/* add threads, ... */
|
||||
|
||||
@ -647,8 +626,7 @@ int main(void)
|
||||
* @brief System Clock Configuration
|
||||
* @retval None
|
||||
*/
|
||||
void SystemClock_Config(void)
|
||||
{
|
||||
void SystemClock_Config(void) {
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = { 0 };
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = { 0 };
|
||||
|
||||
@ -664,8 +642,7 @@ void SystemClock_Config(void)
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
@ -678,8 +655,7 @@ void SystemClock_Config(void)
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
|
||||
{
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
@ -689,8 +665,7 @@ void SystemClock_Config(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_I2C1_Init(void)
|
||||
{
|
||||
static void MX_I2C1_Init(void) {
|
||||
|
||||
/* USER CODE BEGIN I2C1_Init 0 */
|
||||
|
||||
@ -708,8 +683,7 @@ static void MX_I2C1_Init(void)
|
||||
hi2c1.Init.OwnAddress2 = 0;
|
||||
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
||||
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
||||
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
|
||||
{
|
||||
if (HAL_I2C_Init(&hi2c1) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN I2C1_Init 2 */
|
||||
@ -723,8 +697,7 @@ static void MX_I2C1_Init(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_SPI1_Init(void)
|
||||
{
|
||||
static void MX_SPI1_Init(void) {
|
||||
|
||||
/* USER CODE BEGIN SPI1_Init 0 */
|
||||
|
||||
@ -746,8 +719,7 @@ static void MX_SPI1_Init(void)
|
||||
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||
hspi1.Init.CRCPolynomial = 10;
|
||||
if (HAL_SPI_Init(&hspi1) != HAL_OK)
|
||||
{
|
||||
if (HAL_SPI_Init(&hspi1) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SPI1_Init 2 */
|
||||
@ -761,8 +733,7 @@ static void MX_SPI1_Init(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_SPI2_Init(void)
|
||||
{
|
||||
static void MX_SPI2_Init(void) {
|
||||
|
||||
/* USER CODE BEGIN SPI2_Init 0 */
|
||||
|
||||
@ -784,8 +755,7 @@ static void MX_SPI2_Init(void)
|
||||
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
|
||||
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
||||
hspi2.Init.CRCPolynomial = 10;
|
||||
if (HAL_SPI_Init(&hspi2) != HAL_OK)
|
||||
{
|
||||
if (HAL_SPI_Init(&hspi2) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SPI2_Init 2 */
|
||||
@ -799,8 +769,7 @@ static void MX_SPI2_Init(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_TIM1_Init(void)
|
||||
{
|
||||
static void MX_TIM1_Init(void) {
|
||||
|
||||
/* USER CODE BEGIN TIM1_Init 0 */
|
||||
|
||||
@ -828,14 +797,13 @@ static void MX_TIM1_Init(void)
|
||||
sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI;
|
||||
sConfig.IC2Prescaler = TIM_ICPSC_DIV1;
|
||||
sConfig.IC2Filter = 0;
|
||||
if (HAL_TIM_Encoder_Init(&htim1, &sConfig) != HAL_OK)
|
||||
{
|
||||
if (HAL_TIM_Encoder_Init(&htim1, &sConfig) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig)
|
||||
!= HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM1_Init 2 */
|
||||
@ -849,8 +817,7 @@ static void MX_TIM1_Init(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_TIM4_Init(void)
|
||||
{
|
||||
static void MX_TIM4_Init(void) {
|
||||
|
||||
/* USER CODE BEGIN TIM4_Init 0 */
|
||||
|
||||
@ -877,14 +844,13 @@ static void MX_TIM4_Init(void)
|
||||
sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI;
|
||||
sConfig.IC2Prescaler = TIM_ICPSC_DIV1;
|
||||
sConfig.IC2Filter = 0;
|
||||
if (HAL_TIM_Encoder_Init(&htim4, &sConfig) != HAL_OK)
|
||||
{
|
||||
if (HAL_TIM_Encoder_Init(&htim4, &sConfig) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig)
|
||||
!= HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM4_Init 2 */
|
||||
@ -898,8 +864,7 @@ static void MX_TIM4_Init(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_TIM5_Init(void)
|
||||
{
|
||||
static void MX_TIM5_Init(void) {
|
||||
|
||||
/* USER CODE BEGIN TIM5_Init 0 */
|
||||
|
||||
@ -918,43 +883,40 @@ static void MX_TIM5_Init(void)
|
||||
htim5.Init.Period = 4294967295;
|
||||
htim5.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim5.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim5) != HAL_OK)
|
||||
{
|
||||
if (HAL_TIM_Base_Init(&htim5) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||
if (HAL_TIM_ConfigClockSource(&htim5, &sClockSourceConfig) != HAL_OK)
|
||||
{
|
||||
if (HAL_TIM_ConfigClockSource(&htim5, &sClockSourceConfig) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_PWM_Init(&htim5) != HAL_OK)
|
||||
{
|
||||
if (HAL_TIM_PWM_Init(&htim5) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig) != HAL_OK)
|
||||
{
|
||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim5, &sMasterConfig)
|
||||
!= HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
sConfigOC.OCMode = TIM_OCMODE_PWM1;
|
||||
sConfigOC.Pulse = 0;
|
||||
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
|
||||
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||
{
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_1)
|
||||
!= HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
|
||||
{
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_2)
|
||||
!= HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
|
||||
{
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_3)
|
||||
!= HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
|
||||
{
|
||||
if (HAL_TIM_PWM_ConfigChannel(&htim5, &sConfigOC, TIM_CHANNEL_4)
|
||||
!= HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN TIM5_Init 2 */
|
||||
@ -969,8 +931,7 @@ static void MX_TIM5_Init(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_USART6_UART_Init(void)
|
||||
{
|
||||
static void MX_USART6_UART_Init(void) {
|
||||
|
||||
/* USER CODE BEGIN USART6_Init 0 */
|
||||
|
||||
@ -987,8 +948,7 @@ static void MX_USART6_UART_Init(void)
|
||||
huart6.Init.Mode = UART_MODE_TX_RX;
|
||||
huart6.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||
huart6.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||
if (HAL_UART_Init(&huart6) != HAL_OK)
|
||||
{
|
||||
if (HAL_UART_Init(&huart6) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN USART6_Init 2 */
|
||||
@ -1000,8 +960,7 @@ static void MX_USART6_UART_Init(void)
|
||||
/**
|
||||
* Enable DMA controller clock
|
||||
*/
|
||||
static void MX_DMA_Init(void)
|
||||
{
|
||||
static void MX_DMA_Init(void) {
|
||||
|
||||
/* DMA controller clock enable */
|
||||
__HAL_RCC_DMA2_CLK_ENABLE();
|
||||
@ -1021,8 +980,7 @@ static void MX_DMA_Init(void)
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void MX_GPIO_Init(void)
|
||||
{
|
||||
static void MX_GPIO_Init(void) {
|
||||
GPIO_InitTypeDef GPIO_InitStruct = { 0 };
|
||||
/* USER CODE BEGIN MX_GPIO_Init_1 */
|
||||
|
||||
@ -1085,8 +1043,7 @@ static void MX_GPIO_Init(void)
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_StartTouchHist */
|
||||
void StartTouchHist(void *argument)
|
||||
{
|
||||
void StartTouchHist(void *argument) {
|
||||
/* USER CODE BEGIN 5 */
|
||||
/* Infinite loop */
|
||||
for (;;) {
|
||||
@ -1111,25 +1068,30 @@ void StartTouchHist(void *argument)
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_snakegame */
|
||||
void snakegame(void *argument)
|
||||
{
|
||||
void snakegame(void *argument) {
|
||||
/* USER CODE BEGIN snakegame */
|
||||
/* Infinite loop */
|
||||
ILI9341_FillScreen(BLACK);
|
||||
GameInit();
|
||||
GameRender();
|
||||
for (;;) {
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
//uint16_t x,y;
|
||||
//ILI9341_TouchGetCoordinates(&x, &y);
|
||||
GameRender();
|
||||
static char statsBuffer[512];
|
||||
static char statsBuffer[200];
|
||||
vTaskGetRunTimeStats(statsBuffer);
|
||||
|
||||
vTaskDelay(1000);
|
||||
uint16_t timer=HAL_GetTick();
|
||||
|
||||
//ILI9341_FillScreen(timer%0xFFFF);
|
||||
UpdateGame();
|
||||
if(i==6){
|
||||
int a=0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE END snakegame */
|
||||
@ -1142,8 +1104,7 @@ void snakegame(void *argument)
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_startreactiongame */
|
||||
void startreactiongame(void *argument)
|
||||
{
|
||||
void startreactiongame(void *argument) {
|
||||
/* USER CODE BEGIN startreactiongame */
|
||||
/* Infinite loop */
|
||||
uint32_t lasttimestamp = osKernelGetTickCount();
|
||||
@ -1214,8 +1175,7 @@ void startreactiongame(void *argument)
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_gamepicker_entry */
|
||||
void gamepicker_entry(void *argument)
|
||||
{
|
||||
void gamepicker_entry(void *argument) {
|
||||
/* USER CODE BEGIN gamepicker_entry */
|
||||
/* Infinite loop */
|
||||
for (;;) {
|
||||
@ -1251,13 +1211,11 @@ void gamepicker_entry(void *argument)
|
||||
* @param htim : TIM handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||
{
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
||||
/* USER CODE BEGIN Callback 0 */
|
||||
|
||||
/* USER CODE END Callback 0 */
|
||||
if (htim->Instance == TIM2)
|
||||
{
|
||||
if (htim->Instance == TIM2) {
|
||||
HAL_IncTick();
|
||||
}
|
||||
/* USER CODE BEGIN Callback 1 */
|
||||
@ -1269,8 +1227,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||
* @brief This function is executed in case of error occurrence.
|
||||
* @retval None
|
||||
*/
|
||||
void Error_Handler(void)
|
||||
{
|
||||
void Error_Handler(void) {
|
||||
/* USER CODE BEGIN Error_Handler_Debug */
|
||||
/* User can add his own implementation to report the HAL error return state */
|
||||
__disable_irq();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user