SD logger updates (#1672)

* [logger_sd] Start logging based on setting instead of RC

* [logger_sd] Multiple logs on one SD card
This commit is contained in:
Freek van Tienen
2016-05-18 15:40:14 +02:00
committed by Felix Ruess
parent ce8b47d060
commit 7bcf2564e8
4 changed files with 11 additions and 10 deletions
+1 -3
View File
@@ -35,9 +35,7 @@
<!--module name="geo_mag"/--> <!--module name="geo_mag"/-->
<module name="air_data"/> <module name="air_data"/>
<module name="temp_adc"/> <module name="temp_adc"/>
<module name="logger_sd_spi_direct"> <module name="logger_sd_spi_direct"/>
<define name="SDLOGGER_DIRECT_CONTROL_SWITCH" value="AUX3"/>
</module>
<module name="gps_ubx_ucenter"/> <module name="gps_ubx_ucenter"/>
<module name="heli_throttle_curve"/> <module name="heli_throttle_curve"/>
<define name="ROTORCRAFT_IS_HELI" value="TRUE" /> <define name="ROTORCRAFT_IS_HELI" value="TRUE" />
+1 -2
View File
@@ -27,6 +27,7 @@ Do not use start/stop functionality of the module, the module is not intended to
<dl_setting module="loggers/sdlogger_spi_direct" var="sdcard1.status" min="0" max="40" step="1"/> <dl_setting module="loggers/sdlogger_spi_direct" var="sdcard1.status" min="0" max="40" step="1"/>
<dl_setting module="loggers/sdlogger_spi_direct" var="sdcard1.error_status" min="0" max="15" step="1"/> <dl_setting module="loggers/sdlogger_spi_direct" var="sdcard1.error_status" min="0" max="15" step="1"/>
<dl_setting module="loggers/sdlogger_spi_direct" var="sdlogger_spi.command" min="1" max="42" step="1" /> <dl_setting module="loggers/sdlogger_spi_direct" var="sdlogger_spi.command" min="1" max="42" step="1" />
<dl_setting module="loggers/sdlogger_spi_direct" var="sdlogger_spi.do_log" min="0" max="1" step="1" values="Off|On"/>
</dl_settings> </dl_settings>
</dl_settings> </dl_settings>
</settings> </settings>
@@ -40,7 +41,6 @@ Do not use start/stop functionality of the module, the module is not intended to
<configure name="SDLOGGER_DIRECT_SPI" default="spi2" case="upper|lower"/> <configure name="SDLOGGER_DIRECT_SPI" default="spi2" case="upper|lower"/>
<configure name="SDLOGGER_DIRECT_SPI_SLAVE" default="spi_slave2" case="upper|lower"/> <configure name="SDLOGGER_DIRECT_SPI_SLAVE" default="spi_slave2" case="upper|lower"/>
<configure name="SDLOGGER_DIRECT_CONTROL_SWITCH" default="RADIO_AUX2"/>
<configure name="LOGGER_LED" default="none"/> <configure name="LOGGER_LED" default="none"/>
<define name="LOGGER_LED" value="$(LOGGER_LED)" cond="ifneq ($(LOGGER_LED),none)"/> <define name="LOGGER_LED" value="$(LOGGER_LED)" cond="ifneq ($(LOGGER_LED),none)"/>
<raw> <raw>
@@ -55,7 +55,6 @@ Do not use start/stop functionality of the module, the module is not intended to
<define name="SDLOGGER_SPI_LINK_DEVICE" value="$(SDLOGGER_DIRECT_SPI_LOWER)" /> <define name="SDLOGGER_SPI_LINK_DEVICE" value="$(SDLOGGER_DIRECT_SPI_LOWER)" />
<define name="USE_$(SDLOGGER_DIRECT_SPI_SLAVE_UPPER)" value="1" /> <define name="USE_$(SDLOGGER_DIRECT_SPI_SLAVE_UPPER)" value="1" />
<define name="SDLOGGER_SPI_LINK_SLAVE_NUMBER" value="$(SDLOGGER_DIRECT_SPI_SLAVE_UPPER)" /> <define name="SDLOGGER_SPI_LINK_SLAVE_NUMBER" value="$(SDLOGGER_DIRECT_SPI_SLAVE_UPPER)" />
<define name="SDLOGGER_CONTROL_SWITCH" value="$(SDLOGGER_DIRECT_CONTROL_SWITCH)"/>
</makefile> </makefile>
</module> </module>
@@ -32,7 +32,6 @@
#include "modules/loggers/sdlogger_spi_direct.h" #include "modules/loggers/sdlogger_spi_direct.h"
#include "subsystems/datalink/downlink.h" #include "subsystems/datalink/downlink.h"
#include "subsystems/datalink/telemetry.h" #include "subsystems/datalink/telemetry.h"
#include "subsystems/radio_control.h"
#include "led.h" #include "led.h"
#ifdef LOGGER_LED #ifdef LOGGER_LED
@@ -86,6 +85,7 @@ void sdlogger_spi_direct_init(void)
sdlogger_spi.download_id = 0; sdlogger_spi.download_id = 0;
sdlogger_spi.download_address = 0; sdlogger_spi.download_address = 0;
sdlogger_spi.download_length = 0; sdlogger_spi.download_length = 0;
sdlogger_spi.do_log = 0;
/* Set function pointers in link_device to the logger functions */ /* Set function pointers in link_device to the logger functions */
sdlogger_spi.device.check_free_space = (check_free_space_t)sdlogger_spi_direct_check_free_space; sdlogger_spi.device.check_free_space = (check_free_space_t)sdlogger_spi_direct_check_free_space;
@@ -115,7 +115,7 @@ void sdlogger_spi_direct_periodic(void)
break; break;
case SDLogger_Ready: case SDLogger_Ready:
if (radio_control.values[SDLOGGER_CONTROL_SWITCH] > 0 && if ((sdlogger_spi.do_log == 1) &&
sdcard1.status == SDCard_Idle) { sdcard1.status == SDCard_Idle) {
LOGGER_LED_ON; LOGGER_LED_ON;
sdcard_spi_multiwrite_start(&sdcard1, sdlogger_spi.next_available_address); sdcard_spi_multiwrite_start(&sdcard1, sdlogger_spi.next_available_address);
@@ -136,7 +136,7 @@ void sdlogger_spi_direct_periodic(void)
sdcard_spi_multiwrite_next(&sdcard1, &sdlogger_spi_direct_multiwrite_written); sdcard_spi_multiwrite_next(&sdcard1, &sdlogger_spi_direct_multiwrite_written);
} }
/* Check if switch is flipped to stop logging */ /* Check if switch is flipped to stop logging */
if (radio_control.values[SDLOGGER_CONTROL_SWITCH] < 0) { if (sdlogger_spi.do_log == 0) {
sdlogger_spi.status = SDLogger_LoggingFinalBlock; sdlogger_spi.status = SDLogger_LoggingFinalBlock;
} }
break; break;
@@ -223,13 +223,16 @@ void sdlogger_spi_direct_index_received(void)
case SDLogger_RetreivingIndex: case SDLogger_RetreivingIndex:
sdlogger_spi.next_available_address = 0x00004000; sdlogger_spi.next_available_address = 0x00004000;
sdlogger_spi.last_completed = 0; sdlogger_spi.last_completed = 0;
/* Save data for later use // Save data for later use
sdlogger_spi.next_available_address = (sdcard1.input_buf[0] << 24) | sdlogger_spi.next_available_address = (sdcard1.input_buf[0] << 24) |
(sdcard1.input_buf[1] << 16) | (sdcard1.input_buf[1] << 16) |
(sdcard1.input_buf[2] << 8) | (sdcard1.input_buf[2] << 8) |
(sdcard1.input_buf[3]); (sdcard1.input_buf[3]);
sdlogger_spi.last_completed = sdcard1.input_buf[4]; sdlogger_spi.last_completed = sdcard1.input_buf[4];
*/
if(sdlogger_spi.next_available_address < 0x00004000) {
sdlogger_spi.next_available_address = 0x00004000;
}
/* Ready to start logging */ /* Ready to start logging */
sdlogger_spi.status = SDLogger_Ready; sdlogger_spi.status = SDLogger_Ready;
@@ -59,6 +59,7 @@ struct sdlogger_spi_periph{
uint32_t download_address; uint32_t download_address;
uint32_t download_length; uint32_t download_length;
struct link_device device; struct link_device device;
uint8_t do_log;
}; };
extern struct sdlogger_spi_periph sdlogger_spi; extern struct sdlogger_spi_periph sdlogger_spi;