#ifndef HLAVA_H_INCLUDED

#define HLAVA_H_INCLUDED

// PIC16F18445 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1
#pragma config FEXTOSC = OFF    // External Oscillator mode selection bits (Oscillator not enabled)
#pragma config RSTOSC = HFINT1  // Power-up default value for COSC bits (HFINTOSC (1MHz))
#pragma config CLKOUTEN = OFF   // Clock Out Enable bit (CLKOUT function is disabled; i/o or oscillator function on OSC2)
#pragma config CSWEN = ON       // Clock Switch Enable bit (Writing to NOSC and NDIV is allowed)
#pragma config FCMEN = OFF      // Fail-Safe Clock Monitor Enable bit (FSCM timer disabled)

// CONFIG2
#pragma config MCLRE = OFF      // Master Clear Enable bit (MCLR pin function is port defined function)
#pragma config PWRTS = OFF      // Power-up Timer Enable bit (PWRT off)
#pragma config LPBOREN = OFF    // Low-Power BOR enable bit (ULPBOR disabled)
#pragma config BOREN = ON       // Brown-out reset enable bits (Brown-out Reset Enabled, SBOREN bit is ignored)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (VBOR) set to 2.45V)
#pragma config ZCD = OFF        // Zero-cross detect disable (Zero-cross detect circuit is disabled at POR.)
#pragma config PPS1WAY = OFF    // Peripheral Pin Select one-way control (The PPSLOCK bit can be set and cleared repeatedly by software)
#pragma config STVREN = OFF     // Stack Overflow/Underflow Reset Enable bit (Stack Overflow or Underflow will not cause a reset)

// CONFIG3
#pragma config WDTCPS = WDTCPS_31// WDT Period Select bits (Divider ratio 1:65536; software control of WDTPS)
#pragma config WDTE = OFF       // WDT operating mode (WDT Disabled, SWDTEN is ignored)
#pragma config WDTCWS = WDTCWS_7// WDT Window Select bits (window always open (100%); software control; keyed access not required)
#pragma config WDTCCS = SC      // WDT input clock selector (Software Control)

// CONFIG4
#pragma config BBSIZE = BB16K   // Boot Block Size Selection bits (* half of user program memory)
#pragma config BBEN = OFF       // Boot Block Enable bit (Boot Block disabled)
#pragma config SAFEN = OFF      // SAF Enable bit (SAF disabled)
#pragma config WRTAPP = OFF     // Application Block Write Protection bit (Application Block not write protected)
#pragma config WRTB = ON        // Boot Block Write Protection bit (Boot Block write protected)
#pragma config WRTC = OFF       // Configuration Register Write Protection bit (Configuration Register not write protected)
#pragma config WRTD = OFF       // Data EEPROM write protection bit (Data EEPROM NOT write protected)
#pragma config WRTSAF = OFF     // Storage Area Flash Write Protection bit (SAF not write protected)
#pragma config LVP = OFF         // Low Voltage Programming Enable bit (High Voltage on MCLR/Vpp must be used for programming)

// CONFIG5
#pragma config CP = OFF         // UserNVM Program memory code protection bit (UserNVM code protection disabled)
    


#include <xc.h>
#include <stdio.h>
#include "ADC,odpor,baterie,teplota.h"
#include "DIA+EEPROM.h"
#include "digit_7segment_3dig.h"
#include "error_handle.h"
#include "menu.h"
#include "PWM_vykon.h"
#include "uart.h"


#define _XTAL_FREQ 32000000

#define tl_plus RC0
#define tl_min RC2
#define tl_sel RC1
#define tl_fire RB7

#define bcr_on LATC6 = 0
#define bat_on LATC3 = 1
#define bcr_off LATC6 = 1
#define bat_off LATC3 = 0
#define bcr_on_flag  RC6 == 0 
#define bat_on_flag  RC3 == 1 

unsigned char i; //** pro for() funkce
unsigned char n = 0; //pomocna pro udelani mereni baterie po zhaveni jen jednou
unsigned int sleep_timer = 0; //pocitadlo pro vypnti zdroje proudu a displeje
__bit fire = 0; //flag pro zhaveni


void reg_init(void); //nastaveni vsech registru a periferii´


#endif // HLAVA_H_INCLUDED
