Make sure that the NVM bus/controller busy waits in the AVRISP MKII clone project...
[pub/USBasp.git] / Projects / TemperatureDataLogger / TempDataLogger.c
index 7d26ee2..5910528 100644 (file)
@@ -110,6 +110,7 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
        /* Reset log tick counter to prepare for next logging interval */\r
        CurrentLoggingTicks = 0;\r
        \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
        if (USB_DeviceState == DEVICE_STATE_Unattached)\r
        {\r
                uint8_t Day,  Month,  Year;\r
@@ -136,18 +137,19 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
  */\r
 int main(void)\r
 {\r
  */\r
 int main(void)\r
 {\r
+       SetupHardware();\r
+\r
        /* Fetch logging interval from EEPROM */\r
        LoggingInterval500MS_SRAM = eeprom_read_byte(&LoggingInterval500MS_EEPROM);\r
 \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
        /* Mount and open the log file on the dataflash FAT partition */\r
        OpenLogFile();\r
 \r
        /* Mount and open the log file on the dataflash FAT partition */\r
        OpenLogFile();\r
 \r
+       LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
+       sei();\r
+\r
        /* Discard the first sample from the temperature sensor, as it is generally incorrect */\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
        (void)Dummy;\r
        \r
        for (;;)\r
@@ -251,7 +253,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
  *\r
  *  \param[in] MSInterfaceInfo  Pointer to the Mass Storage class interface configuration structure being referenced\r
  */\r
  *\r
  *  \param[in] MSInterfaceInfo  Pointer to the Mass Storage class interface configuration structure being referenced\r
  */\r
-bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)\r
+bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)\r
 {\r
        bool CommandSuccess;\r
        \r
 {\r
        bool CommandSuccess;\r
        \r
@@ -298,10 +300,6 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
 {\r
        Device_Report_t* ReportParams = (Device_Report_t*)ReportData;\r
        \r
 {\r
        Device_Report_t* ReportParams = (Device_Report_t*)ReportData;\r
        \r
-       GPIOR0 = ReportParams->Day;\r
-       GPIOR1 = ReportParams->Month;\r
-       GPIOR2 = ReportParams->Year;\r
-       \r
        DS1307_SetDate(ReportParams->Day,  ReportParams->Month,  ReportParams->Year);\r
        DS1307_SetTime(ReportParams->Hour, ReportParams->Minute, ReportParams->Second);\r
        \r
        DS1307_SetDate(ReportParams->Day,  ReportParams->Month,  ReportParams->Year);\r
        DS1307_SetTime(ReportParams->Hour, ReportParams->Minute, ReportParams->Second);\r
        \r