Commit Graph

1158 Commits

Author SHA1 Message Date
Andrew Tridgell
632e74b76d I2C: imported the I2C library from Wayne Truchsess
this gives us a more robust interface, including timeouts
2011-12-28 20:28:31 +11:00
Andrew Tridgell
f8e1d88815 TimerProcess: prevent a race in setting up the timer callbacks 2011-12-28 16:00:49 +11:00
Andrew Tridgell
089470a671 DataFlash: moved high level logging logic to library
this moves out all the high level logic from ArduPlane/ArduCopter to
the library. It also adds a "config page", as the last page in the
flash. This is used to check if the flash needs erasing. We only erase
now if the DF_LOGGING_FORMAT has changed.

This patch also adds a public CardInserted() method, which is used to
disable logging on APM2 if a dataflash card is not inserted
2011-12-28 16:00:48 +11:00
Andrew Tridgell
42eb62cc46 DataFlash: fixed sense of card detect 2011-12-28 16:00:48 +11:00
Andrew Tridgell
1cb8728a6b MPU6000: protect the driver from double initialisation
initialising twice can lockup the driver
2011-12-28 16:00:48 +11:00
Andrew Tridgell
f2bbfb1296 MPU6000: minor fixes
the hardware functions should be private, and cs_pin should be uint8_t
2011-12-28 16:00:48 +11:00
Andrew Tridgell
d35113f8a6 TimerProcess: check for duplicate registrations
if a driver gets initialised twice, make sure it doesn't get called
twice in the timer loop
2011-12-28 16:00:48 +11:00
Andrew Tridgell
0a08a0b515 TimerProcess: make some variables uint8_t
save a couple of bytes
2011-12-28 16:00:48 +11:00
Mike Smith
ac3f7512cc Fix issue #423 - FastSerial flush bug. 2011-12-26 15:52:21 -08:00
Andrew Tridgell
9f5718bcfa added in DataFlash.cpp
forgot this ....
2011-12-26 19:34:06 +11:00
Andrew Tridgell
887ff43e1f desktop: added attachInterrupt() support 2011-12-26 19:17:11 +11:00
Andrew Tridgell
22c8db774f desktop: fixed for new DataFlash inheritance 2011-12-26 19:17:11 +11:00
Andrew Tridgell
dd26ef3089 dataflash: reworked classes to move most code to parent class
this moves all the non-hardware specific code to the parent
DataFlash_Class class, keeping the hw specific code much smaller and
simpler.

This should prevent discrepancies creeping in between APM1 and APM2
support again
2011-12-26 19:17:11 +11:00
Andrew Tridgell
8bf05982ae dataflash: fixed APM2 flash logging
we had log wrap disabled on APM2, and also had the wrong log size. The
mainline code assumed 4096, but it is 8192 pages long.
2011-12-26 19:17:11 +11:00
Andrew Tridgell
df0d151891 MPU6000: change to 98Hz low pass filter
based on recommendation from Pat
2011-12-26 19:17:11 +11:00
Andrew Tridgell
3ef707a2c3 MPU6000: use data ready interrupt to prevent stale data
We listen for a data ready interrupt and only read new data in read()
if there is new data
2011-12-26 19:17:11 +11:00
Andrew Tridgell
71e08f8484 fixed the MPU6000 test sketch 2011-12-26 19:17:11 +11:00
Randy Mackay
af121c492d Merge remote-tracking branch 'origin/master' 2011-12-25 12:34:16 +09:00
Randy Mackay
c3ea1ca5dc AP_GPS - updated MTK rate to 10Hz and fixed lat/lon printing inaccuracy in Arducopter logs and AP_TEST example sketch 2011-12-25 12:33:06 +09:00
Andrew Tridgell
7c0f39aec5 added MPU6000 test sketch
this doesn't work yet - Pat, any idea why?
2011-12-25 12:03:39 +11:00
Andrew Tridgell
09c97bb367 removed dead test program
this one doesn't build, and has been replaced by IMU_MPU6000_test
2011-12-24 18:11:04 +11:00
Andrew Tridgell
f587a01165 ADC: update for new ap_proceduce prototype 2011-12-21 23:31:38 +11:00
Andrew Tridgell
5b75458502 AP_Baro: update MS5611 driver for new ap_proceduce prototype
this saves calling millis() quite so often
2011-12-21 23:31:38 +11:00
Andrew Tridgell
cef1c4c558 MPU6k: update driver for new ap_proceduce prototype 2011-12-21 23:31:38 +11:00
Andrew Tridgell
8cc2b7669b PeriodicProcess: added set_failsafe() call
this adds an optional failsafe function that will be called in the
timer loop
2011-12-21 23:31:38 +11:00
Andrew Tridgell
845683a56c added comment in polygon code 2011-12-21 23:31:38 +11:00
Andrew Tridgell
eac625ba8f rollover is not a bug
subtracting unsigned numbers does the right thing
2011-12-21 23:31:38 +11:00
Andrew Tridgell
eec5f000b5 added code format markers to AP_InertialSensor library 2011-12-21 23:31:38 +11:00
Andrew Tridgell
614aeb274c fixed build of IMU_MPU6000_test 2011-12-21 23:31:38 +11:00
Andrew Tridgell
b52cd45670 fixed comment 2011-12-19 20:52:59 +11:00
Andrew Tridgell
7c9c26e2b7 AP_Math: re-work polygon algorithm for perfect precision
using sign checking and 64 bit integer math only when needed results
in an algorithm that is just as fast as the floating point version,
but has perfect results for any representable lat/lng
2011-12-19 18:52:56 +11:00
Randy Mackay
a51e868766 AP_RangeFinder - change sonar example sketch to use default Sonar PIN for APM2 (A1) 2011-12-18 14:15:50 +09:00
Andrew Tridgell
7442ba31d8 polygon: improve the speed and precision of the polygon algorithm
now takes 156 usec per test, with a 11 point boundary
2011-12-18 12:59:50 +11:00
Michael Oborne
3848f2094e make file relax 2011-12-17 20:42:51 +08:00
Michael Oborne
fd35ba5976 add relax 2011-12-17 16:53:14 +08:00
Andrew Tridgell
0c8c707980 AP_Baro: fixed temperature on MS5611
this caused a 2x scaling of altitude
2011-12-17 14:58:58 +11:00
Andrew Tridgell
3654c714e9 Revert "ADC: only read channels that are actually being used"
This reverts commit 95e6bb26f4772ca8c7faa62215de6f078d3df3c7.

ADC will be disabled on APM2
2011-12-17 07:29:09 +11:00
Andrew Tridgell
c18ad75504 Revert "ADC: added an enable_channel() API"
This reverts commit dafeac01d8f14162600cf821404ba4072dcae14d.

ADC will be disabled on APM2
2011-12-17 07:29:09 +11:00
Andrew Tridgell
f6a7ad9fa6 Revert "ADC: fixed HIL build"
This reverts commit 86c1a6a5fdd929516cf0f64f4d610cfcd4b4f774.

ADC will now be disabled on APM2
2011-12-17 07:29:09 +11:00
Andrew Tridgell
7c939e83e0 AnalogSource: return a float from read() method
this gives the full resolution when using the ADC backend. It also
adds scaling for the Arduino backend
2011-12-17 07:29:09 +11:00
Andrew Tridgell
4bbd5392ef removed AperiodicProcess code
this code was never being used, and was more complex than it was
worth.
2011-12-17 07:29:09 +11:00
Andrew Tridgell
04ec569313 ADC: fixed HIL build 2011-12-16 20:58:04 +11:00
Andrew Tridgell
658d1d2ba3 added missing mavlink headers 2011-12-16 20:53:26 +11:00
Andrew Tridgell
1ab2b416a3 geofence: store fence points as int32_t
this keeps maximum precision in fence boundaries
2011-12-16 20:11:51 +11:00
Andrew Tridgell
2e2b320560 mavlink: include latest geofence message changes 2011-12-16 20:11:51 +11:00
Andrew Tridgell
3ddfc6664a AP_Math: better polygon algorithm
this one seems to do better with single precision floating point
2011-12-16 20:11:51 +11:00
Andrew Tridgell
686f96414c MAVLink: update to latest mavlink XML
this includes the geo-fencing messages
2011-12-16 20:11:51 +11:00
Andrew Tridgell
c56e5735c2 ADC: added an enable_channel() API
enable_channel() must be used before the Ch6() method is called to
enable gathering of data on the required channels
2011-12-16 20:09:40 +11:00
Andrew Tridgell
be1ba5354e timer: enable interrupts during timer processing
this prevents us losing serial bytes when we call sensor drivers that
take more than 100usec to read.

We also prevent timer recursion by re-enabling the timer after all
callbacks are complete
2011-12-16 20:09:38 +11:00
Andrew Tridgell
af7e34fcc1 ADC: only read channels that are actually being used
on the APM2 we usually use none of the ADC channels, although we may
use the airspeed sensor. This change means we detect which channels
are being read, and only do the SPI transfers for those ones. That
saves us about 100usec per timer interrupt (ie. about 10% of our CPU)
2011-12-16 20:09:35 +11:00
Andrew Tridgell
9e9b229a1d fixed formatting of ADC driver
it was a nasty mix of DOS and UNIX
2011-12-16 20:09:29 +11:00
Andrew Tridgell
5b4717ea55 timers: change to 1kHz timer by default
we were using a 227Hz timer, which is far too slow
2011-12-16 20:09:25 +11:00
Andrew Tridgell
6ad5df2958 desktop: fixed type of dword eeprom read 2011-12-16 20:09:18 +11:00
Andrew Tridgell
338fb1642a AP_Math: make out vector and matrix elements used types with fixed sizes
this prevents differences between CPU types
2011-12-16 20:09:11 +11:00
Pat Hickey
291aaffdd9 APM_RC_APM2: Remove OutputCh from ::Init()
* These calls were off by one anyway, by using the channel numbers
  as ints ant not CH_n macros, and that caused an ESC cal problem.
2011-12-15 13:47:43 -08:00
Andrew Tridgell
f4bd3cb5a2 AP_Math: added Polygon_complete() function
used to veryify user supplied boundaries
2011-12-15 14:42:34 +11:00
Andrew Tridgell
cd9fb3c47a AP_Math: added a Polygon_outside() function
this tests if a point is outside of a polygon. This will be used as
part of our geo-fencing support, and also for a new 'fenced mode'
2011-12-15 14:34:58 +11:00
Andrew Tridgell
621f21e4f5 DCM: added matrix_reset() method 2011-12-13 21:32:50 +11:00
Andrew Tridgell
919ae17473 IMU: abstract the setting of the LEDs in IMU initialisation
we need this to cope with different LED pin assignments on APM1/APM2
2011-12-13 18:19:12 +11:00
Andrew Tridgell
9548366a91 autotest: make magnetic field point down 2011-12-12 22:14:01 +11:00
Andrew Tridgell
fa83de98c8 desktop: fixed build with new AP_Baro code 2011-12-12 15:14:55 +11:00
Andrew Tridgell
eaf134e47e desktop: fixed desktop barometer code 2011-12-12 15:14:55 +11:00
Andrew Tridgell
de5c1c5147 barometer: fixed HIL barometer build 2011-12-12 15:14:55 +11:00
Andrew Tridgell
47da2ec992 ADC: change adc.Ch() to return a float
this gives us a bit more precision in airspeed measurement, and costs
us virtually nothing as we are converting to float immediately after
getting the value
2011-12-12 15:14:55 +11:00
Andrew Tridgell
43a53aa303 dcm: fixed an uninitialised variable
if no compass and not in motion the DCM we would multiply by an
uninitialised number
2011-12-11 15:21:10 -08:00
Pat Hickey
5819f99986 AP_Baro_MS5611: Asynchronous operation, plus c++ style changes.
Yeah, I know this was a big change to make all at once.
2011-12-11 15:21:10 -08:00
Pat Hickey
3d882c4d49 AP_Baro : Add init( AP_PeriodicProcess * ) method to interface & implementations
AP_Baro_MS5611 and AP_Baro_BMP085 implement the interface, with stubs only
2011-12-11 15:21:10 -08:00
Pat Hickey
d5386b8bb8 AP_Baro_BMP085: move apm2_hardware flag from init to constructor. 2011-12-11 15:21:10 -08:00
Pat Hickey
6710cf5c5a Wire and SPI Init: move to sketch system.pde from libraries
* Wire.begin removed from AP_Baro_BMP085::init()
* SPI.begin  removed from AP_Baro_MS5611::init()
* SPI.begin  removed from AP_InertialSensor_MPU6000::hardware_init()

* Both Wire.begin and SPI.begin added very early in init_ardupilot in
  ArduCopter/system.pde and ArduPlane/system.pde
2011-12-11 15:21:10 -08:00
Pat Hickey
a7b9c8b9cd AP_PeriodicProcess: AP_TimerProcess can register multiple callbacks. 2011-12-11 15:21:10 -08:00
Pat Hickey
12222550cf AP_Baro_BMP085: Delete commented out code
* If its important to get old code back, thats why version control exists
2011-12-11 15:21:09 -08:00
Pat Hickey
9a9b63259a AP_Baro_BMP085: implement AP_Baro interface 2011-12-11 15:21:09 -08:00
Pat Hickey
45cbb24ba5 AP_Baro_MS5611: init must also perform SPI.begin 2011-12-11 15:21:09 -08:00
Pat Hickey
a75257f102 AP_Baro_MS5611: CS pin is arduino pin 40 2011-12-11 15:21:09 -08:00
Pat Hickey
7b708f8054 AP_Baro_MS5611: Implement AP_Baro interface 2011-12-11 15:21:09 -08:00
Pat Hickey
41ecb0fef4 AP_Baro_BMP085: Conform to AP_Baro interface. Make the rest private. 2011-12-11 15:21:09 -08:00
Pat Hickey
264cb1a26e AP_Baro_MS5611: conform to AP_Baro interface 2011-12-11 15:21:09 -08:00
Pat Hickey
c3aab6af83 AP_Baro: Create virtual interface 2011-12-11 15:21:09 -08:00
Pat Hickey
84cb023b12 AP_Baro_MS5611: renamed class implementation from APM_MS5611 2011-12-11 15:21:09 -08:00
Pat Hickey
3d93eb9534 AP_Baro_MS5611.h: reorganized
* moved ms5611 macros to c file
* reorganized class declaration & retabbed
* made Temp, Pres, and Alt private variables.
2011-12-11 15:21:09 -08:00
Pat Hickey
8f16b736a4 AP_Baro_MS5611: Overwrote with Jose Julio's latest files. 2011-12-11 15:21:09 -08:00
Pat Hickey
f5720be81f AP_Baro: Export AP_Baro_BMP085 and AP_Baro_BMP085_HIL headers. 2011-12-11 15:21:09 -08:00
Pat Hickey
e8e4881da8 AP_Baro_BMP085(+_HIL): Rename classes from APM_BMP085 to AP_Baro_BMP085. 2011-12-11 15:21:09 -08:00
Pat Hickey
917418994d BMP085 fix line endings 2011-12-11 15:21:09 -08:00
Pat Hickey
7b51a2c42a AP_Baro: move all APM_BMP085 files inside AP_Baro 2011-12-11 15:21:09 -08:00
Pat Hickey
cca6b2f98c Added AP_Baro and AP_Baro_MS5611 classes.
Incomplete and does not work.
2011-12-11 15:21:08 -08:00
Randy Mackay
62a7b19600 Arducopter, RangeFinder - added SONAR_TYPE parameter and properly support the XL (default), LV and long distance XL (aka XLL) sonar types 2011-12-11 16:40:59 +09:00
Pat Hickey
e992b2e2a2 APM_RC: APM1 fast output speed increased to 400hz. 2011-12-10 13:06:06 -08:00
Pat Hickey
733000583d APM_RC: APM2 fast output speed increased to 400hz. 2011-12-10 13:04:11 -08:00
Pat Hickey
8a0c6eba78 AP_IMU_INS: Eliminate init_accel from cold start.
* Bug reported by Jason, 10 Dec 11
2011-12-10 13:00:54 -08:00
Randy Mackay
f4ac36bd8b ArduCopter - removed limitation on Maxbotix sonar type requiring ADC so it can work with APM2.
modified default analog pin in test sketch to be AN4 which is consistent with APM2 default
2011-12-10 18:33:30 +09:00
Randy Mackay
11aad8817c RangeFinder - fixed example sketch so it works again 2011-12-10 16:32:34 +09:00
Randy Mackay
ffb4492c16 RangeFinder - small bug fix to initialise prescale variable.
Fixed up example sketch so it compiles and works again!
2011-12-10 16:25:41 +09:00
James Goppert
8ef704face Merge branch 'master' of https://code.google.com/p/ardupilot-mega 2011-12-07 20:59:15 -05:00
Jason Kemmerling
d6c904f398 Fixed along track bug. 2011-12-07 20:55:06 -05:00
James Goppert
87dec93974 Added APM2 support. 2011-12-07 19:19:30 -05:00
James Goppert
87735bcc9f Added AP_Board to APO 2011-12-07 16:31:56 -05:00
Jason Short
98a26d19e6 Split P and I term 2011-12-06 21:10:30 -08:00
Jason Short
ae917f9e71 Split the P and I terms in PI 2011-12-06 21:08:47 -08:00
Wenyao Xie
f371453159 APO velocity/ altitude working. 2011-12-06 19:38:23 -05:00