Пример #1
0
void Uart1_Put_String(unsigned char *Str)
{
	//判断Str指向的数据是否有效.
	while(*Str)
	{
	//是否是回车字符 如果是,则发送相应的回车 0x0d 0x0a
	if(*Str=='\r')Uart1_Put_Char(0x0d);
		else if(*Str=='\n')Uart1_Put_Char(0x0a);
			else Uart1_Put_Char(*Str);
	//指针++ 指向下一个字节.
	Str++;
	}
}
Пример #2
0
void Send_AtitudeToPC()
{
	int _temp;
	uint8_t sum=0;
	UART1_Put_Char(0x88);
	UART1_Put_Char(0xAF);
	UART1_Put_Char(0x1c);
//发送姿态数据:
	_temp = (int)(Q_ANGLE.Pitch+200);
	sum += Uart1_Put_Char((unsigned char)(_temp>>8));
	sum += Uart1_Put_Char((unsigned char)(_temp&0x00ff));
	_temp = (int)(Q_ANGLE.Roll+200);
	sum += Uart1_Put_Char((unsigned char)(_temp>>8));
	sum += Uart1_Put_Char((unsigned char)(_temp&0x00ff));
  _temp = (int)(Q_ANGLE.Yaw+200);
	sum += Uart1_Put_Char((unsigned char)(_temp>>8));
	sum += Uart1_Put_Char((unsigned char)(_temp&0x00ff));
//发送电机数据:
	_temp =TIM2->CCR1/10;
	sum += Uart1_Put_Char((unsigned char)(_temp&0xff00)>>8);
	sum += Uart1_Put_Char((unsigned char)(_temp&0x00ff));
  _temp =TIM2->CCR2/10;
  sum += Uart1_Put_Char((unsigned char)(_temp&0xff00)>>8);
  sum += Uart1_Put_Char((unsigned char)(_temp&0x00ff));
  _temp = TIM2->CCR3/10;
  sum += Uart1_Put_Char((unsigned char)(_temp&0xff00)>>8);
  sum += Uart1_Put_Char((unsigned char)(_temp&0x00ff));
  _temp =TIM2->CCR4/10;
  sum += Uart1_Put_Char((unsigned char)(_temp&0xff00)>>8);
  sum += Uart1_Put_Char((unsigned char)(_temp&0x00ff));
	Uart1_Put_Char(sum);
}
Пример #3
0
void Uart_DataAnl(u8 buf_num)		//串口缓存数据分析
{
	if(Rx_Buf[buf_num][1]==0x8A)		//串口收到的是上位机的遥控数据
	{
		Uart1_Put_Char(0x30+buf_num);
	}
}
Пример #4
0
void Uart1_Send_Buf(u8 *buf,u8 len)		//发送buf,长度len,返回字节和sum
{
	while(len)
	{
		Uart1_Put_Char(*buf);
		buf++;
		len--;
	}
}
Пример #5
0
void Uart1_Send_RCdata(void)
{
	uint8_t sum = 0;
	sum += Uart1_Put_Char(0x88);
	sum += Uart1_Put_Char(0xAE);
	sum += Uart1_Put_Char(28);
	sum += Uart1_Put_Int16(Rc_Get.THROTTLE);
	sum += Uart1_Put_Int16(Rc_Get.YAW);
	sum += Uart1_Put_Int16(Rc_Get.ROLL);
	sum += Uart1_Put_Int16(Rc_Get.PITCH);
	sum += Uart1_Put_Int16(Rc_Get.AUX1);
	sum += Uart1_Put_Int16(Rc_Get.AUX2);
	sum += Uart1_Put_Int16(Rc_Get.AUX3);
	sum += Uart1_Put_Int16(Rc_Get.AUX4);
	sum += Uart1_Put_Int16(0);
	sum += Uart1_Put_Int16(0);
	sum += Uart1_Put_Int16(0);
	sum += Uart1_Put_Int16(0);
	sum += Uart1_Put_Int16(0);
	sum += Uart1_Put_Int16(0);
	Uart1_Put_Char(sum);
}
void PC_Debug_Show(u8 num,u16 sta)//sta=0 熄灭 sta=1 点亮  >1 取反
{
	static uint8_t led_s[6] = {0,0,0,0,0,0};
	uint8_t sum = 0;
	if(0<num && num<7)
	{
		sum += Uart1_Put_Char(0x88);
		sum += Uart1_Put_Char(0xAD);
		sum += Uart1_Put_Char(0x02);
		sum += Uart1_Put_Char(num);
		if(sta==0)
			sum += Uart1_Put_Char(0x00);
		else if(sta==1)
			sum += Uart1_Put_Char(0x01);
		else 
		{
			if(led_s[num])	led_s[num] = 0;
			else 			led_s[num] = 1;
			sum += Uart1_Put_Char(led_s[num]);
		}
		Uart1_Put_Char(sum);
	}
	else if(6<num && num<13)
	{
		sum += Uart1_Put_Char(0x88);
		sum += Uart1_Put_Char(0xAD);
		sum += Uart1_Put_Char(0x03);
		sum += Uart1_Put_Char(num);
		sum += Uart1_Put_Int16(sta);
		Uart1_Put_Char(sum);
	}
}