+commit 7904b36eaae2468d76f2627bebd86b663afea1f8
+Merge: 8970d45e 4e237bd4
+Author: Bdale Garbee <bdale@gag.com>
+Date: Sun May 29 21:07:44 2022 -0600
+
+ Merge branch 'master' into branch-1.9
+
+commit 4e237bd43fef1858f88ff8f8750759e16442ea7e
+Author: Keith Packard <keithp@keithp.com>
+Date: Sun May 29 17:50:47 2022 -0700
+
+ Version 1.9.11
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 922a6e4f5c79fe46c1dca4df42c1c97e67dc7d68
+Author: Keith Packard <keithp@keithp.com>
+Date: Sun May 29 17:48:01 2022 -0700
+
+ doc: Update copyrights to 2022
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 019884004098adfc6e9f285d127a791f4204b180
+Author: Keith Packard <keithp@keithp.com>
+Date: Sun May 29 17:47:41 2022 -0700
+
+ doc: Add release notes for 1.9.11
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit ce3e42c286755f3c4e1ee6dedc87e15a76343a37
+Author: Keith Packard <keithp@keithp.com>
+Date: Sun May 29 17:46:43 2022 -0700
+
+ doc: Document 10mw limit configuration
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit d2ec815a17e9327414bab7ea09ed483c4f47f460
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri May 20 16:20:13 2022 -0700
+
+ src: Add easymini-v3.0
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit d95995ec702a891884f353cf2078d7ed3261c5c2
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri May 20 16:20:32 2022 -0700
+
+ lpc: Make beeper configurable
+
+ Need to set the port, pin, timer and channel values
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 03753fbddfbc82f18b2e4527a2e3afc58ea972f4
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri May 20 16:41:19 2022 -0700
+
+ lpc: ADC 5 was busted
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 6edf62c6a1f41fa5cd698067d2327b4847708cc8
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed May 4 17:06:36 2022 -0700
+
+ ao-tools/ao-eeprom: Dump converted info for F packets
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 0e4fb5c9bc33bb6d2a337f89daec4e6bb94cd8d8
+Author: Bdale Garbee <bdale@gag.com>
+Date: Tue Apr 12 11:13:44 2022 -0600
+
+ doc: add an appendix with examples for configurable pyro channels
+
+commit c49bd3cb0c31a51fae79ddc92237cc309be9a242
+Merge: d225adc3 b140da92
+Author: Bdale Garbee <bdale@gag.com>
+Date: Wed Apr 6 22:51:13 2022 -0600
+
+ Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
+
+commit b140da92536d7c48ba37868f1c2afce7bb86dfdb
+Merge: 1d208c95 302e9b8f
+Author: Bdale Garbee <bdale@gag.com>
+Date: Tue Apr 5 17:55:06 2022 -0600
+
+ Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
+
+commit 1d208c9509f03f7e2c913abe5c0dd78ef0083c0f
+Author: Bdale Garbee <bdale@gag.com>
+Date: Tue Apr 5 17:54:32 2022 -0600
+
+ use correct test script for v1.0 easymega
+
+commit 302e9b8fda7b36e5009044086737b7791f81addd
+Author: Keith Packard <keithp@keithp.com>
+Date: Mon Apr 4 14:40:37 2022 -0700
+
+ telegps-v0.3: Reduce stack size to fit in ram
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit ad23f26709b822c6d30f7160ffb2f2f51a8af4ce
+Author: Keith Packard <keithp@keithp.com>
+Date: Sun Feb 27 16:10:30 2022 -0800
+
+ ao-telem: Read from stdin if no filenames
+
+ Make ao-telem work as a filter if no filenames are passed on the
+ command line.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit d225adc3af9e5726d436cbbdbf8dcc5837e50804
+Merge: 3759d670 85dd82b2
+Author: Bdale Garbee <bdale@gag.com>
+Date: Mon Apr 4 01:22:04 2022 -0600
+
+ Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
+
+commit d0160ed97b432d59e2111d8b17580b9a83e0b03b
+Author: Bdale Garbee <bdale@gag.com>
+Date: Fri Feb 25 22:11:17 2022 -0700
+
+ dial it down a bit more to not exceed +10 dBm, or 10 mW
+
+commit 3e7661761f6ea81b6a9732359edf4c5ada3e8e20
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Feb 25 15:43:15 2022 -0800
+
+ Allow TX power to be limited to 10mW
+
+ This allows the radio power to be limited so that it doesn't generate
+ more than 10mW.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 58a0a242f31ebe4532564f5c04162e8fb82f9aeb
+Author: Keith Packard <keithp@keithp.com>
+Date: Mon Feb 21 09:40:07 2022 -0800
+
+ Version 1.9.10.4
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 57a6f844e2490a963ce1ef3a2beb9e47258967af
+Author: Keith Packard <keithp@keithp.com>
+Date: Mon Feb 21 09:43:54 2022 -0800
+
+ altos: Document how delay_done is used in ao_pyro.c
+
+ delay_done is the time at which the delay finishes, but non-zero
+ values also indicate that some delay is pending. Add a comment about
+ why the value is set to 1 when it is zero, and switch the tests of
+ this value to comparisons against zero.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit d29047255c8e78d4ab2beeef678d466a6bfc0ae2
+Author: Keith Packard <keithp@keithp.com>
+Date: Sat Feb 19 15:35:31 2022 -0800
+
+ altos: Deal with 8-character version numbers
+
+ With 8 characters, the version number isn't null-terminated, so we
+ need to limit use to the available length in a couple of places.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 76358fb6e68c1f466e4d76a291f60e1053aa50d0
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 21:48:01 2022 -0800
+
+ altos: Add -Wconversion
+
+ This adds the -Wconversion flag to detect potential mistakes in
+ implicit type conversion.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 48971ced7999b7d1265be967b971ccb9555ce40e
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 21:46:57 2022 -0800
+
+ altos/telemega-v5.0: Add casts to beep values
+
+ Need to be careful with types to make sure the math doesn't overflow.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 8d53868e67b51d8908e55c6a2e7a3b687529957d
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 21:46:07 2022 -0800
+
+ ao_lco_v2: Add casts to reduce -Wconversion warnings
+
+ No bugs identified
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 2f06b7c66dfa05c51d8b2afbc1e3c94e20767e4f
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 21:44:52 2022 -0800
+
+ ao_lco_v2: Use int32_t for temporary box value in step_box
+
+ Stepping to the next box will generate negative values and values
+ beyond the highest box number. Use a type capable of holding all of
+ those values, instead of int16_t.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit d2f84f860917f88a34571b8b0f64d03adf5c8f54
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 21:42:50 2022 -0800
+
+ telefireone-v1.0: Use a boolean value for ao_log_running
+
+ Instead of reading a hex value and saving it directly, use
+ zero/none-zero to compute a boolean instead, avoiding a type
+ conversion warning.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 52e9443d540aa5d3f29576a0440149b1b0f9c359
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 21:41:44 2022 -0800
+
+ altos/telefire: Add cast to AO_LED_CONTINUITY to eliminate -Wconversion warning
+
+ All of these products had the same warning.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 877d4643b45ca2099f602390b71e1c77d5e11ef1
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 21:38:25 2022 -0800
+
+ altos/stmf0: Add casts to reduce -Wconversion warnings. Use AO_TICK_TYPE
+
+ No bugs identified. Serial timeout types updated to AO_TICK_TYPE.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 2d4484e1577edc66c52bcb260329387f93123a6d
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 21:34:37 2022 -0800
+
+ altos/stm32l0: Add casts to reduce -Wconversion warnings
+
+ No bugs identified
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 5b3a457f232e39977a437fc52256fc15c612b377
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 21:32:07 2022 -0800
+
+ altos/stm: Add casts to reduce -Wconversion warnings
+
+ No bugs identified
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 709666e00339be7b12730c1f4d35721db292f815
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 17:53:41 2022 -0800
+
+ ao_micropeak.c: Add casts to reduce -Wconversion warnings
+
+ No bugs identified
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 63fc45973ec92bf3ef7122da0f76d6e111ecd342
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 17:53:11 2022 -0800
+
+ ao_flash_task: Add casts to reduce -Wconversion warnings
+
+ No bugs identified
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 7c5b9b2c6bf57aea4332177e7fb0eb2d490f4f6e
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 17:52:11 2022 -0800
+
+ altos/micropeak-v2.0: Add casts to reduce -Wconversion warnings
+
+ No bugs identified
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit e80a45c1565b14479e3a4cfc968d49b13cef4fe0
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 17:49:42 2022 -0800
+
+ altos/lpc: Add casts to reduce -Wconversion warnings
+
+ Most of these were caused by int/long mixes as uint32_t is 'long' on
+ arm for reasons, meaning that bare int constants need to be cast to
+ avoid a warning.
+
+ No bugs identified.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit f2c02cac5442015fee14f88ee016c687c53d8576
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 17:38:56 2022 -0800
+
+ ao_tracker: Fix tracker_interval type to match config type (plus -Wconversion)
+
+ config.tracker_interval is uint8_t, so make the local copy match that
+ type.
+
+ Also fix other warnings found by -Wconversion.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 63c089e2e110a7fe501dd097bd7d26ce4feeb935
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 17:36:12 2022 -0800
+
+ ao_telemetry: Add casts to reduce -Wconversion warnings
+
+ No bugs noted
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit a2505dc4be4a368911533d42d6344ad03b220468
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 17:34:41 2022 -0800
+
+ ao_telemetry: Use int16_t types for telemetry packet intervals
+
+ This avoids concerns about overflow from int8_t types when computing
+ long intervals between packets as the base interface type was an
+ int16_t. This should help deal with higher sample rate sensors when
+ that occurs.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 86bd5f53ba4b13df502ec1bc70512f30cac94010
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:49:48 2022 -0800
+
+ ao_telemetry: Switch time variables to AO_TICK_TYPE
+
+ This makes sure telemetry packet intervals are computed correctly.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit b10049d847fac855b1139d6441de853641b7365b
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:44:03 2022 -0800
+
+ ao_task: Task ids are 8-bits, fix type in struct ao_task
+
+ These are densely allocated and should never be larger than the
+ maximum number of task slots, so fix the type to be 8-bits just like
+ all other places where a task_id is used.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 55ca3cb64e19664e5ffc19d6ff92f46e4252f3b8
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:40:19 2022 -0800
+
+ ao_serial: Change serial_sleep_for APIs to use AO_TICK_TYPE
+
+ These timeouts should all be short, but there's no reason to use a
+ different type.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 8a95afdd417119da6089403f870959a726b0c548
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:39:45 2022 -0800
+
+ kalman, report, romconfig, sample, send_packet: Clean up -Wconversion warnings
+
+ No bugs detected
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 8275b761d182ec587104f084f331d7c2ebc2d1e6
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:35:18 2022 -0800
+
+ ao_monitor: Clean up -Wconversion warnings
+
+ No bugs detected
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit b5962ab4f804df3145481a54b00fed27561f8725
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:33:12 2022 -0800
+
+ ao_radio_cmac_cmd: Clean up types for -Wconversion
+
+ Use more reasonable types for lengths and the like to avoid
+ overflows. No actual bugs detected.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit acc642801aa5f8c0c05bde134e5924fe957ce023
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:31:09 2022 -0800
+
+ ao_radio_cmac: Make recv timeouts AO_TICK_TYPE
+
+ While these should generally be short enough to live in a 16-bit type,
+ use AO_TICK_TYPE for consistency.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit f385aabe458ed162fa8b45afc433ee5de8bb7b60
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:18:49 2022 -0800
+
+ ao_micro: Add casts to micropeak code for -Wconversion warnings
+
+ No bugs detected
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit b123c095384b57446d45d8678dff5448a7c659e4
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:12:47 2022 -0800
+
+ ao_log: Add casts to reduce -Wconversion warnings
+
+ No bugs noted here.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 0b870641ff0299b973de815523bdfd3db5be8bbf
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:11:07 2022 -0800
+
+ ao_log: Fix sensor time triggers to use AO_TICK_TYPE
+
+ These values were used to determine when various log information would
+ be recorded. Using the wrong type meant that they would always
+ trigger, causing the log to fill up rapidly with data that should be
+ sampled at a lower rate.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit dc2d28eab4a998bf5fc60831aaa48d094cbe8785
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:10:06 2022 -0800
+
+ more 16-bit log tick values
+
+commit 9020a82d8b1496bc47dbe454b0735467b5a599b8
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:06:18 2022 -0800
+
+ ao_log: Change flight type to uint16_t, widen APIs dealing with flight numbers to int32_t
+
+ Real Flight numbers are 16-bit unsigned values, but APIs using them
+ pass values that areoverloaded to also represent broken log slots
+ using negative numbers. This means that these APIs need to be able to
+ represent all 65535 possible flight numbers *and* all possible log
+ slots as negative values. Switch the variables holding only flight
+ numbers to uint16_t and those holding either a flight number or log
+ slot to int32_t.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 8e73e5298206db0e781cc76ee151e96d29f29341
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:00:38 2022 -0800
+
+ ao_gps, ao_log: Make conversions to 16-bit time log values explicit
+
+ All log formats record only the low 16-bits of the time value, make
+ conversions to those explicit to silence -Wconversion warnings.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 7917ec1f105f39799acbea0f4c28d25db4f66eb4
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 14:50:58 2022 -0800
+
+ ao_flight: ao_interval_end type was too small, could cause premature landing state
+
+ ao_interval_end is used to provide a window of time during which the
+ max/min values for sensors are measured. After that time expires,
+ those bounds are compared to see if the airframe has been stable and
+ should be moved to landing state. With a type that is too small, that
+ could happen immediately after transitioning to main (for baro-enabled
+ devices) or coast (for accel-only devices). For baro devices, this
+ would disable any redundant main firing events. For accel-only
+ devices, this could disable all events occuring after coast, including
+ firing separation charges or motor igniters.
+
+ There are also a couple of additional changes to reduce -Wconversion
+ messages.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 6f06cf3e8fe0531b927d5e11ae2b0e9af3663b0f
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 14:43:31 2022 -0800
+
+ ao_convert_pa: Switch array index to unsigned type
+
+ This seems more appropriate for this use.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 4aa984bbcce1cdc4f4b82516a9f2a32cf5061dfa
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 14:42:45 2022 -0800
+
+ ao_companion: Make motor_number uint16_t
+
+ Make it match the types used elsewhere
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit f51316c02a8385223567e1aa8e3f5a0b74c16cd6
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 14:41:59 2022 -0800
+
+ fifo: Add casts to fifo operation macros for -Wconversion
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit ba0239ca6839605c7ce45d56677bb9a3b782b7f2
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 14:41:10 2022 -0800
+
+ beep, cmd, config, convert_volt, data, distance, fec, kalman: -Wconversion warnings
+
+ No bugs noted, just adding casts to resolve -Wconversion warnings.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit bdf0671cb36daca741c4842a37a3fc71744a63a2
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 14:15:42 2022 -0800
+
+ altos/ao_freq: Use uint32_t for radio freq setting value
+
+ These values are always unsigned; changing this resolves some
+ -Wconversion messages.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 3d276e01ba96e8174e590b101cc9ef002e6cb67b
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 14:13:53 2022 -0800
+
+ altos/ao_stdio: use uint8_t for stdio index
+
+ This makes type usage of this value consistent. Also fix another
+ -Wconversion warning.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 161f2a3aa7f7364c6d972df4199200828dfe3294
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 14:12:31 2022 -0800
+
+ altos: Switch ao_radio_recv timeout to AO_TICK_TYPE
+
+ Make sure all times are in the wider type.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 72a452d1ca5b3f9f1defef47465e24a10ca72d58
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 14:10:31 2022 -0800
+
+ drivers/ao_rn4678: Fix timeouts to use AO_TICK_TYPE
+
+ Also fix other -Wconversion messages.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 9f56c5763d1c078c5de15e92103b751ea26b7684
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 14:08:56 2022 -0800
+
+ drivers/ao_quadrature: Fix -Wconversion warnings
+
+ No bugs detected.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit dbaef3237cc6874faf8eb9030a15b578b58fd83f
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 14:06:25 2022 -0800
+
+ drivers/ao_pad: Convert from/to 16-bit times over the air
+
+ The radio protocol sends only 16 bits of time, make sure we translate
+ from/to those correctly. No bugs detected, just casts added to
+ clarify. Also fix other -Wconversion warnings.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 11d6e27bfd94ce58b702bfd0889f064ce1ef5a48
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 14:00:43 2022 -0800
+
+ drivers/ao_packet: Switch time values to AO_TICK_TYPE
+
+ Make sure times are kept in the right type. Also resolved other
+ -Wconversion issues.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit c309956389acc01f784f3d0e11745f5ac0a77e06
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 13:59:26 2022 -0800
+
+ drivers: Resolve -Wconversion in m25, mma655x, mmc5983, mpu and ms5607
+
+ No bugs identified.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 9c27459fe1417b460f01f053bc44474623b1cbca
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 09:33:17 2022 -0800
+
+ drivers/ao_lco: Fix box types to be uint16_t. Also clean other -Wconversion messages
+
+ Old LCO code uses 0x1000 as magic value for "DRAG" box, so we need 16
+ bits. Switch all box variables to 16 bits, use int32_t when switching
+ box numbers to deal with negative values and still hold the whole
+ possible range (even though 16 bits "should" be plenty).
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 71c3652d6c511db03402f5b7487bc4098e6d850f
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 09:29:06 2022 -0800
+
+ ao_hmc5883: Add explicit casts for -Wconversion
+
+ No bugs noted.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit c783aafd89777626c362e15c47360b399d03c45d
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 09:26:08 2022 -0800
+
+ ao_companion: Make time conversion to 16-bits in companion protocol explicit
+
+ Companion protocol only passes low 16-bits. Also add explicit casts for -Wconversion
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit fadb563f8aeeee895a7232bb71fa5bade6ef66f0
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 09:25:15 2022 -0800
+
+ ao_gps_skytrac, ao_gps_ublox: Add explicit casts to quiet -Wconversion
+
+ No bugs noted.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 452dd07575a118f29a0dfa712deeb18e92ffb1f4
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 09:20:29 2022 -0800
+
+ drivers: Fix type of radio timeout parameter
+
+ Move from uint16_t to AO_TICK_TYPE. Also add explicit casts to quiet
+ remaining -Wconversion messages.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 46200359c388062a5e7bc40d780808d92a59f0ed
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 09:16:49 2022 -0800
+
+ altos/drivers/ao_button: Save all 32-bits of irq status
+
+ Was saving in a uint8_t
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 7fd29d922be98ddc6406f2323599ef63061044ed
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 09:15:57 2022 -0800
+
+ altos/drivers: Add explicit casts in ao_aprs, ao_bmx160 and ao_btm
+
+ No bugs spotted here, but this quiets -Wconversion warnings
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 5bdb250a43c9e87185f3ddedbd8364f24306bbfd
+Author: Keith Packard <keithp@keithp.com>
+Date: Thu Jan 27 15:52:44 2022 -0800
+
+ altos/attiny: Eliminate warnings from -Wconversion
+
+ These have no effect on the generated code as they simply make
+ implicit conversions explicit.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 85dd82b200d649fbf08aa31e5acde8f1f40d531a
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 16 17:00:59 2022 -0800
+
+ altos: Re-enable apogee delay
+
+ When the igniter code was changed to support booster mode, the code
+ which delayed apogee firing based on the configure apogee delay value
+ was lost. Re-enable that by sticking a delay before firing the drogue
+ charge when the ignite mode is not redundant apogee.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit d91e0b962d95051a10147e691b133927bf3fb8cb
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 9 09:58:07 2022 -0800
+
+ Version 1.9.10.3
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit d11edd6d595eb1a0786f61d4ae4bdf37ecf1a4fb
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 9 09:51:33 2022 -0800
+
+ libaltos: Build Mac OSX libaltos.dylib for arm64 too
+
+ Make this work on the M1.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 5c67c0c789787fcd18b513a775d2415e0af0a2d0
+Author: Keith Packard <keithp@keithp.com>
+Date: Wed Feb 9 09:49:49 2022 -0800
+
+ Switch from AdoptOpenJDK to Adoptium
+
+ This project moved to Eclipse foundation but seems otherwise about the same.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit c5d39fe3ac9252547f966a86f413eebd7b44088f
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 28 15:27:02 2022 -0800
+
+ ao_pyro: Move delay_done out of pyro structure
+
+ The pyro structure should be read-only in flight operations. Move the
+ 'delay_done' element to a parallel array as that gets written. Change
+ types to pointers to const structs to enforce this in the future.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 606a67724dea8ab3d52d52456722dc593cf8ac8d
+Author: Keith Packard <keithp@keithp.com>
+Date: Thu Jan 27 15:49:15 2022 -0800
+
+ altos: AES code was storing bytes in an int array
+
+ The only operations using these values are logic using bytes, not
+ arithmetic, so shrinking the size of the elements should have no
+ effect on operation.
+
+ This saves space *and* eliminates a type conversion warning from
+ -Wconversion.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 3759d6707d67e2584670ea89086576b695ea3509
+Author: Bdale Garbee <bdale@gag.com>
+Date: Tue Jan 25 12:34:31 2022 -0700
+
+ need to save .bin for TeleGPS v2.0
+
+commit 59cbf80e63b4c88de45e59c6e3d209f99910fcf3
+Author: Keith Packard <keithp@keithp.com>
+Date: Fri Jan 21 19:45:14 2022 -0800
+
+ data_interval == 0 means no data collection
+
+ All of the timer functions were still taking one sample every 256
+ clock ticks.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 2dc5d4eecc97b640a2e1f012b4411955682b61c8
+Author: Keith Packard <keithp@keithp.com>
+Date: Tue Jan 11 14:34:14 2022 -0800
+
+ Version 1.9.10.2
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit d24aba871ee9aa3671e15510ee4e2a0266c3d583
+Author: Keith Packard <keithp@keithp.com>
+Date: Tue Jan 11 14:32:55 2022 -0800
+
+ altosdroid: Add BLUETOOTH_CONNECT permission, handle its lack
+
+ Android 12 switched how bluetooth permissions work, so now we need a
+ new one to talk to devices. Also deal with a lack of that by not
+ crashing when we can't get the name of a BT device.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 7f46240dfc57164f0c1b0c4c4ed9695bca63860d
+Author: Keith Packard <keithp@keithp.com>
+Date: Thu Dec 16 13:39:33 2021 -0800
+
+ altos: Switch all tick variables to AO_TICK_TYPE/AO_TICK_SIGNED
+
+ Instead of trying to pick and choose which work as 16-bit values,
+ change everything that doesn't affect external values (log, companion,
+ radio) to AO_TICK_TYPE.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 0e068689f41b74c883615f9f11a322a962cbb792
+Author: Keith Packard <keithp@keithp.com>
+Date: Thu Dec 16 13:38:39 2021 -0800
+
+ altos/attiny: Switch to avrisp2 for development programmer
+
+ My bench programmer puck is the avrisp2, not usbtiny
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit d317c2e30c408909807bde7c5577e499bd3c6f17
+Author: Keith Packard <keithp@keithp.com>
+Date: Thu Dec 16 13:37:17 2021 -0800
+
+ ao-tools/ao-test-igniter: Deal with devices that use both 'apogee' for ADC
+
+ Some devices report drogue igniter ADC value with 'apogee' tag. Deal
+ with this.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 55698a6232bde408ce7e12bb7ee52ba72985fc78
+Author: Keith Packard <keithp@keithp.com>
+Date: Thu Dec 16 13:36:10 2021 -0800
+
+ micropeak: detect empty log received from device
+
+ Avoid reporting a failure to the user when the device has no flight
+ log.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit e3127155c02cd42ef8aa42d167fc214e8997113f
+Author: Bdale Garbee <bdale@gag.com>
+Date: Wed Dec 22 11:35:52 2021 -0700
+
+ doc: add an appendix on frequency calibration to the all-in-one manual
+
+commit 66152b176bad12fbff3188397c607793c0bdd380
+Merge: 8e1145b9 0921e8b1
+Author: Bdale Garbee <bdale@gag.com>
+Date: Mon Dec 20 13:49:41 2021 -0700
+
+ Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
+
+commit 8e1145b9894537e33747fecc7d61d87eadab6135
+Author: Bdale Garbee <bdale@gag.com>
+Date: Mon Dec 20 13:49:28 2021 -0700
+
+ need to capture .bin file for telebt loader, too
+
+commit 0921e8b166c41ea8f65df14cea893481d8e1f0f1
+Merge: 236d80fa 9db486f6
+Author: Bdale Garbee <bdale@gag.com>
+Date: Wed Nov 3 13:24:41 2021 -0600
+
+ Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
+
+commit 9db486f6d78b8a2ae855168338e0ea7d6ee4231f
+Author: Keith Packard <keithp@keithp.com>
+Date: Sat Oct 16 16:27:52 2021 -0700
+
+ Version 1.9.10.1
+
+ AltosDroid fixes (rotation, crash in maps stuff)
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit a1b7357aa5bca6afb588b0bfb5cfe72c4d0255ef
+Author: Keith Packard <keithp@keithp.com>
+Date: Sat Oct 16 15:48:22 2021 -0700
+
+ altosdroid: Fix tab updates on Android 11 after rotate
+
+ Android 11 appears to have "optimized" application rotation by
+ regenerating fragments automatically. This means the tab fragments
+ aren't getting created by TabsAdapter.getItem, so that code didn't
+ know about them, which caused it to not know which tab was active so
+ all of the application state wasn't getting updated in the tabs after
+ rotation.
+
+ Fix this by telling TabsAdapter about fragments that are already
+ created -- altosdroid hears about them in the registerTab hook.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit 5ef3cd5abdb863c534a0abc5d0a726cfa5108eb4
+Author: Keith Packard <keithp@keithp.com>
+Date: Sun Oct 10 23:01:18 2021 -0700
+
+ altosdroid: Skip map draw before transform is set
+
+ A crash report indicates that this can happen.
+
+ Signed-off-by: Keith Packard <keithp@keithp.com>
+
+commit f426462c7e86dc0aa48c004e115144b25eadacf8
+Author: Bdale Garbee <bdale@gag.com>
+Date: Sun Oct 10 22:21:49 2021 -0600
+
+ fix version in 1.9.10 release notes
+
+commit 8970d45ea43bfff1de38778ee8b14c3e54639555
+Author: Bdale Garbee <bdale@gag.com>
+Date: Sun Oct 10 21:42:19 2021 -0600
+
+ releasing 1.9.10
+
commit ed267e76eb03c34ec233c33a002ec9e5e53ec83a
Merge: bd71c839 ef70f80b
Author: Bdale Garbee <bdale@gag.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
+commit 236d80fac2b4293c5750c9d80b387afd4d0fc5cc
+Merge: 047a3f1f 6ef22682
+Author: Bdale Garbee <bdale@gag.com>
+Date: Thu Oct 7 12:11:06 2021 -0600
+
+ Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
+
commit c15bb9513ab0f8636bf52ec827551134c773e832
Author: Keith Packard <keithp@keithp.com>
Date: Wed Oct 6 22:58:09 2021 -0700
Signed-off-by: Keith Packard <keithp@keithp.com>
+commit 047a3f1f08687113b80123cc7568d7057a23bcc3
+Merge: 01b5d271 e7a19e6d
+Author: Bdale Garbee <bdale@gag.com>
+Date: Wed Sep 22 11:53:17 2021 -0600
+
+ Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
+
commit e7a19e6dec201603e98b94b0ba790aa7d2d344f8
Author: Bdale Garbee <bdale@gag.com>
Date: Mon Sep 20 18:17:49 2021 -0600
update TeleMega bench scripts for v5.0 hardware
+commit 01b5d271d21e0c60508c06f4af1ff34bf75bf9fe
+Author: Bdale Garbee <bdale@gag.com>
+Date: Wed Sep 22 11:45:49 2021 -0600
+
+ capture odd changes from production machine?
+
commit 3fb07b29d7bad57a52e4b0c75d623577ca1d4da3
Author: Bdale Garbee <bdale@gag.com>
Date: Mon Sep 20 22:06:30 2021 -0600
src/easytimer-v1/flash-loader/*.elf \
src/telebt-v[3-4].0/flash-loader/{*.elf,*.bin,*.map} \
src/teledongle-v3.0/flash-loader/*.elf \
- src/telegps-v[1-2].0/flash-loader/*.elf \
+ src/telegps-v[1-2].0/flash-loader/{*.elf,*.bin,*.map} \
src/telemega-v[1-5].0/flash-loader/*.elf \
src/telemetrum-v[2-3].0/flash-loader/*.elf \
src/telemini-v3.0/flash-loader/{*.elf,*.bin,*.map} \
defaultConfig {
applicationId "org.altusmetrum.AltosDroid"
minSdkVersion 21
- targetSdkVersion 29
+ targetSdkVersion 30
versionCode @ANDROID_VERSION@
versionName "@VERSION@"
}
<!-- Permissions needed to access bluetooth -->
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
+ <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- Permissions needed to save Telemetry logs to SD card -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Permissions needed for GoogleMaps -->
Log.e(TAG, String.format(format, arguments));
}
+ static void trace(String format, Object ... arguments) {
+ error(format, arguments);
+ for (StackTraceElement el : Thread.currentThread().getStackTrace())
+ Log.e(TAG, "\t" + el.toString() + "\n");
+ }
+
static void check_ui(String format, Object ... arguments) {
- if (Looper.myLooper() == Looper.getMainLooper()) {
- Log.e(TAG, String.format("ON UI THREAD " + format, arguments));
- for (StackTraceElement el : Thread.currentThread().getStackTrace())
- Log.e(TAG, "\t" + el.toString() + "\n");
- }
+ if (Looper.myLooper() == Looper.getMainLooper())
+ trace("ON UI THREAD " + format, arguments);
}
}
}
};
-
private ServiceConnection mConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName className, IBinder service) {
+ AltosDebug.debug("onServiceConnected\n");
mService = new Messenger(service);
try {
Message msg = Message.obtain(null, TelemetryService.MSG_REGISTER_CLIENT);
msg.replyTo = mMessenger;
mService.send(msg);
} catch (RemoteException e) {
+ AltosDebug.debug("attempt to register telemetry service client failed\n");
// In this case the service has crashed before we could even do anything with it
}
if (pending_usb_device != null) {
}
public void onServiceDisconnected(ComponentName className) {
+ AltosDebug.debug("onServiceDisconnected\n");
// This is called when the connection with the service has been unexpectedly disconnected - process crashed.
mService = null;
}
};
void doBindService() {
+ AltosDebug.debug("doBindService\n");
bindService(new Intent(this, TelemetryService.class), mConnection, Context.BIND_AUTO_CREATE);
mIsBound = true;
}
void doUnbindService() {
+ AltosDebug.debug("doUnbindService\n");
if (mIsBound) {
// If we have received the service, and hence registered with it, then now is the time to unregister.
if (mService != null) {
}
}
+ public AltosDroidTab findTab(String name) {
+ for (AltosDroidTab mTab : mTabs)
+ if (name.equals(mTab.tab_name()))
+ return mTab;
+ return null;
+ }
+
public void registerTab(AltosDroidTab mTab) {
mTabs.add(mTab);
}
void update_ui(TelemetryState telem_state, AltosState state, boolean quiet) {
+ AltosDebug.debug("update_ui telem %b state %b quiet %b saved_state %b\n",
+ telem_state != null,
+ state != null,
+ quiet,
+ saved_state != null);
+
this.state = state;
int prev_state = AltosLib.ao_flight_invalid;
saved_state = new SavedState(state);
}
- for (AltosDroidTab mTab : mTabs)
+ for (AltosDroidTab mTab : mTabs) {
+ AltosDebug.debug("mTab %s current %s\n",
+ mTab, mTabsAdapter.currentItem());
mTab.update_ui(telem_state, state, from_receiver, location, mTab == mTabsAdapter.currentItem());
+ }
if (mAltosVoice != null && mTabsAdapter.currentItem() != null)
mAltosVoice.tell(telem_state, state, from_receiver, location, (AltosDroidTab) mTabsAdapter.currentItem(), quiet);
@Override
public void onCreate(Bundle savedInstanceState) {
+ AltosDebug.init(this);
+ AltosDebug.debug("+++ ON CREATE +++");
+
// Initialise preferences
AltosDroidPreferences.init(this);
setTheme(themes[AltosDroidPreferences.font_size()]);
super.onCreate(savedInstanceState);
- AltosDebug.init(this);
- AltosDebug.debug("+++ ON CREATE +++");
-
fm = getSupportFragmentManager();
mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);
- mTabsAdapter.addTab(mTabHost.newTabSpec(tab_pad_name).setIndicator(create_tab_view("Pad")), TabPad.class, null);
- mTabsAdapter.addTab(mTabHost.newTabSpec(tab_flight_name).setIndicator(create_tab_view("Flight")), TabFlight.class, null);
- mTabsAdapter.addTab(mTabHost.newTabSpec(tab_recover_name).setIndicator(create_tab_view("Recover")), TabRecover.class, null);
- mTabsAdapter.addTab(mTabHost.newTabSpec(tab_map_name).setIndicator(create_tab_view("Map")), TabMap.class, null);
+ mTabsAdapter.addTab(mTabHost.newTabSpec(tab_pad_name).setIndicator(create_tab_view("Pad")), TabPad.class, null, findTab(tab_pad_name));
+ mTabsAdapter.addTab(mTabHost.newTabSpec(tab_flight_name).setIndicator(create_tab_view("Flight")), TabFlight.class, null, findTab(tab_flight_name));
+ mTabsAdapter.addTab(mTabHost.newTabSpec(tab_recover_name).setIndicator(create_tab_view("Recover")), TabRecover.class, null, findTab(tab_recover_name));
+ mTabsAdapter.addTab(mTabHost.newTabSpec(tab_map_name).setIndicator(create_tab_view("Map")), TabMap.class, null, findTab(tab_map_name));
// Display the Version
mVersion = (TextView) findViewById(R.id.version);
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
- AltosDebug.debug("onNewIntent");
+ AltosDebug.debug("+ ON NEW INTENT +");
noticeIntent(intent);
}
- private void enable_location_updates() {
+ private void enable_location_updates(boolean do_update) {
// Listen for GPS and Network position updates
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
AltosDebug.debug("Failed to get GPS updates\n");
}
- update_ui(telemetry_state, state, true);
+ if (do_update)
+ update_ui(telemetry_state, state, true);
}
static final int MY_PERMISSION_REQUEST = 1001;
public boolean have_location_permission = false;
public boolean have_storage_permission = false;
+ public boolean have_bluetooth_permission = false;
+ public boolean have_bluetooth_connect_permission = false;
public boolean asked_permission = false;
+ static final String BLUETOOTH_CONNECT = "android.permission.BLUETOOTH_CONNECT";
+
AltosMapOnline map_online;
void
if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
if (permissions[i].equals(Manifest.permission.ACCESS_FINE_LOCATION)) {
have_location_permission = true;
- enable_location_updates();
+ enable_location_updates(true);
if (map_online != null)
map_online.position_permission();
}
if (permissions[i].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
have_storage_permission = true;
}
+ if (permissions[i].equals(Manifest.permission.BLUETOOTH)) {
+ have_bluetooth_permission = true;
+ }
+ if (permissions[i].equals(BLUETOOTH_CONNECT)) {
+ have_bluetooth_connect_permission = true;
+ }
}
}
}
@Override
public void onResume() {
- super.onResume();
AltosDebug.debug("+ ON RESUME +");
+ super.onResume();
+
if (!asked_permission) {
asked_permission = true;
if (ActivityCompat.checkSelfPermission(this,
{
have_storage_permission = true;
}
- int count = (have_location_permission ? 0 : 1) + (have_storage_permission ? 0 : 1);
+ if (ActivityCompat.checkSelfPermission(this,
+ Manifest.permission.BLUETOOTH)
+ == PackageManager.PERMISSION_GRANTED)
+ {
+ have_bluetooth_permission = true;
+ }
+ if (ActivityCompat.checkSelfPermission(this,
+ BLUETOOTH_CONNECT)
+ == PackageManager.PERMISSION_GRANTED)
+ {
+ have_bluetooth_connect_permission = true;
+ }
+ int count = 0;
+ if (!have_location_permission)
+ count += 1;
+ if (!have_storage_permission)
+ count += 1;
+ if (!have_bluetooth_permission)
+ count += 1;
+ if (!have_bluetooth_connect_permission)
+ count += 1;
if (count > 0)
{
String[] permissions = new String[count];
int i = 0;
if (!have_location_permission)
permissions[i++] = Manifest.permission.ACCESS_FINE_LOCATION;
- if (!have_location_permission)
+ if (!have_storage_permission)
permissions[i++] = Manifest.permission.WRITE_EXTERNAL_STORAGE;
+ if (!have_bluetooth_permission)
+ permissions[i++] = Manifest.permission.BLUETOOTH;
+ if (!have_bluetooth_connect_permission)
+ permissions[i++] = BLUETOOTH_CONNECT;
ActivityCompat.requestPermissions(this, permissions, MY_PERMISSION_REQUEST);
}
}
if (have_location_permission)
- enable_location_updates();
+ enable_location_updates(false);
}
@Override
public void onPause() {
- super.onPause();
AltosDebug.debug("- ON PAUSE -");
+
+ super.onPause();
+
// Stop listening for location updates
if (have_location_permission)
((LocationManager) getSystemService(Context.LOCATION_SERVICE)).removeUpdates(this);
@Override
public void onStop() {
- super.onStop();
AltosDebug.debug("-- ON STOP --");
+
+ super.onStop();
}
@Override
public void onDestroy() {
- super.onDestroy();
AltosDebug.debug("--- ON DESTROY ---");
+ super.onDestroy();
+
+ saved_state = null;
+
doUnbindService();
if (mAltosVoice != null) {
mAltosVoice.stop();
@Override
public void onAttach(Context context) {
+ AltosDebug.debug("tab onAttach %s %s\n", tab_name(), this);
super.onAttach(context);
altos_droid = (AltosDroid) context;
altos_droid.registerTab(this);
@Override
public void onDetach() {
+ AltosDebug.debug("tab onDetach %s %s\n", tab_name(), this);
super.onDetach();
altos_droid.unregisterTab(this);
altos_droid = null;
@Override
public void onResume() {
super.onResume();
- AltosDebug.debug("onResume tab %s\n", tab_name());
+ AltosDebug.debug("onResume tab %s %s\n", tab_name(), this);
set_visible(true);
}
public void update_ui(TelemetryState telem_state, AltosState state,
AltosGreatCircle from_receiver, Location receiver, boolean is_current)
{
+ AltosDebug.debug("update_ui %s is_current %b\n", tab_name(), is_current);
last_telem_state = telem_state;
last_state = state;
last_from_receiver = from_receiver;
debug("MapView draw without map\n");
return;
}
+ if (map.transform == null) {
+ debug("MapView draw without transform\n");
+ return;
+ }
canvas = view_canvas;
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setStrokeWidth(stroke_width);
// If there are paired devices, add each one to the ArrayAdapter
if (pairedDevices.size() > 0) {
findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
- for (BluetoothDevice device : pairedDevices)
- if (device.getName().startsWith("TeleBT"))
- mPairedDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
-
+ for (BluetoothDevice device : pairedDevices) {
+ String name = device.getName();
+ if (name != null && name.startsWith("TeleBT"))
+ mPairedDevicesArrayAdapter.add(name + "\n" + device.getAddress());
+ }
} else {
String noDevices = getResources().getText(R.string.none_paired).toString();
mPairedDevicesArrayAdapter.add(noDevices);
{
String name = device.getName();
if (name != null && name.startsWith("TeleBT"))
- mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
+ mNewDevicesArrayAdapter.add(name + "\n" + device.getAddress());
}
/* When discovery is finished, change the Activity title
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ AltosDebug.debug("TabPad onCreateView\n");
View v = inflater.inflate(R.layout.tab_pad, container, false);
battery_voltage_view = (TextView) v.findViewById(R.id.battery_voltage_value);
battery_lights = new GoNoGoLights((ImageView) v.findViewById(R.id.battery_redled),
receiver_latitude_view = (TextView) v.findViewById(R.id.receiver_lat_value);
receiver_longitude_view = (TextView) v.findViewById(R.id.receiver_lon_value);
receiver_altitude_view = (TextView) v.findViewById(R.id.receiver_alt_value);
- return v;
+
+ AltosDebug.debug("TabPad onCreateView done battery_voltage_view %s\n", battery_voltage_view);
+ return v;
}
public String tab_name() { return AltosDroid.tab_pad_name; }
public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) {
+ AltosDebug.debug("pad show state %b bvv %s\n", state != null, battery_voltage_view);
if (state != null) {
battery_voltage_view.setText(AltosDroid.number("%1.2f V", state.battery_voltage));
battery_lights.set(state.battery_voltage >= AltosLib.ao_battery_good, state.battery_voltage == AltosLib.MISSING);
double altitude = AltosLib.MISSING;
if (receiver.hasAltitude())
altitude = receiver.getAltitude();
- receiver_latitude_view.setText(AltosDroid.pos(receiver.getLatitude(), "N", "S"));
- receiver_longitude_view.setText(AltosDroid.pos(receiver.getLongitude(), "E", "W"));
+ String lat_text = AltosDroid.pos(receiver.getLatitude(), "N", "S");
+ String lon_text = AltosDroid.pos(receiver.getLongitude(), "E", "W");
+ AltosDebug.debug("lat %s lon %s\n", lat_text, lon_text);
+ receiver_latitude_view.setText(lat_text);
+ receiver_longitude_view.setText(lon_text);
set_value(receiver_altitude_view, AltosConvert.height, 1, altitude);
}
}
private final Bundle args;
private Fragment fragment;
- TabInfo(String _tag, Class<?> _class, Bundle _args) {
+ TabInfo(String _tag, Class<?> _class, Bundle _args, Fragment _fragment) {
tag = _tag;
clss = _class;
args = _args;
+ fragment = _fragment;
}
}
mViewPager.addOnPageChangeListener(this);
}
- public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args) {
+ public void addTab(TabHost.TabSpec tabSpec, Class<?> clss, Bundle args, Fragment fragment) {
tabSpec.setContent(new DummyTabFactory(mContext));
String tag = tabSpec.getTag();
- TabInfo info = new TabInfo(tag, clss, args);
+ TabInfo info = new TabInfo(tag, clss, args, fragment);
mTabs.add(info);
mTabHost.addTab(tabSpec);
notifyDataSetChanged();
public Fragment getItem(int position) {
TabInfo info = mTabs.get(position);
AltosDebug.debug("TabsAdapter.getItem(%d)", position);
- info.fragment = Fragment.instantiate(mContext, info.clss.getName(), info.args);
+ if (info.fragment == null)
+ info.fragment = Fragment.instantiate(mContext, info.clss.getName(), info.args);
return info.fragment;
}
AltosDroidTab cur_frag = (AltosDroidTab) mTabs.get(position).fragment;
+ AltosDebug.debug("TabsAdapter.onTabChanged(%s) = %d cur %s prev %s", tabId, position, cur_frag, prev_frag);
+
if (prev_frag != cur_frag) {
if (prev_frag != null) {
prev_frag.set_visible(false);
}
}
- if (cur_frag != null) {
+
+ /* This happens when the tab is selected before any of them
+ * have been created, like during rotation
+ */
+ if (cur_frag != null)
cur_frag.set_visible(true);
- }
- AltosDebug.debug("TabsAdapter.onTabChanged(%s) = %d", tabId, position);
mViewPager.setCurrentItem(position);
}
/* HAS_BEEP */
public int beep;
+ /* HAS_RADIO_10MW */
+ public int radio_10mw;
+
/* Storage info replies */
public int storage_size;
public int storage_erase_unit;
beep = AltosLib.MISSING;
+ radio_10mw = AltosLib.MISSING;
+
tracker_motion = AltosLib.MISSING;
tracker_interval = AltosLib.MISSING;
/* HAS_BEEP */
try { beep = get_int(line, "Beeper setting:"); } catch (Exception e) {}
+ /* HAS_RADIO_10MW */
+ try { radio_10mw = get_int(line, "Radio 10mw limit:"); } catch (Exception e) {}
+
/* HAS_TRACKER */
try {
int[] values = get_values(line, "Tracker setting:");
/* HAS_BEEP */
if (beep != AltosLib.MISSING)
beep = source.beep();
+
+ /* HAS_RADIO_10MW */
+ if (radio_10mw != AltosLib.MISSING)
+ radio_10mw = source.radio_10mw();
+
/* HAS_TRACKER */
if (tracker_motion != AltosLib.MISSING)
tracker_motion = source.tracker_motion();
dest.set_aprs_format(aprs_format);
dest.set_aprs_offset(aprs_offset);
dest.set_beep(beep);
+ dest.set_radio_10mw(radio_10mw);
dest.set_tracker_motion(tracker_motion);
dest.set_tracker_interval(tracker_interval);
}
if (beep != AltosLib.MISSING)
link.printf("c b %d\n", beep);
+ /* HAS_RADIO_10MW */
+ if (radio_10mw != AltosLib.MISSING)
+ link.printf("c p %d\n", radio_10mw);
+
/* HAS_TRACKER */
if (tracker_motion != AltosLib.MISSING && tracker_interval != AltosLib.MISSING)
link.printf("c t %d %d\n", tracker_motion, tracker_interval);
public abstract int tracker_interval() throws AltosConfigDataException;
public abstract void set_tracker_interval(int tracker_motion);
+
+ public abstract int radio_10mw() throws AltosConfigDataException;
+
+ public abstract void set_radio_10mw(int radio_10mw);
}
JLabel radio_calibration_label;
JLabel radio_frequency_label;
JLabel radio_enable_label;
+ JLabel radio_10mw_label;
JLabel rate_label;
JLabel aprs_interval_label;
JLabel aprs_ssid_label;
AltosUIFreqList radio_frequency_value;
JLabel radio_calibration_value;
JRadioButton radio_enable_value;
+ JRadioButton radio_10mw_value;
AltosUIRateList rate_value;
JComboBox<String> aprs_interval_value;
JComboBox<Integer> aprs_ssid_value;
beep_value.setToolTipText("Older firmware could not select beeper frequency");
}
+ void set_radio_10mw_tool_tip() {
+ if (radio_10mw_value.isVisible())
+ radio_10mw_value.setToolTipText("Should transmitter power be limited to 10mW");
+ else
+ radio_10mw_value.setToolTipText("Older firmware could not limit radio power");
+ }
+
/* Build the UI using a grid bag */
public AltosConfigFCUI(JFrame in_owner, boolean remote) {
super (in_owner, title, false);
set_radio_enable_tool_tip();
row++;
+ /* Radio 10mW limit */
+ c = new GridBagConstraints();
+ c.gridx = 0; c.gridy = row;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ c.ipady = 5;
+ radio_10mw_label = new JLabel("Limit transmit to 10mW:");
+ pane.add(radio_10mw_label, c);
+
+ c = new GridBagConstraints();
+ c.gridx = 4; c.gridy = row;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = ir;
+ c.ipady = 5;
+ radio_10mw_value = new JRadioButton("Limited");
+ radio_10mw_value.addItemListener(this);
+ pane.add(radio_10mw_value, c);
+ set_radio_10mw_tool_tip();
+ row++;
+
/* Telemetry Rate */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = row;
return AltosLib.MISSING;
}
+ public void set_radio_10mw(int new_radio_10mw) {
+ if (new_radio_10mw != AltosLib.MISSING) {
+ radio_10mw_value.setSelected(new_radio_10mw != 0);
+ }
+ radio_10mw_value.setVisible(new_radio_10mw != AltosLib.MISSING);
+ radio_10mw_label.setVisible(new_radio_10mw != AltosLib.MISSING);
+ set_radio_10mw_tool_tip();
+ }
+
+ public int radio_10mw() {
+ if (radio_10mw_value.isVisible())
+ return radio_10mw_value.isSelected() ? 1 : 0;
+ else
+ return AltosLib.MISSING;
+ }
+
String[] tracker_motion_values() {
if (AltosConvert.imperial_units)
return tracker_motion_values_ft;
MSG_INSTALL_JAVA="Java doit être installé sur votre système.\nRendez-vous sur java.com et suivez les instructions d'installation..."
MSG_LATER="Plus tard"
MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java by Adoptium"
;;
# German
MSG_INSTALL_JAVA="Auf Ihrem System muss die 'Java'-Software installiert sein.\nBesuchen Sie java.com für weitere Installationshinweise."
MSG_LATER="Später"
MSG_VISIT_JAVA_DOT_COM="Java von Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java von AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java von Adoptium"
;;
# Simplified Chinese
MSG_INSTALL_JAVA="你需要在Mac中安装Java运行环境!\n访问 java.com 了解如何安装。"
MSG_LATER="稍后"
MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java by Adoptium"
;;
# Spanish
MSG_INSTALL_JAVA="¡Necesita tener JAVA instalado en su Mac!\nVisite java.com para consultar las instrucciones para su instalación..."
MSG_LATER="Más tarde"
MSG_VISIT_JAVA_DOT_COM="Java de Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java de AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java de Adoptium"
;;
# English | default
MSG_INSTALL_JAVA="You need to have JAVA installed on your Mac!\nVisit java.com for installation instructions..."
MSG_LATER="Later"
MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java by Adoptium"
;;
esac
stub_logger "[EXIT 3] ${MSG_NO_SUITABLE_JAVA_EXPANDED}"
# display error message with AppleScript
- osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_NO_SUITABLE_JAVA_EXPANDED}\n${MSG_NO_SUITABLE_JAVA_CHECK}\" with title \"${CFBundleName}\" buttons {\" OK \", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTOPENJDK}\"} default button 1${DialogWithIcon}" \
+ osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_NO_SUITABLE_JAVA_EXPANDED}\n${MSG_NO_SUITABLE_JAVA_CHECK}\" with title \"${CFBundleName}\" buttons {\" OK \", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTIUM}\"} default button 1${DialogWithIcon}" \
-e "set response to button returned of the result" \
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"https://www.java.com/download/\"" \
- -e "if response is \"${MSG_VISIT_ADOPTOPENJDK}\" then open location \"https://adoptopenjdk.net/releases.html\""
+ -e "if response is \"${MSG_VISIT_ADOPTIUM}\" then open location \"https://adoptium.net/releases.html\""
# exit with error
exit 3
# log exit cause
stub_logger "[EXIT 1] ${MSG_ERROR_LAUNCHING}"
# display error message with AppleScript
- osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_INSTALL_JAVA}\" with title \"${CFBundleName}\" buttons {\"${MSG_LATER}\", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTOPENJDK}\"} default button 1${DialogWithIcon}" \
+ osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_INSTALL_JAVA}\" with title \"${CFBundleName}\" buttons {\"${MSG_LATER}\", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTIUM}\"} default button 1${DialogWithIcon}" \
-e "set response to button returned of the result" \
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"https://www.java.com/download/\"" \
- -e "if response is \"${MSG_VISIT_ADOPTOPENJDK}\" then open location \"https://adoptopenjdk.net/releases.html\""
+ -e "if response is \"${MSG_VISIT_ADOPTIUM}\" then open location \"https://adoptium.net/releases.html\""
# exit with error
exit 1
fi
var skip
Function GetJRE
- ${OpenURL} "adoptopenjdk.net"
+ ${OpenURL} "adoptium.net"
MessageBox MB_OK "Click OK to continue after completing the Java Install."
FunctionEnd
esac
# Check for java
-if ls "$JVM" | grep -q adopt; then
- echo "Adopt OpenJDK already present"
+if ls "$JVM" | grep -q temurin; then
+ echo "Adoptium already present"
else
- open https://adoptopenjdk.net/
- osascript -e 'display dialog "Install Java from https://adoptopenjdk.net then click Continue" buttons {"Continue"} default button 1 with title "Install Java"' >/dev/null
+ open https://adoptium.net/
+ osascript -e 'display dialog "Install Java from https://adoptium.net then click Continue" buttons {"Continue"} default button 1 with title "Install Java"' >/dev/null
fi
cd "$dir"
+++ /dev/null
-#!/usr/bin/nickle
-
-import File;
-
-string timed_read(file f, int timeout) {
- thread reader = fork func() {
- try {
- return fgets(f);
- } catch Thread::signal(int i) {
- return "";
- }
- }();
-
- thread killer = fork func() {
- try {
- sleep (timeout);
- Thread::send_signal(reader, 1);
- } catch Thread::signal(int i) {
- return;
- }
- }();
-
- poly v = Thread::join(reader);
- Thread::send_signal(killer, 1);
- Thread::join(killer);
- if (is_string(v))
- return v;
- return "";
-}
-
-void flush_input(file f) {
- for (;;) {
- string s = timed_read(f, 200);
- if (s == "")
- break;
- }
-}
-
-string[*] settings(file f) {
- string[...] x = {};
-
- flush_input(f);
- fprintf (f, "c s\nv\n");
- flush(f);
- for (;;) {
- string l = File::fgets(f);
- x[dim(x)] = l;
- if (String::index(l, "software-version") == 0)
- break;
- }
- return x;
-}
-
-string[*] find_setting(string[*] s, string match) {
- for (int i = 0; i < dim(s); i++)
- if (String::index(s[i], match) == 0)
- return String::split(s[i], " ");
- return (string[*]) {};
-}
-
-bool
-do_cal(file f) {
- flush_input(f);
- fprintf(f, "E 1\nc a 0\n");
- flush(f);
- string s = "";
- bool worked = true;
- bool running = false;
-
- thread put = fork func() {
- try {
- for (;;) {
- putc(getchar(), f);
- flush(f);
- }
- } catch Thread::signal(int i) {
- return;
- }
- }();
-
- for (;;) {
- int c = getc(f);
- if (c == '\n')
- s = "";
- else
- s = s + String::new(c);
- putchar(c); flush(stdout);
- if (String::index(s, "press a key...") >= 0)
- running = true;
- if (String::index(s, "Invalid") >= 0)
- worked = false;
- if (running && String::index(s, ">") >= 0)
- break;
- }
- fprintf (f, "E 0\n");
- if (worked)
- fprintf (f, "c w\n");
- sleep(200);
- Thread::send_signal(put, 1);
- Thread::join(put);
-
- return worked;
-}
-
-void main () {
- string name = argv[1];
- file f = open(name, "r+");
-
- if (do_cal(f)) {
- string[*] s = settings(f);
- string[*] ac = find_setting(s, "Accel cal");
- printf ("Calibration value +1g %s -1g %s saved\n", ac[3], ac[5]);
- exit (0);
- } else {
- printf ("Calibration failed\n");
- exit (1);
- }
-}
-
-main();
+++ /dev/null
-#!/bin/sh
-
-case $# in
-2)
- dev="$1"
- serial="$2"
- ;;
-*)
- echo "Usage: $0 <device> <serial>"
- exit 1;
- ;;
-esac
-
-echo 'E 0' > $dev
-
-while true; do
-
- dd if=$dev iflag=nonblock of=/dev/null > /dev/null 2>&1
-
- echo 'C 1' > $dev
-
- echo -n "Generating RF carrier. Please enter measured frequency [enter for done]: "
-
- read FREQ
-
- echo 'C 0' > $dev
-
- calline=`./get-radio-cal $dev`
- CURRENT_CAL=`echo $calline | awk '{print $2}'`
- CURRENT_FREQ=`echo $calline | awk '{print $4}'`
- CAL_VALUE=$CURRENT_CAL
-
- case "$FREQ" in
- "")
- echo $serial","$CAL_VALUE >> cal_values
- exit 0
- ;;
- *)
- echo "Current radio calibration "$CURRENT_CAL
- echo "Current radio frequency "$CURRENT_FREQ
-
- CAL_VALUE=`nickle -e "floor($CURRENT_FREQ / $FREQ * $CURRENT_CAL + 0.5)"`
-
- echo "Setting cal value" $CAL_VALUE
-
- dd if=$dev iflag=nonblock of=/dev/null > /dev/null 2>&1
-
- cat << EOF > $dev
-c f $CAL_VALUE
-EOF
- ;;
- esac
-done
-
echo 'E 1' > $dev
-./test-easymega
+./test-easymega-v1.0
exit $?
log_mega = (struct ao_log_mega *) &eeprom->data[pos];
switch (log_mega->type) {
case AO_LOG_FLIGHT:
- printf(" serial %5u flight %5u ground_accel %6d ground_pres %9u",
+ printf(" serial %5u flight %5u ground_accel %6d ground_pres %9u kPa %7.1f %7.1f m",
eeprom->serial_number,
log_mega->u.flight.flight,
log_mega->u.flight.ground_accel,
- log_mega->u.flight.ground_pres);
+ log_mega->u.flight.ground_pres,
+ log_mega->u.flight.ground_pres / 1000.0,
+ ao_pressure_to_altitude(log_mega->u.flight.ground_pres));
+
printf(" along %6d aross %6d through %6d",
log_mega->u.flight.ground_accel_along,
log_mega->u.flight.ground_accel_across,
log_mini = (struct ao_log_mini *) &eeprom->data[pos];
switch (log_mini->type) {
case AO_LOG_FLIGHT:
- printf(" serial %5u flight %5u ground_pres %9u",
+ printf(" serial %5u flight %5u ground_pres %9u kPa %7.1f %7.1f m",
eeprom->serial_number,
log_mini->u.flight.flight,
- log_mini->u.flight.ground_pres);
+ log_mini->u.flight.ground_pres,
+ log_mini->u.flight.ground_pres / 1000.0,
+ ao_pressure_to_altitude(log_mini->u.flight.ground_pres));
break;
case AO_LOG_STATE:
ao_state(log_mini->u.state.state,
log_metrum = (struct ao_log_metrum *) &eeprom->data[pos];
switch (log_metrum->type) {
case AO_LOG_FLIGHT:
- printf(" serial %5u flight %5u ground_accel %6d ground_pres %9u ground_temp %9u",
+ printf(" serial %5u flight %5u ground_accel %6d ground_pres %9u kPa %7.1f %7.1f m ground_temp %9u",
eeprom->serial_number,
log_metrum->u.flight.flight,
log_metrum->u.flight.ground_accel,
log_metrum->u.flight.ground_pres,
+ log_metrum->u.flight.ground_pres / 1000.0,
+ ao_pressure_to_altitude(log_metrum->u.flight.ground_pres),
log_metrum->u.flight.ground_temp);
break;
case AO_LOG_SENSOR:
#define bool(b) ((b) ? "true" : "false")
+static int ignore_crc;
+
+static void
+process(FILE *file)
+{
+ char line[1024];
+ int c;
+
+ while (fgets(line, sizeof (line), file)) {
+ union ao_telemetry_all telem;
+ char call[AO_MAX_CALLSIGN+1];
+ char version[AO_MAX_VERSION+1];
+
+ if (cc_telemetry_parse(line, &telem)) {
+ int rssi = (int8_t) telem.generic.rssi / 2 - 74;
+
+ printf ("serial %5d rssi %d status %02x tick %5d type %3d ",
+ telem.generic.serial, rssi, telem.generic.status,
+ telem.generic.tick, telem.generic.type);
+ if (!ignore_crc && (telem.generic.status & (1 << 7)) == 0) {
+ printf ("CRC error\n");
+ continue;
+ }
+ switch (telem.generic.type) {
+ case AO_TELEMETRY_SENSOR_TELEMETRUM:
+ case AO_TELEMETRY_SENSOR_TELEMINI:
+ case AO_TELEMETRY_SENSOR_TELENANO:
+ printf ("state %1d accel %5d pres %5d ",
+ telem.sensor.state, telem.sensor.accel, telem.sensor.pres);
+ printf ("accel %6.2f speed %6.2f height %5d ",
+ telem.sensor.acceleration / 16.0,
+ telem.sensor.speed / 16.0,
+ telem.sensor.height);
+ printf ("ground_pres %5d ground_accel %5d accel_plus %5d accel_minus %5d\n",
+ telem.sensor.ground_pres,
+ telem.sensor.ground_accel,
+ telem.sensor.accel_plus_g,
+ telem.sensor.accel_minus_g);
+ break;
+ case AO_TELEMETRY_CONFIGURATION:
+ memcpy(call, telem.configuration.callsign, AO_MAX_CALLSIGN);
+ memcpy(version, telem.configuration.version, AO_MAX_VERSION);
+ call[AO_MAX_CALLSIGN] = '\0';
+ version[AO_MAX_CALLSIGN] = '\0';
+ printf ("device %3d flight %5d config %3d.%03d delay %2d main %4d log_max %5d",
+ telem.configuration.device,
+ telem.configuration.flight,
+ telem.configuration.config_major,
+ telem.configuration.config_minor,
+ telem.configuration.apogee_delay,
+ telem.configuration.main_deploy,
+ telem.configuration.flight_log_max);
+ printf (" call %8s version %8s\n", call, version);
+ break;
+ case AO_TELEMETRY_LOCATION:
+ printf ("sats %d flags %s%s%s%s",
+ telem.location.flags & 0xf,
+ (telem.location.flags & (1 << 4)) ? "valid" : "invalid",
+ (telem.location.flags & (1 << 5)) ? ",running" : "",
+ (telem.location.flags & (1 << 6)) ? ",date" : "",
+ (telem.location.flags & (1 << 7)) ? ",course" : "");
+ printf (" alt %5d lat %12.7f lon %12.7f",
+ AO_TELEMETRY_LOCATION_ALTITUDE(&telem.location),
+ telem.location.latitude / 1e7,
+ telem.location.longitude / 1e7);
+ if ((telem.location.flags & (1 << 6)) != 0) {
+ printf (" year %2d month %2d day %2d",
+ telem.location.year,
+ telem.location.month,
+ telem.location.day);
+ printf (" hour %2d minute %2d second %2d",
+ telem.location.hour,
+ telem.location.minute,
+ telem.location.second);
+ }
+ printf (" pdop %3.1f hdop %3.1f vdop %3.1f mode %d",
+ telem.location.pdop / 5.0,
+ telem.location.hdop / 5.0,
+ telem.location.vdop / 5.0,
+ telem.location.mode);
+ if ((telem.location.flags & (1 << 7)) != 0)
+ printf (" ground_speed %6.2f climb_rate %6.2f course %d",
+ telem.location.ground_speed / 100.0,
+ telem.location.climb_rate / 100.0,
+ telem.location.course * 2);
+ printf ("\n");
+ break;
+ case AO_TELEMETRY_SATELLITE:
+ printf ("sats %d", telem.satellite.channels);
+ for (c = 0; c < 12 && c < telem.satellite.channels; c++) {
+ printf (" sat %d svid %d c_n_1 %d",
+ c,
+ telem.satellite.sats[c].svid,
+ telem.satellite.sats[c].c_n_1);
+ }
+ printf ("\n");
+ break;
+ case AO_TELEMETRY_MEGA_SENSOR_MPU:
+ case AO_TELEMETRY_MEGA_SENSOR_BMX160:
+ printf ("orient %3d accel %5d pres %9d temp %5d accel_x %5d accel_y %5d accel_z %5d gyro_x %5d gyro_y %5d gyro_z %5d mag_x %5d mag_y %5d mag_z %5d\n",
+ telem.mega_sensor.orient,
+ telem.mega_sensor.accel,
+ telem.mega_sensor.pres,
+ telem.mega_sensor.temp,
+ telem.mega_sensor.accel_x,
+ telem.mega_sensor.accel_y,
+ telem.mega_sensor.accel_z,
+ telem.mega_sensor.gyro_x,
+ telem.mega_sensor.gyro_y,
+ telem.mega_sensor.gyro_z,
+ telem.mega_sensor.mag_x,
+ telem.mega_sensor.mag_y,
+ telem.mega_sensor.mag_z);
+ break;
+ case AO_TELEMETRY_COMPANION:
+ printf("board_id %3d update_period %3d channels %2d",
+ telem.companion.board_id,
+ telem.companion.update_period,
+ telem.companion.channels);
+ for (c = 0; c < telem.companion.channels; c++)
+ printf(" %6d", telem.companion.companion_data[c]);
+ printf("\n");
+ break;
+ case AO_TELEMETRY_MEGA_DATA:
+ printf ("state %1d v_batt %5d v_pyro %5d ",
+ telem.mega_data.state,
+ telem.mega_data.v_batt,
+ telem.mega_data.v_pyro);
+ for (c = 0; c < 6; c++)
+ printf ("s%1d %5d ", c,
+ telem.mega_data.sense[c] |
+ (telem.mega_data.sense[c] << 8));
+
+ printf ("ground_pres %5d ground_accel %5d accel_plus %5d accel_minus %5d ",
+ telem.mega_data.ground_pres,
+ telem.mega_data.ground_accel,
+ telem.mega_data.accel_plus_g,
+ telem.mega_data.accel_minus_g);
+
+ printf ("accel %6.2f speed %6.2f height %5d\n",
+ telem.mega_data.acceleration / 16.0,
+ telem.mega_data.speed / 16.0,
+ telem.mega_data.height);
+
+ break;
+ case AO_TELEMETRY_METRUM_SENSOR:
+ printf ("state %1d accel %5d pres %9d temp %6.2f acceleration %6.2f speed %6.2f height %5d v_batt %5d sense_a %5d sense_m %5d\n",
+ telem.metrum_sensor.state,
+ telem.metrum_sensor.accel,
+ telem.metrum_sensor.pres,
+ telem.metrum_sensor.temp / 100.0,
+ telem.metrum_sensor.acceleration / 16.0,
+ telem.metrum_sensor.speed / 16.0,
+ telem.metrum_sensor.height,
+ telem.metrum_sensor.v_batt,
+ telem.metrum_sensor.sense_a,
+ telem.metrum_sensor.sense_m);
+ break;
+ case AO_TELEMETRY_METRUM_DATA:
+ printf ("ground_pres %9d ground_accel %5d accel_plus %5d accel_minus %5d\n",
+ telem.metrum_data.ground_pres,
+ telem.metrum_data.ground_accel,
+ telem.metrum_data.accel_plus_g,
+ telem.metrum_data.accel_minus_g);
+ break;
+ case AO_TELEMETRY_MINI:
+ printf ("state %1d v_batt %5d sense_a %5d sense_m %5d pres %9d temp %6.2f acceleration %6.2f speed %6.2f height %5d ground_pres %9d\n",
+ telem.mini.state,
+ telem.mini.v_batt,
+ telem.mini.sense_a,
+ telem.mini.sense_m,
+ telem.mini.pres,
+ telem.mini.temp / 100.0,
+ telem.mini.acceleration / 16.0,
+ telem.mini.speed / 16.0,
+ telem.mini.height,
+ telem.mini.ground_pres);
+ break;
+ default:
+ printf("\n");
+ }
+ }
+ }
+}
+
int
main (int argc, char **argv)
{
- char line[80];
int c, i, ret = 0;
FILE *file;
- int ignore_crc = 0;
while ((c = getopt_long(argc, argv, "c", options, NULL)) != -1) {
switch (c) {
case 'c':
break;
}
}
- for (i = optind; i < argc; i++) {
- file = fopen(argv[i], "r");
- if (!file) {
- perror(argv[i]);
- ret++;
- continue;
- }
- while (fgets(line, sizeof (line), file)) {
- union ao_telemetry_all telem;
- char call[AO_MAX_CALLSIGN+1];
- char version[AO_MAX_VERSION+1];
-
- if (cc_telemetry_parse(line, &telem)) {
- int rssi = (int8_t) telem.generic.rssi / 2 - 74;
-
- printf ("serial %5d rssi %d status %02x tick %5d type %3d ",
- telem.generic.serial, rssi, telem.generic.status,
- telem.generic.tick, telem.generic.type);
- if (!ignore_crc && (telem.generic.status & (1 << 7)) == 0) {
- printf ("CRC error\n");
- continue;
- }
- switch (telem.generic.type) {
- case AO_TELEMETRY_SENSOR_TELEMETRUM:
- case AO_TELEMETRY_SENSOR_TELEMINI:
- case AO_TELEMETRY_SENSOR_TELENANO:
- printf ("state %1d accel %5d pres %5d ",
- telem.sensor.state, telem.sensor.accel, telem.sensor.pres);
- printf ("accel %6.2f speed %6.2f height %5d ",
- telem.sensor.acceleration / 16.0,
- telem.sensor.speed / 16.0,
- telem.sensor.height);
- printf ("ground_pres %5d ground_accel %5d accel_plus %5d accel_minus %5d\n",
- telem.sensor.ground_pres,
- telem.sensor.ground_accel,
- telem.sensor.accel_plus_g,
- telem.sensor.accel_minus_g);
- break;
- case AO_TELEMETRY_CONFIGURATION:
- memcpy(call, telem.configuration.callsign, AO_MAX_CALLSIGN);
- memcpy(version, telem.configuration.version, AO_MAX_VERSION);
- call[AO_MAX_CALLSIGN] = '\0';
- version[AO_MAX_CALLSIGN] = '\0';
- printf ("device %3d flight %5d config %3d.%03d delay %2d main %4d log_max %5d",
- telem.configuration.device,
- telem.configuration.flight,
- telem.configuration.config_major,
- telem.configuration.config_minor,
- telem.configuration.apogee_delay,
- telem.configuration.main_deploy,
- telem.configuration.flight_log_max);
- printf (" call %8s version %8s\n", call, version);
- break;
- case AO_TELEMETRY_LOCATION:
- printf ("sats %d flags %s%s%s%s",
- telem.location.flags & 0xf,
- (telem.location.flags & (1 << 4)) ? "valid" : "invalid",
- (telem.location.flags & (1 << 5)) ? ",running" : "",
- (telem.location.flags & (1 << 6)) ? ",date" : "",
- (telem.location.flags & (1 << 7)) ? ",course" : "");
- printf (" alt %5d lat %12.7f lon %12.7f",
- AO_TELEMETRY_LOCATION_ALTITUDE(&telem.location),
- telem.location.latitude / 1e7,
- telem.location.longitude / 1e7);
- if ((telem.location.flags & (1 << 6)) != 0) {
- printf (" year %2d month %2d day %2d",
- telem.location.year,
- telem.location.month,
- telem.location.day);
- printf (" hour %2d minute %2d second %2d",
- telem.location.hour,
- telem.location.minute,
- telem.location.second);
- }
- printf (" pdop %3.1f hdop %3.1f vdop %3.1f mode %d",
- telem.location.pdop / 5.0,
- telem.location.hdop / 5.0,
- telem.location.vdop / 5.0,
- telem.location.mode);
- if ((telem.location.flags & (1 << 7)) != 0)
- printf (" ground_speed %6.2f climb_rate %6.2f course %d",
- telem.location.ground_speed / 100.0,
- telem.location.climb_rate / 100.0,
- telem.location.course * 2);
- printf ("\n");
- break;
- case AO_TELEMETRY_SATELLITE:
- printf ("sats %d", telem.satellite.channels);
- for (c = 0; c < 12 && c < telem.satellite.channels; c++) {
- printf (" sat %d svid %d c_n_1 %d",
- c,
- telem.satellite.sats[c].svid,
- telem.satellite.sats[c].c_n_1);
- }
- printf ("\n");
- break;
- case AO_TELEMETRY_MEGA_SENSOR_MPU:
- case AO_TELEMETRY_MEGA_SENSOR_BMX160:
- printf ("orient %3d accel %5d pres %9d temp %5d accel_x %5d accel_y %5d accel_z %5d gyro_x %5d gyro_y %5d gyro_z %5d mag_x %5d mag_y %5d mag_z %5d\n",
- telem.mega_sensor.orient,
- telem.mega_sensor.accel,
- telem.mega_sensor.pres,
- telem.mega_sensor.temp,
- telem.mega_sensor.accel_x,
- telem.mega_sensor.accel_y,
- telem.mega_sensor.accel_z,
- telem.mega_sensor.gyro_x,
- telem.mega_sensor.gyro_y,
- telem.mega_sensor.gyro_z,
- telem.mega_sensor.mag_x,
- telem.mega_sensor.mag_y,
- telem.mega_sensor.mag_z);
- break;
- case AO_TELEMETRY_COMPANION:
- printf("board_id %3d update_period %3d channels %2d",
- telem.companion.board_id,
- telem.companion.update_period,
- telem.companion.channels);
- for (c = 0; c < telem.companion.channels; c++)
- printf(" %6d", telem.companion.companion_data[c]);
- printf("\n");
- break;
- case AO_TELEMETRY_MEGA_DATA:
- printf ("state %1d v_batt %5d v_pyro %5d ",
- telem.mega_data.state,
- telem.mega_data.v_batt,
- telem.mega_data.v_pyro);
- for (c = 0; c < 6; c++)
- printf ("s%1d %5d ", c,
- telem.mega_data.sense[c] |
- (telem.mega_data.sense[c] << 8));
-
- printf ("ground_pres %5d ground_accel %5d accel_plus %5d accel_minus %5d ",
- telem.mega_data.ground_pres,
- telem.mega_data.ground_accel,
- telem.mega_data.accel_plus_g,
- telem.mega_data.accel_minus_g);
-
- printf ("accel %6.2f speed %6.2f height %5d\n",
- telem.mega_data.acceleration / 16.0,
- telem.mega_data.speed / 16.0,
- telem.mega_data.height);
-
- break;
- case AO_TELEMETRY_METRUM_SENSOR:
- printf ("state %1d accel %5d pres %9d temp %6.2f acceleration %6.2f speed %6.2f height %5d v_batt %5d sense_a %5d sense_m %5d\n",
- telem.metrum_sensor.state,
- telem.metrum_sensor.accel,
- telem.metrum_sensor.pres,
- telem.metrum_sensor.temp / 100.0,
- telem.metrum_sensor.acceleration / 16.0,
- telem.metrum_sensor.speed / 16.0,
- telem.metrum_sensor.height,
- telem.metrum_sensor.v_batt,
- telem.metrum_sensor.sense_a,
- telem.metrum_sensor.sense_m);
- break;
- case AO_TELEMETRY_METRUM_DATA:
- printf ("ground_pres %9d ground_accel %5d accel_plus %5d accel_minus %5d\n",
- telem.metrum_data.ground_pres,
- telem.metrum_data.ground_accel,
- telem.metrum_data.accel_plus_g,
- telem.metrum_data.accel_minus_g);
- break;
- case AO_TELEMETRY_MINI:
- printf ("state %1d v_batt %5d sense_a %5d sense_m %5d pres %9d temp %6.2f acceleration %6.2f speed %6.2f height %5d ground_pres %9d\n",
- telem.mini.state,
- telem.mini.v_batt,
- telem.mini.sense_a,
- telem.mini.sense_m,
- telem.mini.pres,
- telem.mini.temp / 100.0,
- telem.mini.acceleration / 16.0,
- telem.mini.speed / 16.0,
- telem.mini.height,
- telem.mini.ground_pres);
- break;
- default:
- printf("\n");
- }
+ if (optind < argc) {
+ for (i = optind; i < argc; i++) {
+ file = fopen(argv[i], "r");
+ if (!file) {
+ perror(argv[i]);
+ ret++;
+ continue;
}
- }
- fclose (file);
+ process(file);
+ fclose (file);
- }
+ }
+ } else
+ process(stdin);
return ret;
}
return true;
}
+static const char *
+other_igniter_name(const char *name)
+{
+ if (!strcmp(name, "drogue"))
+ return "apogee";
+ if (!strcmp(name, "apogee"))
+ return "drogue";
+ return name;
+}
+
static struct igniter *
igniters(struct cc_usb *usb)
{
if (found_igniter) {
struct igniter *i;
for (i = head; i; i = i->next)
- if (!strcmp(i->name, igniter_name)) {
+ if (!strcmp(i->name, igniter_name) ||
+ !strcmp(i->name, other_igniter_name(igniter_name)))
+ {
i->adc = atoi(tok);
break;
}
dnl Process this file with autoconf to create configure.
AC_PREREQ(2.57)
-AC_INIT([altos], 1.9.10)
-ANDROID_VERSION=32
+AC_INIT([altos], 1.9.11)
+ANDROID_VERSION=35
AC_CONFIG_SRCDIR([src/kernel/ao.h])
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
-RELEASE_DATE=2021-10-10
+RELEASE_DATE=2022-05-29
AC_SUBST(RELEASE_DATE)
DOC_DATE=`LC_ALL=C date -d $RELEASE_DATE +'%d %b %Y'`
endif
RELNOTES_INC=\
+ release-notes-1.9.11.inc \
release-notes-1.9.10.inc \
release-notes-1.9.9.inc \
release-notes-1.9.8.inc \
config-ui.inc \
load-maps.inc \
aprs-operation.inc \
+ pyro-examples.inc \
handling.inc \
release-head.inc
installation.inc \
using-am-products.inc \
updating-firmware.inc \
+ frequency-cal.inc \
altosui.inc \
altosdroid.inc \
system-operation.inc \
* Make sure doc/altusmetrum-theme.yml has the right copyright year
+* Make sure header.inc has the right copyright year
+
* Add references to that as appropriate from each of the documents:
release-notes.inc
left:
content: '{page-number}'
right:
- content: '© 2021 Bdale Garbee and Keith Packard. Creative Commons ShareAlike 3.0 License'
+ content: '© 2022 Bdale Garbee and Keith Packard. Creative Commons ShareAlike 3.0 License'
verso:
left:
content: $footer_recto_right_content
:revdate: 1 Jan 1970
:icons:
:icontype: svg
-:copyright: Bdale Garbee and Keith Packard 2021
+:copyright: Bdale Garbee and Keith Packard 2022
:doctype: book
:numbered:
:stylesheet: am.css
include::system-operation.adoc[]
+ include::pyro-examples.adoc[]
+
include::handling.adoc[]
include::updating-firmware.adoc[]
+ include::frequency-cal.adoc[]
+
include::flight-data-recording.adoc[]
include::specs.adoc[]
flight. When disabled, the radio will not
transmit anything during flight at all.
+ ==== Limit transmit to 10mW
+
+ Reduces transmit power to no more than 10mW. This is
+ useful when operating under some UK radio regulations.
+
==== Telemetry baud rate
This sets the modulation bit rate for data
[appendix]
== Release Notes
+ :leveloffset: 2
+ include::release-notes-1.9.11.adoc[]
+
+ <<<<
:leveloffset: 2
include::release-notes-1.9.10.adoc[]
:title-logo-image: image:../themes/background.png[]
:revnumber: v{version}
:revdate: 01 Jan 1970
-:copyright: Bdale Garbee and Keith Packard 2021
+:copyright: Bdale Garbee and Keith Packard 2022
:doctype: book
:numbered:
:toc:
--- /dev/null
+[appendix]
+== Frequency Calibration
+
+All products that have radio interfaces require calibration of the radio
+frequency. Normally, this calibration is done once during the production
+process and the resulting cal value is saved into non-volatile memory. The
+procedure decribed here should only be used outside of the factory if you
+are really convinced the radio calibration is bad, and you have access to
+the required tools to do the calibration.
+
+Because this procedure is only rarely needed in the field, we have not
+written any fancy user interface for doing it .. some interaction with
+and careful typing in a command-like style interface are required!
+
+=== Background Information
+
+The radio system on each board uses a quartz crystal to control
+a frequency synthesizer that can be programmed to a range of operating
+frequencies. While these crystals are very stable, they have an accuracy
+specification that means once the base frequency they set is multiplied up
+to the typical operating range of our products, any variation also gets
+multiplied. The objective of the calibration process is, indirectly, to
+measure the actual operating frequency of the crystal and adjust the way
+the frequency synthesizer is programmed to account for this variation.
+
+The frequency may shift a few tens of Hz over the full operating temperature
+range, and it may also shift a bit over time as the crystal ages. But once
+properly calibrated, none of those changes are likely to ever cause any
+operational problem, as the shift in operating frequency due to these factors
+is tiny compared to the bandwidth of our transmitted signal.
+
+=== Required Equipment
+
+The calibration process requires the ability to precisely measure the actual
+frequency of a steady CW carrier on or about the intended operating frequency
+in the vicinity of 435 MHz.
+
+In production, we use an HP 5385A that is locked to a 10 MHz reference that
+is in turn locked to GPS, which provides a highly accurate calibration. Any
+reasonably accurate frequency counter is likely to be sufficient.
+
+You also need a computer with terminal program and USB cable to attach to
+the board in question, along with a battery and power switch suitable for
+powering the board up.
+
+=== RF Calibration Procedure
+
+Using the terminal program, connect to the board over USB. You will find
+that you are now interacting with a command interpreter on the board. Using
+'?' will show the available commands. Of interest for this process are the
+'C' command which turns on a steady transmitted carrier on the currently
+selected operating frequency, and the 'c' subcommands that allow interaction
+with the saved configuration.
+
+Use the 'c s' command to discover and note the current radio calibration
+value, and the operating frequency the board is configured for in kHz.
+
+Set up your frequency counter with a suitable antenna near the board's
+antenna and use the 'C' command to turn on a steady carrier. Let the
+frequency stabilize, and note what it is to as many digits as are steady
+on your counter's display.
+
+To calculate the new calibration value, the equation is:
+
+. (intended_frequency / measured_frequency) * current_cal_value
+
+Set the new calibration value using 'c f <value>', then use 'c w' to save
+that cal value into non-volatile memory. You can use the 'C' command again
+to confirm the operating frequency is now within a few 10's of Hz of the
+intended operating frequency.
+
[license]
== License
-Copyright © 2021 Bdale Garbee and Keith Packard
+Copyright © 2022 Bdale Garbee and Keith Packard
This document is released under the terms of the link:http://creativecommons.org/licenses/by-sa/3.0/[Creative Commons ShareAlike 3.0 License]
--- /dev/null
+[appendix]
+== Example Pyro Channel Configurations
+
+ Programming configurable pyro channels on Altus Metrum products that
+ include them isn't difficult, but in an attempt to aid understanding
+ of the configuration interface and help "keep simple things simple",
+ we offer the following examples of the simplest configurations for
+ common situations, along with some hints on avoiding unexpected
+ results.
+
+ The rich set of conditions provided can be used to configure almost
+ any pyro event you can imagine, for a wide variety of objectives.
+ But don't be fooled! Typical events need only one or a few simple
+ conditions to be configured for success. A key thing to remember is
+ that *all* configured conditions must be true to allow a pyro channel
+ to fire. Trying to include too many conditions often results in
+ conflicting rules that never allow a channel to fire. The most
+ important advice we can offer is, therefore, to try and find the
+ simplest set of conditions that will do what you need for a given
+ project.
+
+ === Two-Stage Flights
+
+ Successful completion of a two-stage flight often involves
+ programming of two events. The first is firing a separation
+ charge, the second is igniting the sustainer's (primary)
+ motor.
+
+ Separation charges are best fired as soon as possible after
+ the previous stage has completed providing acceleration, to
+ minimize drag of the sustainer's coast phase before ignition.
+ Recovery, whether the remainder of the flight is nominal or
+ not, usually works best when the states are separated. So,
+ the "best" way to configure a pyro channel for a separation
+ charge is to just set "after motor number". For a 2-stage
+ project, set this to "1". This will cause the pyro channel
+ to fire as soon as the firmware's flight state machine
+ determines the first motor has burned out.
+
+ Safe ignition of a sustainer (primary) motor requires that
+ it happen after the previous stage burns out, while the
+ airframe remains mostly vertical, and typically after the
+ sustainer has coasted away from the booster a bit. A good
+ starting point is thus "after motor number" set the same as
+ the separation charge, which is "1" for a 2-stage rocket.
+ Then "angle from vertical less than" set to some
+ reasonably vertical amount, perhaps 20 degrees. Then "delay
+ after other conditions" set for the desired duration of coast.
+ Use simulations to figure out what a reasonable value here is,
+ but for typical high power rocketry sport flights that aren't
+ trying to set records, something like 2 seconds is usually a
+ good place to start.
+
+ === Triggered Clusters and Air Starts
+
+ When an airframe has a cluster of motors, one of which is
+ "primary" and centered, surrounding by a ring of "secondary"
+ motors, you may want to use the launch control system to fire the primary motor and use onboard electronics to light
+ the rest of the cluster as soon as launch is detected. This
+ is particularly true if the primary motor is significantly
+ different in geometry and may take longer to come up to
+ pressure than the secondary motors. In this case, a simple
+ configuration to light secondary motors is is "time since
+ boost greater than" enabled and set to "0". There's
+ really no point in setting an angle limit since no time has
+ transpired for the airframe to change orientation.
+
+ Air starts can use the same simple configuration, but with
+ the time set to a non-zero value. However, if air starts
+ are going to light after the airframe leaves the launch rail
+ or tower, add an "angle from vertical less than"
+ condition just you would for a 2-stage sustainer to stay safe.
+
+ === Redundant Apogee
+
+ When flying a board like TeleMega or EasyMega, it's easy to
+ configure a programmable channel to fire a redundant apogee
+ charge. This is of course not *fully* redundant, since it's
+ always possible that the board itself or its battery could
+ the the failure source, but far more often, pyro events fail
+ due to broken wires, bad connectors, or bad e-matches... so
+ firing two charges from one board can add useful redundancy.
+
+ The simplest configuration for redundant apogee is "flight
+ state after" set to "drogue", and then "delay after other
+ conditions" set to a second or two.
+
+ === Redundant Main
+
+ Similarly to apogee, configuring a redundant main charge can
+ provide useful redundancy. What we want is to configure an
+ altitude for deployment lower than the primary main deploy
+ altitude, and then ensure we only trigger on that condition
+ while descending.
+
+ The simplest configuration for redundant main is "flight
+ state after" set to "drogue", which will ensure we're in to
+ the descent phase, then "height less than" set to a number
+ lower than you've chosen for the primary main channel
+ deployment height.
+
+ === Apogee Above Baro Sensor Limit
+
+ A question we've seen increasingly often is "How does the
+ Telemega/Easymega detect apogee for flights above 100,000
+ feet?" Flights above that height are a bit outside
+ our original design envelope, but can be made to work...
+ This is *not* a simple flight, and the configuration for it
+ is also not simple, but we think including this information
+ is important for anyone contemplating such a project with our
+ electronics!
+
+ Our flight computers use a Kalman sensor-fusing filter to
+ estimate the flight state, which consists of three values:
+
+ 1. Height above ground
+ 2. Vertical speed
+ 3. Vertical acceleration
+
+ Apogee is assumed to be where vertical speed crosses zero.
+
+ Below 30km altitude (about 100k'), we use both the barometer
+ and the accelerometer to update the flight state, along with
+ a basic Newtonian model of motion. That works well, pegging
+ apogee within a few sensor samples essentially every time.
+
+ Above 30km, the barometric sensor doesn't provide useful data,
+ so we can't use it to update the flight state. Instead, the
+ Kalman filter falls back to a single sensor mode, using only
+ the accelerometer.
+
+ At all altitudes, we de-sense the barometric data when we
+ estimate the speed is near or above mach as the sensor is
+ often subjected to significant transients, which would
+ otherwise push the flight state estimates too fast and could
+ trigger a false apogee event.
+
+ That means the filter is no longer getting the benefit of two
+ sensors, and relies on just the accelerometer. The trouble
+ with accelerometers is they're measuring the derivative of
+ speed, so you have to integrate their values to compute speed.
+ Any offset error in acceleration measurement gets constantly
+ added to that speed.
+
+ In addition, we assume the axial acceleration is actually
+ vertical acceleration; our tilt measurements have enough
+ integration error during coast that we can't usefully use
+ that to get vertical acceleration. Because we don't live in
+ an inertial frame, that means we're mis-computing the total
+ acceleration acting on the airframe as we have to add gravity
+ into the mix, and simply adding that to the axial acceleration
+ value doesn't generate the right value.
+
+ The effect of this is to under-estimate apogee when you base
+ the computation purely on acceleration as the rocket flies a
+ parabolic path.
+
+ For flights *near* 100k', all of this works pretty well -
+ you've got the flight state estimates adjusted using the
+ barometric sensor up to 30km, then you're flying on inertial
+ data to apogee.
+
+ For flights well above 100k', it's not great; you're usually
+ going fast enough through 100k' that the baro sensor is still
+ de-sensed through the end of its useful range, so the flight
+ state estimates are not as close. After that, as you're flying
+ purely on accelerometer data, there's no way to re-correct the
+ state, so the apogee estimates can be off by quite a bit.
+
+ In the worst cases we have seen, the baro sensor data was
+ wildly incorrect above mach due to poor static port design,
+ leaving the state estimate of speed across the 30km boundary
+ way off and causing the apogee detection to happen far from
+ the correct time.
+
+ The good news is that correctly determining apogee is not
+ really all that important at high altitudes; there's so little
+ density that a drogue will have almost no drag anyways. Data
+ from customer flights shows a very parabolic path down to
+ about 50-60k feet, even with a recovery system deployed.
+
+ So, what we recommend is to set up two apogee plans:
+
+ 1. Use the built-in apogee detection, but add a
+ significant delay (as much as 30 seconds). This
+ will probably fire near enough to apogee to not
+ have a significant impact on the maximum height
+ achieved.
+
+ 2. Add a back-up apogee which fires after apogee
+ *when the height is below about 20-25km*. This
+ way, if the flight isn't nominal, and the sustainer
+ ends up reaching apogee in dense air, you aren't
+ hoping the chutes come out before it gets going
+ too fast. And, you get a second pyro channel firing
+ at that altitude even if it reached a higher
+ altitude before.
+
+ You can wire these two pyro channels to the same pyro device;
+ you just need to make sure they're wired + to + and - to -
+ (the manual shows which screw terminals are which).
+
+ The bottom line is that flights to altitudes modestly above
+ the range of the baro sensor with Altus Metrum products can
+ be accomplished safely, but flying "way high" (like 300k')
+ demands a deployment mechanism which doesn't solely rely on
+ altimeters (like ours) which are designed for modest altitude
+ rocketry. Flights to those altitudes also probably need
+ active stabilization to make sure they follow the prescribed
+ trajectory and stay inside their waiver.
--- /dev/null
+= Release Notes for Version 1.9.11
+include::release-head.adoc[]
+:doctype: article
+
+ Version 1.9.11
+
+ == AltOS
+
+ * Make Apogee Delay work again.
+
+ * Allow TX power to be limited to 10mW for compliance with
+ some uses under UK regulations.
+
+ * Fix numerous minor issues with 16- vs 32- bit time values.
+
+ == AltosUI
+
+ * Support M1-based Macs, follow AdoptOpenJDK to Adoptium
+
+ == AltosDroid
+
+ * Handle Bluetooth permissions reliably.
+
+ * Fix some screen rotation bugs.
[appendix]
== Release Notes
+ :leveloffset: 2
+ include::release-notes-1.9.11.adoc[]
+
+ <<<<
:leveloffset: 2
include::release-notes-1.9.10.adoc[]
[appendix]
== Release Notes
+ :leveloffset: 2
+ include::release-notes-1.9.11.adoc[]
+
+ <<<<
:leveloffset: 2
include::release-notes-1.9.10.adoc[]
:title-logo-image: image:../themes/background.png[]
:revnumber: v{version}
:revdate: 01 Jan 1970
-:copyright: Bdale Garbee and Keith Packard 2021
+:copyright: Bdale Garbee and Keith Packard 2022
:stylesheet: am.css
:linkcss:
:toc:
# -iwithsysroot /System/Library/Frameworks/CoreFoundation.framework/Headers
XCODE=/Applications/Xcode.app
-SDK=$(XCODE)/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
+SDK=$(XCODE)/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk
MINVERSION=10.5
OS_LIB_CFLAGS=\
- -DDARWIN -DPOSIX_TTY -arch x86_64 -isysroot $(SDK) \
+ -DDARWIN -DPOSIX_TTY -arch x86_64 -arch arm64 -isysroot $(SDK) \
-mmacosx-version-min=10.5 \
-iwithsysroot /System/Library/Frameworks/JavaVM.framework/Headers \
-iwithsysroot /System/Library/Frameworks/IOKit.framework/Headers \
public boolean crc_valid;
+ public boolean log_empty;
+
int mix_in (int high, int low) {
return high - (high & 0xffff) + low;
}
f.write('\n');
}
+ public boolean is_empty() {
+ boolean empty = true;
+ for (int c : bytes) {
+ if (!Character.isWhitespace(c) && c != 'f')
+ empty = false;
+ }
+ return empty;
+ }
+
public void export (Writer f) throws IOException {
PrintWriter pw = new PrintWriter(f);
pw.printf(" Time, Press(Pa), Height(m), Height(f), Speed(m/s), Speed(mph), Speed(mach), Accel(m/s²), Accel(ft/s²), Accel(g)\n");
int current_crc = swap16(~file_crc & 0xffff);
int crc = get_16(f);
- crc_valid = crc == current_crc;
+ crc_valid = (crc == current_crc);
+
+ if (!crc_valid && is_empty()) {
+ crc_valid = true;
+ nsamples = 0;
+ }
if (log_id == LOG_ID_MICROPEAK2) {
unique_id = get_line(f);
MSG_INSTALL_JAVA="Java doit être installé sur votre système.\nRendez-vous sur java.com et suivez les instructions d'installation..."
MSG_LATER="Plus tard"
MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java by Adoptium"
;;
# German
MSG_INSTALL_JAVA="Auf Ihrem System muss die 'Java'-Software installiert sein.\nBesuchen Sie java.com für weitere Installationshinweise."
MSG_LATER="Später"
MSG_VISIT_JAVA_DOT_COM="Java von Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java von AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java von Adoptium"
;;
# Simplified Chinese
MSG_INSTALL_JAVA="你需要在Mac中安装Java运行环境!\n访问 java.com 了解如何安装。"
MSG_LATER="稍后"
MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java by Adoptium"
;;
# Spanish
MSG_INSTALL_JAVA="¡Necesita tener JAVA instalado en su Mac!\nVisite java.com para consultar las instrucciones para su instalación..."
MSG_LATER="Más tarde"
MSG_VISIT_JAVA_DOT_COM="Java de Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java de AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java de Adoptium"
;;
# English | default
MSG_INSTALL_JAVA="You need to have JAVA installed on your Mac!\nVisit java.com for installation instructions..."
MSG_LATER="Later"
MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java by Adoptium"
;;
esac
stub_logger "[EXIT 3] ${MSG_NO_SUITABLE_JAVA_EXPANDED}"
# display error message with AppleScript
- osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_NO_SUITABLE_JAVA_EXPANDED}\n${MSG_NO_SUITABLE_JAVA_CHECK}\" with title \"${CFBundleName}\" buttons {\" OK \", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTOPENJDK}\"} default button 1${DialogWithIcon}" \
+ osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_NO_SUITABLE_JAVA_EXPANDED}\n${MSG_NO_SUITABLE_JAVA_CHECK}\" with title \"${CFBundleName}\" buttons {\" OK \", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTIUM}\"} default button 1${DialogWithIcon}" \
-e "set response to button returned of the result" \
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"https://www.java.com/download/\"" \
- -e "if response is \"${MSG_VISIT_ADOPTOPENJDK}\" then open location \"https://adoptopenjdk.net/releases.html\""
+ -e "if response is \"${MSG_VISIT_ADOPTIUM}\" then open location \"https://adoptium.net/releases.html\""
# exit with error
exit 3
# log exit cause
stub_logger "[EXIT 1] ${MSG_ERROR_LAUNCHING}"
# display error message with AppleScript
- osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_INSTALL_JAVA}\" with title \"${CFBundleName}\" buttons {\"${MSG_LATER}\", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTOPENJDK}\"} default button 1${DialogWithIcon}" \
+ osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_INSTALL_JAVA}\" with title \"${CFBundleName}\" buttons {\"${MSG_LATER}\", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTIUM}\"} default button 1${DialogWithIcon}" \
-e "set response to button returned of the result" \
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"https://www.java.com/download/\"" \
- -e "if response is \"${MSG_VISIT_ADOPTOPENJDK}\" then open location \"https://adoptopenjdk.net/releases.html\""
+ -e "if response is \"${MSG_VISIT_ADOPTIUM}\" then open location \"https://adoptium.net/releases.html\""
# exit with error
exit 1
fi
-Wmissing-declarations \
-Wnested-externs \
-Wshadow \
- -Warray-bounds=2
+ -Warray-bounds=2 \
+ -Wconversion
OPT=-Os -Wl,-Map=$(PROGNAME)-$(VERSION).map
},
};
-const int xrcon[30] = {
+const word8 xrcon[30] = {
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36,
0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6,
0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91,
extern const word8x4 M0[4][256];
extern const word8x4 M1[4][256];
-extern const int xrcon[30];
+extern const word8 xrcon[30];
extern const word8 xS[256];
extern const word8 xSi[256];
MCU=attiny85
DUDECPUTYPE=t85
#PROGRAMMER=stk500v2 -P usb
+PROGRAMMER=avrisp2
LOADSLOW=-i 32 -B 32
LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
*/
#define ao_spi_get_mask(reg,mask,bus,speed) do { \
- (reg) &= ~(mask); \
+ (reg) &= (uint8_t) ~(mask); \
} while (0)
#define ao_spi_put_mask(reg,mask,bus) do { \
void
ao_async_stop(void)
{
- LED_PORT &= ~(1 << AO_LED_SERIAL);
+ LED_PORT &= (uint8_t) ~(1 << AO_LED_SERIAL);
}
void
uint8_t bit;
uint8_t w_hi, w_lo;
- /* start data stop */
- w = (0x000 << 0) | (byte << 1) | (0x001 << 9);
+ /* start data stop */
+ w = (uint16_t) ((0x000 << 0) | (byte << 1) | (0x001 << 9));
- w_hi = w >> 8;
- w_lo = w;
+ w_hi = (uint8_t) (w >> 8);
+ w_lo = (uint8_t) w;
ao_arch_block_interrupts();
ISR(TIMER1_COMPA_vect)
{
++ao_tick_count;
- if ((int16_t) (ao_tick_count - ao_wakeup_count) >= 0)
+ if ((AO_TICK_SIGNED) (ao_tick_count - ao_wakeup_count) >= 0)
ao_wakeup((void *) &ao_tick_count);
}
{
cli();
ao_wakeup_count = target;
- while ((int16_t) (target - ao_tick_count) > 0)
+ while ((AO_TICK_SIGNED) (target - ao_tick_count) > 0)
ao_sleep((void *) &ao_tick_count);
sei();
}
{
(void) mode;
pcint_callback = callback;
- pcint_mask = (1 << pin);
+ pcint_mask = (uint8_t) (1 << pin);
ao_exti_disable(PORTB, pin);
GIMSK |= (1 << PCIE);
}
#define ao_exti_enable(gpio, pin) (PCMSK |= (1 << (pin)))
-#define ao_exti_disable(gpio, pin) (PCMSK &= ~(1 << (pin)))
+#define ao_exti_disable(gpio, pin) (PCMSK &= (uint8_t) ~(1 << (pin)))
#define ao_exti_init()
void
ao_led_off(uint8_t colors)
{
- LED_PORT &= ~colors;
+ LED_PORT &= (uint8_t) ~colors;
}
void
ao_led_set(uint8_t colors)
{
- LED_PORT = (LED_PORT & ~LEDS_AVAILABLE) | (colors & LEDS_AVAILABLE);
+ LED_PORT = (uint8_t) ((LED_PORT & ~LEDS_AVAILABLE) | (colors & LEDS_AVAILABLE));
}
void
ao_led_toggle(uint8_t colors)
{
- LED_PORT ^= (colors & LEDS_AVAILABLE);
+ LED_PORT = (uint8_t) (LED_PORT ^ (colors & LEDS_AVAILABLE));
}
void
void
ao_led_init(void)
{
- LED_PORT &= ~LEDS_AVAILABLE;
+ LED_PORT &= (uint8_t) ~LEDS_AVAILABLE;
LED_DDR |= LEDS_AVAILABLE;
}
#else
USICR = SPI_USICR_FAST_2;
#endif
- SPI_DIR &= ~(1 << DDB0); /* DI */
+ SPI_DIR &= (uint8_t) ~(1 << DDB0); /* DI */
SPI_DIR |= (1 << DDB1); /* DO */
SPI_DIR |= (1 << DDB2); /* SCLK */
}
}
void
-ao_led_for(uint8_t colors, uint16_t ticks)
+ao_led_for(uint8_t colors, AO_TICK_TYPE ticks)
{
ao_led_on(colors);
ao_delay(ticks);
#include "ao.h"
-volatile uint16_t ao_tick_count;
+volatile AO_TICK_TYPE ao_tick_count;
-uint16_t ao_time(void)
+AO_TICK_TYPE ao_time(void)
{
uint16_t v;
ao_arch_critical(
for (bit = 0; bit < 8; ++bit)
{
- crc ^= (value & 0x01);
+ crc = (uint16_t) (crc ^ (value & 0x01));
crc = ( crc & 0x01 ) ? ( crc >> 1 ) ^ 0x8408 : ( crc >> 1 );
value = value >> 1;
} // END for
TNC_AX25_HEADER[TNC_CALLSIGN_OFF + i] = ' ' << 1;
/* Fill in the SSID with the low digit of the serial number */
- TNC_AX25_HEADER[TNC_SSID_OFF] = 0x60 | ((ao_config.aprs_ssid & 0xf) << 1);
+ TNC_AX25_HEADER[TNC_SSID_OFF] = (uint8_t) (0x60 | ((ao_config.aprs_ssid & 0xf) << 1));
#endif
}
static void tncCompressInt(uint8_t *dest, int32_t value, int len) {
int i;
for (i = len - 1; i >= 0; i--) {
- dest[i] = value % 91 + 33;
+ dest[i] = (uint8_t) (value % 91 + 33);
value /= 91;
}
}
static inline uint32_t
fixed30_mul(uint32_t x, uint32_t y)
{
- return ((uint64_t) x * y + fixed30_half) >> 30;
+ return (uint32_t) (((uint64_t) x * y + fixed30_half) >> 30);
}
/*
*/
static uint32_t
-ao_fixed_log2(uint32_t x)
+ao_fixed_log2(int32_t ix)
{
uint32_t result;
uint32_t frac = fixed23_one;
+ uint32_t x;
/* Bounds check for sanity */
- if (x <= 0)
+ if (ix <= 0)
return 0;
+ x = (uint32_t) ix;
+
if (x >= fixed30_one)
return 0xffffffff;
#define APRS_LOG_CONVERT fixed23_real(1.714065192056127)
#define APRS_LOG_BASE fixed23_real(346.920048461100941)
-static int
+static int32_t
ao_aprs_encode_altitude(int meters)
{
- return fixed23_floor(fixed23_mul(ao_fixed_log2(meters) + APRS_LOG_CONVERT, APRS_LOG_BASE) + fixed23_half);
+ return (int32_t) fixed23_floor(fixed23_mul(ao_fixed_log2(meters) + APRS_LOG_CONVERT, APRS_LOG_BASE) + fixed23_half);
}
/**
* Generate the plain text position packet.
*/
-static int tncPositionPacket(void)
+static uint8_t tncPositionPacket(void)
{
static int32_t latitude;
static int32_t longitude;
/* Symbol table ID */
*buf++ = '/';
- lat = ((uint64_t) 380926 * (900000000 - latitude)) / 10000000;
- lon = ((uint64_t) 190463 * (1800000000 + longitude)) / 10000000;
+ lat = (int32_t) (((int64_t) 380926 * (900000000 - latitude)) / 10000000);
+ lon = (int32_t) (((int64_t) 190463 * (1800000000 + longitude)) / 10000000);
alt = ao_aprs_encode_altitude(altitude);
if (lon > 1800000000)
lon = 1800000000;
- lat_deg = lat / 10000000;
+ lat_deg = (uint16_t) (lat / 10000000);
lat -= lat_deg * 10000000;
lat *= 60;
- lat_min = lat / 10000000;
+ lat_min = (uint16_t) (lat / 10000000);
lat -= lat_min * 10000000;
- lat_frac = lat / 100000;
+ lat_frac = (uint16_t) (lat / 100000);
- lon_deg = lon / 10000000;
+ lon_deg = (uint16_t) (lon / 10000000);
lon -= lon_deg * 10000000;
lon *= 60;
- lon_min = lon / 10000000;
+ lon_min = (uint16_t) (lon / 10000000);
lon -= lon_min * 10000000;
- lon_frac = lon / 100000;
+ lon_frac = (uint16_t) (lon / 100000);
/* Convert from meters to feet */
alt = (alt * 328 + 50) / 100;
buf += tncComment(buf);
- return buf - tncBuffer;
+ return (uint8_t) (buf - tncBuffer);
}
static int16_t
while (tncMode != TNC_TX_READY && l < len) {
b = 0;
for (bit = 0; bit < 8; bit++) {
- b = b << 1 | (timeNCO >> 15);
+ b = (uint8_t) (b << 1 | (timeNCO >> 15));
timeNCO += timeNCOFreq;
}
*buf++ = b;
crc = sysCRC16(tncBuffer, tncLength, crc ^ 0xffff);
// Save the CRC in the message.
- tncBuffer[tncLength++] = crc & 0xff;
- tncBuffer[tncLength++] = (crc >> 8) & 0xff;
+ tncBuffer[tncLength++] = (uint8_t) (crc & 0xff);
+ tncBuffer[tncLength++] = (uint8_t) ((crc >> 8) & 0xff);
// Prepare the variables that are used in the real-time clock interrupt.
tncBitCount = 0;
uint8_t lo = _ao_bmm150_reg_read(lo_addr);
uint8_t hi = _ao_bmm150_reg_read(hi_addr);
- return ((uint16_t) hi << 8) | lo;
+ return (uint16_t) (((uint16_t) hi << 8) | (uint16_t) lo);
}
/*
//printf("comp_x10 %d\n", process_comp_x10);
retval = ((int16_t)(process_comp_x10 / 8192));
//printf("ret 1 %d\n", retval);
- retval = (retval + (((int16_t)ao_bmm150_trim.dig_x1) * 8)) / 16;
+ retval = (int16_t) ((retval + (((int16_t)ao_bmm150_trim.dig_x1) * 8)) / 16);
//printf("final %d\n", retval);
}
else
process_comp_y8 = (((process_comp_y6 + ((int32_t)0x100000)) * process_comp_y7) / 4096);
process_comp_y9 = (((int32_t)mag_data_y) * process_comp_y8);
retval = (int16_t)(process_comp_y9 / 8192);
- retval = (retval + (((int16_t)ao_bmm150_trim.dig_y1) * 8)) / 16;
+ retval = (int16_t) ((retval + (((int16_t)ao_bmm150_trim.dig_y1) * 8)) / 16);
}
else
{
BMX160_ACC_RANGE_16G);
for (r = 0x3; r <= 0x1b; r++)
- (void) _ao_bmx160_reg_read(r);
+ (void) _ao_bmx160_reg_read((uint8_t) r);
/* Configure gyro:
*
_ao_bmm150_reg_write(BMM150_REPZ, BMM150_REPZ_VALUE(15));
/* Read Trim values */
- ao_bmm150_trim.dig_x1 = _ao_bmm150_reg_read(BMM150_DIG_X1);
- ao_bmm150_trim.dig_y1 = _ao_bmm150_reg_read(BMM150_DIG_Y1);
- ao_bmm150_trim.dig_z4 = _ao_bmm150_reg_read2(BMM150_DIG_Z4_LSB, BMM150_DIG_Z4_MSB);
- ao_bmm150_trim.dig_x2 = _ao_bmm150_reg_read(BMM150_DIG_X2);
- ao_bmm150_trim.dig_y2 = _ao_bmm150_reg_read(BMM150_DIG_Y2);
- ao_bmm150_trim.dig_z2 = _ao_bmm150_reg_read2(BMM150_DIG_Z2_LSB, BMM150_DIG_Z2_MSB);
+ ao_bmm150_trim.dig_x1 = (int8_t) _ao_bmm150_reg_read(BMM150_DIG_X1);
+ ao_bmm150_trim.dig_y1 = (int8_t) _ao_bmm150_reg_read(BMM150_DIG_Y1);
+ ao_bmm150_trim.dig_z4 = (int8_t) _ao_bmm150_reg_read2(BMM150_DIG_Z4_LSB, BMM150_DIG_Z4_MSB);
+ ao_bmm150_trim.dig_x2 = (int8_t) _ao_bmm150_reg_read(BMM150_DIG_X2);
+ ao_bmm150_trim.dig_y2 = (int8_t) _ao_bmm150_reg_read(BMM150_DIG_Y2);
+ ao_bmm150_trim.dig_z2 = (int8_t) _ao_bmm150_reg_read2(BMM150_DIG_Z2_LSB, BMM150_DIG_Z2_MSB);
ao_bmm150_trim.dig_z1 = _ao_bmm150_reg_read2(BMM150_DIG_Z1_LSB, BMM150_DIG_Z1_MSB);
ao_bmm150_trim.dig_xyz1 = _ao_bmm150_reg_read2(BMM150_DIG_XYZ1_LSB, BMM150_DIG_XYZ1_MSB);
- ao_bmm150_trim.dig_z3 = _ao_bmm150_reg_read2(BMM150_DIG_Z3_LSB, BMM150_DIG_Z3_MSB);
- ao_bmm150_trim.dig_xy2 = _ao_bmm150_reg_read(BMM150_DIG_XY2);
+ ao_bmm150_trim.dig_z3 = (int8_t) _ao_bmm150_reg_read2(BMM150_DIG_Z3_LSB, BMM150_DIG_Z3_MSB);
+ ao_bmm150_trim.dig_xy2 = (int8_t) _ao_bmm150_reg_read(BMM150_DIG_XY2);
ao_bmm150_trim.dig_xy1 = _ao_bmm150_reg_read(BMM150_DIG_XY1);
/* To get data out of the magnetometer, set the control op mode to 'forced', then read
#define ao_serial_btm_drain ao_serial1_drain
#endif
-int8_t ao_btm_stdio;
+uint8_t ao_btm_stdio;
uint8_t ao_btm_connected;
#define BT_DEBUG 0
while ((c = ao_btm_getchar()) != AO_READ_AGAIN) {
ao_btm_log_in_char(c);
if (ao_btm_reply_len < sizeof (ao_btm_reply))
- ao_btm_reply[ao_btm_reply_len++] = c;
+ ao_btm_reply[ao_btm_reply_len++] = (char) c;
if (c == '\r' || c == '\n')
break;
}
* Wait for the bluetooth device to return
* status from the previously executed command
*/
-static uint8_t
+static int
ao_btm_wait_reply(void)
{
for (;;) {
ao_btm_putchar(c);
}
-static uint8_t
+static int
ao_btm_cmd(const char *cmd)
{
ao_btm_drain();
return ao_btm_wait_reply();
}
-static uint8_t
+static int
ao_btm_set_name(void)
{
char sn[8];
*--s = '\r';
n = ao_serial_number;
do {
- *--s = '0' + n % 10;
+ *--s = (uint8_t) ('0' + n % 10);
} while (n /= 10);
while ((c = *s++))
ao_btm_putchar(c);
static void
_ao_button_init(uint8_t b)
{
- uint8_t m = ao_arch_irqsave();
+ uint32_t m = ao_arch_irqsave();
uint8_t value = _ao_button_get(b);
ao_button_state[b].value = value;
ao_button_state[b].time = ao_time();
data[0] = ((1 << CC1120_READ) |
(0 << CC1120_BURST) |
CC1120_EXTENDED);
- data[1] = addr;
+ data[1] = (uint8_t) addr;
d = 2;
} else {
data[0] = ((1 << CC1120_READ) |
(0 << CC1120_BURST) |
- addr);
+ (uint8_t) addr);
d = 1;
}
ao_radio_select();
data[0] = ((0 << CC1120_READ) |
(0 << CC1120_BURST) |
CC1120_EXTENDED);
- data[1] = addr;
+ data[1] = (uint8_t) addr;
d = 2;
} else {
data[0] = ((0 << CC1120_READ) |
(0 << CC1120_BURST) |
- addr);
+ (uint8_t) addr);
d = 1;
}
data[d] = value;
addr |= ((1 << CC1120_READ) |
(1 << CC1120_BURST));
}
- ao_radio_spi_send_byte(addr);
+ ao_radio_spi_send_byte((uint8_t) addr);
}
static void
int i;
for (i = 0; i < nreg; i++) {
- ao_radio_reg_write(regs[0], regs[1]);
+ ao_radio_reg_write(regs[0], (uint8_t) regs[1]);
regs += 2;
}
}
if (new_mode == ao_radio_mode)
return;
- changes = new_mode & (~ao_radio_mode);
+ changes = (uint16_t) (new_mode & (~ao_radio_mode));
if (changes & AO_RADIO_MODE_BITS_PACKET) {
ao_radio_set_regs(packet_setup);
if (!ao_radio_configured)
ao_radio_setup();
if (ao_config.radio_setting != last_radio_setting) {
- ao_radio_reg_write(CC1120_FREQ2, ao_config.radio_setting >> 16);
- ao_radio_reg_write(CC1120_FREQ1, ao_config.radio_setting >> 8);
- ao_radio_reg_write(CC1120_FREQ0, ao_config.radio_setting);
+ ao_radio_reg_write(CC1120_FREQ2, (uint8_t) (ao_config.radio_setting >> 16));
+ ao_radio_reg_write(CC1120_FREQ1, (uint8_t) (ao_config.radio_setting >> 8));
+ ao_radio_reg_write(CC1120_FREQ0, (uint8_t) (ao_config.radio_setting));
last_radio_setting = ao_config.radio_setting;
}
if (ao_config.radio_rate != last_radio_rate) {
- ao_radio_mode &= ~AO_RADIO_MODE_BITS_PACKET;
+ ao_radio_mode &= (uint16_t) ~AO_RADIO_MODE_BITS_PACKET;
last_radio_rate = ao_config.radio_rate;
}
ao_radio_set_len(len);
static uint8_t radio_on;
ao_cmd_white();
if (ao_cmd_lex_c != '\n') {
- mode = ao_cmd_decimal();
+ mode = (uint8_t) ao_cmd_decimal();
}
mode++;
if ((mode & 2) && !radio_on) {
}
static void
-ao_radio_wait_isr(uint16_t timeout)
+ao_radio_wait_isr(AO_TICK_TYPE timeout)
{
ao_arch_block_interrupts();
while (!ao_radio_wake && !ao_radio_mcu_wake && !ao_radio_abort)
}
if (done) {
- ao_radio_set_len(total & 0xff);
+ ao_radio_set_len((uint8_t) (total & 0xff));
ao_radio_set_mode(AO_RADIO_MODE_APRS_FINISH);
} else
ao_radio_set_mode(AO_RADIO_MODE_APRS_BUF);
- ao_radio_fifo_write(buf, cnt);
+ ao_radio_fifo_write(buf, (uint8_t) cnt);
if (!started) {
ao_radio_start_tx();
}
uint8_t
-ao_radio_recv(void *d, uint8_t size, uint8_t timeout)
+ao_radio_recv(void *d, uint8_t size, AO_TICK_TYPE timeout)
{
uint8_t len;
uint8_t radio_rssi = 0;
rx_packet_tick = 0;
#endif
len = size + 2; /* CRC bytes */
- len += 1 + ~(len & 1); /* 1 or two pad bytes */
+ len += (uint8_t) (1 + ~(len & 1)); /* 1 or two pad bytes */
len *= 2; /* 1/2 rate convolution */
rx_data_count = len * 8; /* bytes to bits */
rx_data_cur = 0;
rssi0 = ao_radio_reg_read(CC1120_RSSI0);
if (rssi0 & 1) {
- int8_t rssi = ao_radio_reg_read(CC1120_RSSI1);
+ int8_t rssi = (int8_t) ao_radio_reg_read(CC1120_RSSI1);
ao_radio_rssi = rssi;
/* Bound it to the representable range */
/* Carrier sense threshold - 25dB above the noise */\r
CC1120_AGC_CS_THR, 25, /* Carrier Sense Threshold Configuration */\r
CC1120_AGC_GAIN_ADJUST, /* RSSI Offset Configuration */\r
- AO_CC1120_AGC_GAIN_ADJUST,\r
+ (uint16_t) AO_CC1120_AGC_GAIN_ADJUST,\r
\r
CC1120_AGC_CFG3, /* AGC Configuration */\r
(1 << CC1120_AGC_CFG3_RSSI_STEP_THR) |\r
if (new_mode == ao_radio_mode)
return;
- changes = new_mode & (~ao_radio_mode);
+ changes = (uint16_t) (new_mode & (~ao_radio_mode));
if (changes & AO_RADIO_MODE_BITS_PACKET_TX) {
ao_radio_reg_write(CC115L_MDMCFG4, packet_rate_setup[ao_config.radio_rate].mdmcfg4);
ao_radio_reg_write(CC115L_DEVIATN, packet_rate_setup[ao_config.radio_rate].deviatn);
for (i = 0; i < sizeof (packet_setup) / sizeof (packet_setup[0]); i += 2)
- ao_radio_reg_write(packet_setup[i], packet_setup[i+1]);
+ ao_radio_reg_write((uint8_t) packet_setup[i], (uint8_t) packet_setup[i+1]);
}
if (changes & AO_RADIO_MODE_BITS_RDF)
for (i = 0; i < sizeof (rdf_setup) / sizeof (rdf_setup[0]); i += 2)
- ao_radio_reg_write(rdf_setup[i], rdf_setup[i+1]);
+ ao_radio_reg_write((uint8_t) rdf_setup[i], (uint8_t) rdf_setup[i+1]);
if (changes & AO_RADIO_MODE_BITS_APRS)
for (i = 0; i < sizeof (aprs_setup) / sizeof (aprs_setup[0]); i += 2)
- ao_radio_reg_write(aprs_setup[i], aprs_setup[i+1]);
+ ao_radio_reg_write((uint8_t) aprs_setup[i], (uint8_t) aprs_setup[i+1]);
if (changes & AO_RADIO_MODE_BITS_INFINITE)
ao_radio_reg_write(CC115L_PKTCTRL0, AO_PKTCTRL0_INFINITE);
ao_delay(AO_MS_TO_TICKS(10));
for (i = 0; i < sizeof (radio_setup) / sizeof (radio_setup[0]); i += 2)
- ao_radio_reg_write(radio_setup[i], radio_setup[i+1]);
+ ao_radio_reg_write((uint8_t) radio_setup[i], (uint8_t) radio_setup[i+1]);
ao_radio_mode = 0;
if (!ao_radio_configured)
ao_radio_setup();
if (ao_config.radio_setting != last_radio_setting) {
- ao_radio_reg_write(CC115L_FREQ2, ao_config.radio_setting >> 16);
- ao_radio_reg_write(CC115L_FREQ1, ao_config.radio_setting >> 8);
- ao_radio_reg_write(CC115L_FREQ0, ao_config.radio_setting);
+ ao_radio_reg_write(CC115L_FREQ2, (uint8_t) (ao_config.radio_setting >> 16));
+ ao_radio_reg_write(CC115L_FREQ1, (uint8_t) (ao_config.radio_setting >> 8));
+ ao_radio_reg_write(CC115L_FREQ0, (uint8_t) (ao_config.radio_setting));
last_radio_setting = ao_config.radio_setting;
/* Make sure the RF calibration is current */
ao_radio_strobe(CC115L_SCAL);
}
if (ao_config.radio_rate != last_radio_rate) {
- ao_radio_mode &= ~AO_RADIO_MODE_BITS_PACKET_TX;
+ ao_radio_mode &= (uint16_t) ~AO_RADIO_MODE_BITS_PACKET_TX;
last_radio_rate = ao_config.radio_rate;
}
}
this_time = len;
/* queue the data */
- memset(buf, t->value, this_time);
+ memset(buf, t->value, (size_t) this_time);
/* mark as sent */
len -= this_time;
- ao_radio_tone_offset += this_time;
+ ao_radio_tone_offset += (uint8_t) this_time;
ret += this_time;
if (ao_radio_tone_offset >= t->len) {
ao_radio_tone = tones;
ao_radio_tone_current = 0;
ao_radio_tone_offset = 0;
- ao_radio_tone_count = ntones;
+ ao_radio_tone_count = (uint8_t) ntones;
_ao_radio_send_lots(ao_radio_tone_fill, AO_RADIO_MODE_RDF);
ao_radio_put();
}
static uint8_t radio_on;
ao_cmd_white();
if (ao_cmd_lex_c != '\n')
- mode = ao_cmd_decimal();
+ mode = (uint8_t) ao_cmd_decimal();
mode++;
if ((mode & 2) && !radio_on) {
#if HAS_MONITOR
this_time = ao_radio_send_len;
if (this_time > len)
this_time = len;
- memcpy(buf, ao_radio_send_buf, this_time);
+ memcpy(buf, ao_radio_send_buf, (size_t) this_time);
ao_radio_send_buf += this_time;
ao_radio_send_len -= this_time;
if (ao_radio_send_len == 0)
/* At the last buffer, set the total length */
if (done) {
- ao_radio_set_len(total & 0xff);
+ ao_radio_set_len((uint8_t) (total & 0xff));
ao_radio_set_mode(mode | AO_RADIO_MODE_BITS_FIXED);
} else {
ao_radio_set_len(0xff);
b = buf;
while (cnt) {
- uint8_t this_len = cnt;
+ uint8_t this_len = (uint8_t) cnt;
/* Wait for some space in the fifo */
while (!ao_radio_abort && (fifo_space = ao_radio_tx_fifo_space()) == 0) {
data[0] = ((1 << CC1200_READ) |
(0 << CC1200_BURST) |
CC1200_EXTENDED);
- data[1] = addr;
+ data[1] = (uint8_t) addr;
d = 2;
} else {
data[0] = ((1 << CC1200_READ) |
(0 << CC1200_BURST) |
- addr);
+ (uint8_t) addr);
d = 1;
}
ao_radio_select();
data[0] = ((0 << CC1200_READ) |
(0 << CC1200_BURST) |
CC1200_EXTENDED);
- data[1] = addr;
+ data[1] = (uint8_t) addr;
d = 2;
} else {
data[0] = ((0 << CC1200_READ) |
(0 << CC1200_BURST) |
- addr);
+ (uint8_t) addr);
d = 1;
}
data[d] = value;
int i;
for (i = 0; i < nreg; i++) {
- ao_radio_reg_write(regs[0], regs[1]);
+ ao_radio_reg_write(regs[0], (uint8_t) regs[1]);
regs += 2;
}
}
if (new_mode == ao_radio_mode)
return;
- changes = new_mode & (~ao_radio_mode);
+ changes = (uint16_t) (new_mode & (~ao_radio_mode));
if (changes & AO_RADIO_MODE_BITS_PACKET) {
ao_radio_set_regs(packet_setup);
{
static uint32_t last_radio_setting;
static uint8_t last_radio_rate;
+ static uint8_t last_radio_10mw;
ao_mutex_get(&ao_radio_mutex);
if (!ao_radio_configured)
ao_radio_setup();
if (ao_config.radio_setting != last_radio_setting) {
- ao_radio_reg_write(CC1200_FREQ2, ao_config.radio_setting >> 16);
- ao_radio_reg_write(CC1200_FREQ1, ao_config.radio_setting >> 8);
- ao_radio_reg_write(CC1200_FREQ0, ao_config.radio_setting);
+ ao_radio_reg_write(CC1200_FREQ2, (uint8_t) (ao_config.radio_setting >> 16));
+ ao_radio_reg_write(CC1200_FREQ1, (uint8_t) (ao_config.radio_setting >> 8));
+ ao_radio_reg_write(CC1200_FREQ0, (uint8_t) ao_config.radio_setting);
last_radio_setting = ao_config.radio_setting;
ao_radio_strobe(CC1200_SCAL);
}
if (ao_config.radio_rate != last_radio_rate) {
- ao_radio_mode &= ~AO_RADIO_MODE_BITS_PACKET;
+ ao_radio_mode &= (uint16_t) ~AO_RADIO_MODE_BITS_PACKET;
last_radio_rate = ao_config.radio_rate;
}
+ if(ao_config.radio_10mw != last_radio_10mw) {
+ last_radio_10mw = ao_config.radio_10mw;
+ /*
+ * 0x37 "should" be 10dBm, but measurements on TBT
+ * v4.0 show that too hot, so use * 0x32 to make sure
+ * we're in spec.
+ */
+ if (ao_config.radio_10mw)
+ ao_radio_reg_write(CC1200_PA_CFG1, 0x32);
+ else
+ ao_radio_reg_write(CC1200_PA_CFG1, 0x3f);
+ }
ao_radio_set_len(len);
}
/* Wait for the radio to signal an interrupt
*/
static void
-ao_radio_wait_isr(uint16_t timeout)
+ao_radio_wait_isr(AO_TICK_TYPE timeout)
{
ao_arch_block_interrupts();
while (!ao_radio_wake && !ao_radio_abort)
uint8_t mode = 2;
ao_cmd_white();
if (ao_cmd_lex_c != '\n')
- mode = ao_cmd_decimal();
+ mode = (uint8_t) ao_cmd_decimal();
mode++;
if ((mode & 2))
ao_radio_test_on();
/* At the last buffer, set the total length */
if (done)
- ao_radio_set_len(total & 0xff);
+ ao_radio_set_len((uint8_t) (total & 0xff));
/* Wait for some space in the fifo */
while (started && ao_radio_int_pin() != 0 && !ao_radio_abort) {
else
ao_radio_set_mode(AO_RADIO_MODE_APRS_BUF);
- ao_radio_fifo_write(buf, cnt);
+ ao_radio_fifo_write(buf, (uint8_t) cnt);
if (!started) {
ao_radio_strobe(CC1200_STX);
started = 1;
#endif
uint8_t
-ao_radio_recv(void *d, uint8_t size, uint8_t timeout)
+ao_radio_recv(void *d, uint8_t size, AO_TICK_TYPE timeout)
{
uint8_t success = 0;
switch (ao_config.radio_rate) {
default:
case AO_RADIO_RATE_38400:
- timeout = AO_MS_TO_TICKS(size * (8 * 2 * 10) / 384) + 1;
+ timeout = AO_MS_TO_TICKS((AO_TICK_TYPE) size * (8 * 2 * 10) / 384) + 1;
break;
case AO_RADIO_RATE_9600:
- timeout = AO_MS_TO_TICKS(size * (8 * 2 * 10) / 96) + 1;
+ timeout = AO_MS_TO_TICKS((AO_TICK_TYPE) size * (8 * 2 * 10) / 96) + 1;
break;
case AO_RADIO_RATE_2400:
- timeout = AO_MS_TO_TICKS(size * (8 * 2 * 10) / 24) + 1;
+ timeout = AO_MS_TO_TICKS((AO_TICK_TYPE) size * (8 * 2 * 10) / 24) + 1;
break;
}
}
rssi = -11;
/* Write it back to the packet */
- ((int8_t *) d)[size-2] = AO_RADIO_FROM_RSSI(rssi);
+ ((uint8_t *) d)[size-2] = AO_RADIO_FROM_RSSI(rssi);
} else {
ao_radio_idle();
ao_radio_rssi = 0;
CC1200_AGC_REF, 0x27, /* AGC Reference Level Configuration */
CC1200_AGC_CS_THR, 0xec, /* Carrier Sense Threshold Configuration */
CC1200_AGC_GAIN_ADJUST, /* RSSI adjustment */
- AO_CC1200_AGC_GAIN_ADJUST,
+ (uint16_t) AO_CC1200_AGC_GAIN_ADJUST,
CC1200_AGC_CFG1, 0x51, /* Automatic Gain Control Configuration Reg. 1 */
CC1200_AGC_CFG0, 0x87, /* Automatic Gain Control Configuration Reg. 0 */
CC1200_FIFO_CFG, 0x40, /* FIFO Configuration */
{
ao_companion_command.command = command;
ao_companion_command.flight_state = ao_flight_state;
- ao_companion_command.tick = ao_time();
+ ao_companion_command.tick = (uint16_t) ao_time();
ao_companion_command.serial = ao_serial_number;
ao_companion_command.flight = ao_flight_number;
- ao_companion_command.accel = ao_accel;
- ao_companion_command.speed = ao_speed;
- ao_companion_command.height = ao_height;
+ ao_companion_command.accel = (int16_t) ao_accel;
+ ao_companion_command.speed = (int16_t) ao_speed;
+ ao_companion_command.height = (int16_t) ao_height;
ao_companion_command.motor_number = ao_motor_number;
ao_spi_send(&ao_companion_command, sizeof (ao_companion_command), AO_COMPANION_SPI_BUS);
}
}
uint8_t
-ao_event_get_for(struct ao_event *ev, uint16_t timeout)
+ao_event_get_for(struct ao_event *ev, AO_TICK_TYPE timeout)
{
uint8_t empty = 1;
ao_arch_critical(
struct ao_event {
uint8_t type;
uint8_t unit;
- uint16_t tick;
+ AO_TICK_TYPE tick;
int32_t value;
};
ao_event_get(struct ao_event *ev);
uint8_t
-ao_event_get_for(struct ao_event *ev, uint16_t timeout);
+ao_event_get_for(struct ao_event *ev, AO_TICK_TYPE timeout);
void
ao_event_put_isr(uint8_t type, uint8_t unit, int32_t value);
uint8_t ao_gps_new;
uint8_t ao_gps_mutex;
-uint16_t ao_gps_tick;
+AO_TICK_TYPE ao_gps_tick;
struct ao_telemetry_location ao_gps_data;
struct ao_telemetry_satellite ao_gps_tracking_data;
static uint8_t ao_gps_cksum;
static uint8_t ao_gps_error;
-uint16_t ao_gps_tick;
+AO_TICK_TYPE ao_gps_tick;
struct ao_telemetry_location ao_gps_data;
struct ao_telemetry_satellite ao_gps_tracking_data;
-static uint16_t ao_gps_next_tick;
+static AO_TICK_TYPE ao_gps_next_tick;
static struct ao_telemetry_location ao_gps_next;
static uint8_t ao_gps_date_flags;
static struct ao_telemetry_satellite ao_gps_tracking_next;
uint8_t c = ao_gps_char;
if (c < (uint8_t) '0' || (uint8_t) '9' < c)
break;
- v = v * 10 + (uint8_t) (c - (uint8_t) '0');
+ v = (int16_t) (v * 10 + (uint8_t) (c - (uint8_t) '0'));
ao_gps_num_width++;
ao_gps_lexchar();
}
ao_gps_num_width = 0;
while (ao_gps_num_width < 2) {
uint8_t c = ao_gps_char;
- uint8_t d;
if ((uint8_t) '0' <= c && c <= (uint8_t) '9')
- d = - '0';
+ c -= '0';
else if ((uint8_t) 'A' <= c && c <= (uint8_t) 'F')
- d = - 'A' + 10;
+ c -= 'A' - 10;
else if ((uint8_t) 'a' <= c && c <= (uint8_t) 'f')
- d = - 'a' + 10;
+ c -= 'a' - 10;
else
break;
- v = (v << 4) | (c + d);
+ v = (uint8_t) ((v << 4) | c);
ao_gps_num_width++;
ao_gps_lexchar();
}
static int32_t
ao_gps_parse_pos(uint8_t deg_width)
{
- static uint16_t d;
- static uint8_t m;
- static uint16_t f;
+ int16_t d;
+ int16_t m;
+ int16_t f;
char c;
d = ao_gps_decimal(deg_width);
ao_gps_next_tick = ao_time();
ao_gps_next.flags = AO_GPS_RUNNING | ao_gps_date_flags;
- ao_gps_next.hour = ao_gps_decimal(2);
- ao_gps_next.minute = ao_gps_decimal(2);
- ao_gps_next.second = ao_gps_decimal(2);
+ ao_gps_next.hour = (uint8_t) ao_gps_decimal(2);
+ ao_gps_next.minute = (uint8_t) ao_gps_decimal(2);
+ ao_gps_next.second = (uint8_t) ao_gps_decimal(2);
ao_gps_skip_field(); /* skip seconds fraction */
ao_gps_next.latitude = ao_gps_parse_pos(2);
if (ao_gps_parse_flag('E', 'W'))
ao_gps_next.longitude = -ao_gps_next.longitude;
- i = ao_gps_decimal(0xff);
+ i = (uint8_t) ao_gps_decimal(0xff);
if (i == 1)
ao_gps_next.flags |= AO_GPS_VALID;
- i = ao_gps_decimal(0xff) << AO_GPS_NUM_SAT_SHIFT;
+ i = (uint8_t) (ao_gps_decimal(0xff) << AO_GPS_NUM_SAT_SHIFT);
if (i > AO_GPS_NUM_SAT_MASK)
i = AO_GPS_NUM_SAT_MASK;
ao_gps_next.flags |= i;
ao_gps_lexchar();
- i = ao_gps_decimal(0xff);
+ i = (uint8_t) ao_gps_decimal(0xff);
if (i <= 25) {
i = (uint8_t) 10 * i;
if (ao_gps_char == '.')
static void
ao_nmea_gsv(void)
{
- char c;
+ uint8_t c;
uint8_t i;
uint8_t done;
/* Now read the data into the GPS tracking data record
* ... other SVIDs
* 72 checksum
*/
- c = ao_gps_decimal(1); /* total messages */
- i = ao_gps_decimal(1); /* message sequence */
+ c = (uint8_t) ao_gps_decimal(1); /* total messages */
+ i = (uint8_t) ao_gps_decimal(1); /* message sequence */
if (i == 1) {
ao_gps_tracking_next.channels = 0;
}
ao_gps_skip_field(); /* sats in view */
while (ao_gps_char != '*' && ao_gps_char != '\n' && ao_gps_char != '\r') {
i = ao_gps_tracking_next.channels;
- c = ao_gps_decimal(2); /* SVID */
+ c = (uint8_t) ao_gps_decimal(2); /* SVID */
if (i < AO_MAX_GPS_TRACKING)
ao_gps_tracking_next.sats[i].svid = c;
ao_gps_lexchar();
ao_gps_skip_field(); /* elevation */
ao_gps_lexchar();
ao_gps_skip_field(); /* azimuth */
- c = ao_gps_decimal(2); /* C/N0 */
+ c = (uint8_t) ao_gps_decimal(2); /* C/N0 */
if (i < AO_MAX_GPS_TRACKING) {
if ((ao_gps_tracking_next.sats[i].c_n_1 = c) != 0)
ao_gps_tracking_next.channels = i + 1;
static void
ao_nmea_rmc(void)
{
- char a, c;
+ uint8_t a, c;
uint8_t i;
/* Parse the RMC record to read out the current date */
ao_gps_lexchar();
ao_gps_skip_field();
}
- a = ao_gps_decimal(2);
- c = ao_gps_decimal(2);
- i = ao_gps_decimal(2);
+ a = (uint8_t) ao_gps_decimal(2);
+ c = (uint8_t) ao_gps_decimal(2);
+ i = (uint8_t) ao_gps_decimal(2);
ao_nmea_finish();
uint8_t ao_gps_new;
uint8_t ao_gps_mutex;
-uint16_t ao_gps_tick;
+AO_TICK_TYPE ao_gps_tick;
struct ao_telemetry_location ao_gps_data;
struct ao_telemetry_satellite ao_gps_tracking_data;
static void ao_ublox_put_u16(uint16_t c)
{
- ao_ublox_put_u8(c);
- ao_ublox_put_u8(c>>8);
+ ao_ublox_put_u8((uint8_t) c);
+ ao_ublox_put_u8((uint8_t) (c>>8));
}
#if 0
static void ao_ublox_put_u32(uint32_t c)
{
- ao_ublox_put_u8(c);
- ao_ublox_put_u8(c>>8);
- ao_ublox_put_u8(c>>16);
- ao_ublox_put_u8(c>>24);
+ ao_ublox_put_u8((uint8_t) c);
+ ao_ublox_put_u8((uint8_t) (c>>8));
+ ao_ublox_put_u8((uint8_t) (c>>16));
+ ao_ublox_put_u8((uint8_t) (c>>24));
}
static void ao_ublox_put_i32(int32_t c)
uint16_t val;
val = data_byte();
- val |= data_byte () << 8;
+ val |= (uint16_t) ((uint16_t) data_byte () << 8);
*ptr = val;
}
ao_gps_putchar(0x62);
ao_ublox_put_u8(class);
ao_ublox_put_u8(id);
- ao_ublox_put_u8(len);
- ao_ublox_put_u8(len >> 8);
+ ao_ublox_put_u8((uint8_t) len);
+ ao_ublox_put_u8((uint8_t) (len >> 8));
}
static void
/* Length */
ao_ublox_len = header_byte();
- ao_ublox_len |= header_byte() << 8;
+ ao_ublox_len |= (uint16_t) ((uint16_t) header_byte() << 8);
ao_gps_dbg(DBG_PROTO, "%6u class %02x id %02x len %d\n", packet_start_tick, class, id, ao_ublox_len);
ao_gps_data.latitude = nav_posllh.lat;
ao_gps_data.longitude = nav_posllh.lon;
- ao_gps_data.year = nav_timeutc.year - 2000;
+ ao_gps_data.year = (uint8_t) (nav_timeutc.year - 2000);
ao_gps_data.month = nav_timeutc.month;
ao_gps_data.day = nav_timeutc.day;
/* we report dop scaled by 10, but ublox provides dop scaled by 100
*/
- ao_gps_data.pdop = nav_dop.pdop / 10;
- ao_gps_data.hdop = nav_dop.hdop / 10;
- ao_gps_data.vdop = nav_dop.vdop / 10;
+ ao_gps_data.pdop = (uint8_t) (nav_dop.pdop / 10);
+ ao_gps_data.hdop = (uint8_t) (nav_dop.hdop / 10);
+ ao_gps_data.vdop = (uint8_t) (nav_dop.vdop / 10);
- ao_gps_data.ground_speed = nav_velned.g_speed;
- ao_gps_data.climb_rate = -nav_velned.vel_d;
- ao_gps_data.course = nav_velned.heading / 200000;
+ ao_gps_data.ground_speed = (uint16_t) nav_velned.g_speed;
+ ao_gps_data.climb_rate = -(int16_t) nav_velned.vel_d;
+ ao_gps_data.course = (uint8_t) (nav_velned.heading / 200000);
ao_gps_tracking_data.channels = 0;
/* byte swap */
while (i--) {
uint16_t t = *d;
- *d++ = (t >> 8) | (t << 8);
+ *d++ = (uint16_t) ((t >> 8) | (t << 8));
}
#endif
}
ao_lco_show_pad(uint8_t pad)
{
ao_mutex_get(&ao_lco_display_mutex);
- ao_seven_segment_set(AO_LCO_PAD_DIGIT, pad | (ao_lco_drag_race << 4));
+ ao_seven_segment_set(AO_LCO_PAD_DIGIT, (uint8_t) (pad | (ao_lco_drag_race << 4)));
ao_mutex_put(&ao_lco_display_mutex);
}
{
ao_mutex_get(&ao_lco_display_mutex);
if (box == AO_LCO_BOX_DRAG) {
- ao_seven_segment_direct(AO_LCO_BOX_DIGIT_10, SEVEN_SEGMENT_d | (ao_lco_drag_race << 7));
- ao_seven_segment_direct(AO_LCO_BOX_DIGIT_1, SEVEN_SEGMENT_r | (ao_lco_drag_race << 7));
+ ao_seven_segment_direct(AO_LCO_BOX_DIGIT_10, (uint8_t) (SEVEN_SEGMENT_d | (ao_lco_drag_race << 7)));
+ ao_seven_segment_direct(AO_LCO_BOX_DIGIT_1, (uint8_t) (SEVEN_SEGMENT_r | (ao_lco_drag_race << 7)));
} else {
- ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, box % 10 | (ao_lco_drag_race << 4));
- ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, box / 10 | (ao_lco_drag_race << 4));
+ ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, (uint8_t) (box % 10 | (ao_lco_drag_race << 4)));
+ ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, (uint8_t) (box / 10 | (ao_lco_drag_race << 4)));
}
ao_mutex_put(&ao_lco_display_mutex);
}
{
uint8_t tens, ones, tenths;
- tenths = decivolts % 10;
- ones = (decivolts / 10) % 10;
- tens = (decivolts / 100) % 10;
+ tenths = (uint8_t) (decivolts % 10);
+ ones = (uint8_t) ((decivolts / 10) % 10);
+ tens = (uint8_t) ((decivolts / 100) % 10);
ao_mutex_get(&ao_lco_display_mutex);
ao_seven_segment_set(AO_LCO_PAD_DIGIT, tenths);
ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, ones | 0x10);
static AO_TICK_TYPE
ao_lco_drag_button_check(AO_TICK_TYPE now, AO_TICK_TYPE delay)
{
- AO_TICK_TYPE button_delay = ~0;
+ AO_TICK_TYPE button_delay = ~0UL;
/*
* Check to see if the button has been held down long enough
*/
if (ao_lco_fire_down) {
if (ao_lco_drag_race) {
- if ((AO_TICK_SIGNED) (now - ao_lco_fire_tick) >= AO_LCO_DRAG_RACE_STOP_TIME) {
+ if ((AO_TICK_SIGNED) (now - ao_lco_fire_tick) >= (AO_TICK_SIGNED) AO_LCO_DRAG_RACE_STOP_TIME) {
ao_lco_drag_disable();
ao_lco_fire_down = 0;
}
else
button_delay = ao_lco_fire_tick + AO_LCO_DRAG_RACE_STOP_TIME - now;
} else {
- if ((AO_TICK_SIGNED) (now - ao_lco_fire_tick) >= AO_LCO_DRAG_RACE_START_TIME) {
+ if ((AO_TICK_SIGNED) (now - ao_lco_fire_tick) >= (AO_TICK_SIGNED) AO_LCO_DRAG_RACE_START_TIME) {
ao_lco_drag_enable();
ao_lco_fire_down = 0;
}
static void
ao_lco_drag_monitor(void)
{
- AO_TICK_TYPE delay = ~0;
+ AO_TICK_TYPE delay = ~0UL;
AO_TICK_TYPE now;
ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200));
else
ao_sleep_for(&ao_lco_drag_beep_count, delay);
- delay = ~0;
+ delay = ~0UL;
if (!ao_lco_drag_active)
continue;
/* check to see if there's anything left to do here */
if (!ao_lco_fire_down && !ao_lco_drag_race && !ao_lco_drag_beep_count) {
- delay = ~0;
+ delay = ~0UL;
ao_lco_drag_active = 0;
}
}
static void
ao_lco_step_box(int8_t dir)
{
- int16_t new_box = ao_lco_box;
+ int32_t new_box = (int32_t) ao_lco_box;
do {
if (new_box == AO_LCO_BOX_DRAG) {
if (dir < 0)
else if (new_box < ao_lco_min_box)
new_box = AO_LCO_BOX_DRAG;
}
- if (new_box == ao_lco_box)
+ if (new_box == (int32_t) ao_lco_box)
break;
- } while (!ao_lco_box_present(new_box));
- ao_lco_set_box(new_box);
+ } while (!ao_lco_box_present((uint16_t) new_box));
+ ao_lco_set_box((uint16_t) new_box);
}
static void
case AO_EVENT_BUTTON:
switch (event.unit) {
case AO_BUTTON_ARM:
- ao_lco_set_armed(event.value);
+ ao_lco_set_armed((uint8_t) event.value);
break;
case AO_BUTTON_FIRE:
if (ao_lco_armed) {
ao_lco_fire_down = 0;
- ao_lco_set_firing(event.value);
+ ao_lco_set_firing((uint8_t) event.value);
} else {
if (event.value) {
if (ao_lco_box == AO_LCO_BOX_DRAG) {
ao_adc_single_get(&packet);
decivolt = ao_battery_decivolt(packet.v_batt);
- ao_lco_show_voltage(decivolt);
+ ao_lco_show_voltage((uint16_t) decivolt);
ao_delay(AO_MS_TO_TICKS(1000));
}
#endif
static void
ao_lco_set_debug(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status == ao_cmd_success)
ao_lco_debug = r != 0;
}
#endif
extern uint8_t ao_lco_pad; /* Currently selected pad */
-extern int16_t ao_lco_box; /* Currently selected box */
+extern uint16_t ao_lco_box; /* Currently selected box */
extern uint8_t ao_lco_armed; /* armed mode active */
extern uint8_t ao_lco_firing; /* fire button pressed */
#define AO_LCO_PAD_VOLTAGE 0 /* Pad number to show box voltage */
-extern uint8_t ao_lco_min_box, ao_lco_max_box;
+extern uint16_t ao_lco_min_box, ao_lco_max_box;
#define AO_LCO_MASK_SIZE(n) (((n) + 7) >> 3)
#define AO_LCO_MASK_ID(n) ((n) >> 3)
ao_lco_update(void);
uint8_t
-ao_lco_pad_present(uint8_t box, uint8_t pad);
+ao_lco_pad_present(uint16_t box, uint8_t pad);
uint8_t
-ao_lco_pad_first(uint8_t box);
+ao_lco_pad_first(uint16_t box);
void
ao_lco_set_pad(uint8_t new_pad);
uint8_t ao_lco_debug;
uint8_t ao_lco_pad;
-int16_t ao_lco_box;
+uint16_t ao_lco_box;
uint8_t ao_lco_armed; /* arm active */
uint8_t ao_lco_firing; /* fire active */
-uint8_t ao_lco_min_box, ao_lco_max_box;
+uint16_t ao_lco_min_box, ao_lco_max_box;
#if AO_LCO_DRAG
uint8_t ao_lco_drag_race;
}
uint8_t
-ao_lco_pad_present(uint8_t box, uint8_t pad)
+ao_lco_pad_present(uint16_t box, uint8_t pad)
{
/* voltage measurement is always valid */
if (pad == AO_LCO_PAD_VOLTAGE)
}
uint8_t
-ao_lco_pad_first(uint8_t box)
+ao_lco_pad_first(uint16_t box)
{
uint8_t pad;
}
static uint8_t
-ao_lco_get_channels(uint8_t box, struct ao_pad_query *query)
+ao_lco_get_channels(uint16_t box, struct ao_pad_query *query)
{
int8_t r;
ao_lco_channels[box] = query->channels;
ao_lco_valid[box] = AO_LCO_VALID_LAST | AO_LCO_VALID_EVER;
} else
- ao_lco_valid[box] &= ~AO_LCO_VALID_LAST;
+ ao_lco_valid[box] &= (uint8_t) ~AO_LCO_VALID_LAST;
PRINTD("ao_lco_get_channels(%d) rssi %d valid %d ret %d offset %d\n", box, ao_radio_cmac_rssi, ao_lco_valid[box], r, ao_lco_tick_offset[box]);
ao_wakeup(&ao_pad_query);
return ao_lco_valid[box];
}
static void
-ao_lco_box_set_present(uint8_t box)
+ao_lco_box_set_present(uint16_t box)
{
if (box < ao_lco_min_box)
ao_lco_min_box = box;
ao_lco_max_box = box;
if (box >= AO_PAD_MAX_BOXES)
return;
- ao_lco_box_mask[AO_LCO_MASK_ID(box)] |= 1 << AO_LCO_MASK_SHIFT(box);
+ ao_lco_box_mask[AO_LCO_MASK_ID(box)] |= (uint8_t) (1 << AO_LCO_MASK_SHIFT(box));
}
void
void
ao_lco_step_pad(int8_t dir)
{
- int8_t new_pad;
+ int16_t new_pad;
- new_pad = ao_lco_pad;
+ new_pad = (int16_t) ao_lco_pad;
do {
new_pad += dir;
if (new_pad > AO_PAD_MAX_CHANNELS)
new_pad = AO_PAD_MAX_CHANNELS;
if (new_pad == ao_lco_pad)
break;
- } while (!ao_lco_pad_present(ao_lco_box, new_pad));
- ao_lco_set_pad(new_pad);
+ } while (!ao_lco_pad_present(ao_lco_box, (uint8_t) new_pad));
+ ao_lco_set_pad((uint8_t) new_pad);
}
void
if (ao_lco_armed) {
#if AO_LCO_DRAG
if (ao_lco_drag_race) {
- uint8_t box;
+ uint16_t box;
for (box = ao_lco_min_box; box <= ao_lco_max_box; box++)
if (ao_lco_selected[box])
ao_lco_monitor(void)
{
AO_TICK_TYPE delay;
- uint8_t box;
+ uint16_t box;
for (;;) {
PRINTD("monitor armed %d firing %d\n",
ao_lco_toggle_drag(void)
{
if (ao_lco_drag_race && ao_lco_pad != AO_LCO_PAD_VOLTAGE) {
- ao_lco_selected[ao_lco_box] ^= (1 << (ao_lco_pad - 1));
+ ao_lco_selected[ao_lco_box] ^= (uint8_t) (1 << (ao_lco_pad - 1));
PRINTD("Toggle box %d pad %d (pads now %x) to drag race\n",
ao_lco_pad, ao_lco_box, ao_lco_selected[ao_lco_box]);
ao_lco_drag_add_beeps(ao_lco_pad);
static void
lco_args(void)
{
- lco_box = ao_cmd_decimal();
- lco_channels = ao_cmd_hex();
+ lco_box = (uint16_t) ao_cmd_decimal();
+ lco_channels = (uint8_t) ao_cmd_hex();
}
static struct ao_pad_query ao_pad_query;
int8_t r;
lco_args();
- secs = ao_cmd_decimal();
+ secs = (uint8_t) ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
r = lco_query();
lco_arm();
}
- secs = secs * 10 - 5;
+ secs = (uint8_t) (secs * 10 - 5);
if (secs > 100)
secs = 100;
for (i = 0; i < secs; i++) {
int8_t r;
lco_args();
- secs = ao_cmd_decimal();
+ secs = (uint8_t) ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
r = lco_query();
lco_arm();
}
- secs = secs * 10 - 5;
+ secs = (uint8_t) (secs * 10 - 5);
if (secs > 100)
secs = 100;
for (i = 0; i < secs; i++) {
}
#endif
ao_mutex_get(&ao_lco_mutex);
- command.tick = ao_time();
+ command.tick = (uint16_t) ao_time();
command.box = box;
command.cmd = AO_PAD_QUERY;
command.channels = 0;
sent_time = ao_time();
r = ao_radio_cmac_recv(query, sizeof (*query), timeout);
if (r == AO_RADIO_CMAC_OK)
- *tick_offset = sent_time - query->tick;
+ *tick_offset = (uint16_t) sent_time - query->tick;
ao_mutex_put(&ao_lco_mutex);
return r;
}
case AO_EVENT_BUTTON:
switch (event.unit) {
case AO_BUTTON_BOX:
- ao_lco_set_box(event.value);
+ ao_lco_set_box((uint16_t) event.value);
ao_lco_set_armed(0);
break;
case AO_BUTTON_ARM:
- ao_lco_set_armed(event.value);
+ ao_lco_set_armed((uint8_t) event.value);
break;
case AO_BUTTON_FIRE:
if (ao_lco_armed)
- ao_lco_set_firing(event.value);
+ ao_lco_set_firing((uint8_t) event.value);
break;
}
break;
ao_add_task(&ao_lco_input_task, ao_lco_input, "lco input");
ao_add_task(&ao_lco_arm_warn_task, ao_lco_arm_warn, "lco arm warn");
ao_add_task(&ao_lco_igniter_status_task, ao_lco_igniter_status, "lco igniter status");
- ao_led_on(~0);
+ ao_led_on((uint16_t) ~0);
ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200));
- ao_led_off(~0);
+ ao_led_off((uint16_t) ~0);
ao_lco_monitor();
}
static void
ao_lco_set_debug(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status == ao_cmd_success)
- ao_lco_debug = r;
+ ao_lco_debug = r != 0;
}
const struct ao_cmds ao_lco_cmds[] = {
ao_spi_recv(ao_m25_instruction, 1, AO_M25_SPI_BUS);
} while (ao_m25_instruction[0] & M25_STATUS_WIP);
M25_DESELECT(cs);
- ao_m25_wip &= ~cs;
+ ao_m25_wip &= (ao_port_t) ~cs;
}
}
#endif
ao_m25_wait_wip(mask);
- ao_m25_instruction[1] = pos >> 16;
- ao_m25_instruction[2] = pos >> 8;
- ao_m25_instruction[3] = pos;
+ ao_m25_instruction[1] = (uint8_t) (pos >> 16);
+ ao_m25_instruction[2] = (uint8_t) (pos >> 8);
+ ao_m25_instruction[3] = (uint8_t) (pos);
return mask;
}
{
uint8_t d[2];
ao_mma655x_start();
- d[0] = addr | (ao_parity(addr) << 7);
+ d[0] = (uint8_t) (addr | (ao_parity(addr) << 7));
d[1] = 0;
ao_spi_send(&d, 2, AO_MMA655X_SPI_INDEX);
ao_mma655x_restart();
PRINTD(DEBUG_LOW, "write %x %x\n", addr, value);
addr |= (1 << 6); /* write mode */
- d[0] = addr | (ao_parity(addr^value) << 7);
+ d[0] = (uint8_t) (addr | (ao_parity(addr^value) << 7));
d[1] = value;
ao_mma655x_start();
ao_spi_send(d, 2, AO_MMA655X_SPI_INDEX);
ao_mma655x_stop();
-
- addr &= ~(1 << 6);
}
static uint16_t
PRINTD(DEBUG_LOW, "value RECV %02x %02x\n", d[0], d[1]);
v = (uint16_t) d[1] << 2;
- v |= d[0] >> 6;
- v |= (uint16_t) (d[0] & 3) << 10;
+ v = (uint16_t) (v | (d[0] >> 6));
+ v = (uint16_t) (v | ((d[0] & 3) << 10));
return v;
}
a = ao_mma655x_value();
- st_change = a_st - a;
+ st_change = (int16_t) (a_st - a);
PRINTD(DEBUG_HIGH, "self test %d normal %d change %d\n", a_st, a, st_change);
v = -32768;
if (v > 32767)
v = 32767;
- return v;
+ return (int16_t) v;
}
/* Wait for a synchronous sample to finish */
ao_mmc5983_raw(&raw);
/* Bias by 32768 to convert from uint16_t to int16_t */
- s->x = (int32_t) (((uint16_t) raw.x0 << 8) | raw.x1) - 32768;
- s->y = (int32_t) (((uint16_t) raw.y0 << 8) | raw.y1) - 32768;
- s->z = (int32_t) (((uint16_t) raw.z0 << 8) | raw.z1) - 32768;;
+ s->x = (int16_t) ((((uint16_t) raw.x0 << 8) | raw.x1) - 32768);
+ s->y = (int16_t) ((((uint16_t) raw.y0 << 8) | raw.y1) - 32768);
+ s->z = (int16_t) ((((uint16_t) raw.z0 << 8) | raw.z1) - 32768);
}
/* Synchronously sample the sensors */
ao_mmc5983_sync_sample(&reset);
/* The zero point is the average of SET and RESET values */
- ao_mmc5983_offset.x = ((int32_t) set.x + (int32_t) reset.x) / 2;
- ao_mmc5983_offset.y = ((int32_t) set.y + (int32_t) reset.y) / 2;
- ao_mmc5983_offset.z = ((int32_t) set.z + (int32_t) reset.z) / 2;
+ ao_mmc5983_offset.x = (int16_t) (((int32_t) set.x + (int32_t) reset.x) / 2);
+ ao_mmc5983_offset.y = (int16_t) (((int32_t) set.y + (int32_t) reset.y) / 2);
+ ao_mmc5983_offset.z = (int16_t) (((int32_t) set.z + (int32_t) reset.z) / 2);
}
/* Configure the device to automatically sample at 200Hz */
/* byte swap */
while (i--) {
uint16_t t = *d;
- *d++ = (t >> 8) | (t << 8);
+ *d++ = (uint16_t) ((t >> 8) | (t << 8));
}
#endif
}
/* byte swap */
while (i--) {
uint16_t t = *d;
- *d++ = (t >> 8) | (t << 8);
+ *d++ = (uint16_t) ((uint16_t) (t >> 8) | (uint16_t) (t << 8));
}
#endif
}
prom[15] = 0;
for (cnt = 0; cnt < 16; cnt++) {
- n_rem ^= *p++;
+ n_rem ^= (uint16_t) *p++;
for (n_bit = 8; n_bit > 0; n_bit--) {
if (n_rem & 0x8000)
- n_rem = (n_rem << 1) ^ 0x3000;
+ n_rem = (uint16_t) ((n_rem << 1) ^ 0x3000U);
else
n_rem = (n_rem << 1);
}
}
n_rem = (n_rem >> 12) & 0xf;
prom[15] = crc_byte;
- return n_rem;
+ return (uint8_t) n_rem;
}
static bool
#define AO_MS5607_CONVERT_D2_4096 0x58
#define AO_MS5607_ADC_READ 0x00
-#define AO_MS5607_PROM_READ(ad) (0xA0 | ((ad) << 1))
+#define AO_MS5607_PROM_READ(ad) (0xA0U | (uint8_t) ((ad) << 1))
struct ao_ms5607_prom {
uint16_t reserved;
int64_t OFF;
int64_t SENS;
- dT = sample->temp - ((int32_t) ao_ms5607_prom.tref << 8);
+ dT = (int32_t) ((int32_t) sample->temp - ((int32_t) ao_ms5607_prom.tref << 8));
- TEMP = 2000 + (((int64_t) dT * ao_ms5607_prom.tempsens) >> 23);
+ TEMP = (int32_t) (2000 + (((int64_t) dT * ao_ms5607_prom.tempsens) >> 23));
#if HAS_MS5611
OFF = ((int64_t) ao_ms5607_prom.off << 16) + (((int64_t) ao_ms5607_prom.tco * dT) >> 7);
#endif
if (TEMP < 2000) {
- int32_t T2 = ((int64_t) dT * (int64_t) dT) >> 31;
+ int32_t T2 = (int32_t) (((int64_t) dT * (int64_t) dT) >> 31);
int32_t TEMPM = TEMP - 2000;
int64_t OFF2 = (61 * (int64_t) TEMPM * (int64_t) TEMPM) >> 4;
int64_t SENS2 = 2 * (int64_t) TEMPM * (int64_t) TEMPM;
SENS -= SENS2;
}
- value->pres = ((((int64_t) sample->pres * SENS) >> 21) - OFF) >> 15;
+ value->pres = (int32_t) (((((int64_t) sample->pres * SENS) >> 21) - OFF) >> 15);
value->temp = TEMP;
}
while (ao_packet_enable) {
c = ao_packet_getchar();
if (c != AO_READ_AGAIN)
- putchar(c);
+ putchar((char) c);
}
ao_exit();
}
static struct ao_task ao_packet_echo_task;
-static uint16_t ao_packet_master_delay;
-static uint16_t ao_packet_master_time;
+static AO_TICK_TYPE ao_packet_master_delay;
+static AO_TICK_TYPE ao_packet_master_time;
#define AO_PACKET_MASTER_DELAY_SHORT AO_MS_TO_TICKS(100)
#define AO_PACKET_MASTER_DELAY_LONG AO_MS_TO_TICKS(1000)
static void
ao_packet_master_check_busy(void)
{
- int16_t idle;
+ AO_TICK_SIGNED idle;
if (ao_packet_master_delay != AO_PACKET_MASTER_DELAY_SHORT)
return;
- idle = (int16_t) (ao_time() - ao_packet_master_time);
+ idle = (AO_TICK_SIGNED) (ao_time() - ao_packet_master_time);
if (idle > AO_PACKET_MASTER_DELAY_TIMEOUT)
ao_packet_master_delay = AO_PACKET_MASTER_DELAY_LONG;
ao_packet_master(void)
{
ao_config_get();
- ao_tx_packet.addr = ao_serial_number;
+ ao_tx_packet.addr = (uint8_t) ao_serial_number;
ao_tx_packet.len = AO_PACKET_SYN;
ao_packet_master_time = ao_time();
ao_packet_master_delay = AO_PACKET_MASTER_DELAY_SHORT;
static void
ao_packet_slave(void)
{
- ao_tx_packet.addr = ao_serial_number;
+ ao_tx_packet.addr = (uint8_t) ao_serial_number;
ao_tx_packet.len = AO_PACKET_SYN;
ao_packet_restart = 1;
while (ao_packet_enable) {
{
int32_t mul = (int32_t) AO_ADC_REFERENCE_DV * (r_plus + r_minus);
int32_t div = (int32_t) AO_ADC_MAX * r_minus;
- return ((int32_t) adc * mul + mul/2) / div;
+ return (int16_t) (((int32_t) adc * mul + mul/2) / div);
}
static void
sample = ao_data_ring_next(sample);
/* Reply battery voltage */
- query.battery = ao_pad_decivolt(packet->adc.batt, AO_PAD_R_V_BATT_BATT_SENSE, AO_PAD_R_BATT_SENSE_GND);
+ query.battery = (uint8_t) ao_pad_decivolt(packet->adc.batt, AO_PAD_R_V_BATT_BATT_SENSE, AO_PAD_R_BATT_SENSE_GND);
/* Current pyro voltage */
pyro = ao_pad_decivolt(packet->adc.pyro,
prev = cur;
}
- if (ao_pad_armed && (AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > AO_PAD_ARM_TIME)
+ if (ao_pad_armed && (AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > (AO_TICK_SIGNED) AO_PAD_ARM_TIME)
ao_pad_armed = 0;
if (ao_pad_armed) {
#endif
#ifdef AO_PAD_SELECTOR_PORT
-static int ao_pad_read_box(void) {
+static uint8_t ao_pad_read_box(void) {
AO_PORT_TYPE value = ao_gpio_get_all(AO_PAD_SELECTOR_PORT);
unsigned pin;
- int select = 1;
+ uint8_t select = 1;
for (pin = 0; pin < sizeof (AO_PORT_TYPE) * 8; pin++) {
if (AO_PAD_SELECTOR_PINS & (1 << pin)) {
if (command.channels & ~(AO_PAD_ALL_CHANNELS))
break;
- tick_difference = command.tick - (uint16_t) ao_time();
+ tick_difference = (int16_t) (command.tick - (uint16_t) ao_time());
PRINTD ("arm tick %d local tick %d\n", command.tick, (uint16_t) ao_time());
if (tick_difference < 0)
tick_difference = -tick_difference;
break;
}
- query.tick = ao_time();
+ query.tick = (uint16_t) ao_time();
query.box = ao_pad_box;
query.channels = AO_PAD_ALL_CHANNELS;
query.armed = ao_pad_armed;
PRINTD ("not armed\n");
break;
}
- if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > AO_SEC_TO_TICKS(20)) {
+ if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > (AO_TICK_SIGNED) AO_SEC_TO_TICKS(20)) {
PRINTD ("late pad arm_time %ld time %ld\n",
(long) ao_pad_arm_time, ao_time());
break;
#if HAS_LOG
if (!ao_log_running) ao_log_start();
#endif
- if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > AO_SEC_TO_TICKS(20)) {
+ if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > (AO_TICK_SIGNED) AO_SEC_TO_TICKS(20)) {
PRINTD ("late pad arm_time %ld time %ld\n",
(long) ao_pad_arm_time, (long) ao_time());
break;
ignite = 1 << ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- repeat = ao_cmd_decimal();
+ repeat = (uint8_t) ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success) {
repeat = 1;
ao_cmd_status = ao_cmd_success;
static void
ao_pad_set_debug(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status == ao_cmd_success)
ao_pad_debug = r != 0;
}
ao_pad_alarm_debug(void)
{
uint8_t which, value;
- which = ao_cmd_decimal();
+ which = ao_cmd_decimal() != 0;
if (ao_cmd_status != ao_cmd_success)
return;
- value = ao_cmd_decimal();
+ value = ao_cmd_decimal() != 0;
if (ao_cmd_status != ao_cmd_success)
return;
printf ("Set %s to %d\n", which ? "siren" : "strobe", value);
ao_pad_init(void)
{
#ifdef AO_PAD_SELECTOR_PORT
- unsigned pin;
+ int pin;
- for (pin = 0; pin < sizeof (AO_PORT_TYPE) * 8; pin++) {
+ for (pin = 0; pin < (int) sizeof (AO_PORT_TYPE) * 8; pin++) {
if (AO_PAD_SELECTOR_PINS & (1 << pin))
ao_enable_input(AO_PAD_SELECTOR_PORT, pin, AO_EXTI_MODE_PULL_UP);
}
}
void
-ao_led_for(uint8_t colors, uint16_t ticks)
+ao_led_for(uint8_t colors, AO_TICK_TYPE ticks)
{
ao_led_on(colors);
ao_delay(ticks);
struct ao_config ao_config;
-extern volatile uint16_t ao_tick_count;
-uint16_t ao_boost_tick;
+extern volatile AO_TICK_TYPE ao_tick_count;
+AO_TICK_TYPE ao_boost_tick;
void ao_spi_slave(void)
{
a = ao_debounce(a, &debounce_state[0]);
b = ao_debounce(b, &debounce_state[1]);
- return a | (b << 1);
+ return (uint16_t) (a | (b << 1));
}
#define _ao_quadrature_get(q) ao_quadrature_read(port(q), bita(q), bitb(q), ao_debounce_state[q])
ao_quadrature_isr(void)
{
#if AO_QUADRATURE_COUNT > 0
- _ao_quadrature_set(0, _ao_quadrature_get(0));
+ _ao_quadrature_set(0, (uint8_t) _ao_quadrature_get(0));
#endif
#if AO_QUADRATURE_COUNT > 1
- _ao_quadrature_set(1, _ao_quadrature_get(1));
+ _ao_quadrature_set(1, (uint8_t) _ao_quadrature_get(1));
#endif
}
static void
ao_quadrature_test(void)
{
- uint8_t q;
+ uint32_t q;
int32_t c;
uint8_t s;
#ifndef AO_QUADRATURE_SINGLE_CODE
#define init(q) do { \
ao_enable_input(port(q), bita(q), 0); \
ao_enable_input(port(q), bitb(q), 0); \
- _ao_quadrature_start_one(q, _ao_quadrature_get(q)); \
+ _ao_quadrature_start_one(q, (uint8_t) _ao_quadrature_get(q)); \
} while (0)
void
#define NUM_STATUS_STRING (sizeof status_strings/sizeof status_strings[0])
static char ao_rn_buffer[64];
-static int ao_rn_buf_cnt, ao_rn_buf_ptr;
+static size_t ao_rn_buf_cnt, ao_rn_buf_ptr;
static int ao_rn_draining;
static AO_TICK_TYPE ao_rn_buf_time;
/* If we filled the buffer, just give up */
ao_rn_draining = 1;
} else {
- ao_rn_buffer[ao_rn_buf_cnt++] = c;
+ ao_rn_buffer[ao_rn_buf_cnt++] = (char) c;
for (i = 0; i < NUM_STATUS_STRING; i++) {
- int cmp = strlen(status_strings[i]);
+ size_t cmp = strlen(status_strings[i]);
if (cmp >= ao_rn_buf_cnt)
cmp = ao_rn_buf_cnt-1;
if (memcmp(ao_rn_buffer+1, status_strings[i], cmp) == 0)
ao_rn_draining = 1;
}
} else if (c == STATUS_CHAR) {
- ao_rn_buffer[0] = c;
+ ao_rn_buffer[0] = (char) c;
ao_rn_buf_cnt = 1;
ao_rn_buf_ptr = 0;
ao_rn_buf_time = ao_time();
ao_arch_release_interrupts();
return AO_READ_AGAIN;
}
- _ao_serial_rn_sleep_for(delay);
+ _ao_serial_rn_sleep_for((AO_TICK_TYPE) delay);
}
ao_arch_release_interrupts();
return c;
}
static int
-ao_rn_wait_for(int timeout, char *match)
+ao_rn_wait_for(AO_TICK_TYPE timeout, char *match)
{
char reply[AO_RN_MAX_REPLY_LEN + 1];
- int match_len = strlen(match);
+ size_t match_len = strlen(match);
AO_TICK_TYPE giveup_time = ao_time() + timeout;
int c;
*--s = '\0';
n = ao_serial_number;
do {
- *--s = '0' + n % 10;
+ *--s = (uint8_t) ('0' + n % 10);
} while (n /= 10);
ao_rn_send_cmd(AO_RN_SET_NAME_CMD "TeleBT-", s);
return ao_rn_wait_status();
ao_rn_factory(void)
{
int i;
- int v = 0;
+ uint8_t v = 0;
/*
* Factory reset. Flip pin P3_1 5 times within the first five
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
+ printf("tick: %5lu A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
(p)->tick, \
(p)->adc.sense[0], (p)->adc.sense[1], (p)->adc.sense[2], \
(p)->adc.sense[3], (p)->adc.sense[4], (p)->adc.sense[5], \
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
+ printf("tick: %5lu A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
(p)->tick, \
(p)->adc.sense[0], (p)->adc.sense[1], (p)->adc.sense[2], \
(p)->adc.sense[3], (p)->adc.sense[4], (p)->adc.sense[5], \
#define HAS_BEEP 1
#define HAS_BATTERY_REPORT 1
-#define AO_STACK_SIZE 360
+#define AO_STACK_SIZE 352
#define SLEEP_HASH_SIZE 3
#define AO_NUM_TASKS 6
#define AO_SENSE_MAIN(p) ((p)->adc.sense_m)
#define AO_ADC_DUMP(p) \
- printf("tick: %5u apogee: %5d main: %5d batt: %5d\n", \
+ printf("tick: %5lu apogee: %5d main: %5d batt: %5d\n", \
(p)->tick, (p)->adc.sense_a, (p)->adc.sense_m, (p)->adc.v_batt)
/*
#define AO_SENSE_MAIN(p) ((p)->adc.sense_m)
#define AO_ADC_DUMP(p) \
- printf("tick: %5u apogee: %5d main: %5d batt: %5d\n", \
+ printf("tick: %5lu apogee: %5d main: %5d batt: %5d\n", \
(p)->tick, (p)->adc.sense_a, (p)->adc.sense_m, (p)->adc.v_batt)
/*
--- /dev/null
+ao_product.h
+*.elf
--- /dev/null
+#
+# AltOS build
+#
+#
+
+include ../lpc/Makefile.defs
+
+INC = \
+ ao.h \
+ ao_arch.h \
+ ao_arch_funcs.h \
+ ao_pins.h \
+ ao_product.h \
+ lpc.h
+
+#
+# Common AltOS sources
+#
+ALTOS_SRC = \
+ ao_interrupt.c \
+ ao_boot_chain.c \
+ ao_romconfig.c \
+ ao_product.c \
+ ao_mutex.c \
+ ao_panic.c \
+ ao_stdio.c \
+ ao_storage.c \
+ ao_report.c \
+ ao_ignite.c \
+ ao_flight.c \
+ ao_kalman.c \
+ ao_sample.c \
+ ao_data.c \
+ ao_convert_pa.c \
+ ao_convert_volt.c \
+ ao_task.c \
+ ao_log.c \
+ ao_log_mini.c \
+ ao_cmd.c \
+ ao_config.c \
+ ao_timer_lpc.c \
+ ao_exti_lpc.c \
+ ao_usb_lpc.c \
+ ao_spi_lpc.c \
+ ao_adc_lpc.c \
+ ao_beep_lpc.c \
+ ao_m25.c \
+ ao_ms5607.c
+
+PRODUCT=EasyMini-v3.0
+PRODUCT_DEF=-DEASYMINI_V_3_0
+IDPRODUCT=0x0026
+
+CFLAGS = $(PRODUCT_DEF) $(LPC_CFLAGS)
+
+PROGNAME=easymini-v3.0
+PROG=$(PROGNAME)-$(VERSION).elf
+HEX=$(PROGNAME)-$(VERSION).ihx
+
+SRC=$(ALTOS_SRC) ao_easymini.c
+OBJ=$(SRC:.c=.o)
+
+all: $(PROG) $(HEX)
+
+$(PROG): Makefile $(OBJ) altos.ld
+ $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS)
+
+$(OBJ): $(INC)
+
+load: $(PROG)
+ lpc-load $(PROG)
+
+distclean: clean
+
+clean:
+ rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx $(PROGNAME)-*.map
+ rm -f ao_product.h
+
+install:
+
+uninstall:
--- /dev/null
+/*
+ * Copyright © 2011 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include <ao.h>
+#include <ao_exti.h>
+
+int
+main(void)
+{
+ ao_clock_init();
+ ao_task_init();
+ ao_timer_init();
+ ao_exti_init();
+
+ ao_beep_init();
+
+ ao_adc_init();
+ ao_spi_init();
+ ao_storage_init();
+
+ ao_usb_init();
+
+ ao_cmd_init();
+ ao_flight_init();
+ ao_ms5607_init();
+ ao_log_init();
+ ao_report_init();
+ ao_igniter_init();
+ ao_config_init();
+
+ ao_start_scheduler();
+}
--- /dev/null
+/*
+ * Copyright © 2013 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#define HAS_BEEP 1
+#define HAS_BATTERY_REPORT 1
+
+#define AO_STACK_SIZE 352
+#define SLEEP_HASH_SIZE 3
+#define AO_NUM_TASKS 6
+
+#define IS_FLASH_LOADER 0
+
+/* Crystal on the board */
+#define AO_LPC_CLKIN 12000000
+
+/* Main clock frequency. 48MHz for USB so we don't use the USB PLL */
+#define AO_LPC_CLKOUT 48000000
+
+/* System clock frequency */
+#define AO_LPC_SYSCLK 24000000
+
+#define HAS_USB 1
+
+#define HAS_USB_CONNECT 0
+#define HAS_USB_VBUS 0
+#define HAS_USB_PULLUP 1
+#define AO_USB_PULLUP_PORT 1
+#define AO_USB_PULLUP_PIN 23
+
+#define PACKET_HAS_SLAVE 0
+
+#define AO_LOG_FORMAT AO_LOG_FORMAT_EASYMINI1
+
+/* Beeper */
+#define AO_LPC_BEEP_TIMER 0
+#define AO_LPC_BEEP_CHANNEL 3
+#define AO_LPC_BEEP_PORT 1
+#define AO_LPC_BEEP_PIN 27
+
+/* USART */
+
+#define HAS_SERIAL 0
+#define USE_SERIAL_0_STDIN 1
+#define SERIAL_0_18_19 1
+#define SERIAL_0_14_15 0
+#define SERIAL_0_17_18 0
+#define SERIAL_0_26_27 0
+
+/* SPI */
+
+#define HAS_SPI_0 1
+#define SPI_SCK0_P0_6 1
+#define HAS_SPI_1 1
+#define SPI_SCK1_P1_20 1
+#define SPI_MISO1_P0_22 1
+#define SPI_MOSI1_P1_22 1
+
+/* M25 */
+
+#define M25_MAX_CHIPS 1
+#define AO_M25_SPI_CS_PORT 0
+#define AO_M25_SPI_CS_MASK (1 << 23)
+#define AO_M25_SPI_BUS 1
+
+/* MS5607 */
+
+#define HAS_MS5607 1
+#define HAS_MS5611 0
+#define AO_MS5607_PRIVATE_PINS 0
+#define AO_MS5607_CS_PORT 1
+#define AO_MS5607_CS_PIN 5
+#define AO_MS5607_CS_MASK (1 << AO_MS5607_CS_PIN)
+#define AO_MS5607_MISO_PORT 0
+#define AO_MS5607_MISO_PIN 8
+#define AO_MS5607_MISO_MASK (1 << AO_MS5607_MISO_PIN)
+#define AO_MS5607_SPI_INDEX 0
+
+#define HAS_ACCEL 0
+#define HAS_GPS 0
+#define HAS_RADIO 0
+#define HAS_FLIGHT 1
+#define HAS_EEPROM 1
+#define HAS_TELEMETRY 0
+#define HAS_APRS 0
+#define HAS_LOG 1
+#define USE_INTERNAL_FLASH 0
+#define HAS_IGNITE 1
+#define HAS_IGNITE_REPORT 1
+#define SLEEP_HASH_SIZE 3
+
+#define AO_DATA_RING 16
+
+/*
+ * ADC
+ */
+
+#define HAS_ADC 1
+
+#define AO_NUM_ADC 3
+
+#define AO_ADC_0 1
+#define AO_ADC_2 1
+#define AO_ADC_5 1
+
+struct ao_adc {
+ int16_t sense_a;
+ int16_t sense_m;
+ int16_t v_batt;
+};
+
+/*
+ * Igniter
+ */
+
+#define AO_IGNITER_CLOSED 400
+#define AO_IGNITER_OPEN 60
+
+#define AO_IGNITER_DROGUE_PORT 1
+#define AO_IGNITER_DROGUE_PIN 25
+
+#define AO_IGNITER_MAIN_PORT 0
+#define AO_IGNITER_MAIN_PIN 2
+
+#define AO_SENSE_DROGUE(p) ((p)->adc.sense_a)
+#define AO_SENSE_MAIN(p) ((p)->adc.sense_m)
+
+#define AO_ADC_DUMP(p) \
+ printf("tick: %5lu apogee: %5d main: %5d batt: %5d\n", \
+ (p)->tick, (p)->adc.sense_a, (p)->adc.sense_m, (p)->adc.v_batt)
+
+/*
+ * Voltage divider on ADC battery sampler
+ */
+#define AO_BATTERY_DIV_PLUS 100 /* 100k */
+#define AO_BATTERY_DIV_MINUS 27 /* 27k */
+
+/*
+ * Voltage divider on ADC igniter samplers
+ */
+#define AO_IGNITE_DIV_PLUS 100 /* 100k */
+#define AO_IGNITE_DIV_MINUS 27 /* 27k */
+
+/*
+ * ADC reference in decivolts
+ */
+#define AO_ADC_REFERENCE_DV 33
--- /dev/null
+#
+# AltOS flash loader build
+#
+#
+
+TOPDIR=../..
+HARDWARE=easymini-v3.0
+include $(TOPDIR)/lpc/Makefile-flash.defs
--- /dev/null
+/*
+ * Copyright © 2013 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#ifndef _AO_PINS_H_
+#define _AO_PINS_H_
+
+#include <ao_flash_lpc_pins.h>
+
+#define AO_BOOT_PIN 1
+#define AO_BOOT_APPLICATION_GPIO 1
+#define AO_BOOT_APPLICATION_PIN 13
+#define AO_BOOT_APPLICATION_VALUE 1
+#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP
+
+#define HAS_USB_PULLUP 1
+#define AO_USB_PULLUP_PORT 1
+#define AO_USB_PULLUP_PIN 23
+
+#endif /* _AO_PINS_H_ */
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u motor_pressure: %5d batt: %5d\n", \
+ printf("tick: %5lu motor_pressure: %5d batt: %5d\n", \
(p)->tick, \
(p)->adc.motor_pressure, \
(p)->adc.v_batt);
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u A: %5d B: %5d batt: %5d\n", \
+ printf("tick: %5lu A: %5d B: %5d batt: %5d\n", \
(p)->tick, \
(p)->adc.sense[0], (p)->adc.sense[1], \
(p)->adc.v_batt);
#define AO_HERTZ 100
#endif
#define AO_MS_TO_TICKS(ms) ((ms) / (1000 / AO_HERTZ))
-#define AO_SEC_TO_TICKS(s) ((s) * AO_HERTZ)
+#define AO_SEC_TO_TICKS(s) ((AO_TICK_TYPE) (s) * AO_HERTZ)
/* Returns the current time in ticks */
AO_TICK_TYPE
#define AO_GPS_NEW_TRACKING 2
extern uint8_t ao_gps_new;
-extern uint16_t ao_gps_tick;
+extern AO_TICK_TYPE ao_gps_tick;
extern uint8_t ao_gps_mutex;
extern struct ao_telemetry_location ao_gps_data;
extern struct ao_telemetry_satellite ao_gps_tracking_data;
* for reporting RSSI. So, now we use these values everywhere
*/
#define AO_RSSI_FROM_RADIO(radio) ((int16_t) ((int8_t) (radio) >> 1) - 74)
-#define AO_RADIO_FROM_RSSI(rssi) (((int8_t) (rssi) + 74) << 1)
+#define AO_RADIO_FROM_RSSI(rssi) ((uint8_t) (((rssi) + 74) << 1))
/*
* ao_radio_recv tacks on rssi and status bytes
#if HAS_RADIO_RECV
uint8_t
-ao_radio_recv(void *d, uint8_t size, uint8_t timeout);
+ao_radio_recv(void *d, uint8_t size, AO_TICK_TYPE timeout);
void
ao_radio_recv_abort(void);
};
extern struct ao_stdio ao_stdios[];
-extern int8_t ao_cur_stdio;
-extern int8_t ao_num_stdios;
+extern uint8_t ao_cur_stdio;
+extern uint8_t ao_num_stdios;
void
flush(void);
uint8_t
ao_echo(void);
-int8_t
+uint8_t
ao_add_stdio(int (*pollchar)(void),
void (*putchar)(char) ,
void (*flush)(void));
char fifo[AO_FIFO_SIZE];
};
-#define ao_fifo_insert(f,c) do { \
- (f).fifo[(f).insert] = (c); \
- (f).insert = ((f).insert + 1) & (AO_FIFO_SIZE-1); \
-} while(0)
+#define ao_fifo_insert(f,c) do { \
+ (f).fifo[(f).insert] = (char) (c); \
+ (f).insert = ((f).insert + 1) & (AO_FIFO_SIZE-1); \
+ } while(0)
-#define ao_fifo_remove(f,c) do {\
- c = (f).fifo[(f).remove]; \
- (f).remove = ((f).remove + 1) & (AO_FIFO_SIZE-1); \
-} while(0)
+#define ao_fifo_remove(f,c) do { \
+ c = (f).fifo[(f).remove]; \
+ (f).remove = ((f).remove + 1) & (AO_FIFO_SIZE-1); \
+ } while(0)
#define ao_fifo_full(f) ((((f).insert + 1) & (AO_FIFO_SIZE-1)) == (f).remove)
#define ao_fifo_mostly(f) ((((f).insert - (f).remove) & (AO_FIFO_SIZE-1)) >= (AO_FIFO_SIZE * 3 / 4))
* ao_freq.c
*/
-int32_t ao_freq_to_set(int32_t freq, int32_t cal);
+uint32_t ao_freq_to_set(uint32_t freq, uint32_t cal);
/*
* ao_ms5607.c
#define AO_BEEP_MID_PANIC AO_BEEP_MID_DEFAULT
#ifndef AO_BEEP_MAKE_LOW
-#define AO_BEEP_MAKE_LOW(m) ((m) * 150 / 94) /* 2500Hz */
+#define AO_BEEP_MAKE_LOW(m) ((uint8_t) ((m) * 150 / 94)) /* 2500Hz */
#endif
#ifndef AO_BEEP_MAKE_HIGH
-#define AO_BEEP_MAKE_HIGH(m) ((m) * 75 / 94) /* 5000Hz */
+#define AO_BEEP_MAKE_HIGH(m) ((uint8_t) ((m) * 75 / 94)) /* 5000Hz */
#endif
#define AO_BEEP_LOW AO_BEEP_MAKE_LOW(AO_BEEP_MID)
void
ao_cmd_put16(uint16_t v)
{
- ao_cmd_put8(v >> 8);
- ao_cmd_put8(v);
+ ao_cmd_put8((uint8_t) (v >> 8));
+ ao_cmd_put8((uint8_t) v);
}
void
ao_cmd_hexchar(char c)
{
if ('0' <= c && c <= '9')
- return (c - '0');
+ return (int8_t) (c - '0');
if ('a' <= c && c <= 'f')
- return (c - 'a' + 10);
+ return (int8_t) (c - 'a' + 10);
if ('A' <= c && c <= 'F')
- return (c - 'A' + 10);
+ return (int8_t) (c - 'A' + 10);
return -1;
}
ao_cmd_status = ao_cmd_lex_error;
break;
}
- result = (result << 4) | n;
+ result = (uint32_t) ((result << 4) | (uint32_t) n);
ao_cmd_lex();
}
return result;
uint8_t
ao_cmd_hexbyte(void)
{
- return get_hex(2);
+ return (uint8_t) get_hex(2);
}
uint32_t
#endif
#if HAS_VERSION
+#define _stringify(x) #x
+#define stringify(x) _stringify(x)
static void
version(void)
{
, (unsigned) ((uint32_t) AO_BOOT_APPLICATION_BOUND - (uint32_t) AO_BOOT_APPLICATION_BASE)
#endif
);
- printf("software-version %s\n", ao_version);
+ printf("software-version %." stringify(AO_MAX_VERSION) "s\n", ao_version);
}
#endif
uint8_t cmd;
const struct ao_cmds * cs;
const char *h;
- uint8_t e;
+ size_t e;
for (cmds = 0; cmds < ao_ncmds; cmds++) {
cs = ao_cmds[cmds];
int16_t accel;
int16_t speed;
int16_t height;
- int16_t motor_number;
+ uint16_t motor_number;
};
struct ao_companion_setup {
#define AO_CONFIG_DEFAULT_IGNITE_MODE AO_IGNITE_MODE_DUAL
#define AO_CONFIG_DEFAULT_PAD_ORIENTATION AO_PAD_ORIENTATION_ANTENNA_UP
#define AO_CONFIG_DEFAULT_PYRO_TIME AO_MS_TO_TICKS(50)
+#define AO_CONFIG_DEFAULT_RADIO_10MW 0
#if HAS_CONFIG_SAVE
#ifndef USE_INTERNAL_FLASH
#error Please define USE_INTERNAL_FLASH
#define AO_CONFIG_DEFAULT_RADIO_POWER 0x60
#endif
#define AO_CONFIG_DEFAULT_RADIO_AMP 0
-#define AO_CONFIG_DEFAULT_APRS_SSID (ao_serial_number % 10)
+#define AO_CONFIG_DEFAULT_APRS_SSID ((uint8_t) (ao_serial_number % 10))
#define AO_CONFIG_DEFAULT_RADIO_RATE AO_RADIO_RATE_38400
#if HAS_CONFIG_SAVE
if (minor < 9)
memset(&ao_config.aes_key, '\0', AO_AES_LEN);
if (minor < 10)
- ao_config.frequency = 434550 + ao_config._legacy_radio_channel * 100;
+ ao_config.frequency = 434550U + ao_config._legacy_radio_channel * 100U;
if (minor < 11)
ao_config.apogee_lockout = 0;
#if AO_PYRO_NUM
#if HAS_RADIO_POWER
if (minor < 14)
ao_config.radio_power = AO_CONFIG_DEFAULT_RADIO_POWER;
- #endif
+#endif
#if HAS_RADIO_AMP
if (minor < 14)
ao_config.radio_amp = AO_CONFIG_DEFAULT_RADIO_AMP;
#if HAS_APRS
if (minor < 24)
ao_config.aprs_offset = 0;
+#endif
+#if HAS_RADIO_10MW
+ if (minor < 25)
+ ao_config.radio_10mw = AO_CONFIG_DEFAULT_RADIO_10MW;
#endif
ao_config.minor = AO_CONFIG_MINOR;
ao_config_dirty = 1;
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.main_deploy = r;
+ ao_config.main_deploy = (uint16_t) r;
_ao_config_edit_finish();
}
}
}
#if HAS_IMU
- accel_cal_along = accel_along_total >> ACCEL_CALIBRATE_SHIFT;
- accel_cal_across = accel_across_total >> ACCEL_CALIBRATE_SHIFT;
- accel_cal_through = accel_through_total >> ACCEL_CALIBRATE_SHIFT;
+ accel_cal_along = (int16_t) (accel_along_total >> ACCEL_CALIBRATE_SHIFT);
+ accel_cal_across = (int16_t) (accel_across_total >> ACCEL_CALIBRATE_SHIFT);
+ accel_cal_through = (int16_t) (accel_through_total >> ACCEL_CALIBRATE_SHIFT);
#endif
- return accel_total >> ACCEL_CALIBRATE_SHIFT;
+ return (int16_t) (accel_total >> ACCEL_CALIBRATE_SHIFT);
}
static void
int16_t accel_through_up = 0, accel_through_down = 0;
#endif
- up = ao_cmd_decimal();
+ up = (int16_t) ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- down = ao_cmd_decimal();
+ down = (int16_t) ao_cmd_decimal();
auto_cal = (up == 0 && ao_cmd_status != ao_cmd_success);
if (auto_cal) {
up = ao_config_accel_calibrate_auto("up");
ao_config.accel_minus_g = down;
#if HAS_IMU
if (auto_cal) {
- ao_config.accel_zero_along = (accel_along_up + accel_along_down) / 2;
- ao_config.accel_zero_across = (accel_across_up + accel_across_down) / 2;
- ao_config.accel_zero_through = (accel_through_up + accel_through_down) / 2;
+ ao_config.accel_zero_along = (int16_t) ((accel_along_up + accel_along_down) / 2);
+ ao_config.accel_zero_across = (int16_t) ((accel_across_up + accel_across_down) / 2);
+ ao_config.accel_zero_through = (int16_t) ((accel_through_up + accel_through_down) / 2);
} else {
int16_t v;
- v = ao_cmd_decimal();
+ v = (int16_t) ao_cmd_decimal();
if (ao_cmd_status == ao_cmd_success) {
ao_config.accel_zero_along = v;
- v = ao_cmd_decimal();
+ v = (int16_t) ao_cmd_decimal();
if (ao_cmd_status == ao_cmd_success) {
ao_config.accel_zero_across = v;
- v = ao_cmd_decimal();
+ v = (int16_t) ao_cmd_decimal();
if (ao_cmd_status == ao_cmd_success)
ao_config.accel_zero_through = v;
}
uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
+ if (r > 255) {
+ ao_cmd_status = ao_cmd_lex_error;
+ return;
+ }
_ao_config_edit_start();
- ao_config.apogee_delay = r;
+ ao_config.apogee_delay = (uint8_t) r;
_ao_config_edit_finish();
}
static void
ao_config_apogee_lockout_set(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
+ if (r > 65535) {
+ ao_cmd_status = ao_cmd_lex_error;
+ return;
+ }
_ao_config_edit_start();
- ao_config.apogee_lockout = r;
+ ao_config.apogee_lockout = (uint16_t) r;
_ao_config_edit_finish();
}
#endif
static void
ao_config_radio_rate_set(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
if (AO_RADIO_RATE_MAX < r) {
return;
}
_ao_config_edit_start();
- ao_config.radio_rate = r;
+ ao_config.radio_rate = (uint8_t) r;
_ao_config_edit_finish();
#if HAS_TELEMETRY
ao_telemetry_reset_interval();
static void
ao_config_ignite_mode_set(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.ignite_mode = r;
+ ao_config.ignite_mode = (uint8_t) r;
_ao_config_edit_finish();
}
#endif
static void
ao_config_pad_orientation_set(void)
{
- uint16_t r = ao_cmd_decimal() & 1;
+ uint8_t r = ao_cmd_decimal() & 1;
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
static void
ao_config_radio_enable_set(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.radio_enable = r;
+ ao_config.radio_enable = r != 0;
_ao_config_edit_finish();
#if HAS_TELEMETRY && HAS_RADIO_RATE
ao_telemetry_reset_interval();
static void
ao_config_aprs_set(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.aprs_interval = r;
+ ao_config.aprs_interval = (uint16_t) r;
_ao_config_edit_finish();
ao_telemetry_reset_interval();
}
static void
ao_config_aprs_offset_set(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.aprs_offset = r;
+ ao_config.aprs_offset = (uint8_t) r;
_ao_config_edit_finish();
ao_telemetry_reset_interval();
}
#endif
+#if HAS_RADIO_10MW
+
+static void
+ao_config_radio_10mw_show(void)
+{
+ printf ("Radio 10mw limit: %d\n", ao_config.radio_10mw);
+}
+
+static void
+ao_config_radio_10mw_set(void)
+{
+ uint32_t r = ao_cmd_decimal();
+ if (ao_cmd_status != ao_cmd_success)
+ return;
+ _ao_config_edit_start();
+ ao_config.radio_10mw = !!r;
+ _ao_config_edit_finish();
+}
+
+#endif
+
#if HAS_BEEP
static void
ao_config_beep_show(void)
static void
ao_config_beep_set(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.mid_beep = r;
+ ao_config.mid_beep = (uint8_t) r;
_ao_config_edit_finish();
}
#endif
static void
ao_config_tracker_set(void)
{
- uint16_t m, i;
- m = ao_cmd_decimal();
+ uint16_t m;
+ uint8_t i;
+ m = (uint16_t) ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
- i = ao_cmd_decimal();
+ i = (uint8_t) ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
static void
ao_config_pyro_time_set(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.pyro_time = r;
+ ao_config.pyro_time = (uint16_t) r;
_ao_config_edit_finish();
}
#endif
static void
ao_config_aprs_ssid_set(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
if (15 < r) {
return;
}
_ao_config_edit_start();
- ao_config.aprs_ssid = r;
+ ao_config.aprs_ssid = (uint8_t) r;
_ao_config_edit_finish();
}
static void
ao_config_aprs_format_set(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
static void
ao_config_pad_box_set(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.pad_box = r;
+ ao_config.pad_box = (uint8_t) r;
_ao_config_edit_finish();
}
static void
ao_config_pad_idle_set(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
_ao_config_edit_start();
- ao_config.pad_idle = r;
+ ao_config.pad_idle = (uint8_t) r;
_ao_config_edit_finish();
}
#endif
ao_config_pad_box_set, ao_config_pad_box_show },
{ "i <seconds>\0Set idle timeout (0 disable)",
ao_config_pad_idle_set, ao_config_pad_idle_show },
+#endif
+#if HAS_RADIO_10MW
+ { "p <0 no limit, 1 limit>\0Limit radio power to 10mW",
+ ao_config_radio_10mw_set, ao_config_radio_10mw_show },
#endif
{ "s\0Show",
ao_config_show, 0 },
#define AO_CONFIG_MAJOR 1
#define AO_CONFIG_MINOR 25
+/* All cc1200 devices support limiting TX power to 10mW */
+#if !defined(HAS_RADIO_10MW) && defined(AO_CC1200_SPI)
+#define HAS_RADIO_10MW 1
+#endif
+
#define AO_AES_LEN 16
extern uint8_t ao_config_aes_seq;
#if HAS_APRS
uint8_t aprs_offset; /* minor version 24 */
#endif
+#if HAS_RADIO_10MW
+ uint8_t radio_10mw; /* minor version 25 */
+#endif
};
struct ao_config_1_24 {
alt_t
ao_pa_to_altitude(pres_t pa)
{
- int16_t o;
+ uint16_t o;
int16_t part;
alt_t low, high;
pa = 0;
if (pa > 120000L)
pa = 120000L;
- o = pa >> ALT_SHIFT;
+ o = (uint16_t) (pa >> ALT_SHIFT);
part = pa & ALT_MASK;
low = (alt_t) FETCH_ALT(o) * (ALT_SCALE - part);
- high = (alt_t) FETCH_ALT(o+1) * part + (ALT_SCALE >> 1);
- return (low + high) >> ALT_SHIFT;
+ high = (alt_t) FETCH_ALT(o+1) * part;
+ return (low + high + (ALT_SCALE >> 1)) >> ALT_SHIFT;
}
#ifdef AO_CONVERT_TEST
int16_t
ao_battery_decivolt(int16_t adc)
{
- return scale(adc, AO_BATTERY_DIV_PLUS, AO_BATTERY_DIV_MINUS);
+ return (int16_t) scale(adc, AO_BATTERY_DIV_PLUS, AO_BATTERY_DIV_MINUS);
}
#endif
int16_t
ao_ignite_decivolt(int16_t adc)
{
- return scale(adc, AO_IGNITE_DIV_PLUS, AO_IGNITE_DIV_MINUS);
+ return (int16_t) scale(adc, AO_IGNITE_DIV_PLUS, AO_IGNITE_DIV_MINUS);
}
#endif
#define AO_DATA_ALL (AO_DATA_ADC|AO_DATA_MS5607|AO_DATA_MPU6000|AO_DATA_HMC5883|AO_DATA_MMA655X|AO_DATA_MPU9250|AO_DATA_ADXL375|AO_DATA_BMX160|AO_DATA_MMC5983)
struct ao_data {
- uint16_t tick;
+ AO_TICK_TYPE tick;
#if HAS_ADC
struct ao_adc adc;
#endif
#define ao_data_pres_cook(packet) ao_ms5607_convert(&packet->ms5607_raw, &packet->ms5607_cooked)
#define ao_data_pres(packet) ((packet)->ms5607_cooked.pres)
-#define ao_data_temp(packet) ((packet)->ms5607_cooked.temp)
+#define ao_data_temp(packet) ((int16_t) (packet)->ms5607_cooked.temp)
#define pres_to_altitude(p) ao_pa_to_altitude(p)
#endif
#if AO_MMA655X_INVERT
-#define ao_data_accel_raw(packet) (AO_ACCEL_INVERT - (packet)->mma655x)
+#define ao_data_accel_raw(packet) ((accel_t) (AO_ACCEL_INVERT - (packet)->mma655x))
#else
-#define ao_data_accel_raw(packet) ((packet)->mma655x)
+#define ao_data_accel_raw(packet) ((accel_t) (packet)->mma655x)
#endif
#define ao_data_accel_invert(accel) (AO_ACCEL_INVERT - (accel))
/* check if it's shorter to go the other way around */
if ((lon_a >> 1) < (lon_b >> 1) - (1800000000 >> 1))
- lon_a += 3600000000;
+ lon_a = (int32_t) ((uint32_t) lon_a + 3600000000UL);
lon_dist = ao_dist(lon_a, lon_b);
if (c) {
if (lon_dist & 0x7f800000)
static uint8_t ao_fake_has_cur;
static volatile uint8_t ao_fake_has_next;
static uint8_t ao_fake_has_offset;
-static uint16_t ao_fake_tick_offset;
+static AO_TICK_TYPE ao_fake_tick_offset;
static struct ao_data ao_fake_cur, ao_fake_next;
void
for (bit = 0; bit < 8; bit++) {
if (((crc & 0x8000) >> 8) ^ (byte & 0x80))
- crc = (crc << 1) ^ 0x8005;
+ crc = (uint16_t) ((crc << 1) ^ 0x8005);
else
crc = (crc << 1);
- byte <<= 1;
+ byte = (uint8_t) (byte << 1);
}
return crc;
}
};
static inline uint16_t ao_interleave_index(uint16_t i) {
- return (i & ~0x1e) | ao_interleave_order[(i & 0x1e) >> 1];
+ return (uint16_t) ((i & ~0x1e) | ao_interleave_order[(i & 0x1e) >> 1]);
}
#define NUM_STATE 8
* the end of the input, in which case
* it will be seven.
*/
- int8_t dist = b - (o + 8); /* distance to last ready-for-writing bit */
+ int8_t dist = (int8_t) (b - (o + 8)); /* distance to last ready-for-writing bit */
uint32_t min_cost; /* lowest cost */
uint8_t min_state; /* lowest cost state */
uint8_t byte;
printf ("\tbit %3d min_cost %5d old bit %3d old_state %x bits %02x whiten %0x\n",
i/2, min_cost, o + 8, min_state, (bits[p][min_state] >> dist) & 0xff, *whiten);
#endif
- byte = (bits[p][min_state] >> dist) ^ *whiten++;
+ byte = (uint8_t) ((bits[p][min_state] >> dist) ^ *whiten++);
*out++ = byte;
if (out_len > 2)
crc = ao_fec_crc_byte(byte, crc);
ao_fec_check_crc(const uint8_t *bytes, uint8_t len)
{
uint16_t computed_crc = ao_fec_crc(bytes, len);
- uint16_t received_crc = (bytes[len] << 8) | (bytes[len+1]);
+ uint16_t received_crc = (uint16_t) ((bytes[len] << 8) | (bytes[len+1]));
return computed_crc == received_crc;
}
uint8_t num_fec;
/* Append CRC */
- extra[i++] = crc >> 8;
- extra[i++] = crc;
+ extra[i++] = (uint8_t) (crc >> 8);
+ extra[i++] = (uint8_t) crc;
/* Append FEC -- 1 byte if odd, two bytes if even */
num_fec = 2 - (i & 1);
for (byte = 0; byte < 2; byte++) {
if (pair + byte == len)
in = extra;
- fec |= *in++ ^ *whiten++;
+ fec |= (uint16_t) (*in++ ^ *whiten++);
for (bit = 0; bit < 8; bit++) {
encode = encode << 2 | ao_fec_encode_table[fec >> 7];
fec = (fec << 1) & 0x7ff;
interleave = (interleave << 2) | ((encode >> (byte_shift + bit_shift)) & 0x3);
}
- *out++ = interleave >> 24;
- *out++ = interleave >> 16;
- *out++ = interleave >> 8;
- *out++ = interleave >> 0;
+ *out++ = (uint8_t) (interleave >> 24);
+ *out++ = (uint8_t) (interleave >> 16);
+ *out++ = (uint8_t) (interleave >> 8);
+ *out++ = (uint8_t) (interleave >> 0);
}
- return (len + extra_len) * 2;
+ return (uint8_t) ((len + extra_len) * 2);
}
/* Main flight thread. */
enum ao_flight_state ao_flight_state; /* current flight state */
-uint16_t ao_boost_tick; /* time of most recent boost detect */
-uint16_t ao_launch_tick; /* time of first boost detect */
+AO_TICK_TYPE ao_boost_tick; /* time of most recent boost detect */
+AO_TICK_TYPE ao_launch_tick; /* time of first boost detect */
uint16_t ao_motor_number; /* number of motors burned so far */
#if HAS_SENSOR_ERRORS
* track min/max data over a long interval to detect
* resting
*/
-static uint16_t ao_interval_end;
+static AO_TICK_TYPE ao_interval_end;
#ifdef HAS_BARO
static ao_v_t ao_interval_min_height;
static ao_v_t ao_interval_max_height;
* (15 seconds) has past.
*/
if ((ao_accel < AO_MSS_TO_ACCEL(-2.5)) ||
- (int16_t) (ao_sample_tick - ao_boost_tick) > BOOST_TICKS_MAX)
+ (AO_TICK_SIGNED) (ao_sample_tick - ao_boost_tick) > (AO_TICK_SIGNED) BOOST_TICKS_MAX)
{
#if HAS_ACCEL
#if HAS_BARO
* number of seconds.
*/
if (ao_config.apogee_lockout) {
- if ((int16_t) (ao_sample_tick - ao_launch_tick) <
- AO_SEC_TO_TICKS(ao_config.apogee_lockout))
+ if ((AO_TICK_SIGNED) (ao_sample_tick - ao_launch_tick) <
+ (AO_TICK_SIGNED) AO_SEC_TO_TICKS(ao_config.apogee_lockout))
break;
}
#define MAX_QUIET_ACCEL 2
- if ((int16_t) (ao_sample_tick - ao_interval_end) >= 0) {
+ if ((AO_TICK_SIGNED) (ao_sample_tick - ao_interval_end) >= 0) {
if (ao_interval_max_accel_along - ao_interval_min_accel_along <= ao_data_accel_to_sample(MAX_QUIET_ACCEL) &&
ao_interval_max_accel_across - ao_interval_min_accel_across <= ao_data_accel_to_sample(MAX_QUIET_ACCEL) &&
ao_interval_max_accel_through - ao_interval_min_accel_through <= ao_data_accel_to_sample(MAX_QUIET_ACCEL))
if (ao_avg_height > ao_interval_max_height)
ao_interval_max_height = ao_avg_height;
- if ((int16_t) (ao_sample_tick - ao_interval_end) >= 0) {
+ if ((AO_TICK_SIGNED) (ao_sample_tick - ao_interval_end) >= 0) {
if (ao_interval_max_height - ao_interval_min_height <= AO_M_TO_HEIGHT(4))
{
ao_flight_state = ao_flight_landed;
};
extern enum ao_flight_state ao_flight_state;
-extern uint16_t ao_boost_tick;
-extern uint16_t ao_launch_tick;
+extern AO_TICK_TYPE ao_boost_tick;
+extern AO_TICK_TYPE ao_launch_tick;
extern uint16_t ao_motor_number;
extern uint16_t ao_launch_time;
/* Main flight thread. */
enum ao_flight_state ao_flight_state; /* current flight state */
-uint16_t ao_launch_tick; /* time of launch detect */
+AO_TICK_TYPE ao_launch_tick; /* time of launch detect */
/*
* track min/max data over a long interval to detect
* resting
*/
-uint16_t ao_interval_end;
+AO_TICK_TYPE ao_interval_end;
alt_t ao_interval_min_height;
alt_t ao_interval_max_height;
if (ao_height > ao_interval_max_height)
ao_interval_max_height = ao_height;
- if ((int16_t) (ao_sample_tick - ao_interval_end) >= 0) {
+ if ((AO_TICK_SIGNED) (ao_sample_tick - ao_interval_end) >= 0) {
if (ao_interval_max_height - ao_interval_min_height < AO_M_TO_HEIGHT(5))
{
ao_flight_state = ao_flight_landed;
* cal_freq
*/
-int32_t ao_freq_to_set(int32_t target_freq, int32_t cal_value)
+uint32_t ao_freq_to_set(uint32_t target_freq, uint32_t cal_value)
{
- int64_t prod = (int64_t) target_freq * (int64_t) cal_value;
+ uint64_t prod = (uint64_t) target_freq * (uint64_t) cal_value;
/* Round to nearest */
- int32_t target_value = (prod + (434550 / 2)) / 434550;
+ uint32_t target_value = (uint32_t) ((prod + (434550U / 2U)) / 434550U);
return target_value;
}
#endif
if ((new & AO_GPS_NEW_DATA) && (gps_data.flags & AO_GPS_VALID)) {
- gps_log.tick = ao_gps_tick;
+ gps_log.tick = (uint16_t) ao_gps_tick;
gps_log.type = AO_LOG_GPS_TIME;
gps_log.u.gps.latitude = gps_data.latitude;
gps_log.u.gps.longitude = gps_data.longitude;
ao_log_write(&gps_log);
}
if ((new & AO_GPS_NEW_TRACKING) && (n = gps_tracking_data.channels) != 0) {
- gps_log.tick = ao_gps_tick;
+ gps_log.tick = (uint16_t) ao_gps_tick;
gps_log.type = AO_LOG_GPS_SAT;
i = 0;
for (c = 0; c < n; c++)
ao_mutex_put(&ao_gps_mutex);
if ((new & AO_GPS_NEW_DATA) && (gps_data.flags & AO_GPS_VALID)) {
- gps_log.tick = ao_gps_tick;
+ gps_log.tick = (uint16_t) ao_gps_tick;
gps_log.type = AO_LOG_GPS_POS;
gps_log.u.gps.latitude = gps_data.latitude;
gps_log.u.gps.longitude = gps_data.longitude;
if ((new & AO_GPS_NEW_TRACKING) && (n = gps_tracking_data.channels)) {
gps_log.type = AO_LOG_GPS_SAT;
- gps_log.tick = ao_gps_tick;
+ gps_log.tick = (uint16_t) ao_gps_tick;
i = 0;
for (c = 0; c < n; c++) {
svid = gps_tracking_data.sats[c].svid;
* One set of samples read from the A/D converter
*/
struct ao_adc {
- uint16_t tick; /* tick when the sample was read */
+ AO_TICK_TYPE tick; /* tick when the sample was read */
int16_t accel; /* accelerometer */
int16_t pres; /* pressure sensor */
int16_t temp; /* temperature sensor */
ao_ignition[igniter].fired = 1;
switch (igniter) {
case ao_igniter_drogue:
+ if (wait && ao_config.apogee_delay &&
+ ao_config.ignite_mode != AO_IGNITE_MODE_MAIN)
+ ao_delay(AO_SEC_TO_TICKS(ao_config.apogee_delay));
AO_IGNITER_SET_DROGUE(1);
ao_delay(AO_IGNITER_FIRE_TIME);
AO_IGNITER_SET_DROGUE(0);
ao_kalman_predict(void)
{
#ifdef AO_FLIGHT_TEST
- if ((int16_t) (ao_sample_tick - ao_sample_prev_tick) > 50) {
+ if ((AO_TICK_SIGNED) (ao_sample_tick - ao_sample_prev_tick) > 50) {
ao_k_height += ((ao_k_t) ao_speed * AO_K_STEP_1 +
(ao_k_t) ao_accel * AO_K_STEP_2_2_1) >> 4;
ao_k_speed += (ao_k_t) ao_accel * AO_K_STEP_1;
return;
}
- if ((int16_t) (ao_sample_tick - ao_sample_prev_tick) > 5) {
+ if ((AO_TICK_SIGNED) (ao_sample_tick - ao_sample_prev_tick) > 5) {
ao_k_height += ((ao_k_t) ao_speed * AO_K_STEP_10 +
(ao_k_t) ao_accel * AO_K_STEP_2_2_10) >> 4;
ao_k_speed += (ao_k_t) ao_accel * AO_K_STEP_10;
{
ao_kalman_err_height();
#ifdef AO_FLIGHT_TEST
- if ((int16_t) (ao_sample_tick - ao_sample_prev_tick) > 50) {
+ if ((AO_TICK_SIGNED) (ao_sample_tick - ao_sample_prev_tick) > 50) {
ao_k_height += (ao_k_t) AO_BARO_K0_1 * ao_error_h;
ao_k_speed += (ao_k_t) AO_BARO_K1_1 * ao_error_h;
ao_k_accel += (ao_k_t) AO_BARO_K2_1 * ao_error_h;
return;
}
- if ((int16_t) (ao_sample_tick - ao_sample_prev_tick) > 5) {
+ if ((AO_TICK_SIGNED) (ao_sample_tick - ao_sample_prev_tick) > 5) {
ao_k_height += (ao_k_t) AO_BARO_K0_10 * ao_error_h;
ao_k_speed += (ao_k_t) AO_BARO_K1_10 * ao_error_h;
ao_k_accel += (ao_k_t) AO_BARO_K2_10 * ao_error_h;
accel = (ao_config.accel_plus_g - ao_sample_accel) * ao_accel_scale;
/* Can't use ao_accel here as it is the pre-prediction value still */
- ao_error_a = (accel - ao_k_accel) >> 16;
+ ao_error_a = (ao_v_t) ((accel - ao_k_accel) >> 16);
}
#if !defined(FORCE_ACCEL) && HAS_BARO
ao_kalman_err_accel();
#ifdef AO_FLIGHT_TEST
- if ((int16_t) (ao_sample_tick - ao_sample_prev_tick) > 50) {
+ if ((AO_TICK_SIGNED) (ao_sample_tick - ao_sample_prev_tick) > 50) {
if (ao_flight_debug) {
printf ("correct speed %g + (%g * %g) + (%g * %g) = %g\n",
ao_k_speed / (65536.0 * 16.0),
(ao_k_t) AO_BOTH_K21_1 * ao_error_a;
return;
}
- if ((int16_t) (ao_sample_tick - ao_sample_prev_tick) > 5) {
+ if ((AO_TICK_SIGNED) (ao_sample_tick - ao_sample_prev_tick) > 5) {
if (ao_flight_debug) {
printf ("correct speed %g + (%g * %g) + (%g * %g) = %g\n",
ao_k_speed / (65536.0 * 16.0),
ao_kalman_err_accel();
#ifdef AO_FLIGHT_TEST
- if ((int16_t) (ao_sample_tick - ao_sample_prev_tick) > 5) {
+ if ((AO_TICK_SIGNED) (ao_sample_tick - ao_sample_prev_tick) > 5) {
ao_k_height +=(ao_k_t) AO_ACCEL_K0_10 * ao_error_a;
ao_k_speed += (ao_k_t) AO_ACCEL_K1_10 * ao_error_a;
ao_k_accel += (ao_k_t) AO_ACCEL_K2_10 * ao_error_a;
ao_kalman_correct_accel();
#endif
#endif
- ao_height = from_fix(ao_k_height);
- ao_speed = from_fix(ao_k_speed);
- ao_accel = from_fix(ao_k_accel);
+ ao_height = (ao_v_t) from_fix(ao_k_height);
+ ao_speed = (ao_v_t) from_fix(ao_k_speed);
+ ao_accel = (ao_v_t) from_fix(ao_k_accel);
if (ao_height > ao_max_height)
ao_max_height = ao_height;
#if HAS_BARO
ao_avg_height_scaled = ao_avg_height_scaled - ao_avg_height + ao_height;
#endif
#ifdef AO_FLIGHT_TEST
- if ((int16_t) (ao_sample_tick - ao_sample_prev_tick) > 50)
+ if ((AO_TICK_SIGNED) (ao_sample_tick - ao_sample_prev_tick) > 50)
ao_avg_height = (ao_avg_height_scaled + 1) >> 1;
- else if ((int16_t) (ao_sample_tick - ao_sample_prev_tick) > 5)
+ else if ((AO_TICK_SIGNED) (ao_sample_tick - ao_sample_prev_tick) > 5)
ao_avg_height = (ao_avg_height_scaled + 7) >> 4;
else
#endif
- ao_avg_height = (ao_avg_height_scaled + 63) >> 7;
+ ao_avg_height = (ao_v_t) ((ao_avg_height_scaled + 63) >> 7);
}
uint32_t ao_log_start_pos;
uint8_t ao_log_running;
enum ao_flight_state ao_log_state;
-int16_t ao_flight_number;
+uint16_t ao_flight_number;
void
ao_log_flush(void)
if (pos == 0) {
uint8_t i;
for (i = 1; i < LOG_MAX_ERASE; i++) {
- erase.mark = ~LOG_ERASE_MARK;
+ erase.mark = (uint8_t) ~LOG_ERASE_MARK;
erase.flight = 0;
ao_config_write(ao_log_erase_pos(i), &erase, sizeof (erase));
}
return 1;
}
-int16_t
+int32_t
ao_log_flight(uint8_t slot)
{
if (ao_storage_is_erased(ao_log_pos_block_start(slot)))
if (!ao_storage_read(ao_log_pos(slot),
&ao_log_data,
sizeof (ao_log_type)))
- return -(int16_t) (slot + 1);
+ return -(int32_t) (slot + 1);
if (!ao_log_check_data() || ao_log_data.type != AO_LOG_FLIGHT)
- return -(int16_t) (slot + 1);
+ return -(int32_t) (slot + 1);
- return ao_log_data.u.flight.flight;
+ return (int32_t) ao_log_data.u.flight.flight;
}
#endif
return (uint8_t) (ao_storage_log_max / ao_config.flight_log_max);
}
-static int16_t
+static uint16_t
ao_log_max_flight(void)
{
uint8_t log_slot;
uint8_t log_slots;
- int16_t log_flight;
- int16_t max_flight = 0;
+ int32_t log_flight;
+ uint16_t max_flight = 0;
/* Scan the log space looking for the biggest flight number */
log_slots = ao_log_slots();
if (log_flight <= 0)
continue;
if (max_flight == 0 || log_flight > max_flight)
- max_flight = log_flight;
+ max_flight = (uint16_t) log_flight;
}
return max_flight;
}
/* Find a log slot for the next flight, if available */
ao_log_current_pos = ao_log_end_pos = 0;
log_slots = ao_log_slots();
- log_want = (ao_flight_number - 1) % log_slots;
+ log_want = (uint8_t) ((ao_flight_number - 1) % log_slots);
log_slot = log_want;
do {
if (ao_log_flight(log_slot) == 0) {
{
uint8_t slot;
uint8_t slots;
- int16_t flight;
+ int32_t flight;
slots = ao_log_slots();
for (slot = 0; slot < slots; slot++)
{
flight = ao_log_flight(slot);
if (flight)
- printf ("flight %d start %x end %x\n",
+ printf ("flight %ld start %x end %x\n",
flight,
(uint16_t) (ao_log_pos(slot) >> 8),
(uint16_t) (ao_log_pos_block_end(slot) >> 8));
{
uint8_t slot;
uint8_t slots;
- int16_t cmd_flight = 1;
+ int32_t cmd_flight = 1;
ao_cmd_white();
if (ao_cmd_lex_c == '-') {
cmd_flight = -1;
ao_cmd_lex();
}
- cmd_flight *= ao_cmd_decimal();
+ cmd_flight *= (int32_t) ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
}
}
}
- printf("No such flight: %d\n", cmd_flight);
+ printf("No such flight: %ld\n", cmd_flight);
}
const struct ao_cmds ao_log_cmds[] = {
* the log. Tasks may wait for this to be initialized
* by sleeping on this variable.
*/
-extern int16_t ao_flight_number;
+extern uint16_t ao_flight_number;
extern uint8_t ao_log_mutex;
extern uint32_t ao_log_current_pos;
extern uint32_t ao_log_end_pos;
/* Return the flight number from the given log slot, 0 if none, -slot on failure */
-int16_t
+int32_t
ao_log_flight(uint8_t slot);
/* Checksum the loaded log record */
struct {
uint16_t flight; /* 4 */
int16_t ground_accel; /* 6 */
- uint32_t ground_pres; /* 8 */
+ int32_t ground_pres; /* 8 */
int16_t ground_accel_along; /* 12 */
int16_t ground_accel_across; /* 14 */
int16_t ground_accel_through; /* 16 */
struct {
uint16_t flight; /* 4 */
int16_t ground_accel; /* 6 */
- uint32_t ground_pres; /* 8 */
+ int32_t ground_pres; /* 8 */
int16_t ground_accel_along; /* 12 */
int16_t ground_accel_across; /* 14 */
int16_t ground_accel_through; /* 16 */
struct {
uint16_t flight; /* 4 */
int16_t ground_accel; /* 6 */
- uint32_t ground_pres; /* 8 */
+ int32_t ground_pres; /* 8 */
uint32_t ground_temp; /* 12 */
} flight; /* 16 */
/* AO_LOG_STATE */
struct {
uint16_t flight; /* 4 */
uint16_t r6;
- uint32_t ground_pres; /* 8 */
+ int32_t ground_pres; /* 8 */
} flight;
/* AO_LOG_STATE */
struct {
}; /* 16 */
#define ao_log_pack24(dst,value) do { \
- (dst)[0] = (value); \
- (dst)[1] = (value) >> 8; \
- (dst)[2] = (value) >> 16; \
+ (dst)[0] = (uint8_t) (value); \
+ (dst)[1] = (uint8_t) ((value) >> 8); \
+ (dst)[2] = (uint8_t) ((value) >> 16); \
} while (0)
struct ao_log_gps {
void
ao_log(void)
{
- uint16_t next_sensor, next_other;
+ AO_TICK_TYPE next_sensor, next_other;
ao_storage_setup();
for (;;) {
/* Write samples to EEPROM */
while (ao_log_data_pos != ao_sample_data) {
- ao_log_data.tick = ao_data_ring[ao_log_data_pos].tick;
- if ((int16_t) (ao_log_data.tick - next_sensor) >= 0) {
+ AO_TICK_TYPE tick = ao_data_ring[ao_log_data_pos].tick;
+ ao_log_data.tick = tick;
+ if ((AO_TICK_SIGNED) (tick - next_sensor) >= 0) {
ao_log_data.type = AO_LOG_SENSOR;
ao_log_data.u.sensor.accel = ao_data_ring[ao_log_data_pos].adc.accel;
ao_log_data.u.sensor.pres = ao_data_ring[ao_log_data_pos].adc.pres;
ao_log_write(&ao_log_data);
if (ao_log_state <= ao_flight_coast)
- next_sensor = ao_log_data.tick + AO_SENSOR_INTERVAL_ASCENT;
+ next_sensor = tick + AO_SENSOR_INTERVAL_ASCENT;
else
- next_sensor = ao_log_data.tick + AO_SENSOR_INTERVAL_DESCENT;
+ next_sensor = tick + AO_SENSOR_INTERVAL_DESCENT;
}
- if ((int16_t) (ao_log_data.tick - next_other) >= 0) {
+ if ((AO_TICK_SIGNED) (tick - next_other) >= 0) {
ao_log_data.type = AO_LOG_TEMP_VOLT;
ao_log_data.u.temp_volt.temp = ao_data_ring[ao_log_data_pos].adc.temp;
ao_log_data.u.temp_volt.v_batt = ao_data_ring[ao_log_data_pos].adc.v_batt;
ao_log_data.u.deploy.drogue = ao_data_ring[ao_log_data_pos].adc.sense_d;
ao_log_data.u.deploy.main = ao_data_ring[ao_log_data_pos].adc.sense_m;
ao_log_write(&ao_log_data);
- next_other = ao_log_data.tick + AO_OTHER_INTERVAL;
+ next_other = tick + AO_OTHER_INTERVAL;
}
ao_log_data_pos = ao_data_ring_next(ao_log_data_pos);
}
ao_sleep(&ao_log_running);
ao_fireone_data.type = AO_LOG_FLIGHT;
- ao_fireone_data.tick = ao_time();
+ ao_fireone_data.tick = (uint16_t) ao_time();
ao_fireone_data.u.flight.flight = ao_flight_number;
ao_log_firetwo();
for (;;) {
/* Write samples to EEPROM */
while (ao_fireone_data_pos != ao_data_head) {
- ao_fireone_data.tick = ao_data_ring[ao_fireone_data_pos].tick;
+ ao_fireone_data.tick = (uint16_t) ao_data_ring[ao_fireone_data_pos].tick;
ao_fireone_data.type = AO_LOG_SENSOR;
- ao_fireone_data.u.sensor.pressure = ao_data_ring[ao_fireone_data_pos].adc.pressure;
- ao_fireone_data.u.sensor.thrust = ao_data_ring[ao_fireone_data_pos].adc.thrust;
+ ao_fireone_data.u.sensor.pressure = (uint16_t) ao_data_ring[ao_fireone_data_pos].adc.pressure;
+ ao_fireone_data.u.sensor.thrust = (uint16_t) ao_data_ring[ao_fireone_data_pos].adc.thrust;
// for (i = 0; i < 4; i++) {
// ao_fireone_data.u.sensor.thermistor[i] = ao_data_ring[ao_fireone_data_pos].sensor.thermistor[i];
// }
ao_log_gps_flight(void)
{
ao_log_data.type = AO_LOG_FLIGHT;
- ao_log_data.tick = ao_time();
+ ao_log_data.tick = (uint16_t) ao_time();
ao_log_data.u.flight.flight = ao_flight_number;
ao_log_write(&ao_log_data);
}
void
-ao_log_gps_data(uint16_t tick, struct ao_telemetry_location *gps_data)
+ao_log_gps_data(AO_TICK_TYPE tick, struct ao_telemetry_location *gps_data)
{
- ao_log_data.tick = tick;
+ ao_log_data.tick = (uint16_t) tick;
ao_log_data.type = AO_LOG_GPS_TIME;
ao_log_data.u.gps.latitude = gps_data->latitude;
ao_log_data.u.gps.longitude = gps_data->longitude;
}
void
-ao_log_gps_tracking(uint16_t tick, struct ao_telemetry_satellite *gps_tracking_data)
+ao_log_gps_tracking(AO_TICK_TYPE tick, struct ao_telemetry_satellite *gps_tracking_data)
{
uint8_t c, n, i;
- ao_log_data.tick = tick;
+ ao_log_data.tick = (uint16_t) tick;
ao_log_data.type = AO_LOG_GPS_SAT;
i = 0;
n = gps_tracking_data->channels;
ao_log_gps_flight(void);
void
-ao_log_gps_data(uint16_t tick, struct ao_telemetry_location *gps_data);
+ao_log_gps_data(AO_TICK_TYPE tick, struct ao_telemetry_location *gps_data);
void
-ao_log_gps_tracking(uint16_t tick, struct ao_telemetry_satellite *gps_tracking_data);
+ao_log_gps_tracking(AO_TICK_TYPE tick, struct ao_telemetry_satellite *gps_tracking_data);
#endif /* _AO_LOG_GPS_H_ */
void
ao_log(void)
{
- uint16_t next_sensor, next_other;
+ AO_TICK_TYPE next_sensor, next_other;
uint8_t i;
ao_storage_setup();
#if HAS_FLIGHT
ao_log_data.type = AO_LOG_FLIGHT;
- ao_log_data.tick = ao_sample_tick;
+ ao_log_data.tick = (uint16_t) ao_sample_tick;
#if HAS_ACCEL
ao_log_data.u.flight.ground_accel = ao_ground_accel;
#endif
for (;;) {
/* Write samples to EEPROM */
while (ao_log_data_pos != ao_data_head) {
- ao_log_data.tick = ao_data_ring[ao_log_data_pos].tick;
+ AO_TICK_TYPE tick = ao_data_ring[ao_log_data_pos].tick;
+ ao_log_data.tick = (uint16_t) tick;
volatile struct ao_data *d = &ao_data_ring[ao_log_data_pos];
- if ((int16_t) (ao_log_data.tick - next_sensor) >= 0) {
+ if ((AO_TICK_SIGNED) (tick - next_sensor) >= 0) {
ao_log_data.type = AO_LOG_SENSOR;
#if HAS_MS5607
ao_log_data.u.sensor.pres = d->ms5607_raw.pres;
ao_log_data.u.sensor.accel = ao_data_accel(&ao_data_ring[ao_log_data_pos]);
ao_log_write(&ao_log_data);
if (ao_log_state <= ao_flight_coast)
- next_sensor = ao_log_data.tick + AO_SENSOR_INTERVAL_ASCENT;
+ next_sensor = tick + AO_SENSOR_INTERVAL_ASCENT;
else
- next_sensor = ao_log_data.tick + AO_SENSOR_INTERVAL_DESCENT;
+ next_sensor = tick + AO_SENSOR_INTERVAL_DESCENT;
}
- if ((int16_t) (ao_log_data.tick - next_other) >= 0) {
+ if ((AO_TICK_SIGNED) (tick - next_other) >= 0) {
ao_log_data.type = AO_LOG_TEMP_VOLT;
ao_log_data.u.volt.v_batt = d->adc.v_batt;
ao_log_data.u.volt.v_pbatt = d->adc.v_pbatt;
ao_log_data.u.volt.sense[i] = d->adc.sense[i];
ao_log_data.u.volt.pyro = ao_pyro_fired;
ao_log_write(&ao_log_data);
- next_other = ao_log_data.tick + AO_OTHER_INTERVAL;
+ next_other = tick + AO_OTHER_INTERVAL;
}
ao_log_data_pos = ao_data_ring_next(ao_log_data_pos);
}
if (ao_flight_state != ao_log_state) {
ao_log_state = ao_flight_state;
ao_log_data.type = AO_LOG_STATE;
- ao_log_data.tick = ao_time();
+ ao_log_data.tick = (uint16_t) ao_time();
ao_log_data.u.state.state = ao_log_state;
ao_log_data.u.state.reason = 0;
ao_log_write(&ao_log_data);
void
ao_log(void)
{
- uint16_t next_sensor, next_other;
+ AO_TICK_TYPE next_sensor, next_other;
ao_storage_setup();
#if HAS_FLIGHT
ao_log_data.type = AO_LOG_FLIGHT;
- ao_log_data.tick = ao_sample_tick;
+ ao_log_data.tick = (uint16_t) ao_sample_tick;
#if HAS_ACCEL
ao_log_data.u.flight.ground_accel = ao_ground_accel;
#endif
for (;;) {
/* Write samples to EEPROM */
while (ao_log_data_pos != ao_data_head) {
- ao_log_data.tick = ao_data_ring[ao_log_data_pos].tick;
- if ((int16_t) (ao_log_data.tick - next_sensor) >= 0) {
+ AO_TICK_TYPE tick = ao_data_ring[ao_log_data_pos].tick;
+ ao_log_data.tick = (uint16_t) tick;
+ if ((AO_TICK_SIGNED) (tick - next_sensor) >= 0) {
ao_log_data.type = AO_LOG_SENSOR;
#if HAS_MS5607
ao_log_data.u.sensor.pres = ao_data_ring[ao_log_data_pos].ms5607_raw.pres;
#endif
ao_log_write(&ao_log_data);
if (ao_log_state <= ao_flight_coast)
- next_sensor = ao_log_data.tick + AO_SENSOR_INTERVAL_ASCENT;
+ next_sensor = tick + AO_SENSOR_INTERVAL_ASCENT;
else
- next_sensor = ao_log_data.tick + AO_SENSOR_INTERVAL_DESCENT;
+ next_sensor = tick + AO_SENSOR_INTERVAL_DESCENT;
}
- if ((int16_t) (ao_log_data.tick - next_other) >= 0) {
+ if ((AO_TICK_SIGNED) (tick - next_other) >= 0) {
ao_log_data.type = AO_LOG_TEMP_VOLT;
ao_log_data.u.volt.v_batt = ao_data_ring[ao_log_data_pos].adc.v_batt;
ao_log_data.u.volt.sense_a = ao_data_ring[ao_log_data_pos].adc.sense_a;
ao_log_data.u.volt.sense_m = ao_data_ring[ao_log_data_pos].adc.sense_m;
ao_log_write(&ao_log_data);
- next_other = ao_log_data.tick + AO_OTHER_INTERVAL;
+ next_other = tick + AO_OTHER_INTERVAL;
}
ao_log_data_pos = ao_data_ring_next(ao_log_data_pos);
}
if (ao_flight_state != ao_log_state) {
ao_log_state = ao_flight_state;
ao_log_data.type = AO_LOG_STATE;
- ao_log_data.tick = ao_time();
+ ao_log_data.tick = (uint16_t) ao_time();
ao_log_data.u.state.state = ao_log_state;
ao_log_data.u.state.reason = 0;
ao_log_write(&ao_log_data);
void
ao_log_micro_data(void)
{
- uint16_t low_bits = pa;
+ uint16_t low_bits = (uint16_t) pa;
if (ao_log_offset < MAX_LOG_OFFSET) {
ao_eeprom_write(ao_log_offset, &low_bits, sizeof (low_bits));
ao_log_hex_nibble(uint8_t b)
{
if (b < 10)
- ao_async_byte('0' + b);
+ ao_async_byte((uint8_t) ('0' + b));
else
- ao_async_byte('a' - 10 + b);
+ ao_async_byte((uint8_t) ('a' - 10 + b));
}
void
if (n_samples == (N_SAMPLES_TYPE) (~0))
n_samples = 0;
- nbytes = STARTING_LOG_OFFSET + sizeof (uint16_t) * n_samples;
+ nbytes = (uint16_t) (STARTING_LOG_OFFSET + sizeof (uint16_t) * n_samples);
/*
* Rewrite n_samples so that it includes the log ID value with
ao_eeprom_read(b, &byte, 1);
#if AO_LOG_ID
if (N_SAMPLES_OFFSET <= b && b < (N_SAMPLES_OFFSET + sizeof(n_samples))) {
- byte = n_samples >> ((b - N_SAMPLES_OFFSET) << 3);
+ byte = (uint8_t) (n_samples >> ((b - N_SAMPLES_OFFSET) << 3));
}
#endif
ao_log_hex(byte);
}
ao_log_newline();
crc = ~crc;
- ao_log_hex(crc >> 8);
- ao_log_hex(crc);
+ ao_log_hex((uint8_t) (crc >> 8));
+ ao_log_hex((uint8_t) crc);
ao_log_newline();
ao_async_stop();
}
void
ao_log(void)
{
- uint16_t next_sensor;
+ AO_TICK_TYPE next_sensor;
ao_storage_setup();
#if HAS_FLIGHT
ao_log_data.type = AO_LOG_FLIGHT;
- ao_log_data.tick = ao_sample_tick;
+ ao_log_data.tick = (uint16_t) ao_sample_tick;
ao_log_data.u.flight.flight = ao_flight_number;
ao_log_data.u.flight.ground_pres = ao_ground_pres;
ao_log_write(&ao_log_data);
for (;;) {
/* Write samples to EEPROM */
while (ao_log_data_pos != ao_data_head) {
- ao_log_data.tick = ao_data_ring[ao_log_data_pos].tick;
- if ((int16_t) (ao_log_data.tick - next_sensor) >= 0) {
+ AO_TICK_TYPE tick = ao_data_ring[ao_log_data_pos].tick;
+ ao_log_data.tick = (uint16_t) tick;
+ if ((AO_TICK_SIGNED) (tick - next_sensor) >= 0) {
ao_log_data.type = AO_LOG_SENSOR;
ao_log_pack24(ao_log_data.u.sensor.pres,
ao_data_ring[ao_log_data_pos].ms5607_raw.pres);
#endif
ao_log_write(&ao_log_data);
if (ao_log_state <= ao_flight_coast)
- next_sensor = ao_log_data.tick + AO_SENSOR_INTERVAL_ASCENT;
+ next_sensor = tick + AO_SENSOR_INTERVAL_ASCENT;
else
- next_sensor = ao_log_data.tick + AO_SENSOR_INTERVAL_DESCENT;
+ next_sensor = tick + AO_SENSOR_INTERVAL_DESCENT;
}
ao_log_data_pos = ao_data_ring_next(ao_log_data_pos);
}
if (ao_flight_state != ao_log_state) {
ao_log_state = ao_flight_state;
ao_log_data.type = AO_LOG_STATE;
- ao_log_data.tick = ao_time();
+ ao_log_data.tick = (uint16_t) ao_time();
ao_log_data.u.state.state = ao_log_state;
ao_log_data.u.state.reason = 0;
ao_log_write(&ao_log_data);
void
ao_log(void)
{
- uint16_t next_sensor;
+ AO_TICK_TYPE next_sensor;
ao_storage_setup();
ao_sleep(&ao_log_running);
ao_log_data.type = AO_LOG_FLIGHT;
- ao_log_data.tick = ao_sample_tick;
+ ao_log_data.tick = (uint16_t) ao_sample_tick;
ao_log_data.u.flight.ground_accel = ao_ground_accel;
ao_log_data.u.flight.ground_accel_along = ao_ground_accel_along;
ao_log_data.u.flight.ground_accel_through = ao_ground_accel_through;
for (;;) {
/* Write samples to EEPROM */
while (ao_log_data_pos != ao_data_head) {
- ao_log_data.tick = ao_data_ring[ao_log_data_pos].tick;
- if ((int16_t) (ao_log_data.tick - next_sensor) >= 0) {
+ AO_TICK_TYPE tick = ao_data_ring[ao_log_data_pos].tick;
+ ao_log_data.tick = (uint16_t) tick;
+ if ((AO_TICK_SIGNED) (tick - next_sensor) >= 0) {
ao_log_data.type = AO_LOG_SENSOR;
- ao_log_data.u.sensor.pressure = ao_data_motor_pressure(&ao_data_ring[ao_log_data_pos]);
- ao_log_data.u.sensor.v_batt = ao_data_ring[ao_log_data_pos].adc.v_batt;
+ ao_log_data.u.sensor.pressure = (uint16_t) ao_data_motor_pressure(&ao_data_ring[ao_log_data_pos]);
+ ao_log_data.u.sensor.v_batt = (uint16_t) ao_data_ring[ao_log_data_pos].adc.v_batt;
ao_log_data.u.sensor.accel = ao_data_accel(&ao_data_ring[ao_log_data_pos]);
ao_log_data.u.sensor.accel_across = ao_data_across(&ao_data_ring[ao_log_data_pos]);
ao_log_data.u.sensor.accel_along = ao_data_along(&ao_data_ring[ao_log_data_pos]);
ao_log_data.u.sensor.accel_through = ao_data_through(&ao_data_ring[ao_log_data_pos]);
ao_log_write(&ao_log_data);
if (ao_log_state <= ao_flight_coast)
- next_sensor = ao_log_data.tick + AO_SENSOR_INTERVAL_ASCENT;
+ next_sensor = tick + AO_SENSOR_INTERVAL_ASCENT;
else
- next_sensor = ao_log_data.tick + AO_SENSOR_INTERVAL_DESCENT;
+ next_sensor = tick + AO_SENSOR_INTERVAL_DESCENT;
}
ao_log_data_pos = ao_data_ring_next(ao_log_data_pos);
}
if (ao_flight_state != ao_log_state) {
ao_log_state = ao_flight_state;
ao_log_data.type = AO_LOG_STATE;
- ao_log_data.tick = ao_time();
+ ao_log_data.tick = (uint16_t) ao_time();
ao_log_data.u.state.state = ao_log_state;
ao_log_data.u.state.reason = 0;
ao_log_write(&ao_log_data);
#include "ao.h"
-static uint16_t ao_log_tiny_interval;
+static AO_TICK_TYPE ao_log_tiny_interval;
#define AO_LOG_TINY_INTERVAL_DEFAULT AO_MS_TO_TICKS(1000)
#if USE_FAST_ASCENT_LOG
#endif
void
-ao_log_tiny_set_interval(uint16_t ticks)
+ao_log_tiny_set_interval(AO_TICK_TYPE ticks)
{
ao_log_tiny_interval = ticks;
}
* Write out the sample when finished
*/
now = ao_time();
- if ((int16_t) (now - (last_time + ao_log_tiny_interval)) >= 0 && count) {
+ if ((AO_TICK_SIGNED) (now - (last_time + ao_log_tiny_interval)) >= 0 && count) {
count = sum / count;
if (ao_log_started)
ao_log_tiny_data(count);
uint32_t pa;
uint32_t pa_ground;
+uint32_t pa_ground_next;
uint32_t pa_min;
static void
{
int16_t sample_count;
int16_t log_count;
- uint16_t time;
+ AO_TICK_TYPE time;
uint32_t pa_interval_min, pa_interval_max;
int32_t pa_diff;
uint8_t h;
time = ao_time();
ao_pa_get();
ao_microkalman_init();
- pa_ground = pa;
+ pa_ground_next = pa_ground = pa;
sample_count = 0;
h = 0;
for (;;) {
#endif
pa_hist[h] = pa;
h = SKIP_PA_HIST(h,1);
- pa_diff = pa_ground - ao_pa;
+ pa_diff = (int32_t) (pa_ground - ao_pa);
#if BOOST_DETECT
/* Check for a significant pressure change */
pa_sum += pa;
++sample_count;
} else {
- pa_ground = pa_sum >> GROUND_AVG_SHIFT;
+ pa_ground = pa_ground_next;
+ pa_ground_next = pa_sum >> GROUND_AVG_SHIFT;
pa_sum = 0;
sample_count = 0;
#if !BOOST_DETECT
pa_min = ao_pa;
if (sample_count == (GROUND_AVG - 1)) {
- pa_diff = pa_interval_max - pa_interval_min;
+ pa_diff = (int32_t) (pa_interval_max - pa_interval_min);
/* Check to see if the pressure is now stable */
if (pa_diff < LAND_DETECT)
void
ao_microkalman_init(void)
{
- ao_pa = pa;
- ao_k_pa = pa << 8;
+ ao_pa = (uint32_t) pa;
+ ao_k_pa = (uint32_t) (pa << 8);
}
void
ao_microkalman_predict(void)
{
- ao_k_pa += fix16_to_fix8((int32_t) ao_pa_speed * AO_MK_STEP + (int32_t) ao_pa_accel * AO_MK_STEP_2_2);
+ ao_k_pa += (uint32_t) (int32_t) fix16_to_fix8((int32_t) ao_pa_speed * AO_MK_STEP + (int32_t) ao_pa_accel * AO_MK_STEP_2_2);
ao_k_pa_speed += (int32_t) ao_pa_accel * AO_MK_STEP;
}
{
int16_t e; /* Height error in Pa */
- e = pa - from_fix8(ao_k_pa);
+ e = (int16_t) (pa - from_fix8(ao_k_pa));
- ao_k_pa += fix16_to_fix8((int32_t) e * AO_K0_10);
+ ao_k_pa += (uint32_t)(int32_t)fix16_to_fix8(e * AO_K0_10);
ao_k_pa_speed += (int32_t) e * AO_K1_10;
ao_k_pa_accel += (int32_t) e * AO_K2_10;
ao_pa = from_fix8(ao_k_pa);
- ao_pa_speed = from_fix(ao_k_pa_speed);
- ao_pa_accel = from_fix(ao_k_pa_accel);
+ ao_pa_speed = (int16_t) from_fix(ao_k_pa_speed);
+ ao_pa_accel = (int16_t) from_fix(ao_k_pa_accel);
}
static void
set_monitor(void)
{
- ao_external_monitoring = ao_cmd_hex();
+ ao_external_monitoring = (uint8_t) ao_cmd_hex();
ao_wakeup(&ao_external_monitoring);
ao_wakeup(&ao_monitor_head);
_ao_monitor_adjust();
ao_delay_until(AO_TICK_TYPE target)
{
ao_arch_block_interrupts();
- while ((int16_t) (target - ao_tick_count) > 0)
+ while ((AO_TICK_SIGNED) (target - ao_tick_count) > 0)
ao_sleep((void *) &ao_tick_count);
ao_arch_release_interrupts();
}
* of the requirements
*/
static uint8_t
-ao_pyro_ready(struct ao_pyro *pyro)
+ao_pyro_ready(const struct ao_pyro *pyro)
{
enum ao_pyro_flag flag, flags;
#if HAS_GYRO
#endif
case ao_pyro_time_less:
- if ((int32_t) (ao_time() - ao_launch_tick) <= pyro->time_less)
+ if ((AO_TICK_SIGNED) (ao_time() - ao_launch_tick) <= pyro->time_less)
continue;
- DBG("time %d > %d\n", (int32_t)(ao_time() - ao_launch_tick), pyro->time_less);
+ DBG("time %d > %d\n", (AO_TICK_SIGNED)(ao_time() - ao_launch_tick), pyro->time_less);
break;
case ao_pyro_time_greater:
- if ((int32_t) (ao_time() - ao_launch_tick) >= pyro->time_greater)
+ if ((AO_TICK_SIGNED) (ao_time() - ao_launch_tick) >= pyro->time_greater)
continue;
- DBG("time %d < %d\n", (int32_t)(ao_time() - ao_launch_tick), pyro->time_greater);
+ DBG("time %d < %d\n", (AO_TICK_SIGNED)(ao_time() - ao_launch_tick), pyro->time_greater);
break;
case ao_pyro_ascending:
ao_delay(AO_MS_TO_TICKS(50));
}
+static AO_TICK_TYPE pyro_delay_done[AO_PYRO_NUM];
+
static uint8_t
ao_pyro_check(void)
{
- struct ao_pyro *pyro;
+ const struct ao_pyro *pyro;
uint8_t p, any_waiting;
uint16_t fire = 0;
any_waiting = 1;
/* Check pyro state to see if it should fire
*/
- if (!pyro->delay_done) {
+ if (!pyro_delay_done[p]) {
if (!ao_pyro_ready(pyro))
continue;
* it expires
*/
if (pyro->flags & ao_pyro_delay) {
- pyro->delay_done = ao_time() + pyro->delay;
- if (!pyro->delay_done)
- pyro->delay_done = 1;
+ AO_TICK_TYPE delay_done;
+ AO_TICK_SIGNED delay = pyro->delay;
+ if (delay < 0)
+ delay = 0;
+ delay_done = ao_time() + (AO_TICK_TYPE) delay;
+
+ /*
+ * delay_done is the time at which the
+ * delay ends, but it is also used as
+ * an indication that a delay is
+ * active -- non-zero values indicate
+ * an active delay. This code ensures
+ * the value is non-zero, which might
+ * introduce an additional tick
+ * of delay.
+ */
+ if (delay_done == 0)
+ delay_done = 1;
+ pyro_delay_done[p] = delay_done;
}
}
/* Check to see if we're just waiting for
* the delay to expire
*/
- if (pyro->delay_done) {
+ if (pyro_delay_done[p] != 0) {
/* Check to make sure the required conditions
* remain valid. If not, inhibit the channel
* by setting the inhibited bit
*/
if (!ao_pyro_ready(pyro)) {
- ao_pyro_inhibited |= (1 << p);
+ ao_pyro_inhibited |= (uint16_t) (1 << p);
continue;
}
- if ((int32_t) (ao_time() - pyro->delay_done) < 0)
+ if ((AO_TICK_SIGNED) (ao_time() - pyro_delay_done[p]) < 0)
continue;
}
- fire |= (1 << p);
+ fire |= (uint16_t) (1U << p);
}
if (fire) {
case 8:
if (value < 0)
return false;
- *((uint8_t *) ((char *) base + offset)) = value;
+ *((uint8_t *) ((char *) base + offset)) = (uint8_t) value;
break;
case 16:
default:
- *((int16_t *) (void *) ((char *) base + offset)) = value;
+ *((int16_t *) (void *) ((char *) base + offset)) = (int16_t) value;
break;
case 32:
*((int32_t *) (void *) ((char *) base + offset)) = value;
void
ao_pyro_set(void)
{
- uint8_t p;
+ uint32_t p;
struct ao_pyro pyro_tmp;
char name[AO_PYRO_NAME_LEN];
uint8_t c;
if (ao_cmd_status != ao_cmd_success)
return;
if (AO_PYRO_NUM <= p) {
- printf ("invalid pyro channel %d\n", p);
+ printf ("invalid pyro channel %lu\n", p);
return;
}
memset(&pyro_tmp, '\0', sizeof (pyro_tmp));
r = -1;
ao_cmd_lex();
}
- r *= ao_cmd_decimal();
+ r *= (int32_t) ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
if (!ao_pyro_put(&pyro_tmp, ao_pyro_values[v].offset,
char *after_pyro_1_24 = pyro_base_1_24 + AO_PYRO_NUM * sizeof (struct ao_pyro_1_24);
char *config_end_1_25 = (void *) (&ao_config + 1);
- size_t to_move = config_end_1_25 - after_pyro_1_25;
+ size_t to_move = (size_t) (config_end_1_25 - after_pyro_1_25);
memmove(after_pyro_1_25, after_pyro_1_24, to_move);
int32_t delay;
uint8_t state_less, state_greater_or_equal;
int16_t motor;
- int32_t delay_done;
- uint8_t _unused; /* was 'fired' */
+ uint32_t _unused1; /* was 'delay_done' */
+ uint8_t _unused2; /* was 'fired' */
};
#define AO_PYRO_8_BIT_VALUE (ao_pyro_state_less|ao_pyro_state_greater_or_equal)
len = AO_CMAC_KEY_LEN;
rem = len % AO_CMAC_KEY_LEN;
if (rem != 0)
- len += (AO_CMAC_KEY_LEN - rem);
+ len += (uint8_t) (AO_CMAC_KEY_LEN - rem);
return len;
}
*/
static int8_t
-radio_cmac_recv(uint8_t len, uint16_t timeout)
+radio_cmac_recv(uint8_t len, AO_TICK_TYPE timeout)
{
uint8_t i;
}
int8_t
-ao_radio_cmac_recv(void *packet, uint8_t len, uint16_t timeout)
+ao_radio_cmac_recv(void *packet, uint8_t len, AO_TICK_TYPE timeout)
{
int8_t i;
if (len > AO_CMAC_MAX_LEN)
#define AO_RADIO_CMAC_TIMEOUT -4
int8_t
-ao_radio_cmac_recv(void *packet, uint8_t len, uint16_t timeout);
+ao_radio_cmac_recv(void *packet, uint8_t len, AO_TICK_TYPE timeout);
void
ao_radio_cmac_init(void);
static void
radio_cmac_send_cmd(void)
{
- uint8_t i;
- uint8_t len;
+ uint32_t i;
+ uint32_t len;
len = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
if (ao_cmd_status != ao_cmd_success)
return;
}
- ao_radio_cmac_send(cmac_data, len);
+ ao_radio_cmac_send(cmac_data, (uint8_t) len);
}
static void
radio_cmac_recv_cmd(void)
{
- uint8_t len, i;
- uint16_t timeout;
+ uint32_t len, l;
+ int8_t i;
+ AO_TICK_TYPE timeout;
len = ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
+ if (len > AO_CMAC_MAX_LEN) {
+ ao_cmd_status = ao_cmd_syntax_error;
+ return;
+ }
timeout = AO_MS_TO_TICKS(ao_cmd_decimal());
if (ao_cmd_status != ao_cmd_success)
return;
- i = ao_radio_cmac_recv(cmac_data, len, timeout);
+ i = ao_radio_cmac_recv(cmac_data, (uint8_t) len, timeout);
if (i == AO_RADIO_CMAC_OK) {
printf ("PACKET ");
- for (i = 0; i < len; i++)
- printf("%02x", cmac_data[i]);
+ for (l = 0; l < len; l++)
+ printf("%02x", cmac_data[l]);
printf (" %d\n", ao_radio_cmac_rssi);
} else
printf ("ERROR %d %d\n", i, ao_radio_cmac_rssi);
}
static void
-ao_report_number(int16_t n)
+ao_report_number(ao_v_t n)
{
uint8_t digits[10];
uint8_t ndigits, i;
n = 0;
ndigits = 0;
do {
- digits[ndigits++] = n % 10;
+ digits[ndigits++] = (uint8_t) (n % 10);
n /= 10;
} while (n);
uint8_t
ao_report_igniter(void)
{
- return (ao_report_igniter_ready(ao_igniter_drogue) |
- (ao_report_igniter_ready(ao_igniter_main) << 1));
+ return (uint8_t) (ao_report_igniter_ready(ao_igniter_drogue) |
+ (ao_report_igniter_ready(ao_igniter_main) << 1));
}
#endif
agl = 0;
ndigits = 0;
do {
- digits[ndigits++] = agl % 10;
+ digits[ndigits++] = (uint8_t) agl % 10;
agl /= 10;
} while (agl);
#include "ao.h"
AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_version = AO_ROMCONFIG_VERSION;
-AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_check = ~AO_ROMCONFIG_VERSION;
+AO_ROMCONFIG_SYMBOL uint16_t ao_romconfig_check = (uint16_t) ~AO_ROMCONFIG_VERSION;
AO_ROMCONFIG_SYMBOL uint16_t ao_serial_number = 0;
#if HAS_RADIO
AO_ROMCONFIG_SYMBOL uint32_t ao_radio_cal = AO_RADIO_CAL_DEFAULT;
#define ACCEL_TYPE int16_t
#endif
-uint16_t ao_sample_tick; /* time of last data */
+AO_TICK_TYPE ao_sample_tick; /* time of last data */
#if HAS_BARO
pres_t ao_sample_pres;
alt_t ao_sample_alt;
ao_sample_set_one_orient(void)
{
ao_sample_orients[ao_sample_orient_pos] = ao_sample_orient;
- ao_sample_orient_pos = (ao_sample_orient_pos + 1) % AO_NUM_ORIENT;
+ ao_sample_orient_pos = (uint8_t) ((ao_sample_orient_pos + 1) % AO_NUM_ORIENT);
}
static void
float rotz;
rotz = ao_rotation.z * ao_rotation.z - ao_rotation.y * ao_rotation.y - ao_rotation.x * ao_rotation.x + ao_rotation.r * ao_rotation.r;
- ao_sample_orient = acosf(rotz) * (float) (180.0/M_PI);
+ ao_sample_orient = (angle_t) (acosf(rotz) * (float) (180.0/M_PI));
}
#endif /* HAS_GYRO */
ao_sample_preflight_set(void)
{
#if HAS_ACCEL
- ao_ground_accel = ao_sample_accel_sum >> 9;
+ ao_ground_accel = (accel_t) (ao_sample_accel_sum >> 9);
ao_sample_accel_sum = 0;
#endif
#if HAS_BARO
ao_sample_pres_sum = 0;
#endif
#if HAS_IMU
- ao_ground_accel_along = ao_sample_accel_along_sum >> 9;
- ao_ground_accel_across = ao_sample_accel_across_sum >> 9;
- ao_ground_accel_through = ao_sample_accel_through_sum >> 9;
+ ao_ground_accel_along = (accel_t) (ao_sample_accel_along_sum >> 9);
+ ao_ground_accel_across = (accel_t) (ao_sample_accel_across_sum >> 9);
+ ao_ground_accel_through = (accel_t) (ao_sample_accel_through_sum >> 9);
ao_sample_accel_along_sum = 0;
ao_sample_accel_across_sum = 0;
ao_sample_accel_through_sum = 0;
#endif
#if HAS_MOTOR_PRESSURE
- ao_ground_motor_pressure = ao_sample_motor_pressure_sum >> 9;
+ ao_ground_motor_pressure = (motor_pressure_t) (ao_sample_motor_pressure_sum >> 9);
ao_sample_motor_pressure_sum = 0;
#endif
#if HAS_GYRO
ao_sample_rotate(void)
{
#ifdef AO_FLIGHT_TEST
- float dt = (int16_t) (ao_sample_tick - ao_sample_prev_tick) / TIME_DIV;
+ float dt = (AO_TICK_SIGNED) (ao_sample_tick - ao_sample_prev_tick) / TIME_DIV;
#else
static const float dt = 1/TIME_DIV;
#endif
#define AO_MS_TO_SPEED(ms) ((ao_v_t) ((ms) * 16))
#define AO_MSS_TO_ACCEL(mss) ((ao_v_t) ((mss) * 16))
-extern uint16_t ao_sample_tick; /* time of last data */
+extern AO_TICK_TYPE ao_sample_tick; /* time of last data */
extern uint8_t ao_sample_adc; /* Ring position of last processed sample */
extern uint8_t ao_sample_data; /* Ring position of last processed sample */
static void
ao_send_packet(void)
{
- uint16_t count;
+ uint32_t count;
uint8_t b;
uint8_t i;
return;
ao_send[i] = b;
}
- ao_radio_send(ao_send, count);
+ ao_radio_send(ao_send, (uint8_t) count);
}
static const struct ao_cmds ao_send_packet_cmds[] = {
_ao_serial0_pollchar(void);
uint8_t
-_ao_serial0_sleep_for(uint16_t timeout);
+_ao_serial0_sleep_for(AO_TICK_TYPE timeout);
void
ao_serial0_putchar(char c);
_ao_serial1_pollchar(void);
uint8_t
-_ao_serial1_sleep_for(uint16_t timeout);
+_ao_serial1_sleep_for(AO_TICK_TYPE timeout);
void
ao_serial1_putchar(char c);
_ao_serial2_pollchar(void);
uint8_t
-_ao_serial2_sleep_for(uint16_t timeout);
+_ao_serial2_sleep_for(AO_TICK_TYPE timeout);
void
ao_serial2_putchar(char c);
_ao_serial3_pollchar(void);
uint8_t
-_ao_serial3_sleep_for(uint16_t timeout);
+_ao_serial3_sleep_for(AO_TICK_TYPE timeout);
void
ao_serial3_putchar(char c);
struct ao_stdio ao_stdios[AO_NUM_STDIOS];
#if AO_NUM_STDIOS > 1
-int8_t ao_cur_stdio;
-int8_t ao_num_stdios;
+uint8_t ao_cur_stdio;
+uint8_t ao_num_stdios;
#else
-int8_t ao_cur_stdio;
+uint8_t ao_cur_stdio;
#define ao_cur_stdio 0
#define ao_num_stdios 0
#endif
ao_getchar(void)
{
int c;
- int8_t stdio;
+ uint8_t stdio;
ao_arch_block_interrupts();
stdio = ao_cur_stdio;
ao_cur_stdio = stdio;
#endif
ao_arch_release_interrupts();
- return c;
+ return (char) c;
}
uint8_t
return ao_stdios[ao_cur_stdio].echo;
}
-int8_t
+uint8_t
ao_add_stdio(int (*_pollchar)(void),
void (*putchar)(char),
void (*_flush)(void))
/* Compute portion of transfer within
* a single block
*/
- this_off = (uint16_t) pos & (ao_storage_unit - 1);
+ this_off = (uint16_t) (pos & (ao_storage_unit - 1));
this_len = ao_storage_unit - this_off;
if (this_len > len)
this_len = len;
/* Compute portion of transfer within
* a single block
*/
- this_off = (uint16_t) pos & (ao_storage_unit - 1);
+ this_off = (uint16_t) (pos & (ao_storage_unit - 1));
this_len = ao_storage_unit - this_off;
if (this_len > len)
this_len = len;
uint32_t this_time = AO_STORAGE_DATA_SIZE;
if (this_time > read_len)
this_time = read_len;
- if (!ao_storage_read(read_pos, storage_data, this_time)) {
+ if (!ao_storage_read(read_pos, storage_data, (uint16_t) this_time)) {
ret = 0;
goto done;
}
struct ao_task {
void *wchan; /* current wait channel (NULL if running) */
AO_TICK_TYPE alarm; /* abort ao_sleep time */
- uint16_t task_id; /* unique id */
+ uint8_t task_id; /* unique id */
/* Saved stack pointer */
union {
uint32_t *sp32;
#define RDF_SPACE
#else
#define RDF_SPACE
-static uint16_t ao_telemetry_time;
+static AO_TICK_TYPE ao_telemetry_time;
#endif
#if HAS_RDF
static RDF_SPACE uint8_t ao_rdf = 0;
-static RDF_SPACE uint16_t ao_rdf_time;
+static RDF_SPACE AO_TICK_TYPE ao_rdf_time;
#endif
#if HAS_APRS
-static uint16_t ao_aprs_time;
+static AO_TICK_TYPE ao_aprs_time;
#include <ao_aprs.h>
#endif
{
struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
- telemetry.generic.tick = packet->tick;
+ telemetry.generic.tick = (uint16_t) packet->tick;
#if AO_LOG_NORMALIZED
#if AO_LOG_FORMAT == AO_LOG_FORMAT_TELEMEGA_5
telemetry.generic.type = AO_TELEMETRY_MEGA_NORM_MPU6000_MMC5983;
#endif
#if HAS_GYRO
- telemetry.mega_norm.orient = ao_sample_orient;
+ telemetry.mega_norm.orient = (uint8_t) ao_sample_orient;
#endif
telemetry.mega_norm.accel = ao_data_accel(packet);
telemetry.mega_norm.pres = ao_data_pres(packet);
#endif
#if HAS_GYRO
- telemetry.mega_sensor.orient = ao_sample_orient;
+ telemetry.mega_sensor.orient = (uint8_t) ao_sample_orient;
#endif
telemetry.mega_sensor.accel = ao_data_accel(packet);
telemetry.mega_sensor.pres = ao_data_pres(packet);
ao_telemetry_send();
}
-static int8_t ao_telemetry_mega_data_max;
-static int8_t ao_telemetry_mega_data_cur;
+static int16_t ao_telemetry_mega_data_max;
+static int16_t ao_telemetry_mega_data_cur;
/* Send mega data packet */
static void
ao_send_mega_data(void)
{
if (--ao_telemetry_mega_data_cur <= 0) {
- struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+ struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
uint8_t i;
- telemetry.generic.tick = packet->tick;
+ telemetry.generic.tick = (uint16_t) packet->tick;
telemetry.generic.type = AO_TELEMETRY_MEGA_DATA;
telemetry.mega_data.state = ao_flight_state;
/* ADC range is 0-4095, so shift by four to save the high 8 bits */
for (i = 0; i < AO_ADC_NUM_SENSE; i++)
- telemetry.mega_data.sense[i] = packet->adc.sense[i] >> 4;
+ telemetry.mega_data.sense[i] = (int8_t) (packet->adc.sense[i] >> 4);
telemetry.mega_data.ground_pres = ao_ground_pres;
telemetry.mega_data.ground_accel = ao_ground_accel;
telemetry.mega_data.accel_plus_g = ao_config.accel_plus_g;
telemetry.mega_data.accel_minus_g = ao_config.accel_minus_g;
- telemetry.mega_data.acceleration = ao_accel;
- telemetry.mega_data.speed = ao_speed;
- telemetry.mega_data.height = ao_height;
+ telemetry.mega_data.acceleration = (int16_t) ao_accel;
+ telemetry.mega_data.speed = (int16_t) ao_speed;
+ telemetry.mega_data.height = (int16_t) ao_height;
ao_telemetry_mega_data_cur = ao_telemetry_mega_data_max;
ao_telemetry_send();
static void
ao_send_metrum_sensor(void)
{
- struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+ struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
- telemetry.generic.tick = packet->tick;
+ telemetry.generic.tick = (uint16_t) packet->tick;
telemetry.generic.type = AO_TELEMETRY_METRUM_SENSOR;
telemetry.metrum_sensor.state = ao_flight_state;
telemetry.metrum_sensor.pres = ao_data_pres(packet);
telemetry.metrum_sensor.temp = ao_data_temp(packet);
- telemetry.metrum_sensor.acceleration = ao_accel;
- telemetry.metrum_sensor.speed = ao_speed;
- telemetry.metrum_sensor.height = ao_height;
+ telemetry.metrum_sensor.acceleration = (int16_t) ao_accel;
+ telemetry.metrum_sensor.speed = (int16_t) ao_speed;
+ telemetry.metrum_sensor.height = (int16_t) ao_height;
telemetry.metrum_sensor.v_batt = packet->adc.v_batt;
telemetry.metrum_sensor.sense_a = packet->adc.sense_a;
ao_telemetry_send();
}
-static int8_t ao_telemetry_metrum_data_max;
-static int8_t ao_telemetry_metrum_data_cur;
+static int16_t ao_telemetry_metrum_data_max;
+static int16_t ao_telemetry_metrum_data_cur;
/* Send telemetrum data packet */
static void
ao_send_metrum_data(void)
{
if (--ao_telemetry_metrum_data_cur <= 0) {
- struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+ struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
- telemetry.generic.tick = packet->tick;
+ telemetry.generic.tick = (uint16_t) packet->tick;
telemetry.generic.type = AO_TELEMETRY_METRUM_DATA;
telemetry.metrum_data.ground_pres = ao_ground_pres;
static void
ao_send_mini(void)
{
- struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
+ struct ao_data *packet = (struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)];
- telemetry.generic.tick = packet->tick;
+ telemetry.generic.tick = (uint16_t) packet->tick;
telemetry.generic.type = AO_SEND_MINI;
telemetry.mini.state = ao_flight_state;
telemetry.mini.pres = ao_data_pres(packet);
telemetry.mini.temp = ao_data_temp(packet);
- telemetry.mini.acceleration = ao_accel;
- telemetry.mini.speed = ao_speed;
- telemetry.mini.height = ao_height;
+ telemetry.mini.acceleration = (int16_t) ao_accel;
+ telemetry.mini.speed = (int16_t) ao_speed;
+ telemetry.mini.height = (int16_t) ao_height;
telemetry.mini.ground_pres = ao_ground_pres;
#endif /* AO_SEND_MINI */
-static int8_t ao_telemetry_config_max;
-static int8_t ao_telemetry_config_cur;
+static int16_t ao_telemetry_config_max;
+static int16_t ao_telemetry_config_cur;
static uint16_t ao_telemetry_flight_number;
#ifndef ao_telemetry_battery_convert
telemetry.configuration.config_minor = AO_CONFIG_MINOR;
#if AO_idProduct_NUMBER == 0x25 && HAS_ADC
/* TeleGPS gets battery voltage instead of apogee delay */
- telemetry.configuration.apogee_delay = ao_telemetry_battery_convert(ao_data_ring[ao_data_ring_prev(ao_data_head)].adc.v_batt);
+ telemetry.configuration.apogee_delay = (uint16_t) ao_telemetry_battery_convert(ao_data_ring[ao_data_ring_prev(ao_data_head)].adc.v_batt);
#else
telemetry.configuration.apogee_delay = ao_config.apogee_delay;
telemetry.configuration.main_deploy = ao_config.main_deploy;
#endif
- telemetry.configuration.flight_log_max = ao_config.flight_log_max >> 10;
+ telemetry.configuration.flight_log_max = (uint16_t) (ao_config.flight_log_max >> 10);
memcpy (telemetry.configuration.callsign,
ao_config.callsign,
AO_MAX_CALLSIGN);
#if HAS_GPS
-static int8_t ao_telemetry_gps_max;
-static int8_t ao_telemetry_loc_cur;
-static int8_t ao_telemetry_sat_cur;
+static int16_t ao_telemetry_gps_max;
+static int16_t ao_telemetry_loc_cur;
+static int16_t ao_telemetry_sat_cur;
static inline void *
telemetry_bits(struct ao_telemetry_location *l)
return ((uint8_t *) l) + offsetof(struct ao_telemetry_location, flags);
}
-static inline int
+static inline size_t
telemetry_size(void)
{
return sizeof(struct ao_telemetry_location) - offsetof(struct ao_telemetry_location, flags);
memcpy(telemetry_bits(&telemetry.location),
telemetry_bits(&ao_gps_data),
telemetry_size());
- telemetry.location.tick = ao_gps_tick;
+ telemetry.location.tick = (uint16_t) ao_gps_tick;
ao_mutex_put(&ao_gps_mutex);
ao_telemetry_loc_cur = ao_telemetry_gps_max;
ao_telemetry_send();
#if HAS_COMPANION
-static int8_t ao_telemetry_companion_max;
-static int8_t ao_telemetry_companion_cur;
+static int16_t ao_telemetry_companion_max;
+static int16_t ao_telemetry_companion_cur;
static void
ao_send_companion(void)
{
if (--ao_telemetry_companion_cur <= 0) {
telemetry.generic.type = AO_TELEMETRY_COMPANION;
- telemetry.companion.board_id = ao_companion_setup.board_id;
+ telemetry.companion.board_id = (uint8_t) ao_companion_setup.board_id;
telemetry.companion.update_period = ao_companion_setup.update_period;
telemetry.companion.channels = ao_companion_setup.channels;
ao_mutex_get(&ao_companion_mutex);
static void
ao_telemetry(void)
{
- uint16_t time;
- int16_t delay;
+ AO_TICK_TYPE time;
+ AO_TICK_SIGNED delay;
ao_config_get();
if (!ao_config.radio_enable)
time = ao_aprs_time;
}
#endif /* HAS_APRS */
- delay = time - ao_time();
+ delay = (AO_TICK_SIGNED) (time - ao_time());
if (delay > 0) {
- ao_sleep_for(&telemetry, delay);
+ ao_sleep_for(&telemetry, (AO_TICK_TYPE) delay);
}
}
}
void
ao_telemetry_set_interval(uint16_t interval)
{
- int8_t cur = 0;
+ int16_t cur = 0;
#if HAS_RADIO_RATE
/* Limit max telemetry rate based on available radio bandwidth.
ao_telemetry_mega_data_cur = cur;
#endif
#if AO_SEND_METRUM
- ao_telemetry_metrum_data_max = AO_SEC_TO_TICKS(1) / interval;
+ ao_telemetry_metrum_data_max = (int16_t) (AO_SEC_TO_TICKS(1) / interval);
if (ao_telemetry_metrum_data_max > cur)
cur++;
ao_telemetry_metrum_data_cur = cur;
#if HAS_COMPANION
if (!ao_companion_setup.update_period)
ao_companion_setup.update_period = AO_SEC_TO_TICKS(1);
- ao_telemetry_companion_max = ao_companion_setup.update_period / interval;
+ ao_telemetry_companion_max = (int16_t) (ao_companion_setup.update_period / interval);
if (ao_telemetry_companion_max > cur)
cur++;
ao_telemetry_companion_cur = cur;
#endif
#if HAS_GPS
- ao_telemetry_gps_max = AO_SEC_TO_TICKS(1) / interval;
+ ao_telemetry_gps_max = (int16_t) (AO_SEC_TO_TICKS(1) / interval);
if (ao_telemetry_gps_max > cur)
cur++;
ao_telemetry_loc_cur = cur;
ao_telemetry_sat_cur = cur;
#endif
- ao_telemetry_config_max = AO_SEC_TO_TICKS(5) / interval;
+ ao_telemetry_config_max = (int16_t) (AO_SEC_TO_TICKS(5) / interval);
if (ao_telemetry_config_max > cur)
cur++;
ao_telemetry_config_cur = cur;
typedef int32_t gps_alt_t;
#define AO_TELEMETRY_LOCATION_ALTITUDE(l) (((gps_alt_t) (l)->altitude_high << 16) | ((l)->altitude_low))
#define AO_TELEMETRY_LOCATION_SET_ALTITUDE(l,a) (((l)->mode |= AO_GPS_MODE_ALTITUDE_24), \
- ((l)->altitude_high = (a) >> 16), \
- ((l)->altitude_low = (a)))
+ ((l)->altitude_high = (int8_t) ((a) >> 16)), \
+ ((l)->altitude_low = (uint16_t) (a)))
#else
typedef int16_t gps_alt_t;
#define AO_TELEMETRY_LOCATION_ALTITUDE(l) ((gps_alt_t) (l)->altitude_low)
static uint8_t log_started;
static struct ao_telemetry_location gps_data;
static uint8_t tracker_running;
-static uint16_t tracker_interval;
+static uint8_t tracker_interval;
static void
ao_tracker(void)
{
uint8_t new;
- int32_t ground_distance;
- int16_t height;
- uint16_t gps_tick;
+ uint32_t ground_distance;
+ gps_alt_t height;
+ AO_TICK_TYPE gps_tick;
uint8_t new_tracker_running;
#if HAS_ADC
height = -height;
if (ao_tracker_force_telem > 1)
- printf("head %d ring %d ground_distance %ld height %d\n", gps_head, ring, (long) ground_distance, height);
- if (ground_distance > ao_config.tracker_motion ||
+ printf("head %d ring %d ground_distance %lu height %ld\n", gps_head, ring, (long) ground_distance, height);
+ if (ground_distance > (uint32_t) ao_config.tracker_motion ||
height > (ao_config.tracker_motion << 1))
{
moving = 1;
static uint8_t erasing_current;
void
-ao_tracker_erase_start(uint16_t flight)
+ao_tracker_erase_start(int32_t flight)
{
- erasing_current = flight == ao_flight_number;
+ erasing_current = flight == (int32_t) ao_flight_number;
if (erasing_current) {
ao_mutex_get(&tracker_mutex);
ao_log_stop();
static void
ao_tracker_set_telem(void)
{
- uint16_t r = ao_cmd_hex();
+ uint32_t r = ao_cmd_hex();
if (ao_cmd_status == ao_cmd_success)
- ao_tracker_force_telem = r;
+ ao_tracker_force_telem = r != 0;
ao_cmd_status = ao_cmd_success;
printf ("flight: %d\n", ao_flight_number);
printf ("force_telem: %d\n", ao_tracker_force_telem);
ao_tracker_init(void);
void
-ao_tracker_erase_start(uint16_t flight);
+ao_tracker_erase_start(int32_t flight);
void
ao_tracker_erase_end(void);
1 << 4,
#endif
#if AO_ADC_5
- 1 << 6,
+ 1 << 5,
#endif
#if AO_ADC_6
1 << 6,
#define sample(id) (*out++ = (uint16_t) lpc_adc.dr[id] >> 1)
static inline void lpc_adc_start(void) {
- lpc_adc.cr = ((ao_adc_mask_seq[ao_adc_sequence] << LPC_ADC_CR_SEL) |
+ lpc_adc.cr = (((uint32_t) ao_adc_mask_seq[ao_adc_sequence] << LPC_ADC_CR_SEL) |
(AO_ADC_CLKDIV << LPC_ADC_CR_CLKDIV) |
(0 << LPC_ADC_CR_BURST) |
(LPC_ADC_CR_CLKS_11 << LPC_ADC_CR_CLKS) |
ao_adc_init(void)
{
lpc_scb.sysahbclkctrl |= (1 << LPC_SCB_SYSAHBCLKCTRL_ADC);
- lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_ADC_PD);
+ lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_ADC_PD);
/* Enable interrupt when channel is complete */
lpc_adc.inten = (1 << LPC_ADC_INTEN_ADGINTEN);
#define ao_spi_put_bit(reg,bit,bus) ao_spi_put_mask(reg,(1<<bit),bus)
#define ao_enable_port(port) (lpc_scb.sysahbclkctrl |= (1 << LPC_SCB_SYSAHBCLKCTRL_GPIO))
-#define ao_disable_port(port) (lpc_scb.sysahbclkctrl &= ~(1 << LPC_SCB_SYSAHBCLKCTRL_GPIO))
+#define ao_disable_port(port) (lpc_scb.sysahbclkctrl &= ~(1UL << LPC_SCB_SYSAHBCLKCTRL_GPIO))
#define lpc_all_bit(port,bit) (((port) << 5) | (bit))
#define ao_enable_input(port,bit,mode) do { \
ao_enable_port(port); \
lpc_set_gpio(port,bit); \
- lpc_gpio.dir[port] &= ~(1 << bit); \
+ lpc_gpio.dir[port] &= ~(1UL << bit); \
ao_gpio_set_mode(port,bit,mode); \
} while (0)
#define ao_enable_analog(port,bit,id) do { \
ao_enable_port(port); \
- lpc_gpio.dir[port] &= ~(1 << bit); \
+ lpc_gpio.dir[port] &= ~(1UL << bit); \
lpc_ioconf.analog_reg(port,bit) = ((analog_func(id) << LPC_IOCONF_FUNC) | \
(0 << LPC_IOCONF_ADMODE)); \
} while (0)
#include "ao.h"
+#define _cat2(a,b) a##b
+#define cat2(a,b) _cat2(a,b)
+#define _cat4(a,b,c,d) a##b##c##d
+#define cat4(a,b,c,d) _cat4(a,b,c,d)
+#define _cat8(a,b,c,d,e,f,g,h) a##b##c##d##e##f##g##h
+#define cat8(a,b,c,d,e,f,g,h) _cat8(a,b,c,d,e,f,g,h)
+
+#ifndef AO_LPC_BEEP_TIMER
+#define AO_LPC_BEEP_TIMER 1
+#define AO_LPC_BEEP_CHANNEL 1
+#define AO_LPC_BEEP_PORT 0
+#define AO_LPC_BEEP_PIN 14
+#endif
+
+#define AO_LPC_CT_BEEP cat2(lpc_ct32b, AO_LPC_BEEP_TIMER)
+#define AO_LPC_CT_BEEP_CLKCTRL cat2(LPC_SCB_SYSAHBCLKCTRL_CT32B, AO_LPC_BEEP_TIMER)
+#define AO_LPC_CT_BEEP_EMR cat2(LPC_CT32B_EMR_EMC, AO_LPC_BEEP_CHANNEL)
+#define AO_LPC_CT_BEEP_MR AO_LPC_BEEP_CHANNEL
+#define AO_LPC_CT_BEEP_PWMC cat2(LPC_CT32B_PWMC_PWMEN, AO_LPC_BEEP_CHANNEL)
+#define AO_LPC_CT_BEEP_IOCONF cat4(pio,AO_LPC_BEEP_PORT,_,AO_LPC_BEEP_PIN)
+#define AO_LPC_CT_BEEP_FUNC cat8(LPC_IOCONF_FUNC_PIO,AO_LPC_BEEP_PORT,_,AO_LPC_BEEP_PIN,_CT32B,AO_LPC_BEEP_TIMER,_MAT,AO_LPC_BEEP_CHANNEL)
+
void
ao_beep(uint8_t beep)
{
if (beep == 0) {
- lpc_ct32b1.tcr = ((0 << LPC_CT32B_TCR_CEN) |
+ AO_LPC_CT_BEEP.tcr = ((0 << LPC_CT32B_TCR_CEN) |
(1 << LPC_CT32B_TCR_CRST));
- lpc_scb.sysahbclkctrl &= ~(1 << LPC_SCB_SYSAHBCLKCTRL_CT32B1);
+ lpc_scb.sysahbclkctrl &= ~(1UL << AO_LPC_CT_BEEP_CLKCTRL);
} else {
- lpc_scb.sysahbclkctrl |= (1 << LPC_SCB_SYSAHBCLKCTRL_CT32B1);
+ lpc_scb.sysahbclkctrl |= (1UL << AO_LPC_CT_BEEP_CLKCTRL);
/* Set prescaler to match cc1111 clocks
*/
- lpc_ct32b1.pr = AO_LPC_SYSCLK / 750000 - 1;
+ AO_LPC_CT_BEEP.pr = AO_LPC_SYSCLK / 750000 - 1;
/* Write the desired data in the match registers */
/* Reset after two time units */
- lpc_ct32b1.mr[0] = beep << 1;
+ AO_LPC_CT_BEEP.mr[0] = beep << 1;
/* PWM width is half of that */
- lpc_ct32b1.mr[1] = beep;
+ AO_LPC_CT_BEEP.mr[AO_LPC_CT_BEEP_MR] = beep;
- /* Flip output 1 on PWM match */
- lpc_ct32b1.emr = (LPC_CT32B_EMR_EMC_TOGGLE << LPC_CT32B_EMR_EMC1);
+ /* Flip output on PWM match */
+ AO_LPC_CT_BEEP.emr = (LPC_CT32B_EMR_EMC_TOGGLE << AO_LPC_CT_BEEP_EMR);
/* Reset on match 0 */
- lpc_ct32b1.mcr = (1 << LPC_CT32B_MCR_MR0R);
+ AO_LPC_CT_BEEP.mcr = (1 << LPC_CT32B_MCR_MR0R);
+
+ /* PWM on match */
+ AO_LPC_CT_BEEP.pwmc = (1 << AO_LPC_CT_BEEP_PWMC);
- /* PWM on match 1 */
- lpc_ct32b1.pwmc = (1 << LPC_CT32B_PWMC_PWMEN1);
-
/* timer mode */
- lpc_ct32b1.ctcr = 0;
+ AO_LPC_CT_BEEP.ctcr = 0;
/* And turn the timer on */
- lpc_ct32b1.tcr = ((1 << LPC_CT32B_TCR_CEN) |
+ AO_LPC_CT_BEEP.tcr = ((1 << LPC_CT32B_TCR_CEN) |
(0 << LPC_CT32B_TCR_CRST));
}
}
* which is on pin pio0_14
*/
- lpc_ioconf.pio0_14 = ((LPC_IOCONF_FUNC_PIO0_14_CT32B1_MAT1 << LPC_IOCONF_FUNC) |
+ lpc_ioconf.AO_LPC_CT_BEEP_IOCONF = ((AO_LPC_CT_BEEP_FUNC << LPC_IOCONF_FUNC) |
(LPC_IOCONF_MODE_INACTIVE << LPC_IOCONF_MODE) |
(0 << LPC_IOCONF_HYS) |
(0 << LPC_IOCONF_INV) |
(1 << LPC_IOCONF_ADMODE) |
(0 << LPC_IOCONF_OD));
- lpc_scb.sysahbclkctrl |= (1 << LPC_SCB_SYSAHBCLKCTRL_CT32B1);
+ lpc_scb.sysahbclkctrl |= (1 << AO_LPC_CT_BEEP_CLKCTRL);
/* Disable the counter and reset the value */
- lpc_ct32b1.tcr = ((0 << LPC_CT32B_TCR_CEN) |
+ AO_LPC_CT_BEEP.tcr = ((0 << LPC_CT32B_TCR_CEN) |
(1 << LPC_CT32B_TCR_CRST));
}
pin_isr(6)
pin_isr(7)
-#define pin_id(port,pin) ((port) * 24 + (pin));
+#define pin_id(port,pin) ((uint8_t) ((port) * 24 + (pin)))
static void
_ao_exti_set_enable(uint8_t pint)
ao_exti_setup (uint8_t port, uint8_t pin, uint8_t mode, void (*callback)(void)) {
uint8_t id = pin_id(port,pin);
uint8_t pint;
- uint32_t mask;
+ uint8_t mask;
uint8_t prio;
for (pint = 0; pint < LPC_NUM_PINT; pint++)
ao_arch_block_interrupts();
mask = (1 << pint);
ao_pint_inuse |= mask;
- ao_pint_enabled &= ~mask;
+ ao_pint_enabled &= (uint8_t) ~mask;
ao_pint_map[id] = pint;
ao_exti_callback[pint] = callback;
/* Set edge triggered */
lpc_gpio_pin.isel &= ~mask;
- ao_pint_enabled &= ~mask;
+ ao_pint_enabled &= (uint8_t) ~mask;
ao_pint_mode[pint] = mode;
_ao_exti_set_enable(pint);
uint8_t mask = 1 << pint;
ao_arch_block_interrupts();
- ao_pint_enabled &= ~mask;
+ ao_pint_enabled &= (uint8_t) ~mask;
_ao_exti_set_enable(pint);
ao_arch_release_interrupts();
}
static uint32_t
ao_lpc_addr_to_sector(uint8_t *addr)
{
- uint32_t off = addr - LPC_FLASH_BASE;
+ uint32_t off = (uint32_t) (addr - LPC_FLASH_BASE);
return off >> LPC_FLASH_SECTOR_SHIFT;
}
static uint8_t
ao_lpc_addr_is_sector_aligned(uint8_t *addr)
{
- uint32_t off = addr - LPC_FLASH_BASE;
+ uint32_t off = (uint32_t) (addr - LPC_FLASH_BASE);
return (off & LPC_FLASH_SECTOR_MASK) == 0;
}
(void) lpc_usart.iir_fcr;
while (lpc_usart.lsr & (1 << LPC_USART_LSR_RDR)) {
- char c = lpc_usart.rbr_thr;
+ char c = (char) lpc_usart.rbr_thr;
if (!ao_fifo_full(ao_usart_rx_fifo))
ao_fifo_insert(ao_usart_rx_fifo, c);
wake_input = 1;
/* DL MSB */
lpc_usart.ier = (ao_usart_speeds[speed].dl >> 8) & 0xff;
- lpc_usart.fdr = ((ao_usart_speeds[speed].divaddval << LPC_USART_FDR_DIVADDVAL) |
- (ao_usart_speeds[speed].mulval << LPC_USART_FDR_MULVAL));
+ lpc_usart.fdr = (((uint32_t) ao_usart_speeds[speed].divaddval << LPC_USART_FDR_DIVADDVAL) |
+ ((uint32_t) ao_usart_speeds[speed].mulval << LPC_USART_FDR_MULVAL));
/* Turn access to divisor latches back off */
- lpc_usart.lcr &= ~(1 << LPC_USART_LCR_DLAB);
+ lpc_usart.lcr &= ~(1UL << LPC_USART_LCR_DLAB);
}
void
while ((lpc_ssp->sr & (1 << LPC_SSP_SR_RNE)) == 0) \
; \
/* receive a byte */ \
- get lpc_ssp->dr; \
+ get (uint8_t) lpc_ssp->dr; \
} \
/* Wait for the SSP to go idle (it already should be) */ \
while (lpc_ssp->sr & (1 << LPC_SSP_SR_BSY)); \
lpc_scb.ssp0clkdiv = 1;
/* Reset the device */
- lpc_scb.presetctrl &= ~(1 << LPC_SCB_PRESETCTRL_SSP0_RST_N);
+ lpc_scb.presetctrl &= ~(1UL << LPC_SCB_PRESETCTRL_SSP0_RST_N);
lpc_scb.presetctrl |= (1 << LPC_SCB_PRESETCTRL_SSP0_RST_N);
ao_spi_channel_init(0);
#endif
lpc_scb.ssp1clkdiv = 1;
/* Reset the device */
- lpc_scb.presetctrl &= ~(1 << LPC_SCB_PRESETCTRL_SSP1_RST_N);
+ lpc_scb.presetctrl &= ~(1UL << LPC_SCB_PRESETCTRL_SSP1_RST_N);
lpc_scb.presetctrl |= (1 << LPC_SCB_PRESETCTRL_SSP1_RST_N);
ao_spi_channel_init(1);
#endif /* HAS_SPI_1 */
* make sure the flash part remains happy
*/
- lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_BOD_PD);
+ lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_BOD_PD);
lpc_scb.bodctrl = ((LPC_SCB_BOD_BODRSTLEV_2_63 << LPC_SCB_BOD_BODRSTLEV) |
(LPC_SCB_BOD_BODINTVAL_RESERVED << LPC_SCB_BOD_BODINTVAL) |
(1 << LPC_SCB_BOD_BODRSTENA));
/* Turn the IRC clock back on */
- lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_IRC_PD);
+ lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_IRC_PD);
ao_clock_delay();
/* Switch to the IRC clock */
/* Set PLL divider values */
lpc_scb.syspllctrl = ((AO_LPC_M << LPC_SCB_SYSPLLCTRL_MSEL) |
- (p << LPC_SCB_SYSPLLCTRL_PSEL));
+ ((uint32_t) p << LPC_SCB_SYSPLLCTRL_PSEL));
/* Turn off the external crystal clock */
lpc_scb.pdruncfg |= (1 << LPC_SCB_PDRUNCFG_SYSOSC_PD);
((AO_LPC_CLKIN > 15000000) << LPC_SCB_SYSOSCCTRL_FREQRANGE));/* set range */
/* Turn on the external crystal clock */
- lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_SYSOSC_PD);
+ lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_SYSOSC_PD);
ao_clock_delay();
/* Select crystal as PLL input */
;
/* Turn on the PLL */
- lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_SYSPLL_PD);
+ lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_SYSPLL_PD);
/* Wait for it to lock */
ao_usb_set_address(uint8_t address)
{
debug("ao_usb_set_address %02x\n", address);
- lpc_usb.devcmdstat = ((address << LPC_USB_DEVCMDSTAT_DEV_ADDR) |
+ lpc_usb.devcmdstat = (((uint32_t) address << LPC_USB_DEVCMDSTAT_DEV_ADDR) |
(1 << LPC_USB_DEVCMDSTAT_DEV_EN) |
(0 << LPC_USB_DEVCMDSTAT_SETUP) |
(0 << LPC_USB_DEVCMDSTAT_PLL_ON) |
static void
ao_usb_set_ep(vuint32_t *ep, uint8_t *addr, uint16_t nbytes)
{
- *ep = ((ao_usb_sram_offset(addr) << LPC_USB_EP_OFFSET) |
- (nbytes << LPC_USB_EP_NBYTES) |
+ *ep = (((uint32_t) ao_usb_sram_offset(addr) << LPC_USB_EP_OFFSET) |
+ ((uint32_t) nbytes << LPC_USB_EP_NBYTES) |
(0 << LPC_USB_EP_ENDPOINT_ISO) |
(0 << LPC_USB_EP_RATE_FEEDBACK) |
(0 << LPC_USB_EP_TOGGLE_RESET) |
(0 << LPC_USB_EP_STALL) |
(0 << LPC_USB_EP_DISABLED) |
- (1 << LPC_USB_EP_ACTIVE));
+ (1UL << LPC_USB_EP_ACTIVE));
}
static inline uint16_t
static void
ao_usb_set_ep0(void)
{
- int e;
+ uint8_t e;
/* Everything is single buffered for now */
lpc_usb.epbufcfg = 0;
if (len > ao_usb_ep0_out_len)
len = ao_usb_ep0_out_len;
- ao_usb_ep0_out_len -= len;
+ ao_usb_ep0_out_len -= (uint8_t) len;
debug_data ("Fill EP0 len %d:", len);
memcpy(ao_usb_ep0_out_data, rx_buffer, len);
ao_usb_ep0_in_max = max;
/* Don't send more than asked for */
if (ao_usb_ep0_in_len > max)
- ao_usb_ep0_in_len = max;
+ ao_usb_ep0_in_len = (uint8_t) max;
ao_usb_ep0_flush();
}
ao_usb_get_descriptor(uint16_t value, uint16_t length)
{
const uint8_t *descriptor;
- uint8_t type = value >> 8;
- uint8_t index = value;
+ uint8_t type = (uint8_t) (value >> 8);
+ uint8_t index = (uint8_t) value;
descriptor = ao_usb_descriptors;
while (descriptor[0] != 0) {
else
len = descriptor[0];
if (len > length)
- len = length;
+ len = (uint8_t) length;
ao_usb_ep0_in_set(descriptor, len);
break;
}
break;
case AO_USB_REQ_SET_ADDRESS:
debug ("set address %d\n", ao_usb_setup.value);
- ao_usb_address = ao_usb_setup.value;
+ ao_usb_address = (uint8_t) ao_usb_setup.value;
ao_usb_address_pending = 1;
break;
case AO_USB_REQ_GET_DESCRIPTOR:
ao_usb_ep0_in_queue_byte(ao_usb_configuration);
break;
case AO_USB_REQ_SET_CONFIGURATION:
- ao_usb_configuration = ao_usb_setup.value;
+ ao_usb_configuration = (uint8_t) ao_usb_setup.value;
debug ("set configuration %d\n", ao_usb_configuration);
ao_usb_set_configuration();
break;
}
/* Check for reset */
- if (intstat & (1 << LPC_USB_INT_DEV)) {
+ if (intstat & (1UL << LPC_USB_INT_DEV)) {
if (lpc_usb.devcmdstat & (1 << LPC_USB_DEVCMDSTAT_DRES_C))
{
lpc_usb.devcmdstat |= (1 << LPC_USB_DEVCMDSTAT_DRES_C);
_rx_dbg0("out_recv top");
ao_usb_out_avail = 0;
- ao_usb_rx_count = AO_USB_OUT_SIZE - ao_usb_epn_out_count(AO_USB_OUT_EP);
+ ao_usb_rx_count = (uint8_t) (AO_USB_OUT_SIZE - ao_usb_epn_out_count(AO_USB_OUT_EP));
_rx_dbg1("out_recv count", ao_usb_rx_count);
debug ("recv %d\n", ao_usb_rx_count);
while ((c = _ao_usb_pollchar()) == AO_READ_AGAIN)
ao_sleep(AO_USB_OUT_SLEEP_ADDR);
ao_arch_release_interrupts();
- return c;
+ return (char) c;
}
void
(1 << LPC_SCB_PDRUNCFG_USBPLL_PD));
/* Disable USB registers and RAM */
- lpc_scb.sysahbclkctrl &= ~((1 << LPC_SCB_SYSAHBCLKCTRL_USB) |
- (1 << LPC_SCB_SYSAHBCLKCTRL_USBRAM));
+ lpc_scb.sysahbclkctrl &= ~((1UL << LPC_SCB_SYSAHBCLKCTRL_USB) |
+ (1UL << LPC_SCB_SYSAHBCLKCTRL_USBRAM));
ao_arch_release_interrupts();
}
(1 << LPC_SCB_SYSAHBCLKCTRL_USBRAM));
/* Enable USB PHY */
- lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_USBPAD_PD);
+ lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_USBPAD_PD);
/* Turn on USB PLL */
- lpc_scb.pdruncfg &= ~(1 << LPC_SCB_PDRUNCFG_USBPLL_PD);
+ lpc_scb.pdruncfg &= ~(1UL << LPC_SCB_PDRUNCFG_USBPLL_PD);
lpc_scb.usbpllclksel = (LPC_SCB_SYSPLLCLKSEL_SEL_SYSOSC << LPC_SCB_SYSPLLCLKSEL_SEL);
lpc_scb.usbpllclkuen = (0 << LPC_SCB_USBPLLCLKUEN_ENA);
debug ("ao_usb_enable\n");
/* Enable interrupts */
- lpc_usb.inten = ((1 << LPC_USB_INT_EPOUT(0)) |
- (1 << LPC_USB_INT_EPIN(0)) |
- (1 << LPC_USB_INT_EPIN(AO_USB_INT_EP)) |
- (1 << LPC_USB_INT_EPOUT(AO_USB_OUT_EP)) |
- (1 << LPC_USB_INT_EPIN(AO_USB_IN_EP)) |
- (1 << LPC_USB_INT_DEV));
+ lpc_usb.inten = ((1UL << LPC_USB_INT_EPOUT(0)) |
+ (1UL << LPC_USB_INT_EPIN(0)) |
+ (1UL << LPC_USB_INT_EPIN(AO_USB_INT_EP)) |
+ (1UL << LPC_USB_INT_EPOUT(AO_USB_OUT_EP)) |
+ (1UL << LPC_USB_INT_EPIN(AO_USB_IN_EP)) |
+ (1UL << LPC_USB_INT_DEV));
ao_arch_release_interrupts();
/* PIO1_31 */
#define LPC_IOCONF_FUNC_PIO1_31 0
-#define LPC_IOCONF_FUNC_MASK 0x7
+#define LPC_IOCONF_FUNC_MASK 0x7UL
#define ao_lpc_alternate(func) (((func) << LPC_IOCONF_FUNC) | \
(LPC_IOCONF_MODE_INACTIVE << LPC_IOCONF_MODE) | \
#define LPC_IOCONF_MODE_PULL_DOWN 1
#define LPC_IOCONF_MODE_PULL_UP 2
#define LPC_IOCONF_MODE_REPEATER 3
-#define LPC_IOCONF_MODE_MASK 3
+#define LPC_IOCONF_MODE_MASK 3UL
#define LPC_IOCONF_HYS 5
#define LPC_SCB_SYSPLLCTRL_PSEL_2 1
#define LPC_SCB_SYSPLLCTRL_PSEL_4 2
#define LPC_SCB_SYSPLLCTRL_PSEL_8 3
-#define LPC_SCB_SYSPLLCTRL_PSEL_MASK 3
+#define LPC_SCB_SYSPLLCTRL_PSEL_MASK 3UL
#define LPC_SCB_SYSPLLSTAT_LOCK 0
#define LPC_SCB_USBPLLCTRL_PSEL_2 1
#define LPC_SCB_USBPLLCTRL_PSEL_4 2
#define LPC_SCB_USBPLLCTRL_PSEL_8 3
-#define LPC_SCB_USBPLLCTRL_PSEL_MASK 3
+#define LPC_SCB_USBPLLCTRL_PSEL_MASK 3UL
#define LPC_SCB_USBPLLSTAT_LOCK 0
#define LPC_SCB_SYSOSCCTRL_FREQRANGE_15_25 1
#define LPC_SCB_WDTOSCCTRL_DIVSEL 0
-#define LPC_SCB_WDTOSCCTRL_DIVSEL_MASK 0x1f
+#define LPC_SCB_WDTOSCCTRL_DIVSEL_MASK 0x1fUL
#define LPC_SCB_WDTOSCCTRL_FREQSEL 5
#define LPC_SCB_WDTOSCCTRL_FREQSEL_0_6 1
#define LPC_SCB_WDTOSCCTRL_FREQSEL_1_05 2
#define LPC_SCB_WDTOSCCTRL_FREQSEL_4_2 0x0d
#define LPC_SCB_WDTOSCCTRL_FREQSEL_4_4 0x0e
#define LPC_SCB_WDTOSCCTRL_FREQSEL_4_6 0x0f
-#define LPC_SCB_WDTOSCCTRL_FREQSEL_MASK 0x0f
+#define LPC_SCB_WDTOSCCTRL_FREQSEL_MASK 0x0fUL
#define LPC_SCB_SYSRSTSTAT_POR 0
#define LPC_SCB_SYSRSTSTAT_EXTRST 1
#define LPC_SCB_SYSPLLCLKSEL_SEL 0
#define LPC_SCB_SYSPLLCLKSEL_SEL_IRC 0
#define LPC_SCB_SYSPLLCLKSEL_SEL_SYSOSC 1
-#define LPC_SCB_SYSPLLCLKSEL_SEL_MASK 3
+#define LPC_SCB_SYSPLLCLKSEL_SEL_MASK 3UL
#define LPC_SCB_SYSPLLCLKUEN_ENA 0
#define LPC_SCB_USBPLLCLKSEL_SEL 0
#define LPC_SCB_USBPLLCLKSEL_SEL_IRC 0
#define LPC_SCB_USBPLLCLKSEL_SEL_SYSOSC 1
-#define LPC_SCB_USBPLLCLKSEL_SEL_MASK 3
+#define LPC_SCB_USBPLLCLKSEL_SEL_MASK 3UL
#define LPC_SCB_USBPLLCLKUEN_ENA 0
#define LPC_SCB_MAINCLKSEL_SEL_PLL_INPUT 1
#define LPC_SCB_MAINCLKSEL_SEL_WATCHDOG 2
#define LPC_SCB_MAINCLKSEL_SEL_PLL_OUTPUT 3
-#define LPC_SCB_MAINCLKSEL_SEL_MASK 3
+#define LPC_SCB_MAINCLKSEL_SEL_MASK 3UL
#define LPC_SCB_MAINCLKUEN_ENA 0
#define LPC_USART_IIR_INTID_CTI 6
#define LPC_USART_IIR_INTID_THRE 1
#define LPC_USART_IIR_INTID_MS 0
-#define LPC_USART_IIR_INTID_MASK 7
+#define LPC_USART_IIR_INTID_MASK 7UL
#define LPC_USART_IIR_FIFOEN 6
#define LPC_USART_IIR_ABEOINT 8
#define LPC_USART_IIR_ABTOINT 9
#define LPC_USART_LCR_WLS_6 1
#define LPC_USART_LCR_WLS_7 2
#define LPC_USART_LCR_WLS_8 3
-#define LPC_USART_LCR_WLS_MASK 3
+#define LPC_USART_LCR_WLS_MASK 3UL
#define LPC_USART_LCR_SBS 2
#define LPC_USART_LCR_SBS_1 0
#define LPC_USART_LCR_SBS_2 1
-#define LPC_USART_LCR_SBS_MASK 1
+#define LPC_USART_LCR_SBS_MASK 1UL
#define LPC_USART_LCR_PE 3
#define LPC_USART_LCR_PS 4
#define LPC_USART_LCR_PS_ODD 0
#define LPC_USART_LCR_PS_EVEN 1
#define LPC_USART_LCR_PS_ONE 2
#define LPC_USART_LCR_PS_ZERO 3
-#define LPC_USART_LCR_PS_MASK 3
+#define LPC_USART_LCR_PS_MASK 3UL
#define LPC_USART_LCR_BC 6
#define LPC_USART_LCR_DLAB 7
#define lpc_usb (*(struct lpc_usb *) 0x40080000)
#define LPC_USB_DEVCMDSTAT_DEV_ADDR 0
-#define LPC_USB_DEVCMDSTAT_DEV_ADDR_MASK 0x7f
+#define LPC_USB_DEVCMDSTAT_DEV_ADDR_MASK 0x7fUL
#define LPC_USB_DEVCMDSTAT_DEV_EN 7
#define LPC_USB_DEVCMDSTAT_SETUP 8
#define LPC_USB_DEVCMDSTAT_PLL_ON 9
#define LPC_USB_DEVCMDSTAT_VBUSDEBOUNCED 28
#define LPC_USB_INFO_FRAME_NR 0
-#define LPC_USB_INFO_FRAME_NR_MASK 0x3ff
+#define LPC_USB_INFO_FRAME_NR_MASK 0x3ffUL
#define LPC_USB_INFO_ERR_CODE 11
#define LPC_USB_INFO_ERR_CODE_NO_ERROR 0
#define LPC_USB_INFO_ERR_CODE_PID_ENCODING_ERROR 1
#define LPC_USB_INFO_ERR_CODE_BITSTUFF_ERROR 0xd
#define LPC_USB_INFO_ERR_CODE_SYNC_ERROR 0xe
#define LPC_USB_INFO_ERR_CODE_WRONG_DATA_TOGGLE 0xf
-#define LPC_USB_INFO_ERR_CODE_MASK 0xf
+#define LPC_USB_INFO_ERR_CODE_MASK 0xfUL
#define LPC_USB_EPLISTSTART_EP_LIST 0
#define LPC_USB_DATABUFSTART_DA_BUF 0
#define LPC_USB_LPM_HIRD_HW 0
-#define LPC_USB_LPM_HIRD_HW_MASK 0xf
+#define LPC_USB_LPM_HIRD_HW_MASK 0xfUL
#define LPC_USB_LPM_HIRD_SW 4
-#define LPC_USB_LPM_HIRD_SW_MASK 0xf
+#define LPC_USB_LPM_HIRD_SW_MASK 0xfUL
#define LPC_USB_LPM_DATA_PENDING 8
#define LPC_USB_EPSKIP_SKIP 0
#define LPC_USB_EP_RATE_FEEDBACK 27
#define LPC_USB_EP_ENDPOINT_ISO 26
#define LPC_USB_EP_NBYTES 16
-#define LPC_USB_EP_NBYTES_MASK 0x3ff
+#define LPC_USB_EP_NBYTES_MASK 0x3ffUL
#define LPC_USB_EP_OFFSET 0
#define LPC_ISR_PIN_INT0_POS 0
#define IRQ_PRIO_REG(irq) ((irq) >> 2)
#define IRQ_PRIO_BIT(irq) (((irq) & 3) << 3)
-#define IRQ_PRIO_MASK(irq) (0xff << IRQ_PRIO_BIT(irq))
+#define IRQ_PRIO_MASK(irq) (0xffUL << IRQ_PRIO_BIT(irq))
static inline void
lpc_nvic_set_priority(int irq, uint8_t prio) {
ao_ms5607_sample(&ao_ms5607_current);
ao_ms5607_convert(&ao_ms5607_current, &value);
- pa = value.pres;
+ pa = (uint32_t) value.pres;
}
static void
ao_compute_height(void)
{
- ground_alt = ao_pa_to_altitude(pa_ground);
- max_alt = ao_pa_to_altitude(pa_min);
+ ground_alt = ao_pa_to_altitude((pres_t) pa_ground);
+ max_alt = ao_pa_to_altitude((pres_t) pa_min);
ao_max_height = max_alt - ground_alt;
}
stm_scb.scr |= ((1 << STM_SCB_SCR_SLEEPDEEP) |
(1 << STM_SCB_SCR_SLEEPONEXIT));
stm_pwr.cr |= (1 << STM_PWR_CR_PDDS);
- stm_pwr.csr &= ~(1 << STM_PWR_CSR_WUF);
+ stm_pwr.csr &= ~(1UL << STM_PWR_CSR_WUF);
ao_arch_wait_interrupt();
}
}
ao_report_altitude();
ao_pips();
log_micro_dump();
-#if BOOST_DELAY
+#ifdef BOOST_DELAY
ao_delay(BOOST_DELAY);
#endif
log_erase();
*/
uint16_t vref = ao_adc_read_vref();
- uint32_t vdda = 3 * stm_vrefint_cal.vrefint_cal * 1000 / vref;
+ uint32_t vdda = 3UL * stm_vrefint_cal.vrefint_cal * 1000 / vref;
/* Power supply > 3.25V means we're on USB power */
if (vdda > 3250) {
for (;;);
}
-void
-ao_put_string(const char *s)
+static void
+ao_put_stringn(const char *s, int max)
{
char c;
- while ((c = *s++)) {
+ while (max--) {
+ c = *s++;
+ if (!c)
+ break;
if (c == '\n')
ao_usb_putchar('\r');
ao_usb_putchar(c);
}
}
+void
+ao_put_string(const char *s)
+{
+ ao_put_stringn(s, 65535);
+}
+
static void
ao_application(void)
{
static uint32_t
ao_get_hex32(void)
{
- int8_t n;
+ int n;
uint32_t v = 0;
for (;;) {
n = n - ('A' - 10);
else
break;
- v = (v << 4) | n;
+ v = (v << 4) | (uint8_t) n;
n = ao_usb_getchar();
}
return v;
ao_put_hex((uint32_t) AO_BOOT_APPLICATION_BASE);
ao_usb_putchar(' ');
ao_put_hex((uint32_t) AO_BOOT_APPLICATION_BOUND);
- ao_put_string("\nsoftware-version "); ao_put_string(ao_version);
+ ao_put_string("\nsoftware-version "); ao_put_stringn(ao_version, AO_MAX_VERSION);
ao_put_string("\n");
}
{
ao_ms5607_sample(&ao_ms5607_current);
ao_ms5607_convert(&ao_ms5607_current, &value);
- pa = value.pres;
+ pa = (uint32_t) value.pres;
}
static void
ao_compute_height(void)
{
- ground_alt = ao_pa_to_altitude(pa_ground);
- max_alt = ao_pa_to_altitude(pa_min);
+ ground_alt = ao_pa_to_altitude((pres_t) pa_ground);
+ max_alt = ao_pa_to_altitude((pres_t) pa_min);
ao_max_height = max_alt - ground_alt;
}
ao_report_altitude();
ao_pips();
ao_log_micro_dump();
-#if BOOST_DELAY
+#ifdef BOOST_DELAY
ao_delay(BOOST_DELAY);
#endif
ao_report_altitude();
for (;;) {
cli();
- set_sleep_mode(SLEEP_MODE_PWR_DOWN);
+#pragma GCC diagnostic ignored "-Wconversion"
+ set_sleep_mode((uint8_t) SLEEP_MODE_PWR_DOWN);
sleep_mode();
}
}
static void
ao_terragps(void)
{
- uint16_t gps_tick = ao_gps_progress;
+ AO_TICK_TYPE gps_tick = ao_gps_progress;
for (;;) {
while (ao_gps_tick == gps_tick)
outbyte(c);
}
-volatile uint16_t tick_count;
+volatile AO_TICK_TYPE tick_count;
void
stm_tim6_isr(void)
#define AO_ADC_RING 32
struct ao_adc {
- uint16_t tick;
+ AO_TICK_TYPE tick;
int16_t idd;
int16_t temp;
int16_t vref;
#define AO_ADC_RING 32
struct ao_adc {
- uint16_t tick;
+ AO_TICK_TYPE tick;
int16_t idd;
int16_t temp;
int16_t vref;
stm_spi->dr = 0xff;
while (!(stm_spi->sr & (1 << STM_SPI_SR_RXNE)))
;
- return stm_spi->dr;
+ return (uint8_t) stm_spi->dr;
}
void
#define ao_disable_port(port) do { \
if ((port) == &stm_gpioa) \
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOAEN); \
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIOAEN); \
else if ((port) == &stm_gpiob) \
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOBEN); \
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIOBEN); \
else if ((port) == &stm_gpioc) \
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOCEN); \
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIOCEN); \
else if ((port) == &stm_gpiod) \
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIODEN); \
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIODEN); \
else if ((port) == &stm_gpioe) \
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_GPIOEEN); \
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_GPIOEEN); \
} while (0)
{
if (beep == 0) {
stm_beeper.cr1 = 0;
- stm_rcc.apb1enr &= ~(1 << RCC_BEEPER);
+ stm_rcc.apb1enr &= ~(1UL << RCC_BEEPER);
} else {
- stm_rcc.apb1enr |= (1 << RCC_BEEPER);
+ stm_rcc.apb1enr |= (1UL << RCC_BEEPER);
stm_beeper.cr2 = ((0 << STM_TIM234_CR2_TI1S) |
(STM_TIM234_CR2_MMS_RESET << STM_TIM234_CR2_MMS) |
stm_afr_set(BEEPER_PORT, BEEPER_PIN, BEEPER_AFR);
/* Leave the timer off until requested */
- stm_rcc.apb1enr &= ~(1 << RCC_BEEPER);
+ stm_rcc.apb1enr &= ~(1UL << RCC_BEEPER);
}
/* Reset the chip to turn off the port and the power interface clock */
ao_gpio_set_mode(&AO_BOOT_APPLICATION_GPIO, AO_BOOT_APPLICATION_PIN, 0);
ao_disable_port(&AO_BOOT_APPLICATION_GPIO);
- stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_PWREN);
+ stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_PWREN);
return v == AO_BOOT_APPLICATION_VALUE;
}
ao_dma_start(uint8_t index)
{
ao_dma_done[index] = 0;
- stm_dma.channel[index].ccr |= (1 << STM_DMA_CCR_EN);
+ stm_dma.channel[index].ccr |= (1UL << STM_DMA_CCR_EN);
}
void
ao_dma_done_transfer(uint8_t index)
{
- stm_dma.channel[index].ccr &= ~(1 << STM_DMA_CCR_EN);
+ stm_dma.channel[index].ccr &= ~(1UL << STM_DMA_CCR_EN);
#ifndef LEAVE_DMA_ON
ao_arch_critical(
if (--ao_dma_active == 0)
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_DMA1EN);
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_DMA1EN);
);
#endif
if (ao_dma_allocated[index])
mask = 0xff << shift;
w = (*addr & ~mask) | (d << shift);
- ao_intflash_write32(pos & ~3, w);
+ ao_intflash_write32(pos & (uint16_t)~3, w);
}
static uint8_t
uint8_t
ao_eeprom_write(ao_pos_t pos32, void *v, uint16_t len)
{
- uint16_t pos = pos32;
+ uint16_t pos = (uint16_t) pos32;
uint8_t *d = v;
if (pos >= ao_eeprom_total || pos + len > ao_eeprom_total)
if ((pos & 3) == 0 && len >= 4) {
uint32_t w;
- w = d[0] | (d[1] << 8) | (d[2] << 16) | (d[3] << 24);
+ w = (uint32_t) d[0] | ((uint32_t) d[1] << 8) | ((uint32_t) d[2] << 16) | ((uint32_t) d[3] << 24);
ao_intflash_write32(pos, w);
pos += 4;
d += 4;
if (pos >= ao_eeprom_total || pos + len > ao_eeprom_total)
return 0;
while (len--)
- *d++ = ao_intflash_read(pos++);
+ *d++ = ao_intflash_read((uint16_t) (pos++));
return 1;
}
}
static void ao_exti_range_isr(uint8_t first, uint8_t last, uint16_t mask) {
- uint16_t pending = (ao_last_exti = stm_exti.pr) & mask;
+ uint16_t pending = (uint16_t) (ao_last_exti = stm_exti.pr) & mask;
uint8_t pin;
static uint16_t last_mask;
static uint8_t last_pin;
if (sr1 & (1 << STM_I2C_SR1_SB))
stm_i2c->dr = ao_i2c_addr[index];
if (sr1 & (1 << STM_I2C_SR1_ADDR)) {
- stm_i2c->cr2 &= ~(1 << STM_I2C_CR2_ITEVTEN);
+ stm_i2c->cr2 &= ~(1UL << STM_I2C_CR2_ITEVTEN);
ao_i2c_state[index] = I2C_RUNNING;
ao_wakeup(&ao_i2c_state[index]);
}
if (sr1 & (1 << STM_I2C_SR1_BTF)) {
- stm_i2c->cr2 &= ~(1 << STM_I2C_CR2_ITEVTEN);
+ stm_i2c->cr2 &= ~(1UL << STM_I2C_CR2_ITEVTEN);
ao_wakeup(&ao_i2c_state[index]);
}
if (sr1 & (1 << STM_I2C_SR1_RXNE)) {
if (ao_i2c_recv_len[index]) {
- *(ao_i2c_recv_data[index]++) = stm_i2c->dr;
+ *(ao_i2c_recv_data[index]++) = (uint8_t) stm_i2c->dr;
if (!--ao_i2c_recv_len[index])
ao_wakeup(&ao_i2c_recv_len[index]);
}
sr1 = stm_i2c->sr1;
if (sr1 & (1 << STM_I2C_SR1_AF)) {
ao_i2c_state[index] = I2C_ERROR;
- stm_i2c->sr1 = sr1 & ~(1 << STM_I2C_SR1_AF);
+ stm_i2c->sr1 = sr1 & ~(1UL << STM_I2C_SR1_AF);
ao_wakeup(&ao_i2c_state[index]);
}
}
&stm_gpioe
};
-static inline int ao_lcd_stm_seg_enabled(int seg) {
+static inline int ao_lcd_stm_seg_enabled(uint32_t seg) {
if (seg < 32)
return (AO_LCD_STM_SEG_ENABLED_0 >> seg) & 1;
else
return (AO_LCD_STM_SEG_ENABLED_1 >> (seg - 32)) & 1;
}
-static inline int ao_lcd_stm_com_enabled(int com) {
+static inline int ao_lcd_stm_com_enabled(uint32_t com) {
return (AO_LCD_STM_COM_ENABLED >> com) & 1;
}
#ifdef AO_SEGMENT_MAP
#if AO_LCD_PER_DIGIT
- n = digit * AO_LCD_SEGMENTS + segment;
+ n = (uint8_t) (digit * AO_LCD_SEGMENTS + segment);
com = ao_lcd_map[n].com;
seg = ao_lcd_map[n].seg;
#else
#endif
n = (seg >> 5) & 1;
if (value)
- stm_lcd.ram[com * 2 + n] |= (1 << (seg & 0x1f));
+ stm_lcd.ram[com * 2 + n] |= (1UL << (seg & 0x1f));
else
- stm_lcd.ram[com * 2 + n] &= ~(1 << (seg & 0x1f));
+ stm_lcd.ram[com * 2 + n] &= ~(1UL << (seg & 0x1f));
}
#if LCD_DEBUG
unsigned int s, c;
uint32_t csr;
- stm_rcc.ahbenr |= ((AO_LCD_STM_USES_GPIOA << STM_RCC_AHBENR_GPIOAEN) |
- (AO_LCD_STM_USES_GPIOB << STM_RCC_AHBENR_GPIOBEN) |
- (AO_LCD_STM_USES_GPIOC << STM_RCC_AHBENR_GPIOCEN) |
- (AO_LCD_STM_USES_GPIOD << STM_RCC_AHBENR_GPIODEN) |
- (AO_LCD_STM_USES_GPIOE << STM_RCC_AHBENR_GPIOEEN));
+ stm_rcc.ahbenr |= (((uint32_t) AO_LCD_STM_USES_GPIOA << STM_RCC_AHBENR_GPIOAEN) |
+ ((uint32_t) AO_LCD_STM_USES_GPIOB << STM_RCC_AHBENR_GPIOBEN) |
+ ((uint32_t) AO_LCD_STM_USES_GPIOC << STM_RCC_AHBENR_GPIOCEN) |
+ ((uint32_t) AO_LCD_STM_USES_GPIOD << STM_RCC_AHBENR_GPIODEN) |
+ ((uint32_t) AO_LCD_STM_USES_GPIOE << STM_RCC_AHBENR_GPIOEEN));
stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_LCDEN);
void
ao_led_set(AO_LED_TYPE colors)
{
- AO_LED_TYPE on = colors & LEDS_AVAILABLE;
- AO_LED_TYPE off = ~colors & LEDS_AVAILABLE;
+ AO_LED_TYPE on = colors & (AO_LED_TYPE) LEDS_AVAILABLE;
+ AO_LED_TYPE off = (AO_LED_TYPE) (~colors & (AO_LED_TYPE) LEDS_AVAILABLE);
ao_led_off(off);
ao_led_on(on);
#ifdef LED_PORT
stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE);
- LED_PORT->odr &= ~LEDS_AVAILABLE;
+ LED_PORT->odr &= ~(uint32_t) LEDS_AVAILABLE;
#else
#ifdef LED_PORT_0
stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE);
uint16_t hi, lo, second_hi;
do {
- hi = stm_tim2.cnt;
- lo = stm_tim4.cnt;
- second_hi = stm_tim2.cnt;
+ hi = (uint16_t) stm_tim2.cnt;
+ lo = (uint16_t) stm_tim4.cnt;
+ second_hi = (uint16_t) stm_tim2.cnt;
} while (hi != second_hi);
return ((uint32_t) hi << 16) | lo;
}
uint8_t ch;
uint16_t val;
- ch = ao_cmd_decimal();
- val = ao_cmd_decimal();
+ ch = (uint8_t) ao_cmd_decimal();
+ val = (uint16_t) ao_cmd_decimal();
if (ao_cmd_status != ao_cmd_success)
return;
{
if (usart->reg->sr & (1 << STM_USART_SR_RXNE)) {
if (!ao_fifo_full(usart->rx_fifo)) {
- ao_fifo_insert(usart->rx_fifo, usart->reg->dr);
+ ao_fifo_insert(usart->rx_fifo, (char) usart->reg->dr);
ao_wakeup(&usart->rx_fifo);
if (is_stdin)
ao_wakeup(&ao_stdin_ready);
}
#endif
} else {
- usart->reg->cr1 &= ~(1 << STM_USART_CR1_RXNEIE);
+ usart->reg->cr1 &= ~(1UL << STM_USART_CR1_RXNEIE);
}
}
}
_ao_usart_rx(usart, is_stdin);
if (!_ao_usart_tx_start(usart))
- usart->reg->cr1 &= ~(1<< STM_USART_CR1_TXEIE);
+ usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TXEIE);
if (usart->reg->sr & (1 << STM_USART_SR_TC)) {
usart->tx_running = 0;
- usart->reg->cr1 &= ~(1 << STM_USART_CR1_TCIE);
+ usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TCIE);
if (usart->draining) {
usart->draining = 0;
ao_wakeup(&usart->tx_fifo);
}
static inline uint8_t
-_ao_usart_sleep_for(struct ao_stm_usart *usart, uint16_t timeout)
+_ao_usart_sleep_for(struct ao_stm_usart *usart, AO_TICK_TYPE timeout)
{
return ao_sleep_for(&usart->rx_fifo, timeout);
}
}
uint8_t
-_ao_serial1_sleep_for(uint16_t timeout)
+_ao_serial1_sleep_for(AO_TICK_TYPE timeout)
{
return _ao_usart_sleep_for(&ao_stm_usart1, timeout);
}
}
uint8_t
-_ao_serial2_sleep_for(uint16_t timeout)
+_ao_serial2_sleep_for(AO_TICK_TYPE timeout)
{
return _ao_usart_sleep_for(&ao_stm_usart2, timeout);
}
}
uint8_t
-_ao_serial3_sleep_for(uint16_t timeout)
+_ao_serial3_sleep_for(AO_TICK_TYPE timeout)
{
return _ao_usart_sleep_for(&ao_stm_usart3, timeout);
}
ao_serial_set_sw_rts_cts(struct ao_stm_usart *usart,
void (*isr)(void),
struct stm_gpio *port_rts,
- int pin_rts,
+ uint8_t pin_rts,
struct stm_gpio *port_cts,
- int pin_cts)
+ uint8_t pin_cts)
{
/* Pull RTS low to note that there's space in the FIFO
*/
#endif
ao_task_check_alarm();
#if AO_DATA_ALL
- if (++ao_data_count == ao_data_interval) {
+ if (++ao_data_count == ao_data_interval && ao_data_interval) {
ao_data_count = 0;
#if HAS_FAKE_FLIGHT
if (ao_fake_flight_active)
stm_systick.csr = ((1 << STM_SYSTICK_CSR_ENABLE) |
(1 << STM_SYSTICK_CSR_TICKINT) |
(STM_SYSTICK_CSR_CLKSOURCE_HCLK_8 << STM_SYSTICK_CSR_CLKSOURCE));
- stm_nvic.shpr15_12 |= AO_STM_NVIC_CLOCK_PRIORITY << 24;
+ stm_nvic.shpr15_12 |= (uint32_t) AO_STM_NVIC_CLOCK_PRIORITY << 24;
}
#endif
while (!(stm_rcc.cr & (1 << STM_RCC_CR_MSIRDY)))
ao_arch_nop();
- stm_rcc.cfgr = (stm_rcc.cfgr & ~(STM_RCC_CFGR_SW_MASK << STM_RCC_CFGR_SW)) |
+ stm_rcc.cfgr = (stm_rcc.cfgr & ~(uint32_t) (STM_RCC_CFGR_SW_MASK << STM_RCC_CFGR_SW)) |
(STM_RCC_CFGR_SW_MSI << STM_RCC_CFGR_SW);
/* wait for system to switch to MSI */
#if AO_HSE_BYPASS
stm_rcc.cr |= (1 << STM_RCC_CR_HSEBYP);
#else
- stm_rcc.cr &= ~(1 << STM_RCC_CR_HSEBYP);
+ stm_rcc.cr &= ~(uint32_t) (1 << STM_RCC_CR_HSEBYP);
#endif
/* Enable HSE clock */
stm_rcc.cr |= (1 << STM_RCC_CR_HSEON);
stm_rcc.cfgr = cfgr;
/* Disable the PLL */
- stm_rcc.cr &= ~(1 << STM_RCC_CR_PLLON);
- while (stm_rcc.cr & (1 << STM_RCC_CR_PLLRDY))
+ stm_rcc.cr &= ~(1UL << STM_RCC_CR_PLLON);
+ while (stm_rcc.cr & (1UL << STM_RCC_CR_PLLRDY))
asm("nop");
/* PLLVCO to 96MHz (for USB) -> PLLMUL = 6, PLLDIV = 4 */
cfgr |= (AO_RCC_CFGR_PLLDIV << STM_RCC_CFGR_PLLDIV);
/* PLL source */
- cfgr &= ~(1 << STM_RCC_CFGR_PLLSRC);
+ cfgr &= ~(1UL << STM_RCC_CFGR_PLLSRC);
cfgr |= STM_RCC_CFGR_PLLSRC_TARGET_CLOCK;
stm_rcc.cfgr = cfgr;
static void
ao_usb_set_ep0(void)
{
- int e;
+ uint8_t e;
ao_usb_sram_addr = 0;
return;
while (bytes >= 2) {
debug_data (" %02x %02x", src[0], src[1]);
- ao_usb_write_short((src[1] << 8) | src[0], base, offset);
+ ao_usb_write_short((uint16_t) ((uint16_t) (src[1] << 8) | (uint16_t) src[0]), base, offset);
offset += 2;
src += 2;
bytes -= 2;
static inline uint16_t
ao_usb_read_short(uint32_t *base, uint16_t offset)
{
- return base[offset>>1];
+ return (uint16_t) (base[offset>>1]);
}
static void
}
while (bytes >= 2) {
uint16_t s = ao_usb_read_short(base, offset);
- dst[0] = s;
- dst[1] = s >> 8;
+ dst[0] = (uint8_t) s;
+ dst[1] = (uint8_t) (s >> 8);
debug_data (" %02x %02x", dst[0], dst[1]);
offset += 2;
dst += 2;
if (len > ao_usb_ep0_out_len)
len = ao_usb_ep0_out_len;
- ao_usb_ep0_out_len -= len;
+ ao_usb_ep0_out_len -= (uint8_t) len;
/* Pull all of the data out of the packet */
debug_data ("Fill EP0 len %d:", len);
{
/* Don't send more than asked for */
if (ao_usb_ep0_in_len > max)
- ao_usb_ep0_in_len = max;
+ ao_usb_ep0_in_len = (uint8_t) max;
ao_usb_ep0_flush();
}
ao_usb_get_descriptor(uint16_t value, uint16_t length)
{
const uint8_t *descriptor;
- uint8_t type = value >> 8;
- uint8_t index = value;
+ uint8_t type = (uint8_t) (value >> 8);
+ uint8_t index = (uint8_t) value;
descriptor = ao_usb_descriptors;
while (descriptor[0] != 0) {
else
len = descriptor[0];
if (len > length)
- len = length;
+ len = (uint8_t) length;
ao_usb_ep0_in_set(descriptor, len);
break;
}
break;
case AO_USB_REQ_SET_ADDRESS:
debug ("set address %d\n", ao_usb_setup.value);
- ao_usb_address = ao_usb_setup.value;
+ ao_usb_address = (uint8_t) ao_usb_setup.value;
ao_usb_address_pending = 1;
break;
case AO_USB_REQ_GET_DESCRIPTOR:
ao_usb_ep0_in_queue_byte(ao_usb_configuration);
break;
case AO_USB_REQ_SET_CONFIGURATION:
- ao_usb_configuration = ao_usb_setup.value;
+ ao_usb_configuration = (uint8_t) ao_usb_setup.value;
debug ("set configuration %d\n", ao_usb_configuration);
ao_usb_set_configuration();
break;
epr_write = epr;
epr_write &= STM_USB_EPR_PRESERVE_MASK;
epr_write |= STM_USB_EPR_INVARIANT;
- epr_write &= ~(1 << STM_USB_EPR_CTR_RX);
- epr_write &= ~(1 << STM_USB_EPR_CTR_TX);
+ epr_write &= ~(1UL << STM_USB_EPR_CTR_RX);
+ epr_write &= ~(1UL << STM_USB_EPR_CTR_TX);
stm_usb.epr[ep] = epr_write;
switch (ep) {
if (istr & (1 << STM_USB_ISTR_RESET)) {
++reset_count;
- stm_usb.istr &= ~(1 << STM_USB_ISTR_RESET);
+ stm_usb.istr &= ~(1UL << STM_USB_ISTR_RESET);
ao_usb_ep0_receive |= AO_USB_EP0_GOT_RESET;
ao_usb_ep0_handle(ao_usb_ep0_receive);
}
stm_usb_fs_wkup_isr(void)
{
/* USB wakeup, just clear the bit for now */
- stm_usb.istr &= ~(1 << STM_USB_ISTR_WKUP);
+ stm_usb.istr &= ~(1UL << STM_USB_ISTR_WKUP);
}
/* Queue the current IN buffer for transmission */
_rx_dbg0("out_recv top");
ao_usb_out_avail = 0;
- ao_usb_rx_count = ao_usb_bdt[AO_USB_OUT_EPR].single.count_rx & STM_USB_BDT_COUNT_RX_COUNT_RX_MASK;
+ ao_usb_rx_count = (uint8_t) (ao_usb_bdt[AO_USB_OUT_EPR].single.count_rx & STM_USB_BDT_COUNT_RX_COUNT_RX_MASK);
_rx_dbg1("out_recv count", ao_usb_rx_count);
debug ("recv %d\n", ao_usb_rx_count);
while ((c = _ao_usb_pollchar()) == AO_READ_AGAIN)
ao_sleep(AO_USB_OUT_SLEEP_ADDR);
ao_arch_release_interrupts();
- return c;
+ return (char) c;
}
#ifndef HAS_USB_DISABLE
stm_usb.istr = 0;
/* Disable USB pull-up */
- stm_syscfg.pmc &= ~(1 << STM_SYSCFG_PMC_USB_PU);
+ stm_syscfg.pmc &= ~(1UL << STM_SYSCFG_PMC_USB_PU);
/* Switch off the device */
stm_usb.cntr = (1 << STM_USB_CNTR_PDWN) | (1 << STM_USB_CNTR_FRES);
/* Disable the interface */
- stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_USBEN);
+ stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_USBEN);
ao_arch_release_interrupts();
}
#endif
stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SYSCFGEN);
/* Disable USB pull-up */
- stm_syscfg.pmc &= ~(1 << STM_SYSCFG_PMC_USB_PU);
+ stm_syscfg.pmc &= ~(1UL << STM_SYSCFG_PMC_USB_PU);
/* Enable USB device */
stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_USBEN);
};
#define STM_MODER_SHIFT(pin) ((pin) << 1)
-#define STM_MODER_MASK 3
+#define STM_MODER_MASK 3UL
#define STM_MODER_INPUT 0
#define STM_MODER_OUTPUT 1
#define STM_MODER_ALTERNATE 2
static inline void
stm_moder_set(struct stm_gpio *gpio, int pin, vuint32_t value) {
gpio->moder = ((gpio->moder &
- ~(STM_MODER_MASK << STM_MODER_SHIFT(pin))) |
+ (uint32_t) ~(STM_MODER_MASK << STM_MODER_SHIFT(pin))) |
value << STM_MODER_SHIFT(pin));
}
}
#define STM_OTYPER_SHIFT(pin) (pin)
-#define STM_OTYPER_MASK 1
+#define STM_OTYPER_MASK 1UL
#define STM_OTYPER_PUSH_PULL 0
#define STM_OTYPER_OPEN_DRAIN 1
static inline void
stm_otyper_set(struct stm_gpio *gpio, int pin, vuint32_t value) {
gpio->otyper = ((gpio->otyper &
- ~(STM_OTYPER_MASK << STM_OTYPER_SHIFT(pin))) |
+ (uint32_t) ~(STM_OTYPER_MASK << STM_OTYPER_SHIFT(pin))) |
value << STM_OTYPER_SHIFT(pin));
}
}
#define STM_OSPEEDR_SHIFT(pin) ((pin) << 1)
-#define STM_OSPEEDR_MASK 3
+#define STM_OSPEEDR_MASK 3UL
#define STM_OSPEEDR_400kHz 0
#define STM_OSPEEDR_2MHz 1
#define STM_OSPEEDR_10MHz 2
static inline void
stm_ospeedr_set(struct stm_gpio *gpio, int pin, uint32_t value) {
gpio->ospeedr = ((gpio->ospeedr &
- ~(STM_OSPEEDR_MASK << STM_OSPEEDR_SHIFT(pin))) |
+ (uint32_t) ~(STM_OSPEEDR_MASK << STM_OSPEEDR_SHIFT(pin))) |
value << STM_OSPEEDR_SHIFT(pin));
}
}
#define STM_PUPDR_SHIFT(pin) ((pin) << 1)
-#define STM_PUPDR_MASK 3
+#define STM_PUPDR_MASK 3UL
#define STM_PUPDR_NONE 0
#define STM_PUPDR_PULL_UP 1
#define STM_PUPDR_PULL_DOWN 2
static inline void
stm_pupdr_set(struct stm_gpio *gpio, int pin, uint32_t value) {
gpio->pupdr = ((gpio->pupdr &
- ~(STM_PUPDR_MASK << STM_PUPDR_SHIFT(pin))) |
+ (uint32_t) ~(STM_PUPDR_MASK << STM_PUPDR_SHIFT(pin))) |
value << STM_PUPDR_SHIFT(pin));
}
}
#define STM_AFR_SHIFT(pin) ((pin) << 2)
-#define STM_AFR_MASK 0xf
+#define STM_AFR_MASK 0xfUL
#define STM_AFR_NONE 0
#define STM_AFR_AF0 0x0
#define STM_AFR_AF1 0x1
stm_moder_set(gpio, pin, STM_MODER_ALTERNATE);
if (pin < 8)
gpio->afrl = ((gpio->afrl &
- ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
+ (uint32_t) ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
value << STM_AFR_SHIFT(pin));
else {
pin -= 8;
gpio->afrh = ((gpio->afrh &
- ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
+ (uint32_t) ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
value << STM_AFR_SHIFT(pin));
}
}
static inline uint16_t
stm_gpio_get_all(struct stm_gpio *gpio) {
- return gpio->idr;
+ return (uint16_t) gpio->idr;
}
/*
#define STM_USART_CR2_LINEN (14) /* LIN mode enable */
#define STM_USART_CR2_STOP (12) /* STOP bits */
-#define STM_USART_CR2_STOP_MASK 3
+#define STM_USART_CR2_STOP_MASK 3UL
#define STM_USART_CR2_STOP_1 0
#define STM_USART_CR2_STOP_0_5 1
#define STM_USART_CR2_STOP_2 2
#define STM_USART_CR2_LBDIE (6) /* LIN break detection interrupt enable */
#define STM_USART_CR2_LBDL (5) /* lin break detection length */
#define STM_USART_CR2_ADD (0)
-#define STM_USART_CR2_ADD_MASK 0xf
+#define STM_USART_CR2_ADD_MASK 0xfUL
#define STM_USART_CR3_ONEBITE (11) /* One sample bit method enable */
#define STM_USART_CR3_CTSIE (10) /* CTS interrupt enable */
#define STM_TIM1011_CR1_CKD_1 0
#define STM_TIM1011_CR1_CKD_2 1
#define STM_TIM1011_CR1_CKD_4 2
-#define STM_TIM1011_CR1_CKD_MASK 3
+#define STM_TIM1011_CR1_CKD_MASK 3UL
#define STM_TIM1011_CR1_ARPE 7
#define STM_TIM1011_CR1_URS 2
#define STM_TIM1011_CR1_UDIS 1
#define STM_TIM1011_SMCR_ETPS_2 1
#define STM_TIM1011_SMCR_ETPS_4 2
#define STM_TIM1011_SMCR_ETPS_8 3
-#define STM_TIM1011_SMCR_ETPS_MASK 3
+#define STM_TIM1011_SMCR_ETPS_MASK 3UL
#define STM_TIM1011_SMCR_ETF 8
#define STM_TIM1011_SMCR_ETF_NONE 0
#define STM_TIM1011_SMCR_ETF_CK_INT_2 1
#define STM_TIM1011_SMCR_ETF_DTS_32_5 13
#define STM_TIM1011_SMCR_ETF_DTS_32_6 14
#define STM_TIM1011_SMCR_ETF_DTS_32_8 15
-#define STM_TIM1011_SMCR_ETF_MASK 15
+#define STM_TIM1011_SMCR_ETF_MASK 15UL
#define STM_TIM1011_DIER_CC1E 1
#define STM_TIM1011_DIER_UIE 0
#define STM_TIM1011_CCMR1_OC1M_FORCE_ACTIVE 5
#define STM_TIM1011_CCMR1_OC1M_PWM_MODE_1 6
#define STM_TIM1011_CCMR1_OC1M_PWM_MODE_2 7
-#define STM_TIM1011_CCMR1_OC1M_MASK 7
+#define STM_TIM1011_CCMR1_OC1M_MASK 7UL
#define STM_TIM1011_CCMR1_OC1PE 3
#define STM_TIM1011_CCMR1_OC1FE 2
#define STM_TIM1011_CCMR1_CC1S 0
#define STM_TIM1011_CCMR1_CC1S_INPUT_TI1 1
#define STM_TIM1011_CCMR1_CC1S_INPUT_TI2 2
#define STM_TIM1011_CCMR1_CC1S_INPUT_TRC 3
-#define STM_TIM1011_CCMR1_CC1S_MASK 3
+#define STM_TIM1011_CCMR1_CC1S_MASK 3UL
#define STM_TIM1011_CCMR1_IC1F_NONE 0
#define STM_TIM1011_CCMR1_IC1F_CK_INT_2 1
#define STM_TIM1011_CCMR1_IC1F_DTS_32_5 13
#define STM_TIM1011_CCMR1_IC1F_DTS_32_6 14
#define STM_TIM1011_CCMR1_IC1F_DTS_32_8 15
-#define STM_TIM1011_CCMR1_IC1F_MASK 15
+#define STM_TIM1011_CCMR1_IC1F_MASK 15UL
#define STM_TIM1011_CCMR1_IC1PSC 2
#define STM_TIM1011_CCMR1_IC1PSC_1 0
#define STM_TIM1011_CCMR1_IC1PSC_2 1
#define STM_TIM1011_CCMR1_IC1PSC_4 2
#define STM_TIM1011_CCMR1_IC1PSC_8 3
-#define STM_TIM1011_CCMR1_IC1PSC_MASK 3
+#define STM_TIM1011_CCMR1_IC1PSC_MASK 3UL
#define STM_TIM1011_CCMR1_CC1S 0
#define STM_TIM1011_CCER_CC1NP 3
#define STM_TIM1011_TI1_RMP_LSI 1
#define STM_TIM1011_TI1_RMP_LSE 2
#define STM_TIM1011_TI1_RMP_RTC 3
-#define STM_TIM1011_TI1_RMP_MASK 3
+#define STM_TIM1011_TI1_RMP_MASK 3UL
/* Flash interface */
#define STM_RCC_CR_RTCPRE_HSE_DIV_4 1
#define STM_RCC_CR_RTCPRE_HSE_DIV_8 2
#define STM_RCC_CR_RTCPRE_HSE_DIV_16 3
-#define STM_RCC_CR_RTCPRE_HSE_MASK 3
+#define STM_RCC_CR_RTCPRE_HSE_MASK 3UL
#define STM_RCC_CR_CSSON (28)
#define STM_RCC_CR_PLLRDY (25)
#define STM_RCC_CFGR_MCOPRE_DIV_4 2
#define STM_RCC_CFGR_MCOPRE_DIV_8 3
#define STM_RCC_CFGR_MCOPRE_DIV_16 4
-#define STM_RCC_CFGR_MCOPRE_MASK 7
+#define STM_RCC_CFGR_MCOPRE_MASK 7UL
#define STM_RCC_CFGR_MCOSEL (24)
#define STM_RCC_CFGR_MCOSEL_DISABLE 0
#define STM_RCC_CFGR_MCOSEL_PLL 5
#define STM_RCC_CFGR_MCOSEL_LSI 6
#define STM_RCC_CFGR_MCOSEL_LSE 7
-#define STM_RCC_CFGR_MCOSEL_MASK 7
+#define STM_RCC_CFGR_MCOSEL_MASK 7UL
#define STM_RCC_CFGR_PLLDIV (22)
#define STM_RCC_CFGR_PLLDIV_2 1
#define STM_RCC_CFGR_PLLDIV_3 2
#define STM_RCC_CFGR_PLLDIV_4 3
-#define STM_RCC_CFGR_PLLDIV_MASK 3
+#define STM_RCC_CFGR_PLLDIV_MASK 3UL
#define STM_RCC_CFGR_PLLMUL (18)
#define STM_RCC_CFGR_PLLMUL_3 0
#define STM_RCC_CFGR_PLLMUL_24 6
#define STM_RCC_CFGR_PLLMUL_32 7
#define STM_RCC_CFGR_PLLMUL_48 8
-#define STM_RCC_CFGR_PLLMUL_MASK 0xf
+#define STM_RCC_CFGR_PLLMUL_MASK 0xfUL
#define STM_RCC_CFGR_PLLSRC (16)
#define STM_RCC_CFGR_PPRE2_DIV_4 5
#define STM_RCC_CFGR_PPRE2_DIV_8 6
#define STM_RCC_CFGR_PPRE2_DIV_16 7
-#define STM_RCC_CFGR_PPRE2_MASK 7
+#define STM_RCC_CFGR_PPRE2_MASK 7UL
#define STM_RCC_CFGR_PPRE1 (8)
#define STM_RCC_CFGR_PPRE1_DIV_1 0
#define STM_RCC_CFGR_PPRE1_DIV_4 5
#define STM_RCC_CFGR_PPRE1_DIV_8 6
#define STM_RCC_CFGR_PPRE1_DIV_16 7
-#define STM_RCC_CFGR_PPRE1_MASK 7
+#define STM_RCC_CFGR_PPRE1_MASK 7UL
#define STM_RCC_CFGR_HPRE (4)
#define STM_RCC_CFGR_HPRE_DIV_1 0
#define STM_RCC_CFGR_HPRE_DIV_128 0xd
#define STM_RCC_CFGR_HPRE_DIV_256 0xe
#define STM_RCC_CFGR_HPRE_DIV_512 0xf
-#define STM_RCC_CFGR_HPRE_MASK 0xf
+#define STM_RCC_CFGR_HPRE_MASK 0xfUL
#define STM_RCC_CFGR_SWS (2)
#define STM_RCC_CFGR_SWS_MSI 0
#define STM_RCC_CFGR_SWS_HSI 1
#define STM_RCC_CFGR_SWS_HSE 2
#define STM_RCC_CFGR_SWS_PLL 3
-#define STM_RCC_CFGR_SWS_MASK 3
+#define STM_RCC_CFGR_SWS_MASK 3UL
#define STM_RCC_CFGR_SW (0)
#define STM_RCC_CFGR_SW_MSI 0
#define STM_RCC_CFGR_SW_HSI 1
#define STM_RCC_CFGR_SW_HSE 2
#define STM_RCC_CFGR_SW_PLL 3
-#define STM_RCC_CFGR_SW_MASK 3
+#define STM_RCC_CFGR_SW_MASK 3UL
#define STM_RCC_AHBENR_DMA1EN (24)
#define STM_RCC_AHBENR_FLITFEN (15)
#define STM_RCC_CSR_RTCSEL_LSE 1
#define STM_RCC_CSR_RTCSEL_LSI 2
#define STM_RCC_CSR_RTCSEL_HSE 3
-#define STM_RCC_CSR_RTCSEL_MASK 3
+#define STM_RCC_CSR_RTCSEL_MASK 3UL
#define STM_RCC_CSR_LSEBYP (10)
#define STM_RCC_CSR_LSERDY (9)
#define STM_PWR_CR_LPRUN (14)
#define STM_PWR_CR_VOS (11)
-#define STM_PWR_CR_VOS_1_8 1
-#define STM_PWR_CR_VOS_1_5 2
-#define STM_PWR_CR_VOS_1_2 3
-#define STM_PWR_CR_VOS_MASK 3
+#define STM_PWR_CR_VOS_1_8 1UL
+#define STM_PWR_CR_VOS_1_5 2UL
+#define STM_PWR_CR_VOS_1_2 3UL
+#define STM_PWR_CR_VOS_MASK 3UL
#define STM_PWR_CR_FWU (10)
#define STM_PWR_CR_ULP (9)
#define STM_PWR_CR_PLS_2_9 5
#define STM_PWR_CR_PLS_3_1 6
#define STM_PWR_CR_PLS_EXT 7
-#define STM_PWR_CR_PLS_MASK 7
+#define STM_PWR_CR_PLS_MASK 7UL
#define STM_PWR_CR_PVDE (4)
#define STM_PWR_CR_CSBF (3)
#define STM_TIM67_CR2_MMS_RESET 0
#define STM_TIM67_CR2_MMS_ENABLE 1
#define STM_TIM67_CR2_MMS_UPDATE 2
-#define STM_TIM67_CR2_MMS_MASK 7
+#define STM_TIM67_CR2_MMS_MASK 7UL
#define STM_TIM67_DIER_UDE (8)
#define STM_TIM67_DIER_UIE (0)
#define STM_LCD_CR_BIAS_1_4 0
#define STM_LCD_CR_BIAS_1_2 1
#define STM_LCD_CR_BIAS_1_3 2
-#define STM_LCD_CR_BIAS_MASK 3
+#define STM_LCD_CR_BIAS_MASK 3UL
#define STM_LCD_CR_DUTY (2)
#define STM_LCD_CR_DUTY_STATIC 0
#define STM_LCD_CR_DUTY_1_3 2
#define STM_LCD_CR_DUTY_1_4 3
#define STM_LCD_CR_DUTY_1_8 4
-#define STM_LCD_CR_DUTY_MASK 7
+#define STM_LCD_CR_DUTY_MASK 7UL
#define STM_LCD_CR_VSEL (1)
#define STM_LCD_CR_LCDEN (0)
#define STM_LCD_FCR_PS_8192 0xd
#define STM_LCD_FCR_PS_16384 0xe
#define STM_LCD_FCR_PS_32768 0xf
-#define STM_LCD_FCR_PS_MASK 0xf
+#define STM_LCD_FCR_PS_MASK 0xfUL
#define STM_LCD_FCR_DIV (18)
#define STM_LCD_FCR_DIV_16 0x0
#define STM_LCD_FCR_DIV_29 0xd
#define STM_LCD_FCR_DIV_30 0xe
#define STM_LCD_FCR_DIV_31 0xf
-#define STM_LCD_FCR_DIV_MASK 0xf
+#define STM_LCD_FCR_DIV_MASK 0xfUL
#define STM_LCD_FCR_BLINK (16)
#define STM_LCD_FCR_BLINK_DISABLE 0
#define STM_LCD_FCR_BLINK_SEG0_COM0 1
#define STM_LCD_FCR_BLINK_SEG0_COMALL 2
#define STM_LCD_FCR_BLINK_SEGALL_COMALL 3
-#define STM_LCD_FCR_BLINK_MASK 3
+#define STM_LCD_FCR_BLINK_MASK 3UL
#define STM_LCD_FCR_BLINKF (13)
#define STM_LCD_FCR_BLINKF_8 0
#define STM_LCD_FCR_BLINKF_256 5
#define STM_LCD_FCR_BLINKF_512 6
#define STM_LCD_FCR_BLINKF_1024 7
-#define STM_LCD_FCR_BLINKF_MASK 7
+#define STM_LCD_FCR_BLINKF_MASK 7UL
#define STM_LCD_FCR_CC (10)
-#define STM_LCD_FCR_CC_MASK 7
+#define STM_LCD_FCR_CC_MASK 7UL
#define STM_LCD_FCR_DEAD (7)
-#define STM_LCD_FCR_DEAD_MASK 7
+#define STM_LCD_FCR_DEAD_MASK 7UL
#define STM_LCD_FCR_PON (4)
-#define STM_LCD_FCR_PON_MASK 7
+#define STM_LCD_FCR_PON_MASK 7UL
#define STM_LCD_FCR_UDDIE (3)
#define STM_LCD_FCR_SOFIE (1)
uint32_t v;
v = stm_nvic.ipr[n];
- v &= ~IRQ_PRIO_MASK(irq);
+ v &= (uint32_t) ~IRQ_PRIO_MASK(irq);
v |= (prio) << IRQ_PRIO_BIT(irq);
stm_nvic.ipr[n] = v;
}
extern struct stm_mpu stm_mpu;
#define STM_MPU_TYPER_IREGION 16
-#define STM_MPU_TYPER_IREGION_MASK 0xff
+#define STM_MPU_TYPER_IREGION_MASK 0xffUL
#define STM_MPU_TYPER_DREGION 8
-#define STM_MPU_TYPER_DREGION_MASK 0xff
+#define STM_MPU_TYPER_DREGION_MASK 0xffUL
#define STM_MPU_TYPER_SEPARATE 0
#define STM_MPU_CR_PRIVDEFENA 2
#define STM_MPU_CR_ENABLE 0
#define STM_MPU_RNR_REGION 0
-#define STM_MPU_RNR_REGION_MASK 0xff
+#define STM_MPU_RNR_REGION_MASK 0xffUL
#define STM_MPU_RBAR_ADDR 5
-#define STM_MPU_RBAR_ADDR_MASK 0x7ffffff
+#define STM_MPU_RBAR_ADDR_MASK 0x7ffffffUL
#define STM_MPU_RBAR_VALID 4
#define STM_MPU_RBAR_REGION 0
-#define STM_MPU_RBAR_REGION_MASK 0xf
+#define STM_MPU_RBAR_REGION_MASK 0xfUL
#define STM_MPU_RASR_XN 28
#define STM_MPU_RASR_AP 24
#define STM_MPU_RASR_AP_RW_RW 3
#define STM_MPU_RASR_AP_RO_NONE 5
#define STM_MPU_RASR_AP_RO_RO 6
-#define STM_MPU_RASR_AP_MASK 7
+#define STM_MPU_RASR_AP_MASK 7UL
#define STM_MPU_RASR_TEX 19
-#define STM_MPU_RASR_TEX_MASK 7
+#define STM_MPU_RASR_TEX_MASK 7UL
#define STM_MPU_RASR_S 18
#define STM_MPU_RASR_C 17
#define STM_MPU_RASR_B 16
#define STM_MPU_RASR_SRD 8
-#define STM_MPU_RASR_SRD_MASK 0xff
+#define STM_MPU_RASR_SRD_MASK 0xffUL
#define STM_MPU_RASR_SIZE 1
-#define STM_MPU_RASR_SIZE_MASK 0x1f
+#define STM_MPU_RASR_SIZE_MASK 0x1fUL
#define STM_MPU_RASR_ENABLE 0
#define isr_decl(name) void stm_ ## name ## _isr(void)
#define STM_SYSCFG_MEMRMP_MEM_MODE_MAIN_FLASH 0
#define STM_SYSCFG_MEMRMP_MEM_MODE_SYSTEM_FLASH 1
#define STM_SYSCFG_MEMRMP_MEM_MODE_SRAM 3
-#define STM_SYSCFG_MEMRMP_MEM_MODE_MASK 3
+#define STM_SYSCFG_MEMRMP_MEM_MODE_MASK 3UL
#define STM_SYSCFG_PMC_USB_PU 0
static inline void
stm_exticr_set(struct stm_gpio *gpio, int pin) {
- uint8_t reg = pin >> 2;
+ uint8_t reg = (uint8_t) (pin >> 2);
uint8_t shift = (pin & 3) << 2;
uint8_t val = 0;
else if (gpio == &stm_gpioe)
val = STM_SYSCFG_EXTICR_PE;
- stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & ~(0xf << shift)) | val << shift;
+ stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & (uint32_t) ~(0xf << shift)) | val << shift;
}
#define STM_DMA_INDEX(channel) ((channel) - 1)
#define STM_DMA_ISR(index) ((index) << 2)
-#define STM_DMA_ISR_MASK 0xf
+#define STM_DMA_ISR_MASK 0xfUL
#define STM_DMA_ISR_TEIF 3
#define STM_DMA_ISR_HTIF 2
#define STM_DMA_ISR_TCIF 1
#define STM_DMA_ISR_GIF 0
#define STM_DMA_IFCR(index) ((index) << 2)
-#define STM_DMA_IFCR_MASK 0xf
+#define STM_DMA_IFCR_MASK 0xfUL
#define STM_DMA_IFCR_CTEIF 3
#define STM_DMA_IFCR_CHTIF 2
#define STM_DMA_IFCR_CTCIF 1
#define STM_SPI_CR1_BR_PCLK_64 5
#define STM_SPI_CR1_BR_PCLK_128 6
#define STM_SPI_CR1_BR_PCLK_256 7
-#define STM_SPI_CR1_BR_MASK 7
+#define STM_SPI_CR1_BR_MASK 7UL
#define STM_SPI_CR1_MSTR 2
#define STM_SPI_CR1_CPOL 1
#define STM_ADC_CR1_RES_10 1
#define STM_ADC_CR1_RES_8 2
#define STM_ADC_CR1_RES_6 3
-#define STM_ADC_CR1_RES_MASK 3
+#define STM_ADC_CR1_RES_MASK 3UL
#define STM_ADC_CR1_AWDEN 23
#define STM_ADC_CR1_JAWDEN 22
#define STM_ADC_CR1_PDI 17
#define STM_ADC_CR1_DISCNUM_6 5
#define STM_ADC_CR1_DISCNUM_7 6
#define STM_ADC_CR1_DISCNUM_8 7
-#define STM_ADC_CR1_DISCNUM_MASK 7
+#define STM_ADC_CR1_DISCNUM_MASK 7UL
#define STM_ADC_CR1_JDISCEN 12
#define STM_ADC_CR1_DISCEN 11
#define STM_ADC_CR1_JAUTO 10
#define STM_ADC_CR1_AWDIE 6
#define STM_ADC_CR1_EOCIE 5
#define STM_ADC_CR1_AWDCH 0
-#define STM_ADC_CR1_AWDCH_MASK 0x1f
+#define STM_ADC_CR1_AWDCH_MASK 0x1fUL
#define STM_ADC_CR2_SWSTART 30
#define STM_ADC_CR2_EXTEN 28
#define STM_ADC_CR2_EXTEN_RISING 1
#define STM_ADC_CR2_EXTEN_FALLING 2
#define STM_ADC_CR2_EXTEN_BOTH 3
-#define STM_ADC_CR2_EXTEN_MASK 3
+#define STM_ADC_CR2_EXTEN_MASK 3UL
#define STM_ADC_CR2_EXTSEL 24
#define STM_ADC_CR2_EXTSEL_TIM9_CC2 0
#define STM_ADC_CR2_EXTSEL_TIM9_TRGO 1
#define STM_ADC_CR2_EXTSEL_TIM4_TRGO 9
#define STM_ADC_CR2_EXTSEL_TIM6_TRGO 10
#define STM_ADC_CR2_EXTSEL_EXTI_11 15
-#define STM_ADC_CR2_EXTSEL_MASK 15
+#define STM_ADC_CR2_EXTSEL_MASK 15UL
#define STM_ADC_CR2_JWSTART 22
#define STM_ADC_CR2_JEXTEN 20
#define STM_ADC_CR2_JEXTEN_DISABLE 0
#define STM_ADC_CR2_JEXTEN_RISING 1
#define STM_ADC_CR2_JEXTEN_FALLING 2
#define STM_ADC_CR2_JEXTEN_BOTH 3
-#define STM_ADC_CR2_JEXTEN_MASK 3
+#define STM_ADC_CR2_JEXTEN_MASK 3UL
#define STM_ADC_CR2_JEXTSEL 16
#define STM_ADC_CR2_JEXTSEL_TIM9_CC1 0
#define STM_ADC_CR2_JEXTSEL_TIM9_TRGO 1
#define STM_ADC_CR2_JEXTSEL_TIM10_CC1 9
#define STM_ADC_CR2_JEXTSEL_TIM7_TRGO 10
#define STM_ADC_CR2_JEXTSEL_EXTI_15 15
-#define STM_ADC_CR2_JEXTSEL_MASK 15
+#define STM_ADC_CR2_JEXTSEL_MASK 15UL
#define STM_ADC_CR2_ALIGN 11
#define STM_ADC_CR2_EOCS 10
#define STM_ADC_CR2_DDS 9
#define STM_ADC_CR2_DELS_63 5
#define STM_ADC_CR2_DELS_127 6
#define STM_ADC_CR2_DELS_255 7
-#define STM_ADC_CR2_DELS_MASK 7
+#define STM_ADC_CR2_DELS_MASK 7UL
#define STM_ADC_CR2_CONT 1
#define STM_ADC_CR2_ADON 0
#define STM_ADC_CCR_ADCPRE_HSI_1 0
#define STM_ADC_CCR_ADCPRE_HSI_2 1
#define STM_ADC_CCR_ADCPRE_HSI_4 2
-#define STM_ADC_CCR_ADCPRE_MASK 3
+#define STM_ADC_CCR_ADCPRE_MASK 3UL
struct stm_temp_cal {
uint16_t vref;
#define STM_I2C_CR2_FREQ_16_MHZ 16
#define STM_I2C_CR2_FREQ_24_MHZ 24
#define STM_I2C_CR2_FREQ_32_MHZ 32
-#define STM_I2C_CR2_FREQ_MASK 0x3f
+#define STM_I2C_CR2_FREQ_MASK 0x3fUL
#define STM_I2C_SR1_SMBALERT 15
#define STM_I2C_SR1_TIMEOUT 14
#define STM_I2C_SR1_SB 0
#define STM_I2C_SR2_PEC 8
-#define STM_I2C_SR2_PEC_MASK 0xff00
+#define STM_I2C_SR2_PEC_MASK 0xff00UL
#define STM_I2C_SR2_DUALF 7
#define STM_I2C_SR2_SMBHOST 6
#define STM_I2C_SR2_SMBDEFAULT 5
#define STM_I2C_CCR_FS 15
#define STM_I2C_CCR_DUTY 14
#define STM_I2C_CCR_CCR 0
-#define STM_I2C_CCR_MASK 0x7ff
+#define STM_I2C_CCR_MASK 0x7ffUL
struct stm_tim234 {
vuint32_t cr1;
#define STM_TIM234_CR1_CKD_1 0
#define STM_TIM234_CR1_CKD_2 1
#define STM_TIM234_CR1_CKD_4 2
-#define STM_TIM234_CR1_CKD_MASK 3
+#define STM_TIM234_CR1_CKD_MASK 3UL
#define STM_TIM234_CR1_ARPE 7
#define STM_TIM234_CR1_CMS 5
#define STM_TIM234_CR1_CMS_EDGE 0
#define STM_TIM234_CR1_CMS_CENTER_1 1
#define STM_TIM234_CR1_CMS_CENTER_2 2
#define STM_TIM234_CR1_CMS_CENTER_3 3
-#define STM_TIM234_CR1_CMS_MASK 3
+#define STM_TIM234_CR1_CMS_MASK 3UL
#define STM_TIM234_CR1_DIR 4
#define STM_TIM234_CR1_DIR_UP 0
#define STM_TIM234_CR1_DIR_DOWN 1
#define STM_TIM234_CR2_MMS_COMPARE_OC2REF 5
#define STM_TIM234_CR2_MMS_COMPARE_OC3REF 6
#define STM_TIM234_CR2_MMS_COMPARE_OC4REF 7
-#define STM_TIM234_CR2_MMS_MASK 7
+#define STM_TIM234_CR2_MMS_MASK 7UL
#define STM_TIM234_CR2_CCDS 3
#define STM_TIM234_SMCR_ETP 15
#define STM_TIM234_SMCR_ETPS_DIV_2 1
#define STM_TIM234_SMCR_ETPS_DIV_4 2
#define STM_TIM234_SMCR_ETPS_DIV_8 3
-#define STM_TIM234_SMCR_ETPS_MASK 3
+#define STM_TIM234_SMCR_ETPS_MASK 3UL
#define STM_TIM234_SMCR_ETF 8
#define STM_TIM234_SMCR_ETF_NONE 0
#define STM_TIM234_SMCR_ETF_INT_N_2 1
#define STM_TIM234_SMCR_ETF_DTS_32_N_5 13
#define STM_TIM234_SMCR_ETF_DTS_32_N_6 14
#define STM_TIM234_SMCR_ETF_DTS_32_N_8 15
-#define STM_TIM234_SMCR_ETF_MASK 15
+#define STM_TIM234_SMCR_ETF_MASK 15UL
#define STM_TIM234_SMCR_MSM 7
#define STM_TIM234_SMCR_TS 4
#define STM_TIM234_SMCR_TS_ITR0 0
#define STM_TIM234_SMCR_TS_TI1FP1 5
#define STM_TIM234_SMCR_TS_TI2FP2 6
#define STM_TIM234_SMCR_TS_ETRF 7
-#define STM_TIM234_SMCR_TS_MASK 7
+#define STM_TIM234_SMCR_TS_MASK 7UL
#define STM_TIM234_SMCR_OCCS 3
#define STM_TIM234_SMCR_SMS 0
#define STM_TIM234_SMCR_SMS_DISABLE 0
#define STM_TIM234_SMCR_SMS_GATED_MODE 5
#define STM_TIM234_SMCR_SMS_TRIGGER_MODE 6
#define STM_TIM234_SMCR_SMS_EXTERNAL_CLOCK 7
-#define STM_TIM234_SMCR_SMS_MASK 7
+#define STM_TIM234_SMCR_SMS_MASK 7UL
#define STM_TIM234_DIER_TDE 14
#define STM_TIM234_DIER_CC4DE 12
#define STM_TIM234_CCMR1_OC2M_FORCE_HIGH 5
#define STM_TIM234_CCMR1_OC2M_PWM_MODE_1 6
#define STM_TIM234_CCMR1_OC2M_PWM_MODE_2 7
-#define STM_TIM234_CCMR1_OC2M_MASK 7
+#define STM_TIM234_CCMR1_OC2M_MASK 7UL
#define STM_TIM234_CCMR1_OC2PE 11
#define STM_TIM234_CCMR1_OC2FE 10
#define STM_TIM234_CCMR1_CC2S 8
#define STM_TIM234_CCMR1_CC2S_INPUT_TI2 1
#define STM_TIM234_CCMR1_CC2S_INPUT_TI1 2
#define STM_TIM234_CCMR1_CC2S_INPUT_TRC 3
-#define STM_TIM234_CCMR1_CC2S_MASK 3
+#define STM_TIM234_CCMR1_CC2S_MASK 3UL
#define STM_TIM234_CCMR1_OC1CE 7
#define STM_TIM234_CCMR1_OC1M 4
#define STM_TIM234_CCMR1_OC1M_FORCE_HIGH 5
#define STM_TIM234_CCMR1_OC1M_PWM_MODE_1 6
#define STM_TIM234_CCMR1_OC1M_PWM_MODE_2 7
-#define STM_TIM234_CCMR1_OC1M_MASK 7
+#define STM_TIM234_CCMR1_OC1M_MASK 7UL
#define STM_TIM234_CCMR1_OC1PE 3
#define STM_TIM234_CCMR1_OC1FE 2
#define STM_TIM234_CCMR1_CC1S 0
#define STM_TIM234_CCMR1_CC1S_INPUT_TI1 1
#define STM_TIM234_CCMR1_CC1S_INPUT_TI2 2
#define STM_TIM234_CCMR1_CC1S_INPUT_TRC 3
-#define STM_TIM234_CCMR1_CC1S_MASK 3
+#define STM_TIM234_CCMR1_CC1S_MASK 3UL
#define STM_TIM234_CCMR1_IC2F 12
#define STM_TIM234_CCMR1_IC2F_NONE 0
#define STM_TIM234_CCMR2_OC4M_FORCE_HIGH 5
#define STM_TIM234_CCMR2_OC4M_PWM_MODE_1 6
#define STM_TIM234_CCMR2_OC4M_PWM_MODE_2 7
-#define STM_TIM234_CCMR2_OC4M_MASK 7
+#define STM_TIM234_CCMR2_OC4M_MASK 7UL
#define STM_TIM234_CCMR2_OC4PE 11
#define STM_TIM234_CCMR2_OC4FE 10
#define STM_TIM234_CCMR2_CC4S 8
#define STM_TIM234_CCMR2_CC4S_INPUT_TI4 1
#define STM_TIM234_CCMR2_CC4S_INPUT_TI3 2
#define STM_TIM234_CCMR2_CC4S_INPUT_TRC 3
-#define STM_TIM234_CCMR2_CC4S_MASK 3
+#define STM_TIM234_CCMR2_CC4S_MASK 3UL
#define STM_TIM234_CCMR2_OC3CE 7
#define STM_TIM234_CCMR2_OC3M 4
#define STM_TIM234_CCMR2_OC3M_FORCE_HIGH 5
#define STM_TIM234_CCMR2_OC3M_PWM_MODE_1 6
#define STM_TIM234_CCMR2_OC3M_PWM_MODE_2 7
-#define STM_TIM234_CCMR2_OC3M_MASK 7
+#define STM_TIM234_CCMR2_OC3M_MASK 7UL
#define STM_TIM234_CCMR2_OC3PE 3
#define STM_TIM234_CCMR2_OC3FE 2
#define STM_TIM234_CCMR2_CC3S 0
#define STM_TIM234_CCMR2_CC3S_INPUT_TI3 1
#define STM_TIM234_CCMR2_CC3S_INPUT_TI4 2
#define STM_TIM234_CCMR2_CC3S_INPUT_TRC 3
-#define STM_TIM234_CCMR2_CC3S_MASK 3
+#define STM_TIM234_CCMR2_CC3S_MASK 3UL
#define STM_TIM234_CCER_CC4NP 15
#define STM_TIM234_CCER_CC4P 13
#define STM_USB_EPR_STAT_RX_STALL 1
#define STM_USB_EPR_STAT_RX_NAK 2
#define STM_USB_EPR_STAT_RX_VALID 3
-#define STM_USB_EPR_STAT_RX_MASK 3
+#define STM_USB_EPR_STAT_RX_MASK 3UL
#define STM_USB_EPR_STAT_RX_WRITE_INVARIANT 0
#define STM_USB_EPR_SETUP 11
#define STM_USB_EPR_EP_TYPE 9
#define STM_USB_EPR_EP_TYPE_CONTROL 1
#define STM_USB_EPR_EP_TYPE_ISO 2
#define STM_USB_EPR_EP_TYPE_INTERRUPT 3
-#define STM_USB_EPR_EP_TYPE_MASK 3
+#define STM_USB_EPR_EP_TYPE_MASK 3UL
#define STM_USB_EPR_EP_KIND 8
#define STM_USB_EPR_EP_KIND_DBL_BUF 1 /* Bulk */
#define STM_USB_EPR_EP_KIND_STATUS_OUT 1 /* Control */
#define STM_USB_EPR_STAT_TX_NAK 2
#define STM_USB_EPR_STAT_TX_VALID 3
#define STM_USB_EPR_STAT_TX_WRITE_INVARIANT 0
-#define STM_USB_EPR_STAT_TX_MASK 3
+#define STM_USB_EPR_STAT_TX_MASK 3UL
#define STM_USB_EPR_EA 0
-#define STM_USB_EPR_EA_MASK 0xf
+#define STM_USB_EPR_EA_MASK 0xfUL
#define STM_USB_CNTR_CTRM 15
#define STM_USB_CNTR_PMAOVRM 14
#define STM_USB_ISTR_ESOF 8
#define STM_USB_ISTR_DIR 4
#define STM_USB_ISTR_EP_ID 0
-#define STM_USB_ISTR_EP_ID_MASK 0xf
+#define STM_USB_ISTR_EP_ID_MASK 0xfUL
#define STM_USB_FNR_RXDP 15
#define STM_USB_FNR_RXDM 14
#define STM_USB_FNR_LCK 13
#define STM_USB_FNR_LSOF 11
-#define STM_USB_FNR_LSOF_MASK 0x3
+#define STM_USB_FNR_LSOF_MASK 0x3UL
#define STM_USB_FNR_FN 0
-#define STM_USB_FNR_FN_MASK 0x7ff
+#define STM_USB_FNR_FN_MASK 0x7ffUL
#define STM_USB_DADDR_EF 7
#define STM_USB_DADDR_ADD 0
-#define STM_USB_DADDR_ADD_MASK 0x7f
+#define STM_USB_DADDR_ADD_MASK 0x7fUL
extern struct stm_usb stm_usb;
#define STM_USB_BDT_COUNT_RX_BL_SIZE 15
#define STM_USB_BDT_COUNT_RX_NUM_BLOCK 10
-#define STM_USB_BDT_COUNT_RX_NUM_BLOCK_MASK 0x1f
+#define STM_USB_BDT_COUNT_RX_NUM_BLOCK_MASK 0x1fUL
#define STM_USB_BDT_COUNT_RX_COUNT_RX 0
-#define STM_USB_BDT_COUNT_RX_COUNT_RX_MASK 0x1ff
+#define STM_USB_BDT_COUNT_RX_COUNT_RX_MASK 0x1ffUL
#define STM_USB_BDT_SIZE 8
#endif
ao_task_check_alarm();
#if AO_DATA_ALL
- if (++ao_data_count == ao_data_interval) {
+ if (++ao_data_count == ao_data_interval && ao_data_interval) {
ao_data_count = 0;
#if HAS_FAKE_FLIGHT
if (ao_fake_flight_active)
(0 << STM_ADC_CCR_VREFEN));
/* Calibrate. This also enables the ADC vreg */
- stm_adc.cr |= (1 << STM_ADC_CR_ADCAL);
- while ((stm_adc.cr & (1 << STM_ADC_CR_ADCAL)) != 0)
+ stm_adc.cr |= (1UL << STM_ADC_CR_ADCAL);
+ while ((stm_adc.cr & (1UL << STM_ADC_CR_ADCAL)) != 0)
;
/* Enable */
stm_adc.isr = (1 << STM_ADC_ISR_ADRDY);
/* Disable ADC vreg */
- stm_adc.cr &= ~(1 << STM_ADC_CR_ADVREGEN);
+ stm_adc.cr &= ~(1UL << STM_ADC_CR_ADVREGEN);
/* Disable ADC clocks */
- stm_rcc.apb2enr &= ~(1 << STM_RCC_APB2ENR_ADCEN);
+ stm_rcc.apb2enr &= ~(1UL << STM_RCC_APB2ENR_ADCEN);
}
uint16_t
;
/* Fetch result */
- value = stm_adc.dr;
+ value = (uint16_t) stm_adc.dr;
ao_adc_shutdown();
return value;
stm_spi->dr = 0xff;
while (!(stm_spi->sr & (1 << STM_SPI_SR_RXNE)))
;
- return stm_spi->dr;
+ return (uint8_t) stm_spi->dr;
}
void
uint32_t ao_last_exti;
static void ao_exti_range_isr(uint8_t first, uint8_t last, uint16_t mask) {
- uint16_t pending = (ao_last_exti = stm_exti.pr) & mask;
+ uint16_t pending = (uint16_t) (ao_last_exti = stm_exti.pr) & mask;
uint8_t pin;
static uint16_t last_mask;
static uint8_t last_pin;
flash_write_select(this_pos);
/* Update write buffer with new contents */
- int this_word = 4 - (pos & 3);
+ uint16_t this_word = 4 - (pos & 3);
if (this_word > len)
this_word = len;
memcpy(&write_buf.u8[pos & 3], b8, this_word);
}
#endif
} else {
- lpuart->reg->cr1 &= ~(1 << STM_LPUART_CR1_RXNEIE);
+ lpuart->reg->cr1 &= ~(1UL << STM_LPUART_CR1_RXNEIE);
}
}
}
_ao_lpuart_rx(lpuart, is_stdin);
if (!_ao_lpuart_tx_start(lpuart))
- lpuart->reg->cr1 &= ~(1<< STM_LPUART_CR1_TXEIE);
+ lpuart->reg->cr1 &= ~(1UL << STM_LPUART_CR1_TXEIE);
if (lpuart->reg->isr & (1 << STM_LPUART_ISR_TC)) {
lpuart->tx_running = 0;
- lpuart->reg->cr1 &= ~(1 << STM_LPUART_CR1_TCIE);
+ lpuart->reg->cr1 &= ~(1UL << STM_LPUART_CR1_TCIE);
if (lpuart->draining) {
lpuart->draining = 0;
ao_wakeup(&lpuart->tx_fifo);
# endif
/* Disable LPUART */
- stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_LPUART1EN);
+ stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_LPUART1EN);
}
}
#endif
} else {
- usart->reg->cr1 &= ~(1 << STM_USART_CR1_RXNEIE);
+ usart->reg->cr1 &= ~(1UL << STM_USART_CR1_RXNEIE);
}
}
}
_ao_usart_rx(usart, is_stdin);
if (!_ao_usart_tx_start(usart))
- usart->reg->cr1 &= ~(1<< STM_USART_CR1_TXEIE);
+ usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TXEIE);
if (usart->reg->isr & (1 << STM_USART_ISR_TC)) {
usart->tx_running = 0;
- usart->reg->cr1 &= ~(1 << STM_USART_CR1_TCIE);
+ usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TCIE);
if (usart->draining) {
usart->draining = 0;
ao_wakeup(&usart->tx_fifo);
while ((stm_spi->sr & (1 << STM_SPI_SR_TXE)) == 0);
stm_spi->dr = 0xff;
while ((stm_spi->sr & (1 << STM_SPI_SR_RXNE)) == 0);
- *bytes++ = stm_spi->dr;
+ *bytes++ = (uint8_t) stm_spi->dr;
}
#endif
}
++ao_tick_count;
ao_task_check_alarm();
#if AO_DATA_ALL
- if (++ao_data_count == ao_data_interval) {
+ if (++ao_data_count == ao_data_interval && ao_data_interval) {
ao_data_count = 0;
#if HAS_ADC
#if HAS_FAKE_FLIGHT
};
#define STM_MODER_SHIFT(pin) ((pin) << 1)
-#define STM_MODER_MASK 3
+#define STM_MODER_MASK 3UL
#define STM_MODER_INPUT 0
#define STM_MODER_OUTPUT 1
#define STM_MODER_ALTERNATE 2
static inline void
stm_moder_set(struct stm_gpio *gpio, int pin, vuint32_t value) {
- gpio->moder = ((gpio->moder &
- ~(STM_MODER_MASK << STM_MODER_SHIFT(pin))) |
- value << STM_MODER_SHIFT(pin));
+ gpio->moder = (((uint32_t) gpio->moder &
+ (uint32_t) ~(STM_MODER_MASK << STM_MODER_SHIFT(pin))) |
+ (value << STM_MODER_SHIFT(pin)));
}
static inline uint32_t
}
#define STM_OTYPER_SHIFT(pin) (pin)
-#define STM_OTYPER_MASK 1
+#define STM_OTYPER_MASK 1UL
#define STM_OTYPER_PUSH_PULL 0
#define STM_OTYPER_OPEN_DRAIN 1
static inline void
stm_otyper_set(struct stm_gpio *gpio, int pin, vuint32_t value) {
gpio->otyper = ((gpio->otyper &
- ~(STM_OTYPER_MASK << STM_OTYPER_SHIFT(pin))) |
- value << STM_OTYPER_SHIFT(pin));
+ (uint32_t) ~(STM_OTYPER_MASK << STM_OTYPER_SHIFT(pin))) |
+ (value << STM_OTYPER_SHIFT(pin)));
}
static inline uint32_t
}
#define STM_OSPEEDR_SHIFT(pin) ((pin) << 1)
-#define STM_OSPEEDR_MASK 3
+#define STM_OSPEEDR_MASK 3UL
#define STM_OSPEEDR_LOW 0
#define STM_OSPEEDR_MEDIUM 1
#define STM_OSPEEDR_HIGH 2
static inline void
stm_ospeedr_set(struct stm_gpio *gpio, int pin, uint32_t value) {
gpio->ospeedr = ((gpio->ospeedr &
- ~(STM_OSPEEDR_MASK << STM_OSPEEDR_SHIFT(pin))) |
- value << STM_OSPEEDR_SHIFT(pin));
+ (uint32_t) ~(STM_OSPEEDR_MASK << STM_OSPEEDR_SHIFT(pin))) |
+ (value << STM_OSPEEDR_SHIFT(pin)));
}
static inline void
}
#define STM_PUPDR_SHIFT(pin) ((pin) << 1)
-#define STM_PUPDR_MASK 3
+#define STM_PUPDR_MASK 3UL
#define STM_PUPDR_NONE 0
#define STM_PUPDR_PULL_UP 1
#define STM_PUPDR_PULL_DOWN 2
static inline void
stm_pupdr_set(struct stm_gpio *gpio, int pin, uint32_t value) {
gpio->pupdr = ((gpio->pupdr &
- ~(STM_PUPDR_MASK << STM_PUPDR_SHIFT(pin))) |
- value << STM_PUPDR_SHIFT(pin));
+ (uint32_t) ~(STM_PUPDR_MASK << STM_PUPDR_SHIFT(pin))) |
+ (value << STM_PUPDR_SHIFT(pin)));
}
static inline void
}
#define STM_AFR_SHIFT(pin) ((pin) << 2)
-#define STM_AFR_MASK 0xf
+#define STM_AFR_MASK 0xfUL
#define STM_AFR_AF0 0x0
#define STM_AFR_AF1 0x1
#define STM_AFR_AF2 0x2
stm_moder_set(gpio, pin, STM_MODER_ALTERNATE);
if (pin < 8)
gpio->afrl = ((gpio->afrl &
- ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
- value << STM_AFR_SHIFT(pin));
+ (uint32_t) ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
+ (value << STM_AFR_SHIFT(pin)));
else {
pin -= 8;
gpio->afrh = ((gpio->afrh &
- ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
- value << STM_AFR_SHIFT(pin));
+ (uint32_t) ~(STM_AFR_MASK << STM_AFR_SHIFT(pin))) |
+ (value << STM_AFR_SHIFT(pin)));
}
}
static inline uint16_t
stm_gpio_get_all(struct stm_gpio *gpio) {
- return gpio->idr;
+ return (uint16_t) gpio->idr;
}
/*
#define STM_TIM1011_CR1_CKD_1 0
#define STM_TIM1011_CR1_CKD_2 1
#define STM_TIM1011_CR1_CKD_4 2
-#define STM_TIM1011_CR1_CKD_MASK 3
+#define STM_TIM1011_CR1_CKD_MASK 3UL
#define STM_TIM1011_CR1_ARPE 7
#define STM_TIM1011_CR1_URS 2
#define STM_TIM1011_CR1_UDIS 1
#define STM_TIM1011_SMCR_ETPS_2 1
#define STM_TIM1011_SMCR_ETPS_4 2
#define STM_TIM1011_SMCR_ETPS_8 3
-#define STM_TIM1011_SMCR_ETPS_MASK 3
+#define STM_TIM1011_SMCR_ETPS_MASK 3UL
#define STM_TIM1011_SMCR_ETF 8
#define STM_TIM1011_SMCR_ETF_NONE 0
#define STM_TIM1011_SMCR_ETF_CK_INT_2 1
#define STM_TIM1011_SMCR_ETF_DTS_32_5 13
#define STM_TIM1011_SMCR_ETF_DTS_32_6 14
#define STM_TIM1011_SMCR_ETF_DTS_32_8 15
-#define STM_TIM1011_SMCR_ETF_MASK 15
+#define STM_TIM1011_SMCR_ETF_MASK 15UL
#define STM_TIM1011_DIER_CC1E 1
#define STM_TIM1011_DIER_UIE 0
#define STM_TIM1011_CCMR1_OC1M_FORCE_ACTIVE 5
#define STM_TIM1011_CCMR1_OC1M_PWM_MODE_1 6
#define STM_TIM1011_CCMR1_OC1M_PWM_MODE_2 7
-#define STM_TIM1011_CCMR1_OC1M_MASK 7
+#define STM_TIM1011_CCMR1_OC1M_MASK 7UL
#define STM_TIM1011_CCMR1_OC1PE 3
#define STM_TIM1011_CCMR1_OC1FE 2
#define STM_TIM1011_CCMR1_CC1S 0
#define STM_TIM1011_CCMR1_CC1S_INPUT_TI1 1
#define STM_TIM1011_CCMR1_CC1S_INPUT_TI2 2
#define STM_TIM1011_CCMR1_CC1S_INPUT_TRC 3
-#define STM_TIM1011_CCMR1_CC1S_MASK 3
+#define STM_TIM1011_CCMR1_CC1S_MASK 3UL
#define STM_TIM1011_CCMR1_IC1F_NONE 0
#define STM_TIM1011_CCMR1_IC1F_CK_INT_2 1
#define STM_TIM1011_CCMR1_IC1F_DTS_32_5 13
#define STM_TIM1011_CCMR1_IC1F_DTS_32_6 14
#define STM_TIM1011_CCMR1_IC1F_DTS_32_8 15
-#define STM_TIM1011_CCMR1_IC1F_MASK 15
+#define STM_TIM1011_CCMR1_IC1F_MASK 15UL
#define STM_TIM1011_CCMR1_IC1PSC 2
#define STM_TIM1011_CCMR1_IC1PSC_1 0
#define STM_TIM1011_CCMR1_IC1PSC_2 1
#define STM_TIM1011_CCMR1_IC1PSC_4 2
#define STM_TIM1011_CCMR1_IC1PSC_8 3
-#define STM_TIM1011_CCMR1_IC1PSC_MASK 3
+#define STM_TIM1011_CCMR1_IC1PSC_MASK 3UL
#define STM_TIM1011_CCMR1_CC1S 0
#define STM_TIM1011_CCER_CC1NP 3
#define STM_TIM1011_TI1_RMP_LSI 1
#define STM_TIM1011_TI1_RMP_LSE 2
#define STM_TIM1011_TI1_RMP_RTC 3
-#define STM_TIM1011_TI1_RMP_MASK 3
+#define STM_TIM1011_TI1_RMP_MASK 3UL
struct stm_rcc {
vuint32_t cr;
#define STM_RCC_CR_RTCPRE_HSE_DIV_4 1
#define STM_RCC_CR_RTCPRE_HSE_DIV_8 2
#define STM_RCC_CR_RTCPRE_HSE_DIV_16 3
-#define STM_RCC_CR_RTCPRE_HSE_MASK 3
+#define STM_RCC_CR_RTCPRE_HSE_MASK 3UL
#define STM_RCC_CR_CSSON (28)
#define STM_RCC_CR_PLLRDY (25)
#define STM_RCC_ICSCR_MSIRANGE_1048576 4
#define STM_RCC_ICSCR_MSIRANGE_2097152 5
#define STM_RCC_ICSCR_MSIRANGE_4194304 6
-#define STM_RCC_ICSCR_MSIRANGE_MASK 0x7
+#define STM_RCC_ICSCR_MSIRANGE_MASK 0x7UL
#define STM_RCC_ICSCR_MSICAL 16
#define STM_RCC_ICSCR_MSITRIM 24
#define STM_RCC_CFGR_MCOPRE_DIV_4 2
#define STM_RCC_CFGR_MCOPRE_DIV_8 3
#define STM_RCC_CFGR_MCOPRE_DIV_16 4
-#define STM_RCC_CFGR_MCOPRE_MASK 7
+#define STM_RCC_CFGR_MCOPRE_MASK 7UL
#define STM_RCC_CFGR_MCOSEL (24)
#define STM_RCC_CFGR_MCOSEL_DISABLE 0
#define STM_RCC_CFGR_MCOSEL_PLL 5
#define STM_RCC_CFGR_MCOSEL_LSI 6
#define STM_RCC_CFGR_MCOSEL_LSE 7
-#define STM_RCC_CFGR_MCOSEL_MASK 7
+#define STM_RCC_CFGR_MCOSEL_MASK 7UL
#define STM_RCC_CFGR_PLLDIV (22)
#define STM_RCC_CFGR_PLLDIV_2 1
#define STM_RCC_CFGR_PLLDIV_3 2
#define STM_RCC_CFGR_PLLDIV_4 3
-#define STM_RCC_CFGR_PLLDIV_MASK 3
+#define STM_RCC_CFGR_PLLDIV_MASK 3UL
#define STM_RCC_CFGR_PLLMUL (18)
#define STM_RCC_CFGR_PLLMUL_3 0
#define STM_RCC_CFGR_PLLMUL_24 6
#define STM_RCC_CFGR_PLLMUL_32 7
#define STM_RCC_CFGR_PLLMUL_48 8
-#define STM_RCC_CFGR_PLLMUL_MASK 0xf
+#define STM_RCC_CFGR_PLLMUL_MASK 0xfUL
#define STM_RCC_CFGR_PLLSRC (16)
#define STM_RCC_CFGR_PPRE2_DIV_4 5
#define STM_RCC_CFGR_PPRE2_DIV_8 6
#define STM_RCC_CFGR_PPRE2_DIV_16 7
-#define STM_RCC_CFGR_PPRE2_MASK 7
+#define STM_RCC_CFGR_PPRE2_MASK 7UL
#define STM_RCC_CFGR_PPRE1 (8)
#define STM_RCC_CFGR_PPRE1_DIV_1 0
#define STM_RCC_CFGR_PPRE1_DIV_4 5
#define STM_RCC_CFGR_PPRE1_DIV_8 6
#define STM_RCC_CFGR_PPRE1_DIV_16 7
-#define STM_RCC_CFGR_PPRE1_MASK 7
+#define STM_RCC_CFGR_PPRE1_MASK 7UL
#define STM_RCC_CFGR_HPRE (4)
#define STM_RCC_CFGR_HPRE_DIV_1 0
#define STM_RCC_CFGR_HPRE_DIV_128 0xd
#define STM_RCC_CFGR_HPRE_DIV_256 0xe
#define STM_RCC_CFGR_HPRE_DIV_512 0xf
-#define STM_RCC_CFGR_HPRE_MASK 0xf
+#define STM_RCC_CFGR_HPRE_MASK 0xfUL
#define STM_RCC_CFGR_SWS (2)
#define STM_RCC_CFGR_SWS_MSI 0
#define STM_RCC_CFGR_SWS_HSI 1
#define STM_RCC_CFGR_SWS_HSE 2
#define STM_RCC_CFGR_SWS_PLL 3
-#define STM_RCC_CFGR_SWS_MASK 3
+#define STM_RCC_CFGR_SWS_MASK 3UL
#define STM_RCC_CFGR_SW (0)
#define STM_RCC_CFGR_SW_MSI 0
#define STM_RCC_CFGR_SW_HSI 1
#define STM_RCC_CFGR_SW_HSE 2
#define STM_RCC_CFGR_SW_PLL 3
-#define STM_RCC_CFGR_SW_MASK 3
+#define STM_RCC_CFGR_SW_MASK 3UL
#define STM_RCC_IOPENR_IOPAEN 0
#define STM_RCC_IOPENR_IOPBEN 1
#define STM_RCC_CSR_RTCSEL_LSE 1
#define STM_RCC_CSR_RTCSEL_LSI 2
#define STM_RCC_CSR_RTCSEL_HSE 3
-#define STM_RCC_CSR_RTCSEL_MASK 3
+#define STM_RCC_CSR_RTCSEL_MASK 3UL
#define STM_RCC_CSR_LSEBYP (10)
#define STM_RCC_CSR_LSERDY (9)
#define STM_PWR_CR_VOS_1_8 1
#define STM_PWR_CR_VOS_1_5 2
#define STM_PWR_CR_VOS_1_2 3
-#define STM_PWR_CR_VOS_MASK 3
+#define STM_PWR_CR_VOS_MASK 3UL
#define STM_PWR_CR_FWU 10
#define STM_PWR_CR_ULP 9
#define STM_PWR_CR_DBP 8
#define STM_PWR_CR_PLS_2_9 5
#define STM_PWR_CR_PLS_3_1 6
#define STM_PWR_CR_PLS_EXT 7
-#define STM_PWR_CR_PLS_MASK 7
+#define STM_PWR_CR_PLS_MASK 7UL
#define STM_PWR_CR_PVDE 4
#define STM_PWR_CR_CSBF 3
#define STM_PWR_CR_CWUF 2
#define STM_TIM67_CR2_MMS_RESET 0
#define STM_TIM67_CR2_MMS_ENABLE 1
#define STM_TIM67_CR2_MMS_UPDATE 2
-#define STM_TIM67_CR2_MMS_MASK 7
+#define STM_TIM67_CR2_MMS_MASK 7UL
#define STM_TIM67_DIER_UDE (8)
#define STM_TIM67_DIER_UIE (0)
#define STM_LCD_CR_BIAS_1_4 0
#define STM_LCD_CR_BIAS_1_2 1
#define STM_LCD_CR_BIAS_1_3 2
-#define STM_LCD_CR_BIAS_MASK 3
+#define STM_LCD_CR_BIAS_MASK 3UL
#define STM_LCD_CR_DUTY (2)
#define STM_LCD_CR_DUTY_STATIC 0
#define STM_LCD_CR_DUTY_1_3 2
#define STM_LCD_CR_DUTY_1_4 3
#define STM_LCD_CR_DUTY_1_8 4
-#define STM_LCD_CR_DUTY_MASK 7
+#define STM_LCD_CR_DUTY_MASK 7UL
#define STM_LCD_CR_VSEL (1)
#define STM_LCD_CR_LCDEN (0)
#define STM_LCD_FCR_PS_8192 0xd
#define STM_LCD_FCR_PS_16384 0xe
#define STM_LCD_FCR_PS_32768 0xf
-#define STM_LCD_FCR_PS_MASK 0xf
+#define STM_LCD_FCR_PS_MASK 0xfUL
#define STM_LCD_FCR_DIV (18)
#define STM_LCD_FCR_DIV_16 0x0
#define STM_LCD_FCR_DIV_29 0xd
#define STM_LCD_FCR_DIV_30 0xe
#define STM_LCD_FCR_DIV_31 0xf
-#define STM_LCD_FCR_DIV_MASK 0xf
+#define STM_LCD_FCR_DIV_MASK 0xfUL
#define STM_LCD_FCR_BLINK (16)
#define STM_LCD_FCR_BLINK_DISABLE 0
#define STM_LCD_FCR_BLINK_SEG0_COM0 1
#define STM_LCD_FCR_BLINK_SEG0_COMALL 2
#define STM_LCD_FCR_BLINK_SEGALL_COMALL 3
-#define STM_LCD_FCR_BLINK_MASK 3
+#define STM_LCD_FCR_BLINK_MASK 3UL
#define STM_LCD_FCR_BLINKF (13)
#define STM_LCD_FCR_BLINKF_8 0
#define STM_LCD_FCR_BLINKF_256 5
#define STM_LCD_FCR_BLINKF_512 6
#define STM_LCD_FCR_BLINKF_1024 7
-#define STM_LCD_FCR_BLINKF_MASK 7
+#define STM_LCD_FCR_BLINKF_MASK 7UL
#define STM_LCD_FCR_CC (10)
-#define STM_LCD_FCR_CC_MASK 7
+#define STM_LCD_FCR_CC_MASK 7UL
#define STM_LCD_FCR_DEAD (7)
-#define STM_LCD_FCR_DEAD_MASK 7
+#define STM_LCD_FCR_DEAD_MASK 7UL
#define STM_LCD_FCR_PON (4)
-#define STM_LCD_FCR_PON_MASK 7
+#define STM_LCD_FCR_PON_MASK 7UL
#define STM_LCD_FCR_UDDIE (3)
#define STM_LCD_FCR_SOFIE (1)
uint32_t v;
v = stm_nvic.ipr[n];
- v &= ~IRQ_PRIO_MASK(irq);
+ v &= (uint32_t) ~IRQ_PRIO_MASK(irq);
v |= (prio) << IRQ_PRIO_BIT(irq);
stm_nvic.ipr[n] = v;
}
extern struct stm_mpu stm_mpu;
#define STM_MPU_TYPER_IREGION 16
-#define STM_MPU_TYPER_IREGION_MASK 0xff
+#define STM_MPU_TYPER_IREGION_MASK 0xffUL
#define STM_MPU_TYPER_DREGION 8
-#define STM_MPU_TYPER_DREGION_MASK 0xff
+#define STM_MPU_TYPER_DREGION_MASK 0xffUL
#define STM_MPU_TYPER_SEPARATE 0
#define STM_MPU_CR_PRIVDEFENA 2
#define STM_MPU_CR_ENABLE 0
#define STM_MPU_RNR_REGION 0
-#define STM_MPU_RNR_REGION_MASK 0xff
+#define STM_MPU_RNR_REGION_MASK 0xffUL
#define STM_MPU_RBAR_ADDR 5
-#define STM_MPU_RBAR_ADDR_MASK 0x7ffffff
+#define STM_MPU_RBAR_ADDR_MASK 0x7ffffffUL
#define STM_MPU_RBAR_VALID 4
#define STM_MPU_RBAR_REGION 0
-#define STM_MPU_RBAR_REGION_MASK 0xf
+#define STM_MPU_RBAR_REGION_MASK 0xfUL
#define STM_MPU_RASR_XN 28
#define STM_MPU_RASR_AP 24
#define STM_MPU_RASR_AP_RW_RW 3
#define STM_MPU_RASR_AP_RO_NONE 5
#define STM_MPU_RASR_AP_RO_RO 6
-#define STM_MPU_RASR_AP_MASK 7
+#define STM_MPU_RASR_AP_MASK 7UL
#define STM_MPU_RASR_TEX 19
-#define STM_MPU_RASR_TEX_MASK 7
+#define STM_MPU_RASR_TEX_MASK 7UL
#define STM_MPU_RASR_S 18
#define STM_MPU_RASR_C 17
#define STM_MPU_RASR_B 16
#define STM_MPU_RASR_SRD 8
-#define STM_MPU_RASR_SRD_MASK 0xff
+#define STM_MPU_RASR_SRD_MASK 0xffUL
#define STM_MPU_RASR_SIZE 1
-#define STM_MPU_RASR_SIZE_MASK 0x1f
+#define STM_MPU_RASR_SIZE_MASK 0x1fUL
#define STM_MPU_RASR_ENABLE 0
#define isr_decl(name) void stm_ ## name ## _isr(void)
#define STM_SYSCFG_MEMRMP_MEM_MODE_MAIN_FLASH 0
#define STM_SYSCFG_MEMRMP_MEM_MODE_SYSTEM_FLASH 1
#define STM_SYSCFG_MEMRMP_MEM_MODE_SRAM 3
-#define STM_SYSCFG_MEMRMP_MEM_MODE_MASK 3
+#define STM_SYSCFG_MEMRMP_MEM_MODE_MASK 3UL
#define STM_SYSCFG_PMC_USB_PU 0
#define STM_SYSCFG_EXTICR_PH 5
static inline void
-stm_exticr_set(struct stm_gpio *gpio, int pin) {
+stm_exticr_set(struct stm_gpio *gpio, uint8_t pin) {
uint8_t reg = pin >> 2;
uint8_t shift = (pin & 3) << 2;
uint8_t val = 0;
else if (gpio == &stm_gpioe)
val = STM_SYSCFG_EXTICR_PE;
- stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & ~(0xf << shift)) | val << shift;
+ stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & ~(0xfUL << shift)) | val << shift;
}
struct stm_dma_channel {
#define STM_DMA_INDEX(channel) ((channel) - 1)
#define STM_DMA_ISR(index) ((index) << 2)
-#define STM_DMA_ISR_MASK 0xf
+#define STM_DMA_ISR_MASK 0xfUL
#define STM_DMA_ISR_TEIF 3
#define STM_DMA_ISR_HTIF 2
#define STM_DMA_ISR_TCIF 1
#define STM_DMA_ISR_GIF 0
#define STM_DMA_IFCR(index) ((index) << 2)
-#define STM_DMA_IFCR_MASK 0xf
+#define STM_DMA_IFCR_MASK 0xfUL
#define STM_DMA_IFCR_CTEIF 3
#define STM_DMA_IFCR_CHTIF 2
#define STM_DMA_IFCR_CTCIF 1
#define STM_SPI_CR1_BR_PCLK_64 5
#define STM_SPI_CR1_BR_PCLK_128 6
#define STM_SPI_CR1_BR_PCLK_256 7
-#define STM_SPI_CR1_BR_MASK 7
+#define STM_SPI_CR1_BR_MASK 7UL
#define STM_SPI_CR1_MSTR 2
#define STM_SPI_CR1_CPOL 1
#define STM_ADC_CFGR1_EXTEN_RISING 1
#define STM_ADC_CFGR1_EXTEN_FALLING 2
#define STM_ADC_CFGR1_EXTEN_BOTH 3
-#define STM_ADC_CFGR1_EXTEN_MASK 3
+#define STM_ADC_CFGR1_EXTEN_MASK 3UL
#define STM_ADC_CFGR1_EXTSEL 6
#define STM_ADC_CFGR1_ALIGN 5
#define STM_ADC_CFGR1_RES_10 1
#define STM_ADC_CFGR1_RES_8 2
#define STM_ADC_CFGR1_RES_6 3
-#define STM_ADC_CFGR1_RES_MASK 3
+#define STM_ADC_CFGR1_RES_MASK 3UL
#define STM_ADC_CFGR1_SCANDIR 2
#define STM_ADC_CFGR1_SCANDIR_UP 0
#define STM_ADC_CFGR1_SCANDIR_DOWN 1
#define STM_I2C_CR2_FREQ_16_MHZ 16
#define STM_I2C_CR2_FREQ_24_MHZ 24
#define STM_I2C_CR2_FREQ_32_MHZ 32
-#define STM_I2C_CR2_FREQ_MASK 0x3f
+#define STM_I2C_CR2_FREQ_MASK 0x3fUL
#define STM_I2C_SR1_SMBALERT 15
#define STM_I2C_SR1_TIMEOUT 14
#define STM_I2C_SR1_SB 0
#define STM_I2C_SR2_PEC 8
-#define STM_I2C_SR2_PEC_MASK 0xff00
+#define STM_I2C_SR2_PEC_MASK 0xff00UL
#define STM_I2C_SR2_DUALF 7
#define STM_I2C_SR2_SMBHOST 6
#define STM_I2C_SR2_SMBDEFAULT 5
#define STM_I2C_CCR_FS 15
#define STM_I2C_CCR_DUTY 14
#define STM_I2C_CCR_CCR 0
-#define STM_I2C_CCR_MASK 0x7ff
+#define STM_I2C_CCR_MASK 0x7ffUL
struct stm_tim234 {
vuint32_t cr1;
#define STM_TIM234_CR1_CKD_1 0
#define STM_TIM234_CR1_CKD_2 1
#define STM_TIM234_CR1_CKD_4 2
-#define STM_TIM234_CR1_CKD_MASK 3
+#define STM_TIM234_CR1_CKD_MASK 3UL
#define STM_TIM234_CR1_ARPE 7
#define STM_TIM234_CR1_CMS 5
#define STM_TIM234_CR1_CMS_EDGE 0
#define STM_TIM234_CR1_CMS_CENTER_1 1
#define STM_TIM234_CR1_CMS_CENTER_2 2
#define STM_TIM234_CR1_CMS_CENTER_3 3
-#define STM_TIM234_CR1_CMS_MASK 3
+#define STM_TIM234_CR1_CMS_MASK 3UL
#define STM_TIM234_CR1_DIR 4
#define STM_TIM234_CR1_DIR_UP 0
#define STM_TIM234_CR1_DIR_DOWN 1
#define STM_TIM234_CR2_MMS_COMPARE_OC2REF 5
#define STM_TIM234_CR2_MMS_COMPARE_OC3REF 6
#define STM_TIM234_CR2_MMS_COMPARE_OC4REF 7
-#define STM_TIM234_CR2_MMS_MASK 7
+#define STM_TIM234_CR2_MMS_MASK 7UL
#define STM_TIM234_CR2_CCDS 3
#define STM_TIM234_SMCR_ETP 15
#define STM_TIM234_SMCR_ETPS_DIV_2 1
#define STM_TIM234_SMCR_ETPS_DIV_4 2
#define STM_TIM234_SMCR_ETPS_DIV_8 3
-#define STM_TIM234_SMCR_ETPS_MASK 3
+#define STM_TIM234_SMCR_ETPS_MASK 3UL
#define STM_TIM234_SMCR_ETF 8
#define STM_TIM234_SMCR_ETF_NONE 0
#define STM_TIM234_SMCR_ETF_INT_N_2 1
#define STM_TIM234_SMCR_ETF_DTS_32_N_5 13
#define STM_TIM234_SMCR_ETF_DTS_32_N_6 14
#define STM_TIM234_SMCR_ETF_DTS_32_N_8 15
-#define STM_TIM234_SMCR_ETF_MASK 15
+#define STM_TIM234_SMCR_ETF_MASK 15UL
#define STM_TIM234_SMCR_MSM 7
#define STM_TIM234_SMCR_TS 4
#define STM_TIM234_SMCR_TS_ITR0 0
#define STM_TIM234_SMCR_TS_TI1FP1 5
#define STM_TIM234_SMCR_TS_TI2FP2 6
#define STM_TIM234_SMCR_TS_ETRF 7
-#define STM_TIM234_SMCR_TS_MASK 7
+#define STM_TIM234_SMCR_TS_MASK 7UL
#define STM_TIM234_SMCR_OCCS 3
#define STM_TIM234_SMCR_SMS 0
#define STM_TIM234_SMCR_SMS_DISABLE 0
#define STM_TIM234_SMCR_SMS_GATED_MODE 5
#define STM_TIM234_SMCR_SMS_TRIGGER_MODE 6
#define STM_TIM234_SMCR_SMS_EXTERNAL_CLOCK 7
-#define STM_TIM234_SMCR_SMS_MASK 7
+#define STM_TIM234_SMCR_SMS_MASK 7UL
#define STM_TIM234_DIER_TDE 14
#define STM_TIM234_DIER_CC4DE 12
#define STM_TIM234_CCMR1_OC2M_FORCE_HIGH 5
#define STM_TIM234_CCMR1_OC2M_PWM_MODE_1 6
#define STM_TIM234_CCMR1_OC2M_PWM_MODE_2 7
-#define STM_TIM234_CCMR1_OC2M_MASK 7
+#define STM_TIM234_CCMR1_OC2M_MASK 7UL
#define STM_TIM234_CCMR1_OC2PE 11
#define STM_TIM234_CCMR1_OC2FE 10
#define STM_TIM234_CCMR1_CC2S 8
#define STM_TIM234_CCMR1_CC2S_INPUT_TI2 1
#define STM_TIM234_CCMR1_CC2S_INPUT_TI1 2
#define STM_TIM234_CCMR1_CC2S_INPUT_TRC 3
-#define STM_TIM234_CCMR1_CC2S_MASK 3
+#define STM_TIM234_CCMR1_CC2S_MASK 3UL
#define STM_TIM234_CCMR1_OC1CE 7
#define STM_TIM234_CCMR1_OC1M 4
#define STM_TIM234_CCMR1_OC1M_FORCE_HIGH 5
#define STM_TIM234_CCMR1_OC1M_PWM_MODE_1 6
#define STM_TIM234_CCMR1_OC1M_PWM_MODE_2 7
-#define STM_TIM234_CCMR1_OC1M_MASK 7
+#define STM_TIM234_CCMR1_OC1M_MASK 7UL
#define STM_TIM234_CCMR1_OC1PE 3
#define STM_TIM234_CCMR1_OC1FE 2
#define STM_TIM234_CCMR1_CC1S 0
#define STM_TIM234_CCMR1_CC1S_INPUT_TI1 1
#define STM_TIM234_CCMR1_CC1S_INPUT_TI2 2
#define STM_TIM234_CCMR1_CC1S_INPUT_TRC 3
-#define STM_TIM234_CCMR1_CC1S_MASK 3
+#define STM_TIM234_CCMR1_CC1S_MASK 3UL
#define STM_TIM234_CCMR1_IC2F 12
#define STM_TIM234_CCMR1_IC2F_NONE 0
#define STM_TIM234_CCMR2_OC4M_FORCE_HIGH 5
#define STM_TIM234_CCMR2_OC4M_PWM_MODE_1 6
#define STM_TIM234_CCMR2_OC4M_PWM_MODE_2 7
-#define STM_TIM234_CCMR2_OC4M_MASK 7
+#define STM_TIM234_CCMR2_OC4M_MASK 7UL
#define STM_TIM234_CCMR2_OC4PE 11
#define STM_TIM234_CCMR2_OC4FE 10
#define STM_TIM234_CCMR2_CC4S 8
#define STM_TIM234_CCMR2_CC4S_INPUT_TI4 1
#define STM_TIM234_CCMR2_CC4S_INPUT_TI3 2
#define STM_TIM234_CCMR2_CC4S_INPUT_TRC 3
-#define STM_TIM234_CCMR2_CC4S_MASK 3
+#define STM_TIM234_CCMR2_CC4S_MASK 3UL
#define STM_TIM234_CCMR2_OC3CE 7
#define STM_TIM234_CCMR2_OC3M 4
#define STM_TIM234_CCMR2_OC3M_FORCE_HIGH 5
#define STM_TIM234_CCMR2_OC3M_PWM_MODE_1 6
#define STM_TIM234_CCMR2_OC3M_PWM_MODE_2 7
-#define STM_TIM234_CCMR2_OC3M_MASK 7
+#define STM_TIM234_CCMR2_OC3M_MASK 7UL
#define STM_TIM234_CCMR2_OC3PE 3
#define STM_TIM234_CCMR2_OC3FE 2
#define STM_TIM234_CCMR2_CC3S 0
#define STM_TIM234_CCMR2_CC3S_INPUT_TI3 1
#define STM_TIM234_CCMR2_CC3S_INPUT_TI4 2
#define STM_TIM234_CCMR2_CC3S_INPUT_TRC 3
-#define STM_TIM234_CCMR2_CC3S_MASK 3
+#define STM_TIM234_CCMR2_CC3S_MASK 3UL
#define STM_TIM234_CCER_CC4NP 15
#define STM_TIM234_CCER_CC4P 13
/* Reset ADC */
stm_rcc.apb2rstr |= (1 << STM_RCC_APB2RSTR_ADCRST);
- stm_rcc.apb2rstr &= ~(1 << STM_RCC_APB2RSTR_ADCRST);
+ stm_rcc.apb2rstr &= ~(1UL << STM_RCC_APB2RSTR_ADCRST);
/* Turn on ADC pins */
stm_rcc.ahbenr |= AO_ADC_RCC_AHBENR;
stm_adc.smpr = STM_ADC_SMPR_SMP_1_5 << STM_ADC_SMPR_SMP;
/* Turn off enable and start */
- stm_adc.cr &= ~((1 << STM_ADC_CR_ADEN) | (1 << STM_ADC_CR_ADSTART));
+ stm_adc.cr &= ~((1UL << STM_ADC_CR_ADEN) | (1 << STM_ADC_CR_ADSTART));
/* Calibrate */
- stm_adc.cr |= (1 << STM_ADC_CR_ADCAL);
- while ((stm_adc.cr & (1 << STM_ADC_CR_ADCAL)) != 0)
+ stm_adc.cr |= (1UL << STM_ADC_CR_ADCAL);
+ while ((stm_adc.cr & (1UL << STM_ADC_CR_ADCAL)) != 0)
;
/* Enable */
stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SYSCFGCOMPEN);
/* Set ADC to use DMA channel 1 (option 1) */
- stm_syscfg.cfgr1 &= ~(1 << STM_SYSCFG_CFGR1_ADC_DMA_RMP);
+ stm_syscfg.cfgr1 &= ~(1UL << STM_SYSCFG_CFGR1_ADC_DMA_RMP);
ao_dma_alloc(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC_1));
}
/* Reset ADC */
stm_rcc.apb2rstr |= (1 << STM_RCC_APB2RSTR_ADCRST);
- stm_rcc.apb2rstr &= ~(1 << STM_RCC_APB2RSTR_ADCRST);
+ stm_rcc.apb2rstr &= ~(1UL << STM_RCC_APB2RSTR_ADCRST);
/* Turn on ADC pins */
stm_rcc.ahbenr |= AO_ADC_RCC_AHBENR;
#endif
/* Wait for ADC to be idle */
- while (stm_adc.cr & ((1 << STM_ADC_CR_ADCAL) |
- (1 << STM_ADC_CR_ADDIS)))
+ while (stm_adc.cr & ((1UL << STM_ADC_CR_ADCAL) |
+ (1UL << STM_ADC_CR_ADDIS)))
;
/* Disable */
}
/* Turn off everything */
- stm_adc.cr &= ~((1 << STM_ADC_CR_ADCAL) |
- (1 << STM_ADC_CR_ADSTP) |
- (1 << STM_ADC_CR_ADSTART) |
- (1 << STM_ADC_CR_ADEN));
+ stm_adc.cr &= ~((1UL << STM_ADC_CR_ADCAL) |
+ (1UL << STM_ADC_CR_ADSTP) |
+ (1UL << STM_ADC_CR_ADSTART) |
+ (1UL << STM_ADC_CR_ADEN));
/* Configure */
stm_adc.cfgr1 = ((0 << STM_ADC_CFGR1_AWDCH) | /* analog watchdog channel 0 */
(0 << STM_ADC_CCR_VREFEN));
/* Calibrate */
- stm_adc.cr |= (1 << STM_ADC_CR_ADCAL);
- while ((stm_adc.cr & (1 << STM_ADC_CR_ADCAL)) != 0)
+ stm_adc.cr |= (1UL << STM_ADC_CR_ADCAL);
+ while ((stm_adc.cr & (1UL << STM_ADC_CR_ADCAL)) != 0)
;
/* Enable */
stm_rcc.apb2enr |= (1 << STM_RCC_APB2ENR_SYSCFGCOMPEN);
/* Set ADC to use DMA channel 1 (option 1) */
- stm_syscfg.cfgr1 &= ~(1 << STM_SYSCFG_CFGR1_ADC_DMA_RMP);
+ stm_syscfg.cfgr1 &= ~(1UL << STM_SYSCFG_CFGR1_ADC_DMA_RMP);
ao_dma_alloc(STM_DMA_INDEX(STM_DMA_CHANNEL_ADC_1));
stm_spi->dr = 0xff;
while (!(stm_spi->sr & (1 << STM_SPI_SR_RXNE)))
;
- return stm_spi->dr;
+ return (uint8_t) stm_spi->dr;
}
void
static inline void ao_disable_port(struct stm_gpio *port)
{
if ((port) == &stm_gpioa) {
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPAEN);
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPAEN);
ao_power_unregister(&ao_power_gpioa);
} else if ((port) == &stm_gpiob) {
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPBEN);
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPBEN);
ao_power_unregister(&ao_power_gpiob);
} else if ((port) == &stm_gpioc) {
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPCEN);
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPCEN);
ao_power_unregister(&ao_power_gpioc);
} else if ((port) == &stm_gpiof) {
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPFEN);
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPFEN);
ao_power_unregister(&ao_power_gpiof);
}
}
#if BEEPER_TIMER == 1
timer.bdtr = 0;
#endif
- stm_rcc_enr &= ~(1 << STM_RCC_TIMER);
+ stm_rcc_enr &= ~(1UL << STM_RCC_TIMER);
/* Disconnect the timer from the pin */
stm_afr_set(BEEPER_PORT, BEEPER_PIN, STM_AFR_NONE);
ao_enable_output(BEEPER_PORT, BEEPER_PIN, 0);
/* Leave the timer off until requested */
- stm_rcc_enr &= ~(1 << STM_RCC_TIMER);
+ stm_rcc_enr &= ~(1UL << STM_RCC_TIMER);
}
/* Reset the chip to turn off the port and the power interface clock */
ao_gpio_set_mode(&AO_BOOT_APPLICATION_GPIO, AO_BOOT_APPLICATION_PIN, 0);
ao_disable_port(&AO_BOOT_APPLICATION_GPIO);
- stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_PWREN);
+ stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_PWREN);
return v == AO_BOOT_APPLICATION_VALUE;
}
ao_crc_in_32_out_16(uint32_t v) {
stm_crc.dr.u32 = v;
v = stm_crc.dr.u32;
- return v ^ (v >> 16);
+ return (uint16_t) (v ^ (v >> 16));
}
static inline uint16_t
void
ao_dma_done_transfer(uint8_t index)
{
- stm_dma.channel[index].ccr &= ~(1 << STM_DMA_CCR_EN);
+ stm_dma.channel[index].ccr &= ~(1UL << STM_DMA_CCR_EN);
ao_arch_critical(
if (--ao_dma_active == 0)
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_DMAEN);
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_DMAEN);
);
if (ao_dma_allocated[index])
ao_dma_mutex[index] = 0;
void
ao_dma_abort(uint8_t index)
{
- stm_dma.channel[index].ccr &= ~(1 << STM_DMA_CCR_EN);
+ stm_dma.channel[index].ccr &= ~(1UL << STM_DMA_CCR_EN);
ao_wakeup(&ao_dma_done[index]);
}
uint32_t ao_last_exti;
static void ao_exti_range_isr(uint8_t first, uint8_t last, uint16_t mask) {
- uint16_t pending = (ao_last_exti = stm_exti.pr) & mask;
+ uint16_t pending = (uint16_t) ((ao_last_exti = stm_exti.pr) & mask);
uint8_t pin;
static uint16_t last_mask;
static uint8_t last_pin;
ao_flash_wait_bsy();
- stm_flash.cr &= ~(1 << STM_FLASH_CR_PER);
+ stm_flash.cr &= ~(1UL << STM_FLASH_CR_PER);
}
static uint32_t
ao_flash_wait_bsy();
}
- stm_flash.cr &= ~(1 << STM_FLASH_CR_PG);
+ stm_flash.cr &= ~(1UL << STM_FLASH_CR_PG);
}
void
{
struct stm_gpio *port = arg;
if (port == &stm_gpioa)
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPAEN);
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPAEN);
else if ((port) == &stm_gpiob)
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPBEN);
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPBEN);
else if ((port) == &stm_gpioc)
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPCEN);
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPCEN);
else if ((port) == &stm_gpiof)
- stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_IOPFEN);
+ stm_rcc.ahbenr &= ~(1UL << STM_RCC_AHBENR_IOPFEN);
}
static void
ao_led_set(AO_LED_TYPE colors)
{
AO_LED_TYPE on = colors & LEDS_AVAILABLE;
- AO_LED_TYPE off = ~colors & LEDS_AVAILABLE;
+ AO_LED_TYPE off = (AO_LED_TYPE) (~colors & LEDS_AVAILABLE);
ao_led_off(off);
ao_led_on(on);
#ifdef LED_PORT
stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE);
- LED_PORT->odr &= ~LEDS_AVAILABLE;
+ LED_PORT->odr &= (uint32_t) ~LEDS_AVAILABLE;
#else
#ifdef LED_PORT_0
stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE);
}
#endif
} else {
- usart->reg->cr1 &= ~(1 << STM_USART_CR1_RXNEIE);
+ usart->reg->cr1 &= ~(1UL << STM_USART_CR1_RXNEIE);
}
}
}
_ao_usart_rx(usart, is_stdin);
if (!_ao_usart_tx_start(usart))
- usart->reg->cr1 &= ~(1<< STM_USART_CR1_TXEIE);
+ usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TXEIE);
if (usart->reg->isr & (1 << STM_USART_ISR_TC)) {
usart->tx_running = 0;
- usart->reg->cr1 &= ~(1 << STM_USART_CR1_TCIE);
+ usart->reg->cr1 &= ~(1UL << STM_USART_CR1_TCIE);
if (usart->draining) {
usart->draining = 0;
ao_wakeup(&usart->tx_fifo);
}
static inline uint8_t
-_ao_usart_sleep_for(struct ao_stm_usart *usart, uint16_t timeout)
+_ao_usart_sleep_for(struct ao_stm_usart *usart, AO_TICK_TYPE timeout)
{
return ao_sleep_for(&usart->rx_fifo, timeout);
}
}
uint8_t
-_ao_serial1_sleep_for(uint16_t timeout)
+_ao_serial1_sleep_for(AO_TICK_TYPE timeout)
{
return _ao_usart_sleep_for(&ao_stm_usart1, timeout);
}
}
uint8_t
-_ao_serial2_sleep_for(uint16_t timeout)
+_ao_serial2_sleep_for(AO_TICK_TYPE timeout)
{
return _ao_usart_sleep_for(&ao_stm_usart2, timeout);
}
ao_serial_shutdown(void)
{
#if HAS_SERIAL_1
- stm_rcc.apb2enr &= ~(1 << STM_RCC_APB2ENR_USART1EN);
+ stm_rcc.apb2enr &= ~(1UL << STM_RCC_APB2ENR_USART1EN);
#endif
#if HAS_SERIAL_2
- stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_USART2EN);
+ stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_USART2EN);
#endif
}
++ao_tick_count;
ao_task_check_alarm();
#if AO_DATA_ALL
- if (++ao_data_count == ao_data_interval) {
+ if (++ao_data_count == ao_data_interval && ao_data_interval) {
ao_data_count = 0;
#if HAS_ADC
#if HAS_FAKE_FLIGHT
#if AO_HSE_BYPASS
stm_rcc.cr |= (1 << STM_RCC_CR_HSEBYP);
#else
- stm_rcc.cr &= ~(1 << STM_RCC_CR_HSEBYP);
+ stm_rcc.cr &= ~(1UL << STM_RCC_CR_HSEBYP);
#endif
/* Enable HSE clock */
stm_rcc.cr |= (1 << STM_RCC_CR_HSEON);
asm("nop");
/* Disable the PLL */
- stm_rcc.cr &= ~(1 << STM_RCC_CR_PLLON);
- while (stm_rcc.cr & (1 << STM_RCC_CR_PLLRDY))
+ stm_rcc.cr &= ~(1UL << STM_RCC_CR_PLLON);
+ while (stm_rcc.cr & (1UL << STM_RCC_CR_PLLRDY))
asm("nop");
/* Set multiplier */
cfgr |= (AO_RCC_CFGR_PLLMUL << STM_RCC_CFGR_PLLMUL);
/* PLL source */
- cfgr &= ~(1 << STM_RCC_CFGR_PLLSRC);
+ cfgr &= ~(1UL << STM_RCC_CFGR_PLLSRC);
cfgr |= (STM_RCC_CFGR_PLLSRC_TARGET_CLOCK << STM_RCC_CFGR_PLLSRC);
stm_rcc.cfgr = cfgr;
}
#if !AO_HSI && !AO_NEED_HSI
/* Turn off the HSI clock */
- stm_rcc.cr &= ~(1 << STM_RCC_CR_HSION);
+ stm_rcc.cr &= ~(1UL << STM_RCC_CR_HSION);
#endif
#ifdef STM_PLLSRC
/* USB PLL source */
epr_old = epr_write = stm_usb.epr[ep].r;
epr_write &= STM_USB_EPR_PRESERVE_MASK;
epr_write |= STM_USB_EPR_INVARIANT;
- epr_write |= set_toggle(epr_old,
- STM_USB_EPR_STAT_TX_MASK << STM_USB_EPR_STAT_TX,
- stat_tx << STM_USB_EPR_STAT_TX);
+ epr_write |= (uint16_t) set_toggle(epr_old,
+ STM_USB_EPR_STAT_TX_MASK << STM_USB_EPR_STAT_TX,
+ stat_tx << STM_USB_EPR_STAT_TX);
stm_usb.epr[ep].r = epr_write;
_tx_dbg1("set_stat_tx bottom", epr_write);
}
epr_write = stm_usb.epr[ep].r;
epr_write &= STM_USB_EPR_PRESERVE_MASK;
epr_write |= STM_USB_EPR_INVARIANT;
- epr_write |= ((dtog_rx << STM_USB_EPR_DTOG_RX) |
- (dtog_tx << STM_USB_EPR_DTOG_TX));
+ epr_write |= (uint16_t) ((dtog_rx << STM_USB_EPR_DTOG_RX) |
+ (dtog_tx << STM_USB_EPR_DTOG_TX));
stm_usb.epr[ep].r = epr_write;
_tx_dbg1("toggle_dtog bottom", epr_write);
}
epr_write = epr_old = stm_usb.epr[ep].r;
epr_write &= STM_USB_EPR_PRESERVE_MASK;
epr_write |= STM_USB_EPR_INVARIANT;
- epr_write |= set_toggle(epr_old,
- STM_USB_EPR_STAT_RX_MASK << STM_USB_EPR_STAT_RX,
- stat_rx << STM_USB_EPR_STAT_RX);
+ epr_write |= (uint16_t) set_toggle(epr_old,
+ STM_USB_EPR_STAT_RX_MASK << STM_USB_EPR_STAT_RX,
+ stat_rx << STM_USB_EPR_STAT_RX);
stm_usb.epr[ep].r = epr_write;
}
ao_arch_block_interrupts();
epr = stm_usb.epr[ep].r;
- epr = ((0 << STM_USB_EPR_CTR_RX) |
- (type << STM_USB_EPR_EP_TYPE) |
- (kind << STM_USB_EPR_EP_KIND) |
- (0 << STM_USB_EPR_CTR_TX) |
- (addr << STM_USB_EPR_EA) |
- set_toggle(epr,
-
- (1 << STM_USB_EPR_DTOG_RX) |
- (STM_USB_EPR_STAT_RX_MASK << STM_USB_EPR_STAT_RX) |
- (1 << STM_USB_EPR_DTOG_TX) |
- (STM_USB_EPR_STAT_TX_MASK << STM_USB_EPR_STAT_TX),
-
- (dtog_rx << STM_USB_EPR_DTOG_RX) |
- (stat_rx << STM_USB_EPR_STAT_RX) |
- (dtog_tx << STM_USB_EPR_DTOG_TX) |
- (stat_tx << STM_USB_EPR_STAT_TX)));
+ epr = (uint16_t) ((0UL << STM_USB_EPR_CTR_RX) |
+ ((uint32_t) type << STM_USB_EPR_EP_TYPE) |
+ ((uint32_t) kind << STM_USB_EPR_EP_KIND) |
+ (0UL << STM_USB_EPR_CTR_TX) |
+ ((uint32_t) addr << STM_USB_EPR_EA) |
+ set_toggle(epr,
+
+ (1UL << STM_USB_EPR_DTOG_RX) |
+ (STM_USB_EPR_STAT_RX_MASK << STM_USB_EPR_STAT_RX) |
+ (1UL << STM_USB_EPR_DTOG_TX) |
+ (STM_USB_EPR_STAT_TX_MASK << STM_USB_EPR_STAT_TX),
+
+ ((uint32_t) dtog_rx << STM_USB_EPR_DTOG_RX) |
+ ((uint32_t) stat_rx << STM_USB_EPR_STAT_RX) |
+ ((uint32_t) dtog_tx << STM_USB_EPR_DTOG_TX) |
+ ((uint32_t) stat_tx << STM_USB_EPR_STAT_TX)));
stm_usb.epr[ep].r = epr;
ao_arch_release_interrupts();
debug ("writing epr[%d] 0x%04x wrote 0x%04x\n",
sram_addr += AO_USB_CONTROL_SIZE;
#if AO_USB_HAS_INT
- sram_addr += (sram_addr & 1);
+ sram_addr = (uint16_t) ((uint16_t) sram_addr + (uint16_t) (sram_addr & 1));
ao_usb_int_tx_offset = sram_addr;
sram_addr += AO_USB_INT_SIZE;
#endif
#if AO_USB_HAS_OUT
- sram_addr += (sram_addr & 1);
+ sram_addr = (uint16_t) ((uint16_t) sram_addr + (uint16_t) (sram_addr & 1));
ao_usb_out_rx_offset = sram_addr;
sram_addr += AO_USB_OUT_SIZE * 2;
#endif
#if AO_USB_HAS_IN
- sram_addr += (sram_addr & 1);
+ sram_addr = (uint16_t) ((uint16_t) sram_addr + (uint16_t) (sram_addr & 1));
ao_usb_in_tx_offset = sram_addr;
sram_addr += AO_USB_IN_SIZE * 2;
#endif
#if AO_USB_HAS_IN2
- sram_addr += (sram_addr & 1);
+ sram_addr = (uint16_t) ((uint16_t) sram_addr + (uint16_t) (sram_addr & 1));
ao_usb_in_tx2_offset = sram_addr;
sram_addr += AO_USB_IN_SIZE * 2;
#endif
#if AO_USB_HAS_IN3
- sram_addr += (sram_addr & 1);
+ sram_addr = (uint16_t) ((uint16_t) sram_addr + (uint16_t) (sram_addr & 1));
ao_usb_in_tx3_offset = sram_addr;
sram_addr += AO_USB_IN_SIZE * 2;
#endif
static void
ao_usb_set_ep0(void)
{
- int e;
+ uint8_t e;
ao_usb_init_btable();
{
if (offset & 1)
ao_usb_packet_put(offset - 1,
- ao_usb_packet_get(offset - 1) | ((uint16_t) byte) << 8);
+ (uint16_t) (ao_usb_packet_get(offset - 1) | ((uint16_t) byte) << 8));
else
ao_usb_packet_put(offset, (uint16_t) byte);
}
if (len > ao_usb_ep0_out_len)
len = ao_usb_ep0_out_len;
- ao_usb_ep0_out_len -= len;
+ ao_usb_ep0_out_len -= (uint8_t) len;
/* Pull all of the data out of the packet */
debug_data ("Fill EP0 len %d:", len);
{
/* Don't send more than asked for */
if (ao_usb_ep0_in_len > max)
- ao_usb_ep0_in_len = max;
+ ao_usb_ep0_in_len = (uint8_t) max;
ao_usb_ep0_flush();
}
for (i = 28; i >= 0; i -= 4) {
uint8_t bits = (in >> i) & 0xf;
- *out++ = ((bits < 10) ? '0' : ('a' - 10)) + bits;
+ *out++ = (uint8_t) (((bits < 10) ? '0' : ('a' - 10)) + bits);
*out++ = 0;
}
}
ao_usb_get_descriptor(uint16_t value, uint16_t length)
{
const uint8_t *descriptor;
- uint8_t type = value >> 8;
- uint8_t index = value;
+ uint8_t type = (uint8_t) (value >> 8);
+ uint8_t index = (uint8_t) value;
descriptor = ao_usb_descriptors;
while (descriptor[0] != 0) {
}
#endif
if (len > length)
- len = length;
+ len = (uint8_t) length;
ao_usb_ep0_in_set(descriptor, len);
break;
}
break;
case AO_USB_REQ_SET_ADDRESS:
debug ("set address %d\n", ao_usb_setup.value);
- ao_usb_address = ao_usb_setup.value;
+ ao_usb_address = (uint8_t) ao_usb_setup.value;
ao_usb_address_pending = 1;
break;
case AO_USB_REQ_GET_DESCRIPTOR:
ao_usb_ep0_in_queue_byte(ao_usb_configuration);
break;
case AO_USB_REQ_SET_CONFIGURATION:
- ao_usb_configuration = ao_usb_setup.value;
+ ao_usb_configuration = (uint8_t) ao_usb_setup.value;
debug ("set configuration %d\n", ao_usb_configuration);
ao_usb_set_configuration();
break;
ao_usb_wakeup(void)
{
ao_clock_resume();
- stm_usb.cntr &= ~(1 << STM_USB_CNTR_FSUSP);
+ stm_usb.cntr &= (uint16_t) ~(1 << STM_USB_CNTR_FSUSP);
ao_power_resume();
}
#endif
{
uint32_t istr = stm_usb.istr;
- stm_usb.istr = ~istr;
+ stm_usb.istr = (uint16_t) ~istr;
if (istr & (1 << STM_USB_ISTR_CTR)) {
uint8_t ep = istr & STM_USB_ISTR_EP_ID_MASK;
uint16_t epr, epr_write;
epr_write = epr;
epr_write &= STM_USB_EPR_PRESERVE_MASK;
epr_write |= STM_USB_EPR_INVARIANT;
- epr_write &= ~(1 << STM_USB_EPR_CTR_RX);
- epr_write &= ~(1 << STM_USB_EPR_CTR_TX);
+ epr_write &= (uint16_t) ~(1 << STM_USB_EPR_CTR_RX);
+ epr_write &= (uint16_t) ~(1 << STM_USB_EPR_CTR_TX);
stm_usb.epr[ep].r = epr_write;
switch (ep) {
_ao_usb_in_wait();
ao_usb_in_flushed = 0;
- ao_usb_tx_byte(ao_usb_in_tx_offset + AO_USB_IN_SIZE * ao_usb_in_tx_which + ao_usb_tx_count++, c);
+ ao_usb_tx_byte((uint16_t) (ao_usb_in_tx_offset + AO_USB_IN_SIZE * ao_usb_in_tx_which + ao_usb_tx_count++), c);
/* Send the packet when full */
if (ao_usb_tx_count == AO_USB_IN_SIZE) {
_ao_usb_in2_wait();
ao_usb_in2_flushed = 0;
- ao_usb_tx_byte(ao_usb_in_tx2_offset + AO_USB_IN_SIZE * ao_usb_in_tx2_which + ao_usb_tx2_count++, c);
+ ao_usb_tx_byte((uint16_t) (ao_usb_in_tx2_offset + AO_USB_IN_SIZE * ao_usb_in_tx2_which + ao_usb_tx2_count++), c);
/* Send the packet when full */
if (ao_usb_tx2_count == AO_USB_IN_SIZE) {
_ao_usb_in3_wait();
ao_usb_in3_flushed = 0;
- ao_usb_tx_byte(ao_usb_in_tx3_offset + AO_USB_IN_SIZE * ao_usb_in_tx3_which + ao_usb_tx3_count++, c);
+ ao_usb_tx_byte((uint16_t) (ao_usb_in_tx3_offset + AO_USB_IN_SIZE * ao_usb_in_tx3_which + ao_usb_tx3_count++), c);
/* Send the packet when full */
if (ao_usb_tx3_count == AO_USB_IN_SIZE) {
/* Switch to new buffer */
ao_usb_out_rx_which = 1 - ao_usb_out_rx_which;
- ao_usb_rx_count = stm_usb_bdt[AO_USB_OUT_EPR].double_rx[ao_usb_out_rx_which].count & STM_USB_BDT_COUNT_RX_COUNT_RX_MASK;
+ ao_usb_rx_count = (uint8_t) (stm_usb_bdt[AO_USB_OUT_EPR].double_rx[ao_usb_out_rx_which].count & STM_USB_BDT_COUNT_RX_COUNT_RX_MASK);
ao_usb_rx_pos = 0;
/* Toggle the SW_BUF_RX bit */
}
/* Pull a character out of the fifo */
- c = ao_usb_rx_byte(ao_usb_out_rx_offset + ao_usb_out_rx_which * AO_USB_OUT_SIZE + ao_usb_rx_pos++);
+ c = ao_usb_rx_byte((uint16_t) (ao_usb_out_rx_offset + ao_usb_out_rx_which * AO_USB_OUT_SIZE + ao_usb_rx_pos++));
_rx_dbg1("char", c);
return c;
}
while ((c = _ao_usb_pollchar()) == AO_READ_AGAIN)
ao_sleep(AO_USB_OUT_SLEEP_ADDR);
ao_arch_release_interrupts();
- return c;
+ return (char) c;
}
#endif
stm_usb.istr = 0;
/* Disable USB pull-up */
- stm_usb.bcdr &= ~(1 << STM_USB_BCDR_DPPU);
+ stm_usb.bcdr &= (uint16_t) ~(1 << STM_USB_BCDR_DPPU);
/* Switch off the device */
stm_usb.cntr = (1 << STM_USB_CNTR_PDWN) | (1 << STM_USB_CNTR_FRES);
/* Disable the interface */
- stm_rcc.apb1enr &= ~(1 << STM_RCC_APB1ENR_USBEN);
+ stm_rcc.apb1enr &= ~(1UL << STM_RCC_APB1ENR_USBEN);
ao_arch_release_interrupts();
}
int t;
/* Select HSI48 as USB clock source */
- stm_rcc.cfgr3 &= ~(1 << STM_RCC_CFGR3_USBSW);
+ stm_rcc.cfgr3 &= ~(1UL << STM_RCC_CFGR3_USBSW);
/* Enable USB device */
stm_rcc.apb1enr |= (1 << STM_RCC_APB1ENR_USBEN);
/* Clear reset condition */
- stm_rcc.apb1rstr &= ~(1 << STM_RCC_APB1RSTR_USBRST);
+ stm_rcc.apb1rstr &= ~(1UL << STM_RCC_APB1RSTR_USBRST);
/* Disable USB pull-up */
- stm_usb.bcdr &= ~(1 << STM_USB_BCDR_DPPU);
+ stm_usb.bcdr &= (uint16_t) ~(1 << STM_USB_BCDR_DPPU);
/* Do not touch the GPIOA configuration; USB takes priority
* over GPIO on pins A11 and A12, but if you select alternate
};
#define STM_MODER_SHIFT(pin) ((pin) << 1)
-#define STM_MODER_MASK 3
+#define STM_MODER_MASK 3UL
#define STM_MODER_INPUT 0
#define STM_MODER_OUTPUT 1
#define STM_MODER_ALTERNATE 2
}
#define STM_OTYPER_SHIFT(pin) (pin)
-#define STM_OTYPER_MASK 1
+#define STM_OTYPER_MASK 1UL
#define STM_OTYPER_PUSH_PULL 0
#define STM_OTYPER_OPEN_DRAIN 1
}
#define STM_OSPEEDR_SHIFT(pin) ((pin) << 1)
-#define STM_OSPEEDR_MASK 3
+#define STM_OSPEEDR_MASK 3UL
#define STM_OSPEEDR_LOW 0 /* 2MHz */
#define STM_OSPEEDR_MEDIUM 1 /* 10MHz */
#define STM_OSPEEDR_HIGH 3 /* 10-50MHz */
}
#define STM_PUPDR_SHIFT(pin) ((pin) << 1)
-#define STM_PUPDR_MASK 3
+#define STM_PUPDR_MASK 3UL
#define STM_PUPDR_NONE 0
#define STM_PUPDR_PULL_UP 1
#define STM_PUPDR_PULL_DOWN 2
}
#define STM_AFR_SHIFT(pin) ((pin) << 2)
-#define STM_AFR_MASK 0xf
+#define STM_AFR_MASK 0xfUL
#define STM_AFR_NONE 0
#define STM_AFR_AF0 0x0
#define STM_AFR_AF1 0x1
static inline uint16_t
stm_gpio_get_all(struct stm_gpio *gpio) {
- return gpio->idr;
+ return (uint16_t) gpio->idr;
}
/*
#define STM_RCC_CFGR_MCOPRE_DIV_32 5
#define STM_RCC_CFGR_MCOPRE_DIV_64 6
#define STM_RCC_CFGR_MCOPRE_DIV_128 7
-#define STM_RCC_CFGR_MCOPRE_DIV_MASK 7
+#define STM_RCC_CFGR_MCOPRE_DIV_MASK 7UL
#define STM_RCC_CFGR_MCO (24)
# define STM_RCC_CFGR_MCO_DISABLE 0
# define STM_RCC_CFGR_MCO_HSE 6
# define STM_RCC_CFGR_MCO_PLLCLK 7
# define STM_RCC_CFGR_MCO_HSI48 8
-# define STM_RCC_CFGR_MCO_MASK (0xf)
+# define STM_RCC_CFGR_MCO_MASK (0xfUL)
#define STM_RCC_CFGR_PLLMUL (18)
#define STM_RCC_CFGR_PLLMUL_2 0
#define STM_RCC_CFGR_PLLMUL_14 12
#define STM_RCC_CFGR_PLLMUL_15 13
#define STM_RCC_CFGR_PLLMUL_16 14
-#define STM_RCC_CFGR_PLLMUL_MASK 0xf
+#define STM_RCC_CFGR_PLLMUL_MASK 0xfUL
#define STM_RCC_CFGR_PLLXTPRE (17)
#define STM_RCC_CFGR_PPRE_DIV_4 5
#define STM_RCC_CFGR_PPRE_DIV_8 6
#define STM_RCC_CFGR_PPRE_DIV_16 7
-#define STM_RCC_CFGR_PPRE_MASK 7
+#define STM_RCC_CFGR_PPRE_MASK 7UL
#define STM_RCC_CFGR_HPRE (4)
#define STM_RCC_CFGR_HPRE_DIV_1 0
#define STM_RCC_CFGR_HPRE_DIV_128 0xd
#define STM_RCC_CFGR_HPRE_DIV_256 0xe
#define STM_RCC_CFGR_HPRE_DIV_512 0xf
-#define STM_RCC_CFGR_HPRE_MASK 0xf
+#define STM_RCC_CFGR_HPRE_MASK 0xfUL
#define STM_RCC_CFGR_SWS (2)
#define STM_RCC_CFGR_SWS_HSI 0
#define STM_RCC_CFGR_SWS_HSE 1
#define STM_RCC_CFGR_SWS_PLL 2
#define STM_RCC_CFGR_SWS_HSI48 3
-#define STM_RCC_CFGR_SWS_MASK 3
+#define STM_RCC_CFGR_SWS_MASK 3UL
#define STM_RCC_CFGR_SW (0)
#define STM_RCC_CFGR_SW_HSI 0
#define STM_RCC_CFGR_SW_HSE 1
#define STM_RCC_CFGR_SW_PLL 2
#define STM_RCC_CFGR_SW_HSI48 3
-#define STM_RCC_CFGR_SW_MASK 3
+#define STM_RCC_CFGR_SW_MASK 3UL
#define STM_RCC_APB2RSTR_DBGMCURST 22
#define STM_RCC_APB2RSTR_TIM17RST 18
#define IRQ_PRIO_REG(irq) ((irq) >> 2)
#define IRQ_PRIO_BIT(irq) (((irq) & 3) << 3)
-#define IRQ_PRIO_MASK(irq) (0xff << IRQ_PRIO_BIT(irq))
+#define IRQ_PRIO_MASK(irq) (0xffUL << IRQ_PRIO_BIT(irq))
static inline void
stm_nvic_set_priority(int irq, uint8_t prio) {
#define STM_SYSCFG_CFGR1_MEM_MODE_MAIN_FLASH 0
#define STM_SYSCFG_CFGR1_MEM_MODE_SYSTEM_FLASH 1
#define STM_SYSCFG_CFGR1_MEM_MODE_SRAM 3
-#define STM_SYSCFG_CFGR1_MEM_MODE_MASK 3
+#define STM_SYSCFG_CFGR1_MEM_MODE_MASK 3UL
#define STM_SYSCFG_EXTICR_PA 0
#define STM_SYSCFG_EXTICR_PB 1
static inline void
stm_exticr_set(struct stm_gpio *gpio, int pin) {
- uint8_t reg = pin >> 2;
- uint8_t shift = (pin & 3) << 2;
+ uint8_t reg = (uint8_t) pin >> 2;
+ uint8_t shift = ((uint8_t) pin & 3) << 2;
uint8_t val = 0;
/* Enable SYSCFG */
else if (gpio == &stm_gpiof)
val = STM_SYSCFG_EXTICR_PF;
- stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & ~(0xf << shift)) | val << shift;
+ stm_syscfg.exticr[reg] = (stm_syscfg.exticr[reg] & ~(0xfUL << shift)) | val << shift;
}
struct stm_dma_channel {
#define STM_DMA_INDEX(channel) ((channel) - 1)
#define STM_DMA_ISR(index) ((index) << 2)
-#define STM_DMA_ISR_MASK 0xf
+#define STM_DMA_ISR_MASK 0xfUL
#define STM_DMA_ISR_TEIF 3
#define STM_DMA_ISR_HTIF 2
#define STM_DMA_ISR_TCIF 1
#define STM_DMA_ISR_GIF 0
#define STM_DMA_IFCR(index) ((index) << 2)
-#define STM_DMA_IFCR_MASK 0xf
+#define STM_DMA_IFCR_MASK 0xfUL
#define STM_DMA_IFCR_CTEIF 3
#define STM_DMA_IFCR_CHTIF 2
#define STM_DMA_IFCR_CTCIF 1
#define STM_DMA_CCR_PL_MEDIUM (1)
#define STM_DMA_CCR_PL_HIGH (2)
#define STM_DMA_CCR_PL_VERY_HIGH (3)
-#define STM_DMA_CCR_PL_MASK (3)
+#define STM_DMA_CCR_PL_MASK (3UL)
#define STM_DMA_CCR_MSIZE (10)
#define STM_DMA_CCR_MSIZE_8 (0)
#define STM_DMA_CCR_MSIZE_16 (1)
#define STM_DMA_CCR_MSIZE_32 (2)
-#define STM_DMA_CCR_MSIZE_MASK (3)
+#define STM_DMA_CCR_MSIZE_MASK (3UL)
#define STM_DMA_CCR_PSIZE (8)
#define STM_DMA_CCR_PSIZE_8 (0)
#define STM_DMA_CCR_PSIZE_16 (1)
#define STM_DMA_CCR_PSIZE_32 (2)
-#define STM_DMA_CCR_PSIZE_MASK (3)
+#define STM_DMA_CCR_PSIZE_MASK (3UL)
#define STM_DMA_CCR_MINC (7)
#define STM_DMA_CCR_PINC (6)
#define STM_SPI_CR1_BR_PCLK_64 5
#define STM_SPI_CR1_BR_PCLK_128 6
#define STM_SPI_CR1_BR_PCLK_256 7
-#define STM_SPI_CR1_BR_MASK 7
+#define STM_SPI_CR1_BR_MASK 7UL
#define STM_SPI_CR1_MSTR 2
#define STM_SPI_CR1_CPOL 1
#define STM_ADC_CFGR1_EXTEN_RISING 1
#define STM_ADC_CFGR1_EXTEN_FALLING 2
#define STM_ADC_CFGR1_EXTEN_BOTH 3
-#define STM_ADC_CFGR1_EXTEN_MASK 3
+#define STM_ADC_CFGR1_EXTEN_MASK 3UL
#define STM_ADC_CFGR1_EXTSEL 6
#define STM_ADC_CFGR1_ALIGN 5
#define STM_ADC_CFGR1_RES_10 1
#define STM_ADC_CFGR1_RES_8 2
#define STM_ADC_CFGR1_RES_6 3
-#define STM_ADC_CFGR1_RES_MASK 3
+#define STM_ADC_CFGR1_RES_MASK 3UL
#define STM_ADC_CFGR1_SCANDIR 2
#define STM_ADC_CFGR1_SCANDIR_UP 0
#define STM_ADC_CFGR1_SCANDIR_DOWN 1
#define STM_I2C_CR2_FREQ_8_MHZ 8
#define STM_I2C_CR2_FREQ_16_MHZ 16
#define STM_I2C_CR2_FREQ_32_MHZ 32
-#define STM_I2C_CR2_FREQ_MASK 0x3f
+#define STM_I2C_CR2_FREQ_MASK 0x3fUL
#define STM_I2C_SR1_SMBALERT 15
#define STM_I2C_SR1_TIMEOUT 14
#define STM_I2C_SR1_SB 0
#define STM_I2C_SR2_PEC 8
-#define STM_I2C_SR2_PEC_MASK 0xff00
+#define STM_I2C_SR2_PEC_MASK 0xff00UL
#define STM_I2C_SR2_DUALF 7
#define STM_I2C_SR2_SMBHOST 6
#define STM_I2C_SR2_SMBDEFAULT 5
#define STM_I2C_CCR_FS 15
#define STM_I2C_CCR_DUTY 14
#define STM_I2C_CCR_CCR 0
-#define STM_I2C_CCR_MASK 0x7ff
+#define STM_I2C_CCR_MASK 0x7ffUL
struct stm_tim1 {
vuint32_t cr1;
#define STM_TIM23_CR1_CKD_1 0
#define STM_TIM23_CR1_CKD_2 1
#define STM_TIM23_CR1_CKD_4 2
-#define STM_TIM23_CR1_CKD_MASK 3
+#define STM_TIM23_CR1_CKD_MASK 3UL
#define STM_TIM23_CR1_ARPE 7
#define STM_TIM23_CR1_CMS 5
#define STM_TIM23_CR1_CMS_EDGE 0
#define STM_TIM23_CR1_CMS_CENTER_1 1
#define STM_TIM23_CR1_CMS_CENTER_2 2
#define STM_TIM23_CR1_CMS_CENTER_3 3
-#define STM_TIM23_CR1_CMS_MASK 3
+#define STM_TIM23_CR1_CMS_MASK 3UL
#define STM_TIM23_CR1_DIR 4
#define STM_TIM23_CR1_DIR_UP 0
#define STM_TIM23_CR1_DIR_DOWN 1
#define STM_TIM23_CR2_MMS_COMPARE_OC2REF 5
#define STM_TIM23_CR2_MMS_COMPARE_OC3REF 6
#define STM_TIM23_CR2_MMS_COMPARE_OC4REF 7
-#define STM_TIM23_CR2_MMS_MASK 7
+#define STM_TIM23_CR2_MMS_MASK 7UL
#define STM_TIM23_CR2_CCDS 3
#define STM_TIM23_SMCR_ETP 15
#define STM_TIM23_SMCR_ETPS_DIV_2 1
#define STM_TIM23_SMCR_ETPS_DIV_4 2
#define STM_TIM23_SMCR_ETPS_DIV_8 3
-#define STM_TIM23_SMCR_ETPS_MASK 3
+#define STM_TIM23_SMCR_ETPS_MASK 3UL
#define STM_TIM23_SMCR_ETF 8
#define STM_TIM23_SMCR_ETF_NONE 0
#define STM_TIM23_SMCR_ETF_INT_N_2 1
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u drogue: %5d main: %5d batt: %5d\n", \
+ printf("tick: %5lu drogue: %5d main: %5d batt: %5d\n", \
(p)->tick, \
(p)->adc.sense_a, (p)->adc.sense_m, \
(p)->adc.v_batt);
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u batt %5d\n", \
+ printf("tick: %5lu batt %5d\n", \
(p)->tick, \
(p)->adc.v_batt);
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u batt %5d\n", \
+ printf("tick: %5lu batt %5d\n", \
(p)->tick, \
(p)->adc.v_batt);
#define LED_7_PORT (&stm_gpioa)
#define LED_7_PIN 10
-#define AO_LED_CONTINUITY(c) (1 << (c))
+#define AO_LED_CONTINUITY(c) ((AO_LED_TYPE) (1 << (c)))
#define AO_LED_CONTINUITY_MASK (0xff)
/* ARM */
};
#define AO_ADC_DUMP(p) \
- printf ("tick: %5u " \
+ printf ("tick: %5lu " \
"0: %5d 1: %5d 2: %5d 3: %5d " \
"4: %5d 5: %5d 6: %5d 7: %5d " \
"pyro: %5d batt: %5d\n", \
#define LED_7_PORT (&stm_gpioa)
#define LED_7_PIN 10
-#define AO_LED_CONTINUITY(c) (1 << (c))
+#define AO_LED_CONTINUITY(c) ((AO_LED_TYPE) (1 << (c)))
#define AO_LED_CONTINUITY_MASK (0xff)
/* ARM */
};
#define AO_ADC_DUMP(p) \
- printf ("tick: %5u " \
+ printf ("tick: %5lu " \
"0: %5d 1: %5d 2: %5d 3: %5d " \
"4: %5d 5: %5d 6: %5d 7: %5d " \
"pyro: %5d batt: %5d\n", \
#define LED_PIN_ARMED 5
#define AO_LED_ARMED (1 << LED_PIN_ARMED)
-#define AO_LED_CONTINUITY(c) (1 << (4 - (c)))
+#define AO_LED_CONTINUITY(c) ((AO_LED_TYPE) (1 << (4 - (c))))
#define AO_LED_CONTINUITY_MASK (0x1 << 4)
#define LEDS_AVAILABLE (LED_PORT_0_MASK|LED_PORT_1_MASK)
};
#define AO_ADC_DUMP(p) \
- printf ("tick: %5u 0: %5d pyro: %5d batt %5d thrust %5d pressure %5d\n", \
+ printf ("tick: %5lu 0: %5d pyro: %5d batt %5d thrust %5d pressure %5d\n", \
(p)->tick, \
(p)->adc.sense[0], \
(p)->adc.pyro, \
static void
set_logging(void)
{
- ao_log_running = ao_cmd_hex();
+ ao_log_running = ao_cmd_hex() != 0;
ao_wakeup(&ao_log_running);
}
#define LED_PIN_ARMED 5
#define AO_LED_ARMED (1 << LED_PIN_ARMED)
-#define AO_LED_CONTINUITY(c) (1 << (4 - (c)))
+#define AO_LED_CONTINUITY(c) ((AO_LED_TYPE) (1 << (4 - (c))))
#define AO_LED_CONTINUITY_MASK (0x3 << 3)
#define LEDS_AVAILABLE (LED_PORT_0_MASK|LED_PORT_1_MASK)
};
#define AO_ADC_DUMP(p) \
- printf ("tick: %5u 0: %5d 1: %5d pyro: %5d batt %5d\n", \
+ printf ("tick: %5lu 0: %5d 1: %5d pyro: %5d batt %5d\n", \
(p)->tick, \
(p)->adc.sense[0], \
(p)->adc.sense[1], \
#ifndef _AO_PINS_H_
#define _AO_PINS_H_
-#define AO_STACK_SIZE 448
+#define AO_STACK_SIZE 440
#define IS_FLASH_LOADER 0
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u batt: %5d\n", \
+ printf("tick: %5lu batt: %5d\n", \
(p)->tick, \
(p)->adc.v_batt)
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u batt: %5d\n", \
+ printf("tick: %5lu batt: %5d\n", \
(p)->tick, \
(p)->adc.v_batt)
ao_lco_show_pad(uint8_t pad)
{
ao_mutex_get(&ao_lco_display_mutex);
- ao_seven_segment_set(AO_LCO_PAD_DIGIT, pad | (ao_lco_drag_race << 4));
+ ao_seven_segment_set(AO_LCO_PAD_DIGIT, (uint8_t) (pad | (ao_lco_drag_race << 4)));
ao_mutex_put(&ao_lco_display_mutex);
}
ao_lco_show_box(uint16_t box)
{
ao_mutex_get(&ao_lco_display_mutex);
- ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, box % 10 | (ao_lco_drag_race << 4));
- ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, box / 10 | (ao_lco_drag_race << 4));
+ ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, (uint8_t) (box % 10 | (ao_lco_drag_race << 4)));
+ ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, (uint8_t) (box / 10 | (ao_lco_drag_race << 4)));
ao_mutex_put(&ao_lco_display_mutex);
}
uint8_t tens, ones, tenths;
PRINTD("voltage %d\n", decivolts);
- tenths = decivolts % 10;
- ones = (decivolts / 10) % 10;
- tens = (decivolts / 100) % 10;
+ tenths = (uint8_t) (decivolts % 10);
+ ones = (uint8_t) ((decivolts / 10) % 10);
+ tens = (uint8_t) ((decivolts / 100) % 10);
ao_mutex_get(&ao_lco_display_mutex);
ao_seven_segment_set(AO_LCO_PAD_DIGIT, tenths);
ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, ones | 0x10);
static void
ao_lco_step_box(int8_t dir)
{
- int16_t new_box = ao_lco_box;
+ int32_t new_box = (int32_t) ao_lco_box;
do {
new_box += dir;
new_box = ao_lco_max_box;
if (new_box == ao_lco_box)
break;
- } while (!ao_lco_box_present(new_box));
- ao_lco_set_box(new_box);
+ } while (!ao_lco_box_present((uint16_t) new_box));
+ ao_lco_set_box((uint16_t) new_box);
}
static struct ao_task ao_lco_drag_task;
static void
ao_lco_drag_monitor(void)
{
- AO_TICK_TYPE delay = ~0;
+ AO_TICK_TYPE delay = ~0UL;
AO_TICK_TYPE now;
ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200));
else
ao_sleep_for(&ao_lco_drag_beep_count, delay);
- delay = ~0;
+ delay = ~0UL;
now = ao_time();
delay = ao_lco_drag_warn_check(now, delay);
delay = ao_lco_drag_beep_check(now, delay);
case AO_EVENT_BUTTON:
switch (event.unit) {
case AO_BUTTON_ARM:
- ao_lco_set_armed(event.value);
+ ao_lco_set_armed((uint8_t) event.value);
ao_lco_set_select();
break;
case AO_BUTTON_FIRE:
if (ao_lco_armed)
- ao_lco_set_firing(event.value);
+ ao_lco_set_firing((uint8_t) event.value);
break;
case AO_BUTTON_DRAG_SELECT:
if (event.value)
ao_adc_single_get(&packet);
decivolt = ao_battery_decivolt(packet.v_batt);
- ao_lco_show_voltage(decivolt);
+ ao_lco_show_voltage((uint16_t) decivolt);
ao_delay(AO_MS_TO_TICKS(1000));
}
static void
ao_lco_set_debug(void)
{
- uint16_t r = ao_cmd_decimal();
+ uint32_t r = ao_cmd_decimal();
if (ao_cmd_status == ao_cmd_success)
ao_lco_debug = r != 0;
}
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
+ printf("tick: %5lu A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
(p)->tick, \
(p)->adc.sense[0], (p)->adc.sense[1], (p)->adc.sense[2], \
(p)->adc.sense[3], (p)->adc.sense[4], (p)->adc.sense[5], \
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
+ printf("tick: %5lu A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
(p)->tick, \
(p)->adc.sense[0], (p)->adc.sense[1], (p)->adc.sense[2], \
(p)->adc.sense[3], (p)->adc.sense[4], (p)->adc.sense[5], \
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
+ printf("tick: %5lu A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
(p)->tick, \
(p)->adc.sense[0], (p)->adc.sense[1], (p)->adc.sense[2], \
(p)->adc.sense[3], (p)->adc.sense[4], (p)->adc.sense[5], \
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
+ printf("tick: %5lu A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
(p)->tick, \
(p)->adc.sense[0], (p)->adc.sense[1], (p)->adc.sense[2], \
(p)->adc.sense[3], (p)->adc.sense[4], (p)->adc.sense[5], \
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
+ printf("tick: %5lu A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
(p)->tick, \
(p)->adc.sense[0], (p)->adc.sense[1], (p)->adc.sense[2], \
(p)->adc.sense[3], (p)->adc.sense[4], (p)->adc.sense[5], \
#define BEEPER_PORT (&stm_gpioe)
#define BEEPER_PIN 4
#define AO_BEEP_MID_DEFAULT 179 /* 2100 Hz */
-#define AO_BEEP_MAKE_LOW(m) ((m) * 197/179) /* 1900 Hz */
-#define AO_BEEP_MAKE_HIGH(m) ((m) * 163/179) /* 2300 Hz */
+#define AO_BEEP_MAKE_LOW(m) ((uint8_t) ((m) * 197U/179U)) /* 1900 Hz */
+#define AO_BEEP_MAKE_HIGH(m) ((uint8_t) ((m) * 163U/179U)) /* 2300 Hz */
#define HAS_BATTERY_REPORT 1
#define HAS_RADIO 1
#define HAS_TELEMETRY 1
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
+ printf("tick: %5lu A: %5d B: %5d C: %5d D: %5d drogue: %5d main: %5d batt: %5d pbatt: %5d temp: %5d\n", \
(p)->tick, \
(p)->adc.sense[0], (p)->adc.sense[1], (p)->adc.sense[2], \
(p)->adc.sense[3], (p)->adc.sense[4], (p)->adc.sense[5], \
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u drogue: %5d main: %5d batt: %5d\n", \
+ printf("tick: %5lu drogue: %5d main: %5d batt: %5d\n", \
(p)->tick, \
(p)->adc.sense_a, (p)->adc.sense_m, \
(p)->adc.v_batt);
};
#define AO_ADC_DUMP(p) \
- printf("tick: %5u drogue: %5d main: %5d batt: %5d\n", \
+ printf("tick: %5lu drogue: %5d main: %5d batt: %5d\n", \
(p)->tick, \
(p)->adc.sense_a, (p)->adc.sense_m, \
(p)->adc.v_batt);
#define AO_SENSE_MAIN(p) ((p)->adc.sense_m)
#define AO_ADC_DUMP(p) \
- printf("tick: %5u apogee: %5d main: %5d batt: %5d\n", \
+ printf("tick: %5lu apogee: %5d main: %5d batt: %5d\n", \
(p)->tick, (p)->adc.sense_a, (p)->adc.sense_m, (p)->adc.v_batt)
/*
uint16_t ao_serial_number;
int16_t ao_flight_number;
-extern uint16_t ao_sample_tick;
+extern AO_TICK_TYPE ao_sample_tick;
#if HAS_BARO
extern alt_t ao_sample_height;
double ao_sample_qangle;
-int ao_sample_prev_tick;
-uint16_t prev_tick;
+AO_TICK_TYPE ao_sample_prev_tick;
+AO_TICK_TYPE prev_tick;
#include "ao_kalman.c"
MSG_INSTALL_JAVA="Java doit être installé sur votre système.\nRendez-vous sur java.com et suivez les instructions d'installation..."
MSG_LATER="Plus tard"
MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java by Adoptium"
;;
# German
MSG_INSTALL_JAVA="Auf Ihrem System muss die 'Java'-Software installiert sein.\nBesuchen Sie java.com für weitere Installationshinweise."
MSG_LATER="Später"
MSG_VISIT_JAVA_DOT_COM="Java von Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java von AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java von Adoptium"
;;
# Simplified Chinese
MSG_INSTALL_JAVA="你需要在Mac中安装Java运行环境!\n访问 java.com 了解如何安装。"
MSG_LATER="稍后"
MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java by Adoptium"
;;
# Spanish
MSG_INSTALL_JAVA="¡Necesita tener JAVA instalado en su Mac!\nVisite java.com para consultar las instrucciones para su instalación..."
MSG_LATER="Más tarde"
MSG_VISIT_JAVA_DOT_COM="Java de Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java de AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java de Adoptium"
;;
# English | default
MSG_INSTALL_JAVA="You need to have JAVA installed on your Mac!\nVisit java.com for installation instructions..."
MSG_LATER="Later"
MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
- MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
+ MSG_VISIT_ADOPTIUM="Java by Adoptium"
;;
esac
stub_logger "[EXIT 3] ${MSG_NO_SUITABLE_JAVA_EXPANDED}"
# display error message with AppleScript
- osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_NO_SUITABLE_JAVA_EXPANDED}\n${MSG_NO_SUITABLE_JAVA_CHECK}\" with title \"${CFBundleName}\" buttons {\" OK \", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTOPENJDK}\"} default button 1${DialogWithIcon}" \
+ osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_NO_SUITABLE_JAVA_EXPANDED}\n${MSG_NO_SUITABLE_JAVA_CHECK}\" with title \"${CFBundleName}\" buttons {\" OK \", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTIUM}\"} default button 1${DialogWithIcon}" \
-e "set response to button returned of the result" \
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"https://www.java.com/download/\"" \
- -e "if response is \"${MSG_VISIT_ADOPTOPENJDK}\" then open location \"https://adoptopenjdk.net/releases.html\""
+ -e "if response is \"${MSG_VISIT_ADOPTIUM}\" then open location \"https://adoptium.net/releases.html\""
# exit with error
exit 3
# log exit cause
stub_logger "[EXIT 1] ${MSG_ERROR_LAUNCHING}"
# display error message with AppleScript
- osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_INSTALL_JAVA}\" with title \"${CFBundleName}\" buttons {\"${MSG_LATER}\", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTOPENJDK}\"} default button 1${DialogWithIcon}" \
+ osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_INSTALL_JAVA}\" with title \"${CFBundleName}\" buttons {\"${MSG_LATER}\", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTIUM}\"} default button 1${DialogWithIcon}" \
-e "set response to button returned of the result" \
-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"https://www.java.com/download/\"" \
- -e "if response is \"${MSG_VISIT_ADOPTOPENJDK}\" then open location \"https://adoptopenjdk.net/releases.html\""
+ -e "if response is \"${MSG_VISIT_ADOPTIUM}\" then open location \"https://adoptium.net/releases.html\""
# exit with error
exit 1
fi
JLabel radio_calibration_label;
JLabel radio_frequency_label;
JLabel radio_enable_label;
+ JLabel radio_10mw_label;
JLabel rate_label;
JLabel aprs_interval_label;
JLabel aprs_ssid_label;
AltosUIFreqList radio_frequency_value;
JLabel radio_calibration_value;
JRadioButton radio_enable_value;
+ JRadioButton radio_10mw_value;
AltosUIRateList rate_value;
JComboBox<String> aprs_interval_value;
JComboBox<Integer> aprs_ssid_value;
radio_enable_value.setToolTipText("Firmware version does not support disabling radio");
}
+ void set_radio_10mw_tool_tip() {
+ if (radio_10mw_value.isVisible())
+ radio_10mw_value.setToolTipText("Should transmitter power be limited to 10mW");
+ else
+ radio_10mw_value.setToolTipText("Older firmware could not limit radio power");
+ }
+
void set_rate_tool_tip() {
if (rate_value.isVisible())
rate_value.setToolTipText("Select telemetry baud rate");
set_radio_enable_tool_tip();
row++;
+ /* Radio 10mW limit */
+ c = new GridBagConstraints();
+ c.gridx = 0; c.gridy = row;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.NONE;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = il;
+ c.ipady = 5;
+ radio_10mw_label = new JLabel("Limit transmit to 10mW:");
+ pane.add(radio_10mw_label, c);
+
+ c = new GridBagConstraints();
+ c.gridx = 4; c.gridy = row;
+ c.gridwidth = 4;
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.weightx = 1;
+ c.anchor = GridBagConstraints.LINE_START;
+ c.insets = ir;
+ c.ipady = 5;
+ radio_10mw_value = new JRadioButton("Limited");
+ radio_10mw_value.addItemListener(this);
+ pane.add(radio_10mw_value, c);
+ set_radio_10mw_tool_tip();
+ row++;
+
/* Telemetry Rate */
c = new GridBagConstraints();
c.gridx = 0; c.gridy = row;
return AltosLib.MISSING;
}
+ public void set_radio_10mw(int new_radio_10mw) {
+ if (new_radio_10mw != AltosLib.MISSING) {
+ radio_10mw_value.setSelected(new_radio_10mw != 0);
+ }
+ radio_10mw_value.setVisible(new_radio_10mw != AltosLib.MISSING);
+ radio_10mw_label.setVisible(new_radio_10mw != AltosLib.MISSING);
+ set_radio_10mw_tool_tip();
+ }
+
+ public int radio_10mw() {
+ if (radio_10mw_value.isVisible())
+ return radio_10mw_value.isSelected() ? 1 : 0;
+ else
+ return AltosLib.MISSING;
+ }
+
public void set_telemetry_rate(int new_rate) {
if (new_rate != AltosLib.MISSING)
rate_value.set_rate(new_rate);