X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/871d9bf1af06fe208ca16cb3b19722bec1300e63..ceb16ee24f1e6add5e2ad0398369c24d2d868cd8:/Projects/TemperatureDataLogger/TempDataLogger.c diff --git a/Projects/TemperatureDataLogger/TempDataLogger.c b/Projects/TemperatureDataLogger/TempDataLogger.c index 2f2e8daf7..59105286e 100644 --- a/Projects/TemperatureDataLogger/TempDataLogger.c +++ b/Projects/TemperatureDataLogger/TempDataLogger.c @@ -110,6 +110,7 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK) /* Reset log tick counter to prepare for next logging interval */ CurrentLoggingTicks = 0; + /* Only log when not connected to a USB host */ if (USB_DeviceState == DEVICE_STATE_Unattached) { uint8_t Day, Month, Year; @@ -136,18 +137,19 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK) */ int main(void) { + SetupHardware(); + /* Fetch logging interval from EEPROM */ LoggingInterval500MS_SRAM = eeprom_read_byte(&LoggingInterval500MS_EEPROM); - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); - - SetupHardware(); - /* Mount and open the log file on the dataflash FAT partition */ OpenLogFile(); + LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + sei(); + /* Discard the first sample from the temperature sensor, as it is generally incorrect */ - uint8_t Dummy = Temperature_GetTemperature(); + volatile uint8_t Dummy = Temperature_GetTemperature(); (void)Dummy; for (;;) @@ -199,6 +201,7 @@ void SetupHardware(void) Temperature_Init(); Dataflash_Init(); USB_Init(); + TWI_Init(); /* 500ms logging interval timer configuration */ OCR1A = ((F_CPU / 1024) / 2); @@ -250,7 +253,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) * * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface configuration structure being referenced */ -bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* MSInterfaceInfo) +bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) { bool CommandSuccess; @@ -297,10 +300,6 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI { Device_Report_t* ReportParams = (Device_Report_t*)ReportData; - GPIOR0 = ReportParams->Day; - GPIOR1 = ReportParams->Month; - GPIOR2 = ReportParams->Year; - DS1307_SetDate(ReportParams->Day, ReportParams->Month, ReportParams->Year); DS1307_SetTime(ReportParams->Hour, ReportParams->Minute, ReportParams->Second);