玄学出现网址打印,其他部分未初始化
This commit is contained in:
parent
29d8387c74
commit
9e112a4749
|
@ -263,5 +263,5 @@
|
|||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="refreshScope"/>
|
||||
|
||||
</cproject>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#define J1_PWR_Ctrl 38
|
||||
|
||||
|
||||
void J1_485_Init(void);
|
||||
void J1_485_Init(uint32_t baud);
|
||||
void J1_PWR_Open(void);
|
||||
void J1_PWR_Close(void);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
/* PE8 */
|
||||
#define J2_PWR_Ctrl 39
|
||||
|
||||
void J2_485_Init(void);
|
||||
void J2_485_Init(uint32_t baud);
|
||||
void J2_PWR_Open(void);
|
||||
void J2_PWR_Close(void);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
/* PE9 */
|
||||
#define J3_PWR_Ctrl 40
|
||||
|
||||
void J3_485_Init(void);
|
||||
void J3_485_Init(uint32_t baud);
|
||||
void J3_PWR_Open(void);
|
||||
void J3_PWR_Close(void);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
/* PE10 */
|
||||
#define J4_PWR_Ctrl 41
|
||||
|
||||
void J4_485_Init(void);
|
||||
void J4_485_Init(uint32_t baud);
|
||||
void J4_PWR_Open(void);
|
||||
void J4_PWR_Close(void);
|
||||
|
||||
|
|
|
@ -32,11 +32,11 @@
|
|||
#define USART3_buffer_len 256
|
||||
|
||||
|
||||
void J5_0_485_Init(void);
|
||||
void J5_0_485_Init(uint32_t baud);
|
||||
|
||||
extern void USARTx_SendByte(USART_TypeDef* pUSARTx, uint8_t data);
|
||||
extern void USARTx_SendStr(USART_TypeDef* pUSARTx, char *str);
|
||||
void USART3_IRQHandler(void);
|
||||
//void USART3_IRQHandler(void);
|
||||
|
||||
void USART_CONNET_J0(void);
|
||||
void USART_CONNET_J5(void);
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
void USARTx_SendByte(USART_TypeDef* pUSARTx, uint8_t data);
|
||||
void USARTx_SendStr(USART_TypeDef* pUSARTx, char *str);
|
||||
void USARTx_SendByte_str(USART_TypeDef* pUSARTx, uint8_t data);
|
||||
void USARTx_SendStr_Len(USART_TypeDef* pUSARTx, char *str, int len);
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "J1_UART6.h"
|
||||
|
||||
|
||||
void J1_485_Init(void)
|
||||
void J1_485_Init(uint32_t baud)
|
||||
{
|
||||
rt_pin_mode(J1_DE, PIN_MODE_OUTPUT);
|
||||
/* 设置485状态为读 */
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
|
||||
|
||||
void J2_485_Init(void)
|
||||
void J2_485_Init(uint32_t baud)
|
||||
{
|
||||
rt_pin_mode(J2_DE, PIN_MODE_OUTPUT);
|
||||
/* 设置485状态为读 */
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
|
||||
|
||||
void J3_485_Init(void)
|
||||
void J3_485_Init(uint32_t baud)
|
||||
{
|
||||
rt_pin_mode(J3_DE, PIN_MODE_OUTPUT);
|
||||
/* 设置485状态为读 */
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
|
||||
|
||||
void J4_485_Init(void)
|
||||
void J4_485_Init(uint32_t baud)
|
||||
{
|
||||
rt_pin_mode(J4_DE, PIN_MODE_OUTPUT);
|
||||
/* 设置485状态为读 */
|
||||
|
|
|
@ -23,7 +23,7 @@ uint8_t USART_Rbuffer[USART3_buffer_len];
|
|||
* Input : None
|
||||
* Return : None
|
||||
**/
|
||||
void J5_0_485_Init(void)
|
||||
void J5_0_485_Init(uint32_t baud)
|
||||
{
|
||||
rt_pin_mode(J5_PWR_Ctrl, PIN_MODE_OUTPUT);
|
||||
rt_pin_mode(J6_PWR_Ctrl, PIN_MODE_OUTPUT);
|
||||
|
@ -59,7 +59,7 @@ void J5_0_485_Init(void)
|
|||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //设置PB11为浮空输入
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
|
||||
USART_InitStructure.USART_BaudRate = 115200;
|
||||
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;
|
||||
|
@ -74,7 +74,7 @@ void J5_0_485_Init(void)
|
|||
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
USART_ITConfig(USART3, USART_IT_IDLE, ENABLE);
|
||||
// USART_ITConfig(USART3, USART_IT_IDLE, ENABLE);
|
||||
|
||||
USART_Cmd(USART3,ENABLE);
|
||||
}
|
||||
|
@ -90,25 +90,25 @@ void USART3_IRQHandler(void)
|
|||
USART_Rbuffer_Num++;
|
||||
}
|
||||
|
||||
if(USART_GetITStatus(USART3, USART_IT_IDLE) != RESET) //中断产生
|
||||
{
|
||||
// for(USART_Tbuffer_Num=0;USART_Tbuffer_Num < USART_Rbuffer_Num;USART_Tbuffer_Num++)
|
||||
// {
|
||||
// USARTx_SendByte(USART3, USART_Rbuffer[USART_Tbuffer_Num]); //发送数据
|
||||
// }
|
||||
USARTx_SendStr_Len(USART3, USART_Rbuffer, USART_Rbuffer_Num);
|
||||
rt_kprintf("USART_Rbuffer_Num = %d \n", USART_Rbuffer_Num);
|
||||
// USART3->STATR;
|
||||
// USART3->DATAR;
|
||||
USART_Rbuffer_Num = 0; //初始化
|
||||
USART_ReceiveData(USART3); //读DR
|
||||
}
|
||||
|
||||
if(USART_GetFlagStatus(USART3,USART_FLAG_ORE) == SET) //溢出
|
||||
{
|
||||
USART_ClearFlag(USART3,USART_FLAG_ORE); //清标志
|
||||
USART_ReceiveData(USART3); //读DR
|
||||
}
|
||||
// if(USART_GetITStatus(USART3, USART_IT_IDLE) != RESET) //中断产生
|
||||
// {
|
||||
//// for(USART_Tbuffer_Num=0;USART_Tbuffer_Num < USART_Rbuffer_Num;USART_Tbuffer_Num++)
|
||||
//// {
|
||||
//// USARTx_SendByte(USART3, USART_Rbuffer[USART_Tbuffer_Num]); //发送数据
|
||||
//// }
|
||||
// USARTx_SendStr_Len(USART3, USART_Rbuffer, USART_Rbuffer_Num);
|
||||
// rt_kprintf("USART_Rbuffer_Num = %d \n", USART_Rbuffer_Num);
|
||||
//// USART3->STATR;
|
||||
//// USART3->DATAR;
|
||||
// USART_Rbuffer_Num = 0; //初始化
|
||||
// USART_ReceiveData(USART3); //读DR
|
||||
// }
|
||||
//
|
||||
// if(USART_GetFlagStatus(USART3,USART_FLAG_ORE) == SET) //溢出
|
||||
// {
|
||||
// USART_ClearFlag(USART3,USART_FLAG_ORE); //清标志
|
||||
// USART_ReceiveData(USART3); //读DR
|
||||
// }
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -50,6 +50,7 @@ void USARTx_SendByte(USART_TypeDef* pUSARTx, uint8_t data)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void USARTx_SendByte_str(USART_TypeDef* pUSARTx, uint8_t data)
|
||||
{
|
||||
USART_SendData(pUSARTx, data);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "ch32v30x.h"
|
||||
#include <rtthread.h>
|
||||
#include <rthw.h>
|
||||
#include "ring_queue.h"
|
||||
#include "RingQueue/ring_queue.h"
|
||||
#include "rs485.h"
|
||||
|
||||
#define ASCII_CHAR_BACKSPACE 0x08 /* '\b' */
|
||||
|
@ -21,29 +21,46 @@
|
|||
#define ASCII_CHAR_FORM_FEED 0x0C /* '\f' */
|
||||
#define ASCII_CHAR_CARRIAGE_RETURN 0x0D /* '\r' */
|
||||
|
||||
#define RS485_MAX_PACK_DATA_LEN 30
|
||||
//#define RS485_MAX_PACK_DATA_LEN 30
|
||||
|
||||
typedef uint32_t device_handle;
|
||||
|
||||
extern device_handle g_J1RS485_UART6_handle;
|
||||
extern device_handle g_J2RS485_UART7_handle;
|
||||
extern device_handle g_J3RS485_USART2_handle;
|
||||
extern device_handle g_J4RS485_UART8_handle;
|
||||
extern device_handle g_J50RS485_USART3_handle;
|
||||
extern device_handle g_LORA_UART5_handle;
|
||||
|
||||
typedef enum{
|
||||
J1RS485_UART6 = 0,
|
||||
J2RS485_UART7,
|
||||
J3RS485_USART2,
|
||||
J4RS485_UART8,
|
||||
J50RS485_USART3,
|
||||
LORA_UART5,
|
||||
J1RS485_UART6 = 6,
|
||||
J2RS485_UART7 = 7,
|
||||
J3RS485_USART2 = 2,
|
||||
J4RS485_UART8 = 8,
|
||||
J50RS485_USART3 = 3,
|
||||
LORA_UART5 = 5,
|
||||
}uartIndex_e;
|
||||
|
||||
typedef enum{
|
||||
ONLYONE = 1,
|
||||
J0RS485 = 0,
|
||||
J5RS485 = 5,
|
||||
J6RS485 = 6,
|
||||
J7RS485 = 7,
|
||||
J8RS485 = 8,
|
||||
J9RS485 = 9,
|
||||
}uartNum_e;
|
||||
|
||||
/* UART 驱动数据结构,对应一个uart设备 */
|
||||
typedef struct _uart_device_info{
|
||||
uint8_t init;
|
||||
uartIndex_e uart_index;
|
||||
uint32_t uart_baudrate;
|
||||
RingQueue uart_ring_queue;
|
||||
uartNum_e uart_num;
|
||||
}uart_device_info;
|
||||
|
||||
//device_handle uart_dev_init(uartIndex_e uart_index, uint8_t *buff, int buff_size);
|
||||
//device_handle uart_dev_init(uart_device_info *uart_device, uint8_t *buff, int buff_size);
|
||||
device_handle uart_dev_init(void);
|
||||
void uart_sendstr(device_handle device,char *str);
|
||||
void uart_dev_write(device_handle device, void *data, int len);
|
||||
|
|
|
@ -6,38 +6,80 @@
|
|||
*/
|
||||
|
||||
#include "uart_dev.h"
|
||||
#include "J1_UART6.h"
|
||||
#include "J2_UART7.h"
|
||||
#include "J3_USART2.h"
|
||||
#include "J4_UART8.h"
|
||||
#include "J5-0_USART3.h"
|
||||
|
||||
|
||||
/* 使能485发送 */
|
||||
//#define rs485_send_enable 1
|
||||
#define rs485_send_enable 1
|
||||
|
||||
static void uart_init(uartIndex_e uart_index, int baud);
|
||||
//static void uart_init(uartIndex_e uart_index, int baud);
|
||||
static void uart_init(uart_device_info *uart_device, int baud);
|
||||
static uint8_t uart_putchar(device_handle device, char ch);
|
||||
|
||||
//device_handle g_bat485_uart3_handle;
|
||||
//device_handle g_gw485_uart4_handle;
|
||||
//
|
||||
//static uint8_t bat485_in_buff[200];
|
||||
//static uint8_t gw485_in_buff[300];
|
||||
//
|
||||
device_handle g_J1RS485_UART6_handle;
|
||||
device_handle g_J2RS485_UART7_handle;
|
||||
device_handle g_J3RS485_USART2_handle;
|
||||
device_handle g_J4RS485_UART8_handle;
|
||||
device_handle g_J50RS485_USART3_handle;
|
||||
device_handle g_LORA_UART5_handle;
|
||||
|
||||
#define IN_BUFF_SIZE 128
|
||||
//static uint8_t J1RS485_in_buff[IN_BUFF_SIZE];
|
||||
//static uint8_t J2RS485_in_buff[IN_BUFF_SIZE];
|
||||
//static uint8_t J3RS485_in_buff[IN_BUFF_SIZE];
|
||||
//static uint8_t J4RS485_in_buff[IN_BUFF_SIZE];
|
||||
//static uint8_t J50RS485_in_buff[IN_BUFF_SIZE];
|
||||
//static uint8_t LORA_in_buff[IN_BUFF_SIZE];
|
||||
uint8_t J1RS485_in_buff[IN_BUFF_SIZE];
|
||||
uint8_t J2RS485_in_buff[IN_BUFF_SIZE];
|
||||
uint8_t J3RS485_in_buff[IN_BUFF_SIZE];
|
||||
uint8_t J4RS485_in_buff[IN_BUFF_SIZE];
|
||||
uint8_t J50RS485_in_buff[IN_BUFF_SIZE];
|
||||
uint8_t LORA_in_buff[IN_BUFF_SIZE];
|
||||
|
||||
//uint8_t rs485_out_buff[100];
|
||||
|
||||
|
||||
/**
|
||||
* @brief 串口信息初始化,串口号及波特率.
|
||||
* @brief 串口信息初始化,串口号.
|
||||
* @param uart_index 对应的硬件串口号
|
||||
* @param uart_baudrate 波特率
|
||||
*/
|
||||
uart_device_info uart_devices[]={
|
||||
// [0] = {
|
||||
// .init = 0,
|
||||
// .uart_index = BAT485_UART_INDEX,
|
||||
// .uart_baudrate = 9600,
|
||||
// },
|
||||
// [1] = {
|
||||
// .init = 0,
|
||||
// .uart_index = GW485_UART_INDEX,
|
||||
// .uart_baudrate = 9600,
|
||||
// },
|
||||
[0] = {
|
||||
.init = 0,
|
||||
.uart_index = J1RS485_UART6,
|
||||
.uart_num = ONLYONE,
|
||||
},
|
||||
[1] = {
|
||||
.init = 0,
|
||||
.uart_index = J2RS485_UART7,
|
||||
.uart_num = ONLYONE,
|
||||
},
|
||||
[2] = {
|
||||
.init = 0,
|
||||
.uart_index = J3RS485_USART2,
|
||||
.uart_num = ONLYONE,
|
||||
},
|
||||
[3] = {
|
||||
.init = 0,
|
||||
.uart_index = J4RS485_UART8,
|
||||
.uart_num = ONLYONE,
|
||||
},
|
||||
[4] = {
|
||||
.init = 0,
|
||||
.uart_index = J50RS485_USART3,
|
||||
.uart_num = J0RS485,
|
||||
},
|
||||
[5] = {
|
||||
.init = 0,
|
||||
.uart_index = LORA_UART5,
|
||||
.uart_num = ONLYONE,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -64,29 +106,55 @@ uart_device_info uart_devices[]={
|
|||
// }
|
||||
// return 0;
|
||||
//}
|
||||
//device_handle uart_dev_init(uart_device_info *uart_device, uint8_t *buff, int buff_size)
|
||||
//{
|
||||
// int i = 0;
|
||||
// for(; i < ELEMENT_OF(uart_devices); i++){
|
||||
// if(uart_devices[i].uart_index == uart_device->uart_index){
|
||||
// if(!uart_devices[i].init){
|
||||
// InitRingQueue(&uart_devices[i].uart_ring_queue, buff, buff_size);
|
||||
// uart_init(uart_device, uart_devices[i].uart_baudrate);
|
||||
//
|
||||
// uart_devices[i].init = 1;
|
||||
// }
|
||||
// return (device_handle)(&uart_devices[i]);
|
||||
// }
|
||||
// }
|
||||
// return 0;
|
||||
//}
|
||||
device_handle uart_dev_init(void)
|
||||
{
|
||||
// int i = 0;
|
||||
// for(; i < ELEMENT_OF(uart_devices); i++){
|
||||
// if(uart_devices[i].uart_index == uart_index){
|
||||
// if(!uart_devices[i].init){
|
||||
// InitRingQueue(&uart_devices[i].uart_ring_queue, buff, buff_size);
|
||||
// uart_init(uart_index, uart_devices[i].uart_baudrate);
|
||||
//
|
||||
// uart_devices[i].init = 1;
|
||||
// }
|
||||
// return (device_handle)(&uart_devices[i]);
|
||||
// }
|
||||
// }
|
||||
// InitRingQueue(&uart_devices[0].uart_ring_queue, bat485_in_buff, sizeof(bat485_in_buff));
|
||||
// uart_init(BAT485_UART_INDEX, g_slConfigInfo.bat485_Baud);
|
||||
// uart_devices[0].init = 1;
|
||||
// g_bat485_uart3_handle = (device_handle)(&uart_devices[0]);
|
||||
//
|
||||
// InitRingQueue(&uart_devices[1].uart_ring_queue, gw485_in_buff, sizeof(gw485_in_buff));
|
||||
// uart_init(GW485_UART_INDEX, g_slConfigInfo.gw485_Baud);
|
||||
// uart_devices[1].init = 1;
|
||||
// g_gw485_uart4_handle = (device_handle)(&uart_devices[1]);
|
||||
InitRingQueue(&uart_devices[0].uart_ring_queue, J1RS485_in_buff, sizeof(J1RS485_in_buff));
|
||||
uart_init(&uart_devices[0], 9600);
|
||||
uart_devices[0].init = 1;
|
||||
g_J1RS485_UART6_handle = (device_handle)(&uart_devices[0]);
|
||||
|
||||
InitRingQueue(&uart_devices[1].uart_ring_queue, J2RS485_in_buff, sizeof(J2RS485_in_buff));
|
||||
uart_init(&uart_devices[1], 9600);
|
||||
uart_devices[1].init = 1;
|
||||
g_J2RS485_UART7_handle = (device_handle)(&uart_devices[1]);
|
||||
|
||||
|
||||
InitRingQueue(&uart_devices[2].uart_ring_queue, J3RS485_in_buff, sizeof(J3RS485_in_buff));
|
||||
uart_init(&uart_devices[2], 9600);
|
||||
uart_devices[2].init = 1;
|
||||
g_J3RS485_USART2_handle = (device_handle)(&uart_devices[2]);
|
||||
|
||||
InitRingQueue(&uart_devices[3].uart_ring_queue, J4RS485_in_buff, sizeof(J4RS485_in_buff));
|
||||
uart_init(&uart_devices[3], 9600);
|
||||
uart_devices[3].init = 1;
|
||||
g_J4RS485_UART8_handle = (device_handle)(&uart_devices[3]);
|
||||
|
||||
|
||||
InitRingQueue(&uart_devices[4].uart_ring_queue, J50RS485_in_buff, sizeof(J50RS485_in_buff));
|
||||
uart_init(&uart_devices[4], 9600);
|
||||
uart_devices[4].init = 1;
|
||||
g_J50RS485_USART3_handle = (device_handle)(&uart_devices[4]);
|
||||
|
||||
InitRingQueue(&uart_devices[5].uart_ring_queue, LORA_in_buff, sizeof(LORA_in_buff));
|
||||
uart_init(&uart_devices[5], 9600);
|
||||
uart_devices[5].init = 1;
|
||||
g_LORA_UART5_handle = (device_handle)(&uart_devices[5]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -98,13 +166,36 @@ device_handle uart_dev_init(void)
|
|||
* @param baud 波特率
|
||||
* @retval None
|
||||
*/
|
||||
void uart_init(uartIndex_e uart_index, int baud)
|
||||
{
|
||||
// if (uart_index == BAT485_UART_INDEX) {
|
||||
// BAT_485_Init(uart_devices[0].uart_baudrate);
|
||||
// } else if (uart_index == GW485_UART_INDEX) {
|
||||
// GW_485_Init(uart_devices[1].uart_baudrate);
|
||||
// }
|
||||
void uart_init(uart_device_info *uart_device, int baud)
|
||||
{ rt_kprintf("1 \n");
|
||||
uart_device->uart_baudrate = baud;
|
||||
if (uart_device->uart_index == J1RS485_UART6) {
|
||||
J1_485_Init(baud);
|
||||
} else if (uart_device->uart_index == J2RS485_UART7) {
|
||||
J2_485_Init(baud);
|
||||
} else if (uart_device->uart_index == J3RS485_USART2) {
|
||||
J3_485_Init(baud);
|
||||
} else if (uart_device->uart_index == J4RS485_UART8) {
|
||||
J4_485_Init(baud);
|
||||
} else if (uart_device->uart_index == J50RS485_USART3) {
|
||||
J5_0_485_Init(baud);
|
||||
if (uart_device->uart_num == J0RS485) {
|
||||
USART_CONNET_J0();
|
||||
} else if (uart_device->uart_num == J5RS485) {
|
||||
USART_CONNET_J5();
|
||||
} else if (uart_device->uart_num == J6RS485) {
|
||||
USART_CONNET_J6();
|
||||
} else if (uart_device->uart_num == J7RS485) {
|
||||
USART_CONNET_J7();
|
||||
} else if (uart_device->uart_num == J8RS485) {
|
||||
USART_CONNET_J8();
|
||||
} else if (uart_device->uart_num == J9RS485) {
|
||||
USART_CONNET_J9();
|
||||
}
|
||||
rt_kprintf("1 \n");
|
||||
} else if (uart_device->uart_index == LORA_UART5) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -119,53 +210,117 @@ uint8_t uart_putchar(device_handle device, char ch)
|
|||
if((!device) || (!device_info->init))
|
||||
return 0;
|
||||
|
||||
// if (device_info->uart_index == BAT485_UART_INDEX) {
|
||||
// USARTx_SendByte(BAT_485, ch);
|
||||
// } else if(device_info->uart_index == GW485_UART_INDEX) {
|
||||
// USARTx_SendByte(GW_485, ch);
|
||||
// }
|
||||
if (device_info->uart_index == J1RS485_UART6) {
|
||||
|
||||
} else if (device_info->uart_index == J2RS485_UART7) {
|
||||
|
||||
} else if (device_info->uart_index == J3RS485_USART2) {
|
||||
|
||||
} else if (device_info->uart_index == J4RS485_UART8) {
|
||||
|
||||
} else if (device_info->uart_index == J50RS485_USART3) {
|
||||
USARTx_SendByte_str(USART3, ch);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief bat485发送使能.
|
||||
* @brief J1RS485发送使能.
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void bat485_tx_enabla(void)
|
||||
void J1RS485_tx_enabla(void)
|
||||
{
|
||||
// GPIO_WriteBit(GPIO_BAT_485_RDE, Pin_BAT_485_RDE, write);
|
||||
rt_pin_write(J1_DE, write);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief bat485发送关闭.
|
||||
* @brief J1RS485发送关闭.
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void bat485_tx_disenabla(void)
|
||||
void J1RS485_tx_disenabla(void)
|
||||
{
|
||||
// GPIO_WriteBit(GPIO_BAT_485_RDE, Pin_BAT_485_RDE, read);
|
||||
rt_pin_write(J1_DE, read);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gw485发送使能.
|
||||
* @brief J2RS485发送使能.
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void gw485_tx_enabla(void)
|
||||
void J2RS485_tx_enabla(void)
|
||||
{
|
||||
// GPIO_WriteBit(GPIO_GW_485_RDE, Pin_GW_485_RDE, write);
|
||||
rt_pin_write(J2_DE, write);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gw485发送关闭.
|
||||
* @brief J2RS485发送关闭.
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void gw485_tx_disenabla(void)
|
||||
void J2RS485_tx_disenabla(void)
|
||||
{
|
||||
// GPIO_WriteBit(GPIO_GW_485_RDE, Pin_GW_485_RDE, read);
|
||||
rt_pin_write(J2_DE, read);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief J3RS485发送使能.
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void J3RS485_tx_enabla(void)
|
||||
{
|
||||
rt_pin_write(J3_DE, write);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief J3RS485发送关闭.
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void J3RS485_tx_disenabla(void)
|
||||
{
|
||||
rt_pin_write(J3_DE, read);
|
||||
}
|
||||
/**
|
||||
* @brief J4RS485发送使能.
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void J4RS485_tx_enabla(void)
|
||||
{
|
||||
rt_pin_write(J4_DE, write);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief J4RS485发送关闭.
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void J4RS485_tx_disenabla(void)
|
||||
{
|
||||
rt_pin_write(J4_DE, read);
|
||||
}
|
||||
/**
|
||||
* @brief J50RS485发送使能.
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void J50RS485_tx_enabla(void)
|
||||
{
|
||||
rt_pin_write(USART3_DE, write);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief J50RS485发送关闭.
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void J50RS485_tx_disenabla(void)
|
||||
{
|
||||
rt_pin_write(USART3_DE, read);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -177,11 +332,16 @@ void gw485_tx_disenabla(void)
|
|||
void uart_sendstr(device_handle device,char *str)
|
||||
{
|
||||
#if rs485_send_enable
|
||||
if(device == g_bat485_uart3_handle){
|
||||
bat485_tx_enabla();
|
||||
}
|
||||
else if (device == g_gw485_uart4_handle) {
|
||||
gw485_tx_enabla();
|
||||
if(device == g_J1RS485_UART6_handle){
|
||||
J1RS485_tx_enabla();
|
||||
} else if (device == g_J2RS485_UART7_handle) {
|
||||
J2RS485_tx_enabla();
|
||||
} else if (device == g_J3RS485_USART2_handle) {
|
||||
J3RS485_tx_enabla();
|
||||
} else if (device == g_J4RS485_UART8_handle) {
|
||||
J4RS485_tx_enabla();
|
||||
} else if (device == g_J50RS485_USART3_handle) {
|
||||
J50RS485_tx_enabla();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -196,12 +356,17 @@ void uart_sendstr(device_handle device,char *str)
|
|||
}
|
||||
|
||||
#if rs485_send_enable
|
||||
if(device == g_bat485_uart3_handle){
|
||||
bat485_tx_disenabla();
|
||||
}
|
||||
else if (device == g_gw485_uart4_handle) {
|
||||
gw485_tx_disenabla();
|
||||
}
|
||||
if(device == g_J1RS485_UART6_handle){
|
||||
J1RS485_tx_disenabla();
|
||||
} else if (device == g_J2RS485_UART7_handle) {
|
||||
J2RS485_tx_disenabla();
|
||||
} else if (device == g_J3RS485_USART2_handle) {
|
||||
J3RS485_tx_disenabla();
|
||||
} else if (device == g_J4RS485_UART8_handle) {
|
||||
J4RS485_tx_disenabla();
|
||||
} else if (device == g_J50RS485_USART3_handle) {
|
||||
J50RS485_tx_disenabla();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -217,11 +382,16 @@ void uart_sendstr(device_handle device,char *str)
|
|||
void uart_dev_write(device_handle device, void *data, int len)
|
||||
{
|
||||
#if rs485_send_enable
|
||||
if(device == g_bat485_uart3_handle){
|
||||
bat485_tx_enabla();
|
||||
}
|
||||
else if (device == g_gw485_uart4_handle) {
|
||||
gw485_tx_enabla();
|
||||
if(device == g_J1RS485_UART6_handle){
|
||||
J1RS485_tx_enabla();
|
||||
} else if (device == g_J2RS485_UART7_handle) {
|
||||
J2RS485_tx_enabla();
|
||||
} else if (device == g_J3RS485_USART2_handle) {
|
||||
J3RS485_tx_enabla();
|
||||
} else if (device == g_J4RS485_UART8_handle) {
|
||||
J4RS485_tx_enabla();
|
||||
} else if (device == g_J50RS485_USART3_handle) {
|
||||
J50RS485_tx_enabla();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -230,12 +400,17 @@ void uart_dev_write(device_handle device, void *data, int len)
|
|||
}
|
||||
|
||||
#if rs485_send_enable
|
||||
if(device == g_bat485_uart3_handle){
|
||||
bat485_tx_disenabla();
|
||||
}
|
||||
else if (device == g_gw485_uart4_handle) {
|
||||
gw485_tx_disenabla();
|
||||
}
|
||||
if(device == g_J1RS485_UART6_handle){
|
||||
J1RS485_tx_disenabla();
|
||||
} else if (device == g_J2RS485_UART7_handle) {
|
||||
J2RS485_tx_disenabla();
|
||||
} else if (device == g_J3RS485_USART2_handle) {
|
||||
J3RS485_tx_disenabla();
|
||||
} else if (device == g_J4RS485_UART8_handle) {
|
||||
J4RS485_tx_disenabla();
|
||||
} else if (device == g_J50RS485_USART3_handle) {
|
||||
J50RS485_tx_disenabla();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ int main(void)
|
|||
SystemCoreClockUpdate();
|
||||
rt_kprintf(" SysClk: %dHz\r\n",SystemCoreClock);
|
||||
rt_kprintf(" ChipID: %08x\r\n",DBGMCU_GetCHIPID());
|
||||
rt_kprintf("test \r\n");
|
||||
|
||||
app_star();
|
||||
|
||||
|
|
12
User/start.c
12
User/start.c
|
@ -1,12 +1,15 @@
|
|||
#include <start.h>
|
||||
#include "inc/Android.h"
|
||||
|
||||
|
||||
#include "inc/Android.h"
|
||||
#include "inc/Flash.h"
|
||||
#include "inc/UART.h"
|
||||
#include "inc/J5-0_USART3.h"
|
||||
|
||||
#include <inc/communication_protocol.h>
|
||||
#include "inc/Rs485.h"
|
||||
#include "inc/uart_dev.h"
|
||||
|
||||
|
||||
/*
|
||||
* 硬件初始化函数
|
||||
*
|
||||
|
@ -19,7 +22,6 @@ void hareware_init()
|
|||
|
||||
// SPI_Flash_TEST();
|
||||
|
||||
J5_0_485_Init();
|
||||
// USARTx_SendStr(J5_0_USART, "This is a test data.\n");
|
||||
|
||||
|
||||
|
@ -33,6 +35,10 @@ void hareware_init()
|
|||
*/
|
||||
void software_init()
|
||||
{
|
||||
uart_dev_init();
|
||||
|
||||
// uart_sendstr(g_J50RS485_USART3_handle, "This is a test data.\n");
|
||||
USARTx_SendStr(USART3, "This is a test data.\n");
|
||||
Rs485_thread_Init();
|
||||
|
||||
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -37,7 +37,7 @@ Software/src/uart_dev.o: ../Software/src/uart_dev.c \
|
|||
D:\psx\su806\git\CH32V303_V0.1\rtthread\include/rtm.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\rtthread\components\finsh/finsh_api.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\rtthread\include/rthw.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\drivers\RingQueue/ring_queue.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\drivers/RingQueue/ring_queue.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software\inc/rs485.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software\inc/communication_protocol.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware/inc/UART.h \
|
||||
|
@ -51,7 +51,13 @@ Software/src/uart_dev.o: ../Software/src/uart_dev.c \
|
|||
D:\psx\su806\git\CH32V303_V0.1\rtthread\components\drivers\include/ipc/pipe.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\rtthread\components\drivers\include/ipc/poll.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\rtthread\components\drivers\include/drivers/serial.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\rtthread\components\drivers\include/drivers/pin.h
|
||||
D:\psx\su806\git\CH32V303_V0.1\rtthread\components\drivers\include/drivers/pin.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware\inc/J1_UART6.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware\inc/UART.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware\inc/J2_UART7.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware\inc/J3_USART2.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware\inc/J4_UART8.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware\inc/J5-0_USART3.h
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software\inc/uart_dev.h:
|
||||
|
||||
|
@ -129,7 +135,7 @@ D:\psx\su806\git\CH32V303_V0.1\rtthread\components\finsh/finsh_api.h:
|
|||
|
||||
D:\psx\su806\git\CH32V303_V0.1\rtthread\include/rthw.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\drivers\RingQueue/ring_queue.h:
|
||||
D:\psx\su806\git\CH32V303_V0.1\drivers/RingQueue/ring_queue.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software\inc/rs485.h:
|
||||
|
||||
|
@ -158,3 +164,15 @@ D:\psx\su806\git\CH32V303_V0.1\rtthread\components\drivers\include/ipc/poll.h:
|
|||
D:\psx\su806\git\CH32V303_V0.1\rtthread\components\drivers\include/drivers/serial.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\rtthread\components\drivers\include/drivers/pin.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware\inc/J1_UART6.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware\inc/UART.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware\inc/J2_UART7.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware\inc/J3_USART2.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware\inc/J4_UART8.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware\inc/J5-0_USART3.h:
|
||||
|
|
Binary file not shown.
BIN
obj/User/main.o
BIN
obj/User/main.o
Binary file not shown.
|
@ -50,11 +50,12 @@ User/start.d: ../User/start.c D:\psx\su806\git\CH32V303_V0.1\User/start.h \
|
|||
D:\psx\su806\git\CH32V303_V0.1\rtthread\components\drivers\include/drivers/pin.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware/inc/Flash.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware/inc/UART.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware/inc/J5-0_USART3.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware/inc/UART.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software/inc/communication_protocol.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software/inc/Rs485.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software/inc/communication_protocol.h
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software/inc/communication_protocol.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software/inc/uart_dev.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\drivers/RingQueue/ring_queue.h \
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software/inc/rs485.h
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\User/start.h:
|
||||
|
||||
|
@ -160,12 +161,14 @@ D:\psx\su806\git\CH32V303_V0.1\Hardware/inc/Flash.h:
|
|||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware/inc/UART.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware/inc/J5-0_USART3.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Hardware/inc/UART.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software/inc/communication_protocol.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software/inc/Rs485.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software/inc/communication_protocol.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software/inc/uart_dev.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\drivers/RingQueue/ring_queue.h:
|
||||
|
||||
D:\psx\su806\git\CH32V303_V0.1\Software/inc/rs485.h:
|
||||
|
|
BIN
obj/User/start.o
BIN
obj/User/start.o
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue