资源简介
很好的无人机飞控源码,无人机爱好者的福音
代码片段和文件信息
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// + Copyright (c) 04.2007 Holger Buss
// + only for non-profit use
// + www.MikroKopter.com
// + see the File “License.txt“ for further Informations
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#include
#include
#include
#include “analog.h“
#include “main.h“
#include “timer0.h“
#include “fc.h“
#include “printf_P.h“
#include “eeprom.h“
#include “twimaster.h“
volatile int16_t Current_AccZ = 0;
volatile int16_t UBat = 100;
volatile int16_t AdValueGyrNick = 0 AdValueGyrRoll = 0 AdValueGyrYaw = 0;
uint8_t AnalogOffsetNick = 115 AnalogOffsetRoll = 115 AnalogOffsetYaw = 115;
uint8_t GyroDefectNick = 0 GyroDefectRoll = 0 GyroDefectYaw = 0;
volatile int16_t AdValueAccRoll = 0 AdValueAccNick = 0 AdValueAccTop = 0;
volatile int32_t AirPressure = 32000;
volatile uint8_t average_pressure = 0;
volatile int16_t StartAirPressure;
volatile uint16_t ReadingAirPressure = 1023;
int8_t ExpandBaro = 0;
uint8_t PressureSensorOffset;
volatile int16_t HeightD = 0;
volatile uint16_t MeasurementCounter = 0;
/*****************************************************/
/* Initialize Analog Digital Converter */
/*****************************************************/
void ADC_Init(void)
{
uint8_t sreg = SREG;
// disable all interrupts before reconfiguration
cli();
//ADC0 ... ADC7 is connected to PortA pin 0 ... 7
DDRA = 0x00;
PORTA = 0x00;
// Digital Input Disable Register 0
// Disable digital input buffer for analog adc_channel pins
DIDR0 = 0xFF;
// external reference adjust data to the right
ADMUX &= ~((1 << REFS1)|(1 << REFS0)|(1 << ADLAR));
// set muxer to ADC adc_channel 0 (0 to 7 is a valid choice)
ADMUX = (ADMUX & 0xE0) | 0x00;
//Set ADC Control and Status Register A
//Auto Trigger Enable Prescaler Select Bits to Division Factor 128 i.e. ADC clock = SYSCKL/128 = 156.25 kHz
ADCSRA = (1< //Set ADC Control and Status Register B
//Trigger Source to Free Running Mode
ADCSRB &= ~((1 << ADTS2)|(1 << ADTS1)|(1 << ADTS0));
// Enable AD conversion
ADC_Enable();
// restore global interrupt flags
SREG = sreg;
}
void SearchAirPressureOffset(void)
{
uint8_t off;
off = GetParamByte(PID_PRESSURE_OFFSET);
if(off > 20) off -= 10;
OCR0A = off;
ExpandBaro = 0;
Delay_ms_Mess(100);
if(ReadingAirPressure < 850) off = 0;
for(; off < 250;off++)
{
OCR0A = off;
Delay_ms_Mess(50);
printf(“.“);
if(ReadingAirPressure < 850) break;
}
SetParamByte(PID_PRESSURE_OFFSET off);
PressureSensorOffset = off;
Delay_ms_Mess(300);
}
void SearchGyroOffset(void)
{
uint8_t i ready = 0;
GyroDefectNick = 0; GyroDefectRoll = 0;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9889 2009-01-05 21:53 V0.71h Code Redesign killagreg\analog.c
文件 1014 2009-01-05 21:53 V0.71h Code Redesign killagreg\analog.h
文件 16285 2009-01-05 21:53 V0.71h Code Redesign killagreg\eeprom.c
文件 6236 2009-01-05 21:53 V0.71h Code Redesign killagreg\eeprom.h
文件 60324 2009-04-26 13:53 V0.71h Code Redesign killagreg\fc.c
文件 3446 2009-01-05 21:53 V0.71h Code Redesign killagreg\fc.h
文件 499 2009-01-05 21:53 V0.71h Code Redesign killagreg\fifo.c
文件 2075 2009-01-05 21:53 V0.71h Code Redesign killagreg\fifo.h
文件 833 2009-01-05 21:53 V0.71h Code Redesign killagreg\flight.pnproj
文件 64 2009-01-05 21:53 V0.71h Code Redesign killagreg\flight.pnps
文件 8598 2009-01-05 21:53 V0.71h Code Redesign killagreg\FlightCtrl.aps
文件 12409 2009-01-05 21:53 V0.71h Code Redesign killagreg\gps.c
文件 109 2009-01-05 21:53 V0.71h Code Redesign killagreg\gps.h
文件 1519 2009-01-05 21:53 V0.71h Code Redesign killagreg\led.c
文件 377 2009-01-05 21:53 V0.71h Code Redesign killagreg\led.h
文件 4745 2009-01-05 21:53 V0.71h Code Redesign killagreg\License.txt
文件 9981 2009-01-05 21:53 V0.71h Code Redesign killagreg\main.c
文件 913 2009-01-05 21:53 V0.71h Code Redesign killagreg\main.h
文件 12957 2009-01-05 21:53 V0.71h Code Redesign killagreg\makefile
文件 9298 2009-01-05 21:53 V0.71h Code Redesign killagreg\menu.c
文件 330 2009-01-05 21:53 V0.71h Code Redesign killagreg\menu.h
文件 2323 2009-01-05 21:53 V0.71h Code Redesign killagreg\mk3mag.c
文件 352 2009-01-05 21:53 V0.71h Code Redesign killagreg\mk3mag.h
文件 14346 2009-01-05 21:53 V0.71h Code Redesign killagreg\mm3.c
文件 581 2009-01-05 21:53 V0.71h Code Redesign killagreg\mm3.h
文件 4258 2009-01-05 21:53 V0.71h Code Redesign killagreg\mymath.c
文件 263 2009-01-05 21:53 V0.71h Code Redesign killagreg\mymath.h
文件 726 2009-01-05 21:53 V0.71h Code Redesign killagreg\old_macros.h
文件 13755 2009-01-05 21:53 V0.71h Code Redesign killagreg\printf_P.c
文件 555 2009-01-05 21:53 V0.71h Code Redesign killagreg\printf_P.h
............此处省略22个文件信息
- 上一篇:阿里云DDNS动态域名服务
- 下一篇:dul 8910 三个版本
评论
共有 条评论