file: 📦 添加service、component和其他相关文件
update: 📝 更新主函数调用 feat: ✨ 增加消息队列功能
This commit is contained in:
parent
45efbdf4c7
commit
eea3c0265a
@ -0,0 +1,2 @@
|
|||||||
|
每个APP调用不同的service来组成不同的功能
|
||||||
|
module间通过消息队列进行功能
|
||||||
@ -33,11 +33,15 @@
|
|||||||
#include "main_common.h"
|
#include "main_common.h"
|
||||||
#include "shell_port.h"
|
#include "shell_port.h"
|
||||||
|
|
||||||
|
#include "imp_msg_queue.h"
|
||||||
|
#include "ext_trans_service.h"
|
||||||
|
|
||||||
/* define --------------------------------------------------------------------*/
|
/* define --------------------------------------------------------------------*/
|
||||||
/* typedef -------------------------------------------------------------------*/
|
/* typedef -------------------------------------------------------------------*/
|
||||||
/* variables -----------------------------------------------------------------*/
|
/* variables -----------------------------------------------------------------*/
|
||||||
|
|
||||||
static uint8_t print_en = 0;
|
static uint8_t print_en = 0;
|
||||||
|
static imp_msg_queue_t* msg_q_handle = NULL;
|
||||||
|
|
||||||
/* Private function(only *.c) -----------------------------------------------*/
|
/* Private function(only *.c) -----------------------------------------------*/
|
||||||
|
|
||||||
@ -50,14 +54,50 @@ uint8_t _set_print_en(int argc, char **argv)
|
|||||||
print_en = en_v;
|
print_en = en_v;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t _set_send_msg_to(int argc, char** argv)
|
||||||
|
{
|
||||||
|
if (argc < 3) {
|
||||||
|
cdc_printf("too few argv: cmd sendtoid value_num\r\n");
|
||||||
|
}
|
||||||
|
uint16_t send_to_id = (uint16_t)atoi(argv[1]);
|
||||||
|
int value_num = atoi(argv[2]);
|
||||||
|
|
||||||
|
imp_msg_item_t msg_item = { 0 };
|
||||||
|
msg_item.msg_data = value_num;
|
||||||
|
imp_msg_queue_send_msg(msg_q_handle, send_to_id, &msg_item);
|
||||||
|
cdc_printf("send from %d to %d value %d ok\r\n", msg_item.send_id,
|
||||||
|
msg_item.recv_id, msg_item.msg_data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t _main_task_wake_up_services()
|
||||||
|
{
|
||||||
|
xTaskCreate(imp_ext_trans_service_task,
|
||||||
|
imp_main_task_table[IMP_TASK_ID_EXT_TRANS_SERVICE_TASK], 2048,
|
||||||
|
NULL, 10, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Exported functions --------------------------------------------------------*/
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
|
||||||
uint8_t imp_main_app_task()
|
uint8_t imp_main_app_task()
|
||||||
{
|
{
|
||||||
int i = 0;
|
uint16_t i = 0;
|
||||||
|
msg_q_handle = imp_msg_queue_create_handle(IMP_TASK_ID_MAIN_TASK);
|
||||||
|
imp_msg_item_t msg_item = { 0 };
|
||||||
|
|
||||||
|
_main_task_wake_up_services();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (print_en) {
|
if (print_en) {
|
||||||
cdc_printf("hello %d\r\n", i++);
|
cdc_printf("hello %d\r\n", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i++ % 4 == 0) {
|
||||||
|
msg_item.msg_data = i;
|
||||||
|
imp_msg_queue_send_msg(
|
||||||
|
msg_q_handle, IMP_TASK_ID_EXT_TRANS_SERVICE_TASK, &msg_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||||
@ -67,6 +107,8 @@ uint8_t imp_main_app_task()
|
|||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
||||||
main_pe, _set_print_en, set print value);
|
main_pe, _set_print_en, set print value);
|
||||||
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
||||||
|
main_msg_to, _set_send_msg_to, send msg to other task);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* EOF
|
* EOF
|
||||||
|
|||||||
@ -29,6 +29,7 @@ extern "C" {
|
|||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "main_common.h"
|
||||||
|
|
||||||
/* define --------------------------------------------------------------------*/
|
/* define --------------------------------------------------------------------*/
|
||||||
/* typedef -------------------------------------------------------------------*/
|
/* typedef -------------------------------------------------------------------*/
|
||||||
|
|||||||
@ -12,6 +12,8 @@ idf_component_register(
|
|||||||
"utilities/imp_util_ring_queue/"
|
"utilities/imp_util_ring_queue/"
|
||||||
"utilities/imp_types/"
|
"utilities/imp_types/"
|
||||||
"APP/main_app/"
|
"APP/main_app/"
|
||||||
|
"components/msq_queue"
|
||||||
|
"services/ext_trans_service"
|
||||||
|
|
||||||
EXCLUDE_SRCS
|
EXCLUDE_SRCS
|
||||||
"utilities/usb_cherry/CherryUSB/class/cdc/usbh_cdc_acm.c"
|
"utilities/usb_cherry/CherryUSB/class/cdc/usbh_cdc_acm.c"
|
||||||
@ -34,6 +36,8 @@ idf_component_register(
|
|||||||
"utilities/imp_util_ring_queue/"
|
"utilities/imp_util_ring_queue/"
|
||||||
"APP/main_app/"
|
"APP/main_app/"
|
||||||
"utilities/imp_types/"
|
"utilities/imp_types/"
|
||||||
|
"components/msq_queue"
|
||||||
|
"services/ext_trans_service"
|
||||||
|
|
||||||
LDFRAGMENTS
|
LDFRAGMENTS
|
||||||
"utilities/letter_shell/port/esp-idf/shell.lf"
|
"utilities/letter_shell/port/esp-idf/shell.lf"
|
||||||
|
|||||||
1
main/components/README.md
Normal file
1
main/components/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
component是
|
||||||
124
main/components/msq_queue/imp_msg_queue.c
Normal file
124
main/components/msq_queue/imp_msg_queue.c
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/**
|
||||||
|
* @file imp_msg_queue.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 "imp_msg_queue.h"
|
||||||
|
#include "main_common.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
/* define --------------------------------------------------------------------*/
|
||||||
|
/* typedef -------------------------------------------------------------------*/
|
||||||
|
/* variables -----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/// @brief 消息队列的freeRTOS句柄
|
||||||
|
static QueueHandle_t sg_imp_msg_queue = NULL;
|
||||||
|
|
||||||
|
/* Private function(only *.c) -----------------------------------------------*/
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
|
||||||
|
uint8_t imp_msg_queue_init()
|
||||||
|
{
|
||||||
|
sg_imp_msg_queue =
|
||||||
|
xQueueCreate(IMP_MSG_QUEUE_MAX_ITEM_COUNT, sizeof(imp_msg_item_t));
|
||||||
|
if (sg_imp_msg_queue != NULL) {
|
||||||
|
cdc_printf("msg queue init ok!\n");
|
||||||
|
} else {
|
||||||
|
cdc_printf("msg queue init failed!\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
imp_msg_queue_t* imp_msg_queue_create_handle(uint16_t task_id)
|
||||||
|
{
|
||||||
|
if (NULL == sg_imp_msg_queue) {
|
||||||
|
cdc_printf("msg queue create failed!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
imp_msg_queue_t* ptr = (imp_msg_queue_t*)malloc(sizeof(imp_msg_queue_t*));
|
||||||
|
ptr->is_init = 1;
|
||||||
|
ptr->msg_queue_handle = sg_imp_msg_queue;
|
||||||
|
ptr->task_id = task_id;
|
||||||
|
ptr->task_name = imp_main_task_table[task_id];
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t imp_msg_queue_recv_msg(imp_msg_queue_t* handle, imp_msg_item_t* msg,
|
||||||
|
uint16_t timeout)
|
||||||
|
{
|
||||||
|
if (NULL == sg_imp_msg_queue || NULL == handle) {
|
||||||
|
cdc_printf("handle or msg queue is NULL\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
BaseType_t msg_queue_return;
|
||||||
|
imp_msg_item_t item = { 0 };
|
||||||
|
|
||||||
|
msg_queue_return = xQueuePeek(handle->msg_queue_handle, &item, timeout);
|
||||||
|
if (msg_queue_return != pdTRUE) {
|
||||||
|
return 2;
|
||||||
|
} else {
|
||||||
|
// read succeed
|
||||||
|
if (item.recv_id == handle->task_id) {
|
||||||
|
xQueueReceive(handle->msg_queue_handle, msg, 0);
|
||||||
|
if (msg->recv_id == handle->task_id) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t imp_msg_queue_send_msg(imp_msg_queue_t* handle, uint16_t recv_id,
|
||||||
|
imp_msg_item_t* msg)
|
||||||
|
{
|
||||||
|
if (NULL == sg_imp_msg_queue || NULL == handle) {
|
||||||
|
cdc_printf("handle or msg queue is NULL\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
BaseType_t msg_queue_return;
|
||||||
|
|
||||||
|
msg->send_id = handle->task_id;
|
||||||
|
msg->recv_id = recv_id;
|
||||||
|
msg_queue_return = xQueueSend(handle->msg_queue_handle, msg, portMAX_DELAY);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t imp_msg_queue_destroy_handle(imp_msg_queue_t* handle)
|
||||||
|
{
|
||||||
|
if (NULL == sg_imp_msg_queue || NULL == handle) {
|
||||||
|
cdc_printf("handle or msg queue is NULL\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
handle->is_init = 0;
|
||||||
|
handle->msg_queue_handle = NULL;
|
||||||
|
handle->task_name = NULL;
|
||||||
|
handle->task_id = 0;
|
||||||
|
free(handle);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EOF
|
||||||
|
*/
|
||||||
174
main/components/msq_queue/imp_msg_queue.h
Normal file
174
main/components/msq_queue/imp_msg_queue.h
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
/**
|
||||||
|
* @file imp_msg_queue.h
|
||||||
|
* @author Alvin Young (impressionyang@outlook.com)
|
||||||
|
* @brief
|
||||||
|
* @version 0.1
|
||||||
|
* @date 2024-12-03
|
||||||
|
*
|
||||||
|
* _ _
|
||||||
|
* (_)_ _ ___ _______ ___ ___ (_)__ ___ __ _____ ____ ___ _
|
||||||
|
* / / ' \/ _ \/ __/ -_|_-<(_-</ / _ \/ _ \/ // / _ `/ _ \/ _ `/
|
||||||
|
* /_/_/_/_/ .__/_/ \__/___/___/_/\___/_//_/\_, /\_,_/_//_/\_, /
|
||||||
|
* /_/ /___/ /___/
|
||||||
|
* @copyright Copyright (c) 2024 impressionyang
|
||||||
|
*
|
||||||
|
* @par 修改日志:
|
||||||
|
* <table>
|
||||||
|
* <tr><th>Date <th>Version <th>Author <th>Description
|
||||||
|
* <tr><td>2024-12-03 <td>v1.0 <td>Alvin Young <td>首次创建
|
||||||
|
* </table>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __IMP_MSG_QUEUE_H__
|
||||||
|
#define __IMP_MSG_QUEUE_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "freertos/queue.h"
|
||||||
|
|
||||||
|
/* define --------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define IMP_MSG_QUEUE_MAX_ITEM_COUNT (20)
|
||||||
|
/* typedef -------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/// @brief 消息队列的消息内容
|
||||||
|
typedef struct __imp_msg_item_t__
|
||||||
|
{
|
||||||
|
uint16_t send_id;
|
||||||
|
uint16_t recv_id;
|
||||||
|
uint16_t msg_type;
|
||||||
|
union {
|
||||||
|
uint32_t msg_data;
|
||||||
|
void* msg_data_ptr;
|
||||||
|
};
|
||||||
|
union {
|
||||||
|
uint32_t msg_reserve;
|
||||||
|
uint32_t msg_data_len;
|
||||||
|
};
|
||||||
|
} imp_msg_item_t;
|
||||||
|
|
||||||
|
/// @brief 消息队列的句柄
|
||||||
|
typedef struct __imp_msg_queue_t__
|
||||||
|
{
|
||||||
|
uint8_t is_init;
|
||||||
|
/// @brief 唯一的值代表不同的Task
|
||||||
|
uint16_t task_id;
|
||||||
|
char* task_name;
|
||||||
|
/// @brief 通过create 获取消息队列句柄
|
||||||
|
QueueHandle_t msg_queue_handle;
|
||||||
|
} imp_msg_queue_t;
|
||||||
|
|
||||||
|
/* variables -----------------------------------------------------------------*/
|
||||||
|
/* Private function(only *.c) -----------------------------------------------*/
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @brief 初始化消息队列
|
||||||
|
* @return uint8_t
|
||||||
|
* @date 2024-12-04
|
||||||
|
* @author Alvin Young (impressionyang@outlook.com)
|
||||||
|
*
|
||||||
|
* @details
|
||||||
|
* @note
|
||||||
|
* @par 修改日志:
|
||||||
|
* <table>
|
||||||
|
* <tr><th>Date <th>Author <th>Description
|
||||||
|
* <tr><td>2024-12-04 <td>Alvin Young <td>新建
|
||||||
|
* </table>
|
||||||
|
*/
|
||||||
|
uint8_t imp_msg_queue_init();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @brief 获取一个消息队列控制句柄
|
||||||
|
* @param [in] task_id
|
||||||
|
* @return imp_msg_queue_t*
|
||||||
|
* @date 2024-12-04
|
||||||
|
* @author Alvin Young (impressionyang@outlook.com)
|
||||||
|
*
|
||||||
|
* @details
|
||||||
|
* @note
|
||||||
|
* @par 修改日志:
|
||||||
|
* <table>
|
||||||
|
* <tr><th>Date <th>Author <th>Description
|
||||||
|
* <tr><td>2024-12-04 <td>Alvin Young <td>新建
|
||||||
|
* </table>
|
||||||
|
*/
|
||||||
|
imp_msg_queue_t* imp_msg_queue_create_handle(uint16_t task_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @brief 接收消息
|
||||||
|
* @param [in] handle
|
||||||
|
* @param [in] msg
|
||||||
|
* @return uint8_t
|
||||||
|
* @date 2024-12-04
|
||||||
|
* @author Alvin Young (impressionyang@outlook.com)
|
||||||
|
*
|
||||||
|
* @details
|
||||||
|
* @note
|
||||||
|
* @par 修改日志:
|
||||||
|
* <table>
|
||||||
|
* <tr><th>Date <th>Author <th>Description
|
||||||
|
* <tr><td>2024-12-04 <td>Alvin Young <td>新建
|
||||||
|
* </table>
|
||||||
|
*/
|
||||||
|
uint8_t imp_msg_queue_recv_msg(imp_msg_queue_t* handle, imp_msg_item_t* msg,
|
||||||
|
uint16_t timeout);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @brief 发送消息
|
||||||
|
* @param [in] handle
|
||||||
|
* @param [in] recv_id
|
||||||
|
* @param [in] msg
|
||||||
|
* @return uint8_t
|
||||||
|
* @date 2024-12-04
|
||||||
|
* @author Alvin Young (impressionyang@outlook.com)
|
||||||
|
*
|
||||||
|
* @details
|
||||||
|
* @note
|
||||||
|
* @par 修改日志:
|
||||||
|
* <table>
|
||||||
|
* <tr><th>Date <th>Author <th>Description
|
||||||
|
* <tr><td>2024-12-04 <td>Alvin Young <td>新建
|
||||||
|
* </table>
|
||||||
|
*/
|
||||||
|
uint8_t imp_msg_queue_send_msg(imp_msg_queue_t* handle, uint16_t recv_id,
|
||||||
|
imp_msg_item_t* msg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @brief 销毁一个消息队列控制句柄
|
||||||
|
* @param [in] handle
|
||||||
|
* @return uint8_t
|
||||||
|
* @date 2024-12-04
|
||||||
|
* @author Alvin Young (impressionyang@outlook.com)
|
||||||
|
*
|
||||||
|
* @details
|
||||||
|
* @note
|
||||||
|
* @par 修改日志:
|
||||||
|
* <table>
|
||||||
|
* <tr><th>Date <th>Author <th>Description
|
||||||
|
* <tr><td>2024-12-04 <td>Alvin Young <td>新建
|
||||||
|
* </table>
|
||||||
|
*/
|
||||||
|
uint8_t imp_msg_queue_destroy_handle(imp_msg_queue_t* handle);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif //__IMP_MSG_QUEUE_H__
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EOF
|
||||||
|
*/
|
||||||
10
main/main.c
10
main/main.c
@ -20,6 +20,7 @@
|
|||||||
#include "shell_port.h"
|
#include "shell_port.h"
|
||||||
#include "main_app.h"
|
#include "main_app.h"
|
||||||
#include "main_common.h"
|
#include "main_common.h"
|
||||||
|
#include "imp_msg_queue.h"
|
||||||
|
|
||||||
static void _init_esp()
|
static void _init_esp()
|
||||||
{
|
{
|
||||||
@ -47,8 +48,8 @@ void app_main(void)
|
|||||||
esp_chip_info_t chip_info;
|
esp_chip_info_t chip_info;
|
||||||
uint32_t flash_size;
|
uint32_t flash_size;
|
||||||
esp_chip_info(&chip_info);
|
esp_chip_info(&chip_info);
|
||||||
cdc_printf("This is %s chip with %d CPU core(s), %s%s%s%s, ", CONFIG_IDF_TARGET,
|
cdc_printf("This is %s chip with %d CPU core(s), %s%s%s%s, ",
|
||||||
chip_info.cores,
|
CONFIG_IDF_TARGET, chip_info.cores,
|
||||||
(chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
|
(chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
|
||||||
(chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
|
(chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
|
||||||
(chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
|
(chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
|
||||||
@ -64,7 +65,8 @@ void app_main(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cdc_printf("%" PRIu32 "MB %s flash\r\n", flash_size / (uint32_t)(1024 * 1024),
|
cdc_printf("%" PRIu32 "MB %s flash\r\n",
|
||||||
|
flash_size / (uint32_t)(1024 * 1024),
|
||||||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded"
|
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded"
|
||||||
: "external");
|
: "external");
|
||||||
|
|
||||||
@ -77,6 +79,8 @@ void app_main(void)
|
|||||||
// }
|
// }
|
||||||
cdc_printf("start run app:\r\n");
|
cdc_printf("start run app:\r\n");
|
||||||
|
|
||||||
|
|
||||||
|
imp_msg_queue_init();
|
||||||
xTaskCreate(imp_main_app_task, "main", 2048, NULL, 10, NULL);
|
xTaskCreate(imp_main_app_task, "main", 2048, NULL, 10, NULL);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|||||||
39
main/main_common.c
Normal file
39
main/main_common.c
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* @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"
|
||||||
|
/* 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) -----------------------------------------------*/
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
/*
|
||||||
|
* EOF
|
||||||
|
*/
|
||||||
@ -29,8 +29,16 @@ extern "C" {
|
|||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
/* define --------------------------------------------------------------------*/
|
/* define --------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#define IMP_TASK_ID_IDLE (0)
|
||||||
|
#define IMP_TASK_ID_MAIN_TASK (1)
|
||||||
|
#define IMP_TASK_ID_EXT_TRANS_SERVICE_TASK (2)
|
||||||
|
|
||||||
/* typedef -------------------------------------------------------------------*/
|
/* typedef -------------------------------------------------------------------*/
|
||||||
/* variables -----------------------------------------------------------------*/
|
/* variables -----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
extern char* imp_main_task_table[];
|
||||||
|
|
||||||
/* Private function(only *.c) -----------------------------------------------*/
|
/* Private function(only *.c) -----------------------------------------------*/
|
||||||
/* Exported functions --------------------------------------------------------*/
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
|
||||||
|
|||||||
1
main/services/README.md
Normal file
1
main/services/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
service是某个专门的功能集合,具备多线程资源,他自己就是一个线程,通过调动不同的component进行特定的事项
|
||||||
59
main/services/ext_trans_service/ext_trans_service.c
Normal file
59
main/services/ext_trans_service/ext_trans_service.c
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
* @file ext_trans_service.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 "ext_trans_service.h"
|
||||||
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
|
#include "imp_msg_queue.h"
|
||||||
|
|
||||||
|
/* define --------------------------------------------------------------------*/
|
||||||
|
/* typedef -------------------------------------------------------------------*/
|
||||||
|
/* variables -----------------------------------------------------------------*/
|
||||||
|
|
||||||
|
static imp_msg_queue_t* msg_q_handle = NULL;
|
||||||
|
/* Private function(only *.c) -----------------------------------------------*/
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
|
||||||
|
uint8_t imp_ext_trans_service_task()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
msg_q_handle =
|
||||||
|
imp_msg_queue_create_handle(IMP_TASK_ID_EXT_TRANS_SERVICE_TASK);
|
||||||
|
imp_msg_item_t msg_item = { 0 };
|
||||||
|
uint8_t msg_read_ret = 0;
|
||||||
|
while (1) {
|
||||||
|
msg_read_ret = imp_msg_queue_recv_msg(msg_q_handle, &msg_item, 0);
|
||||||
|
if (!msg_read_ret) {
|
||||||
|
// read succeed
|
||||||
|
cdc_printf("read msg ok from %d to %d value: %d\r\n",
|
||||||
|
msg_item.send_id, msg_item.recv_id, msg_item.msg_data);
|
||||||
|
}
|
||||||
|
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EOF
|
||||||
|
*/
|
||||||
51
main/services/ext_trans_service/ext_trans_service.h
Normal file
51
main/services/ext_trans_service/ext_trans_service.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* @file ext_trans_service.h
|
||||||
|
* @author Alvin Young (impressionyang@outlook.com)
|
||||||
|
* @brief 用来界定外部串口输出的内容是字符流还是控制流的,需要完成的操作为分割控制流
|
||||||
|
* 和字符流,控制流交给控制模块同时切断cdc_printf的功能,字符流则释放cdc_printf的打
|
||||||
|
* 印内容权限
|
||||||
|
* @version 0.1
|
||||||
|
* @date 2024-12-03
|
||||||
|
*
|
||||||
|
* _ _
|
||||||
|
* (_)_ _ ___ _______ ___ ___ (_)__ ___ __ _____ ____ ___ _
|
||||||
|
* / / ' \/ _ \/ __/ -_|_-<(_-</ / _ \/ _ \/ // / _ `/ _ \/ _ `/
|
||||||
|
* /_/_/_/_/ .__/_/ \__/___/___/_/\___/_//_/\_, /\_,_/_//_/\_, /
|
||||||
|
* /_/ /___/ /___/
|
||||||
|
* @copyright Copyright (c) 2024 impressionyang
|
||||||
|
*
|
||||||
|
* @par 修改日志:
|
||||||
|
* <table>
|
||||||
|
* <tr><th>Date <th>Version <th>Author <th>Description
|
||||||
|
* <tr><td>2024-12-03 <td>v1.0 <td>Alvin Young <td>首次创建
|
||||||
|
* </table>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef __EXT_TRANS_SERVICE_H__
|
||||||
|
#define __EXT_TRANS_SERVICE_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "main_common.h"
|
||||||
|
/* define --------------------------------------------------------------------*/
|
||||||
|
/* typedef -------------------------------------------------------------------*/
|
||||||
|
/* variables -----------------------------------------------------------------*/
|
||||||
|
/* Private function(only *.c) -----------------------------------------------*/
|
||||||
|
/* Exported functions --------------------------------------------------------*/
|
||||||
|
|
||||||
|
uint8_t imp_ext_trans_service_task();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif //__EXT_TRANS_SERVICE_H__
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EOF
|
||||||
|
*/
|
||||||
Loading…
Reference in New Issue
Block a user