芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

飞芯科技-芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

stm32f103单片机自制飞控代码

单片机源程序如下:

  1. 芯片解密#include "sys.h"

  2. u8 report=0;                        //芯片解密默认开启上报
  3. int motor1,motor2,servo1,servo2;
  4. float Setpitch=0,Setroll=0;
  5. float pitch,roll,yaw;                 //芯片解密欧拉角
  6. short aacx,aacy,aacz;                //加速度传感器原始数据
  7. short gyrox,gyroy,gyroz;        //陀螺仪原始数据
  8. short temp;                                        //温度       
  9. int main(void)
  10. {       
  11.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);         //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
  12.         Usart_init();                 //串口初始化
  13.         delay_init();          //延时初始化 delay_ms(1000);
  14.         BEEP_GPIO_Init();
  15.         Motor_PWM_Init(20000-1, 72-1);
  16.         Servo_PWM_Init(20000-1, 72-1);
  17.         TIM2_Int_Init(100-1,720-1);
  18.         Motor_Unlock(1900,1100);
  19.         BEEP_GPIO_High();
  20.         FrSky_Uart2_Init(100000);
  21.         Adc_Init();
  22.         SPI1_Init();
  23.         SPL06_Init();
  24.         MPU_IIC_Init(); //MPU使用的IIC初始化
  25.         while(MPU_Init())
  26.         {
  27.                 printf("mpu error\n");
  28.                 delay_ms(200);
  29.         };                                        //初始化MPU6050
  30.        
  31.         while(mpu_dmp_init())
  32.         {
  33.                 printf("mpu dmp error\n");
  34.                 delay_ms(200);
  35.         }
  36.   PID_Init();
  37.         BEEP_GPIO_Low();

  38.         while(1)
  39.         {

  40.                 int i;
  41.                 static float Baro_Buf[20];
  42.                 Baro.Org_Alt = SPL06_Get_Altitude();
  43.                 //气压原始数据缓存
  44.     for(i=19;i>0;i--)
  45.     {
  46.         Baro_Buf[i]=Baro_Buf[i-1];
  47.     }
  48.     Baro_Buf[0]=Baro.Org_Alt;

  49. //                printf("%f\n",Baro.Org_Alt );
  50. //                delay_ms(100);
  51. /********测量电池电压********/
  52.                
  53.                 Get_Bat_Voltage();
  54.                 if(Bat_Voltage<11)
  55.                 {
  56.                         BEEP_GPIO_High();
  57.                 }
  58.                 else
  59.                 {
  60.                         BEEP_GPIO_Low();
  61.                 }
  62. //////                printf("电池电压为 %f \n",Bat_Voltage);
  63. ///**********陀螺仪数据输出***************/               
  64. if(mpu_dmp_get_data(&pitch,&roll,&yaw)==0)
  65. {
  66. //        printf("%f,%f,%f\r\n",pitch,roll,yaw);
  67.         temp=MPU_Get_Temperature();        //得到温度值
  68.         MPU_Get_Accelerometer(&aacx,&aacy,&aacz);        //得到加速度传感器数据
  69.         MPU_Get_Gyroscope(&gyrox,&gyroy,&gyroz);        //得到陀螺仪数据
  70.         if(report)mpu6050_send_data(aacx,aacy,aacz,gyrox,gyroy,gyroz);//用自定义帧发送加速度和陀螺仪原始数据
  71.         if(report)usart1_report_imu(aacx,aacy,aacz,gyrox,gyroy,gyroz,(int)(roll*100),(int)(pitch*100),(int)(yaw*10));

  72. }



联系方式

地址:石家庄市新华区民族路77号华强广场D座2009
电话:0311-88816616/87087811
手机:13315190088
传真:0311-67901001
联系人:张工
网址:www.feixindz.com
邮箱:feixindz@163.com
微信:xinpianjiemi
QQ:527263666/568069805

在线客服
热线电话

企业微信