sbus电路用8050搭一个就行,之前的都是标准库写的,这里用hal库移植了一下,亲测能用,一共有8路,做个遥控啥的可以用。
if(usart1_stop_flag==1)
{
usart1_stop_flag=0;
channel[0] = (((sbus[1] & 0x7) << 8) | sbus[0])*0.5+30;//*0.77+767;
channel[1] = (((sbus[2] & 0x3f) << 5) | (sbus[1] >> 3))*0.5+30;//*0.77+767;
channel[2] = (((sbus[4] & 0x1)<<10) | (sbus[3] << 2) | (sbus[2] >> 6))*0.261+279.27;//*0.77+767;
channel[3]= (((sbus[5] & 0xf) << 7) | (sbus[4] >> 1))*0.5+30;//*0.77+767;
channel[4]= (((sbus[6] & 0x7f) << 4) | (sbus[5] >> 4))*0.5+30;//*0.77+767;
channel[5]= (((sbus[8] & 0x2) << 9) | (sbus[7] << 1) | (sbus[6] >> 7))*0.5+30;//*0.77+767;
channel[6] = (((sbus[9] & 0x1f) << 6) | (sbus[8] >> 2))*0.5+30;//*0.77+767;
channel[7] = ((sbus[10] << 3) | (sbus[9] >> 5))*0.5+30;//*0.77+767;
printf("1=%d\t",channel[0]);
printf("2=%d\t",channel[1]);
printf("3=%d\t",channel[2]);
printf("4=%d\t",channel[3]);
printf("5=%d\t",channel[4]);
printf("6=%d\t",channel[5]);
printf("7=%d\t",channel[6]);
printf("8=%d\r\n ",channe
原理图:无
仿真:无
代码下载:
szg_at9s.7z
(5.6 MB, 下载次数: 14)
|