55 lines
1.3 KiB
C
55 lines
1.3 KiB
C
//
|
|
// 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);
|
|
|
|
}
|
|
*/ |