FIL TempLogFile;\r
\r
\r
+/** ISR to handle the 500ms ticks for sampling and data logging */\r
ISR(TIMER1_COMPA_vect, ISR_BLOCK)\r
{\r
uint8_t LEDMask = LEDs_GetLEDs();\r
/* Reset log tick counter to prepare for next logging interval */\r
CurrentLoggingTicks = 0;\r
\r
+ /* Only log when not connected to a USB host */\r
if (USB_DeviceState == DEVICE_STATE_Unattached)\r
{\r
uint8_t Day, Month, Year;\r
/* Fetch logging interval from EEPROM */\r
LoggingInterval500MS_SRAM = eeprom_read_byte(&LoggingInterval500MS_EEPROM);\r
\r
- LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
-\r
SetupHardware();\r
\r
+ LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
+\r
/* Mount and open the log file on the dataflash FAT partition */\r
OpenLogFile();\r
\r
/* Discard the first sample from the temperature sensor, as it is generally incorrect */\r
- uint8_t Dummy = Temperature_GetTemperature();\r
+ volatile uint8_t Dummy = Temperature_GetTemperature();\r
(void)Dummy;\r
\r
for (;;)\r
}\r
}\r
\r
+/** Opens the log file on the Dataflash's FAT formatted partition according to the current date */\r
void OpenLogFile(void)\r
{\r
char LogFileName[12];\r
f_lseek(&TempLogFile, TempLogFile.fsize);\r
}\r
\r
+/** Closes the open data log file on the Dataflash's FAT formatted partition */\r
void CloseLogFile(void)\r
{\r
/* Sync any data waiting to be written, unmount the storage device */\r
Temperature_Init();\r
Dataflash_Init();\r
USB_Init();\r
+ TWI_Init();\r
\r
/* 500ms logging interval timer configuration */\r
OCR1A = ((F_CPU / 1024) / 2);\r
DS1307_SetDate(ReportParams->Day, ReportParams->Month, ReportParams->Year);\r
DS1307_SetTime(ReportParams->Hour, ReportParams->Minute, ReportParams->Second);\r
\r
+ /* If the logging interval has changed from its current value, write it to EEPROM */\r
if (LoggingInterval500MS_SRAM != ReportParams->LogInterval500MS)\r
{\r
LoggingInterval500MS_SRAM = ReportParams->LogInterval500MS;\r