芯片破解stm32 modbus通信程序 485触摸屏
- 芯片破解#include "rs485.h"
- 芯片破解#include "SysTick.h"
- 芯片破解#include "crc16.h"
- 芯片破解#include "led.h"
- /*******************************************************************************
- * 函 数 名         : RS485_Init
- * 函数功能                   : USART2初始化函数
- * 输    入         : bound:波特率
- * 输    出         : 无
- *******************************************************************************/  
- u8 USART2_RX_BUF[64];                   //接收缓冲,最大64字节
- u8 USART2_RX_CNT=0;                       //接收字节计数器
- u8 flagFrame=0;                         //帧接收完成标志,即接收到一帧新数据
- unsigned char regGroup[5];  //Modbus寄存器组,地址为0x00~0x04
- void RS485_Init(u32 bound)
- {
-         GPIO_InitTypeDef GPIO_InitStructure;
-         USART_InitTypeDef USART_InitStructure;
-         NVIC_InitTypeDef NVIC_InitStructure;
-        
-         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOG|RCC_APB2Periph_GPIOA,ENABLE); //使能GPIOA\G时钟
-         RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);//使能USART2时钟
-        
-         /*  配置GPIO的模式和IO口 */
-         GPIO_InitStructure.GPIO_Pin=GPIO_Pin_2;        //TX-485        //串口输出PA2
-         GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;                  //复用推挽输出
-         GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;       
-         GPIO_Init(GPIOA,&GPIO_InitStructure);                /* 初始化串口输入IO */
-        
-         GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3;        //RX-485           //串口输入PA3
-         GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;            //模拟输入
-         GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
-         GPIO_Init(GPIOA,&GPIO_InitStructure);
-        
-         GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3;        //CS-485
-         GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;           //推挽输出
-         GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
-         GPIO_Init(GPIOG,&GPIO_InitStructure);
-        
-         //USART2 初始化设置
-         USART_InitStructure.USART_BaudRate = bound;//波特率设置
-         USART_InitStructure.USART_WordLength = USART_WordLength_8b;//字长为8位数据格式
-         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_Rx | USART_Mode_Tx;        //收发模式
-         USART_Init(USART2, &USART_InitStructure); //初始化串口2
-        
-         USART_Cmd(USART2, ENABLE);  //使能串口 2
-        
-         USART_ClearFlag(USART2, USART_FLAG_TC);
-                
-         USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);//开启接受中断
-         //Usart2 NVIC 配置
-         NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
-         NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=2;//抢占优先级3
-         NVIC_InitStructure.NVIC_IRQChannelSubPriority =2;                //子优先级2
-         NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;                        //IRQ通道使能
-         NVIC_Init(&NVIC_InitStructure);        //根据指定的参数初始化VIC寄存器、
-        
- RS485_TX_EN=0; //默认为接收模式
 
  
 
  芯片解密
  芯片解密
