Commit Graph

109 Commits

Author SHA1 Message Date
Dominic Clifton d6c1ce323d BUGFIX - Warning LED / arm prevention code fixes.
The old code was using f.ACC_CALIBRATED to mean 'flash the warning led'
and 'prevent arming'
There was another flag called f.OK_TO_ARM which really meant 'prevent
arming after failsafe unless using a switch to arm' - this meant the
comment in the code was incorrect since it did not mention the switch.
There was code which every ~71 minutes would set f.ACC_CALIBRATED to
FALSE and would toggle the LED, even when flying.
There was code that was run during every cycle that did not need to be
run when armed.
There was code that was run during every cycle which did not need to be
run when waiting for calibration to finish.
The warning light was toggled regardless of actual accelerometer
calibration state.

This commit fixes all that and prevents the user from arming after a
failsafe landing until the system is reset, regardless of wether a
switch is used to arm or not.

This commit also flashes the warning led during barometer calibration
and will not let you arm until it has completed.

Add a 5 second delay on startup to failsafe to prevent failsafe from
activating in the case of TX/RX gear with long bind procedures before
they send out valid data.

Failsafe now only prevents re-arming if a landing was forced.

In the case when you power on your RX without your TX on the beeper
sounds and failsafe warning ligts are activated.  When the FC then
detects a signal the lights go off and you can then arm.
2014-05-22 22:46:54 +01:00
Dominic Clifton eb0beb70a9 Fix softserial loopback support compilation errors. 2014-05-21 20:06:53 +01:00
Dominic Clifton 5d460766e9 RXMSP is no longer a serial rx provider since it uses MSP and not it's
own dedicated serial port.
Added a feature to enable/disable RX_MSP.
Renamed feature SERIALRX to RX_SERIAL.
Renamed feature PARALLEL_PWM to RX_PARALLEL_PWM
Renamed PPM to RX_PPM.

Update serial configuration checking to better support Serial RX and
telemetry by verifiying serial port features and supported baud rates.

It's now possible to use a low-speed serial rx provider via softserial -
only problem is all the current serial rx providers are 100000/115200
baud.  The code changes however open the door for using serial rx and
any capable serial port such as uart3-5 on the STM32F30x

It's also now possible to use GPS at low speeds on software serial
ports.
2014-05-12 13:23:20 +01:00
Dominic Clifton 56d6e9012f Improvement - Ensure memory used only during system init is returned to
the heap.

This saves at least 18 bytes of ram.
2014-05-10 17:05:08 +01:00
Dominic Clifton 5c4bfd4e58 Configuration validation.
This enables a new feature setting for PARALLEL_PWM which is enabled by
default.

This starts to move much of the feature checking/excluding code that is
littered through into a single place - validateAndFixConfig().  Since
the config is known to be valid after the method is called other code
can just get on with it's job instead of checking for confliciting
features/settings.
2014-05-10 14:12:24 +01:00
Dominic Clifton 0fd127bf60 Allow the user to specify their serial port scenarios. 2014-05-10 14:11:01 +01:00
Dominic Clifton 1777d8feda First cut of configurable serial port functionality.
Currently port usage is hard-coded to the default port layout, cli
commands are coming in a future commit.

This decouples all code from the global 'serialPorts' structure which
has been removed.  Any code that needs to use a serial port can use
findOpenSerialPort() and openSerialPort() and maintain it's own
reference to the port.

Ports can switch between functions.  e.g. by default
cli/msp/telemetry/gps
passthrough all use USART1.  Each port maintains it's current function.
see begin/endSerialPortFunction.

There are only certain combinations of serial port functions that are
supported, these are listed in serialPortFunctionScenario_e.

This commit also adds a few 'static' keywords to variables that should
have been.

There a a few other minor fixes and tweaks to various bits of code that
this uncovered too.
2014-05-09 23:39:10 +01:00
Dominic Clifton 6704ba40b5 Decouple failsafe from RX drivers.
This removes a number of FIXMEs regarding driver dependencies on the
main code.

The code to verify pulse lengths is now in computeRC which means that
all RX drivers do not have to duplicate the pulse length checking code.

This means that failsafe can be used to validate serial RX providers as
well as PWM/PPM RX providers.
2014-05-08 13:28:14 +01:00
Dominic Clifton 10f3835491 CHEBUZZF3 - Use timer configuration that matches the hardware. 2014-05-08 01:28:31 +01:00
Dominic Clifton 6e00615baf Fix PPM/PWM code. 2014-05-06 13:37:07 +01:00
Dominic Clifton 6721587566 Split PWM code into appropriate separate files - mapping, rx and output.
By decoupling everything the structures now only contain members they need.  The mapping code is simplified.  The calculation of timer periods is now where it belongs (with the output code, not with the mapping code).  Also, since each motor output has it's own callback method it is technically possible to mix brushed and brushless motors if the brushed motors and brushless motors use different timers.  Additional code would be required to fully support that.
2014-05-06 11:08:45 +01:00
Dominic Clifton ee2140d324 Merge remote-tracking branch 'multiwii/master'
Conflicts:
	src/board.h
	src/drivers/adc_common.c
	src/drivers/pwm_common.c
	src/drivers/pwm_common.h
	src/main.c
	src/mw.c
	src/mw.h
	src/sensors.c
	src/utils.h
2014-05-03 22:50:57 +01:00
treymarc 9e8b05dc0e add serial_rx msp
Conflicts:

	Makefile
	src/board.h
	src/main.c
	src/mw.h
	src/serial_cli.c
2014-05-03 18:20:17 +01:00
Dominic Clifton 8be5e63faa Fix FY90Q build. 2014-05-02 21:30:29 +01:00
Dominic Clifton 89b9a0492f Cleanup OLIMEXINO softserial loopback support. 2014-05-02 21:17:18 +01:00
Dominic Clifton 92bed4a33d STM32F30x - Working parallel PWM. Timer IRQ handle was not defined for
TIM8 correctly. Software serial conficted with parallel PWM input. Fixed
crash due to incorrect timerConfig index calculation code.

The crash occurred when capture compare interrupt handlers attempted to
call an invalid callback.

Note: the crash does not affect existing baseflight code since the
formula is OK when using a 2 dimensional array with equal dimensions.

Formula details here:
https://docs.google.com/spreadsheets/d/1UuxnC0VKiprvt1wt3KXffefEWJUb_-ILFLQuP377Anw
2014-05-02 17:09:41 +01:00
dongie c1fcdabdc1 rearranged startup / sensor detection for production testing. moved dead gyro endless loop out of the way. 2014-05-02 18:27:23 +09:00
dongie cce4d4975d moved some of init logic around to get sensors + other important hardware checked first; added dummy implementation of production test for future use, outputting debug info over PB6 (USART1_TX remap) 2014-05-01 19:05:13 +09:00
treymarc ed46b4e4ac add serial_rx msp 2014-05-01 05:06:36 +02:00
Dominic Clifton 695db3523a Remove flight_mixer.c's dependency on mw.h/board.h.
This is a large commit, from the commit it is clear that the mixer has
many dependencies, this is expected since it is central to the
application.

To achieve the decoupling many master config and profile members had to
be moved into structures.

Relocated throttle/pitch curves into rc_curves.c/h since it has nothing
to with rx code, this fixed the dependencies inside the rx provider
files.
2014-04-24 00:18:24 +01:00
Dominic Clifton e4c9fb585c Merge remote-tracking branch 'multiwii/master'
Conflicts:
	obj/baseflight.hex
	src/config.c
	src/main.c
	src/mw.c
	src/mw.h
	src/serial_cli.c
2014-04-23 02:38:39 +01:00
dongie 5a05de5da7 fixing some typos and inconsistencies in cli/set variable naming. 2014-04-23 09:53:05 +09:00
Dominic Clifton 9d56b4a00f Remove sensor_initialisation.c's dependency on mw.h/board.h.
Extracted sensor alignment variables to sensorAlignmentConfig

This commit marks the end of the sensor dependency cleanup.
2014-04-23 00:41:21 +01:00
Dominic Clifton 9f26018abd Cleanup baro/mag/gyro/acc method names from old sensors.c 2014-04-22 02:43:39 +01:00
Dominic Clifton 7e76fd6995 Fix OLIMEXINO build (no-baro) 2014-04-22 02:07:11 +01:00
Dominic Clifton fe89d40fa0 Remove main.c's dependency on mw.h/board.h.
Moved pidControllers out of mw.c into flight_common.c/h.
Moved appropriate code into rc_controls.c/h.
2014-04-22 01:58:23 +01:00
Dominic Clifton 2c80094b0e Remove gps_common.c's dependencies on the mw.h/board.h.
Moved some GPS code from mw.c into gps_common.c.
Moved pid values into a pidProfile_t structure; this was done so that
gps_common.c does not have a dependency on config_profile.h.
pidProfile_t lives in flight_common.h now.
Moved gps profile settings from profile_t into gpsProfile_t for the same
reason.
Removed gps_common.c's dependency on masterConfig_t by passing needed
variables into gpsInit().
2014-04-22 00:37:35 +01:00
Dominic Clifton f8d0dd98f7 Split config_storage.h into config_master.h and config_profile.h to
separate concerns and help reduce and clarify dependencies.

cfg and mcfg are too similarly named and are not obvious.  Renamed cfg
to currentProfile and mcfg to masterConfig.  This will increase source
code line length somewhat but that's ok; lines of code doing too much
are now easier to spot.
2014-04-21 23:08:25 +01:00
Dominic Clifton 6c4caabfae Fixing failsafe initialisation, failsafe work as it did before
e969d184e6
2014-04-21 14:42:25 +01:00
Dominic Clifton a3d2a3df2d Merge remote-tracking branch 'multiwii/master'
Conflicts:
	obj/baseflight.hex
	src/config.c
	src/drivers/system_common.c
	src/main.c
	src/mw.h
	src/serial_cli.c
2014-04-21 12:35:44 +01:00
Dominic Clifton 8875aad776 rename sensor_t to acc_t and gyro_t and remove unused variables from
each.  relocated acc_t/gyro_t from sensors_common.h into
drivers/accgyro_common.h since they define an interface and the
dependency was pointing the wrong way from the drivers.
baro_t/acc_t/gyro_t dependences are all now pointing the right way.
2014-04-21 12:02:02 +01:00
dongie 9f107545e2 Merge pull request #78 from schugabe/overclock
Added overclock feature
2014-04-21 19:47:11 +09:00
Dominic Clifton bd95c38ff0 Cleanup EEPROM reset and validation methods so that it is obvious what
the code is doing.  There are now no EEPROM read/write/reset/verify
methods that take any arguments which removes magic boolean variables
from method signatures.

This also removes duplicate code in the cliDefaults and cliSave commands
which results in smaller code also also due to the deduplication of a
reboot message.
2014-04-21 01:36:06 +01:00
Dominic Clifton e969d184e6 decouple failsafe from the rest of the system.
Note: the pwm_common driver has a dependency on the main failsafe code,
the solution is probably to move some of the code into rx_pwm.
2014-04-21 00:46:16 +01:00
Dominic Clifton a7e4c859bd decouple cli/msp from each other. relocated non-msp code into
serial_common.c/h. decouple runtime_config from serial ports.  decouple
buzzer from serial ports.  decouple opening of the main serial port from
the msp code.  decouple serial rx providers from runtime_config.  rename
core_t to serialPorts_t since it only contained serial ports.  It's now
clear which files use serial ports based on the header files they
include.
2014-04-19 01:01:31 +01:00
Dominic Clifton 94c0f87c45 Remove useServos from core_t since it's only needed for initial startup
and by the mixer.  main.c now asks the mixer if it needs to use servos
and the mixer decides this in mixerInit().  Main already has a
dependency on the mixer.  This allows future commits to further clean up
core_t which is still a source of dependency problems.
2014-04-18 23:13:43 +01:00
Dominic Clifton be6ce96e5d Merge remote-tracking branch 'multiwii/master' into project-structure-alternative
Conflicts:
	src/mw.h
2014-04-18 19:45:30 +01:00
Dominic Clifton f68fc17627 Cleaned up RX initialisation. Updated Spektrum RX code to support 12
channels when using Spektrum 2048 - untested.  Renamed and extracted
core_t.numRCChannels to rxConfig.channelCount so that future commits can
clean up core_t further since core_t contains completely unrelated
properties.
2014-04-18 17:25:53 +01:00
Dominic Clifton a85bfa51e3 Remove config.c's dependencies on the mw.h/board.h files. Moved some RX
code into rx_common.c. Moved some GPS code into gps_common.c.  Isolated
some GPS functions into gps_common.c that were called from mw.c/loop().
moved gimbal defines into gimbal.h.  Moved sound & light code into
statusindicator.c
2014-04-18 12:13:37 +01:00
Dominic Clifton 8477b45061 Cleanup declarations of failsafeCnt so that it is only in failsafe.h and
failsafe.c.  Now it is clear from the list of includes that each
serialrx provider supports failsafe.
2014-04-18 00:37:03 +01:00
Dominic Clifton 6a9d38783c Fixing and unifying Serial RX initialisation. Destination arguments now
go last and each init method is passed the rxConfig.
2014-04-18 00:08:48 +01:00
Dominic Clifton 0f02e12f40 de-duplicate failsafe code. extract failsafe code to seperate files.
remove dependency on board.h and mw.h on a few files.

Moved rx configuration paramaters into rxConfig in order to remove the
dependency on config_t from the sbus rx code  - sumd/spektrum to follow.

Avoided use of YAW/PITCH/ROLL in some files since those constants are
from an unrelated enum type.

Replaced some magic numbers with constants to remove comments and
improve code readability.

Note, due to the tight coupling and global variable usage it was
difficult to create a smaller commit.
2014-04-17 23:02:22 +01:00
Dominic Clifton 41b5a01958 Decouple board alignment code. 2014-04-17 19:31:01 +01:00
Dominic Clifton 7e45a0c7e6 Fixing FY90Q build. Cleanup of printf support and initialisation.
Remove duplicate inclusion of math.h in board.h.
2014-04-17 17:37:43 +01:00
Dominic Clifton 89612bd881 De-couple battery code.
This fixes a bug where buzzerFreq could be uninitialised before it's
use.
This improves performance by only checking whether to sound the battery
alarm after the battery voltage has been recalculated.
There were unused battery beep codes which have been deleted to save
code size.
Configuration structure extracted from mw.h into config.h.
Moved mixer configuration structures into flight_mixer.h.
Added a build_config.c in order to decouple pwm_common.h from config.h.
Finally, battery configuration values now live in a batteryConfig
structure which means that battery.c does not depend on config.h and all
of it's dependencies.

Fixed the use of plurals on defines that were not collection objects.
PIDITEMS and CHECKBOXITEMS are now PID_ITEM_COUNT and
CHECKBOX_ITEM_COUNT.
2014-04-17 16:36:01 +01:00
Dominic Clifton 64d16e1987 Relocated used code from board.h into appropriate headers, deleted
unused code.
2014-04-17 15:02:41 +01:00
treymarc 6330456296 remove unnecessary var, inline accsum_reset, lrintf , rename smallAngle 2014-04-16 22:48:37 +00:00
Dominic Clifton 001de4cdf3 Move FY90q acc/gyro code to accgyro_fy90q.c. Update ADC drivers so they
do not include "board.h". It is now clear what all ADC drivers need to
compile and what was unnecessarily included before.

Note: FY90Q make target now compiles successfully, it was broken for
various reasons before.
2014-04-16 18:58:20 +01:00
Johannes Kasberger 385c4387b7 changed feature to set variable 2014-04-15 14:26:02 +02:00
Johannes Kasberger 5377b39f36 removed feature from driver 2014-04-15 09:19:19 +02:00