#ifndef HARDWARE_RS485_UART_H_ #define HARDWARE_RS485_UART_H_ #include "ch32v30x.h" // #define uart4_enable #define J1_USART UART6 #define J2_USART UART7 #define J3_USART USART2 #define J4_USART UART8 #define J5_0_USART USART3 #define Upward_USART UART5 /* 串口6 PE5 */ #define J1_DE_PROT GPIOE #define J1_DE_PIN GPIO_Pin_5 /* 串口7 PE6 */ #define J2_DE_PROT GPIOE #define J2_DE_PIN GPIO_Pin_6 /* 串口2 PA1 */ #define J3_DE_PROT GPIOA #define J3_DE_PIN GPIO_Pin_1 /* 串口8 PE5 */ #define J4_DE_PROT GPIOB #define J4_DE_PIN GPIO_Pin_0 /* 串口3 分时复用 */ /* | A - B - C - YX | | 0 - 0 - 0 - J0 | | 0 - 0 - 1 - J5 | | 0 - 1 - 0 - J6 | | 0 - 1 - 1 - J7 | | 1 - 0 - 0 - J8 | | 1 - 0 - 1 - J9 | */ #define J5_0_DE_PROT GPIOD #define J5_0_DE_PIN GPIO_Pin_8 #define J5_0_A_PROT GPIOD #define J5_0_A_PIN GPIO_Pin_9 #define J5_0_B_PROT GPIOD #define J5_0_B_PIN GPIO_Pin_10 #define J5_0_C_PROT GPIOD #define J5_0_C_PIN GPIO_Pin_11 #define write485 Bit_SET #define read485 Bit_RESET void set_485_Read(void); /* J1_UART6 */ void J1_485_Init(uint32_t baud); #define readJ1_485 GPIO_WriteBit(J1_DE_PROT, J1_DE_PIN, read485); #define writeJ1_485 GPIO_WriteBit(J1_DE_PROT, J1_DE_PIN, write485); /* J2_UART7 */ void J2_485_Init(uint32_t baud); #define readJ2_485 GPIO_WriteBit(J2_DE_PROT, J2_DE_PIN, read485); #define writeJ2_485 GPIO_WriteBit(J2_DE_PROT, J2_DE_PIN, write485); /* J3_USART2 */ void J3_485_Init(uint32_t baud); #define readJ3_485 GPIO_WriteBit(J3_DE_PROT, J3_DE_PIN, read485); #define writeJ3_485 GPIO_WriteBit(J3_DE_PROT, J3_DE_PIN, write485); /* J4_UART8 */ void J4_485_Init(uint32_t baud); #define readJ4_485 GPIO_WriteBit(J4_DE_PROT, J4_DE_PIN, read485); #define writeJ4_485 GPIO_WriteBit(J4_DE_PROT, J4_DE_PIN, write485); /* J0-5_USART3 */ void J5_0_485_Init(uint32_t baud); #define readJ5_0_485 GPIO_WriteBit(J5_0_DE_PROT, J5_0_DE_PIN, read485); #define writeJ5_0_485 GPIO_WriteBit(J5_0_DE_PROT, J5_0_DE_PIN, write485); void USART_CONNET_J0(void); void USART_CONNET_J5(void); void USART_CONNET_J6(void); void USART_CONNET_J7(void); void USART_CONNET_J8(void); void USART_CONNET_J9(void); #ifdef uart4_enable /* LORA_UART4 */ void LORA_UART4_Init(uint32_t baud); #endif /* Upward_UART5 */ void Upward_UART5_Init(uint32_t baud); extern void J3_Interrupt(); extern void J5_0_Interrupt(); extern void Upward_Interrupt(); extern void J1_Interrupt(); extern void J2_Interrupt(); extern void J4_Interrupt(); void USARTx_SendByte(USART_TypeDef* pUSARTx, uint8_t data); void USARTx_SendStr_Len(USART_TypeDef* pUSARTx, char *str, int len); #endif /* HARDWARE_RS485_UART_H_ */