/*
 Author: Obrtac Tomas  
 Mail: obrtac.tomas@gmail.com
 2017
 */


#include <xc.h>

void Sleep_Funct(void)
{
    OSCCONbits.IDLEN = 0 ; // We will go in to sleep mode
    DSCONHbits.DSEN = 0; // We run deep sleep
    Sleep();  
    WDTCONbits.DS = 0; //Clearing some bits
    DSCONLbits.RELEASE = 0;
}

void Basic_Settings(void)
{
    OSCCONbits.IRCF = 0x0F; //set OSCCON IRCF bits to select OSC frequency=8 Mhz
    OSCCONbits.SCS = 0x02; //set the SCS bits to select internal oscillator block
    ADCON0 = 0;
    ADCON1 = 0x0F;  //Deactivate analog inputs AN0 - AN9
    ANCON0 = 0;
    ANCON1 = 0x0F; // Deactivate rest of analog inputs
    ANCON0bits.PCFG0 = 1; // Configure pins as digital inputs
}

