You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
969 B
62 lines
969 B
#include "stm32f10x.h" // Device header
|
|
#include <stdio.h>
|
|
#include "rs485.h"
|
|
//u8 rx_buf[64];
|
|
extern u8 RS485_RX_BUF_COPY[128];
|
|
void bufcut_Init(u8 *RX_BUF,u8 *CUT_RX_BUF,u8 start_index, u8 end_index)
|
|
{
|
|
int i, j = 0;
|
|
|
|
for (i = start_index; i < end_index; i++)
|
|
{
|
|
RX_BUF[j] = CUT_RX_BUF[i];
|
|
j++;
|
|
}
|
|
}
|
|
|
|
void RX_BUF_Init(void)
|
|
{
|
|
int i=0;
|
|
for(i=0;i<64;i++)
|
|
{
|
|
RS485_RX_BUF[i]=0;
|
|
}
|
|
|
|
}
|
|
|
|
void RX_BUF_ZERO(u8 num)//把处理过的数组变为0
|
|
{
|
|
for(int i=0;i<num;i++)
|
|
{
|
|
RS485_RX_BUF_COPY[i]=0;
|
|
}
|
|
|
|
}
|
|
|
|
void RX_BUF_Transfer(u8 zero,u8 transfer_num)//把未处理的数组转移到第一位
|
|
{
|
|
int i=0;
|
|
|
|
for (i = zero; i < 128 - transfer_num; i++)
|
|
{
|
|
RS485_RX_BUF_COPY[i] = RS485_RX_BUF_COPY[i + transfer_num];
|
|
}
|
|
for (i = 128 - transfer_num; i < 128; i++)
|
|
{
|
|
RS485_RX_BUF_COPY[i] = 0;
|
|
}
|
|
|
|
//RS485_RX_CNT -= transfer_num;
|
|
}
|
|
|
|
|
|
void RX_BUF_Printf(int num)
|
|
{
|
|
int i=0;
|
|
for(i=0;i<num;i++)
|
|
{
|
|
printf("%x ",RS485_RX_BUF[i]);
|
|
}
|
|
|
|
}
|