/*********************************************************************

         Microchip Generic Function Demo Firmware Version 1.0
                
Filename:        user.h
Dependancies:    See "Includes" section, below.
Processor:       PIC32MX
Hardware:        Refer to AN1166 - USB Generic Function on an Embedded 
                 device
Assembler:       pic32-gcc
Linker:          pic32-ld
Company:         Microchip Technology, Inc.

Software License Agreement

The software supplied herewith by Microchip Technology Incorporated
(the “Company”) for its PICmicro® Microcontroller is intended and
supplied to you, the Company’s customer, for use solely and
exclusively on Microchip PICmicro Microcontroller products. The
software is owned by the Company and/or its supplier, and is
protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the
user to criminal sanctions under applicable laws, as well as to
civil liability for the breach of the terms and conditions of this
license.

THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 ********************************************************************/

#ifndef __USER_H__
#define __USER_H__

/** I N C L U D E S **********************************************************/
// None

/** D E F I N I T I O N S ****************************************************/

/* Generic USB Function Demo Version 1.0 */
#define MAJOR_VERSION   	0x01
#define MINOR_VERSION   	0x00

/* Temperature Mode */
#define TEMP_REAL_TIME  	0x00
#define TEMP_LOGGING    	0x01

/* Device Commands */
#define READ_VERSION     	0x00
#define ID_BOARD         	0x31
#define UPDATE_LED       	0x32
#define SET_TEMP_REAL    	0x33
#define RD_TEMP          	0x34
#define SET_TEMP_LOGGING 	0x35
#define RD_TEMP_LOGGING  	0x36
#define RD_POT           	0x37
#define RESET            	0xFF

/** S T R U C T U R E S ******************************************************/
typedef union DATA_PACKET
{
    BYTE _byte[USBGEN_EP_SIZE];     // For byte access
    WORD _word[USBGEN_EP_SIZE/2];   // For word access(USBGEN_EP_SIZE must be even)
    struct __attribute__((packed)) 
    {
        BYTE CMD;
        BYTE len;
    };
    struct __attribute__((packed)) 
    {
        unsigned :8;
        BYTE ID;
    };
    struct __attribute__((packed)) 
    {
        unsigned :8;
        BYTE led_num;
        BYTE led_status;
    };
    struct __attribute__((packed)) 
    {
        unsigned :8;
        WORD word_data;
    };
} DATA_PACKET;


/** P U B L I C  P R O T O T Y P E S *****************************************/
void UserInit(void);
void ProcessIO(void);


#endif // __USER_H__
