;*****************************************************************************************
;******** КОНФИГУРИРОВАНИЕ КОНТРОЛЛЕРА ********************************************
;GP1 kn-mss  GP0 on/off mss
;GP3 kn-slvik GP2 on/off auto/manual slvik
;****** Калибровка Генератора **************************************************************
start        
processor 10F200
include <p10f200.inc>

  __CONFIG   _CP_OFF  & _MCLRE_Off & _WDT_OFF
Reg_1 equ 0x10
Reg_2 equ 0x11
Reg_3 equ 0x12
xxx1 equ 0x13
xxx2 equ 0x14
xxx3 equ 0x15
xxx4 equ 0x16
xxx5 equ 0x17

  org 0x00
  
  clrf GPIO
  movlw b'1010'
  tris GPIO
  movlw 0x00
  option
  
  clrf GPIO
  
Start2

	
	
	btfsc	GPIO,GP1
	call	mss
	
	btfss	GPIO,GP3
	call	slvik
	
	
	goto	Start2
	
;=======================================
slvik	call	p05c		;короткое/длинное нажатие
	btfss 	GPIO, GP3
	goto	onoff		;вкл/выкл
	goto	ra		;ручной/автомат
;-----------------------------
onoff	btfss 	GPIO,GP2   	;ручной/автомат вкл/выкл?
	goto	on22
	goto	off22
;---------
on22	bsf 	GPIO,GP2		
	call 	p200ms
	bcf 	GPIO,GP2
	call 	p200ms
	bsf	GPIO, GP2
	call	p200ms 
mp2	btfss 	GPIO,GP3
	goto	mp2		 
	return
;---------
off22	bcf	GPIO, GP2
	call	p200ms 
	bsf	GPIO, GP2
	call	p200ms 
mp22	btfss 	GPIO,GP3
	goto	mp22
	return
;-----------------------------
	
ra	btfss 	GPIO,GP2
	goto	on2
	goto	off2
	
on2	bsf 	GPIO,GP2
	call 	p200ms 
	return
	
off2	bcf	GPIO, GP2
	call	p200ms 
	return
;=======================================
 	
	
	
	
	
	
;=======================================
mss	btfsc 	GPIO, GP1
	goto	mss
;-----------------------------
	
	btfss 	GPIO, GP0
	goto	on
	goto	off
	
on	bsf 	GPIO, GP0
	call 	p200ms 
	return
	
off	bcf	GPIO, GP0
	call	p200ms 
	return
;=======================================
 



;=========================================
p05c	  movlw       .85
            movwf       Reg_1
            movlw       .138
            movwf       Reg_2
            movlw       .3
            movwf       Reg_3
            decfsz      Reg_1,F
            goto        $-1
            decfsz      Reg_2,F
            goto        $-3
            decfsz      Reg_3,F
            goto        $-5
            nop
            nop
            return

p200ms         
	  movlw       .186
            movwf       Reg_1
            movlw       .4
            movwf       Reg_2
            movlw       .2
            movwf       Reg_3
            decfsz      Reg_1,F
            goto        $-1
            decfsz      Reg_2,F
            goto        $-3
            decfsz      Reg_3,F
            goto        $-5
            nop
            return  
   end

