Добавлены интерфейсы и драйверы

This commit is contained in:
cfif 2025-09-30 15:52:33 +03:00
commit 7023f641fa
7 changed files with 219 additions and 0 deletions

42
MainModesArbiter.c Normal file
View File

@ -0,0 +1,42 @@
//
// Created by cfif on 05.05.23.
//
#include "MainModesArbiter_Private.h"
void Mma_Init(
tMma *env,
tGpios *gpios,
tSerialPorts *serialPorts,
tRtcs *rtcs
) {
env->gpios = gpios;
env->serialPorts = serialPorts;
env->rtcs = rtcs;
InitThreadAtrStatic(&env->thread.attr, "Mma", env->thread.controlBlock, env->thread.stack, osPriorityNormal);
env->thread.id = 0;
}
static _Noreturn void Mma_Thread(tMma *env) {
// Запуск устройства
Mma_InitStage(env);
for (;;) {
// GpioPinSet(&env->gpios->Led.ledR, true);
SystemDelayMs(500);
// GpioPinSet(&env->gpios->Led.ledR, false);
SystemDelayMs(500);
}
}
void Mma_StartThread(tMma *env) {
if (!env->thread.id) {
env->thread.id = osThreadNew((osThreadFunc_t) (Mma_Thread), (void *) (env), &env->thread.attr);
} else {
osThreadResume(env->thread.id);
}
}

57
MainModesArbiter.h Normal file
View File

@ -0,0 +1,57 @@
//
// Created by cfif on 05.05.23.
//
#ifndef WATER_BOX_BSD_MAINMODESARBITER_H
#define WATER_BOX_BSD_MAINMODESARBITER_H
#include "CmsisRtosThreadUtils.h"
//Железные интерфейсы
#include "PeripheralInterfaces.h"
//Подсистемы
#include "PowerManagement.h"
#include "Rtcs.h"
#include "LoggerToSerialPort.h"
#include "ComInt.h"
#include "Indication.h"
#include "CommandLines.h"
typedef struct {
// Преферийные интерфесы
tGpios *gpios;
tSerialPorts *serialPorts;
tLoggerToSerialPort slog;
tComInt comInt;
tRtcs *rtcs;
tPowerManagement power;
tCommandLine cli;
tIndication Indication;
struct {
osThreadId_t id;
uint32_t stack[2048 * 1];
StaticTask_t controlBlock;
osThreadAttr_t attr;
} thread;
uint8_t data[46];
uint8_t BufFileWrite[512];
} tMma;
void Mma_Init(
tMma *env,
tGpios *gpios,
tSerialPorts *serialPorts,
tRtcs *rtcs
);
void Mma_StartThread(tMma *env);
#endif //WATER_BOX_BSD_MAINMODESARBITER_H

View File

@ -0,0 +1,72 @@
//
// Created by cfif on 05.05.23.
//
#include "MainModesArbiter_Private.h"
//#include "FirmwareMetadataSection.h"
#define LOGGER &env->slog.logger
const char LOG_TASK_MAIN[] = "Initialization task";
void Mma_InitComIntLog(tMma *env) {
Indication_Init(&env->Indication, HVAC_DEV_MODE_STARTUP);
LoggerToSerialPort_Init(
&env->slog,
0,
&SERIAL_PORTS.cliVirtualInIo,
NULL,
SERIAL_LOGGER_SHOW_AUTHOR | SERIAL_LOGGER_SHOW_LOG_LEVEL
);
env->slog.timeout = 0;
LoggerInfoStatic(&env->slog.logger, LOG_TASK_MAIN, "Начало логирования")
}
static void Mma_InitSubSystems(tMma *env) {
InitPeripheralInterfaces();
// Настройка таймера реального времени
time_t set_timestamp = 0;
RtcSet(&env->rtcs->rtcI0, &set_timestamp);
Mma_InitComIntLog(env);
LoggerInfoStatic(&env->slog.logger, LOG_TASK_MAIN, "Инициализация подсистем")
/*
ComInt_Init(
&env->comInt,
&SERIAL_PORTS.Rs485_HalfDuplexIo,
NULL,
&SERIAL_PORTS.SerialPortUsbIO,
NULL,
&SERIAL_PORTS.cliVirtualOutIo,
&env->Indication.currentModeName
);
ComInt_StartThread(&env->comInt);
CommandLine_Init(&env->cli, &env->serialPorts->cliVirtualInIo);
CommandLine_StartThread(&env->cli);
*/
LoggerInfoStatic(&env->slog.logger, LOG_TASK_MAIN, "Конец инициализации подсистем")
}
static void Mma_RunSubThreads(tMma *env) {
Indication_SetMode(&env->Indication, HVAC_DEV_MODE_RUN);
}
static void Mma_InitPower(tMma *env) {
}
void Mma_InitStage(tMma *env) {
Mma_InitSubSystems(env);
Mma_InitPower(env);
Mma_RunSubThreads(env);
}

View File

@ -0,0 +1,12 @@
//
// Created by cfif on 05.05.23.
//
#ifndef WATER_BOX_BSD_MAINMODESARBITER_PRIVATE_H
#define WATER_BOX_BSD_MAINMODESARBITER_PRIVATE_H
#include "MainModesArbiter.h"
void Mma_InitStage(tMma *env);
#endif //WATER_BOX_BSD_MAINMODESARBITER_PRIVATE_H

12
PeripheralInterfaces.c Normal file
View File

@ -0,0 +1,12 @@
//
// Created by cfif on 05.05.23.
//
#include "PeripheralInterfaces.h"
void InitPeripheralInterfaces() {
Gpios_Init();
SerialPorts_Init();
Rtcs_Init();
}

14
PeripheralInterfaces.h Normal file
View File

@ -0,0 +1,14 @@
//
// Created by cfif on 05.05.23.
//
#ifndef WATER_BOX_BSD_PERIPHERALINTERFACES_H
#define WATER_BOX_BSD_PERIPHERALINTERFACES_H
#include "Gpios.h"
#include "SerialPorts.h"
#include "Rtcs.h"
void InitPeripheralInterfaces();
#endif //WATER_BOX_BSD_PERIPHERALINTERFACES_H

10
modular.json Normal file
View File

@ -0,0 +1,10 @@
{
"cmake": {
"inc_dirs": [
"./"
],
"srcs": [
"./**.c"
]
}
}