/**
* @file main_common.c
* @author Alvin Young (impressionyang@outlook.com)
* @brief
* @version 0.1
* @date 2024-12-04
*
* _ _
* (_)_ _ ___ _______ ___ ___ (_)__ ___ __ _____ ____ ___ _
* / / ' \/ _ \/ __/ -_|_-<(_- / _ \/ _ \/ // / _ `/ _ \/ _ `/
* /_/_/_/_/ .__/_/ \__/___/___/_/\___/_//_/\_, /\_,_/_//_/\_, /
* /_/ /___/ /___/
* @copyright Copyright (c) 2024 impressionyang
*
* @par 修改日志:
*
* | Date | Version | Author | Description
* |
|---|
| 2024-12-04 | v1.0 | Alvin Young | 首次创建
* |
*
*/
/* Define to prevent recursive inclusion -------------------------------------*/
/* Includes ------------------------------------------------------------------*/
#include "main_common.h"
#include
#include
#include "shell_port.h"
#include "main_app.h"
#include "imp_msg_queue.h"
#include "shell_port.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);
uint8_t _imp_set_out_port(int argc, char** argv)
{
if (argc < 2) {
cdc_printf("too few arg\r\n");
return 1;
}
uint8_t type = atoi(argv[1]);
cdc_printf("set outport type %d\r\n", type);
imp_comp_out_port_ioctl(EM_IMP_OUT_PORT_CMD_SET_OUT_TYPE, (uint8_t*)&type,
1);
return 0;
}
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
oport, _imp_set_out_port, set out port);
/* 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)) {
imp_comp_out_port_write(EM_IMP_OUT_PORT_TYPE_STRING, (uint8_t*)aBuffer,
sizeof(aBuffer));
} else if (n > 0) {
imp_comp_out_port_write(EM_IMP_OUT_PORT_TYPE_STRING, (uint8_t*)aBuffer,
n);
}
va_end(args);
return n;
}
/*
* EOF
*/