Init
This commit is contained in:
parent
c0487d7b56
commit
a970c76789
|
|
@ -56,6 +56,69 @@ static void vSerialPort_InitUSART3(tSerialPortArtery *env) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t buf_USART2_DMA[100];
|
||||||
|
|
||||||
|
|
||||||
|
// IDLE прерывание
|
||||||
|
void USART2_IRQHandler() {
|
||||||
|
SerialPort_IrqProcessing_UartIdle(&SERIAL_PORTS.Rs485);
|
||||||
|
}
|
||||||
|
|
||||||
|
// RX
|
||||||
|
void DMA1_Channel6_IRQHandler(void) {
|
||||||
|
SerialPort_IrqProcessing_DmaRxLoop(&SERIAL_PORTS.Rs485);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TX
|
||||||
|
void DMA1_Channel7_IRQHandler(void) {
|
||||||
|
SerialPort_IrqProcessing_DmaTx(&SERIAL_PORTS.Rs485);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Настройка порта PRO04
|
||||||
|
static void vSerialPort_InitUSART2(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_2 | GPIO_PINS_3;
|
||||||
|
GPIO_InitStruct.gpio_pull = GPIO_PULL_NONE;
|
||||||
|
gpio_init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE2, GPIO_MUX_7);
|
||||||
|
gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE3, GPIO_MUX_7);
|
||||||
|
|
||||||
|
vSerialPortInitDmaWithNameAndSniffer(
|
||||||
|
env, USART2, 115200,
|
||||||
|
1, 6, 1, 7,
|
||||||
|
false, 0xFF,
|
||||||
|
buf_USART2_DMA, sizeof(buf_USART2_DMA),
|
||||||
|
1024, 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
uint8_t buf_USART3_DMA[256];
|
uint8_t buf_USART3_DMA[256];
|
||||||
|
|
||||||
|
|
@ -537,6 +600,16 @@ void SerialPorts_Init(tRs485DirectionPins *directionPins) {
|
||||||
vSerialPort_InitUSART3(&env->DEBUG_USART3);
|
vSerialPort_InitUSART3(&env->DEBUG_USART3);
|
||||||
SERIAL_PORTS.DEBUG_USART3_IO = vSerialPortGetIo(&SERIAL_PORTS.DEBUG_USART3);
|
SERIAL_PORTS.DEBUG_USART3_IO = vSerialPortGetIo(&SERIAL_PORTS.DEBUG_USART3);
|
||||||
|
|
||||||
|
|
||||||
|
vSerialPort_InitUSART2(&env->Rs485);
|
||||||
|
SERIAL_PORTS.Rs485_IO = vSerialPortGetIo(&SERIAL_PORTS.Rs485);
|
||||||
|
SERIAL_PORTS.Rs485_HalfDuplex = vSerialPortHalfDuplexInit(&SERIAL_PORTS.Rs485_IO,
|
||||||
|
&directionPins->transmit,
|
||||||
|
&directionPins->receive);
|
||||||
|
SERIAL_PORTS.Rs485_HalfDuplexIo = vSerialPortHalfDuplexGetIo(&SERIAL_PORTS.Rs485_HalfDuplex);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SerialPortVirt_Init(&env->cliVirtualPortOut, 4096);
|
SerialPortVirt_Init(&env->cliVirtualPortOut, 4096);
|
||||||
env->cliVirtualPortOut_Io = SerialPortVirt_GetIo(&env->cliVirtualPortOut);
|
env->cliVirtualPortOut_Io = SerialPortVirt_GetIo(&env->cliVirtualPortOut);
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,8 @@
|
||||||
#include "SerialPortVirt.h"
|
#include "SerialPortVirt.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
tGpioPin de;
|
tGpioPin receive;
|
||||||
|
tGpioPin transmit;
|
||||||
} tRs485DirectionPins;
|
} tRs485DirectionPins;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
@ -29,7 +30,13 @@ typedef struct {
|
||||||
tSerialPortIO DEBUG_USART3_IO;
|
tSerialPortIO DEBUG_USART3_IO;
|
||||||
|
|
||||||
|
|
||||||
|
tSerialPortArtery Rs485;
|
||||||
|
tSerialPortIO Rs485_IO;
|
||||||
|
tSerialPortHalfDuplex Rs485_HalfDuplex;
|
||||||
|
tSerialPortIO Rs485_HalfDuplexIo;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
*
|
||||||
tSerialPortArtery PRO04;
|
tSerialPortArtery PRO04;
|
||||||
tSerialPortIO PRO04IO;
|
tSerialPortIO PRO04IO;
|
||||||
tSerialPortIO PRO04_snif_IO;
|
tSerialPortIO PRO04_snif_IO;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue