aboutsummaryrefslogtreecommitdiff
path: root/src/ootx_decoder.h
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2017-02-14 10:03:18 -0500
committercnlohr <lohr85@gmail.com>2017-02-14 10:03:18 -0500
commit119a205619632076c7b258eaa6c28dd7bcd2c294 (patch)
treed99f9611314c7a565190570e2c337f8ffc6ae9c3 /src/ootx_decoder.h
parent1f760c1341cd170f3cf519b5b01c1fa8c5b9c610 (diff)
downloadlibsurvive-119a205619632076c7b258eaa6c28dd7bcd2c294.tar.gz
libsurvive-119a205619632076c7b258eaa6c28dd7bcd2c294.tar.bz2
integrate josh's new work. It works! #19 is just about solved!
Diffstat (limited to 'src/ootx_decoder.h')
-rw-r--r--src/ootx_decoder.h47
1 files changed, 39 insertions, 8 deletions
diff --git a/src/ootx_decoder.h b/src/ootx_decoder.h
index 5df5ba2..8ddf527 100644
--- a/src/ootx_decoder.h
+++ b/src/ootx_decoder.h
@@ -1,4 +1,4 @@
-// (C) 2016 Joshua Allen, MIT/x11 License.
+// (C) 2017 Joshua Allen, MIT/x11 License.
//
//All MIT/x11 Licensed Code in this file may be relicensed freely under the GPL or LGPL licenses.
@@ -8,8 +8,6 @@
#include <stddef.h>
#include <stdint.h>
-#define MAX_OOTX_BUFF_SIZE 1024
-
typedef struct {
uint16_t length;
uint8_t* data;
@@ -17,7 +15,7 @@ typedef struct {
} ootx_packet;
typedef struct {
- uint8_t buffer[MAX_OOTX_BUFF_SIZE];
+ uint8_t* buffer;
uint16_t buf_offset;
uint8_t bits_written;
uint16_t* payload_size;
@@ -25,17 +23,50 @@ typedef struct {
uint32_t preamble;
uint8_t bits_processed;
uint8_t found_preamble;
+
+ uint8_t bit_count[2];
+
void * user;
int user1;
} ootx_decoder_context;
-//void ootx_init_buffer();
-void ootx_process_bit(ootx_decoder_context *ctx, uint8_t dbit); //dbit MUST be 0x00 or 0xFF
+typedef float float16;
+
+typedef struct {
+ uint16_t fw_version;//Firmware version (bit 15..6), protocol version (bit 5..0)
+ uint32_t id; //Unique identifier of the base station
+ float16 fcal_0_phase; //"phase" for rotor 0
+ float16 fcal_1_phase; //"phase" for rotor 1
+ float16 fcal_0_tilt; //"tilt" for rotor 0
+ float16 fcal_1_tilt; //"tilt" for rotor 1
+ uint8_t sys_unlock_count; //Lowest 8 bits of the rotor desynchronization counter
+ uint8_t hw_version; //Hardware version
+ float16 fcal_0_curve; //"curve" for rotor 0
+ float16 fcal_1_curve; //"curve" for rotor 1
+ int8_t accel_dir_x; //"orientation vector"
+ int8_t accel_dir_y; //"orientation vector"
+ int8_t accel_dir_z; //"orientation vector"
+ float16 fcal_0_gibphase; //"gibbous phase" for rotor 0 (normalized angle)
+ float16 fcal_1_gibphase; //"gibbous phase" for rotor 1 (normalized angle)
+ float16 fcal_0_gibmag; //"gibbous magnitude" for rotor 0
+ float16 fcal_1_gibmag; //"gibbous magnitude" for rotor 1
+ uint8_t mode_current; //Currently selected mode (default: 0=A, 1=B, 2=C)
+ uint8_t sys_faults; //"fault detect flags" (should be 0)
+} lighthouse_info_v6;
+
+void init_lighthouse_info_v6(lighthouse_info_v6* lhi, uint8_t* data);
+void print_lighthouse_info_v6(lighthouse_info_v6* lhi);
+
void ootx_init_decoder_context(ootx_decoder_context *ctx);
-int8_t ootx_decode_lighthouse_number(uint8_t last_num, uint32_t ticks, int32_t delta);
+void ootx_free_decoder_context(ootx_decoder_context *ctx);
+
+uint8_t ootx_process_bit(ootx_decoder_context *ctx, uint32_t length);
+void ootx_pump_bit(ootx_decoder_context *ctx, uint8_t dbit);
+uint8_t ootx_decode_bit(uint32_t length);
-extern void (*ootx_packet_clbk)(ootx_decoder_context * ctx, ootx_packet* packet);
+extern void (*ootx_packet_clbk)(ootx_decoder_context *ctx, ootx_packet* packet);
+extern void (*ootx_bad_crc_clbk)(ootx_decoder_context *ctx, ootx_packet* packet, uint32_t crc);
#endif