288 lines
12 KiB
C
288 lines
12 KiB
C
//
|
|
// Created by cfif on 05.05.23.
|
|
//
|
|
#include "SerialLinPorts.h"
|
|
#include "at32f435_437.h"
|
|
|
|
tSerialLinPorts SERIAL_LIN_PORTS;
|
|
|
|
|
|
//начало--------------------------------- Настройка порта LIN1 ---------------------------------------------------------
|
|
//начало--------------------------------- Настройка порта LIN1 ---------------------------------------------------------
|
|
//начало--------------------------------- Настройка порта LIN1 ---------------------------------------------------------
|
|
void UART4_IRQHandler(void) {
|
|
SerialPort_IrqProcessing_UartLin(&SERIAL_LIN_PORTS.LIN1_UART4);
|
|
}
|
|
|
|
static void vSerialPort_InitUSART4(tSerialPortLinArtery *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
|
|
);
|
|
}
|
|
//конец--------------------------------- Настройка порта LIN1 ----------------------------------------------------------
|
|
//конец--------------------------------- Настройка порта LIN1 ----------------------------------------------------------
|
|
//конец--------------------------------- Настройка порта LIN1 ----------------------------------------------------------
|
|
|
|
|
|
//начало--------------------------------- Настройка порта LIN2 ---------------------------------------------------------
|
|
//начало--------------------------------- Настройка порта LIN2 ---------------------------------------------------------
|
|
//начало--------------------------------- Настройка порта LIN2 ---------------------------------------------------------
|
|
void UART5_IRQHandler(void) {
|
|
SerialPort_IrqProcessing_UartLin(&SERIAL_LIN_PORTS.LIN2_UART5);
|
|
}
|
|
|
|
static void vSerialPort_InitUART5(tSerialPortLinArtery *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_11;
|
|
GPIO_InitStruct.gpio_pull = GPIO_PULL_NONE;
|
|
gpio_init(GPIOE, &GPIO_InitStruct);
|
|
|
|
GPIO_InitStruct.gpio_pins = GPIO_PINS_10;
|
|
gpio_init(GPIOE, &GPIO_InitStruct);
|
|
|
|
gpio_pin_mux_config(GPIOE, GPIO_PINS_SOURCE11, GPIO_MUX_8);
|
|
gpio_pin_mux_config(GPIOE, GPIO_PINS_SOURCE10, GPIO_MUX_8);
|
|
|
|
vSerialPortLinInit(
|
|
env,
|
|
UART5,
|
|
false,
|
|
9600,
|
|
UART5_IRQn,
|
|
CRM_UART5_PERIPH_CLOCK,
|
|
0xFF,
|
|
16,
|
|
0
|
|
);
|
|
}
|
|
//конец--------------------------------- Настройка порта LIN2 ----------------------------------------------------------
|
|
//конец--------------------------------- Настройка порта LIN2 ----------------------------------------------------------
|
|
//конец--------------------------------- Настройка порта LIN2 ----------------------------------------------------------
|
|
|
|
|
|
|
|
//начало--------------------------------- Настройка порта LIN3 ---------------------------------------------------------
|
|
//начало--------------------------------- Настройка порта LIN3 ---------------------------------------------------------
|
|
//начало--------------------------------- Настройка порта LIN3 ---------------------------------------------------------
|
|
void USART6_IRQHandler(void) {
|
|
SerialPort_IrqProcessing_UartLin(&SERIAL_LIN_PORTS.LIN3_USART6);
|
|
}
|
|
|
|
static void vSerialPort_InitUSART6(tSerialPortLinArtery *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_7;
|
|
GPIO_InitStruct.gpio_pull = GPIO_PULL_NONE;
|
|
gpio_init(GPIOC, &GPIO_InitStruct);
|
|
|
|
GPIO_InitStruct.gpio_pins = GPIO_PINS_4;
|
|
gpio_init(GPIOA, &GPIO_InitStruct);
|
|
|
|
gpio_pin_mux_config(GPIOC, GPIO_PINS_SOURCE7, GPIO_MUX_8);
|
|
gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE4, GPIO_MUX_8);
|
|
|
|
vSerialPortLinInit(
|
|
env,
|
|
USART6,
|
|
false,
|
|
9600,
|
|
USART6_IRQn,
|
|
CRM_USART6_PERIPH_CLOCK,
|
|
0xFF,
|
|
16,
|
|
0
|
|
);
|
|
}
|
|
//конец--------------------------------- Настройка порта LIN3 ----------------------------------------------------------
|
|
//конец--------------------------------- Настройка порта LIN3 ----------------------------------------------------------
|
|
//конец--------------------------------- Настройка порта LIN3 ----------------------------------------------------------
|
|
|
|
|
|
//начало--------------------------------- Настройка порта LIN4 ---------------------------------------------------------
|
|
//начало--------------------------------- Настройка порта LIN4 ---------------------------------------------------------
|
|
//начало--------------------------------- Настройка порта LIN4 ---------------------------------------------------------
|
|
void UART7_IRQHandler(void) {
|
|
SerialPort_IrqProcessing_UartLin(&SERIAL_LIN_PORTS.LIN4_UART7);
|
|
}
|
|
|
|
static void vSerialPort_InitUART7(tSerialPortLinArtery *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_6;
|
|
GPIO_InitStruct.gpio_pull = GPIO_PULL_NONE;
|
|
gpio_init(GPIOF, &GPIO_InitStruct);
|
|
|
|
GPIO_InitStruct.gpio_pins = GPIO_PINS_7;
|
|
gpio_init(GPIOF, &GPIO_InitStruct);
|
|
|
|
gpio_pin_mux_config(GPIOF, GPIO_PINS_SOURCE6, GPIO_MUX_8);
|
|
gpio_pin_mux_config(GPIOF, GPIO_PINS_SOURCE7, GPIO_MUX_8);
|
|
|
|
vSerialPortLinInit(
|
|
env,
|
|
UART7,
|
|
false,
|
|
9600,
|
|
UART7_IRQn,
|
|
CRM_UART7_PERIPH_CLOCK,
|
|
0xFF,
|
|
16,
|
|
0
|
|
);
|
|
}
|
|
//конец--------------------------------- Настройка порта LIN4 ----------------------------------------------------------
|
|
//конец--------------------------------- Настройка порта LIN4 ----------------------------------------------------------
|
|
//конец--------------------------------- Настройка порта LIN4 ----------------------------------------------------------
|
|
|
|
|
|
//начало--------------------------------- Настройка порта LIN5 ---------------------------------------------------------
|
|
//начало--------------------------------- Настройка порта LIN5 ---------------------------------------------------------
|
|
//начало--------------------------------- Настройка порта LIN5 ---------------------------------------------------------
|
|
void UART8_IRQHandler(void) {
|
|
SerialPort_IrqProcessing_UartLin(&SERIAL_LIN_PORTS.LIN5_UART8);
|
|
}
|
|
|
|
static void vSerialPort_InitUART8(tSerialPortLinArtery *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_3;
|
|
GPIO_InitStruct.gpio_pull = GPIO_PULL_NONE;
|
|
gpio_init(GPIOC, &GPIO_InitStruct);
|
|
|
|
GPIO_InitStruct.gpio_pins = GPIO_PINS_2;
|
|
gpio_init(GPIOC, &GPIO_InitStruct);
|
|
|
|
gpio_pin_mux_config(GPIOC, GPIO_PINS_SOURCE3, GPIO_MUX_8);
|
|
gpio_pin_mux_config(GPIOC, GPIO_PINS_SOURCE2, GPIO_MUX_8);
|
|
|
|
vSerialPortLinInit(
|
|
env,
|
|
UART8,
|
|
false,
|
|
9600,
|
|
UART8_IRQn,
|
|
CRM_UART8_PERIPH_CLOCK,
|
|
0xFF,
|
|
16,
|
|
0
|
|
);
|
|
}
|
|
//конец--------------------------------- Настройка порта LIN5 ----------------------------------------------------------
|
|
//конец--------------------------------- Настройка порта LIN5 ----------------------------------------------------------
|
|
//конец--------------------------------- Настройка порта LIN5 ----------------------------------------------------------
|
|
|
|
//начало--------------------------------- Настройка порта LIN6 ---------------------------------------------------------
|
|
//начало--------------------------------- Настройка порта LIN6 ---------------------------------------------------------
|
|
//начало--------------------------------- Настройка порта LIN6 ---------------------------------------------------------
|
|
void USART1_IRQHandler(void) {
|
|
SerialPort_IrqProcessing_UartLin(&SERIAL_LIN_PORTS.LIN6_USART1);
|
|
}
|
|
|
|
static void vSerialPort_InitUSART1(tSerialPortLinArtery *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_3;
|
|
GPIO_InitStruct.gpio_pull = GPIO_PULL_NONE;
|
|
gpio_init(GPIOB, &GPIO_InitStruct);
|
|
|
|
GPIO_InitStruct.gpio_pins = GPIO_PINS_6;
|
|
gpio_init(GPIOB, &GPIO_InitStruct);
|
|
|
|
gpio_pin_mux_config(GPIOB, GPIO_PINS_SOURCE3, GPIO_MUX_7);
|
|
gpio_pin_mux_config(GPIOB, GPIO_PINS_SOURCE6, GPIO_MUX_7);
|
|
|
|
vSerialPortLinInit(
|
|
env,
|
|
USART1,
|
|
false,
|
|
9600,
|
|
USART1_IRQn,
|
|
CRM_USART1_PERIPH_CLOCK,
|
|
0xFF,
|
|
16,
|
|
0
|
|
);
|
|
}
|
|
//конец--------------------------------- Настройка порта LIN6 ----------------------------------------------------------
|
|
//конец--------------------------------- Настройка порта LIN6 ----------------------------------------------------------
|
|
//конец--------------------------------- Настройка порта LIN6 ----------------------------------------------------------
|
|
|
|
void SerialLinPorts_Init() {
|
|
tSerialLinPorts *env = &SERIAL_LIN_PORTS;
|
|
|
|
// LIN1 (LIN5)
|
|
vSerialPort_InitUSART4(&env->LIN1_UART4);
|
|
SERIAL_LIN_PORTS.LIN1_UART4_IO = vSerialPorLinGetIo(&SERIAL_LIN_PORTS.LIN1_UART4);
|
|
|
|
// LIN2
|
|
vSerialPort_InitUART5(&env->LIN2_UART5);
|
|
SERIAL_LIN_PORTS.LIN2_UART5_IO = vSerialPorLinGetIo(&SERIAL_LIN_PORTS.LIN2_UART5);
|
|
|
|
// LIN3
|
|
vSerialPort_InitUSART6(&env->LIN3_USART6);
|
|
SERIAL_LIN_PORTS.LIN3_USART6_IO = vSerialPorLinGetIo(&SERIAL_LIN_PORTS.LIN3_USART6);
|
|
|
|
// LIN4
|
|
vSerialPort_InitUART7(&env->LIN4_UART7);
|
|
SERIAL_LIN_PORTS.LIN4_UART7_IO = vSerialPorLinGetIo(&SERIAL_LIN_PORTS.LIN4_UART7);
|
|
|
|
// LIN5
|
|
vSerialPort_InitUART8(&env->LIN5_UART8);
|
|
SERIAL_LIN_PORTS.LIN5_UART8_IO = vSerialPorLinGetIo(&SERIAL_LIN_PORTS.LIN5_UART8);
|
|
|
|
// LIN6
|
|
vSerialPort_InitUSART1(&env->LIN6_USART1);
|
|
SERIAL_LIN_PORTS.LIN6_USART1_IO = vSerialPorLinGetIo(&SERIAL_LIN_PORTS.LIN6_USART1);
|
|
}
|