Перенос на новую организацию GONEC

This commit is contained in:
cfif 2025-01-24 13:22:33 +03:00
commit 6a860ee100
3 changed files with 119 additions and 0 deletions

42
Inc/TaskMsd.h Normal file
View File

@ -0,0 +1,42 @@
//
// Created by cfif on 04.10.2022.
//
#ifndef TTASKMSD_H
#define TTASKMSD_H
#include <cmsis_os.h>
#include "Gnss.h"
#include "EraGlonassMsd.h"
#include "ModemMain.h"
#include "ModemGnss.h"
#include "Gpios.h"
typedef struct {
tGnss *gnss;
tRtcIO *rtcIo;
tModemMain *modemMain;
tGpios *gpios;
struct {
osThreadId_t id;
uint32_t stack[2048];
StaticTask_t controlBlock;
osThreadAttr_t attr;
} thread;
} tTaskMsd;
void TaskMsd_Init(
tTaskMsd *env,
tGnss *gnss,
tRtcIO *rtcIo,
tModemMain *modemMain,
tGpios *gpios
);
void TaskMsd_StartThread(tTaskMsd *env);
#endif //TTASKMSD_H

59
Src/TaskMsd.c Normal file
View File

@ -0,0 +1,59 @@
//
// Created by cfif on 04.10.2022.
//
#include <stddef.h>
#include <SystemDelayInterface.h>
#include <TaskMsd.h>
#include <CmsisRtosThreadUtils.h>
#include "fs_interface.h"
void TaskMsd_Init(
tTaskMsd *env,
tGnss *gnss,
tRtcIO *rtcIo,
tModemMain *modemMain,
tGpios *gpios
) {
env->gnss = gnss;
env->rtcIo = rtcIo;
env->modemMain = modemMain;
env->gpios = gpios;
//Инициализируем поток
InitThreadAtrStatic(&env->thread.attr, "TaskMsd", env->thread.controlBlock, env->thread.stack, osPriorityNormal);
env->thread.id = 0;
}
static _Noreturn void TaskMsd_Thread(tTaskMsd *env) {
bool isFlagStuckSos = false;
for (;;) {
bool isButtonSosPress = GpioPinGet(&env->gpios->Power.discretIn1_pg2);
// Нажата кнопка SOS
if (isButtonSosPress) {
isFlagStuckSos = true;
} else {
if (isFlagStuckSos) {
isFlagStuckSos = false;
sendMsd(env->modemMain);
}
}
SystemDelayMs(200);
}
}
void TaskMsd_StartThread(tTaskMsd *env) {
if (!env->thread.id) {
env->thread.id = osThreadNew((osThreadFunc_t) (TaskMsd_Thread), (void *) (env), &env->thread.attr);
} else {
osThreadResume(env->thread.id);
}
}

18
modular.json Normal file
View File

@ -0,0 +1,18 @@
{
"dep": [
{
"type": "git",
"provider": "GONEC",
"repo": "SystemDelayInterface"
}
],
"cmake": {
"inc_dirs": [
"Inc"
],
"srcs": [
"Src/**.c"
]
}
}