From 9d49933faf72a58ff5542feaa199f82cec434420 Mon Sep 17 00:00:00 2001 From: cfif Date: Fri, 17 Oct 2025 13:26:07 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lins.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Lins.h | 19 ++++++++++++++ modular.json | 13 ++++++++++ 3 files changed, 102 insertions(+) create mode 100644 Lins.c create mode 100644 Lins.h create mode 100644 modular.json diff --git a/Lins.c b/Lins.c new file mode 100644 index 0000000..8b29b79 --- /dev/null +++ b/Lins.c @@ -0,0 +1,70 @@ +// +// Created by Cfif on 14.12.23. +// +#include +#include "fc7xxx_driver_port.h" +#include "fc7xxx_driver_gpio.h" +#include "Lins.h" + +tLins LINS; + +void LinCallbackHandler(uint8_t u8LinIndex, void *state) { + GetLinCallbackHandler(&LINS.lin, u8LinIndex, state); +} + +void FCUART4_RxTx_IRQHandler(void) { + LIN_DrvIRQHandler(LINS.lin.UART_INDEX); +} + +void Lins_Init() { + tLins *env = &LINS; + + PORT_InitType tInitStruct = {0}; + GPIO_InitType tGpioInitStruct = {0}; + + /* Port D12: MUX = ALT3, UART4_RX */ + tInitStruct.u32PortPins = PORT_PIN_12; + tInitStruct.uPortPinMux.u32PortPinMode = PORTD_12_FCUART4_RX; + tInitStruct.bPullEn = true; + tInitStruct.ePullSel = PORT_PULL_UP; + PORT_InitPins(PORT_D, &tInitStruct); + + tGpioInitStruct.u32GpioPins = GPIO_PIN_12; + tGpioInitStruct.ePinDirection = GPIO_IN; + GPIO_InitPins(GPIO_D, &tGpioInitStruct); + + /* Port D5: MUX = ALT3, UART4_TX */ + tInitStruct.u32PortPins = PORT_PIN_5; + tInitStruct.uPortPinMux.u32PortPinMode = PORTD_5_FCUART4_TX; + PORT_InitPins(PORT_D, &tInitStruct); + + tGpioInitStruct.u32GpioPins = GPIO_PIN_5; + tGpioInitStruct.ePinDirection = GPIO_OUT; + tGpioInitStruct.ePinLevel = GPIO_HIGH; + GPIO_InitPins(GPIO_D, &tGpioInitStruct); + + /* Port D18: MUX = GPIO output */ + //tInitStruct.u32PortPins = PORT_PIN_18; + //tInitStruct.uPortPinMux.u32PortPinMode = PORT_GPIO_MODE; + //PORT_InitPins(PORT_D, &tInitStruct); + + //tGpioInitStruct.u32GpioPins = GPIO_PIN_18; + //tGpioInitStruct.ePinDirection = GPIO_OUT; + //tGpioInitStruct.ePinLevel = GPIO_HIGH; + //GPIO_InitPins(GPIO_D, &tGpioInitStruct); + + LIN_Initial( + &env->lin, + FCUART4, + 19200, + + 4, // UART0 = 0 ... UART7 = 7 + FCUART4_IRQn, // FCUART0_IRQn ... FCUART7_IRQn + 0xFF, + + NULL, + LinCallbackHandler + ); + + env->linIo = vLinGetIo(&env->lin); +} diff --git a/Lins.h b/Lins.h new file mode 100644 index 0000000..7fde53c --- /dev/null +++ b/Lins.h @@ -0,0 +1,19 @@ +// +// Created by ilya on 14.12.23. +// + +#ifndef FLAG_LINS_H +#define FLAG_LINS_H + +#include "LinFlagchip.h" + +typedef struct { + tLinFlagchip lin; + tLinIO linIo; +} tLins; + +extern tLins LINS; + +void Lins_Init(); + +#endif //FLAG_LINS_H diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..9589ff8 --- /dev/null +++ b/modular.json @@ -0,0 +1,13 @@ +{ + "dep": [ + + ], + "cmake": { + "inc_dirs": [ + "./" + ], + "srcs": [ + "./**.c" + ] + } +} \ No newline at end of file