Начало
This commit is contained in:
commit
0c4bf0371c
|
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// Created by cfif on 11.10.23.
|
||||
//
|
||||
#include "Indication.h"
|
||||
#include <SystemDelayInterface.h>
|
||||
#include <CmsisRtosThreadUtils.h>
|
||||
|
||||
tStringStatic eDeviceModesNames[] = {
|
||||
StringStaticInit("Запуск"),
|
||||
StringStaticInit("Работа")
|
||||
};
|
||||
|
||||
static void Indication_Update(tIndication *env) {
|
||||
env->currentModeName = StringStaticGetLink(&eDeviceModesNames[env->mode]);
|
||||
|
||||
env->tick = ((env->tick + 1) % 10);
|
||||
}
|
||||
|
||||
void Indication_Init(
|
||||
tIndication *env,
|
||||
eHvacDevModes initMode
|
||||
) {
|
||||
|
||||
env->mode = initMode;
|
||||
Indication_Update(env);
|
||||
|
||||
InitThreadAtrStatic(&env->thread.attr, "Indication", env->thread.controlBlock, env->thread.stack, osPriorityNormal);
|
||||
env->thread.id = 0;
|
||||
}
|
||||
|
||||
void Indication_SetMode(tIndication *env, eHvacDevModes mode) {
|
||||
if (env->mode != mode) {
|
||||
env->mode = mode;
|
||||
Indication_Update(env);
|
||||
}
|
||||
}
|
||||
|
||||
static _Noreturn void Indication_Thread(tIndication *env) {
|
||||
for (;;) {
|
||||
Indication_Update(env);
|
||||
SystemDelayMs(100);
|
||||
}
|
||||
}
|
||||
|
||||
void Indication_StartThread(tIndication *env) {
|
||||
if (!env->thread.id) {
|
||||
env->thread.id = osThreadNew((osThreadFunc_t) (Indication_Thread), (void *) (env), &env->thread.attr);
|
||||
} else {
|
||||
osThreadResume(env->thread.id);
|
||||
}
|
||||
}
|
||||
|
||||
void Indication_StopThread(tIndication *env) {
|
||||
if (env->thread.id) {
|
||||
osThreadSuspend(env->thread.id);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
//
|
||||
// Created by cfif on 11.10.23.
|
||||
//
|
||||
|
||||
#ifndef ERA_ELEMENT_2_INDICATION_H
|
||||
#define ERA_ELEMENT_2_INDICATION_H
|
||||
|
||||
#include <cmsis_os.h>
|
||||
#include <BaseTypes.h>
|
||||
|
||||
typedef enum {
|
||||
HVAC_DEV_MODE_STARTUP = 0,
|
||||
HVAC_DEV_MODE_RUN = 1
|
||||
} eHvacDevModes;
|
||||
|
||||
typedef struct {
|
||||
eHvacDevModes mode;
|
||||
tStringLink currentModeName;
|
||||
|
||||
uint16_t tick;
|
||||
|
||||
struct {
|
||||
osThreadId_t id;
|
||||
uint32_t stack[128];
|
||||
StaticTask_t controlBlock;
|
||||
osThreadAttr_t attr;
|
||||
} thread;
|
||||
} tIndication;
|
||||
|
||||
void Indication_Init(tIndication *env, eHvacDevModes initMode);
|
||||
void Indication_SetMode(tIndication *env, eHvacDevModes mode);
|
||||
void Indication_StartThread(tIndication *env);
|
||||
void Indication_StopThread(tIndication *env);
|
||||
|
||||
#endif //ERA_ELEMENT_2_INDICATION_H
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"cmake": {
|
||||
"inc_dirs": [
|
||||
"./"
|
||||
],
|
||||
"srcs": [
|
||||
"./**.c"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue