Radio Datalogger Project  Version 2.0
Functions | Variables
TempDataLogger.c File Reference
#include "TempDataLogger.h"

Functions

 ISR (TIMER1_COMPA_vect, ISR_BLOCK)
 
int main (void)
 
void RadioReceive (void)
 
void OpenLogFile (void)
 
void CloseLogFile (void)
 
void SetupHardware (void)
 
void GetCorrectionValues (void)
 
void EVENT_USB_Device_Connect (void)
 
void EVENT_USB_Device_Disconnect (void)
 
void EVENT_USB_Device_ConfigurationChanged (void)
 
void EVENT_USB_Device_Suspend (void)
 
void EVENT_USB_Device_ControlRequest (void)
 
bool CALLBACK_MS_Device_SCSICommandReceived (USB_ClassInfo_MS_Device_t *const MSInterfaceInfo)
 
bool CALLBACK_HID_Device_CreateHIDReport (USB_ClassInfo_HID_Device_t *const HIDInterfaceInfo, uint8_t *const ReportID, const uint8_t ReportType, void *ReportData, uint16_t *const ReportSize)
 
void CALLBACK_HID_Device_ProcessHIDReport (USB_ClassInfo_HID_Device_t *const HIDInterfaceInfo, const uint8_t ReportID, const uint8_t ReportType, const void *ReportData, const uint16_t ReportSize)
 

Variables

USB_ClassInfo_MS_Device_t Disk_MS_Interface
 
uint8_t PrevHIDReportBuffer [GENERIC_REPORT_SIZE]
 
USB_ClassInfo_HID_Device_t Generic_HID_Interface
 
uint16_t EEMEM LoggingInterval500MS_EEPROM = DEFAULT_LOG_INTERVAL
 
uint16_t LoggingInterval500MS_SRAM
 
uint8_t oldday
 
char Sensor1Name_SRAM [9]
 
char EEMEM Sensor1Name_EEPROM [8] = DEFAULT_SENSOR1_NAME
 
int8_t Sensor1Correction_SRAM
 
int8_t Sensor1PreviousValue
 
int8_t Sensor1MinValue =0
 
int8_t Sensor1MaxValue
 
bool Sensor1Received =false
 
uint8_t EEMEM Sensor1Correction_EEPROM
 
char Sensor2Name_SRAM [9]
 
char EEMEM Sensor2Name_EEPROM [8] = DEFAULT_SENSOR2_NAME
 
int8_t Sensor2Value =0
 
int8_t Sensor2PreviousValue
 
int8_t Sensor2Correction_SRAM
 
int8_t Sensor2MinValue
 
int8_t Sensor2MaxValue
 
bool Sensor2Received =false
 
uint8_t EEMEM Sensor2Correction_EEPROM
 
char Sensor3Name_SRAM [9]
 
char EEMEM Sensor3Name_EEPROM [8] = DEFAULT_SENSOR3_NAME
 
int8_t Sensor3Value =0
 
int8_t Sensor3PreviousValue
 
int8_t Sensor3Correction_SRAM
 
int8_t Sensor3MinValue
 
int8_t Sensor3MaxValue
 
bool Sensor3Received =false
 
uint8_t EEMEM Sensor3Correction_EEPROM
 
uint16_t CurrentLoggingTicks
 
uint8_t DataReceived
 
char recbuf [10]
 
uint8_t bufferposition
 
uint8_t Checksum
 
uint8_t rec_started
 
uint16_t Sensor2Timeout
 
uint16_t Sensor3Timeout
 
bool LogfileCreateSuccess
 
bool ReceiverRestart
 
uint32_t FreeMemory
 
uint16_t DaysLeft_SRAM
 
uint16_t EEMEM DaysLeft_EEPROM
 
FATFS DiskFATState
 
FIL TempLogFile
 
uint16_t WebEnableCounter
 

Detailed Description

Main source file for the TemperatureDataLogger project. This file contains the main tasks of the project and is responsible for the initial application hardware configuration.

Function Documentation

bool CALLBACK_HID_Device_CreateHIDReport ( USB_ClassInfo_HID_Device_t *const  HIDInterfaceInfo,
uint8_t *const  ReportID,
const uint8_t  ReportType,
void *  ReportData,
uint16_t *const  ReportSize 
)

HID class driver callback function for the creation of HID reports to the host.

Parameters
[in]HIDInterfaceInfoPointer to the HID class interface configuration structure being referenced
[in,out]ReportIDReport ID requested by the host if non-zero, otherwise callback should set to the generated report ID
[in]ReportTypeType of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature
[out]ReportDataPointer to a buffer where the created report should be stored
[out]ReportSizeNumber of bytes written in the report (or zero if no report is to be sent
Returns
Boolean true to force the sending of the report, false to let the library determine if it needs to be sent
void CALLBACK_HID_Device_ProcessHIDReport ( USB_ClassInfo_HID_Device_t *const  HIDInterfaceInfo,
const uint8_t  ReportID,
const uint8_t  ReportType,
const void *  ReportData,
const uint16_t  ReportSize 
)

HID class driver callback function for the processing of HID reports from the host.

Parameters
[in]HIDInterfaceInfoPointer to the HID class interface configuration structure being referenced
[in]ReportIDReport ID of the received report from the host
[in]ReportTypeThe type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature
[in]ReportDataPointer to a buffer where the created report has been stored
[in]ReportSizeSize in bytes of the received HID report
bool CALLBACK_MS_Device_SCSICommandReceived ( USB_ClassInfo_MS_Device_t *const  MSInterfaceInfo)

Mass Storage class driver callback function the reception of SCSI commands from the host, which must be processed.

Parameters
[in]MSInterfaceInfoPointer to the Mass Storage class interface configuration structure being referenced
void CloseLogFile ( void  )

Closes the open data log file on the Dataflash's FAT formatted partition

void EVENT_USB_Device_ConfigurationChanged ( void  )

Event handler for the library USB Configuration Changed event.

void EVENT_USB_Device_Connect ( void  )

Event handler for the library USB Connection event.

void EVENT_USB_Device_ControlRequest ( void  )

Event handler for the library USB Control Request reception event.

void EVENT_USB_Device_Disconnect ( void  )

Event handler for the library USB Disconnection event.

void EVENT_USB_Device_Suspend ( void  )
void GetCorrectionValues ( void  )
ISR ( TIMER1_COMPA_vect  ,
ISR_BLOCK   
)

ISR to manage the reception of data from the serial port ISR to handle the 500ms ticks for sampling and data logging

int main ( void  )

Main program entry point. This routine contains the overall program flow, including initial setup of all components and the main program loop.

void OpenLogFile ( void  )

Opens the log file on the Dataflash's FAT formatted partition according to the current date

void RadioReceive ( void  )

Receive telegram from radio modul

void SetupHardware ( void  )

Configures the board hardware and chip peripherals for the demo's functionality.

Variable Documentation

uint8_t bufferposition
uint8_t Checksum
uint16_t CurrentLoggingTicks

Total number of 500ms logging ticks elapsed since the last log value was recorded

uint8_t DataReceived

From radio modul received data

uint16_t EEMEM DaysLeft_EEPROM
uint16_t DaysLeft_SRAM

days left for data logging

USB_ClassInfo_MS_Device_t Disk_MS_Interface
Initial value:
=
{
.Config =
{
.InterfaceNumber = 0,
.DataINEndpointNumber = MASS_STORAGE_IN_EPNUM,
.DataINEndpointSize = MASS_STORAGE_IO_EPSIZE,
.DataINEndpointDoubleBank = false,
.DataOUTEndpointNumber = MASS_STORAGE_OUT_EPNUM,
.DataOUTEndpointSize = MASS_STORAGE_IO_EPSIZE,
.DataOUTEndpointDoubleBank = false,
.TotalLUNs = 1,
},
}

LUFA Mass Storage Class driver interface configuration and state information. This structure is passed to all Mass Storage Class driver functions, so that multiple instances of the same class within a device can be differentiated from one another.

FATFS DiskFATState

FAT Fs structure to hold the internal state of the FAT driver for the Dataflash contents.

uint32_t FreeMemory

free memory on device

USB_ClassInfo_HID_Device_t Generic_HID_Interface
Initial value:
=
{
.Config =
{
.InterfaceNumber = 1,
.ReportINEndpointNumber = GENERIC_IN_EPNUM,
.ReportINEndpointSize = GENERIC_EPSIZE,
.ReportINEndpointDoubleBank = false,
.PrevReportINBuffer = PrevHIDReportBuffer,
.PrevReportINBufferSize = sizeof(PrevHIDReportBuffer),
},
}

LUFA HID Class driver interface configuration and state information. This structure is passed to all HID Class driver functions, so that multiple instances of the same class within a device can be differentiated from one another.

bool LogfileCreateSuccess

logfile successful created

uint16_t EEMEM LoggingInterval500MS_EEPROM = DEFAULT_LOG_INTERVAL

Non-volatile Logging Interval value in EEPROM, stored as a number of 500ms ticks

uint16_t LoggingInterval500MS_SRAM

SRAM Logging Interval value fetched from EEPROM, stored as a number of 500ms ticks

uint8_t oldday

store the day of actual logfile

uint8_t PrevHIDReportBuffer[GENERIC_REPORT_SIZE]

Buffer to hold the previously generated HID report, for comparison purposes inside the HID class driver.

uint8_t rec_started
char recbuf[10]

radio telegram content and assigned variables

bool ReceiverRestart

receiver restart

uint8_t EEMEM Sensor1Correction_EEPROM
int8_t Sensor1Correction_SRAM
int8_t Sensor1MaxValue
int8_t Sensor1MinValue =0
char EEMEM Sensor1Name_EEPROM[8] = DEFAULT_SENSOR1_NAME
char Sensor1Name_SRAM[9]

store name or location sensor 1

int8_t Sensor1PreviousValue
bool Sensor1Received =false
uint8_t EEMEM Sensor2Correction_EEPROM
int8_t Sensor2Correction_SRAM
int8_t Sensor2MaxValue
int8_t Sensor2MinValue
char EEMEM Sensor2Name_EEPROM[8] = DEFAULT_SENSOR2_NAME
char Sensor2Name_SRAM[9]

store name or location and value of sensor 2

int8_t Sensor2PreviousValue
bool Sensor2Received =false
uint16_t Sensor2Timeout

radio timeout counters

int8_t Sensor2Value =0
uint8_t EEMEM Sensor3Correction_EEPROM
int8_t Sensor3Correction_SRAM
int8_t Sensor3MaxValue
int8_t Sensor3MinValue
char EEMEM Sensor3Name_EEPROM[8] = DEFAULT_SENSOR3_NAME
char Sensor3Name_SRAM[9]

store name or location and value of sensor 3

int8_t Sensor3PreviousValue
bool Sensor3Received =false
uint16_t Sensor3Timeout
int8_t Sensor3Value =0
FIL TempLogFile

FAT Fs structure to hold a FAT file handle for the log data write destination.

uint16_t WebEnableCounter

counter for web enable