91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 12KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-25
  • 語言: 其他
  • 標簽: STM32??

資源簡介

SBUS串口中斷接收與轉換的代碼,SBUS數據幀轉成數值的規律。數值轉實際脈寬的擬合。

資源截圖

代碼片段和文件信息

#include?
#include??
#include?

#define?SBUS_INPUT_CHANNELS?16 //通道數
#define?RC_Lose 0 //遙控信號丟失
uint8_t?Sbus_Buff[25]; //串口接收緩存
uint16_t?Sbus_PWM?[16];


struct?sbus_bit_pick?{??
uint8_t?byte; //字節
uint8_t?rshift; //右移
uint8_t?mask; //掩碼
uint8_t?lshift; //左移
};

static?const?struct?sbus_bit_pick?sbus_decoder[SBUS_INPUT_CHANNELS][3]?=?{
//
/*??0?*/?{?{?0?0?0xff?0}?{?1?0?0x07?8}?{?0?0?0x00??0}?}
/*??1?*/?{?{?1?3?0x1f?0}?{?2?0?0x3f?5}?{?0?0?0x00??0}?}
/*??2?*/?{?{?2?6?0x03?0}?{?3?0?0xff?2}?{?4?0?0x01?10}?}
/*??3?*/?{?{?4?1?0x7f?0}?{?5?0?0x0f?7}?{?0?0?0x00??0}?}
/*??4?*/?{?{?5?4?0x0f?0}?{?6?0?0x7f?4}?{?0?0?0x00??0}?}
/*??5?*/?{?{?6?7?0x01?0}?{?7?0?0xff?1}?{?8?0?0x03??9}?}
/*??6?*/?{?{?8?2?0x3f?0}?{?9?0?0x1f?6}?{?0?0?0x00??0}?}
/*??7?*/?{?{?9?5?0x07?0}?{10?0?0xff?3}?{?0?0?0x00??0}?}
/*??8?*/?{?{11?0?0xff?0}?{12?0?0x07?8}?{?0?0?0x00??0}?}
/*??9?*/?{?{12?3?0x1f?0}?{13?0?0x3f?5}?{?0?0?0x00??0}?}
/*?10?*/?{?{13?6?0x03?0}?{14?0?0xff?2}?{15?0?0x01?10}?}
/*?11?*/?{?{15?1?0x7f?0}?{16?0?0x0f?7}?{?0?0?0x00??0}?}
/*?12?*/?{?{16?4?0x0f?0}?{17?0?0x7f?4}?{?0?0?0x00??0}?}
/*?13?*/?{?{17?7?0x01?0}?{18?0?0xff?1}?{19?0?0x03??9}?}
/*?14?*/?{?{19?2?0x3f?0}?{20?0?0x1f?6}?{?0?0?0x00??0}?}
/*?15?*/?{?{20?5?0x07?0}?{21?0?0xff?3}?{?0?0?0x00??0}?}
};




/**
??*?@brief??USART2?GPIO?配置工作模式配置。100000?8-N-1??SBUS
??*?@param??無
??*?@retval?無
??*/
void?USART2_Config(void)
{
GPIO_InitTypeDef?GPIO_InitStructure;
USART_InitTypeDef?USART_InitStructure;

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOAENABLE);
//USART2?RX
GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed=?GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin??=?GPIO_Pin_3;
GPIO_Init(GPIOA&GPIO_InitStructure);


//配置串口工作模式
USART_InitStructure.USART_BaudRate =?100000;
USART_InitStructure.USART_HardwareFlowControl?=?USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode?=?USART_Mode_Rx;
USART_InitStructure.USART_WordLength?=?USART_WordLength_9b;
USART_InitStructure.USART_Parity???=?USART_Parity_Even;
USART_InitStructure.USART_StopBits?=?USART_StopBits_2;
USART_Init(USART2?&USART_InitStructure);?
USART_ITConfig(USART2?USART_IT_RXNE?ENABLE);
USART_ITConfig(USART2?USART_IT_IDLE?ENABLE);
USART_Cmd(USART2?ENABLE);
}

/********************************S.BUS數值轉換***************************************************/
//轉換的到的數值是PWM脈寬*2000
uint8_t?Conversion_PWM()
{
?unsigned?char?channelpick;
for?(channel?=?0;?channel?

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????4576??2018-10-23?18:44??Sbus.c
?????文件?????????160??2018-10-23?18:44??Sbus.h
?????文件???????13792??2018-10-23?11:22??SBUS數值擬合.xls

評論

共有 條評論

相關資源