/*************************************************************************
Hardware profile
**************************************************************************
FileName:        hardwareProfile.h
Dependencies:    None
Processor:       PIC32

Complier:        MPLAB C Compiler for PIC32 v1.04
                 MPLAB IDE v8.15 or higher
Company:         Microchip Technology, Inc.

Copyright (c) 2008 Microchip Technology, Inc.
Software License Agreement

The software supplied herewith by Microchip Technology Incorporated
(the “Company”) for its PIC32 Microcontroller is intended
and supplied to you, the Company’s customer, for use solely and
exclusively on Microchip PIC32 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.

**************************************************************************
 Change History:
 ID     Date            Changes
 C11842 10/15/2008      Modified for 80MHz operation, Updated comments
**************************************************************************/

#ifndef _HARDWARE_PROFILE_H_
#define _HARDWARE_PROFILE_H_

#ifndef SYS_CLOCK
    #error "Define SYS_CLOCK (ex. -DSYS_CLOCK=80000000) on compiler command line"
#endif

#define CLOCK_FREQ                  SYS_CLOCK
#define GetSystemClock()            SYS_CLOCK
#define GetPeripheralClock()        SYS_CLOCK

/** LED **************************************/
#define LED1                        BIT_0
#define LED2                        BIT_1
#define LED3                        BIT_2

#define InitAllLEDs()               (mPORTDClearBits(LED1 | LED2 | LED3), \
                                     mPORTDSetPinsDigitalOut(LED1 | LED2 | LED3) )
                                    
#define mLED_1                      PORTDbits.RD0
#define mLED_2                      PORTDbits.RD1
#define mLED_3                      PORTDbits.RD2
                                    
#define mLED_1_On()                 (LATDSET = LED1)
#define mLED_2_On()                 (LATDSET = LED2)
#define mLED_3_On()                 (LATDSET = LED3)
                                    
#define mLED_1_Off()                (LATDCLR = LED1)
#define mLED_2_Off()                (LATDCLR = LED2)
#define mLED_3_Off()                (LATDCLR = LED3)
                                    
#define mLED_1_Toggle()             (LATDINV = LED1)
#define mLED_2_Toggle()             (LATDINV = LED2)
#define mLED_3_Toggle()             (LATDINV = LED3)

/** BUTTONS AND CHANGE NOTICE *********************/
#define SW1                         BIT_6
#define SW2                         BIT_7
#define SW3                         BIT_13
#define PU15                        CN15_PULLUP_ENABLE
#define PU16                        CN16_PULLUP_ENABLE
#define PU19                        CN19_PULLUP_ENABLE

#define InitAllSwitches()           mPORTDSetPinsDigitalIn(SW1 | SW2 | SW3),\
                                    ConfigCNPullups(PU15 | PU16 | PU19)
                                    
#define mGetSW1                     mPORTDReadBits(SW1)
#define mGetSW2                     mPORTDReadBits(SW2)
#define mGetSW3                     mPORTDReadBits(SW3)

/** USER DEBUG MESSAGE *********************************/
#define PIC32_STARTER_KIT
#include "db_utils.h"
#define InitMessages()          DBINIT()
#define SendMessage(l,m)        DBPUTS(m)
#define SendMessage1()          DBPUTS("**** PIC32 USB Starter Kit Generic Host Demo ****")
#define SendMessage2()          DBPUTS("Attach Device and press SW1 to read Temp and Pot Data.")
       
/*************************
 * Appliation Parameters *
 *************************/
 
#define NORMAL_BLINK_INTERVAL       100     // ms
#define ERROR_BLINK_INTERVAL        50      // ms
#define MAX_ALLOWED_CURRENT         100     // mA
                                    
#define MSG_LENGTH                  19      // Includes '\n' & NULL


#endif  //hardware_profile

