diff --git a/quad/src/quad_app/log_data.c b/quad/src/quad_app/log_data.c index 2f0e251d83cd1245645d48d2749f41fa99511ff6..96a0db977a91e03aafa489fea545633f31b552ce 100644 --- a/quad/src/quad_app/log_data.c +++ b/quad/src/quad_app/log_data.c @@ -410,7 +410,7 @@ void RTprintLogging(struct CommDriver *comm, log_t* log_struct, parameter_t* ps, timer_axi_reset(); } -void RTprintend(); +void RTprintend() { if (arrayIndex == 0) { @@ -524,3 +524,25 @@ void format_log(int idx, log_t* log_struct, struct str* buf) { } safe_sprintf_cat(buf, "\n"); } + +/* + Initially sets it so that all debug values are zero +*/ +void initializeFlags(SensorRTFlags_t * flags) { + + flags = calloc(1, sizeof(SensorRTFlags_t)); + flags -> imuflags = calloc(1, sizeof(IMUFlags_t)); + flags -> optflowflags = calloc(1, sizeof(OptFlowFlags_t)); + flags -> lidarflags = calloc(1, sizeof(lidarFlags_t)); + flags -> errorflags = calloc(1, sizeof(SensorErrorFlags_t)); + flags -> flag_count = 0; +} + +void freeFlags(SensorRTFlags_t * flags){ + free(flags -> imuflags); + free(flags -> optflowflags); + free(flags -> lidarflags); + free(flags -> errorflags); + free(flags -> flag_count); + free(flags); +} diff --git a/quad/src/quad_app/util.c b/quad/src/quad_app/util.c index 698d453c7734dc2fd4dd5975d722fcdfa2ac6581..70fc13f3366c745456e532af2a151bf199ae749a 100644 --- a/quad/src/quad_app/util.c +++ b/quad/src/quad_app/util.c @@ -121,3 +121,11 @@ void pack_short(int16_t val, u8* buff) { void pack_float(float val, u8* buff) { memcpy(buff, &val, sizeof(val)); } + +/* + Helper to return single bit of u32 data. This returns the "position"'th bit of the given u32, + assuming it is Zero indexed. +*/ +u32 read_bit(u32 data, int position) { + return (data >> position) & 1; +}