Cache the parser data internally.

The code to calculate parameters like maximum depth and divetime is
duplicated in multiple places. Move this code to a single place, and
cache the data in the parser instead.
Also cache the number of mixes and the mix values

At least one dive computer in the Suunto Vyper family, the Vytec DS, is
capable of recording gas mix switches, and therefore supports more than
one mix. When going through the dive profile caching process, also look
for gas changes and record how many mixes were used in the dive. Mix 1
is always the main tank and it’s O2 value can be found in the dive
header, but the other tank O2 values are not available ahead of time. By
reviewing the dive profile ahead of time, the entire list of mixes can
be returned to the application at the beginning of the dive as per
usual.
Merge branch 'vyper'
Import Tiny AES128

This imports Tiny AES128 from https://github.com/kokke/tiny-AES128-C for
use in the decoding of OSTC3 firmwares.

This aes-code is released into the public domain.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Port TinyAES-128 to be thread safe.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Workaround msvc lack of a stdint.h

Suggested-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Add code to read and decrypt OSTC3 firmware files

This code is inspired by JeanDo ostc-companion.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Lift the OSTC3 INIT out of open

This lifts the OSTC3 INIT command out from the open function and does
that separately. This is refactoring to be able to enter service mode so
we can access service mode commands.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Add a helper to put the OSTC3 into servicemode

This code is inspired by JeanDo ostc-companion.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Add utility functions to convert uints to bytes

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Add a function to erase the memory of the OSTC3

This is the fist step in the firmware upgrade process.

This code is inspired by JeanDo ostc-companion.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Add function to read the rom from the OSTC3

This is necessary to verify that the memory written got transfered
correctly.

This code is inspired by JeanDo ostc-companion.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Add code to write rom of the OSTC3

This is how you transfer a new firmware to the OSTC3.

This code is inspired by JeanDo ostc-companion.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Add code to send upgrade firmware command to OSTC3

This function triggers a reboot into the bootloader which flashes the
new firmware to Prom.

This code is inspired by JeanDo ostc-companion.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Firmware upgrade for OSTC3

This connects the bits and implements firmware upgrade for the OSTC3.

This code is inspired by JeanDo ostc-companion.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Teach examples/ostc-fwupdate about OSTC3

This teaches the example firmware upgrader about how to upgrade the
OSTC3's.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Add Anton to copyright notice.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Remove unused imports

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Simplify state switching and checking for OSTC3

This simplifies the code to check and handle state switching for the
OSTC3.

Suggested-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Replace the code for handling line endings.

The new implementation is similar to the already existing code for
reading Intel HEX files. It can handle arbitrary line endings, and not
just CRLF or LF.