From c25a8098afa3f9444aa61ad10f24fdcb8d9bc4fe Mon Sep 17 00:00:00 2001 From: cfif Date: Mon, 18 May 2026 17:40:41 +0300 Subject: [PATCH] Init --- Inc/LinIO.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++ modular.json | 7 ++++++ 2 files changed, 68 insertions(+) create mode 100644 Inc/LinIO.h create mode 100644 modular.json diff --git a/Inc/LinIO.h b/Inc/LinIO.h new file mode 100644 index 0000000..1ede795 --- /dev/null +++ b/Inc/LinIO.h @@ -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 diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..9bdd478 --- /dev/null +++ b/modular.json @@ -0,0 +1,7 @@ +{ + "cmake": { + "inc_dirs": [ + "Inc" + ] + } +} \ No newline at end of file