esp32s2_bare_board/main/APP/main_app/main_app.c

73 lines
2.1 KiB
C

/**
* @file main_app.c
* @author Alvin Young (impressionyang@outlook.com)
* @brief
* @version 0.1
* @date 2024-11-25
*
* _ _
* (_)_ _ ___ _______ ___ ___ (_)__ ___ __ _____ ____ ___ _
* / / ' \/ _ \/ __/ -_|_-<(_-</ / _ \/ _ \/ // / _ `/ _ \/ _ `/
* /_/_/_/_/ .__/_/ \__/___/___/_/\___/_//_/\_, /\_,_/_//_/\_, /
* /_/ /___/ /___/
* @copyright Copyright (c) 2024 impressionyang
*
* @par 修改日志:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2024-11-25 <td>v1.0 <td>Alvin Young <td>首次创建
* </table>
*
*/
/* Define to prevent recursive inclusion -------------------------------------*/
/* Includes ------------------------------------------------------------------*/
#include "main_app.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_chip_info.h"
#include "sdkconfig.h"
#include <inttypes.h>
#include <stdio.h>
#include "main_common.h"
#include "shell_port.h"
/* define --------------------------------------------------------------------*/
/* typedef -------------------------------------------------------------------*/
/* variables -----------------------------------------------------------------*/
static uint8_t print_en = 0;
/* Private function(only *.c) -----------------------------------------------*/
uint8_t _set_print_en(int argc, char **argv)
{
if (argc < 2) {
cdc_printf("too few argv\r\n");
}
int en_v = atoi(argv[1]);
print_en = en_v;
return 0;
}
/* Exported functions --------------------------------------------------------*/
uint8_t imp_main_app_task()
{
int i = 0;
while (1) {
if (print_en) {
cdc_printf("hello %d\r\n", i++);
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
main_pe, _set_print_en, set print value);
/*
* EOF
*/