a stab at turning on rudimentary logging for telefiretwo
authorBdale Garbee <bdale@gag.com>
Sat, 22 Apr 2017 22:59:03 +0000 (16:59 -0600)
committerBdale Garbee <bdale@gag.com>
Sat, 22 Apr 2017 22:59:03 +0000 (16:59 -0600)
src/kernel/ao_log_firetwo.c
src/telefiretwo-v1.0/Makefile
src/telefiretwo-v1.0/ao_pins.h

index 71e84dfeb755da2c65fd87d55a4cc8705a23b2a5..4655920623e1d1cd7d58709d797819184cc6bacc 100644 (file)
@@ -75,7 +75,9 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_firetwo))] ;
 void
 ao_log(void)
 {
 void
 ao_log(void)
 {
-       __pdata uint16_t        next_sensor, next_other;
+       uint16_t ao_idle_pressure = 0;          // write code to capture pre-test values someday
+       uint16_t ao_idle_thrust = 0;
+       uint16_t ao_flight_state = ao_flight_startup;
 
        ao_storage_setup();
 
 
        ao_storage_setup();
 
@@ -84,37 +86,31 @@ ao_log(void)
        while (!ao_log_running)
                ao_sleep(&ao_log_running);
 
        while (!ao_log_running)
                ao_sleep(&ao_log_running);
 
-#if HAS_FLIGHT
        log.type = AO_LOG_FLIGHT;
        log.type = AO_LOG_FLIGHT;
-       log.tick = ao_sample_tick;
+       log.tick = ao_time();
        log.u.flight.idle_pressure = ao_idle_pressure;
        log.u.flight.idle_thrust = ao_idle_thrust;
        log.u.flight.flight = ao_flight_number;
        ao_log_firetwo(&log);
        log.u.flight.idle_pressure = ao_idle_pressure;
        log.u.flight.idle_thrust = ao_idle_thrust;
        log.u.flight.flight = ao_flight_number;
        ao_log_firetwo(&log);
-#endif
 
        /* Write the whole contents of the ring to the log
         * when starting up.
         */
        ao_log_data_pos = ao_data_ring_next(ao_data_head);
 
        /* Write the whole contents of the ring to the log
         * when starting up.
         */
        ao_log_data_pos = ao_data_ring_next(ao_data_head);
-       next_other = next_sensor = ao_data_ring[ao_log_data_pos].tick;
        ao_log_state = ao_flight_startup;
        for (;;) {
                /* Write samples to EEPROM */
                while (ao_log_data_pos != ao_data_head) {
                        log.tick = ao_data_ring[ao_log_data_pos].tick;
        ao_log_state = ao_flight_startup;
        for (;;) {
                /* Write samples to EEPROM */
                while (ao_log_data_pos != ao_data_head) {
                        log.tick = ao_data_ring[ao_log_data_pos].tick;
-                       if ((int16_t) (log.tick - next_sensor) >= 0) {
-                               log.type = AO_LOG_SENSOR;
-                               log.u.sensor.pressure = ao_data_ring[ao_log_data_pos].sensor.pressure;
-                               log.u.sensor.thrust = ao_data_ring[ao_log_data_pos].sensor.thrust;
-                               for (i = 0; i < 4; i++) {
-                                       log.u.sensor.thermistor[i] = ao_data_ring[ao_log_data_pos].sensor.thermistor[i];
-                               }
-                               ao_log_firetwo(&log);
-                       }
+                       log.type = AO_LOG_SENSOR;
+                       log.u.sensor.pressure = ao_data_ring[ao_log_data_pos].adc.pressure;
+                       log.u.sensor.thrust = ao_data_ring[ao_log_data_pos].adc.thrust;
+//                     for (i = 0; i < 4; i++) {
+//                             log.u.sensor.thermistor[i] = ao_data_ring[ao_log_data_pos].sensor.thermistor[i];
+//                     }
+                       ao_log_firetwo(&log);
                        ao_log_data_pos = ao_data_ring_next(ao_log_data_pos);
                }
                        ao_log_data_pos = ao_data_ring_next(ao_log_data_pos);
                }
-#if HAS_FLIGHT
                /* Write state change to EEPROM */
                if (ao_flight_state != ao_log_state) {
                        ao_log_state = ao_flight_state;
                /* Write state change to EEPROM */
                if (ao_flight_state != ao_log_state) {
                        ao_log_state = ao_flight_state;
@@ -127,7 +123,6 @@ ao_log(void)
                        if (ao_log_state == ao_flight_landed)
                                ao_log_stop();
                }
                        if (ao_log_state == ao_flight_landed)
                                ao_log_stop();
                }
-#endif
 
                ao_log_flush();
 
 
                ao_log_flush();
 
@@ -139,7 +134,6 @@ ao_log(void)
                        ao_sleep(&ao_log_running);
        }
 }
                        ao_sleep(&ao_log_running);
        }
 }
-#endif
 
 uint16_t
 ao_log_flight(uint8_t slot)
 
 uint16_t
 ao_log_flight(uint8_t slot)
index f46295991c9d9818d7ac4e5165faefd0bc4e6b10..87d5d47723493ee70a099a7eb3517377b61c7447 100644 (file)
@@ -7,6 +7,7 @@ include ../stm/Makefile.defs
 INC = \
        ao.h \
        ao_pins.h \
 INC = \
        ao.h \
        ao_pins.h \
+       ao_log.h \
        ao_arch.h \
        ao_arch_funcs.h \
        ao_pad.h \
        ao_arch.h \
        ao_arch_funcs.h \
        ao_pad.h \
@@ -52,7 +53,9 @@ ALTOS_SRC = \
        ao_aes.c \
        ao_aes_tables.c \
        ao_pad.c \
        ao_aes.c \
        ao_aes_tables.c \
        ao_pad.c \
-       ao_radio_cmac_cmd.c
+       ao_radio_cmac_cmd.c \
+       ao_log.c \
+       ao_log_firetwo.c
 
 PRODUCT_SRC = \
        ao_telefiretwo.c
 
 PRODUCT_SRC = \
        ao_telefiretwo.c
index aa8501c04807c73e3a08c4201e1f07e496fd4838..95189cdc3beb84b3185e1cafb7454247fc0c918f 100644 (file)
@@ -41,6 +41,8 @@
 #define AO_DATA_RING           32
 #define HAS_FIXED_PAD_BOX      1
 
 #define AO_DATA_RING           32
 #define HAS_FIXED_PAD_BOX      1
 
+#define LOG_ERASE_MARK         0x55
+
 /* 8MHz High speed external crystal */
 #define AO_HSE                 8000000
 
 /* 8MHz High speed external crystal */
 #define AO_HSE                 8000000