/* Microchip Technology Inc. and its subsidiaries.  You may use this software 
 * and any derivatives exclusively with Microchip products. 
 * 
 * THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS".  NO WARRANTIES, WHETHER 
 * EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED 
 * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A 
 * PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION 
 * WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION. 
 *
 * IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, 
 * INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND 
 * WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS 
 * BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE 
 * FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS 
 * IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF 
 * ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
 *
 * MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE 
 * TERMS. 
 */
#ifndef MACROS_H
#define	MACROS_H

#ifdef	__cplusplus
extern "C" {
#endif

#define CLC_logic_1_Initialize() CLC1CONbits.EN = 1;\
                    CLC2CONbits.EN = 1;\
                    CLC3CONbits.EN = 1;\
                    CLC4CONbits.EN = 1;\
                    CLC1POLbits.G4POL = 1;\
                    CLC1POLbits.G4POL = 0;\
                    CLC2POLbits.G3POL = 1;\
                    CLC2POLbits.G3POL = 0;\
                    CLC3POLbits.G3POL = 1;\
                    CLC3POLbits.G3POL = 0

#define CLC_logic_0_Initialize() CLC5CONbits.EN = 1
    
#define CLC_logic_1_Stop() CLC1CONbits.EN = 0;\
                    CLC2CONbits.EN = 0;\
                    CLC3CONbits.EN = 0;\
                    CLC4CONbits.EN = 0

#define CLC_logic_0_Stop() CLC5CONbits.EN = 0
    
#define TurnOffSliderLEDs() SLED6_SetHigh();\
                            SLED5_SetHigh();\
                            SLED4_SetHigh();\
                            SLED3_SetHigh();\
                            SLED2_SetHigh();\
                            SLED1_SetHigh()

#define TurnOnSliderLED1() SLED6_SetLow();\
                            SLED5_SetHigh();\
                            SLED4_SetHigh();\
                            SLED3_SetHigh();\
                            SLED2_SetHigh();\
                            SLED1_SetHigh()    

#define TurnOnSliderLED2() SLED6_SetLow();\
                            SLED5_SetLow();\
                            SLED4_SetHigh();\
                            SLED3_SetHigh();\
                            SLED2_SetHigh();\
                            SLED1_SetHigh() 
    
#define TurnOnSliderLED3() SLED6_SetLow();\
                            SLED5_SetLow();\
                            SLED4_SetLow();\
                            SLED3_SetHigh();\
                            SLED2_SetHigh();\
                            SLED1_SetHigh() 

#define TurnOnSliderLED4() SLED6_SetLow();\
                            SLED5_SetLow();\
                            SLED4_SetLow();\
                            SLED3_SetLow();\
                            SLED2_SetHigh();\
                            SLED1_SetHigh()    

#define TurnOnSliderLED5() SLED6_SetLow();\
                            SLED5_SetLow();\
                            SLED4_SetLow();\
                            SLED3_SetLow();\
                            SLED2_SetLow();\
                            SLED1_SetHigh() 
    
#define TurnOnSliderLED6() SLED6_SetLow();\
                            SLED5_SetLow();\
                            SLED4_SetLow();\
                            SLED3_SetLow();\
                            SLED2_SetLow();\
                            SLED1_SetLow() 
    
#define DSM_SRC_Set(x) MDSRC = x
    
#define TIMER0_PR_4_5ms() T0CON1bits.T0CKPS= 0b1000 //clock prescaler 1:256 for period of 4.5 ms with TMRH 0x8C   
#define TIMER0_PR_562_5us() T0CON1bits.T0CKPS= 0b0101 //clock prescaler 1:32 for period of 562.5 us with TMRH 0x8C 
#define DisableTMR0Intr() PIE0bits.TMR0IE = 0
#define EnableTMR0Intr() PIE0bits.TMR0IE = 1

#ifdef	__cplusplus
}
#endif

#endif	/* MACROS_H */

