2025-02-26 09:59:15 +00:00
|
|
|
|
#include "HD_UART.h"
|
|
|
|
|
|
|
|
|
|
void USART2_IRQHandler(void) __attribute__((interrupt()));
|
|
|
|
|
void USART3_IRQHandler(void) __attribute__((interrupt()));
|
|
|
|
|
#ifdef uart4_enable
|
|
|
|
|
// void UART4_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
|
|
|
|
void UART4_IRQHandler(void) __attribute__((interrupt()));
|
|
|
|
|
#endif
|
|
|
|
|
void UART5_IRQHandler(void) __attribute__((interrupt()));
|
|
|
|
|
void UART6_IRQHandler(void) __attribute__((interrupt()));
|
|
|
|
|
void UART7_IRQHandler(void) __attribute__((interrupt()));
|
|
|
|
|
void UART8_IRQHandler(void) __attribute__((interrupt()));
|
|
|
|
|
|
|
|
|
|
#define write Bit_SET
|
|
|
|
|
#define read Bit_RESET
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>UART6<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>J1_485,Ĭ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param baud <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void J1_485_Init(uint32_t baud)
|
|
|
|
|
{
|
|
|
|
|
/* <20><>ʼ<EFBFBD><CABC>DE<44><45><EFBFBD><EFBFBD> */
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J1_DE_PIN;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_Init(J1_DE_PROT, &GPIO_InitStructure);
|
|
|
|
|
readJ1_485;
|
|
|
|
|
|
|
|
|
|
USART_InitTypeDef USART_InitStructure;
|
|
|
|
|
NVIC_InitTypeDef NVIC_InitStructure;
|
|
|
|
|
|
|
|
|
|
/* UART6 TX --> PC0 RX --> PC1 */
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
|
|
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART6, ENABLE);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //<2F><><EFBFBD><EFBFBD>PC0Ϊ<30><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //<2F><><EFBFBD><EFBFBD>PC1Ϊ<31><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
USART_InitStructure.USART_BaudRate = baud;
|
|
|
|
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
|
|
|
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
|
|
|
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
|
|
|
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
|
|
|
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
|
|
|
|
USART_Init(UART6, &USART_InitStructure);
|
|
|
|
|
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannel = UART6_IRQn;
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3; //<2F><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD>Ϊ3
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //<2F><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>Ϊ3
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨ<51><CDA8>ʹ<EFBFBD><CAB9>
|
|
|
|
|
NVIC_Init(&NVIC_InitStructure); //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
|
|
|
|
USART_ITConfig(UART6, USART_IT_RXNE, ENABLE);
|
2025-02-28 08:57:09 +00:00
|
|
|
|
USART_ITConfig(UART6, USART_IT_IDLE, ENABLE);
|
2025-02-26 09:59:15 +00:00
|
|
|
|
|
|
|
|
|
USART_Cmd(UART6,ENABLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>UART7<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>J2_485,Ĭ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>ر<EFBFBD>״̬
|
|
|
|
|
* @param baud <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void J2_485_Init(uint32_t baud)
|
|
|
|
|
{
|
|
|
|
|
/* <20><>ʼ<EFBFBD><CABC>DE<44><45><EFBFBD><EFBFBD> */
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE, ENABLE);
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J2_DE_PIN;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_Init(J2_DE_PROT, &GPIO_InitStructure);
|
|
|
|
|
readJ2_485;
|
|
|
|
|
|
|
|
|
|
USART_InitTypeDef USART_InitStructure;
|
|
|
|
|
NVIC_InitTypeDef NVIC_InitStructure;
|
|
|
|
|
|
|
|
|
|
/* UART7 TX --> PC2 RX --> PC3 */
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
|
|
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART7, ENABLE);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //<2F><><EFBFBD><EFBFBD>PC2Ϊ<32><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //<2F><><EFBFBD><EFBFBD>PC3Ϊ<33><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
USART_InitStructure.USART_BaudRate = baud;
|
|
|
|
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
|
|
|
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
|
|
|
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
|
|
|
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
|
|
|
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
|
|
|
|
USART_Init(UART7, &USART_InitStructure);
|
|
|
|
|
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannel = UART7_IRQn;
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3; //<2F><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD>Ϊ3
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //<2F><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>Ϊ3
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨ<51><CDA8>ʹ<EFBFBD><CAB9>
|
|
|
|
|
NVIC_Init(&NVIC_InitStructure); //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
|
|
|
|
USART_ITConfig(UART7, USART_IT_RXNE, ENABLE);
|
2025-02-28 08:57:09 +00:00
|
|
|
|
USART_ITConfig(UART7, USART_IT_IDLE, ENABLE);
|
2025-02-26 09:59:15 +00:00
|
|
|
|
|
|
|
|
|
USART_Cmd(UART7,ENABLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>USART2<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>J3_485,Ĭ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>ر<EFBFBD>״̬
|
|
|
|
|
* @param baud <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void J3_485_Init(uint32_t baud)
|
|
|
|
|
{
|
|
|
|
|
/* <20><>ʼ<EFBFBD><CABC>DE<44><45><EFBFBD><EFBFBD> */
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J3_DE_PIN;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_Init(J3_DE_PROT, &GPIO_InitStructure);
|
|
|
|
|
readJ3_485;
|
|
|
|
|
|
|
|
|
|
USART_InitTypeDef USART_InitStructure;
|
|
|
|
|
NVIC_InitTypeDef NVIC_InitStructure;
|
|
|
|
|
|
|
|
|
|
/* USART2 TX --> PA2 RX --> PA3 */
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
|
|
|
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //<2F><><EFBFBD><EFBFBD>PA2Ϊ<32><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //<2F><><EFBFBD><EFBFBD>PA3Ϊ<33><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
USART_InitStructure.USART_BaudRate = baud;
|
|
|
|
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
|
|
|
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
|
|
|
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
|
|
|
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
|
|
|
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
|
|
|
|
USART_Init(USART2, &USART_InitStructure);
|
|
|
|
|
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3; //<2F><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD>Ϊ1
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //<2F><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>Ϊ1
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨ<51><CDA8>ʹ<EFBFBD><CAB9>
|
|
|
|
|
NVIC_Init(&NVIC_InitStructure); //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
|
|
|
|
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
|
2025-02-28 08:57:09 +00:00
|
|
|
|
USART_ITConfig(USART2, USART_IT_IDLE, ENABLE);
|
2025-02-26 09:59:15 +00:00
|
|
|
|
|
|
|
|
|
USART_Cmd(USART2,ENABLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>UART8<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>J4_485,Ĭ<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>ر<EFBFBD>״̬
|
|
|
|
|
* @param baud <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void J4_485_Init(uint32_t baud)
|
|
|
|
|
{
|
|
|
|
|
/* <20><>ʼ<EFBFBD><CABC>DE<44><45><EFBFBD><EFBFBD> */
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J4_DE_PIN;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_Init(J4_DE_PROT, &GPIO_InitStructure);
|
|
|
|
|
readJ4_485;
|
|
|
|
|
|
|
|
|
|
USART_InitTypeDef USART_InitStructure;
|
|
|
|
|
NVIC_InitTypeDef NVIC_InitStructure;
|
|
|
|
|
|
|
|
|
|
/* UART8 TX --> PC4 RX --> PC5 */
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
|
|
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART8, ENABLE);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //<2F><><EFBFBD><EFBFBD>PC4Ϊ<34><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //<2F><><EFBFBD><EFBFBD>PC5Ϊ<35><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
USART_InitStructure.USART_BaudRate = baud;
|
|
|
|
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
|
|
|
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
|
|
|
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
|
|
|
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
|
|
|
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
|
|
|
|
USART_Init(UART8, &USART_InitStructure);
|
|
|
|
|
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannel = UART8_IRQn;
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3; //<2F><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD>Ϊ3
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //<2F><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>Ϊ3
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨ<51><CDA8>ʹ<EFBFBD><CAB9>
|
|
|
|
|
NVIC_Init(&NVIC_InitStructure); //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
|
|
|
|
USART_ITConfig(UART8, USART_IT_RXNE, ENABLE);
|
2025-02-28 08:57:09 +00:00
|
|
|
|
USART_ITConfig(UART8, USART_IT_IDLE, ENABLE);
|
2025-02-26 09:59:15 +00:00
|
|
|
|
|
|
|
|
|
USART_Cmd(UART8,ENABLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>USART3<EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><EFBFBD><EFBFBD>J5-0<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD>485<EFBFBD>ӿ<EFBFBD>,<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD><EFBFBD>Ƶ<EFBFBD>485ΪJ0<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դȫ<EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD>
|
|
|
|
|
* @param baud <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void J5_0_485_Init(uint32_t baud)
|
|
|
|
|
{
|
|
|
|
|
/* <20><>ʼ<EFBFBD><CABC>DE<44><45><EFBFBD><EFBFBD> */
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J5_0_DE_PIN;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
|
2025-03-04 10:04:30 +00:00
|
|
|
|
GPIO_Init(J5_0_DE_PROT, &GPIO_InitStructure);
|
2025-02-26 09:59:15 +00:00
|
|
|
|
readJ5_0_485;
|
2025-03-04 10:04:30 +00:00
|
|
|
|
// writeJ5_0_485;
|
2025-02-26 09:59:15 +00:00
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J5_0_A_PIN;
|
2025-03-04 10:04:30 +00:00
|
|
|
|
GPIO_Init(J5_0_DE_PROT, &GPIO_InitStructure);
|
2025-02-26 09:59:15 +00:00
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J5_0_B_PIN;
|
2025-03-04 10:04:30 +00:00
|
|
|
|
GPIO_Init(J5_0_DE_PROT, &GPIO_InitStructure);
|
2025-02-26 09:59:15 +00:00
|
|
|
|
GPIO_InitStructure.GPIO_Pin = J5_0_C_PIN;
|
2025-03-04 10:04:30 +00:00
|
|
|
|
GPIO_Init(J5_0_DE_PROT, &GPIO_InitStructure);
|
2025-02-26 09:59:15 +00:00
|
|
|
|
USART_CONNET_J0();
|
|
|
|
|
|
|
|
|
|
USART_InitTypeDef USART_InitStructure;
|
|
|
|
|
NVIC_InitTypeDef NVIC_InitStructure;
|
|
|
|
|
|
|
|
|
|
/* USART3 TX --> PB10 RX --> PB11 */
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
|
|
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //<2F><><EFBFBD><EFBFBD>PB10Ϊ<30><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //<2F><><EFBFBD><EFBFBD>PB11Ϊ<31><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
USART_InitStructure.USART_BaudRate = baud;
|
|
|
|
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
|
|
|
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
|
|
|
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
|
|
|
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
|
|
|
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
|
|
|
|
USART_Init(USART3, &USART_InitStructure);
|
|
|
|
|
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1; //<2F><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD>Ϊ1
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>Ϊ1
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨ<51><CDA8>ʹ<EFBFBD><CAB9>
|
|
|
|
|
NVIC_Init(&NVIC_InitStructure); //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
|
|
|
|
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
2025-02-28 08:57:09 +00:00
|
|
|
|
USART_ITConfig(USART3, USART_IT_IDLE, ENABLE);
|
2025-02-26 09:59:15 +00:00
|
|
|
|
// USART_ITConfig(USART3, USART_IT_IDLE, ENABLE);
|
|
|
|
|
|
|
|
|
|
USART_Cmd(USART3,ENABLE);
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* Function Name : USART_CONNET_J0
|
|
|
|
|
* Description : <EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>J0<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>485.
|
|
|
|
|
* Input : None
|
|
|
|
|
* Return : None
|
|
|
|
|
**/
|
|
|
|
|
void USART_CONNET_J0(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_WriteBit(J5_0_A_PROT, J5_0_A_PIN, Bit_RESET);
|
|
|
|
|
GPIO_WriteBit(J5_0_B_PROT, J5_0_B_PIN, Bit_RESET);
|
|
|
|
|
GPIO_WriteBit(J5_0_C_PROT, J5_0_C_PIN, Bit_RESET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Function Name : USART_CONNET_J5
|
|
|
|
|
* Description : <EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>J5<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>485.
|
|
|
|
|
* Input : None
|
|
|
|
|
* Return : None
|
|
|
|
|
**/
|
|
|
|
|
void USART_CONNET_J5(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_WriteBit(J5_0_A_PROT, J5_0_A_PIN, Bit_RESET);
|
|
|
|
|
GPIO_WriteBit(J5_0_B_PROT, J5_0_B_PIN, Bit_RESET);
|
|
|
|
|
GPIO_WriteBit(J5_0_C_PROT, J5_0_C_PIN, Bit_SET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Function Name : USART_CONNET_J6
|
|
|
|
|
* Description : <EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>J6<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>485.
|
|
|
|
|
* Input : None
|
|
|
|
|
* Return : None
|
|
|
|
|
**/
|
|
|
|
|
void USART_CONNET_J6(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_WriteBit(J5_0_A_PROT, J5_0_A_PIN, Bit_RESET);
|
|
|
|
|
GPIO_WriteBit(J5_0_B_PROT, J5_0_B_PIN, Bit_SET);
|
|
|
|
|
GPIO_WriteBit(J5_0_C_PROT, J5_0_C_PIN, Bit_RESET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Function Name : USART_CONNET_J7
|
|
|
|
|
* Description : <EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>J7<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>485.
|
|
|
|
|
* Input : None
|
|
|
|
|
* Return : None
|
|
|
|
|
**/
|
|
|
|
|
void USART_CONNET_J7(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_WriteBit(J5_0_A_PROT, J5_0_A_PIN, Bit_RESET);
|
|
|
|
|
GPIO_WriteBit(J5_0_B_PROT, J5_0_B_PIN, Bit_SET);
|
|
|
|
|
GPIO_WriteBit(J5_0_C_PROT, J5_0_C_PIN, Bit_SET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Function Name : USART_CONNET_J8
|
|
|
|
|
* Description : <EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>J8<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>485.
|
|
|
|
|
* Input : None
|
|
|
|
|
* Return : None
|
|
|
|
|
**/
|
|
|
|
|
void USART_CONNET_J8(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_WriteBit(J5_0_A_PROT, J5_0_A_PIN, Bit_SET);
|
|
|
|
|
GPIO_WriteBit(J5_0_B_PROT, J5_0_B_PIN, Bit_RESET);
|
|
|
|
|
GPIO_WriteBit(J5_0_C_PROT, J5_0_C_PIN, Bit_RESET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Function Name : USART_CONNET_J9
|
|
|
|
|
* Description : <EFBFBD><EFBFBD><EFBFBD>ƴ<EFBFBD><EFBFBD><EFBFBD>3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>J9<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>485.
|
|
|
|
|
* Input : None
|
|
|
|
|
* Return : None
|
|
|
|
|
**/
|
|
|
|
|
void USART_CONNET_J9(void)
|
|
|
|
|
{
|
|
|
|
|
GPIO_WriteBit(J5_0_A_PROT, J5_0_A_PIN, Bit_SET);
|
|
|
|
|
GPIO_WriteBit(J5_0_B_PROT, J5_0_B_PIN, Bit_RESET);
|
|
|
|
|
GPIO_WriteBit(J5_0_C_PROT, J5_0_C_PIN, Bit_SET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef uart4_enable
|
|
|
|
|
/*
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>UART4<EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>LORA<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param baud <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void LORA_UART4_Init(uint32_t baud)
|
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
USART_InitTypeDef USART_InitStructure;
|
|
|
|
|
NVIC_InitTypeDef NVIC_InitStructure;
|
|
|
|
|
|
|
|
|
|
/* UART4 TX --> PC10 RX --> PC11 */
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
|
|
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //<2F><><EFBFBD><EFBFBD>PC10Ϊ<30><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //<2F><><EFBFBD><EFBFBD>PC11Ϊ<31><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
USART_InitStructure.USART_BaudRate = baud;
|
|
|
|
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
|
|
|
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
|
|
|
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
|
|
|
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
|
|
|
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
|
|
|
|
USART_Init(UART4, &USART_InitStructure);
|
|
|
|
|
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannel = UART4_IRQn;
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=3; //<2F><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD>Ϊ3
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //<2F><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>Ϊ3
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨ<51><CDA8>ʹ<EFBFBD><CAB9>
|
|
|
|
|
NVIC_Init(&NVIC_InitStructure); //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
|
|
|
|
USART_ITConfig(UART4, USART_IT_RXNE, ENABLE);
|
|
|
|
|
|
|
|
|
|
USART_Cmd(UART4,ENABLE);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>UART5<EFBFBD><EFBFBD>Ӧ<EFBFBD>Ķ<EFBFBD><EFBFBD>ϴ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param baud <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void Upward_UART5_Init(uint32_t baud)
|
|
|
|
|
{
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
|
|
|
USART_InitTypeDef USART_InitStructure;
|
|
|
|
|
NVIC_InitTypeDef NVIC_InitStructure;
|
|
|
|
|
|
|
|
|
|
/* UART5 TX --> PC12 RX --> PD2 */
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
|
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
|
|
|
|
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_UART5, ENABLE);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
|
|
|
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; //<2F><><EFBFBD><EFBFBD>PC12Ϊ<32><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
|
|
|
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //<2F><><EFBFBD><EFBFBD>PD2Ϊ<32><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
GPIO_Init(GPIOD, &GPIO_InitStructure);
|
|
|
|
|
|
|
|
|
|
USART_InitStructure.USART_BaudRate = baud;
|
|
|
|
|
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
|
|
|
|
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
|
|
|
|
USART_InitStructure.USART_Parity = USART_Parity_No;
|
|
|
|
|
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
|
|
|
|
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
|
|
|
|
|
USART_Init(UART5, &USART_InitStructure);
|
|
|
|
|
|
|
|
|
|
USART_ITConfig(UART5, USART_IT_RXNE, ENABLE);
|
|
|
|
|
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannel = UART5_IRQn;
|
2025-03-04 10:04:30 +00:00
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; //<2F><>ռ<EFBFBD><D5BC><EFBFBD>ȼ<EFBFBD>Ϊ3
|
2025-02-26 09:59:15 +00:00
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3; //<2F><><EFBFBD><EFBFBD><EFBFBD>ȼ<EFBFBD>Ϊ3
|
|
|
|
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQͨ<51><CDA8>ʹ<EFBFBD><CAB9>
|
|
|
|
|
NVIC_Init(&NVIC_InitStructure); //<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
|
|
|
|
USART_Cmd(UART5,ENABLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void USART2_IRQHandler(void)
|
|
|
|
|
{
|
|
|
|
|
J3_Interrupt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void USART3_IRQHandler(void)
|
|
|
|
|
{
|
|
|
|
|
J5_0_Interrupt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef uart4_enable
|
|
|
|
|
void UART4_IRQHandler(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void UART5_IRQHandler(void)
|
|
|
|
|
{
|
|
|
|
|
Upward_Interrupt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UART6_IRQHandler(void)
|
|
|
|
|
{
|
|
|
|
|
J1_Interrupt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UART7_IRQHandler(void)
|
|
|
|
|
{
|
|
|
|
|
J2_Interrupt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void UART8_IRQHandler(void)
|
|
|
|
|
{
|
|
|
|
|
J4_Interrupt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>
|
|
|
|
|
* @param pUSARTx <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
data <EFBFBD>ַ<EFBFBD>
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void USARTx_SendByte(USART_TypeDef* pUSARTx, uint8_t data)
|
|
|
|
|
{
|
|
|
|
|
while(USART_GetFlagStatus(pUSARTx, USART_FLAG_TXE) == RESET) /* waiting for sending finish */
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
USART_SendData(pUSARTx, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param pUSARTx <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
data <EFBFBD>ַ<EFBFBD>
|
|
|
|
|
len <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void USARTx_SendStr_Len(USART_TypeDef* pUSARTx, char *str, int len)
|
|
|
|
|
{
|
|
|
|
|
if (pUSARTx == J1_USART) {
|
|
|
|
|
writeJ1_485;
|
|
|
|
|
} else if (pUSARTx == J2_USART) {
|
|
|
|
|
writeJ2_485;
|
|
|
|
|
} else if (pUSARTx == J3_USART) {
|
|
|
|
|
writeJ3_485;
|
|
|
|
|
} else if (pUSARTx == J4_USART) {
|
|
|
|
|
writeJ4_485;
|
|
|
|
|
} else if (pUSARTx == J5_0_USART) {
|
2025-03-04 10:04:30 +00:00
|
|
|
|
writeJ5_0_485;
|
2025-02-26 09:59:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < len; i++) {
|
|
|
|
|
USARTx_SendByte(pUSARTx, str[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pUSARTx == J1_USART) {
|
|
|
|
|
readJ1_485;
|
|
|
|
|
} else if (pUSARTx == J2_USART) {
|
|
|
|
|
readJ2_485;
|
|
|
|
|
} else if (pUSARTx == J3_USART) {
|
|
|
|
|
readJ3_485;
|
|
|
|
|
} else if (pUSARTx == J4_USART) {
|
|
|
|
|
readJ4_485;
|
|
|
|
|
} else if (pUSARTx == J5_0_USART) {
|
|
|
|
|
readJ5_0_485;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|