esp32s2_bare_board/main/main_common.c
impressionyang 3b438fd8af test: 通过对外输出接口进行打印和对接shell OK
feat:  增加对外控制输出
file: 📦 添加对外输出文件
2024-12-18 07:19:45 +00:00

80 lines
2.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file main_common.c
* @author Alvin Young (impressionyang@outlook.com)
* @brief
* @version 0.1
* @date 2024-12-04
*
* _ _
* (_)_ _ ___ _______ ___ ___ (_)__ ___ __ _____ ____ ___ _
* / / ' \/ _ \/ __/ -_|_-<(_-</ / _ \/ _ \/ // / _ `/ _ \/ _ `/
* /_/_/_/_/ .__/_/ \__/___/___/_/\___/_//_/\_, /\_,_/_//_/\_, /
* /_/ /___/ /___/
* @copyright Copyright (c) 2024 impressionyang
*
* @par 修改日志:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2024-12-04 <td>v1.0 <td>Alvin Young <td>首次创建
* </table>
*
*/
/* Define to prevent recursive inclusion -------------------------------------*/
/* Includes ------------------------------------------------------------------*/
#include "main_common.h"
#include <stdarg.h>
#include "shell_port.h"
#include "main_app.h"
#include "imp_msg_queue.h"
/* define --------------------------------------------------------------------*/
/* typedef -------------------------------------------------------------------*/
/* variables -----------------------------------------------------------------*/
/// @brief 所有Task的命名集合名字长度不能超过configMAX_TASK_NAME_LEN = 16
char* imp_main_task_table[] = {
"idle",
"main_task",
"ext_trans_task",
};
/* Private function(only *.c) -----------------------------------------------*/
extern void cdc_acm_msc_init();
extern uint16_t cdc_usb_read_bytes(uint8_t* data, uint16_t len);
extern uint16_t cdc_usb_writ_bytes(uint8_t* data, uint16_t len);
/* Exported functions --------------------------------------------------------*/
uint8_t imp_main_common_init()
{
cdc_acm_msc_init();
imp_comp_out_port_init();
imp_comp_out_port_ioctl(EM_IMP_OUT_PORT_CMD_SET_OUT_READ_FUNC,
(uint8_t*)cdc_usb_read_bytes, 0);
imp_comp_out_port_ioctl(EM_IMP_OUT_PORT_CMD_SET_OUT_WRIT_FUNC,
(uint8_t*)cdc_usb_writ_bytes, 0);
vTaskDelay(10);
userShellInit();
vTaskDelay(10);
return 0;
}
int cdc_printf(const char* fmt, ...)
{
int n;
char aBuffer[64] = { 0 };
va_list args;
va_start(args, fmt);
n = vsnprintf(aBuffer, sizeof(aBuffer), fmt, args);
if (n > (int)sizeof(aBuffer)) {
cdc_usb_writ_bytes((uint8_t*)aBuffer, sizeof(aBuffer));
} else if (n > 0) {
cdc_usb_writ_bytes((uint8_t*)aBuffer, n);
}
va_end(args);
return n;
}
/*
* EOF
*/