Обновление
This commit is contained in:
commit
a715877959
|
|
@ -0,0 +1,140 @@
|
|||
//
|
||||
// Created by CFIF on 25.03.24.
|
||||
//
|
||||
#include "SerialPorts.h"
|
||||
|
||||
tSerialPorts SERIAL_PORTS;
|
||||
|
||||
|
||||
uint8_t buf_USART2_TRANSMITTED[256];
|
||||
ALIGN(256) uint8_t buf_USART2_DMA[128];
|
||||
|
||||
|
||||
static void DMA_USART2_TransferCompleteCallbackTx() {
|
||||
SerialPort_TxEndTransmitted(SERIAL_PORTS.SerialPortLog_IO.env, 1);
|
||||
asm("nop");
|
||||
}
|
||||
|
||||
static void DMA_USART2_TransferCompleteCallbackRx() {
|
||||
SerialPort_RxDmaBufToQueue(SERIAL_PORTS.SerialPortLog_IO.env, true,buf_USART2_DMA);
|
||||
}
|
||||
|
||||
static void FCUART_IldeInterrupt_CallBack(uint8_t u8UartIndex) {
|
||||
SerialPort_RxDmaBufToQueue(SERIAL_PORTS.SerialPortLog_IO.env, false,buf_USART2_DMA);
|
||||
PROCESS_UNUSED_VAR(u8UartIndex)
|
||||
}
|
||||
|
||||
static void FCUART_ErrorInterrupt_CallBack(uint8_t u8UartIndex, uint32_t u32Error) {
|
||||
asm("nop");
|
||||
PROCESS_UNUSED_VAR(u8UartIndex)
|
||||
PROCESS_UNUSED_VAR(u32Error)
|
||||
}
|
||||
|
||||
static void FCUART_TxEmptyInterrupt_CallBack(uint8_t u8UartIndex, FCUART_DataType *pTxData) {
|
||||
asm("nop");
|
||||
PROCESS_UNUSED_VAR(u8UartIndex)
|
||||
PROCESS_UNUSED_VAR(pTxData)
|
||||
}
|
||||
|
||||
static void FCUART_TxCompleteInterrupt_CallBack(uint8_t u8UartIndex, FCUART_DataType *pTxData) {
|
||||
|
||||
if (u8UartIndex == SERIAL_PORTS.SerialPortLog.UART_INDEX) {
|
||||
SerialPort_TxEndTransmitted(SERIAL_PORTS.SerialPortLog_IO.env, 1);
|
||||
}
|
||||
|
||||
PROCESS_UNUSED_VAR(pTxData)
|
||||
}
|
||||
|
||||
void FCUART2_RxTx_IRQHandler(void) {
|
||||
FCUARTN_RxTx_IRQHandler(SERIAL_PORTS.SerialPortLog.UART_INDEX);
|
||||
}
|
||||
|
||||
// Настройка порта
|
||||
static void vSerialPort_InitUSART2(tSerialPortFlagchip *env) {
|
||||
PORT_InitType tInitStruct = {0};
|
||||
GPIO_InitType tGpioInitStruct = {0};
|
||||
|
||||
// Port D6: MUX = ALT2, UART2_RX
|
||||
tInitStruct.u32PortPins = PORT_PIN_6;
|
||||
tInitStruct.uPortPinMux.u32PortPinMode = PORTD_6_FCUART2_RX;
|
||||
PORT_InitPins(PORT_D, &tInitStruct);
|
||||
|
||||
tGpioInitStruct.u32GpioPins = GPIO_PIN_6;
|
||||
tGpioInitStruct.ePinDirection = GPIO_IN;
|
||||
GPIO_InitPins(GPIO_D, &tGpioInitStruct);
|
||||
|
||||
// Port D7: MUX = ALT2, UART2_TX
|
||||
tInitStruct.u32PortPins = PORT_PIN_7;
|
||||
tInitStruct.uPortPinMux.u32PortPinMode = PORTD_7_FCUART2_TX;
|
||||
PORT_InitPins(PORT_D, &tInitStruct);
|
||||
|
||||
tGpioInitStruct.u32GpioPins = GPIO_PIN_7;
|
||||
tGpioInitStruct.ePinDirection = GPIO_OUT;
|
||||
tGpioInitStruct.ePinLevel = GPIO_HIGH;
|
||||
GPIO_InitPins(GPIO_D, &tGpioInitStruct);
|
||||
|
||||
vSerialPortInitDMA(
|
||||
env,
|
||||
|
||||
FCUART2,
|
||||
921600,//115200,
|
||||
|
||||
2, // UART0 = 0 ... UART7 = 7
|
||||
FCUART2_IRQn, // FCUART0_IRQn ... FCUART7_IRQn
|
||||
0xFF,
|
||||
|
||||
buf_USART2_TRANSMITTED,
|
||||
sizeof(buf_USART2_TRANSMITTED),
|
||||
|
||||
DMA_CHANNEL_5,
|
||||
DMA_REQ_FCUART2_RX,
|
||||
buf_USART2_DMA,
|
||||
sizeof(buf_USART2_DMA),
|
||||
DMA5_IRQn,
|
||||
0xFF, // IRQ_DMA_PRIORITY
|
||||
DMA5_IRQn, // IRQ_DMA_CHANNEL_PRIORITY
|
||||
|
||||
DMA_CHANNEL_6,
|
||||
DMA_REQ_FCUART2_TX,
|
||||
buf_USART2_DMA,
|
||||
sizeof(buf_USART2_DMA),
|
||||
DMA6_IRQn,
|
||||
0xFF, // IRQ_DMA_PRIORITY
|
||||
DMA6_IRQn, // IRQ_DMA_CHANNEL_PRIORITY
|
||||
|
||||
|
||||
1024,
|
||||
0,
|
||||
|
||||
DMA_USART2_TransferCompleteCallbackRx,
|
||||
NULL,
|
||||
|
||||
DMA_USART2_TransferCompleteCallbackTx,
|
||||
NULL,
|
||||
|
||||
|
||||
FCUART_IldeInterrupt_CallBack,
|
||||
FCUART_ErrorInterrupt_CallBack,
|
||||
|
||||
FCUART_TxEmptyInterrupt_CallBack,
|
||||
FCUART_TxCompleteInterrupt_CallBack
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SerialPorts_Init() {
|
||||
tSerialPorts *env = &SERIAL_PORTS;
|
||||
|
||||
//// Виртуальный сериал порт
|
||||
SerialPortVirt_Init(&env->cliVirtualPortOut, 4096);
|
||||
env->cliVirtualPortOut_Io = SerialPortVirt_GetIo(&env->cliVirtualPortOut);
|
||||
|
||||
vSerialPort_InitUSART2(&env->SerialPortLog);
|
||||
SERIAL_PORTS.SerialPortLog_IO = vSerialPortGetIo(&env->SerialPortLog);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// Created by CFIF on 25.03.24.
|
||||
//
|
||||
|
||||
#ifndef HVAC_M7_SERIALPORTS_H
|
||||
#define HVAC_M7_SERIALPORTS_H
|
||||
|
||||
#include "SerialPortFlagchip.h"
|
||||
#include "SerialPortVirt.h"
|
||||
|
||||
typedef struct {
|
||||
tSerialPortFlagchip SerialPortLog;
|
||||
tSerialPortIO SerialPortLog_IO;
|
||||
|
||||
tSerialPortVirt cliVirtualPortOut;
|
||||
tSerialPortIO cliVirtualPortOut_Io;
|
||||
|
||||
} tSerialPorts;
|
||||
|
||||
extern tSerialPorts SERIAL_PORTS;
|
||||
|
||||
void SerialPorts_Init();
|
||||
|
||||
#endif //HVAC_M7_SERIALPORTS_H
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"cmake": {
|
||||
"inc_dirs": [
|
||||
"./"
|
||||
],
|
||||
"srcs": [
|
||||
"./**.c"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue