/*\r
LUFA Library\r
- Copyright (C) Dean Camera, 2009.\r
+ Copyright (C) Dean Camera, 2010.\r
\r
dean [at] fourwalledcubicle [dot] com\r
www.fourwalledcubicle.com\r
*/\r
\r
/*\r
- Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+ Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
\r
Permission to use, copy, modify, distribute, and sell this \r
software and its documentation for any purpose is hereby granted\r
/** FAT Fs structure to hold a FAT file handle for the log data write destination. */\r
FIL TempLogFile;\r
\r
-/** Counter to count the number of 10 millisecond tick that has elapsed since the last sample */\r
+/** Counter to count the number of 10 millisecond ticks that has elapsed since the last sample */\r
uint16_t CurrentLogTick;\r
\r
\r
if (CurrentLogTick++ != LOG_INTERVAL_10MS)\r
return;\r
\r
+ uint8_t LEDMask = LEDs_GetLEDs();\r
+\r
+ LEDs_SetAllLEDs(LEDMASK_USB_BUSY);\r
+\r
CurrentLogTick = 0;\r
\r
if (USB_DeviceState == DEVICE_STATE_Unattached)\r
f_printf(&TempLogFile, "%d Degrees\r\n", Temperature_GetTemperature());\r
f_sync(&TempLogFile);\r
}\r
+ \r
+ LEDs_SetAllLEDs(LEDMask);\r
}\r
\r
\r
f_mount(0, &DiskFATState);\r
f_open(&TempLogFile, LOG_FILENAME, FA_OPEN_ALWAYS | FA_WRITE);\r
f_lseek(&TempLogFile, TempLogFile.fsize);\r
-\r
- /* Write out the log seperator line */\r
f_printf(&TempLogFile, "===========================\r\n");\r
- Temperature_GetTemperature(); // Discard first temperature reading to ensure accuracy\r
-\r
+ \r
+ /* Discard the first sample from the temperature sensor, as it is generally incorrect */\r
+ uint8_t Dummy = Temperature_GetTemperature();\r
+ (void)Dummy;\r
+ \r
for (;;)\r
{\r
MS_Device_USBTask(&Disk_MS_Interface);\r
/* Hardware Initialization */\r
LEDs_Init();\r
SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);\r
- Dataflash_Init();\r
- USB_Init();\r
ADC_Init(ADC_REFERENCE_AVCC | ADC_FREE_RUNNING | ADC_PRESCALE_128);\r
Temperature_Init();\r
+ Dataflash_Init();\r
+ USB_Init();\r
\r
/* 10ms interval timer configuration */\r
OCR1A = (((F_CPU / 1024) / 100) - 1);\r
- TCCR1A = (1 << WGM01); // CTC mode\r
- TCCR1B = (1 << CS12) | (1 << CS10); // Fcpu/1024 speed\r
+ TCCR1B = (1 << WGM12) | (1 << CS12) | (1 << CS10); // CTC mode, Fcpu/1024 speed\r
TIMSK1 = (1 << OCIE1A);\r
\r
/* Clear Dataflash sector protections, if enabled */\r
f_mount(0, &DiskFATState);\r
f_open(&TempLogFile, LOG_FILENAME, FA_OPEN_ALWAYS | FA_WRITE);\r
f_lseek(&TempLogFile, TempLogFile.fsize);\r
+ f_printf(&TempLogFile, "===========================\r\n");\r
}\r
\r
/** Event handler for the library USB Configuration Changed event. */\r