Обновление
This commit is contained in:
commit
e2d04301bd
|
|
@ -0,0 +1,53 @@
|
|||
//
|
||||
// Created by cfif on 05.04.2024.
|
||||
//
|
||||
#include <SystemDelayInterface.h>
|
||||
#include "CanSpamReceiver.h"
|
||||
#include "CmsisRtosThreadUtils.h"
|
||||
#include "CanPorts.h"
|
||||
|
||||
void CanSpamReceiver_Init(tCanSpamReceiver *env,
|
||||
tSerialPortFrameIO *ioCanFrame) {
|
||||
|
||||
env->ioCanFrame = ioCanFrame;
|
||||
|
||||
env->access = osMutexNew(NULL);
|
||||
|
||||
InitThreadAtrStatic(&env->thread.attr, "CanSpamReceiver", env->thread.controlBlock, env->thread.stack,
|
||||
osPriorityNormal);
|
||||
}
|
||||
|
||||
void ListenCanSpamReceiver(tCanSpamReceiver *env) {
|
||||
|
||||
uint16_t recv = env->ioCanFrame->receive(env->ioCanFrame->env, PROTOCOL_CAN_RAW, (uint8_t *) &env->canFrame, 1,
|
||||
1000);
|
||||
|
||||
if (recv == 0)
|
||||
return;
|
||||
|
||||
if (osMutexAcquire(env->access, 100) == osOK) {
|
||||
|
||||
uint32_t id = env->canFrame.standard_id;
|
||||
|
||||
if (env->canFrame.id_type == FLEXCAN_ID_EXT) {
|
||||
id = env->canFrame.extended_id;
|
||||
}
|
||||
|
||||
uint32_t result = ccu_candb_Receive(&ccu_candb_rx, env->canFrame.data, id, env->canFrame.dlc);
|
||||
|
||||
osMutexRelease(env->access);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static _Noreturn void CanSpamReceiver_Thread(tCanSpamReceiver *env) {
|
||||
for (;;) {
|
||||
ListenCanSpamReceiver(env);
|
||||
}
|
||||
}
|
||||
|
||||
void CanSpamReceiver_StartThread(tCanSpamReceiver *env) {
|
||||
if (!env->thread.id) {
|
||||
env->thread.id = osThreadNew((osThreadFunc_t) (CanSpamReceiver_Thread), (void *) (env), &env->thread.attr);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
//
|
||||
// Created by cfif on 05.04.2024.
|
||||
//
|
||||
|
||||
#ifndef HVAC_COMMANDLINES_H
|
||||
#define HVAC_COMMANDLINES_H
|
||||
|
||||
#include <cmsis_os.h>
|
||||
#include "CanSerialPortFrame.h"
|
||||
#include "ccu_candb-binutil.h"
|
||||
|
||||
typedef struct {
|
||||
|
||||
tSerialPortFrameIO *ioCanFrame;
|
||||
osMutexId_t access;
|
||||
can_rx_message_type canFrame;
|
||||
|
||||
struct {
|
||||
osThreadId_t id;
|
||||
uint32_t stack[512];
|
||||
StaticTask_t controlBlock;
|
||||
osThreadAttr_t attr;
|
||||
} thread;
|
||||
|
||||
} tCanSpamReceiver;
|
||||
|
||||
void CanSpamReceiver_Init(tCanSpamReceiver *env, tSerialPortFrameIO *ioCanFrame);
|
||||
|
||||
void CanSpamReceiver_StartThread(tCanSpamReceiver *env);
|
||||
|
||||
#endif //HVAC_COMMANDLINES_H
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"cmake": {
|
||||
"inc_dirs": [
|
||||
"./"
|
||||
],
|
||||
"srcs": [
|
||||
"./**.c"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue