From 7aee7e72496d3fcfaf15046130daece64d51dfae Mon Sep 17 00:00:00 2001 From: cfif Date: Tue, 19 May 2026 16:47:01 +0300 Subject: [PATCH] Init --- SerialLinPorts.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ SerialLinPorts.h | 37 ++++++++++++++++++++++++++++++++ modular.json | 10 +++++++++ 3 files changed, 102 insertions(+) create mode 100644 SerialLinPorts.c create mode 100644 SerialLinPorts.h create mode 100644 modular.json diff --git a/SerialLinPorts.c b/SerialLinPorts.c new file mode 100644 index 0000000..1fca2e8 --- /dev/null +++ b/SerialLinPorts.c @@ -0,0 +1,55 @@ +// +// Created by cfif on 05.05.23. +// +#include "SerialLinPorts.h" +#include "at32f435_437.h" + +tSerialLinPorts SERIAL_LIN_PORTS; + +/* +void UART4_IRQHandler(void) { + SerialPort_IrqProcessing_UartLin(&SERIAL_PORTS.LIN1_UART4); +} + +// Настройка порта +static void vSerialPort_InitUSART4(tSerialPortArtery *env) { + + gpio_init_type GPIO_InitStruct; + gpio_default_para_init(&GPIO_InitStruct); + + GPIO_InitStruct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER; + GPIO_InitStruct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL; + GPIO_InitStruct.gpio_mode = GPIO_MODE_MUX; + GPIO_InitStruct.gpio_pins = GPIO_PINS_1; + GPIO_InitStruct.gpio_pull = GPIO_PULL_NONE; + gpio_init(GPIOA, &GPIO_InitStruct); + + GPIO_InitStruct.gpio_pins = GPIO_PINS_0; + gpio_init(GPIOA, &GPIO_InitStruct); + + gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE1, GPIO_MUX_8); + gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE0, GPIO_MUX_8); + + vSerialPortLinInit( + env, + UART4, + false, + 9600, + UART4_IRQn, + CRM_UART4_PERIPH_CLOCK, + 0xFF, + 16, + 0 + ); +} + + +void SerialLinPorts_Init() { + tSerialLinPorts *env = &SERIAL_LIN_PORTS; + + // LIN5 + vSerialPort_InitUSART4(&env->LIN1_UART4); + SERIAL_LIN_PORTS.LIN1_UART4_IO = vSerialPortGetIo(&SERIAL_LIN_PORTS.LIN1_UART4); + +} + */ \ No newline at end of file diff --git a/SerialLinPorts.h b/SerialLinPorts.h new file mode 100644 index 0000000..c03fae3 --- /dev/null +++ b/SerialLinPorts.h @@ -0,0 +1,37 @@ +// +// Created by cfif on 05.05.23. +// + +#ifndef WATER_BOX_BSD_SERIALPORTSLIN_H +#define WATER_BOX_BSD_SERIALPORTSLIN_H + +#include "SerialPortArtery.h" +#include "GpioPin.h" + +typedef struct { +/* + tSerialPortArtery LIN1_UART4; + tSerialPortIO LIN1_UART4_IO; + + tSerialPortArtery LIN2_UART5; + tSerialPortIO LIN2_UART5_IO; + + tSerialPortArtery LIN3_USART6; + tSerialPortIO LIN3_USART6_IO; + + tSerialPortArtery LIN4_UART7; + tSerialPortIO LIN4_UART7_IO; + + tSerialPortArtery LIN5_UART8; + tSerialPortIO LIN5_UART8_IO; + + tSerialPortArtery LIN6_USART1; + tSerialPortIO LIN6_USART1_IO; +*/ + + +} tSerialLinPorts; + +extern tSerialLinPorts SERIAL_LIN_PORTS; + +#endif //WATER_BOX_BSD_SERIALPORTSLIN_H diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..0dd1901 --- /dev/null +++ b/modular.json @@ -0,0 +1,10 @@ +{ + "cmake": { + "inc_dirs": [ + "./" + ], + "srcs": [ + "./**.c" + ] + } +} \ No newline at end of file