Переход в новую организацию

This commit is contained in:
cfif 2025-03-11 12:05:56 +03:00
commit 5c185bfea4
3 changed files with 132 additions and 0 deletions

52
CmsisRtosThreadUtils.c Executable file
View File

@ -0,0 +1,52 @@
//
// Created by xemon on 23.11.22.
//
#include "CmsisRtosThreadUtils.h"
void InitThreadAtr(
osThreadAttr_t *attr,
const char *name, ///< name of the thread
void *cb_mem, ///< memory for control block
uint32_t cb_size, ///< size of provided memory for control block
void *stack_mem, ///< memory for stack
uint32_t stack_size, ///< size of stack
osPriority_t priority ///< initial thread priority (default: osPriorityNormal)
) {
attr->name = name;
attr->cb_mem = cb_mem;
attr->cb_size = cb_size;
attr->stack_mem = stack_mem;
attr->stack_size = stack_size;
attr->priority = priority;
attr->tz_module = 0;
attr->reserved = 0;
}
void InitQueueAtr(
osMessageQueueAttr_t *attr,
const char *name, ///< name of the thread
void *cb_mem, ///< memory for control block
uint32_t cb_size, ///< size of provided memory for control block
void *mem, ///< memory for data
uint32_t mem_size ///< size of mem
) {
attr->name = name;
attr->cb_mem = cb_mem;
attr->cb_size = cb_size;
attr->mq_mem = mem;
attr->mq_size = mem_size;
}

63
CmsisRtosThreadUtils.h Executable file
View File

@ -0,0 +1,63 @@
//
// Created by xemon on 08.09.22.
//
#ifndef CMSISRTOSTHREADSUTILS_CMSISRTOSTHREADSUTILS_H
#define CMSISRTOSTHREADSUTILS_CMSISRTOSTHREADSUTILS_H
#include "cmsis_os.h"
typedef struct {
osThreadId_t id;
StaticTask_t controlBlock;
} tThreadData;
#define tStaticThreadBlock(WORDS_LEN) struct { osThreadId_t id; osThreadAttr_t attr; StaticTask_t controlBlock; uint32_t stack[WORDS_LEN]; }
#define tStaticThreadDynBlock struct { osThreadId_t id; osThreadAttr_t attr; }
#define THREAD_ATTR_CREATE(PRIORITY, TASK_NAME) osThreadAttr_t TASK_NAME##TaskAttr ={ \
.name = #TASK_NAME, \
.cb_mem = &threads.TASK_NAME.controlBlock, \
.cb_size = sizeof(threads.TASK_NAME.controlBlock), \
\
.stack_mem = &threadsBuffers.TASK_NAME[0], \
.stack_size = sizeof(threadsBuffers.TASK_NAME), \
\
.priority = (osPriority_t) (PRIORITY) \
}
#define THREAD_ADD(THREAD_NAME, ENV, FUNC) threads.THREAD_NAME.id = osThreadNew((osThreadFunc_t)(FUNC), (void *) (ENV), &THREAD_NAME##TaskAttr)
void InitThreadAtr(
osThreadAttr_t *attr,
const char *name, ///< name of the thread
void *cb_mem, ///< memory for control block
uint32_t cb_size, ///< size of provided memory for control block
void *stack_mem, ///< memory for stack
uint32_t stack_size, ///< size of stack
osPriority_t priority ///< initial thread priority (default: osPriorityNormal)
);
void InitQueueAtr(
osMessageQueueAttr_t *attr,
const char *name, ///< name of the thread
void *cb_mem, ///< memory for control block
uint32_t cb_size, ///< size of provided memory for control block
void *mem, ///< memory for data
uint32_t mem_size ///< size of mem
);
#define InitThreadAtrStatic(ATTR, NAME, CB, STACK, PRIOR) InitThreadAtr(ATTR,NAME,&CB,sizeof(CB),STACK,sizeof(STACK),PRIOR)
#define InitQueueAtrStatic(ATTR, NAME, CB, MEM) InitQueueAtr(ATTR,NAME,&CB,sizeof(CB),MEM,sizeof(MEM))
#define InitThreadBlock(BLOCK, NAME, PRIOR) (BLOCK).id = 0; InitThreadAtr(&(BLOCK).attr,NAME,&(BLOCK).controlBlock,sizeof((BLOCK).controlBlock),(BLOCK).stack,sizeof((BLOCK).stack),PRIOR)
#define InitThreadDynBlock(BLOCK, NAME, STACK, PRIOR) (BLOCK).id = 0; InitThreadAtr(&(BLOCK).attr,NAME,NULL,0,NULL,STACK,PRIOR)
#define PinThreadToCore(BLOCK, CORE) (BLOCK).attr.pinToCore = 1; (BLOCK).attr.core = CORE
#endif //CMSISRTOSTHREADSUTILS_CMSISRTOSTHREADSUTILS_H

17
modular.json Executable file
View File

@ -0,0 +1,17 @@
{
"dep": [
{
"type": "git",
"provider": "GONEC_BOOT_MODEM",
"repo": "CmsisRtosInterface"
}
],
"cmake": {
"inc_dirs": [
"./"
],
"srcs": [
"./*.c"
]
}
}