Init
This commit is contained in:
commit
900a0037f1
|
|
@ -0,0 +1,26 @@
|
||||||
|
//
|
||||||
|
// Created by cfif on 17.11.22.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef LIN_AT32_H
|
||||||
|
#define LIN_AT32_H
|
||||||
|
|
||||||
|
#include "LinIO.h"
|
||||||
|
#include "SerialPortIO.h"
|
||||||
|
#include "SerialPort.h"
|
||||||
|
#include "cmsis_os2.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
tSerialPortIO *serialPortIO;
|
||||||
|
tLinData *linData;
|
||||||
|
} tLinAt32;
|
||||||
|
|
||||||
|
void LIN_Initial(
|
||||||
|
tLinAt32 *env,
|
||||||
|
tSerialPortIO *serialPortIO,
|
||||||
|
void *linData
|
||||||
|
);
|
||||||
|
|
||||||
|
tLinIO vLinGetIo(tLinAt32 *env);
|
||||||
|
|
||||||
|
#endif //LIN_AT32_H
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
//
|
||||||
|
// Created by cfif on 07.09.22.
|
||||||
|
//
|
||||||
|
#include <SystemDelayInterface.h>
|
||||||
|
#include "LinAt32.h"
|
||||||
|
#include "SerialPortArtery.h"
|
||||||
|
|
||||||
|
void LIN_Initial(
|
||||||
|
tLinAt32 *env,
|
||||||
|
tSerialPortIO *serialPortIO,
|
||||||
|
void *linData
|
||||||
|
) {
|
||||||
|
env->serialPortIO = serialPortIO;
|
||||||
|
env->linData = linData;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t vLinRunCommand(tLinAt32 *env, uint32_t timeout) {
|
||||||
|
|
||||||
|
lin_frame_t txFrame;
|
||||||
|
|
||||||
|
txFrame.dataLen = env->linData->g_aTxBufferLen;
|
||||||
|
for (uint8_t i = 0; i < env->linData->g_aTxBufferLen; ++i) {
|
||||||
|
txFrame.data[i] = env->linData->g_aTxBuffer[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool result = vSerialPortSendLinFrame(env->serialPortIO->env, &txFrame, timeout);
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
return LIN_RX_COMPLETED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return LIN_TIMEOUT;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t vLinGetCommand(tLinAt32 *env, uint32_t timeout) {
|
||||||
|
lin_frame_t rxFrame;
|
||||||
|
|
||||||
|
uint16_t len = SerialPortReceive(env->serialPortIO, (void *) &rxFrame, sizeof(lin_frame_t), timeout);
|
||||||
|
|
||||||
|
if (len == 0) {
|
||||||
|
return LIN_NO_EVENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
env->linData->g_aRxBufferLen = rxFrame.dataLen;
|
||||||
|
for (uint8_t i = 0; i < rxFrame.dataLen; ++i) {
|
||||||
|
env->linData->g_aRxBuffer[i] = rxFrame.data[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return rxFrame.event;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
tLinIO vLinGetIo(tLinAt32 *env) {
|
||||||
|
tLinIO io = {
|
||||||
|
.env = env,
|
||||||
|
.runCommand = (LinIOTransaction) vLinRunCommand,
|
||||||
|
.getCommand = (LinIOTransaction) vLinGetCommand
|
||||||
|
};
|
||||||
|
return io;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"dep": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"provider": "HVAC_DEV",
|
||||||
|
"repo": "LinInterface"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"cmake": {
|
||||||
|
"inc_dirs": [
|
||||||
|
"Inc"
|
||||||
|
],
|
||||||
|
"srcs": [
|
||||||
|
"Src/**.c"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue