53 lines
1.4 KiB
C
53 lines
1.4 KiB
C
//
|
|
// Created by cfif on 16.09.22.
|
|
//
|
|
|
|
#ifndef SERIALPORT_SERIALPORTLIN_ARTERY_H
|
|
#define SERIALPORT_SERIALPORTLIN_ARTERY_H
|
|
|
|
#include "SerialPort.h"
|
|
#include "at32f435_437.h"
|
|
#include "cmsis_os2.h"
|
|
#include "stdbool.h"
|
|
#include "LinIO.h"
|
|
|
|
typedef struct __attribute__((packed)) {
|
|
uint8_t id; // ID команды (0-63)
|
|
uint8_t dataLen; // Длина данных (0-8)
|
|
uint8_t data[8]; // Массив данных
|
|
uint8_t checksum; // Контрольная сумма
|
|
lin_event_id_t event; // Событие/статус приема
|
|
} lin_frame_t;
|
|
|
|
typedef struct {
|
|
usart_type *uart;
|
|
bool linFrameStarted;
|
|
uint8_t linByteCount;
|
|
uint32_t linLastByteTime;
|
|
uint32_t linFrameTimeoutMs;
|
|
uint8_t linBuffer[12];
|
|
lin_frame_t rxFrame;
|
|
osMessageQueueId_t rxDataQueue;
|
|
osMessageQueueId_t rxDataSnifferQueue;
|
|
} tSerialPortLinArtery;
|
|
|
|
|
|
void vSerialPortLinInit(
|
|
tSerialPortLinArtery *env,
|
|
usart_type *uart,
|
|
bool swap,
|
|
uint32_t BoundRate,
|
|
IRQn_Type irq,
|
|
crm_periph_clock_type uartClock,
|
|
uint8_t irqPriority,
|
|
uint32_t rxBufferLength,
|
|
uint32_t rxSnifferLength
|
|
);
|
|
|
|
void SerialPort_IrqProcessing_UartLin(tSerialPortLinArtery *env);
|
|
tSerialPortLinIO vSerialPorLinGetIo(tSerialPortLinArtery *env);
|
|
|
|
void LIN_CheckTimeout(tSerialPortLinArtery *env);
|
|
|
|
#endif //SERIALPORT_SERIALPORTLIN_ARTERY_H
|