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

This commit is contained in:
cfif 2025-01-24 13:22:32 +03:00
commit 8cebf12626
3 changed files with 142 additions and 0 deletions

34
Inc/TaskAdc.h Normal file
View File

@ -0,0 +1,34 @@
//
// Created by cfif on 04.10.2022.
//
#ifndef TTASKACD_H
#define TTASKACD_H
#include <cmsis_os.h>
#include "Adcs.h"
typedef struct {
tAdcs *adcs;
uint16_t vcc;
struct {
osThreadId_t id;
uint32_t stack[2048];
StaticTask_t controlBlock;
osThreadAttr_t attr;
} thread;
} tTaskAdc;
void TaskAdc_Init(
tTaskAdc *env,
tAdcs *adcs
);
void TaskAdc_StartThread(tTaskAdc *env);
uint32_t getVcc(tTaskAdc *env);
#endif //TTASKACD_H

90
Src/TaskAdc.c Normal file
View File

@ -0,0 +1,90 @@
//
// Created by cfif on 04.10.2022.
//
#include <stddef.h>
#include <SystemDelayInterface.h>
#include <TaskAdc.h>
#include <CmsisRtosThreadUtils.h>
#include "fs_interface.h"
void TaskAdc_Init(
tTaskAdc *env,
tAdcs *adcs
) {
env->adcs = adcs;
//Инициализируем поток
InitThreadAtrStatic(&env->thread.attr, "TaskAcd", env->thread.controlBlock, env->thread.stack, osPriorityNormal);
env->thread.id = 0;
}
uint32_t getVcc(tTaskAdc *env) {
double vcc;
vcc = env->vcc / 0.219666667;
return (uint32_t)vcc;
}
uint8_t bufAnswer[1024];
static _Noreturn void TaskAdc_Thread(tTaskAdc *env) {
/*
tFs *fs;
FIL file;
UINT bytes_read;
int step = 0;
while (1) {
FRESULT fr = f_open_i(fs, &file, "1:/LOG/04-06-23.LOG", FA_READ);
if (fr) {
asm("nop");
}
if (step == 1)
fr = f_lseek_i(fs, &file, 40000);
if (step == 2)
fr = f_lseek_i(fs, &file, 80000);
++step;
if (step == 3)
step = 0;
uint32_t t1 = SystemGetMs();
fr = f_read_i(fs, &file, bufAnswer, 1024, &bytes_read);
uint32_t t2 = SystemGetMs();
uint32_t t3 = t2 - t1;
if (t3 > 10) {
asm("nop");
}
f_close_i(fs, &file);
SystemDelayMs(100);
}
*/
for (;;) {
env->vcc = env->adcs->vccIo.get(&env->adcs->vcc, 1000);
SystemDelayMs(100);
}
}
void TaskAdc_StartThread(tTaskAdc *env) {
if (!env->thread.id) {
env->thread.id = osThreadNew((osThreadFunc_t) (TaskAdc_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"
]
}
}