This commit is contained in:
cfif 2026-05-18 17:40:41 +03:00
commit c25a8098af
2 changed files with 68 additions and 0 deletions

61
Inc/LinIO.h Normal file
View File

@ -0,0 +1,61 @@
//
// Created by cfif on 17.11.22.
//
#ifndef MODULE_LINIO_H
#define MODULE_LINIO_H
#include "stdint.h"
#include "cmsis_os2.h"
typedef enum
{
LIN_NO_EVENT = 0x00U, /*!< No event occurred. */
LIN_WAKEUP_SIGNAL, /*!< Wakeup signal */
LIN_BAUDRATE_ADJUSTED, /*!< Baudrate was adjusted in slave autobaud mode. */
LIN_RECV_BREAK_FIELD_OK, /*!< Break Field was received */
LIN_SYNC_OK, /*!< Sync field is correct */
LIN_SYNC_ERROR, /*!< Sync field is incorrect */
LIN_PID_OK, /*!< PID receive correct */
LIN_PID_ERROR, /*!< PID receive incorrect */
LIN_FRAME_ERROR, /*!< Frame receive error */
LIN_READBACK_ERROR, /*!< Readback words are incorrect */
LIN_CHECKSUM_ERROR, /*!< Checksum byte error */
LIN_TX_COMPLETED, /*!< TX data completed */
LIN_RX_COMPLETED, /*!< rx data completed */
LIN_RX_OVERRUN, /*!< RX overflow occurred */
LIN_TIMEOUT, /*!< RX overflow occurred */
} lin_event_id_t;
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 enum {
LIN_DIRECTION_GET = 0,
LIN_DIRECTION_SET = 1
} eDirection;
typedef struct {
osMessageQueueId_t rxDataQueue;
eDirection direction;
uint8_t g_aTxBufferLen;
uint8_t g_aTxBuffer[8];
uint8_t g_aRxBufferLen;
uint8_t g_aRxBuffer[8];
} tLinData;
typedef uint8_t (* LinIOTransaction )(void *env, uint32_t timeout);
typedef struct {
void *env;
LinIOTransaction runCommand;
LinIOTransaction getCommand;
} tLinIO;
#endif //MODULE_LINIO_H

7
modular.json Normal file
View File

@ -0,0 +1,7 @@
{
"cmake": {
"inc_dirs": [
"Inc"
]
}
}