|
/******************************************************************************
|
* Copyright (C) 2014-2015 HangZhou SiZhu Co.,LTD.
|
*
|
*-----------------------------------------------------------------------------
|
* File: RS485.h
|
* Description: head file of RS485.c used to receive and send data
|
* Author: Lishoujian (867693272@qq.com)
|
* Date: Jan 8, 2015
|
*****************************************************************************/
|
|
/* ----------------------- Platform includes --------------------------------*/
|
|
#ifndef __RS485_H
|
#define __RS485_H
|
#include "sys.h"
|
#include "gprs.h"
|
|
|
#ifdef UFG6X0_VALVE_HAVE_BILLING_CENTER
|
|
#define UARTNUM USART3
|
#define UART_IRQ USART3_IRQn
|
#define APB_GPIO_GROUP RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOE
|
#define RCC_APB_Periph_UART RCC_APB1Periph_USART3
|
|
#define V_RS485_CON_EN_PIN_NUM GPIO_Pin_2 //02-019
|
#define V_RS485_CON_EN_PIN_GROUP GPIOE
|
#define V_RS485_TXD_EN_PIN_NUM GPIO_Pin_10
|
#define V_RS485_TXD_EN_PIN_GROUP GPIOB
|
#define V_RS485_RXD_EN_PIN_NUM GPIO_Pin_11
|
#define V_RS485_RXD_EN_PIN_GROUP GPIOB
|
#define DMA_RS485_Channel DMA1_Channel3
|
#define DMA_RS485_TX_Channel DMA1_Channel2
|
#define RCC_AHB_Preiph_UART_DMA RCC_AHBPeriph_DMA1
|
//ģʽ¿ØÖÆ
|
#define RS485_EN PEout(2) //485 mode control.0,receive;1,send.
|
#define V_RS485_EN_HIGH GPIO_SetBits(GPIOE,GPIO_Pin_2)
|
#define V_RS485_EN_LOW GPIO_ResetBits(GPIOE,GPIO_Pin_2)
|
|
#else
|
#define UARTNUM UART4
|
#define UART_IRQ UART4_IRQn
|
#define APB_GPIO_GROUP RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD
|
#define RCC_APB_Periph_UART RCC_APB1Periph_UART4
|
|
#define V_RS485_CON_EN_PIN_NUM GPIO_Pin_4 //02-019
|
#define V_RS485_CON_EN_PIN_GROUP GPIOD
|
#define V_RS485_TXD_EN_PIN_NUM GPIO_Pin_10
|
#define V_RS485_TXD_EN_PIN_GROUP GPIOC
|
#define V_RS485_RXD_EN_PIN_NUM GPIO_Pin_11
|
#define V_RS485_RXD_EN_PIN_GROUP GPIOC
|
#define DMA_RS485_Channel DMA2_Channel3
|
#define DMA_RS485_TX_Channel DMA2_Channel5
|
#define RCC_AHB_Preiph_UART_DMA RCC_AHBPeriph_DMA2
|
#define DMA_RS485_TC DMA2_FLAG_TC3
|
#define DMA_RS485_TX_TC DMA2_FLAG_TC5
|
//#define RS485_EN_NUM 12
|
//ģʽ¿ØÖÆ
|
#define RS485_EN PDout(4) //485 mode control.0,receive;1,send.
|
#define V_RS485_EN_HIGH GPIO_SetBits(GPIOD,GPIO_Pin_4)
|
#define V_RS485_EN_LOW GPIO_ResetBits(GPIOD,GPIO_Pin_4)
|
#endif
|
|
|
#define REC_LENGTH 900
|
#define SEND_MAX_NUM 200
|
|
|
|
typedef enum
|
{
|
UP_PC_COM,
|
RS485_MODBUS_RTU_COM,
|
BT_COM
|
|
}COM_TYPE;
|
|
|
|
|
|
typedef struct rx_modbus_t
|
{
|
u8 RS485_BUF[REC_LENGTH];
|
u16 rec_buffer_cnt;
|
u8 receive_modebus_head_flag;
|
u16 rec_buffer_cnt_old;
|
u16 rec_check_equre_cnt;
|
|
}RX_MODBUS_T;
|
|
void UartDebugFun(char *str);
|
void RS485_TXDMA_Init(u8 *data,u32 lenth);
|
void RS485_Usart_Init(uint32 system_BaudRate);
|
void RS485_Send_Data(uint8 *buf,uint16 len);
|
|
void RS485_Receive_Data(uint8 * recbuf, uint8 *rec485buffer, uint8 len);
|
|
extern RX_MODBUS_T rs485_receive_g;
|
extern u8 share_sendbuf[SEND_MAX_NUM];
|
#endif
|