.include "m16def.inc"


.equ 	UP_BORDER	=88	;предельное значение + 1

.equ 	err_kbr_timeout =0x19
.equ 	err_kbr_no_open =0x10

.equ 	err_key1	=0x11
.equ 	err_key2	=0x12
.equ 	err_key3	=0x13
.equ 	err_key4	=0x14
.equ 	err_key5	=0x15
.equ 	err_key6	=0x16
.equ 	err_key7	=0x17
.equ 	err_key8	=0x18




.equ 	err_noR_key1	=0x21
.equ 	err_noR_key2	=0x22
.equ 	err_noR_key3	=0x23
.equ 	err_noR_key4	=0x24
.equ 	err_noR_key5	=0x25
.equ 	err_noR_key6	=0x26
.equ 	err_noR_key7	=0x27
.equ 	err_noR_key8	=0x28

.equ 	err_S_key_base	=0x30

.equ 	err_S_key1	=0x31
.equ 	err_S_key2	=0x32
.equ 	err_S_key3	=0x33
.equ 	err_S_key4	=0x34
.equ 	err_S_key5	=0x35
.equ 	err_S_key6	=0x36
.equ 	err_S_key7	=0x37
.equ 	err_S_key8	=0x38








;.equ	size_IR_buf	=255

.equ	size_com_buf		=200
.equ	size_rd_buf		=200
;.equ	size_temp_buf_cmd	=40
.equ	size_temp_buf		=200
.equ	size_kbr_stack		=4	;реальный размер 5 байт, включая "kbr_stack_top"


;.def	tmp1		=r1	;
;.def	tmp2		=r2	;
;.def	tmp3		=r3	;
;.def	tmp4		=r4	;
.def	temp8		=r5	;
.def	temp7		=r6	;
.def	default_key_data =r7	;
.def	temp6		=r8	;
.def	input_selector	=r9	;
.def	tout_count	=r10	;
.def	temp4	=r11	;
.def	err_ind		=r12
.def	selector_device	=r13
.def	timer1		=r14	;
.def	count_tout	=r15	;

.def	temp5		=r16	;
.def	temp2		=r17	;
.def	temp1		=r18
.def	temp		=r19	;
.def	temp3		=r20	;
.def	counter		=r21	;
.def	FL1		=r22	;
.def	FL2		=r23	;
.def	FL3		=r24	;
.def	FL4		=r25


.def	spmcrval	=r25

;.def	copyL	=r1		;temporary register
;.def	copyH	=r2		;temporary register
;.def	mp10L	=r3		;Low byte of number to be multiplied by 10  Low byte of binary result (same as mp10L)
;.def	mp10H	=r4		;High byte of number to be multiplied by 10  High byte of binary result (same as mp10H)
;.def	adder	=r5		;value to add after multiplication	

;.def	fBCD2	=r6		;BCD value digits 1 and 0
;.def	fBCD1	=r7		;BCD value digits 2 and 3
;.def	fBCD0	=r8		;BCD value digit 5



;-- DIP40 -------

;-----PORTA--------------

.equ	pinIO1		=0	;pin 40
.equ	pinIO2		=1	;pin 39  
.equ	pinIO3		=2	;pin 38
.equ	pinIO4		=3	;pin 37
.equ	pinIO5		=4	;pin 36 
.equ	pinIO6		=5	;pin 35 ;sda_pin
.equ	pinIO7		=6	;pin 34 ;scl_pin 
.equ	pinIO8		=7	;pin 33 ;	


;-----PORTB--------------

.equ	DATA4094	=0	;pin 1
.equ	CLK4094		=1	;pin 2  
.equ	STR4094		=2	;pin 3
.equ	cs_flash	=3	;pin 4
.equ	cs_flash2	=4	;pin 5 
;.equ			=5	;pin 6 MOSI
;.equ			=6	;pin 7 MISO 
;.equ			=7	;pin 8 SCK

;-----PORTC--------------

;.equ	scl_pin		=0	;pin 22 1нога DB9 green
;.equ	sda_pin		=1	;pin 23 4нога DB9 red
;.equ			=2	;pin 24 
;.equ			=3	;pin 25 
;.equ			=4	;pin 26 
.equ	pusk		=5	;pin 27 
.equ	clk_164		=6	;pin 28 
.equ	E_PIN		=7	;pin 29 


;-----PORTD--------------

.equ	RXD		=0	;pin 14
.equ	TXD		=1	;pin 15 
.equ	LED_OUT1	=2	;pin 16 
.equ	LED_OUT2	=3	;pin 17	
.equ	LED_OUT3	=4	;pin 18 (as IR input)
.equ	CTS		=5	;pin 19
.equ	SEL_RS232	=6	;pin 20 
.equ	IR_LED_OUT	=7	;pin 21 



.dseg

.org	$100


buf4094_out: 		.BYTE 1
buf4094_pinIO:	 	.BYTE 1

flash_page_adrL:	.BYTE 1
flash_page_adrH:	.BYTE 1


key1_dataH:	.byte 1
key1_dataL:	.byte 1
key2_dataH:	.byte 1
key2_dataL:	.byte 1	
key3_dataH:	.byte 1
key3_dataL:	.byte 1
key4_dataH:	.byte 1
key4_dataL:	.byte 1
key5_dataH:	.byte 1
key5_dataL:	.byte 1
key6_dataH:	.byte 1
key6_dataL:	.byte 1
key7_dataH:	.byte 1
key7_dataL:	.byte 1
key8_dataH:	.byte 1
key8_dataL:	.byte 1
key_set:	.byte 1		
key_mode1:	.byte 1

;rd_buf:		.byte 10

;key_mode2:	.byte 1
;key_mode3:	.byte 1






kbr_search_buf:		.BYTE 8

kbr_buf:	.BYTE	5
rd_buf:		.BYTE 	size_rd_buf
temp_buf: 	.BYTE 	size_temp_buf
com_buf: 	.BYTE 	size_com_buf

lcd_buf:		.BYTE 60
lcd_buf_page_name:	.BYTE 30	

VFD_BUFFER:		.BYTE 20

dd1:		.BYTE 1
ram_temp1:		.BYTE 1
temp_H: 		.BYTE 1
temp_L: 		.BYTE 1














.cseg
;---------bits of FL1-----------
.equ	f_t0		=0b00000001		;1- переполнение ТС0
.equ	f_t1		=0b00000010		;
.equ	f_err_step	=0b00000100		;1- ошибка в шаге 
.equ	f_sec1		=0b00001000		;
.equ	f_an_par	=0b00010000		;1- прочитать параметр
.equ	f_overpress	=0b00100000		;
.equ	f_rd_kbr	=0b01000000		;
.equ	f_sec100ms	=0b10000000		;

;---------pos bits of FL1-----------
.equ	fp_t0		=0		;
.equ	fp_t1		=1		;
.equ	fp_err_step	=2		;
.equ	fp_sec1		=3		;
.equ	fp_an_par	=4		;
.equ	fp_overpress	=5		;
.equ	fp_rd_kbr	=6		;
.equ	fp_sec100ms	=7		;



;---------bits of FL2-----------
.equ	f_tempF1	=0b00000001	;1- 
.equ	f_tempF2	=0b00000010	;1- 
;.equ	f_tempF3	=0b00000100	;1- 
;.equ	f_an_minomet	=0b00001000	;1- 
;.equ	f_en_out	=0b00010000	;1-
;.equ	f_tout		=0b00100000	;
;.equ	f_en_tout	=0b01000000	;
;.equ	f_ate0		=0b10000000	;1- 

;---------pos bits of FL2-----------
.equ	fp_tempF1	=0		;
.equ	fp_tempF2	=1		;
;.equ	fp_ext_key	=2		;
;.equ	fp_an_minomet	=3		
;.equ	fp_en_out	=4		;
;.equ	fp_tout		=5		;
;.equ	fp_en_tout	=6		;
;.equ	fp_ate0		=7		;




;---------bits of FL3-----------
.equ	f_flash_ln1	=0b00000001	;1- 
.equ	f_sec		=0b00000010	;1- 
.equ	f_flash_ln2	=0b00000100	;1- 
.equ	f_init_lcd	=0b00001000	;1- 
;.equ	f_	=0b00010000	;1-
;.equ	f_	=0b00100000	;
.equ	f_ack	=0b01000000	;
.equ	f_tout	=0b10000000	;1- 

;---------pos bits of FL3-----------
.equ	fp_flash_ln1	=0		;
.equ	fp_sec		=1		;
.equ	fp_flash_ln2	=2		;
.equ	fp_init_lcd	=3		
;.equ	fp_	=4		;
;.equ	fp_	=5		;
.equ	fp_ack	=6		;
.equ	fp_tout	=7		;




;---------bits of FL4-----------
;.equ	f_flash_ln1	=0b00000001	;1- 
;.equ	f_ack		=0b00000010	;1- 
;.equ	f_flash_ln2	=0b00000100	;1- 
;.equ	f_init_lcd	=0b00001000	;1- 
;.equ	f_1st_byte	=0b00010000	;1-
;.equ	f_rd_stop	=0b00100000	;
;.equ	f_en_string	=0b01000000	;
;.equ	f_restart	=0b10000000	;1- принята "1"

;---------pos bits of FL4-----------
;.equ	fp_flash_ln1	=0		;
;.equ	fp_ack		=1		;
;.equ	fp_flash_ln2	=2		;
;.equ	fp_init_lcd	=3		
;.equ	fp_1st_byte	=4		;
;.equ	fp_rd_stop	=5		;
;.equ	fp_en_string	=6		;
;.equ	fp_restart	=7		;




;---------bits of FL4-----------
.equ	f_key1		=0b00000001	;
.equ	f_key2		=0b00000010	;
.equ	f_key3		=0b00000100	;
.equ	f_key4		=0b00001000	;
.equ	f_key5		=0b00010000	;
.equ	f_key6		=0b00100000	;
.equ	f_key7		=0b01000000	;
.equ	f_key8		=0b10000000	;

;---------pos bits of FL4-----------
.equ	fp_key1		=0		;
.equ	fp_key2		=1		;
.equ	fp_key3		=2		;
.equ	fp_key4		=3		
.equ	fp_key5		=4		;
.equ	fp_key6		=5		;
.equ	fp_key7		=6		;
.equ	fp_key8		=7		;













;---------bits of buf4094_out -----------
.equ	f_wdt_out	=0b00000001	;
.equ	f_ledG		=0b00000010	;
.equ	f_ledY		=0b00000100	;
.equ	f_ledR		=0b00001000	;
.equ	f_rel1		=0b00010000	;
.equ	f_rel2		=0b00100000	;
.equ	f_rel3		=0b01000000	;
.equ	f_buzzer	=0b10000000	;

;---------pos bits of buf4094_out -----------
.equ	fp_wdt_out	=0		;
.equ	fp_ledG		=1		;
.equ	fp_ledY		=2		;
.equ	fp_ledR		=3		
.equ	fp_rel1		=4		;
.equ	fp_rel2		=5		;
.equ	fp_rel3		=6		;
.equ	fp_buzzer	=7		;



;---------bits of buf4094_pinIO -----------
.equ	f_pinIO0	=0b00000001	;
.equ	f_pinIO1	=0b00000010	;
.equ	f_pinIO2	=0b00000100	;
.equ	f_pinIO3	=0b00001000	;
.equ	f_pinIO4	=0b00010000	;
.equ	f_pinIO5	=0b00100000	;
.equ	f_pinIO6	=0b01000000	;
;.equ	f_pinIO7	=0b10000000	;

;---------pos bits of buf4094_pinIO -----------
.equ	fp_pinIO0	=0
.equ	fp_pinIO1	=1	;
.equ	fp_pinIO2	=2	;
.equ	fp_pinIO3	=3	;
.equ	fp_pinIO4	=4	;
.equ	fp_pinIO5	=5	;
.equ	fp_pinIO6	=6	;
;.equ	fp_pinIO7	=7	;







;.macro	scl_low
;	sbi	ddrd,LED_OUT1
;.endmacro	

;.macro	scl_high
;	cbi	ddrd,LED_OUT1
;.endmacro	


;.macro	sda_low
;	sbi	ddrd,LED_OUT2
;.endmacro	

;.macro	sda_high
;	cbi	ddrd,LED_OUT2
;.endmacro	




.macro	flash_en
	cbi	portb,cs_flash
.endmacro	

.macro	flash_dis
	sbi	portb,cs_flash
.endmacro	



.macro	flash2_en
	cbi	portb,cs_flash2
.endmacro	

.macro	flash2_dis
	sbi	portb,cs_flash2
.endmacro	

;---
.macro	DATA4094_1
	sbi	portb,DATA4094
.endmacro

.macro	DATA4094_0
	cbi	portb,DATA4094
.endmacro

.macro	CLK4094_1
	sbi	portb,CLK4094
.endmacro

.macro	CLK4094_0
	cbi	portb,CLK4094
.endmacro

.macro	STR4094_1
	sbi	portb,STR4094
.endmacro

.macro	STR4094_0
	cbi	portb,STR4094
.endmacro


;.macro	RTS_ON
;	cbi	portd,RTS
;.endmacro

;.macro	RTS_OFF
;	sbi	portd,RTS
;.endmacro



.macro	RS232_COMP
	sbi	portd,SEL_RS232
.endmacro

.macro	RS232_MIK21
	cbi	portd,SEL_RS232
.endmacro




.macro	clk_164_1
	sbi	portc,clk_164
.endmacro	

.macro	clk_164_0
	cbi	portc,clk_164
.endmacro	




.macro	lcd_E_pin_1
	sbi	portc,E_PIN
.endmacro	

.macro	lcd_E_pin_0
	cbi	portc,E_PIN
.endmacro	


.macro	IR_LED_ON
	sbi	portd,IR_LED_OUT
.endmacro	

.macro	IR_LED_OFF
	cbi	portd,IR_LED_OUT
.endmacro	
;-------------

.macro	TEST0_IR_IN
	sbic	pind,LED_OUT3
.endmacro	

.macro	TEST1_IR_IN
	sbis	pind,LED_OUT3
.endmacro	





;-------------
.macro	LED_OUT1_ON
	sbi	portd,led_out1
.endmacro	

.macro	LED_OUT1_OFF
	cbi	portd,led_out1
.endmacro	
;-------------

.macro	LED_OUT2_ON
	sbi	portd,led_out2
.endmacro	

.macro	LED_OUT2_OFF
	cbi	portd,led_out2
.endmacro
;-------------

.macro	LED_OUT3_ON
	sbi	portd,led_out3
.endmacro	

.macro	LED_OUT3_OFF
	cbi	portd,led_out3
.endmacro	
;-------------




		

;		lds	temp,buf4094_out
;		cbr	temp,f_REL3	;Relay3 ON
;		sts	buf4094_out,temp	
;		call	control_outs








;+++++++++++++ SYMBOLS ++++++++++++++++++++++++++++


.equ 	_sp	=0x20	; 
.equ 	_kwl	=0x28	;(
.equ 	_kwr	=0x29	;)
.equ 	_zw	=0x2A	; * 
.equ 	_pl	=0x2B	; + 
.equ 	_mi	=0x2D	; - 
.equ 	_sl	=0x2F	; / 
.equ 	_eq	=0x3D	; =
.equ 	_ddp	=0x3A	; : 
.equ 	_dzp	=0x3B	; ; 
.equ 	_kwe	=0x3F	; ?
.equ 	_dp	=0x2E	; . 
.equ 	_zp	=0x2C	; , 
.equ 	_kw	=0x22	; " 
.equ 	_strl	=0x3C	;< 
.equ 	_strr	=0x3E	;> 
.equ 	_bell	=0xED	;>
.equ 	_esc	=0x7E	;ESC
.equ 	_stru	=0xD9	;
.equ 	_strd	=0xDA	;

.equ 	_CR	=0x0D	;
.equ 	_LF	=0x0A	;


.equ 	_0	=0x30	;
.equ 	_1	=0x31	;
.equ 	_2	=0x32	;
.equ 	_3	=0x33	;
.equ 	_4	=0x34	;
.equ 	_5	=0x35	;
.equ 	_6	=0x36	;
.equ 	_7	=0x37	;
.equ 	_8	=0x38	;
.equ 	_9	=0x39	;
.equ 	_A	=0x41	;
.equ 	_B	=0x42	;
.equ 	_C	=0x43	;
.equ 	_D	=0x44	;
.equ 	_E	=0x45	;
.equ 	_F	=0x46	;
.equ 	_G	=0x47	;
.equ 	_H	=0x48	;
.equ 	_I	=0x49	;
.equ 	_J	=0x4A	;
.equ 	_K	=0x4B	;
.equ 	_L	=0x4C	;
.equ 	_M	=0x4D	;
.equ 	_N	=0x4E	;
.equ 	_O	=0x4F	;
.equ 	_P	=0x50	;
.equ 	_Q	=0x51	;
.equ 	_R	=0x52	;
.equ 	_S	=0x53	;
.equ 	_T	=0x54	;
.equ 	_U	=0x55	;
.equ 	_V	=0x56	;
.equ 	_W	=0x57	;
.equ 	_X	=0x58	;
.equ 	_Y	=0x59	;
.equ 	_Z	=0x5A	;


.equ 	_Am	=0x61	;
.equ 	_Bm	=0x62	;
.equ 	_Cm	=0x63	;
.equ 	_Dm	=0x64	;
.equ 	_Em	=0x65	;
.equ 	_Fm	=0x66	;
.equ 	_Gm	=0x67	;
.equ 	_Hm	=0x68	;
.equ 	_Im	=0x69	;
.equ 	_Jm	=0x6A	;
.equ 	_Km	=0x6B	;
.equ 	_Lm	=0x6C	;
.equ 	_Mm	=0x6D	;
.equ 	_Nm	=0x6E	;
.equ 	_Om	=0x6F	;
.equ 	_Pm	=0x70	;
.equ 	_Qm	=0x71	;
.equ 	_Rm	=0x72	;
.equ 	_Sm	=0x73	;
.equ 	_Tm	=0x74	;
.equ 	_Um	=0x75	;
.equ 	_Vm	=0x76	;
.equ 	_Wm	=0x77	;
.equ 	_Xm	=0x78	;
.equ 	_Ym	=0x79	;
.equ 	_Zm	=0x7A	;














;----------------------------
.org	0
		rjmp	start_program	 
;-------------------------------
;.org	INT0addr
;		jmp	inter_int1
;-------------------------------
;.org	OC1Baddr
;		rjmp	int_OC1B
;----------------------------------
;.org	OVF1addr
;		jmp	timer1_int
;----------------------------	
.org	OVF0addr
		jmp	timer0_int	
;----------------------------


.org	0x003f
	.DB	_0,_A		;идентификатор модели изделия (for bootloader)


	
.org	0x0040		

start_program:
;start:		




	;----- очистка регистров --------
		ldi	zh,0
		ldi	zl,1	;начать очистку с "r1"
		ldi	temp,29	;очистить 29 регистров
		mov	r0,temp
		ldi	temp,0

reg_clr0:	st	z,temp
		inc	zl
		dec	r0
		brne	reg_clr0


		ldi	zh,high($60)
		ldi	zl,low($60)
		
		ldi	counter,255
		ldi	temp,0


start_reg3:	st	z+,temp
		dec	counter
		brne	start_reg3

	;---------подготовка порта A -----
		ldi	temp,0b00000000
		out	DDRA,temp

		ldi	temp,0b00000000	
		out	PORTA,temp

	;---------подготовка порта B -----
		ldi	temp,0b10111111
		out	DDRB,temp

		ldi	temp,0b11111000	
		out	PORTB,temp

	;---------подготовка порта C -----
		ldi	temp,0b11000000
		out	DDRC,temp

		ldi	temp,0b00011100	
		out	PORTC,temp
		
	;---------подготовка порта D -----
		ldi	temp,0b11000010
		out	DDRD,temp
		ldi	temp,0b01100011
		out	PORTD,temp	


		;----------инициализация UART----
		ldi	temp,0b00011000		;RX & TX enable
		out	ucsrb,temp		;

;		;init value of "ucsrc"  -  8 bit mode of Character size

		ldi	temp,51		;9.6 kbit/s
		out	ubrrl,temp		;
;
		;----------инициализация WDT----
;		ldi	temp,0b00011111
;		out	WDTCR,temp		;включить WDT с макс. интервалом



		ldi	temp,low(ramend)		
		out	spl,temp 	;определить стек		
		
		ldi	temp,high(ramend)		
		out	sph,temp 	;определить стек


		;----------инициализация TC0 и TC1----
		
		ldi	temp,0b00000001	;
		out	timsk,temp

		ldi	temp,0b00000101	;разрешить работу счетчика TC0, к=1024 
		out	tccr0,temp	;
		
		wdr
		

		;---- SPI_MasterInit ---------------

;		ldi 	temp,0b01010001		;Enable SPI, Master, set clock rate fck/16
;		out 	SPCR,temp





		sei

;		call	tr_string000	;


		;jmp	test_led35_000

rrrr:

		ldi	temp,low(ramend)		
		out	spl,temp 	;определить стек		
		
		ldi	temp,high(ramend)		
		out	sph,temp 	;определить стек



		rcall	init_LED

		lds	temp,buf4094_out
		cbr	temp,f_buzzer	;buzzer ON
		sbr	temp,f_ledR
		sbr	temp,f_ledG
		sbr	temp,f_ledY
		sts	buf4094_out,temp
	
		ldi	temp,0xFF
		sts	buf4094_pinIO,temp
	
		call	control_outs



		ldi	temp,1
		rcall	time_delay


	


		rcall	init_LED

		;jmp	scan_IIC

	;-------- INIT LCD -------------------------
		call	init_LCD



		
		ldi	zh,high(2*lcd_string_start1)		;
		ldi	zl,low(2*lcd_string_start1)
;		call	remov_d2lcdBuf_ln1

;		ldi	zh,high(2*lcd_string_start2)		;
;		ldi	zl,low(2*lcd_string_start2)
		rcall	trTWOline2lcd


		RS232_COMP

	;------ проверка FLASH MEM ----------
;		cbr	fl2,f_cs2
;		call	RdStatReg	;проверка на исправность DATA FLASH
	
;		cpi	temp,$A4
;		breq	test_flash_OK
	
;		ldi	zh,high(2*lcd_string_start4)		;
;		ldi	zl,low(2*lcd_string_start4)
;		call	remov_d2lcdBuf_ln2
;		sbr	fl3,f_flash_ln2
;		call	tr_data2lcd

;test_flash_ERR:	rcall	error_ind
;		rjmp	test_flash_ERR
	;------------------------------------
test_flash_OK:

		ldi	temp,10
		rcall	time_delay


		ldi	zh,high(2*lcd_string_start5)		;
		ldi	zl,low(2*lcd_string_start5)
		rcall	trTWOline2lcd
	


		ldi	temp,10
		rcall	time_delay



		ldi	zl,low(prof_mem)
		ldi	zh,high(prof_mem)

		call	LOAD_EE_DATA
		mov	temp3,temp	

		dec	temp3

		
		;ldi	temp,0b11111111
		;sts	key_set,temp
		
		;ldi	temp,0b00000010
		;sts	key_mode1,temp
		;ldi	temp3,35
		;rjmp	ddd



sel_dev1:	rcall	wait_press_key
		brcs	sel_dev3


		rcall	short_beep


		ldi	zh,high(2*blanc_screen)		;
		ldi	zl,low(2*blanc_screen)

		rcall	trTWOline2lcd

		ldi	temp,2
		rcall	time_delay

		inc	temp3		
		cpi	temp3,UP_BORDER		;предельное значение + 1
		brne	sel_dev2

		ldi	temp3,1
	
sel_dev2:
		rcall	calc_adrLN	
		rjmp	sel_dev1

sel_dev3:	ldi	zh,high(2*lcd_string_ready)		;
		ldi	zl,low(2*lcd_string_ready)
		call	remov_d2lcdBuf_ln2
		sbr	fl3,f_flash_ln2
		call	tr_data2lcd

		rcall	wait_press_key2


		call	prepare_buf
		call	prep_IO



		ldi	temp,12		;38.4 kbit/s
		out	ubrrl,temp		;


;--------------------------------------------------------
main:		rcall	wait_ft0




main1:		rcall	wait_unpress_pusk

ddd:

		ldi	zh,high(2*lcd_string_testON)		;
		ldi	zl,low(2*lcd_string_testON)
		call	remov_d2lcdBuf_ln2
		sbr	fl3,f_flash_ln2
		call	tr_data2lcd


		lds	temp,buf4094_out
		sbr	temp,f_ledY	;желтый LED горит
		cbr	temp,f_rel1	;подать питание
		sts	buf4094_out,temp
		rcall	control_outs

		ldi	temp,0
		mov	err_ind,temp





		;rjmp ddd

		
		rcall	testVCC
		brcs	stop_test

		;rcall	test_other
		;brcs	stop_test

		;rcall	test_tuner
		;brcs	stop_test

















		

		rcall	send_IR_test
		brcs	stop_test


		;rjmp ddd

;rrr:		rjmp	rrr


		rcall	test_kbr_key
		brcs	stop_test

		rcall	test_led
		brcs	stop_test






stop_test:	
		

		lds	temp,buf4094_out
		cbr	temp,f_ledY
		sbr	temp,f_rel1	;выключить питание
		cbr	temp,f_buzzer
		sts	buf4094_out,temp
		rcall	control_outs

		tst	err_ind
		brne	main_err

	
		rcall	end_indic

		rjmp	main

;main3:










;		
main_err:	

		ldi	zh,high(2*lcd_string_ERROR)		;
		ldi	zl,low(2*lcd_string_ERROR)
		call	remov_d2lcdBuf_ln2

		ldi	yh,high(lcd_buf+22)	;
		ldi	yl,low(lcd_buf+22)

		ldi	temp1,_0
		mov	temp,err_ind
		swap	temp
		andi	temp,0x0F

;		ldi	temp1,_0
		add	temp,temp1
		st	y+,temp
		
		mov	temp,err_ind
		andi	temp,0x0F

;		ldi	temp1,_0
		add	temp,temp1
		st	y+,temp

		sbr	fl3,f_flash_ln2
		call	tr_data2lcd

		rcall	error_ind



		rcall	wait_unpress_pusk


		ldi	zh,high(2*lcd_string_ready)		;
		ldi	zl,low(2*lcd_string_ready)
		call	remov_d2lcdBuf_ln2
		sbr	fl3,f_flash_ln2
		call	tr_data2lcd



		rjmp	main

;		RJMP	main3

;----------------------------------------
end_indic:
		ldi	zh,high(2*lcd_string_testOK)		;
		ldi	zl,low(2*lcd_string_testOK)
		call	remov_d2lcdBuf_ln2
		sbr	fl3,f_flash_ln2
		call	tr_data2lcd

		lds	temp,buf4094_out
		cbr	temp,f_ledY
		sbr	temp,f_rel1	;выключить питание
		cbr	temp,f_buzzer
		sts	buf4094_out,temp
		rcall	control_outs




		ldi	temp,2
		rcall	time_delay	;0,2 сек продолжительность гудка


		lds	temp,buf4094_out
		sbr	temp,f_buzzer
		sbr	temp,f_rel1	;выключить питание
		sts	buf4094_out,temp
		rcall	control_outs

		ldi	temp,10		;2сек горит надпись "Test OK"
		rcall	time_delay
end_indic_1:
		ldi	zh,high(2*lcd_string_ready)		;
		ldi	zl,low(2*lcd_string_ready)
		call	remov_d2lcdBuf_ln2
		sbr	fl3,f_flash_ln2
		call	tr_data2lcd

		ret
;----------------------------------------
wait_unpress_pusk:
main_err1:	sbic	pinc,pusk
		rjmp	main_err1
		
		ldi	temp,3

main_err2:	rcall	wait_ft0		
		sbic	pinc,pusk
		rjmp	main_err1
	
		dec	temp
		brne	main_err2




main_err11:	sbis	pinc,pusk
		rjmp	main_err11
		
		ldi	temp,3

main_err21:	rcall	wait_ft0		
		sbis	pinc,pusk
		rjmp	main_err11
	
		dec	temp
		brne	main_err21

		ret

;----------------------------------------
short_beep:	rcall	wait_ft0
		lds	temp,buf4094_out
		cbr	temp,f_buzzer	;buzzer ON
		sts	buf4094_out,temp
	
		call	control_outs

		rcall	wait_ft0
		rcall	wait_ft0

		lds	temp,buf4094_out
		sbr	temp,f_buzzer	;buzzer OFF
		sts	buf4094_out,temp
	
		call	control_outs

		ret


;------------------------------------------




;test_other:	lds	temp,key_mode1
;		sbrs	temp,6		;1- проверять провода на замыкания
;		rjmp	test_other_ret	
;
;
;
;test_other3:	cpi	temp3,3
;		breq	test_other3_0
;		rjmp	test_tuner4
;test_other3_0:
;		ldi	temp,0xFF
;		sts	buf4094_pinIO,temp
;		call	control_outs
;
;		rcall	METadc6		;test SCL
;
;		subi	temp,0xA0
;		brcc	test_other3_1
;
;		ldi	temp,0x41
;		rjmp	test_other_ret2
;
;test_other3_1:	rcall	METadc5		;test SDA
;
;		subi	temp,0xA0
;		brcc	test_other3_2
;
;		ldi	temp,0x42
;		rjmp	test_other_ret2
;
;test_other3_2:
;		ldi	temp2,0x30
;		ldi	temp5,0x50
;		rcall	test_borderIN0	;test CVBS
;		brcc	test_other3_3
;		
;		ldi	temp,0x43
;		rjmp	test_other_ret2
;
;
;test_other3_3:	
;		ldi	temp2,0x60
;		ldi	temp5,0x90
;		rcall	test_borderIN1	;test AF
;		brcc	test_other3_4
;		
;		ldi	temp,0x44
;		rjmp	test_other_ret2
;
;
;test_other3_4:
;		ldi	temp2,0xf0
;		ldi	temp5,0xff
;		rcall	test_borderIN2	;test IF
;		brcc	test_other3_5
;		
;		ldi	temp,0x45
;		rjmp	test_other_ret2
;
;test_other3_5:
;		ldi	temp2,0xf0
;		ldi	temp5,0xff
;		rcall	test_borderIN3	;test RxD
;		brcc	test_other3_6
;		
;		ldi	temp,0x46
;		rjmp	test_other_ret2
;
;test_other3_6:
;		ldi	temp2,0xf0
;		ldi	temp5,0xff
;		rcall	test_borderIN4	;test TxD
;		brcc	test_other3_7
;		
;		ldi	temp,0x47
;		rjmp	test_other_ret2
;
;test_other3_7:
;
;		ldi	temp,0xFF
;		cbr	temp,f_pinIO3
;		sts	buf4094_pinIO,temp
;		call	control_outs
;
;
;		ldi	temp2,0x60
;		ldi	temp5,0xA0
;		rcall	test_borderIN4	;test short TxD & RxD
;		brcc	test_other3_8
;		
;		ldi	temp,0x48
;		rjmp	test_other_ret2
;
;test_other3_8:
;		sbic	pind,LED_OUT1
;		rjmp	test_other3_9
;
;		ldi	temp,0x49
;		rjmp	test_other_ret2
;
;test_other3_9:
;
;		rjmp	test_other_ret
;
;		
;test_other4:	;cpi	temp3,4
;		;brne	test_tuner5
;
;
;
;;test_other6:	cpi	temp3,6
;;		brne	test_tuner7
;
;
;
;
;;test_tuner7:
;
;
;
;
;
;test_other_ret2:
;		mov	err_ind,temp
;
;test_other_ret:	clc
;		tst	err_ind
;		breq	test_other_ret1
;		sec
;test_other_ret1:
;		ret
;-------------------------------------
;		rcall	METadc2	
;		out	udr,temp
		
;		ldi	temp,2
;		rcall	time_delay

;		rjmp	test_other3_3


;		rcall	test_borderIN1

;---------------------------------







;-----------------------------------
;test_borderIN0:	
;		ldi	counter,3
;
;test_borderIN0_1:
;		rcall	wait_ft0
;		rcall	METadc0	
;		mov	temp1,temp
;
;		sub	temp,temp2
;		brcc	test_borderIN0_2
;
;test_borderIN0_3:		
;		dec	counter
;		brne	test_borderIN0_1
;		sec	
;		rjmp	test_borderIN0_ret
;
;test_borderIN0_2:
;		sub	temp5,temp1
;		brcs	test_borderIN0_3
;
;test_borderIN0_ret:
;		ret
;-------------------------------------
;test_borderIN1:	
;		ldi	counter,3
;
;test_borderIN1_1:
;		rcall	wait_ft0
;		rcall	METadc1	
;		mov	temp1,temp
;
;		sub	temp,temp2
;		brcc	test_borderIN1_2
;
;test_borderIN1_3:		
;		dec	counter
;		brne	test_borderIN1_1
;		sec	
;		rjmp	test_borderIN1_ret
;
;test_borderIN1_2:
;		sub	temp5,temp1
;		brcs	test_borderIN1_3
;
;test_borderIN1_ret:
;		ret
;-------------------------------------
;test_borderIN2:	
;		ldi	counter,3
;
;test_borderIN2_1:
;		rcall	wait_ft0
;		rcall	METadc2	
;		mov	temp1,temp
;
;		sub	temp,temp2
;		brcc	test_borderIN2_2
;
;test_borderIN2_3:		
;		dec	counter
;		brne	test_borderIN2_1
;		sec	
;		rjmp	test_borderIN2_ret
;
;test_borderIN2_2:
;		sub	temp5,temp1
;		brcs	test_borderIN2_3
;
;test_borderIN2_ret:
;		ret
;-------------------------------------
;test_borderIN3:	
;		ldi	counter,3
;
;test_borderIN3_1:
;		rcall	wait_ft0
;		rcall	METadc3	
;		mov	temp1,temp
;
;		sub	temp,temp2
;		brcc	test_borderIN3_2
;
;test_borderIN3_3:		
;		dec	counter
;		brne	test_borderIN3_1
;		sec	
;		rjmp	test_borderIN3_ret
;
;test_borderIN3_2:
;		sub	temp5,temp1
;		brcs	test_borderIN3_3
;
;test_borderIN3_ret:
;		ret
;-------------------------------------
;test_borderIN4:	
;		ldi	counter,3
;
;test_borderIN4_1:
;		rcall	wait_ft0
;		rcall	METadc4	
;		mov	temp1,temp
;
;		sub	temp,temp2
;		brcc	test_borderIN4_2
;
;test_borderIN4_3:		
;		dec	counter
;		brne	test_borderIN4_1
;		sec	
;		rjmp	test_borderIN4_ret
;
;test_borderIN4_2:
;		sub	temp5,temp1
;		brcs	test_borderIN4_3
;
;test_borderIN4_ret:
;		ret
;-------------------------------------
;test_borderIN5:	
;		ldi	counter,3
;
;test_borderIN5_1:
;		rcall	wait_ft0
;		rcall	METadc5	
;		mov	temp1,temp
;
;		sub	temp,temp2
;		brcc	test_borderIN5_2
;
;test_borderIN5_3:		
;		dec	counter
;		brne	test_borderIN5_1
;		sec	
;		rjmp	test_borderIN5_ret
;
;test_borderIN5_2:
;		sub	temp5,temp1
;		brcs	test_borderIN5_3
;
;test_borderIN5_ret:
;		ret
;-------------------------------------
;test_borderIN6:	
;		ldi	counter,3
;
;test_borderIN6_1:
;		rcall	wait_ft0
;		rcall	METadc6	
;		mov	temp1,temp
;
;		sub	temp,temp2
;		brcc	test_borderIN6_2
;
;test_borderIN6_3:		
;		dec	counter
;		brne	test_borderIN6_1
;		sec	
;		rjmp	test_borderIN6_ret
;
;test_borderIN6_2:
;		sub	temp5,temp1
;		brcs	test_borderIN6_3
;
;test_borderIN6_ret:
;		ret
;------------------------------------

;test_tuner:	lds	temp,key_mode1
;		sbrs	temp,5		;1- проверять тюнер
;		rjmp	test_tuner_ret		
;
;	
;
;test_tuner1:	cpi	temp3,1
;		brne	test_tuner2
;
;		rcall	Htest_tuner
;		brcc	test_tuner_ret1	
;		rjmp	test_tuner_ret2
;		
;test_tuner2:	cpi	temp3,2
;		brne	test_tuner3
;
;
;		rcall	Ttest_tuner
;		brcc	test_tuner_ret1	
;		rjmp	test_tuner_ret2
;
;test_tuner3:	cpi	temp3,3
;		brne	test_tuner4
;		
;		rcall	Etest_tuner
;		brcc	test_tuner_ret1	
;		rjmp	test_tuner_ret2
;
;
;
;test_tuner4:	;cpi	temp3,3
;		;brne	test_tuner4
;
;		rjmp	test_tuner_ret1
;
;test_tuner_ret2:	
;		ldi	temp,5		;no ACK
;		mov	err_ind,temp
;
;		sec
;		rjmp	test_tuner_ret	
;test_tuner_ret1:
;		clc	
;test_tuner_ret:
;		ret
;----------------------------------
testVCC:	lds	temp,key_mode1
		sbrc	temp,1		
		rjmp	testVCC_ret1	;1-не проверять ИК


		ldi	temp,10
		rcall	time_delay


		;rjmp	testVCC_ret1


		ldi	temp1,3

testVCC1:	rcall	METadcVCC

		subi	temp,0x60
		brcc	testVCC_ret1
		rcall	wait_ft0
		dec	temp1
		brne	testVCC1
		
		ldi	temp,1		;Power NG
		mov	err_ind,temp

		sec
		rjmp	testVCC_ret

testVCC_ret1:	clc

testVCC_ret:	ret
;-------------------------------------
METadc0:	ldi	temp,0b00100000		;
		rjmp	wait_adc2

METadc1:	ldi	temp,0b00100001		;
		rjmp	wait_adc2

METadc2:	ldi	temp,0b00100010		;
		rjmp	wait_adc2

METadc3:	ldi	temp,0b00100011		;
		rjmp	wait_adc2

METadc4:	ldi	temp,0b00100100		;
		rjmp	wait_adc2

METadc5:	ldi	temp,0b00100101		;
		rjmp	wait_adc2

METadc6:	ldi	temp,0b00100110		;
		rjmp	wait_adc2

METadcVCC:	ldi	temp,0b00100111		;ADLAR=1


wait_adc2:	out	ADMUX,temp
		ldi	temp,0b11000110	;Start ADC, PRS=8
		out	ADCSRA,temp

wait_adc1:
		in	temp,ADCSRA
		sbrc	temp,ADSC	
		rjmp	wait_adc1

		in	temp,ADCL
		in	temp,ADCH



		ret



;------------------------------------
calc_adrLN:	mov	temp,temp3

		ldi	zh,high(2*sel_device1)		;
		ldi	zl,low(2*sel_device1)

		cpi	temp,1
		breq	calc_adrLN_ret	

		dec	temp
calc_adrLN1:	adiw	zl,32
		dec	temp
		brne	calc_adrLN1

calc_adrLN_ret:
		rcall	trTWOline2lcd
		ret	
;-------------------------------------
prep2botloader:

		ldi	zh,high(2*lcd_string_rdbld)		;
		ldi	zl,low(2*lcd_string_rdbld)
		rcall	trTWOline2lcd



		jmp	boot_ld	
;----------------------------------
wait_press_key:
		rcall	wait_ft0

		in	temp,UCSRA
		sbrs	temp,RXC
		rjmp	wait_press_key3

		in	temp,UDR
		cpi	temp,_U
		brne	wait_press_key3

		rjmp	prep2botloader


wait_press_key3:
		sbic	pinc,pusk
		rjmp	wait_press_key

		ldi	temp1,30
wait_press_key1:
		rcall	wait_ft0
		dec	temp1
		brne	wait_press_key2

		sec	
		rjmp	wait_press_key_ret

wait_press_key2:
		sbis	pinc,pusk
		rjmp	wait_press_key1
		clc

wait_press_key_ret:
		ret
;--------------------------------------------
Wr2Lcd2ln:	call	remov_d2lcdBuf_ln2

		sbr	fl3,f_flash_ln1
		sbr	fl3,f_flash_ln2
		call	tr_data2lcd
		ret
;---------------------------------------------
init_LED:	ldi	temp,0xff
		sbr	temp,f_ledG	;ledG ON
		cbr	temp,f_ledR
		cbr	temp,f_ledY
		sts	buf4094_out,temp

		call	control_outs

		ret

;---------------------------------------------
error_ind:	ldi	counter,7
error_ind1:
		lds	temp,buf4094_out
		sbr	temp,f_ledR
		cbr	temp,f_ledY
		cbr	temp,f_buzzer
		sbr	temp,f_rel1	;выключить питание
		sts	buf4094_out,temp

		rcall	control_outs

		
		ldi	temp,1
		rcall	time_delay

;		rcall	init_LED



		lds	temp,buf4094_out
		cbr	temp,f_ledR
		cbr	temp,f_ledY
		sbr	temp,f_buzzer
		sts	buf4094_out,temp

		rcall	control_outs





		ldi	temp,1
		rcall	time_delay

		dec	counter
		brne	error_ind1

		ret
;-----------------------------------------------



;--------------------------------------
tr_1byte:	push	temp
		out	udr,temp

tr_1byte_1:	in	temp,ucsra
		sbrs	temp,TXC
		rjmp	tr_1byte_1
		
		out	ucsra,temp

		pop	temp
		
		ret
;---------------------------------------
RES_TOUT:	mov	count_tout,temp
		ldi	temp,3
		mov	timer1,temp
		cbr	fl3,f_tout
		ret
;-------------------------------------
time_delay:	rcall	RES_TOUT

time_delay1:	sbrs	fl3,fp_tout
		rjmp	time_delay1
		ret
;----------------------------------
wait_ft0:	sbrs	fl1,fp_t0
		rjmp	wait_ft0
		cbr	fl1,f_t0
		ret
;-----------------------------------------
;timer1_int:	sbr	fl1,f_t1
;		reti
;-----------------------------------
timer0_int:	sbr	fl1,f_t0		;

		push	temp

		dec	timer1
		brne	timer0_int_ret

		ldi	temp,3
		mov	timer1,temp

		sbr	fl1,f_sec100ms

		dec	count_tout
		brne	timer0_int_ret

		sbr	fl3,f_tout

timer0_int_ret:
		pop	temp

		reti
;-----------------------------------------------
;RES_TOUT:	mov	count_tout,temp
;		ldi	temp,50
;		mov	timer1,temp
;		cbr	fl4,f_tout
;
;		ret
;--------------------------------------------------


;---------------------------------------------
;EraseAllPages:
;
;;		ldi	zh,high(999)		;Pages to Erase
;;		ldi	zl,low(999)
;
;		ldi	temp,0
;		sts	flash_page_adrL,temp			
;		sts	flash_page_adrH,temp	;начальная страница
;
;EraseAllPages1:
;		rcall	RdStatReg		;Ready?
;
;		ldi	temp,0x81		;Page Erase
;		rcall	SPI_MasterTransmit	; 
;		rcall	SendPageAdr
;
;		rcall	IncPageAdr
;		brcc	EraseAllPages1
;
;;		sbiw	zl,1
;		brne	EraseAllPages1
;
;PresetPageAdr:
;		ldi	temp,0
;		sts	flash_page_adrL,temp			
;		sts	flash_page_adrH,temp	;начальная страница
;
;		ret
;---------------------------------------------

;--------------------------------------------
;IncPageAdr:	push	zl
;		push	zh
;
;		lds	zl,flash_page_adrL
;		lds	zh,flash_page_adrH
;
;		cpi	zl,low(999)	;проверка на достижение макс адреса
;		brne	IncPageAdr1
;		
;		cpi	zh,high(999)	;проверка на достижение макс адреса
;		breq	IncPageAdr_ret1
;
;IncPageAdr1:	adiw	zl,1
;
;		sts	flash_page_adrL,zl
;		sts	flash_page_adrH,zh
;		
;		clc
;		rjmp	IncPageAdr_ret
;
;IncPageAdr_ret1:
;		sec
;
;IncPageAdr_ret:
;		pop	zh
;		pop	zl
;		ret
;--------------------------------------------

;---------------------------------------------
;SendPageAdr:	
;
;		;------- page ADRESS - 10 bit -----------
;		lds	temp1,flash_page_adrH	;
;		lds	temp2,flash_page_adrL	;
;		;-------------------------------------------
;
;		lsl	temp1
;		bst	temp2,7		
;		bld	temp1,0
;		lsl	temp2
;
;		mov	temp,temp1		;Page Adr - byte №1
;		rcall	SPI_MasterTransmit
;		
;		mov	temp,temp2		;Page Adr - byte №2
;		rcall	SPI_MasterTransmit
;
;		mov	temp,temp1		;Page Adr - byte №3
;		rcall	SPI_MasterTransmit
;
;		rcall	RdStatReg
;
;
;		ret
;---------------------------------------------------------------------------------------------
;write_page2flash: 	
;		rcall	RdStatReg	
;
;
;	;--- передать данные из RAM в буфер ----------------
;		ldi	temp,0x84		;Buffer 1 Write
;		rcall	SPI_MasterTransmit	;Код операции
;	
;		ldi	counter,3
;write_page2flash_1:
;		ldi	temp,0			;Начальный адрес в буфере
;		rcall	SPI_MasterTransmit
;		dec	counter
;		brne	write_page2flash_1
;
;		ldi	temp,0
;		rcall	SPI_MasterTransmit	;первые два байта - пустые
;
;		ldi	temp,0
;		rcall	SPI_MasterTransmit
;
;		ldi	counter,254		;
;	
;;		ldi	zh,high(temp_buf)
;;		ldi	zl,low(temp_buf)
;
;write_page2flash_2:
;
;		ld	temp,z+
;
;		rcall	SPI_MasterTransmit
;	
;		dec	counter
;		brne	write_page2flash_2		;буфер заполнен?
;		
;	;---- записать данные из буфера в FLASH --------
;
;		rcall	RdStatReg	;Ready?
;
;		ldi	temp,0x83		;Buffer 1 to Main Memory Page Program
;		rcall	SPI_MasterTransmit	;запись из буфера в память 
;
;		rcall	SendPageAdr
;
;		flash_dis
;		rcall	flash_disable_sel
;		ret
;--------------------------------------------------------------------------------------------------










;--------------------------------------------------------------------------------------------------
;-------------- переслать данные из FLASH в буфер -----------------------
;Read_page_flash2buf:
;		rcall	RdStatReg
;
;		ldi	temp,0x53	;"Main Memory Page to Buffer 1 Transfer"
;		rcall	SPI_MasterTransmit	
;
;		rcall	SendPageAdr
;		
;		ret

;---------------------------------------------------------------------------------------------
;------------------ переслать данные из буфера в RAM ----------------
;Read_data_buf2ram:
;		rcall	RdStatReg
;
;		ldi	temp,0xd4		;Buffer 1 Read
;		rcall	SPI_MasterTransmit	
;
;		ldi	counter,4		;Plus transmit "Additional Don’t Care Byte"
;Read_data_buf2ram_1:
;		ldi	temp,0			;Начальный адрес в буфере
;		rcall	SPI_MasterTransmit
;		dec	counter
;		brne	Read_data_buf2ram_1
;
;		rcall	SPI_MasterRead		;первые два байта - пустые
;		rcall	SPI_MasterRead
;
;;		ldi	zh,high(temp_buf)
;;		ldi	zl,low(temp_buf)
;;		ldi	temp,0
;		ldi	counter,254
;

;Read_data_buf2ram_2:
;		rcall	SPI_MasterRead
;		st	z+,temp	

;		dec	counter
;		brne	Read_data_buf2ram_2		;буфер заполнен?
;
;		rcall	RdStatReg	;Ready?
;
;		ret
;-------------------------------------------
;flash_disable_sel:

;		sbrs	fl3,fp_cs2
;		rjmp	flash_dis_sel1
;		flash2_dis
;		rjmp	flash_dis_sel2

;flash_dis_sel1:
;		flash_dis
;flash_dis_sel2:


;		ret
;---------------------------------------------
;RdStatReg:	;flash_dis
;		rcall	flash_disable_sel
;		ldi	temp,10
;		
;RdStatReg2:	dec	temp
;		brne	RdStatReg2
;
;		ldi	temp,0xd7	
;		rcall	SPI_MasterTransmit
;RdStatReg1:		
;		rcall	SPI_MasterRead
;
;		sbrs	temp,7
;		rjmp	RdStatReg1
;
;;		flash_dis
;		rcall	flash_disable_sel
;		ret
;-----------------------------------------------------------------------------
SPI_MasterTransmit:
;		sbrs	fl3,fp_cs2
;		rjmp	SPI_MasterTransmit1
;		flash2_en
;		rjmp	SPI_MasterTransmit2

SPI_MasterTransmit1:
		flash_en
SPI_MasterTransmit2:
		out 	SPDR,temp
Wait_Transmit_SPI:
		in	temp,SPSR
		sbrs 	temp,SPIF	;Wait for transmission complete
		rjmp 	Wait_Transmit_SPI
	
		ret
;-----------------------------------------------------------------------------
SPI_MasterRead:
		ldi	temp,0xff
		out 	SPDR,temp

;		sbrs	fl3,fp_cs2
;		rjmp	SPI_MasterRead1
;		flash2_en
;		rjmp	SPI_MasterRead2

SPI_MasterRead1:
		flash_en
SPI_MasterRead2:

Wait_SPI_MasterRead:
		in	temp,SPSR
		sbrs 	temp,SPIF	;Wait for transmission complete
		rjmp 	Wait_SPI_MasterRead

		in	temp,SPDR

		ret
;------------------------------------------------------------------------------

;-----------------------------------------------
;send_READY:	ldi	zh,high(2*bl_tr_ready)
;		ldi	zl,low(2*bl_tr_ready)
;		rjmp	send_answ_ret1
;
;send_OK:	ldi	zh,high(2*bl_trOK)
;		ldi	zl,low(2*bl_trOK)	
;		rjmp	send_answ_ret1
;			
;
;send_ERR:	ldi	zh,high(2*bl_tr_error)
;		ldi	zl,low(2*bl_tr_error)	
;send_answ_ret1:	rcall	TR_COM_DATA	
;
;send_answ_ret:	ret
;----------------------------------------------------
;TR_COM_DATA:	lpm	counter,z+
;			
;TR_COM_DATA1:	lpm	temp,z+
;		
;		rcall	tr_1byte
;		dec	counter
;		brne	TR_COM_DATA1
;		ret
;
;--------------------------------------------
;test_flash:	
;		ldi	temp,0x9f	
;		
;		rcall	SPI_MasterTransmit
;		
;		rcall	SPI_MasterRead

;		cpi	temp,0x1e
;		brne	test_flash_ret1

;		mov	test_data,temp
;		call	test_send

;		rcall	SPI_MasterRead

;		cpi	temp,0x00
;		brne	test_flash_ret1

;		mov	test_data,temp
;		call	test_send
	
;		clc
;		rjmp	test_flash_ret	
;test_flash_ret1:		
;		sec
;test_flash_ret:
;
;		rcall	flash_disable_sel
;		flash_dis
;		ret



;----------------------------------------------------------------------



;-----------------------------------------------------------
control_outs:	push	temp
		in	temp,sreg
		push 	temp
		push	counter

		lds	temp,buf4094_out
	
		ldi	counter,8
control_outs1:
		DATA4094_0

		rol	temp	
		brcs	control_outs1_1

		DATA4094_1
control_outs1_1:
		CLK4094_1
		CLK4094_0

		dec	counter
		brne	control_outs1


;		lds	temp,buf4094_prof_led
		lds	temp,buf4094_pinIO
		ldi	counter,8
control_outs2:
		DATA4094_0

		rol	temp	
		brcc	control_outs2_1

		DATA4094_1

control_outs2_1:

		CLK4094_1
		CLK4094_0


		dec	counter
		brne	control_outs2

;		ldi	temp,100

		
		STR4094_1
;control_outs3:
;		dec	temp
;		brne	control_outs3
		STR4094_0



		pop	counter
		pop	temp
		out	sreg,temp
		pop	temp

;		cbr	fl2,f_en_out

		ret

;-----------------------------------------------------------



;------------------------------------------------------------------
;--------------------------------------------
SER_OUT_i:	ldi	counter,0b00000000	;RS=0
		rcall	SER_OUT_4u_bit

		ret
;--------------------------------------------
SER_OUT_c:	push	temp
		ldi	counter,0b00000000	;RS=0
		rcall	SER_OUT_4u_bit

		pop	temp
		
		lsl	temp
		lsl	temp
		lsl	temp
		lsl	temp

		ldi	counter,0b00000000	;RS=0
		rcall	SER_OUT_4u_bit

		ret
;--------------------------------------------
SER_OUT_d:	push	temp
		ldi	counter,0b10000000	;RS=1
		rcall	SER_OUT_4u_bit

		pop	temp
		
		lsl	temp
		lsl	temp
		lsl	temp
		lsl	temp

		ldi	counter,0b10000000	;RS=1
		rcall	SER_OUT_4u_bit

		ret
;--------------------------------------------
delay2us:	ldi	temp1,6
delay2us_1:	dec	temp1
		brne	delay2us_1
		ret
;--------------------------------------------
SER_OUT_4u_bit:	
		bst	temp,4
		bld	counter,3


		bst	temp,5
		bld	counter,2


		bst	temp,6
		bld	counter,1


		bst	temp,7
		bld	counter,0


		mov	temp,counter		

;;		rcall	S_OUT0
;;		ret	

S_OUT0_lcd0:

		ldi	counter,8


S_OUT0_lcd:	DATA4094_0
		sbrc	temp,0
		DATA4094_1

		rcall	delay2us

		
;		nop
;		nop
;		nop
;		nop
;		nop
;		nop
;		nop
;		nop
;		nop


				
		clk_164_1



		rcall	delay2us
;		nop
;		nop
;		nop
;		nop		
;		nop
;		nop

		clk_164_0
				
		lsr	temp
		clz
		dec	counter
		brne	S_OUT0_lcd

		;sbrc	fl1,fp_rd_kbr
		;rjmp	S_OUT0_lcd_ret		

		rcall	delay2us

;		nop
;		nop
;		nop
;		nop
;		nop
;		nop
;		nop
;		nop
;;		nop
	

		lcd_E_pin_1

		rcall	delay2us

;		nop
;		nop
;		nop
;		nop
;		nop
;		nop
;		nop
;		nop
;		nop
;		nop
	

		lcd_E_pin_0
S_OUT0_lcd_ret:
		DATA4094_0

		ret		
;-----------------------------------------------
INIT_LCD:

		rcall	del_20ms
		ldi	temp,0b00110000		;1st bite
		rcall	ser_out_i



		rcall	del_20ms
		ldi	temp,0b00110000		;2st bite
		rcall	ser_out_i

		rcall	del_20ms
		ldi	temp,0b00110000		;3st bite
		rcall	ser_out_i

 		rcall	del_20ms
		ldi	temp,0b00100000		;4-bit interface
		rcall	ser_out_i

		rcall	del_20ms
		ldi	temp,0b00101000		;Function set, N=0(bit3), F=0(bit2)
		rcall	ser_out_c

		rcall	del_20ms
		ldi	temp,0b00001000		;Display OFF
		rcall	ser_out_c

		rcall	del_20ms
		ldi	temp,0b00000001		;Clear Display
		rcall	ser_out_c

		rcall	del_20ms
		ldi	temp,0b00000110		;entry mode set
		rcall	ser_out_c

		rcall	del_20ms
		ldi	temp,0b00001100		;Display ON
		rcall	ser_out_c	


		rcall	del_20ms
		ldi	temp,0b00000010		;Return Home
		rcall	ser_out_c		

		rcall	del_20ms



		ret
;--------------------------------------------------------------
tr_data2lcd:	ldi	yh,high(lcd_buf)	;
		ldi	yl,low(lcd_buf)

	;----- 1st LINE -----------------------

		ldi	temp,0b10000000		;Start adress 1st line = 0x00
		rcall	ser_out_c		

		rcall	tr_data2lcd_ln1

	;----- 2st LINE -----------------------

		rcall	del_100us


		ldi	temp,0b11000000		;Start adress 2st line = 0x40
		rcall	ser_out_c		

		rcall	tr_data2lcd_ln2

		rcall	del_100us


		ret		
;--------------------------------------
tr_data2lcd_ln1:
		ldi	temp,16			;вывести 16 символов
		mov	temp4,temp
tr_data2lcd_ln1_1:
		rcall	del_100us		

		ld	temp,y+			;write symbol

		sbrs	fl3,fp_flash_ln1
		rjmp	tr_data2lcd_ln1_2
		
		sbrs	fl3,fp_sec
		rjmp	tr_data2lcd_ln1_2

		ldi	temp,_sp

tr_data2lcd_ln1_2:
		rcall	ser_out_d	

		dec	temp4
		brne	tr_data2lcd_ln1_1

		ret
;-------------------------------------
tr_data2lcd_ln2:
		ldi	temp,16			;вывести 16 символов
		mov	temp4,temp

tr_data2lcd_ln2_1:
		rcall	del_100us		

		ld	temp,y+			;write symbol
		sbrs	fl3,fp_flash_ln2
		rjmp	tr_data2lcd_ln2_2
		
		sbrs	fl3,fp_sec
		rjmp	tr_data2lcd_ln2_2

		ldi	temp,_sp

tr_data2lcd_ln2_2:
		rcall	ser_out_d	

		dec	temp4
		brne	tr_data2lcd_ln2_1

		ret
;-----------------------------------------------
del_100us:	ldi	counter,127
		rjmp	del_100us_1

del_200us:	ldi	counter,255

del_100us_1:	dec	counter
		nop
		brne	del_100us_1		

		ret
;---------------------------------------
del_20ms:
		ldi	temp,2
del_20ms_1:	rcall	wait_ft0
		dec	temp
		brne	del_20ms_1
		ret


;------------------------------------------
;rld_data2lcd_buf:
;		ldi	zh,high(2*string0)	;
;		ldi	zl,low(2*string0)

rld_data2lcd_buf1:

		cpi	temp,0
		breq	rld_data2lcd_buf2

rld_data2lcd_buf3:
		adiw	zl,16
		adiw	zl,16

		dec	temp
		brne	rld_data2lcd_buf3


rld_data2lcd_buf2:
		rcall	rld_data2lcd_buf_ln1
		rcall	rld_data2lcd_buf_ln2

		cbr	fl3,f_flash_ln1
		cbr	fl3,f_flash_ln2
		ret
;---------------------------------
rld_data2lcd_buf_ln1:
		ldi	yh,high(lcd_buf)	;
		ldi	yl,low(lcd_buf)

		ldi	counter,16
rld_data2lcd_buf_ln1_1:
		lpm	temp,z+
		st	y+,temp

		dec	counter
		brne	rld_data2lcd_buf_ln1_1

		ret
;----------------------------------
rld_data2lcd_buf_ln2:
		ldi	yh,high(lcd_buf+16)	;
		ldi	yl,low(lcd_buf+16)

		ldi	counter,16
rld_data2lcd_buf_ln2_1:
		lpm	temp,z+
		st	y+,temp

		dec	counter
		brne	rld_data2lcd_buf_ln2_1

		ret
;---------------------------------------------------
trTWOline2lcd:
		sbr	fl3,f_flash_ln1
		sbr	fl3,f_flash_ln2

		ldi	yh,high(lcd_buf)	;
		ldi	yl,low(lcd_buf)
		ldi	counter,32
		rcall	remov_d2lcdBuf_ln0
		rcall	tr_data2lcd
		ret
;-------------------------------------------------
remov_d2lcdBuf_ln2:
		ldi	yh,high(lcd_buf+16)	;
		ldi	yl,low(lcd_buf+16)
		rjmp	remov_d2lcdBuf_ln

remov_d2lcdBuf_ln1:
		ldi	yh,high(lcd_buf)	;
		ldi	yl,low(lcd_buf)

remov_d2lcdBuf_ln:
		ldi	counter,16

remov_d2lcdBuf_ln0:
		lpm	temp,z+
		st	y+,temp

		dec	counter
		brne	remov_d2lcdBuf_ln0

		cbr	fl3,f_init_lcd
		ret
;----------------------------------
;DATA_TDA9885_T:	ldi	zh,high(2*Tdata186_0)
;		ldi	zl,low(2*Tdata186_0)
;
;		call	trIICstring
;		brcs	DATA_TDA9885_T_ret
;
;		ldi	zh,high(2*Tdata186_1)
;		ldi	zl,low(2*Tdata186_1)
;
;		call	trIICstring
;		brcs	DATA_TDA9885_T_ret
;
;		ldi	zh,high(2*Tdata186_2)
;		ldi	zl,low(2*Tdata186_2)
;
;		call	trIICstring
;DATA_TDA9885_T_ret:
;		ret
;-----------------------------------------
;DATA_TDA9885_H:	ldi	zh,high(2*Hdata186_0)
;		ldi	zl,low(2*Hdata186_0)
;
;		call	trIICstring
;		brcs	DATA_TDA9885_H_ret
;
;		ldi	zh,high(2*Hdata186_1)
;		ldi	zl,low(2*Hdata186_1)
;
;		call	trIICstring
;		brcs	DATA_TDA9885_H_ret
;
;		ldi	zh,high(2*Hdata186_3)
;		ldi	zl,low(2*Hdata186_3)
;
;		call	trIICstring
;DATA_TDA9885_H_ret:
;		ret
;----------------------------------------
;SEARCH_CH:	ldi	xh,0x13
;		ldi	xl,0x00
;
;SEARCH_CH1:	call	wait_ft0
;		call	wait_ft0
;		call	wait_ft0
;
;
;		mov	temp,xh
;		call	tr_1byte
;		mov	temp,xl
;		call	tr_1byte
;		ldi	temp,_cr
;		call	tr_1byte
;
;
;		rcall	trIICstring_posl
;;		brcs	test_adr14
;;
;		adiw	xl,1
;		mov	temp,xh
;		sbrs	temp,7
;		rjmp	SEARCH_CH1
;
;		RJMP	SEARCH_CH
;-----------------------------------------
;-------------------------------------
;trIICstring_posl:
;
;		rcall	send_start
;		ldi	temp,0xC0
;		rcall	send_byte
;;		sbrs	fl3,fp_ack	
;;		rjmp	trIICstring_posl_ret1
;
;		mov	temp,xh
;		rcall	send_byte
;;		sbrs	fl3,fp_ack	
;;		rjmp	trIICstring_posl_ret1
;
;		mov	temp,xl
;		rcall	send_byte
;;		sbrs	fl3,fp_ack	
;;		rjmp	trIICstring_posl_ret1
;
;		ldi	temp,0b11001000
;		rcall	send_byte
;;		sbrs	fl3,fp_ack	
;;		rjmp	trIICstring_posl_ret1
;
;
;		ldi	temp,0b00000010	;bit0 -VHV-Lo, bit1 -VHV-Hi, bit3 -UHV	
;		rcall	send_byte
;;		sbrs	fl3,fp_ack	
;;		rjmp	trIICstring_posl_ret1
;
;;		ldi	temp,0xD8
;;		rcall	send_byte
;;		sbrs	fl3,fp_ack	
;;		rjmp	trIICstring_posl_ret1
;
;
;;		ldi	temp,0x60
;;		rcall	send_byte
;;		sbrs	fl3,fp_ack	
;;		rjmp	trIICstring_posl_ret1
;
;		rcall	send_stop
;		clc
;		rjmp	trIICstring_posl_ret
;
;trIICstring_posl_ret1:
;		sec
;
;trIICstring_posl_ret:
;		ret
;
;0xC8,0x02,0xD8,0x60
;----------------------------------------
;Htest_tuner:	rcall	DATA_TDA9885_H
;		brcs	Htest_tuner_ret1
;
;		ldi	zh,high(2*Hdata1C0)
;		ldi	zl,low(2*Hdata1C0)
;
;		call	trIICstring
;		brcs	Htest_tuner_ret1
;
;		rcall	DEL_1SEC
;		brcs	Htest_tuner_ret2
;
;
;		ldi	zh,high(2*Hdata186_2)
;		ldi	zl,low(2*Hdata186_2)
;
;		call	trIICstring
;		brcs	Htest_tuner_ret1
;
;		ldi	zh,high(2*Hdata2C0)
;		ldi	zl,low(2*Hdata2C0)
;
;		call	trIICstring
;		brcs	Htest_tuner_ret1
;
;		rcall	DEL_1SEC
;		brcs	Htest_tuner_ret2
;
;		ldi	zh,high(2*Hdata3C0)
;		ldi	zl,low(2*Hdata3C0)
;
;		call	trIICstring
;		brcs	Htest_tuner_ret1
;
;		rcall	DEL_1SEC
;		brcc	Htest_tuner
;
;Htest_tuner_ret2:
;		clc
;		rjmp	Htest_tuner_ret
;Htest_tuner_ret1:
;		sec	
;
;Htest_tuner_ret:
;		ret
;--------------------------------------


;Ttest_tuner:	rcall	DATA_TDA9885_T
;		brcs	Ttest_tuner_ret2
;
;		ldi	zh,high(2*Tdata1C0)
;		ldi	zl,low(2*Tdata1C0)
;
;		call	trIICstring
;		brcs	Ttest_tuner_ret1
;
;		rcall	DEL_1SEC
;		brcs	Ttest_tuner_ret2
;
;		ldi	zh,high(2*Tdata2C0)
;		ldi	zl,low(2*Tdata2C0)
;
;		call	trIICstring
;		brcs	Ttest_tuner_ret1
;
;
;		call	DEL_1SEC
;		brcs	Ttest_tuner_ret2
;
;		ldi	zh,high(2*Tdata3C0)
;		ldi	zl,low(2*Tdata3C0)
;
;		call	trIICstring
;		brcs	Ttest_tuner_ret1
;
;		call	DEL_1SEC
;		brcc	Ttest_tuner
;
;Ttest_tuner_ret2:
;		clc	
;
;Ttest_tuner_ret1:
;		sec
;Ttest_tuner_ret:
;		ret
;-------------------------------------
;Etest_tuner:	rcall	DATA_TDA9885_H
;		brcs	Etest_tuner_ret1
;
;		ldi	zh,high(2*Hdata1C0)
;		ldi	zl,low(2*Hdata1C0)
;
;		call	trIICstring
;		brcs	Etest_tuner_ret1
;
;		call	DEL_1SEC
;		brcs	Etest_tuner_ret2
;
;		ldi	zh,high(2*Hdata186_2)
;		ldi	zl,low(2*Hdata186_2)
;
;		call	trIICstring
;		brcs	Etest_tuner_ret1
;
;		ldi	zh,high(2*Hdata2C0)
;		ldi	zl,low(2*Hdata2C0)
;
;		call	trIICstring
;		brcs	Etest_tuner_ret1
;
;		call	DEL_1SEC
;		brcs	Etest_tuner_ret2
;
;		ldi	zh,high(2*Hdata3C0)
;		ldi	zl,low(2*Hdata3C0)
;
;		call	trIICstring
;		brcs	Etest_tuner_ret1
;
;		rcall	DEL_1SEC
;		brcc	Etest_tuner
;
;Etest_tuner_ret2:
;		clc
;		rjmp	Etest_tuner_ret
;Etest_tuner_ret1:
;		sec	
;
;Etest_tuner_ret:
;		ret
;--------------------------------------
;DEL_1SEC:	ldi	temp1,50
;DEL_1SEC1:	call	wait_ft0
;
;		sbis	pinc,pusk
;		rjmp	DEL_1SEC_ret1
;
;		dec	temp1
;		brne	DEL_1SEC1
;
;		clc	
;		rjmp	DEL_1SEC_ret
;			
;DEL_1SEC_ret1:	sec
;DEL_1SEC_ret:	ret
;----------------------------------------








;------------------------------------------		
SEND_START:	cbi	ddra,pinIO6	;SDA= "1"
		;cbi	ddra,pinIO7	;SCL= "1"
		rcall	delay_6		;
		sbi	ddra,pinIO6	;SDA= "0"
		rcall	delay_6
		;sbi	ddra,pinIO7	;SCL= "0"
		rcall	delay_6
		ret
;-------------------------------------------			
SEND_STOP:	;sbi	ddra,pinIO6	;SDA= "0"
		;rcall	delay_6
		;cbi	ddra,pinIO7	;SCL= "1"
		;rcall	delay_6
		cbi	ddra,pinIO6	;SDA= "1"

		ldi	temp,255
SEND_STOP1:	dec	temp
		brne	SEND_STOP1
		ret
;-------------------------------------------		
WAIT_SDA_HIGH:	rcall	delay_6
		;cbi	ddra,pinIO6	;SDA= "1"
		cbi	ddra,pinIO7	;SCL= "1"
		rcall	delay_6

		

		;cbi	ddra,pinIO6	;SDA= "1"
		rcall	delay_6
		cbr	fl3,f_ack

		


		sbis	pina,pinIO6
		sbr	fl3,f_ack

		
		rcall	delay_6
		sbi	ddra,pinIO7	;SCL= "0"
		rcall	delay_6
WAIT_SDA_HIGH1:
		ret
;-------------------------------------		
SEND_BYTE:	cli
		;push	counter

		sts	ram_temp1,counter

		

		ldi	counter,8		;counter
;		cbi	ddrc,sda_pin	;?????????? "1"

SB_LOOP:	rol	temp

		cbi	ddra,pinIO6	;SDA= "1"
		brcs	SB_LOOP2
		sbi	ddra,pinIO6	;SDA= "0"

		


SB_LOOP2:	rcall	delay_6
		rcall	delay_6
		cbi	ddra,pinIO7	;SCL= "1"
		rcall	delay_6
		rcall	delay_6
		sbi	ddra,pinIO7	;SCL= "0"
		;rcall	delay_6
		dec	counter
		brne	sb_loop
		
		cbi	ddra,pinIO6	;SDA= "1"

		rcall	delay_6
		rcall	wait_sda_high
		rcall	delay_6

		;cbi	ddra,pinIO6
		;sbi	ddra,pinIO7	;SCL= "0"
		rcall	delay_6
SEND_BYTE_1:
		lds	counter,ram_temp1
		;pop	counter
		sei
		ret		
;------------------------------------		

;-------------------------------------
DELAY_6:	ldi	temp1,100	;25

DELAY_6L:	dec	temp1	
		brne	DELAY_6L
		ret
;--------------------------------------	

prepare_buf:	ldi	zl,low(2*prof1_data)
		ldi	zh,high(2*prof1_data)
		
		mov	temp,temp3

		dec	temp
		breq	prepare_buf3	

prepare_buf2:	adiw	zl,18

		dec	temp
		brne	prepare_buf2

prepare_buf3:

		call	kbr_brd_set

		


		ret


;		ldi	temp,100
;		mov	temp6,temp
;---------------------------------------------------

send_IR_test:	lds	temp,key_mode1
		sbrc	temp,1		;1-не проверять ИК
		rjmp	send_IR_test3

		cbi	DDRD,LED_OUT3	;AS INPUT
		cbi	portD,LED_OUT3	;pullup resistor disable

		ldi	temp,100
		mov	temp6,temp
send_IR_test5:
		ldi	temp1,100		;передать импульсы
		
send_IR_test0:	IR_LED_OFF

		rcall	wait_ft0

		TEST0_IR_IN
		rjmp	send_IR_test1

		sec
		ldi	temp,2
		mov	err_ind,temp	;ошибка - замыкание вывода на "землю"
		rjmp	send_IR_test_ret


send_IR_test1:	rcall	tr_string	

		rcall	tr_string000

		subi	counter,40
		brcc	send_IR_test2

		dec	temp6
		brne	send_IR_test5
		
		
send_IR_test4:	
		sec
		ldi	temp,3
		mov	err_ind,temp	;ошибка - нет сигнала с ИК приемника
		rjmp	send_IR_test_ret

send_IR_test2:	;dec	temp1
		;brne	send_IR_test0
send_IR_test3:
		clc

send_IR_test_ret:		

;		cbi	DDRD,0
		ret


;---------------------------------------
tr_string:	cli
		;ldi	temp,0 
		;out	tccr0b,temp	

		ldi	counter,0		
		
tr_string1:	ldi	temp5,100

tr_IRbit1_1:	IR_LED_ON			;зажечь IR LED
		ldi	temp,10		
tr_IRbit1_2:	dec	temp
		brne	tr_IRbit1_2
		IR_LED_OFF			;погасить IR LED

		ldi	temp,56		
tr_IRbit1_3:	dec	temp
		brne	tr_IRbit1_3

		nop
;		nop

;		TEST1_IR_IN		
		sbis	pind,LED_OUT3
		inc	counter

		dec	temp5

		brne	tr_IRbit1_1


;		ldi	temp,0b00000101	;разрешить работу счетчика TC0, к=1024 
;		out	tccr0b,temp	;
		sei

		ret
;---------------------------------------
tr_string000:
		IR_LED_OFF	

		
tr_string0001:	ldi	temp5,10

tr_string0002:	ldi	temp,0		;погасить IR LED
tr_string0003:	
		dec	temp
		brne	tr_string0003

		dec	temp5

		brne	tr_string0002

		ret
;---------------------------------------
SelectKeyAdc:	lds	temp,key_mode1
		sbrs	temp,0		
		rjmp	SelectKeyAdc_1

		rcall	METadc6	
		rjmp	SelectKeyAdc_ret

SelectKeyAdc_1:
		rcall	METadc0		
SelectKeyAdc_ret:
		ret
;--------------------------------------
test_kbr_key:	;ret
		
		lds	temp,key_mode1
		sbrs	temp,6		;1-add delay
		rjmp	test_kbr_key_01

		ldi	temp,30
test_kbr_key_02:
		rcall	wait_ft0
		dec	temp
		brne	test_kbr_key_02




test_kbr_key_01:
		cbr	fl1,f_overpress

		lds	fl4,key_set

		cpi	fl4,0xFF
		brne	test_kbr_key_s2
		clc
		rjmp	test_kbr_key_ret


test_kbr_key_s2:
		rcall	wait_ft0

		lds	temp,key_mode1
		sbrs	temp,5		;
		rjmp	test_kbr_key_s20

		lds	temp,buf4094_pinIO
		cbr	temp,f_pinIO0
		sts	buf4094_pinIO,temp
		call	control_outs

test_kbr_key_s20:

		rcall	SelectKeyAdc

;		lds	temp,key_mode1
;		sbrs	temp,0		
;		rjmp	test_kbr_key_s22
;
;		rcall	METadc6	
;		rjmp	test_kbr_key_s21
;
;test_kbr_key_s22:
;		rcall	METadc0		;IN1 as input for serial keys
;test_kbr_key_s21:
		subi	temp,5

		mov	default_key_data,temp	

;		cpi	temp3,6
;		brne	test_kbr_key_s1
		
;		rjmp	test_samJ_cable


test_kbr_key_s1:

;		lds	temp,key_mode1
;		sbrs	temp,0		

;		rjmp	test_kbr_key099	

;		sbr	fl2,f_key_par	;проверка параллельных кнопок
		
;		;--- проверка параллельных кнопок на замыкание между собой 
;		sbrs	temp,3
;		rjmp	test_kbr_key_s2




test_kbr_key099:
		ldi	temp,150	;100	;10 сек	на все нажатия, ограничитель продолжительности тестирования
		rcall	RES_TOUT


			;
;		ldi	counter,0	;ограничитель продолжительности тестирования
test_kbr_key9:
		sbrc	fl1,fp_overpress
		rjmp	test_err_key_ret


		ldi	temp2,1		;счетчик продолжительности нажатия кнопки
		
test_kbr_key0:	rcall	wait_ft0
;		dec	counter
;		brne	test_kbr_key01
	
		sbrs	fl3,fp_tout
		rjmp	test_kbr_key01
		
				
		

test_err_key1:	sbrc	fl4,0		
		rjmp	test_err_key2
test_err_key11:	ldi	temp,err_key1
		mov	err_ind,temp
		rjmp	test_err_key_ret

test_err_key2:	sbrc	fl4,1		
		rjmp	test_err_key3
test_err_key21:	ldi	temp,err_key2
		mov	err_ind,temp
		rjmp	test_err_key_ret

test_err_key3:	sbrc	fl4,2		
		rjmp	test_err_key4
test_err_key31:	ldi	temp,err_key3
		mov	err_ind,temp
		rjmp	test_err_key_ret

test_err_key4:	sbrc	fl4,3		
		rjmp	test_err_key5
test_err_key41:	ldi	temp,err_key4
		mov	err_ind,temp
		rjmp	test_err_key_ret

test_err_key5:	sbrc	fl4,4		
		rjmp	test_err_key6
test_err_key51:	ldi	temp,err_key5
		mov	err_ind,temp
		rjmp	test_err_key_ret

test_err_key6:	sbrc	fl4,5		
		rjmp	test_err_key7
test_err_key61:	ldi	temp,err_key6
		mov	err_ind,temp
		rjmp	test_err_key_ret

test_err_key7:	sbrc	fl4,6		
		rjmp	test_err_key8
test_err_key71:	ldi	temp,err_key7
		mov	err_ind,temp
		rjmp	test_err_key_ret

test_err_key8:	sbrc	fl4,7		
		rjmp	test_err_key9

test_err_key81:	ldi	temp,err_key8
		mov	err_ind,temp
		rjmp	test_err_key_ret

test_err_key9:	ldi	temp,err_kbr_timeout	;ошибка - нажаты не все кнопки
		mov	err_ind,temp

test_err_key_ret:
		sec
		rjmp	test_kbr_key_ret

test_kbr_key01:	
		cpi	fl4,0xFF
		brne	test_kbr_key02


;		clc
;		rjmp	test_kbr_key_ret	;все кнопки нажаты - выход


test_kbr_key011:
		rcall	wait_ft0


		rcall	SelectKeyAdc
;		rcall	METadc0		;IN1 as input for serial keys

		dec	counter
		brne	test_kbr_key012

		sec
		
		ldi	temp,err_kbr_no_open	;ошибка - не все кнопки отжаты
		mov	err_ind,temp
		rjmp	test_kbr_key_ret


test_kbr_key012:
		;mov	temp1,default_key_data
		;sub	temp,temp1
		;brcs	test_kbr_key011

		clc
		rjmp	test_kbr_key_ret	;все кнопки нажаты - выход

test_kbr_key02:
;		sbrc	fl2,fp_key_par
;		rjmp	test_parkbr_key1

		lds	temp,key_mode1
		sbrs	temp,3
		rjmp	test_kbr_key003
		
		rcall	METadc1
		rjmp	test_kbr_key002
		
test_kbr_key003:		
		;rcall	METadc0

		rcall	SelectKeyAdc
test_kbr_key002:
		mov	temp7,temp
	;------------------- KEY 1 -----------------
test_kbr_key1:	
	

		sbrs	fl1,fp_sec100ms
		rjmp	test_kbr_key10
		
		cbr	fl1,f_sec100ms
		;out	udr,temp
		rcall	tr_1byte

test_kbr_key10:	;rjmp	test_kbr_key02

	
		
		sbrc	fl4,fp_key1
		rjmp	test_kbr_key2

		lds	temp5,key1_dataH
		mov	temp,temp5
		;rcall	tr_1byte

		lds	temp4,key1_dataL
		mov	temp,temp4
		;rcall	tr_1byte
		
		;ldi	temp,_CR
		;rcall	tr_1byte

		rcall	calk_border
		brcs	test_kbr_key12

		dec	temp2
		breq	test_kbr_key11
		rjmp	test_kbr_key0

test_kbr_key11:	sbr	fl4,f_key1	;зафиксировать нажатие кнопки

		rcall	wait_unpress_key
		sbrs	fl1,fp_overpress
test_kbr_key12:
		rjmp	test_kbr_key9

		ldi	temp1,1
		add	err_ind,temp1	
		rjmp	test_err_key_ret




	;------------------- KEY 2 -----------------
test_kbr_key2:	;mov	temp1,temp
		sbrc	fl4,fp_key2
		rjmp	test_kbr_key3

		lds	temp5,key2_dataH
		lds	temp4,key2_dataL
		rcall	calk_border
		brcs	test_kbr_key22

		dec	temp2
		breq	test_kbr_key21
		rjmp	test_kbr_key0

test_kbr_key21:	sbr	fl4,f_key2	;зафиксировать нажатие кнопки

		rcall	wait_unpress_key
		sbrs	fl1,fp_overpress
test_kbr_key22:
		rjmp	test_kbr_key9

		ldi	temp1,2
		add	err_ind,temp1	
		rjmp	test_err_key_ret

			


	;------------------- KEY 3 -----------------
test_kbr_key3:	;mov	temp1,temp
		sbrc	fl4,fp_key3
		rjmp	test_kbr_key4

		lds	temp5,key3_dataH
		lds	temp4,key3_dataL
		rcall	calk_border
		brcs	test_kbr_key32

		dec	temp2
		breq	test_kbr_key31
		rjmp	test_kbr_key0

test_kbr_key31:	sbr	fl4,f_key3	;зафиксировать нажатие кнопки

		rcall	wait_unpress_key
		sbrs	fl1,fp_overpress
test_kbr_key32:
		rjmp	test_kbr_key9

		ldi	temp1,3
		add	err_ind,temp1	
		rjmp	test_err_key_ret

			



	;------------------- KEY 4 -----------------
test_kbr_key4:	;mov	temp1,temp
		sbrc	fl4,fp_key4
		rjmp	test_kbr_key5

		lds	temp5,key4_dataH
		lds	temp4,key4_dataL
		rcall	calk_border
		brcs	test_kbr_key42

		dec	temp2
		breq	test_kbr_key41
		rjmp	test_kbr_key0

test_kbr_key41:	sbr	fl4,f_key4	;зафиксировать нажатие кнопки

		rcall	wait_unpress_key
		sbrs	fl1,fp_overpress
test_kbr_key42:
		rjmp	test_kbr_key9

		ldi	temp1,4
		add	err_ind,temp1	
		rjmp	test_err_key_ret

		



	;------------------- KEY 5 -----------------
test_kbr_key5:	;mov	temp1,temp
		sbrc	fl4,fp_key5
		rjmp	test_kbr_key6

		lds	temp5,key5_dataH
		lds	temp4,key5_dataL
		rcall	calk_border
		brcs	test_kbr_key52

		dec	temp2
		breq	test_kbr_key51
		rjmp	test_kbr_key0

test_kbr_key51:	sbr	fl4,f_key5	;зафиксировать нажатие кнопки

		rcall	wait_unpress_key
		sbrs	fl1,fp_overpress
test_kbr_key52:
		rjmp	test_kbr_key9

		ldi	temp1,5
		add	err_ind,temp1	
		rjmp	test_err_key_ret

			



	;------------------- KEY 6 -----------------
test_kbr_key6:	;mov	temp1,temp
		sbrc	fl4,fp_key6
		rjmp	test_kbr_key7

		lds	temp5,key6_dataH
		lds	temp4,key6_dataL
		rcall	calk_border
		brcs	test_kbr_key62

		dec	temp2
		breq	test_kbr_key61
		rjmp	test_kbr_key0

test_kbr_key61:	sbr	fl4,f_key6	;зафиксировать нажатие кнопки

		rcall	wait_unpress_key
		sbrs	fl1,fp_overpress
test_kbr_key62:
		rjmp	test_kbr_key9

		ldi	temp1,6
		add	err_ind,temp1	
		rjmp	test_err_key_ret




	;------------------- KEY 7 -----------------
test_kbr_key7:	;mov	temp1,temp
		sbrc	fl4,fp_key7
		rjmp	test_kbr_key8

		lds	temp5,key7_dataH
		lds	temp4,key7_dataL
		rcall	calk_border
		brcs	test_kbr_key72

		dec	temp2
		breq	test_kbr_key71
		rjmp	test_kbr_key0

test_kbr_key71:	sbr	fl4,f_key7	;зафиксировать нажатие кнопки

		rcall	wait_unpress_key
		sbrs	fl1,fp_overpress
test_kbr_key72:
		rjmp	test_kbr_key9

		ldi	temp1,7
		add	err_ind,temp1	
		rjmp	test_err_key_ret


	;------------------- KEY 8 -----------------
test_kbr_key8:	;mov	temp1,temp
		sbrc	fl4,fp_key8
		rjmp	test_kbr_key0

		lds	temp5,key8_dataH
		lds	temp4,key8_dataL
		rcall	calk_border
		brcs	test_kbr_key82

		dec	temp2
		breq	test_kbr_key81
		rjmp	test_kbr_key0

test_kbr_key81:	sbr	fl4,f_key8	;зафиксировать нажатие кнопки

		rcall	wait_unpress_key
		sbrs	fl1,fp_overpress
test_kbr_key82:
		rjmp	test_kbr_key9

		ldi	temp1,8
		add	err_ind,temp1	
		rjmp	test_err_key_ret
		












test_kbr_key_ret:

		ret
;----------------------------------------

calk_border:	mov	temp1,temp7
;		mov	temp,temp1
;		rcall	tr_1byte

		sub	temp1,temp5
		brcc	calk_border1

		mov	temp1,temp7
		sub	temp1,temp4
		brcc	calk_border_ret

calk_border1:	sec		

calk_border_ret:
		ret
;-------------------------------------
wait_unpress_key:
		rcall	short_beep
		clc
		ret



		ldi	temp1,200
wait_unpress_key1:
		dec	temp1
		brne	wait_unpress_key2
		sbr	fl1,f_overpress

		ldi	temp,err_S_key_base
		mov	err_ind,temp

		rjmp	wait_unpress_key_ret

wait_unpress_key2:
		
		;rcall	METadc0
		rcall	SelectKeyAdc

		mov	temp4,temp
	
		sub	temp,default_key_data
		
		brcc	wait_unpress_key_ret

		rcall	wait_ft0

		sbrs	fl1,fp_sec100ms
		rjmp	wait_unpress_key1
		
		cbr	fl1,f_sec100ms
		out	udr,temp4

		rjmp	wait_unpress_key1

wait_unpress_key_ret:
		ret

;------------------------------------------
test_led:
		lds	temp,key_mode1
		sbrc	temp,2		;1-не проверять LED
		rjmp	test_led_ret


test_led3:	cpi	temp3,3	
		brne	test_led4

		rjmp	test_led19_000


	;-----------------------------------
test_led4:	cpi	temp3,4	
		breq	test_led4_1
		rjmp	test_led5



test_led4_1:
		rcall	wait_ft0
		rcall	METadc1		;проверка на замыкание проводов
		subi	temp,2
		mov	temp7,temp
		out	udr,temp

		ldi	temp,0x8A	;
		mov	temp5,temp
		ldi	temp,0x80	;
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led4_2

		ldi	temp,0x41
		mov	err_ind,temp
		rjmp	test_led_ret


test_led4_2:

		rcall	wait_ft0
		rcall	METadc2		;проверка на то что 3,5мм jack не вставлен
		out	udr,temp

		subi	temp,0xF0
		brcc	test_led4_3

		ldi	temp,0x42
		mov	err_ind,temp
		rjmp	test_led_ret


test_led4_3:	rcall	short_beep


		ldi	temp,255	;3sec
		mov	temp8,temp

test_led4_31:	dec	temp8
		brne	test_led4_32

		ldi	temp,0x43
		mov	err_ind,temp
		rjmp	test_led_ret

test_led4_32:
		rcall	wait_ft0
		rcall	METadc2		;
		out	udr,temp

		subi	temp,0x05
		brcc	test_led4_31	;проверка на то что 3,5мм jack вставлен


		ldi	temp,20
test_led4_33:	rcall	wait_ft0
		dec	temp
		brne	test_led4_33


		rcall	wait_ft0
		rcall	METadc3		;
		;subi	temp,2
		mov	temp7,temp
		out	udr,temp

		ldi	temp,0x3A	;проверка левого канала
		mov	temp5,temp
		ldi	temp,0x30	;
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led4_4

		ldi	temp,0x44
		mov	err_ind,temp
		rjmp	test_led_ret


test_led4_4:
		rcall	wait_ft0
		rcall	METadc4		;
		;subi	temp,2
		mov	temp7,temp
		out	udr,temp

		ldi	temp,0x1B	;;проверка правого канала
		mov	temp5,temp
		ldi	temp,0x10	;
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led4_5

		ldi	temp,0x44
		mov	err_ind,temp
		rjmp	test_led_ret


test_led4_5:


		rjmp	test_led_ret


	;-----------------------------------
test_led5:	cpi	temp3,5	
		brne	test_led6



		rjmp	test_led19_000


	;-----------------------------------
test_led6:	cpi	temp3,6	
		brne	test_led7


		rjmp	test_led19_000

	;-----------------------------------
test_led7:	cpi	temp3,7	
		brne	test_led10


		rjmp	test_led19_000

	;-----------------------------------
test_led10:	cpi	temp3,10	
		brne	test_led11


		rjmp	test_led19_000


	;-----------------------------------
test_led11:	cpi	temp3,11	
		breq	test_led11_0
		rjmp	test_led12

test_led11_0:
;PINpower12v - IO5
;PINadj - IO6
;PINblon - IO7

;output CN2 - IO1
;output CN4 - IO2
;output CN5 - IO3
;output CN3 - IO4

		rcall	wait_ft0
		rcall	wait_ft0
		rcall	wait_ft0



		rcall	METadc4		;test PINpower12v
		subi	temp,2
		mov	temp7,temp
		out	udr,temp
		
		;rjmp	test_led11_1	;!!!!!!

		ldi	temp,0xFF	;0xD5
		mov	temp5,temp
		ldi	temp,0xA0	;0xCE
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led11_1

		ldi	temp,0x41
		mov	err_ind,temp
		rjmp	test_led11_ret

test_led11_1:
		rcall	wait_ft0
		rcall	METadc5		;test PINadj
		subi	temp,1
		mov	temp7,temp
		out	udr,temp

		;rjmp	test_led11_2	;!!!!!!


		ldi	temp,0xE0	;0xD0
		mov	temp5,temp
		ldi	temp,0xC0	;0xC8
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led11_2

		ldi	temp,0x42
		mov	err_ind,temp
		rjmp	test_led11_ret

test_led11_2:
		rcall	wait_ft0
		rcall	METadc6		;test PINblon

		mov	temp7,temp
		out	udr,temp

		;rjmp	test_led11_3	;!!!!!!



		ldi	temp,0xEA	;0xA7
		mov	temp5,temp
		ldi	temp,0xA0	;0x9E
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led11_3

		ldi	temp,0x43
		mov	err_ind,temp
		rjmp	test_led11_ret

test_led11_3:

		call	invertor_ON


		rcall	METadc0		
		mov	temp7,temp
		out	udr,temp

		;rjmp	test_led11_5	;!!!!!

		ldi	temp,0x03
		mov	temp5,temp
		ldi	temp,0x00
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led11_5

		ldi	temp,0x44
		mov	err_ind,temp
		rjmp	test_led11_ret


test_led11_5:	rcall	wait_ft0
		rcall	METadc1		
		mov	temp7,temp
		out	udr,temp

		;rjmp	test_led11_6	;!!!!!

		ldi	temp,0x03
		mov	temp5,temp
		ldi	temp,0x00
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led11_6

		ldi	temp,0x45
		mov	err_ind,temp
		rjmp	test_led11_ret


test_led11_6:	rcall	wait_ft0
		rcall	METadc2
		mov	temp7,temp
		out	udr,temp

		;rjmp	test_led11_7	;!!!!!

		ldi	temp,0x24
		mov	temp5,temp
		ldi	temp,0x18
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led11_7

		ldi	temp,0x46
		mov	err_ind,temp
		rjmp	test_led11_ret


test_led11_7:	rcall	wait_ft0
		rcall	METadc3		
		mov	temp7,temp
		out	udr,temp

		;rjmp	test_led11_8	;!!!!!

		ldi	temp,0x24
		mov	temp5,temp
		ldi	temp,0x18
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led11_8

		ldi	temp,0x47
		mov	err_ind,temp
		rjmp	test_led11_ret
test_led11_8:













;		rcall	METadc0
;		out	udr,temp
;
;
;		rcall	wait_ft0
;		rcall	METadc1
;		out	udr,temp
;
;		rcall	wait_ft0
;		rcall	METadc2
;		out	udr,temp
;
;		rcall	wait_ft0
;		rcall	METadc3
;		out	udr,temp



test_led11_ret:	call	prep_IO11_1

		rjmp	test_led_ret




	;-----------------------------------
test_led12:	cpi	temp3,12	
		breq	test_led12_0
		rjmp	test_led13

test_led12_0:
		rcall	wait_ft0
		rcall	wait_ft0
		rcall	wait_ft0



		rcall	METadc4		;test PINpower12v
		dec	temp
		mov	temp7,temp
		out	udr,temp
		


		ldi	temp,0xff
		mov	temp5,temp
		ldi	temp,0xA0
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led12_1

		ldi	temp,0x41
		mov	err_ind,temp
		rjmp	test_led12_ret

test_led12_1:
		rcall	wait_ft0
		rcall	METadc5		;test PINadj
		dec	temp
		mov	temp7,temp
		out	udr,temp


		ldi	temp,0xFF
		mov	temp5,temp
		ldi	temp,0xC0
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led12_2

		ldi	temp,0x42
		mov	err_ind,temp
		rjmp	test_led12_ret

test_led12_2:
		rcall	wait_ft0
		rcall	METadc6		;test PINblon
		
		mov	temp7,temp
		out	udr,temp

		ldi	temp,0xFA	;0xEA
		mov	temp5,temp
		ldi	temp,0xA0	;0xDA
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led12_3

		ldi	temp,0x43
		mov	err_ind,temp
		rjmp	test_led12_ret

test_led12_3:

		call	invertor_ON



		rcall	wait_ft0







		
		sbrs	fl2,fp_tempF1
		rjmp	test_led12_31	

		rcall	METadc3
		rjmp	test_led12_32

test_led12_31:
		rcall	METadc2

test_led12_32:

		mov	temp7,temp
		out	udr,temp



		sbrs	fl2,fp_tempF2
		rjmp	test_led12_33

		ldi	temp,0x76	
		mov	temp5,temp
		ldi	temp,0x60
		mov	temp4,temp

		rjmp	test_led12_34

test_led12_33:

		ldi	temp,0x67	;0x67
		mov	temp5,temp
		ldi	temp,0x4A	;0x5B
		mov	temp4,temp

test_led12_34:

		rcall	calk_border
		brcc	test_led12_4

		ldi	temp,0x44
		mov	err_ind,temp
		rjmp	test_led12_ret


test_led12_4:	sbrc	fl2,fp_tempF2
		rjmp	test_led12_ret

		rcall	wait_ft0

		sbrs	fl2,fp_tempF1
		rjmp	test_led12_41	

		rcall	METadc2
		rjmp	test_led12_42

test_led12_41:
		rcall	METadc3

test_led12_42:


		
				
		mov	temp7,temp
		out	udr,temp

		ldi	temp,0x42
		mov	temp5,temp
		ldi	temp,0x2A
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led12_5

		ldi	temp,0x45
		mov	err_ind,temp
		rjmp	test_led12_ret
test_led12_5:









test_led12_ret:	rjmp	test_led11_ret

	;-------------------------------------------
test_led13:
		cpi	temp3,13	
		brne	test_led16
	
	
;		rjmp	test_led13_2

		ldi	zl,low(2*prof13_1_data)
		ldi	zh,high(2*prof13_1_data)	
		
		rcall	kbr_brd_set
	
	
		rcall	test_kbr_key

		brcc	test_led13_2

		ldi	temp,0x40
		add	err_ind,temp
		
		rjmp	test_led13_ret

	
test_led13_2:		
		
		LED_OUT2_OFF	;красный
		ldi	temp,10
		rcall	time_delay

		LED_OUT2_ON



		ldi	temp1,5
test_led13_1:
		LED_OUT1_OFF	;зеленый
		
		ldi	temp,1
		rcall	time_delay
		LED_OUT1_ON

		ldi	temp,1
		rcall	time_delay

		dec	temp1
		brne	test_led13_1

test_led13_ret:
		call	prep_IO13_1

		rjmp	test_led_ret

	;-------------------------------------------
test_led16:
		cpi	temp3,16	
		brne	test_led17

		rcall	Flash_led_OK

		rjmp	test_led_ret



	;-------------------------------------------
test_led17:
		cpi	temp3,17	
		brne	test_led18

		rcall	Flash_led_OA

		rjmp	test_led_ret


	;-------------------------------------------
test_led18:
		cpi	temp3,18	
		brne	test_led19

		rcall	Flash_led_OA

		rjmp	test_led_ret





	;-------------------------------------------
test_led19:
		cpi	temp3,19
		breq	test_led19_000
		rjmp	test_led20


test_led19_000:








		lds	temp,buf4094_pinIO
		cbr	temp,f_pinIO1
		sts	buf4094_pinIO,temp
		call	control_outs

		ldi	temp,1
		rcall	time_delay
		

		rcall	METadc1
		out	udr,temp


		subi	temp,0x15
		brcc	test_led19_03


test_led19_01:
		ldi	temp,0xFF
		sts	buf4094_pinIO,temp
		call	control_outs

		ldi	temp,1
		rcall	time_delay
			

		rcall	METadc1
		out	udr,temp


		subi	temp,0xF0
		brcc	test_led19_02

test_led19_03:
		ldi	temp,0x07	;Error -  провод KEY замкнут на соседние провода	
		rjmp	test_led19_ret

test_led19_02:

		ldi	temp,1
		rcall	time_delay

		sbrs	fl2,fp_tempF1
		rjmp	test_led19_021

		sbrc	fl2,fp_tempF2
		rjmp	test_led19_023
		
		ldi	temp,0x35.
		mov	temp6,temp

		ldi	temp,0x30
		mov	temp7,temp
		rjmp	test_led19_022


test_led19_023:
		ldi	temp,0x5A.
		mov	temp6,temp

		ldi	temp,0x53
		mov	temp7,temp
		rjmp	test_led19_022


test_led19_021:
		ldi	temp,0xA0
		mov	temp6,temp

		ldi	temp,0x90
		mov	temp7,temp

test_led19_022:		


		rcall	METadc2		;TEST LIGHT SENSOR
		out	udr,temp

		sub	temp,temp6
		brcc	test_led19_1
test_led19_0:
		ldi	temp,0x06	;Error - неисправен LIGHT SENSOR	
		rjmp	test_led19_ret
test_led19_1:		
		LED_OUT2_OFF	;красный
		ldi	temp,10
		rcall	time_delay

		LED_OUT2_ON

		ldi	temp1,5
test_led19_2:
		LED_OUT1_OFF	;зеленый
		
		ldi	temp,1
		rcall	time_delay
		LED_OUT1_ON

		ldi	temp,1
		rcall	time_delay

		dec	temp1
		brne	test_led19_2

		ldi	counter,40	
test_led19_3:				;test LIGHT SENSOR
		ldi	temp2,3

test_led19_4:	ldi	temp,1
		rcall	time_delay
		LED_OUT2_OFF
		LED_OUT1_ON
		
		ldi	temp,1
		rcall	time_delay

		LED_OUT2_ON
		LED_OUT1_OFF

		dec	counter
		breq	test_led19_0

		rcall	METadc2

		out	udr,temp

		sub	temp,temp7
		brcc	test_led19_3

		dec	temp2
		brne	test_led19_4

		ldi	temp,0

test_led19_ret:
		LED_OUT1_OFF
		LED_OUT2_ON

		rjmp	test_led_ret1

	;------------------------------------
test_led20:	cpi	temp3,20
		brne	test_led21

;		ldi	temp,2
;		rcall	time_delay
;
;		rcall	METadc3
;		out	udr,temp
;		mov	temp7,temp
;
;		ldi	temp,0xC7
;		mov	temp5,temp
;		ldi	temp,0xBB
;		mov	temp4,temp
;		rcall	calk_border
;		brcc	test_led20_1
;test_led20_2:
;		ldi	temp,0x05
;		mov	err_ind,temp
;		rjmp	test_led20_ret
;test_led20_1:
;		ldi	temp,0xFF
;		cbr	temp,f_pinIO3
;		sts	buf4094_pinIO,temp
;		call	control_outs
;
;		ldi	temp,2
;		rcall	time_delay
;
;
;		rcall	METadc3
;		out	udr,temp
;		mov	temp7,temp
;
;		ldi	temp,0x6B
;		mov	temp5,temp
;		ldi	temp,0x60	
;		mov	temp4,temp
;		rcall	calk_border
;		brcs	test_led20_2
;
;test_led20_ret:
;		ldi	temp,0xFF
;		sts	buf4094_pinIO,temp
;		call	control_outs

		rjmp	test_led_ret
	;------------------------------------
test_led21:

		cpi	temp3,21
		brne	test_led22


		rcall	Flash_led_OK

		rjmp	test_led_ret


	;------------------------
test_led22:
		cpi	temp3,22
		brne	test_led24


		rcall	Flash_led_OK

		rjmp	test_led_ret



;test_led22_1:		
;		LED_OUT2_ON	;красный горит
;		ldi	temp,10
;		rcall	time_delay
;
;		LED_OUT2_OFF
;
;		ldi	temp1,5
;test_led22_2:
;		LED_OUT1_ON	;зеленый вспыхивает
;		
;		ldi	temp,1
;		rcall	time_delay
;		LED_OUT1_OFF
;
;		ldi	temp,1
;		rcall	time_delay
;
;		dec	temp1
;		brne	test_led22_2
;
;
;
;test_led22_3:	LED_OUT1_ON
;		LED_OUT2_ON
;
;
;		ldi	temp,15
;		rcall	time_delay
;
;
;		rcall	METadc2		;TEST LIGHT SENSOR
;		out	udr,temp
;
;		mov	temp1,temp
;
;
;
;		clc
;		subi	temp,0x20
;		brcc	test_led22_4
;test_led22_0:
;		ldi	temp,0x06	;Error - неисправен LIGHT SENSOR	
;		mov	err_ind,temp
;		rjmp	test_led22_ret
;
;
;test_led22_4:	
;
;
;test_led22_5:	LED_OUT2_OFF
;
;		ldi	temp2,40
;		
;test_led22_6:	dec	temp2
;		breq	test_led22_0
;	
;		ldi	temp,1
;		rcall	time_delay
;
;		rcall	METadc2	
;		
;		subi	temp,10
;		brcc	test_led22_6
;		
;
;
;test_led22_ret:	LED_OUT1_OFF
;		LED_OUT2_OFF
;		rjmp	test_led_ret






	;------------------------
test_led24:
		cpi	temp3,24
		brne	test_led25


;		ldi	temp,15
;		rcall	time_delay
;
;		rcall	METadc2		;TEST LIGHT SENSOR
;		out	udr,temp
;
;		clc
;		subi	temp,0xA0
;		brcc	test_led24_4
;test_led24_0:
;		ldi	temp,0x06	;Error - неисправен LIGHT SENSOR	
;		mov	err_ind,temp
;		rjmp	test_led24_ret
;
;
;test_led24_4:	
;
;		ldi	temp,10
;test_led24_5:
;		rcall	wait_ft0
;		dec	temp
;		brne	test_led24_5
;
;		rcall	short_beep
;
;	
;		ldi	temp2,40
;		
;test_led24_6:	dec	temp2
;		breq	test_led24_0
;	
;		ldi	temp,1
;		rcall	time_delay
;
;		rcall	METadc2	
;		
;		subi	temp,0x50
;		brcc	test_led24_6
;		
;
;
;test_led24_ret:	

		rjmp	test_led_ret


	;------------------------
test_led25:
		cpi	temp3,25
		brne	test_led27



;		LED_OUT2_ON	;красный горит
;		ldi	temp,10
;		rcall	time_delay
;
;		LED_OUT2_OFF
;
;		ldi	temp1,5
;test_led25_2:
;		LED_OUT1_ON	;зеленый вспыхивает
;		
;		ldi	temp,1
;		rcall	time_delay
;		LED_OUT1_OFF
;
;		ldi	temp,1
;		rcall	time_delay
;
;		dec	temp1
;		brne	test_led25_2
;
;
;		ldi	temp1,5
;test_led25_4:
;		ldi	temp,0x00
;		sbr	temp,f_pinIO4
;		sts	buf4094_pinIO,temp
;		call	control_outs	
;		
;		ldi	temp,1
;		rcall	time_delay
;
;		ldi	temp,0x00
;		sts	buf4094_pinIO,temp
;		call	control_outs
;
;		ldi	temp,1
;		rcall	time_delay
;
;		dec	temp1
;		brne	test_led25_4
;
;
;
;		ldi	temp,0x00
;		sbr	temp,f_pinIO5
;		sts	buf4094_pinIO,temp
;		call	control_outs
;
;
;		ldi	temp,10
;		rcall	time_delay
;
;
;		ldi	temp1,5
;test_led25_3:
;		ldi	temp,0x00
;		sbr	temp,f_pinIO6
;		sts	buf4094_pinIO,temp
;		call	control_outs	
;		
;		ldi	temp,1
;		rcall	time_delay
;
;		ldi	temp,0x00
;		sts	buf4094_pinIO,temp
;		call	control_outs
;
;		ldi	temp,1
;		rcall	time_delay
;
;		dec	temp1
;		brne	test_led25_3
;
;
;		call	prep_IO25_1


		rjmp	test_led_ret




	;------------------------
;test_led26:
;		cpi	temp3,26
;		brne	test_led27


;		rjmp	test_led_ret

	;------------------------
test_led27:
		cpi	temp3,27
		breq	test_led27_0
		rjmp	test_led30


test_led27_0:		
		rcall	METadc1

		ldi	temp,5
		rcall	time_delay

		rcall	METadc1


test_led27_1:		
		rcall	METadc1
		mov	temp7,temp

		lds	temp5,key1_dataH
		lds	temp4,key1_dataL
		rcall	calk_border
		brcc	test_led27_2

		ldi	temp,0x11	;Error - 	
		mov	err_ind,temp
		rjmp	test_led27_ret


test_led27_2:
		rcall	METadc2
		mov	temp7,temp

		lds	temp5,key2_dataH
		lds	temp4,key2_dataL
		rcall	calk_border
		brcc	test_led27_3

		ldi	temp,0x12	;Error - 	
		mov	err_ind,temp
		rjmp	test_led27_ret


test_led27_3:
		rcall	METadc3
		mov	temp7,temp

		lds	temp5,key3_dataH
		lds	temp4,key3_dataL
		rcall	calk_border
		brcc	test_led27_4

		ldi	temp,0x13	;Error - 	
		mov	err_ind,temp
		rjmp	test_led27_ret


test_led27_4:	rcall	METadc4
		mov	temp7,temp

		lds	temp5,key4_dataH
		lds	temp4,key4_dataL
		rcall	calk_border
		brcc	test_led27_5

		ldi	temp,0x14	;Error - 	
		mov	err_ind,temp
		rjmp	test_led27_ret


test_led27_5:	rcall	METadc5
		mov	temp7,temp

		lds	temp5,key5_dataH
		lds	temp4,key5_dataL
		rcall	calk_border
		brcc	test_led27_6

		ldi	temp,0x15	;Error - 	
		mov	err_ind,temp
		rjmp	test_led27_ret


test_led27_6:	rcall	METadc6
		dec	temp
		dec	temp
		mov	temp7,temp

		lds	temp5,key6_dataH
		lds	temp4,key6_dataL
		rcall	calk_border
		brcc	test_led27_7

		ldi	temp,0x16	;Error - 	
		mov	err_ind,temp
		rjmp	test_led27_ret


test_led27_7:


test_led27_ret:
		rjmp	test_led_ret

	;------------------------
test_led30:
		cpi	temp3,30
		breq	test_led30_01	
		rjmp	test_led31

test_led30_01:

		cbi	porta,pinIO5

		ldi	temp,0b00000000		;Display mode setting commands - 6 digits 16 segments
		rcall	SER_OUT

;		ldi	temp,0b00000100		;Display mode setting commands - 6 digits 16 segments
;		rcall	SER_OUT

		
		sbi	porta,pinIO5
		rcall	delay_50us
		;cbi	porta,pinIO5



		sbi	porta,pinIO5
		rcall	delay_50us



		;---------- горят все сегменты ------
		rcall	fill_BUF
		rcall	tr_data2VFD_0



		ldi	temp,5
		rcall	time_delay


		ldi	temp,0b11111010	;0
		rcall	trDIG2VFDcontr
	
		ldi	temp,0b10000010	;1
		rcall	trDIG2VFDcontr

		ldi	temp,0b10111001	;2
		rcall	trDIG2VFDcontr

		ldi	temp,0b10101011	;3
		rcall	trDIG2VFDcontr


		ldi	temp,0b11000011	;4
		rcall	trDIG2VFDcontr

		ldi	temp,0b01101011	;5
		rcall	trDIG2VFDcontr

		ldi	temp,0b01111011	;6
		rcall	trDIG2VFDcontr

		ldi	temp,0b10100010	;7
		rcall	trDIG2VFDcontr

		ldi	temp,0b11111011	;8
		rcall	trDIG2VFDcontr

		ldi	temp,0b11101011	;9
		rcall	trDIG2VFDcontr


		call	short_beep
		call	wait_ft0
		call	wait_ft0
		call	short_beep
	
		ldi	fl4,0b11111000
		ldi	temp5,50	

test_led30_1:	cpi	fl4,0xFF
		breq	test_led30_ret

		call	wait_ft0
		call	wait_ft0
		call	wait_ft0

		rcall	RD_VFD_KBR_DATA

		lds	temp1,dd1		

		sbrc	fl4,0
		rjmp	test_led30_2		

;		cpi	temp1,0x44	;0x44
;		brne	test_led30_2
		
		sbrs	temp1,6
		rjmp	test_led30_2

		sbr	fl4,0b00000001
		rjmp	test_led30_5
		

test_led30_2:
		sbrc	fl4,1
		rjmp	test_led30_3		

;		cpi	temp1,0x88	;0x88
;		brne	test_led30_3
	
		sbrs	temp1,7
		rjmp	test_led30_3
			
		sbr	fl4,0b00000010
		rjmp	test_led30_5


test_led30_3:
		sbrc	fl4,2
		rjmp	test_led30_4		

;		cpi	temp1,0x08	;0x88
;		brne	test_led30_4
	
		sbrs	temp1,3
		rjmp	test_led30_4
	
		
		sbr	fl4,0b00000100
;		rjmp	test_led30_4
test_led30_5:
		call	short_beep
test_led30_4:
		dec	temp5
		brne	test_led30_1


		call	test_err_key1

		rjmp	test_led30_ret1

test_led30_ret:	
		;---------- LED горит ---------------
		cbi	porta,pinIO5
		ldi	temp,0b01000001		;Data setting commands - Write data to LED port
		rcall	SER_OUT
		ldi	temp,0b00001000		;зеленый LED горит
		rcall	SER_OUT
		sbi	porta,pinIO5


		ldi	temp,5
		rcall	time_delay
		

		;---------- LED выключить ---------------

		ldi	temp,6
		mov	temp7,temp
test_led30_41:
		ldi	temp,1
		rcall	time_delay

		cbi	porta,pinIO5
		ldi	temp,0b01000001		;Data setting commands - Write data to LED port
		rcall	SER_OUT
		ldi	temp,0b00000100		;LED не горит 
		rcall	SER_OUT
		sbi	porta,pinIO5


		ldi	temp,1
		rcall	time_delay


		cbi	porta,pinIO5
		ldi	temp,0b01000001		;Data setting commands - Write data to LED port
		rcall	SER_OUT
		ldi	temp,0b00001100		;LED не горит 
		rcall	SER_OUT
		sbi	porta,pinIO5

		dec	temp7
		brne	test_led30_41

	
test_led30_ret1:
		rjmp	test_led_ret



	;------------------------
test_led31:
		cpi	temp3,31
		breq	test_led31_0
		rjmp	test_led32

test_led31_0:

		LED_OUT1_OFF
		ldi	temp,5
		rcall	time_delay


		;---------- горят все сегменты ------
		rcall	fill_BUF
		rcall	tr_data2VFD

		;---------- LED горит ---------------
		cbi	porta,pinIO5
		ldi	temp,0b01000001		;Data setting commands - Write data to LED port
		rcall	SER_OUT
		ldi	temp,0b00000000		;LED горит
		rcall	SER_OUT
		sbi	porta,pinIO5



		ldi	temp,5
		rcall	time_delay


		;---------- LED выключить ---------------
		cbi	porta,pinIO5
		ldi	temp,0b01000001		;Data setting commands - Write data to LED port
		rcall	SER_OUT
		ldi	temp,0b00001000		;LED не горит 
		rcall	SER_OUT
		sbi	porta,pinIO5


		ldi	temp,15
		rcall	time_delay


		rcall	INIT_BUF

		

		ldi	yl,low(VFD_BUFFER)
		ldi	yh,high(VFD_BUFFER)			


		ldi	zl,low(2*code_dig0)
		ldi	zh,high(2*code_dig0)

		rcall	shift_data2buf_31


		rcall	tr_data2VFD

		ldi	fl4,0b10000000
		ldi	temp5,50

test_led31_1:
		cpi	fl4,0xFF
		breq	test_led31_ret
		
		rcall	wait_ft0
		rcall	wait_ft0
		rcall	wait_ft0

		rcall	RD_VFD_KBR_DATA
		rcall	shift_data2buf
		rcall	tr_data2VFD

		dec	temp5
		brne	test_led31_1

		;ldi	temp,7
		;mov	err_ind,temp
		
		call	test_err_key1
		
		
		rjmp	test_led31_ret1

test_led31_ret:
		ldi	temp,3
		rcall	time_delay	
test_led31_ret1:
		LED_OUT1_ON



		rjmp	test_led_ret
	;------------------------

	;------------------------
test_led32:
		cpi	temp3,32
		brne	test_led33

		ldi	temp5,5
test_led32_2:
		ldi	temp,0b11111111
		rcall	SER_OUT

		ldi	temp,1
		rcall	time_delay

		ldi	temp,0b11111110
		rcall	SER_OUT

		ldi	temp,1
		rcall	time_delay

		dec	temp5
		brne	test_led32_2

;		ldi	temp5,5

test_led32_1:	
		sbi	porta,pinIO4
		sbi	porta,pinIO2
		rcall	change_led_data

		
		sbi	porta,pinIO3
		sbi	porta,pinIO5
		rcall	change_led_data


		rcall	wait_ft0
		call	short_beep
		rcall	wait_ft0
		rcall	wait_ft0
		call	short_beep


		ldi	temp5,30
		ldi	fl4,0b11111000


test_led32_3:
		sbrc	fl4,0
		rjmp	test_led32_31
		ldi	temp,0b00000001
		rcall	SER_OUT

		sbis	pina,pinIO1
		rjmp	test_led32_31
		sbr	fl4,0b00000001
		rjmp	test_led32_33	


test_led32_31:	sbrc	fl4,1
		rjmp	test_led32_32

		ldi	temp,0b00000010
		rcall	SER_OUT

		sbis	pina,pinIO1
		rjmp	test_led32_32
		sbr	fl4,0b00000010
		rjmp	test_led32_33	

test_led32_32:
		sbrc	fl4,2
		rjmp	test_led32_34


		ldi	temp,0b00000100
		rcall	SER_OUT

		sbis	pina,pinIO1
		rjmp	test_led32_34
		sbr	fl4,0b00000100


test_led32_33:
		call	short_beep
		cpi	fl4,0xFF
		breq	test_led32_ret

test_led32_34:
		ldi	temp,1
		rcall	time_delay



		dec	temp5
		brne	test_led32_3

		call	test_err_key1



test_led32_ret:
		rcall	prep_IO32_1


		rjmp	test_led_ret
	;------------------------




	;------------------------
test_led33:
		cpi	temp3,33
		breq	test_led33_0
		rjmp	test_led35


test_led33_0:

		;ldi	temp,0b01111100
		;out	porta,temp

		ldi	temp5,5
test_led33_2:
		ldi	temp,0b11111111
		rcall	SER_OUT

		ldi	temp,1
		rcall	time_delay

		ldi	temp,0b00000000
		rcall	SER_OUT

		ldi	temp,1
		rcall	time_delay

		dec	temp5
		brne	test_led33_2
	
		sbi	porta,pinIO3
		sbi	porta,pinIO5
		rcall	change_led_data

		
		
		sbi	porta,pinIO4
		sbi	porta,pinIO2
		rcall	change_led_data


		
		ldi	temp,0b01100000
		out	porta,temp

		ldi	temp,1
		rcall	time_delay

		rcall	METadc0
		subi	temp,0xE0
		brcc	test_led33_1

		
test_led33_11:		
		ldi	temp,0x07	;ERROR одна из кнопок нажата	
		mov	err_ind,temp
		rjmp	test_led33_ret


		
test_led33_1:	
	
		rcall	wait_ft0
		call	short_beep
		ldi	temp,1
		rcall	time_delay
		call	short_beep	
	
		ldi	temp,100
		mov	temp6,temp
		
		
		
		ldi	fl4,0b10000000
		rjmp	test_led33_del


	;-------------------------
test_led33_3:
		sbrc	fl4,0
		rjmp	test_led33_31

		cbi	porta,pinIO5

		rcall	met_kbr_ser

		rcall	test_border33_01
;		brcs	test_led33_del
		
		brcs	test_led33_31


		sbr	fl4,0b00000001
		rjmp	test_led33_beep	


test_led33_31:	
		ldi	temp,0b01111110
		out	porta,temp

		sbrc	fl4,1
		rjmp	test_led33_32

		cbi	porta,pinIO4

		rcall	met_kbr_ser

		rcall	test_border33_01
;		brcs	test_led33_del

		brcs	test_led33_32

		sbr	fl4,0b00000010
		rjmp	test_led33_beep



test_led33_32:	ldi	temp,0b01111110
		out	porta,temp


		sbrc	fl4,2
		rjmp	test_led33_33

		cbi	porta,pinIO4

		rcall	met_kbr_ser


		rcall	test_border33_02
;		brcs	test_led33_del

		brcs	test_led33_33

		sbr	fl4,0b00000100
		rjmp	test_led33_beep



test_led33_33:	ldi	temp,0b01111110
		out	porta,temp



		sbrc	fl4,3
		rjmp	test_led33_34

		cbi	porta,pinIO3

		rcall	met_kbr_ser


		rcall	test_border33_01
;		brcs	test_led33_del

		brcs	test_led33_34

		sbr	fl4,0b00001000
		rjmp	test_led33_beep




test_led33_34:	ldi	temp,0b01111110
		out	porta,temp

		sbrc	fl4,4
		rjmp	test_led33_35

		cbi	porta,pinIO2

		rcall	met_kbr_ser


		rcall	test_border33_02
;		brcs	test_led33_del

		brcs	test_led33_35

		sbr	fl4,0b00010000
		rjmp	test_led33_beep



test_led33_35:	ldi	temp,0b01111110
		out	porta,temp


		sbrc	fl4,5
		rjmp	test_led33_36

		cbi	porta,pinIO2

		rcall	met_kbr_ser


		rcall	test_border33_01
;		brcs	test_led33_del


		brcs	test_led33_36

		sbr	fl4,0b00100000
		rjmp	test_led33_beep



test_led33_36:	ldi	temp,0b01111110
		out	porta,temp


		sbrc	fl4,6
		rjmp	test_led33_del

		cbi	porta,pinIO3

		rcall	met_kbr_ser


		rcall	test_border33_02
		brcs	test_led33_del

		sbr	fl4,0b01000000
		rjmp	test_led33_beep










test_led33_beep:
		call	short_beep
		cpi	fl4,0xFF
		breq	test_led33_37

test_led33_del:
		ldi	temp,0b01111110
		out	porta,temp

		ldi	temp,1
		rcall	time_delay
		

test_led33_count:
		dec	temp6
		breq	test_led33_count1
		rjmp	test_led33_3


test_led33_count1:
		call	test_err_key1

		rjmp	test_led33_ret
test_led33_37:
		rcall	Flash_led_OK
test_led33_ret:
		rcall	prep_IO33_1

		rjmp	test_led_ret
	;------------------------

	;------------------------
test_led35:
		cpi	temp3,35
		breq	test_led35_04
		rjmp	test_led36

test_led35_04:	
		ldi	temp,2
		rcall	time_delay



		ldi	zh,high(2*Globo_str1)
		ldi	zl,low(2*Globo_str1)

		rcall	trIICstring
		brcc	test_led35_02

test_led35_03:
		ldi	temp,0x07	;ERROR 	
		mov	err_ind,temp
		
		rjmp	test_led35_ret

test_led35_02:
		rcall	rdIICstring
		;out	udr,temp
		rcall	rdIICstring
		;out	udr,temp

		ldi	temp,20
		rcall	time_delay

;
;		ldi	temp,_cr
;		rcall	tr_1byte



		ldi	zh,high(2*Globo_str3)
		ldi	zl,low(2*Globo_str3)

		rcall	trIICstring
		brcs	test_led35_03


		rcall	rdIICstring
		;out	udr,temp
		rcall	rdIICstring
		;out	udr,temp

;		ldi	temp,_cr
;		rcall	tr_1byte


		ldi	temp,10
		rcall	time_delay


		rcall	wait_ft0
		call	short_beep
		ldi	temp,1
		rcall	time_delay
		call	short_beep


		ldi	fl4,0b10000000
		
		ldi	temp,100
		mov	temp6,temp

	


test_led35_0:
		

		ldi	temp,1
		rcall	time_delay

		dec	temp6
		brne	test_led35_01
		
test_led35_07:		
		call	test_err_key1
		rjmp	test_led35_ret


test_led35_01:

		ldi	zh,high(2*Globo_str2)
		ldi	zl,low(2*Globo_str2)

		rcall	trIICstring
		brcs	test_led35_03


		rcall	rdIICstring
		;out	udr,temp
		rcall	rdIICstring
		;out	udr,temp

			

test_led35_key1:
		sbrc	fl4,0
		rjmp	test_led35_key2
		
		cpi	temp,0x02	;K2
		brne	test_led35_key_ret

		sbr	fl4,0b00000001
		rjmp	test_led35_key_beep

test_led35_key2:
		sbrc	fl4,1
		rjmp	test_led35_key3
		
		cpi	temp,0x04	;K5
		brne	test_led35_key_ret

		sbr	fl4,0b00000010
		rjmp	test_led35_key_beep

test_led35_key3:
		sbrc	fl4,2
		rjmp	test_led35_key4
		
		cpi	temp,0x08	;K3
		brne	test_led35_key_ret

		sbr	fl4,0b00000100
		rjmp	test_led35_key_beep

test_led35_key4:
		sbrc	fl4,3
		rjmp	test_led35_key5
		
		cpi	temp,0x20	;K1
		brne	test_led35_key_ret

		sbr	fl4,0b00001000
		rjmp	test_led35_key_beep

test_led35_key5:
		sbrc	fl4,4
		rjmp	test_led35_key6
		
		cpi	temp,0x40	;K6
		brne	test_led35_key_ret

		sbr	fl4,0b00010000
		rjmp	test_led35_key_beep

test_led35_key6:
		sbrc	fl4,5
		rjmp	test_led35_key7
		
		cpi	temp,0x10	;K4
		brne	test_led35_key_ret

		sbr	fl4,0b00100000
		rjmp	test_led35_key_beep

test_led35_key7:
		sbrc	fl4,6
		rjmp	test_led35_key_ret
		
		cpi	temp,0x01	;K7
		brne	test_led35_key_ret

		sbr	fl4,0b01000000
;		rjmp	test_led35_key_beep
test_led35_key_beep:
		call	short_beep


test_led35_key_ret:

;		ldi	temp,_cr
;		rcall	tr_1byte

		cpi	fl4,0xFF
		breq	test_led35_ret

		rjmp	test_led35_0

	
test_led35_ret:	
		ldi	temp,2
		rcall	time_delay

		rjmp	test_led_ret
	;------------------------


	;------------------------
test_led36:
		cpi	temp3,36
		breq	test_led36_0	
		rjmp	test_led38

test_led36_0:

		;rjmp	test_led36_0



		;---------- горят все сегменты ------
		rcall	fill_BUF
		rcall	tr_data2VFD

		;---------- LED горит ---------------
		cbi	porta,pinIO5
		ldi	temp,0b01000001		;Data setting commands - Write data to LED port
		rcall	SER_OUT
		ldi	temp,0b00000000		;LED горит
		rcall	SER_OUT
		sbi	porta,pinIO5



		ldi	temp,5
		rcall	time_delay


		;---------- LED выключить ---------------
		cbi	porta,pinIO5
		ldi	temp,0b01000001		;Data setting commands - Write data to LED port
		rcall	SER_OUT
		ldi	temp,0b00001000		;LED не горит 
		rcall	SER_OUT
		sbi	porta,pinIO5


		ldi	temp,15
		call	time_delay


		rcall	INIT_BUF

		

		ldi	yl,low(VFD_BUFFER)
		ldi	yh,high(VFD_BUFFER)			


		ldi	zl,low(2*code2_dig0)
		ldi	zh,high(2*code2_dig0)

		rcall	shift_data2buf_31


		rcall	tr_data2VFD

		ldi	fl4,0b10000000
		ldi	temp5,70

test_led36_1:
		cpi	fl4,0xFF
		breq	test_led36_ret
		
		call	wait_ft0
		call	wait_ft0
		call	wait_ft0

		rcall	RD_VFD_KBR_DATA
		lds	temp,dd1		


test_led36_00:	;rjmp	test_led36_2



		cpi	temp,0xFF
		brne	test_led36_2
	
		ldi	temp,7		;нет связи с контроллером
		mov	err_ind,temp

		rjmp	test_led36_ret1

test_led36_2:
		rcall	shift2_data2buf
		rcall	tr_data2VFD

		;rjmp	test_led36_1
		
		dec	temp5
		brne	test_led36_1

		;ldi	temp,7
		;mov	err_ind,temp
		
		call	test_err_key1
		
		
		rjmp	test_led36_ret1

test_led36_ret:
		rcall	Flash_led_OK


;		ldi	temp,3
;		rcall	time_delay	
test_led36_ret1:
		



		rjmp	test_led_ret
	;------------------------


	;------------------------
test_led38:
		cpi	temp3,38
		brne	test_led40



		rcall	met_kbr_ser

		subi	temp,0xA0
		brcc	test_led38_ret

		ldi	temp,0x06
		mov	err_ind,temp

	
test_led38_ret:		


		rjmp	test_led_ret
	;------------------------



	;------------------------
test_led40:
		cpi	temp3,40
		breq	test_led40_0
		rjmp	test_led42

test_led40_0:
		ldi	temp,50
		mov	temp5,temp

		ldi	temp,0xFF
		cbr	temp,f_pinIO2
		sts	buf4094_pinIO,temp
		call	control_outs

test_led40_1:	ldi	temp,1
		call	time_delay
		
		dec	temp5
		brne	test_led40_11

		ldi	temp,0x41
		mov	err_ind,temp
		rjmp	test_led40_ret


test_led40_11:
		call	METadc3	
		
		subi	temp,0xf0
		brcc	test_led40_1

		call	short_beep
		


		ldi	temp,0xFF
		cbr	temp,f_pinIO1
		sts	buf4094_pinIO,temp
		call	control_outs


test_led40_2:	ldi	temp,1
		call	time_delay
		
		dec	temp5
		brne	test_led40_21

		ldi	temp,0x42
		mov	err_ind,temp
		rjmp	test_led40_ret


test_led40_21:
		call	METadc2	
		
		subi	temp,0xf0
		brcc	test_led40_2

		call	short_beep



		ldi	temp,0xFF
		
		sts	buf4094_pinIO,temp
		call	control_outs


test_led40_3:	ldi	temp,1
		call	time_delay
		
		dec	temp5
		brne	test_led40_31

		ldi	temp,0x43
		mov	err_ind,temp
		rjmp	test_led40_ret


test_led40_31:
		call	METadc2	
		
		subi	temp,0xf0
		brcc	test_led40_3

		call	short_beep







test_led40_ret:
		ldi	temp,2
		call	time_delay

		rjmp	test_led_ret

	;------------------------		
test_led42:
		cpi	temp3,42
		brne	test_led43


		rjmp	test_led12_0



	;------------------------		
test_led43:
		cpi	temp3,43
		brne	test_led45

		rjmp	test_led12_0

	;------------------------		
test_led45:
		cpi	temp3,45
		brne	test_led48


		rcall	Flash_led_OK		


		rjmp	test_led_ret



	;------------------------

	;------------------------		
test_led48:
		cpi	temp3,48
		breq	test_led48_0
		rjmp	test_led51

test_led48_0:
		LED_OUT1_Off
	
		sbi	porta,pinIO4
		sbi	porta,pinIO2

		rcall	change_led_data

		sbi	porta,pinIO3
		sbi	porta,pinIO5

		rcall	change_led_data
		
		ldi	temp,0b01100000
		out	porta,temp

		cbi	ddra,pinIO7
		cbi	porta,pinIO7

		ldi	temp,1
		call	time_delay

		call	METadc0
		subi	temp,0xE0
		brcc	test_led48_1
test_led48_11:		
		ldi	temp,0x07	;ERROR одна из кнопок нажата	
		mov	err_ind,temp
		rjmp	test_led48_ret
test_led48_1:	
		call	METadc6
		subi	temp,0xE0
		brcs	test_led48_11

		call	wait_ft0
		call	short_beep
		ldi	temp,1
		call	time_delay
		call	short_beep	

		ldi	temp,100
		mov	temp6,temp
		
		ldi	fl4,0b11000000
		rjmp	test_led48_del
	;-------------------------
test_led48_3:
		sbrc	fl4,0
		rjmp	test_led48_31

		call	METadc6
		mov	temp7,temp
		out	udr,temp

		rcall	test_border48_01
		brcc	test_led48_301
		rjmp	test_led48_del

test_led48_301:
		sbr	fl4,0b00000001
		rjmp	test_led48_beep	

test_led48_31:
		sbrc	fl4,1
		rjmp	test_led48_32

		cbi	porta,pinIO2
		rcall	met_kbr_ser

		rcall	test_border48_01
		brcs	test_led48_del

		sbi	porta,pinIO2

		cbi	porta,pinIO5
		rcall	met_kbr_ser

		rcall	test_border48_02
		brcs	test_led48_del

		sbr	fl4,0b00000010
		rjmp	test_led48_beep	

test_led48_32:
		sbrc	fl4,2
		rjmp	test_led48_33

		cbi	porta,pinIO3
		rcall	met_kbr_ser

		rcall	test_border48_01
		brcs	test_led48_del

		sbi	porta,pinIO3

		cbi	porta,pinIO2
		rcall	met_kbr_ser

		rcall	test_border48_02
		brcs	test_led48_del

		sbr	fl4,0b00000100
		rjmp	test_led48_beep	
test_led48_33:
		sbrc	fl4,3
		rjmp	test_led48_34

		call	METadc6
		mov	temp7,temp
		out	udr,temp

		rcall	test_border48_01
		brcs	test_led48_del

		sbr	fl4,0b00001000
		rjmp	test_led48_beep	

test_led48_34:
		sbrc	fl4,4
		rjmp	test_led48_35

		cbi	porta,pinIO2
		rcall	met_kbr_ser

		rcall	test_border48_01
		brcs	test_led48_del

		sbi	porta,pinIO2

		cbi	porta,pinIO4
		rcall	met_kbr_ser

		rcall	test_border48_01
		
		brcs	test_led48_del

		sbr	fl4,0b00010000
		rjmp	test_led48_beep	
test_led48_35:
		sbrc	fl4,5
		rjmp	test_led48_36

		cbi	porta,pinIO2
		rcall	met_kbr_ser

		rcall	test_border48_01
		brcs	test_led48_del

		sbi	porta,pinIO2

		cbi	porta,pinIO4
		rcall	met_kbr_ser

		rcall	test_border48_02
		
		brcs	test_led48_del

		sbr	fl4,0b00100000
		rjmp	test_led48_beep	
test_led48_36:
		rjmp	test_led48_37

test_led48_beep:
		call	short_beep
		cpi	fl4,0xFF
		breq	test_led48_37
test_led48_del:
		ldi	temp,0b01111110
		out	porta,temp

		ldi	temp,1
		call	time_delay
test_led48_count:
		dec	temp6
		breq	test_led48_count1
		rjmp	test_led48_3


test_led48_count1:
		call	test_err_key1

		rjmp	test_led48_ret
test_led48_37:
		
		ldi	temp1,7
		rcall	Flash_led_OK_1
test_led48_ret:
		rcall	prep_IO33_1
		rjmp	test_led_ret


	;------------------------
test_led51:	cpi	temp3,51
		brne	test_led52
		
		rcall	Flash_led_OA


		rjmp	test_led_ret

	;------------------------
test_led52:	
		cpi	temp3,52
		brne	test_led56



		rjmp	test_led19_000



	;------------------------
test_led56:	
		cpi	temp3,56
		brne	test_led58



		rjmp	test_led19_000

	;------------------------
test_led58:	
		cpi	temp3,58
		brne	test_led60

		ldi	zl,low(2*prof58_1_data)
		ldi	zh,high(2*prof58_1_data)	
	
		rcall	kbr_brd_set
	
	
		rcall	test_kbr_key

		brcc	test_led58_ret

		ldi	temp,0x08
		add	err_ind,temp
		
;		rjmp	test_led58_ret



test_led58_ret:
		ldi	zl,low(2*prof58_data)
		ldi	zh,high(2*prof58_data)	
	
		rcall	kbr_brd_set



		rjmp	test_led_ret


	;------------------------
test_led60:	
		cpi	temp3,60
		brne	test_led68

		;rjmp	test_led4_1


		rcall	Flash_led_OA


		rjmp	test_led_ret




	;-------------------------------------------------------
test_led68:	
		cpi	temp3,68
		breq	test_led68_0
		rjmp	test_led69



test_led68_1E:	ldi	temp,0x41
		mov	err_ind,temp
		rjmp	test_led_ret


test_led68_0:
		ldi	temp,0xFF
		sts	buf4094_pinIO,temp
		call	control_outs	
	
		ldi	temp,20
test_led68_01:	call	wait_ft0
		dec	temp
		brne	test_led68_01










;test_led68_stop: rjmp	test_led68_stop


		in	temp,UDR


;		rjmp	test_led68_1

		;---------------------
		
;		ldi	temp,0xFF
;		cbr	temp,f_pinIO1
;		sts	buf4094_pinIO,temp
;		call	control_outs
;
;		;call	wait_ft0
;
;		call	METadc1
;
;
;		
;		rcall	test_led68_data2	;0x00	
;		brcs	test_led68_1E
;
;		;call	wait_ft0
;
;		call	METadc2
;		rcall	test_led68_data1	;0xFE
;		brcs	test_led68_1E

		;---------------------
		
		ldi	temp,0xFF
		cbr	temp,f_pinIO2
		sts	buf4094_pinIO,temp
		call	control_outs
		
		;call	wait_ft0

		call	METadc2
		rcall	test_led68_data0	;0x96	
		brcs	test_led68_1E

		;call	wait_ft0

		call	METadc3
		rcall	test_led68_data1	;0xFE
		brcs	test_led68_1E

		;---------------------
		
		ldi	temp,0xFF
		cbr	temp,f_pinIO3
		sts	buf4094_pinIO,temp
		call	control_outs

		;call	wait_ft0

		call	METadc3
		rcall	test_led68_data0	;0x9B	
		brcs	test_led68_1E

		;call	wait_ft0

		call	METadc4
		rcall	test_led68_data2	;0x00
		brcs	test_led68_1E


		;---------------------
		
		ldi	temp,0xFF
		cbr	temp,f_pinIO4
		sts	buf4094_pinIO,temp
		call	control_outs

		;call	wait_ft0

		call	METadc4
		rcall	test_led68_data2	;0x00	
		brcs	test_led68_2E

		;call	wait_ft0

		call	METadc5
		rcall	test_led68_data1	;0xFF
		brcs	test_led68_2E


		;---------------------
		
		ldi	temp,0xFF
		cbr	temp,f_pinIO5
		sts	buf4094_pinIO,temp
		call	control_outs

		;call	wait_ft0

		call	METadc5
		rcall	test_led68_data0	;0x9B
		brcs	test_led68_2E

		;call	wait_ft0

		call	METadc6
		rcall	test_led68_data1	;0xFF
		brcs	test_led68_2E


		;---------------------
		
		ldi	temp,0xFF
		cbr	temp,f_pinIO6
		sts	buf4094_pinIO,temp
		call	control_outs

		;call	wait_ft0

		call	METadc6
		rcall	test_led68_data0	;0x9B	
		brcs	test_led68_2E

		;call	wait_ft0

		call	METadc5
		rcall	test_led68_data1	;0xFF
		brcc	test_led68_1

		;rjmp	test_led68_1


test_led68_2E:	ldi	temp,0x41
		mov	err_ind,temp
		rjmp	test_led_ret


test_led68_1:	
		ldi	temp,0xFF
		sts	buf4094_pinIO,temp
		call	control_outs	


	
		in	temp,UDR


		ldi	temp,0b00011000		;RX & TX enable
		out	ucsrb,temp		;

	;	
		call	short_beep
		call	wait_ft0
		call	wait_ft0
		call	short_beep

		ldi	fl4,0b11110000


		ldi	temp,50		;5 сек	на все нажатия, ограничитель продолжительности тестирования
		call	RES_TOUT




test_led68_31:



		ldi	yh,high(rd_buf)
		ldi	yl,low(rd_buf)

		ldi	counter,6


test_led68_3:	cpi	fl4,0xFF
		breq	test_led68_2


		sbrc	fl3,fp_tout
		rjmp	test_led68_21


		in	temp,UCSRA
		sbrs	temp,RXC
		rjmp	test_led68_3
		in	temp,UDR
		out	UDR,temp


		st	y+,temp
		dec	counter
		brne	test_led68_3	
test_led68_3_1:
		ldi	zh,high(2*SatStringChDown)
		ldi	zl,low(2*SatStringChDown)

		rcall	CompareRdData
		brcs	test_led68_3_2

		sbr	fl4,f_key4

		rjmp	test_led68_3_beep

test_led68_3_2:
		ldi	zh,high(2*SatStringChUp)
		ldi	zl,low(2*SatStringChUp)

		rcall	CompareRdData
		brcs	test_led68_3_3

		sbr	fl4,f_key3

		rjmp	test_led68_3_beep

test_led68_3_3:
		ldi	zh,high(2*SatStringVolDown)
		ldi	zl,low(2*SatStringVolDown)

		rcall	CompareRdData
		brcs	test_led68_3_4

		sbr	fl4,f_key2

		rjmp	test_led68_3_beep

test_led68_3_4:
		ldi	zh,high(2*SatStringVolUp)
		ldi	zl,low(2*SatStringVolUp)

		rcall	CompareRdData
		brcs	test_led68_3_5

		sbr	fl4,f_key1

		rjmp	test_led68_3_beep

test_led68_3_5:
		rjmp	test_led68_31


test_led68_3_beep:
		call	short_beep

		rjmp	test_led68_31

test_led68_21:	call	test_err_key1	
		rjmp	test_led68_22




test_led68_2:	ldi	temp,0b00000000		;RX & TX disable
		out	ucsrb,temp		;

		rcall	RemovIrData
		rcall	Ftr_string	;передать IR команду
	
		rcall	test_led68_22

		rcall	RemovIrData
		rcall	Ftr_string	;передать IR команду
	
		rcall	test_led68_22

		rcall	RemovIrData
		rcall	Ftr_string	;передать IR команду

		
		ldi	temp,60		;
		call	RES_TOUT	

test_led68_221:	sbrc	fl3,fp_tout
		rjmp	test_led68_222
		

		call	wait_ft0

		call	METadc4
		
		subi	temp,0x80

		brcs	test_led68_221
		rjmp	test_led68_22

test_led68_222:
		ldi	temp,0x42
		mov	err_ind,temp
		rjmp	test_led_ret


		rcall	test_led68_22


test_led68_ret:	rjmp	test_led_ret


	;------------------------


test_led69:	cpi	temp3,69
		brne	test_led72

		ldi	zl,low(2*prof69_1_data)
		ldi	zh,high(2*prof69_1_data)	
	
		rcall	kbr_brd_set
	
		rcall	test_kbr_key

		brcc	test_led69_ret

		ldi	temp,0x07
		add	err_ind,temp
	
test_led69_ret:
		ldi	zl,low(2*prof69_data)
		ldi	zh,high(2*prof69_data)	
	
		rcall	kbr_brd_set

		rjmp	test_led_ret






	;----------------------------
test_led72:	
		cpi	temp3,72
		brne	test_led75

		rcall	Flash_led_OK

		rjmp	test_led_ret



	;----------------------------
test_led75:	
		cpi	temp3,75
		breq	test_led75_0
		rjmp	test_led76

test_led75_0:
		


		;call	wait_ft0
		;call	wait_ft0
		;ldi	temp,_CR
		;out	UDR,temp
		;call	wait_ft0

		call	METadc4
		;out	UDR,temp
		
		subi	temp,0x05
		brcs	test_led75_1

		ldi	temp,0x42
		mov	err_ind,temp
		
		rjmp	test_led75_ret

test_led75_1:
		;---------------------
		ldi	temp,0xFF
		cbr	temp,f_pinIO1
		sts	buf4094_pinIO,temp
		call	control_outs

		call	wait_ft0
		call	wait_ft0
		;call	wait_ft0
		;call	wait_ft0


		call	METadc1
		;out	UDR,temp

		subi	temp,0x05
		brcc	test_led75_err


		;call	wait_ft0
		call	METadc2
		;out	UDR,temp

		subi	temp,0xF0
		brcs	test_led75_err	

;		rjmp	test_led75_ret

		;---------------------
		ldi	temp,0xFF
		cbr	temp,f_pinIO2
		sts	buf4094_pinIO,temp
		call	control_outs

		;call	wait_ft0
		call	METadc2
		;out	UDR,temp
		
		subi	temp,0x05
		brcc	test_led75_err


		;call	wait_ft0
		call	METadc3
		;out	UDR,temp
		
		subi	temp,0xF0
		brcs	test_led75_err	

		;---------------------
		ldi	temp,0xFF
		cbr	temp,f_pinIO3
		sts	buf4094_pinIO,temp
		call	control_outs

		;call	wait_ft0
		call	METadc3
		;out	UDR,temp
		
		subi	temp,0x05
		brcc	test_led75_err

		;call	wait_ft0
		call	METadc2
		;out	UDR,temp
		
		subi	temp,0xF0
		brcs	test_led75_err	

		rjmp	test_led75_ret


test_led75_err:
		ldi	temp,0x41
		mov	err_ind,temp
		
test_led75_ret:

		ldi	temp,0xFF
		sts	buf4094_pinIO,temp
		call	control_outs


		rjmp	test_led_ret








	;----------------------------
test_led76:	
		cpi	temp3,76
		breq	test_led76_0	
		rjmp	test_led77


		


test_led76_0:
		call	wait_ft0
		TEST1_IR_IN
		rjmp	test_led76_0


;		call	wait_ft0
;		call	wait_ft0

test_led76_01:
		call	wait_ft0
		TEST0_IR_IN
		rjmp	test_led76_01


		ldi	zh,high(2*lcd_string_testON)		;
		ldi	zl,low(2*lcd_string_testON)
		call	remov_d2lcdBuf_ln2
		sbr	fl3,f_flash_ln2
		call	tr_data2lcd



		call	METadc4		;test PINpower12v
		dec	temp
		mov	temp7,temp
		out	udr,temp

		ldi	temp,0x30
		mov	temp5,temp
		ldi	temp,0x05
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led76_1

		ldi	temp,0x41
		mov	err_ind,temp
		rjmp	test_led76_ret

test_led76_1:
		call	wait_ft0
		call	METadc5		;test PINadj
		dec	temp
		mov	temp7,temp
		out	udr,temp


		ldi	temp,0xFF
		mov	temp5,temp
		ldi	temp,0xE0
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led76_2

		ldi	temp,0x42
		mov	err_ind,temp
		rjmp	test_led76_ret

test_led76_2:
		call	wait_ft0
		call	METadc6		;test PINblon
		
		dec	temp
		mov	temp7,temp
		out	udr,temp
		

		ldi	temp,0xFF	;0xEA
		mov	temp5,temp
		ldi	temp,0xD0	;0xDA
		mov	temp4,temp
		rcall	calk_border
		brcc	test_led76_3

		ldi	temp,0x43
		mov	err_ind,temp
		rjmp	test_led76_ret

test_led76_3:

		rcall	invertorLED_ON

		call	wait_ft0
		call	METadc2
		mov	temp7,temp
		out	udr,temp


		sbrc	fl2,fp_tempF1
		rjmp	test_led76_32


		ldi	temp,0xA8	;41,5...42,5V
		mov	temp5,temp
		ldi	temp,0x8D	;
		mov	temp4,temp

		rjmp	test_led76_31


test_led76_32:	ldi	temp,0xA8	;39,5...40,5V	
		mov	temp5,temp
		ldi	temp,0x88	;
		mov	temp4,temp

test_led76_31:
		rcall	calk_border
		brcc	test_led76_ret

		ldi	temp,0x44
		mov	err_ind,temp
		rjmp	test_led76_ret


test_led76_ret:	rcall	prep_IO11_1

		
		tst	err_ind
		brne	test_led76_ret1

	
		call	end_indic

		call	wait_ft0	
		ldi	temp,_cr
		out	udr,temp


		rjmp	test_led76_0


test_led76_ret1:

		ldi	zh,high(2*lcd_string_ERROR)		;
		ldi	zl,low(2*lcd_string_ERROR)
		call	remov_d2lcdBuf_ln2

		ldi	yh,high(lcd_buf+22)	;
		ldi	yl,low(lcd_buf+22)

		ldi	temp1,_0
		mov	temp,err_ind
		swap	temp
		andi	temp,0x0F

;		ldi	temp1,_0
		add	temp,temp1
		st	y+,temp
		
		mov	temp,err_ind
		andi	temp,0x0F

;		ldi	temp1,_0
		add	temp,temp1
		st	y+,temp

		sbr	fl3,f_flash_ln2
		call	tr_data2lcd

		call	error_ind

		call	end_indic_1


;		ldi	zh,high(2*lcd_string_ready)		;
;		ldi	zl,low(2*lcd_string_ready)
;		call	remov_d2lcdBuf_ln2
;		sbr	fl3,f_flash_ln2
;		call	tr_data2lcd

		ldi	temp,0
		mov	err_ind,temp


		rjmp	test_led76_0




;		rjmp	test_led_ret


	;----------------------------
test_led77:	
		cpi	temp3,77
		brne	test_led78

		rjmp	test_led76_0


	;----------------------------
test_led78:	
		cpi	temp3,78
		breq	test_led78_0	
		rjmp	test_led82

test_led78_0:
		ldi	temp,100
		mov	temp6,temp

test_led78_1:
		call	wait_ft0
		dec	temp6
		brne	test_led78_2

		ldi	temp,0x11
		mov	err_ind,temp
		rjmp	test_led78_ret

test_led78_2:		
		call	METadc2		;test PINblon
		
		mov	temp7,temp
		out	udr,temp
		

		ldi	temp,0x05	;0xEA
		mov	temp5,temp
		ldi	temp,0x00	;0xDA
		mov	temp4,temp
		rcall	calk_border
		brcs	test_led78_1

		call	short_beep


		ldi	temp,100
		mov	temp6,temp

test_led78_11:
		call	wait_ft0
		dec	temp6
		brne	test_led78_21

		ldi	temp,0x12
		mov	err_ind,temp
		rjmp	test_led78_ret

test_led78_21:		
		call	METadc3		;test PINblon
		
		mov	temp7,temp
		out	udr,temp
		

		ldi	temp,0x05	;0xEA
		mov	temp5,temp
		ldi	temp,0x00	;0xDA
		mov	temp4,temp
		rcall	calk_border
		brcs	test_led78_11

		call	short_beep


		ldi	temp,100
		mov	temp6,temp

test_led78_12:
		call	wait_ft0
		dec	temp6
		brne	test_led78_22

		ldi	temp,0x13
		mov	err_ind,temp
		rjmp	test_led78_ret

test_led78_22:		
		call	METadc4		;test PINblon
		
		mov	temp7,temp
		out	udr,temp
		

		ldi	temp,0x05	;0xEA
		mov	temp5,temp
		ldi	temp,0x00	;0xDA
		mov	temp4,temp
		rcall	calk_border
		brcs	test_led78_12

		call	short_beep

		ldi	temp,100
		mov	temp6,temp

test_led78_13:
		call	wait_ft0
		dec	temp6
		brne	test_led78_23

		ldi	temp,0x14
		mov	err_ind,temp
		rjmp	test_led78_ret

test_led78_23:		
		call	METadc0		;test PINblon
		
		mov	temp7,temp
		out	udr,temp
		

		ldi	temp,0x05	;0xEA
		mov	temp5,temp
		ldi	temp,0x00	;0xDA
		mov	temp4,temp
		rcall	calk_border
		brcs	test_led78_13

		call	short_beep


		ldi	temp,100
		mov	temp6,temp

test_led78_14:
		call	wait_ft0
		dec	temp6
		brne	test_led78_24

		ldi	temp,0x15
		mov	err_ind,temp
		rjmp	test_led78_ret

test_led78_24:		
		call	METadc1		;test PINblon
		
		mov	temp7,temp
		out	udr,temp
		

		ldi	temp,0x10	;0xEA
		mov	temp5,temp
		ldi	temp,0x08	;0xDA
		mov	temp4,temp
		rcall	calk_border
		brcs	test_led78_14

		call	short_beep

		ldi	temp,100
		mov	temp6,temp

test_led78_15:
		call	wait_ft0
		dec	temp6
		brne	test_led78_25

		ldi	temp,0x16
		mov	err_ind,temp
		rjmp	test_led78_ret

test_led78_25:		
		call	METadc1		;test PINblon
		
		mov	temp7,temp
		out	udr,temp
		

		ldi	temp,0x20	;0xEA
		mov	temp5,temp
		ldi	temp,0x18	;0xDA
		mov	temp4,temp
		rcall	calk_border
		brcs	test_led78_15

		call	short_beep


		ldi	temp,100
		mov	temp6,temp

test_led78_16:
		call	wait_ft0
		dec	temp6
		brne	test_led78_26

		ldi	temp,0x17
		mov	err_ind,temp
		rjmp	test_led78_ret

test_led78_26:		
		call	METadc0		;test PINblon
		
		mov	temp7,temp
		out	udr,temp
		

		ldi	temp,0x20	;0xEA
		mov	temp5,temp
		ldi	temp,0x18	;0xDA
		mov	temp4,temp
		rcall	calk_border
		brcs	test_led78_16

		call	short_beep


		ldi	temp,100
		mov	temp6,temp

test_led78_17:
		call	wait_ft0
		dec	temp6
		brne	test_led78_27

		ldi	temp,0x18
		mov	err_ind,temp
		rjmp	test_led78_ret

test_led78_27:		
		call	METadc1		;test PINblon
		
		mov	temp7,temp
		out	udr,temp
		

		ldi	temp,0x05	;0xEA
		mov	temp5,temp
		ldi	temp,0x00	;0xDA
		mov	temp4,temp
		rcall	calk_border
		brcs	test_led78_17

		call	short_beep


		ldi	temp,100
		mov	temp6,temp

test_led78_18:
		call	wait_ft0
		dec	temp6
		brne	test_led78_28

		ldi	temp,0x19
		mov	err_ind,temp
		rjmp	test_led78_ret

test_led78_28:		
		call	METadc0		;test PINblon
		
		mov	temp7,temp
		out	udr,temp
		

		ldi	temp,0x10	;0xEA
		mov	temp5,temp
		ldi	temp,0x08	;0xDA
		mov	temp4,temp
		rcall	calk_border
		brcs	test_led78_18

		call	short_beep





test_led78_ret:

		rjmp	test_led_ret



	;----------------------------
test_led82:	
		cpi	temp3,82
		brne	test_led84

		ldi	zl,low(2*prof82_1_data)
		ldi	zh,high(2*prof82_1_data)	
	
		rcall	kbr_brd_set
	
		call	test_kbr_key

		brcs	test_led82_1

		;ldi	temp,0x07
		;add	err_ind,temp
	
	
		rcall	Flash_led_OA
test_led82_1:

		ldi	zl,low(2*prof82_data)
		ldi	zh,high(2*prof82_data)	
	
		rcall	kbr_brd_set

		rjmp	test_led_ret


	;----------------------------
test_led84:	
		cpi	temp3,84
		brne	test_led85

		rcall	Flash_led_OK	

		rjmp	test_led_ret

	;----------------------------
test_led85:	
		cpi	temp3,85
		brne	test_led86



		ldi	zl,low(2*prof85_1_data)
		ldi	zh,high(2*prof85_1_data)	
	
		rcall	kbr_brd_set
	
		call	test_kbr_key

		brcc	test_led85_1

		ldi	temp,0x08
		add	err_ind,temp
	
	
		
test_led85_1:

		ldi	zl,low(2*prof85_data)
		ldi	zh,high(2*prof85_data)	
	
		rcall	kbr_brd_set

		rjmp	test_led_ret



	;----------------------------
test_led86:	
		cpi	temp3,86
		brne	test_led87



;test_led86_0:	rjmp	test_led86_0


		ldi	zl,low(2*prof86_1_data)
		ldi	zh,high(2*prof86_1_data)	
	
		rcall	kbr_brd_set
	
		call	test_kbr_key

		brcc	test_led86_1

		ldi	temp,0x03
		add	err_ind,temp
		rjmp	test_led86_ret	
	
		
test_led86_1:
		ldi	zl,low(2*prof86_2_data)
		ldi	zh,high(2*prof86_2_data)	
	
		rcall	kbr_brd_set
	
		call	test_kbr_key

		brcc	test_led86_2

		ldi	temp,0x04
		add	err_ind,temp
		rjmp	test_led86_ret	
	
		
test_led86_2:
		ldi	zl,low(2*prof86_3_data)
		ldi	zh,high(2*prof86_3_data)	
	
		rcall	kbr_brd_set
	
		call	test_kbr_key

		brcc	test_led86_3

		ldi	temp,0x05
		add	err_ind,temp
		rjmp	test_led86_ret	
	
		
test_led86_3:



test_led86_ret:

		ldi	zl,low(2*prof86_data)
		ldi	zh,high(2*prof86_data)	
	
		rcall	kbr_brd_set

		rjmp	test_led_ret








	;----------------------------
test_led87:	
;		cpi	temp3,87
;		brne	test_led88
		rjmp	test_led_ret



test_led_ret1:	mov	err_ind,temp


test_led_ret:
		call	wait_ft0	
		ldi	temp,_cr
		out	udr,temp

		clc
		tst	err_ind
		breq	test_led_ret3
		sec
test_led_ret3:	


		ret

;-------------------------------------------------
test_led68_22:	ldi	temp,20
test_led68_223:	call	wait_ft0
		dec	temp
		brne	test_led68_223
		ret
;-------------------------------------------------
RemovIrData:	ldi	xh,high(temp_buf)
		ldi	xl,low(temp_buf)
				
		ldi	zh,high(2*SatIrDataKey1)
		ldi	zl,low(2*SatIrDataKey1)

		ldi	counter,144

RemovIrData_1:	lpm	temp,z+
		st	x+,temp
		dec	counter
		brne	RemovIrData_1

		ret
;---------------------------------------------------		
trDIG2VFDcontr:
		rcall	INIT_BUF0
		rcall	tr_data2VFD_0

		ldi	temp,3
		call	time_delay
		ret
;----------------------------------------------------
Ftr_string:	

		;ldi	temp,0 
		;out	tccr0,temp	;остановить счетчик

		cli		

		ldi	xl,low(temp_buf)	;буфер с данными
		ldi	xh,high(temp_buf)
		
		ldi	counter,0		

Ftr_string1:	ld	zh,x+
		ld	zl,x+

		tst	zl
		brne	Ftr_IRbit1_1
		tst	zh
		breq	Ftr_string_ret
		
Ftr_IRbit1_1:	sbi	portd,IR_LED_OUT	;зажечь IR LED
		ldi	temp,10		
Ftr_IRbit1_2:	dec	temp
		brne	Ftr_IRbit1_2
		cbi	portd,IR_LED_OUT	;погасить IR LED

		ldi	temp,56		
Ftr_IRbit1_3:	dec	temp
		brne	Ftr_IRbit1_3

		nop
		nop

		sbiw	zl,1

		brne	Ftr_IRbit1_1

Ftr_string0:	
		ld	zh,x+
		ld	zl,x+

		tst	zl
		brne	Ftr_IRbit0_1
		tst	zh
		breq	Ftr_string_ret



Ftr_IRbit0_1:	cbi	portd,IR_LED_OUT	
		ldi	temp,10		
Ftr_IRbit0_2:	dec	temp
		brne	Ftr_IRbit0_2
		cbi	portd,IR_LED_OUT	

		ldi	temp,56		
Ftr_IRbit0_3:	dec	temp
		brne	Ftr_IRbit0_3

		nop
		nop
		
		sbiw	zl,1

		brne	Ftr_IRbit0_1
	
		inc	counter

		cpi	counter,58
		brne	Ftr_string1

Ftr_string_ret:	
		cbi	portd,IR_LED_OUT

		cbr	fl1,f_t0

		;ldi	temp,0
		;out	TCNT0,temp

		;ldi	temp,0b00000001	;
		;out	timsk,temp

		;ldi	temp,0b00000101	;разрешить работу счетчика TC0, к=1024 
		;out	tccr0,temp	;

		sei

		;call	wait_ft0

		clc
		ret
;---------------------------------------------














CompareRdData:	ldi	yh,high(rd_buf)
		ldi	yl,low(rd_buf)

		sts	temp_H,zh
		sts	temp_L,zl
		
		ldi	temp,size_rd_buf
		mov	temp4,temp

CompareRdData_2:
		lds	zh,temp_H
		lds	zl,temp_L

		ldi	counter,6

CompareRdData_1:
		dec	temp4
		breq	CompareRdData_ret1	

		ld	temp,y+
		lpm	temp1,z+
		cp	temp,temp1
		brne	CompareRdData_2

		dec	counter
		brne	CompareRdData_1

		clc
		rjmp	CompareRdData_ret


CompareRdData_ret1:
		sec

CompareRdData_ret:

		ret
;----------------------------------------------------
test_led68_data2:
		cpi	temp,0xFF
		brne	test_led68_data21
	
		dec	temp

test_led68_data21:
		mov	temp7,temp
		call	wait_ft0	
		out	udr,temp

		ldi	temp1,0x05	;0x00
		mov	temp5,temp1
		
		ldi	temp1,0x00
		mov	temp4,temp1

		rjmp	test_led68_data01

		;-----------------------
test_led68_data1:
		cpi	temp,0xFF
		brne	test_led68_data11
	
		dec	temp

test_led68_data11:
		mov	temp7,temp
		call	wait_ft0	
		out	udr,temp

		ldi	temp1,0xFF	;0xFF
		mov	temp5,temp1
		
		ldi	temp1,0xF0
		mov	temp4,temp1

		rjmp	test_led68_data01

		;--------------------------
test_led68_data0:
		mov	temp7,temp
		call	wait_ft0	
		out	udr,temp

		ldi	temp1,0xB0	;0x9B
		mov	temp5,temp1
		
		ldi	temp1,0x80
		mov	temp4,temp1

test_led68_data01:
		call	calk_border
		
		ret
;----------------------------------------------------
kbr_brd_set:	ldi	yl,low(key1_dataH)
		ldi	yh,high(key1_dataH)

		ldi	counter,18
	
kbr_brd_set_1:	lpm	temp,z+
		st	y+,temp
		dec	counter
		brne	kbr_brd_set_1	

		ret
;----------------------------------------------
trIICstring:	sts	temp_H,zh	
		sts	temp_L,zl

		ldi	temp,10
		mov	temp7,temp

trIICstring_01:	lds	zh,temp_H	
		lds	zl,temp_L


		sbi	ddra,pinIO7
		lpm	counter,z+
		;rcall	send_start

trIICstring1:	lpm	temp,z+	
		;out	udr,temp
		call	send_byte
		
		sbrs	fl3,fp_ack	
		rjmp	trIICstring_ret1

		call	delay_6
		call	delay_6

		dec	counter
		brne	trIICstring1

		sbi	ddra,pinIO7
		call	send_stop
		clc
		rjmp	trIICstring_ret

trIICstring_ret1:
		sbi	ddra,pinIO7
		cbi	ddra,pinIO7

		ldi	temp,_cr
		;out	udr,temp

		ldi	temp,10
trIICstring_ret11:
		call	delay_6
		dec	temp
		brne	trIICstring_ret11



		dec	temp7
		brne	trIICstring_01
		sec
trIICstring_ret:

		;ldi	temp,_cr
		;out	udr,temp

		ret	
;---------------------------------------



;--------------------------------------
rdIICstring:	cbi	ddra,pinIO6	;SDA= "1"

		cli
		sts	ram_temp1,counter
		;push	counter

		ldi	counter,8		;counter
		ldi	temp,0

rdIICstring1:	

		call	delay_6
		call	delay_6
		cbi	ddra,pinIO7	;SCL= "1"
		call	delay_6
		call	delay_6
		call	delay_6
		call	delay_6

		cbr	temp,0b00000001
		sbic	pina,pinIO6
		sbr	temp,0b00000001

		cpi	counter,1
		breq	rdIICstring2
		lsl	temp
rdIICstring2:	

		call	delay_6
		sbi	ddra,pinIO7	;SCL= "0"
		;rcall	delay_6
		dec	counter
		brne	rdIICstring1
		


	

		sbi	ddra,pinIO6	;SDA= "0"

		call	delay_6
		call	delay_6
		cbi	ddra,pinIO7	;SCL= "1"
		call	delay_6
		call	delay_6
		;rcall	delay_6
		;rcall	delay_6
		sbi	ddra,pinIO7	;SCL= "0"


		call	delay_6
		cbi	ddra,pinIO6	;SDA= "1"
		
		call	delay_6



		lds	counter,ram_temp1
		;pop	counter
		sei
		
		ret		

;--------------------------------------
test_border33_01:
		ldi	temp1,0x68
		mov	temp5,temp1
		ldi	temp1,0x50
		mov	temp4,temp1
		call	calk_border
		ret

test_border33_02:
		ldi	temp1,0xB8
		mov	temp5,temp1
		ldi	temp1,0x90
		mov	temp4,temp1
		call	calk_border
		ret
;------------------------------------------
;--------------------------------------
test_border48_01:
		ldi	temp1,0x90
		mov	temp5,temp1
		ldi	temp1,0x60
		mov	temp4,temp1
		call	calk_border
		ret

test_border48_02:
		ldi	temp1,0x20
		mov	temp5,temp1
		ldi	temp1,0x01
		mov	temp4,temp1
		call	calk_border
		ret
;------------------------------------------



met_kbr_ser:
		call	METadc0
		subi	temp,1
		mov	temp7,temp
		out	udr,temp

		ret

;------------------------------------------
Flash_led_OA:		
		LED_OUT2_OFF	;красный горит
		ldi	temp,10
		call	time_delay

		LED_OUT2_ON
Flash_led_OA_2:
		ldi	temp1,5
Flash_led_OA_1:
		LED_OUT1_OFF	;зеленый вспыхивает
		
		ldi	temp,1
		call	time_delay
		LED_OUT1_ON

		ldi	temp,1
		call	time_delay

		dec	temp1
		brne	Flash_led_OA_1


		ret


;----------------------------------


Flash_led_OK:		
		LED_OUT2_ON	;красный горит
		ldi	temp,10
		call	time_delay

		LED_OUT2_OFF
Flash_led_OK_2:
		ldi	temp1,5
Flash_led_OK_1:
		LED_OUT1_ON	;зеленый вспыхивает
		
		ldi	temp,1
		call	time_delay
		LED_OUT1_OFF

		ldi	temp,1
		call	time_delay

		dec	temp1
		brne	Flash_led_OK_1


		ret


;----------------------------------
change_led_data:
		ldi	counter,0

change_led_data1:
		ldi	zl,low(2*led_dig)
		ldi	zh,high(2*led_dig)
		
		mov	temp,counter
		tst	temp
		breq	change_led_data3

change_led_data2:
		
		adiw	zl,1
		dec	temp
		brne	change_led_data2

change_led_data3:

		lpm	temp,z
		rcall	SER_OUT

		ldi	temp,1
		call	time_delay
		
		inc	counter
		cpi	counter,10
		brne	change_led_data1

;		cpi	temp3,33
;		brne	change_led_data32
;
;		ldi	temp,0b01111110
;		out	porta,temp
;		rjmp	change_led_data31

;change_led_data32:			
		ldi	temp,0b01100000
		out	porta,temp

change_led_data31:

		ldi	temp,0b11111111
		rcall	SER_OUT

		

		ret
;-------------------------------------
RD_VFD_KBR_DATA:
		rcall	delay_50us
		cbi	porta,pinIO5

		ldi	temp,0b01000010		;Data setting commands - Read key data
		rcall	SER_OUT

		sbrs	fl2,fp_tempF1
		rjmp	RD_VFD_KBR_DATA_1
		
		rcall	sRD1_keyDATA
		rjmp	RD_VFD_KBR_DATA_2

RD_VFD_KBR_DATA_1:
		rcall	RD1_keyDATA
		
RD_VFD_KBR_DATA_2:
		sbi	porta,pinIO5


		out	udr,temp1

		;cpi	temp,


;		tst	temp
;		breq	RD_VFD_KBR_DATA_ret

;		cbr	fl1,f_sec1


RD_VFD_KBR_DATA_ret:

		rcall	delay_50us
		ret



;---------------------------------------
shift_data2buf:


		ldi	yl,low(VFD_BUFFER)
		ldi	yh,high(VFD_BUFFER)			


		ldi	zl,low(2*code_dig0)
		ldi	zh,high(2*code_dig0)
		

		lds	temp,dd1
shift_data2buf_40:
		cpi	temp,0b00000001
		brne	shift_data2buf_41

		sbr	fl4,0b00000100
		ldi	temp,3
		rjmp	shift_data2buf_5

shift_data2buf_41:
		cpi	temp,0b00000010
		brne	shift_data2buf_42

		sbr	fl4,0b00001000
		ldi	temp,4
		rjmp	shift_data2buf_5

shift_data2buf_42:
		cpi	temp,0b00000100
		brne	shift_data2buf_43

		sbr	fl4,0b00010000
		ldi	temp,5
		rjmp	shift_data2buf_5

shift_data2buf_43:
		cpi	temp,0b00001000
		brne	shift_data2buf_44

		sbr	fl4,0b00100000
		ldi	temp,6
		rjmp	shift_data2buf_5


shift_data2buf_44:
		cpi	temp,0b00010000
		brne	shift_data2buf_45

		sbr	fl4,0b00000010
		ldi	temp,2
		rjmp	shift_data2buf_5

shift_data2buf_45:
		cpi	temp,0b00100000
		brne	shift_data2buf_46

		sbr	fl4,0b01000000
		ldi	temp,7
		rjmp	shift_data2buf_5

shift_data2buf_46:
		sbic	pina,pinIO3
		rjmp	shift_data2buf_ret

		ldi	temp,1
		sbr	fl4,0b00000001

shift_data2buf_5:
		
		adiw	zl,2
		adiw	yl,2
		dec	temp
		brne	shift_data2buf_5


shift_data2buf_31:		
		lpm	temp,z+
		st	y+,temp
		lpm	temp,z+
		st	y,temp

		call	short_beep

shift_data2buf_ret:
		ret
;------------------------------------------
shift2_data2buf:
		ldi	yl,low(VFD_BUFFER)
		ldi	yh,high(VFD_BUFFER)			


		ldi	zl,low(2*code2_dig0)
		ldi	zh,high(2*code2_dig0)
		

		lds	temp,dd1
shift2_data2buf_40:
		
		cpi	temp,0x20
		brne	shift2_data2buf_41

		sbr	fl4,0b00000001
		ldi	temp,1
		rjmp	shift2_data2buf_5

shift2_data2buf_41:
		cpi	temp,0x40
		brne	shift2_data2buf_42

		sbr	fl4,0b00000010
		ldi	temp,2
		rjmp	shift2_data2buf_5

shift2_data2buf_42:
		cpi	temp,0x80
		brne	shift2_data2buf_43

		sbr	fl4,0b00000100
		ldi	temp,3
		rjmp	shift2_data2buf_5

shift2_data2buf_43:
		cpi	temp,0x02
		brne	shift2_data2buf_44

		sbr	fl4,0b00001000
		ldi	temp,4
		rjmp	shift2_data2buf_5

shift2_data2buf_44:
		cpi	temp,0x01
		brne	shift2_data2buf_45

		sbr	fl4,0b00010000
		ldi	temp,5
		rjmp	shift2_data2buf_5

shift2_data2buf_45:
		cpi	temp,0x08
		brne	shift2_data2buf_46

		sbr	fl4,0b00100000
		ldi	temp,6
		rjmp	shift2_data2buf_5

shift2_data2buf_46:
		cpi	temp,0x04
		brne	shift2_data2buf_ret

		ldi	temp,7
		sbr	fl4,0b01000000

shift2_data2buf_5:
		
		adiw	zl,2
		adiw	yl,2
		dec	temp
		brne	shift2_data2buf_5


shift2_data2buf_31:		
		lpm	temp,z+
		st	y+,temp
		lpm	temp,z+
		st	y,temp

		call	short_beep

shift2_data2buf_ret:
		ret
;------------------------------------------



tr_data2VFD:	cbi	porta,pinIO5

		ldi	temp,0b00000000		;Display mode setting commands - 6 digits 16 segments
		rcall	SER_OUT

;		ldi	temp,0b00000100		;Display mode setting commands - 6 digits 16 segments
;		rcall	SER_OUT

		
		sbi	porta,pinIO5
		rcall	delay_50us
		cbi	porta,pinIO5



		sbi	porta,pinIO5
		rcall	delay_50us
;		cbi	porta,pinIO5
;
;		ldi	temp,0b01000001		;Data setting commands - Write data to LED port
;		rcall	SER_OUT
;
;
;		ldi	temp,0b00001000		;LED Data 
;		bst	fl1,fp_sec1
;;		bld	temp,3
;		
;
;
;		rcall	SER_OUT
;
;
;		sbi	porta,pinIO5
;		rcall	delay_50us


tr_data2VFD_0:

		cbi	porta,pinIO5




		ldi	temp,0b01000000		;Data setting commands - Write data to display memory, Increments address, Nomal operation
		rcall	SER_OUT

		sbi	porta,pinIO5
		rcall	delay_50us
		cbi	porta,pinIO5

		ldi	temp,0b11000000		;Address setting commands 
		rcall	SER_OUT

		ldi	yl,low(VFD_BUFFER)
		ldi	yh,high(VFD_BUFFER)

		ldi	temp1,16

	
tr_data2VFD_1:	ld	temp,y+
		rcall	SER_OUT		;DATA 

		dec	temp1
		brne	tr_data2VFD_1


		sbi	porta,pinIO5
		rcall	delay_50us
		cbi	porta,pinIO5

		ldi	temp,0b10001111		;Display control commands
		rcall	SER_OUT


		sbi	porta,pinIO5


		ret

;--------------------------------------------
RD1_keyDATA:	
		ldi	temp1,0
		
		;CLK_1
		sbi	porta,pinIO6


		rcall	del_clk

		sbic	pina,pinIO4
		sbr	temp1,0b00000001

		
		rcall	del_clk

		sbic	pina,pinIO4
		sbr	temp1,0b00000010

		rcall	del_clk

		sbic	pina,pinIO4
		sbr	temp1,0b00000100

		rcall	del_clk

		sbic	pina,pinIO4
		sbr	temp1,0b00001000


		rcall	del_clk

		sbic	pina,pinIO4
		sbr	temp1,0b00010000

		rcall	del_clk

		sbic	pina,pinIO4
		sbr	temp1,0b00100000


		rcall	del_clk

		sbic	pina,pinIO4
		sbr	temp1,0b01000000


		rcall	del_clk

		sbic	pina,pinIO4
		sbr	temp1,0b10000000

		rcall	delay_10us


		sts	dd1,temp1


		ret
;----------------------------------------------
sRD1_keyDATA:	
		ldi	temp1,0
		
		;CLK_1
		sbi	porta,pinIO6


		rcall	del_clk

		sbic	pina,pinIO7
		sbr	temp1,0b00000001

		
		rcall	del_clk

		sbic	pina,pinIO7
		sbr	temp1,0b00000010

		rcall	del_clk

		sbic	pina,pinIO7
		sbr	temp1,0b00000100

		rcall	del_clk

		sbic	pina,pinIO7
		sbr	temp1,0b00001000


		rcall	del_clk

		sbic	pina,pinIO7
		sbr	temp1,0b00010000

		rcall	del_clk

		sbic	pina,pinIO7
		sbr	temp1,0b00100000


		rcall	del_clk

		sbic	pina,pinIO7
		sbr	temp1,0b01000000


		rcall	del_clk

		sbic	pina,pinIO7
		sbr	temp1,0b10000000

		rcall	delay_10us


		sts	dd1,temp1


		ret
;----------------------------------------------

;----------------------------------------
del_clk:	rcall	delay_10us

		;CLK_0
		cbi	porta,pinIO6
		rcall	delay_10us	
		;CLK_1
		sbi	porta,pinIO6
		ret
;------------------------------------------
fill_BUF:	ldi	temp,0xFF
		rjmp	INIT_BUF0

INIT_BUF:	ldi	temp,0
INIT_BUF0:
		ldi	yl,low(VFD_BUFFER)
		ldi	yh,high(VFD_BUFFER)
		
		ldi	counter,16
		

INIT_BUF1:	st	y+,temp
		dec	counter
		brne	INIT_BUF1

		

		ret
;-----------------------------------------
SER_OUT:	
		sbi	ddra,pinIO7
				

		push	counter
		ldi	counter,8

SER_OUT_1:	;D_toIN_0
		cbi	porta,pinIO7
		sbrc	temp,0
		sbi	porta,pinIO7
		;D_toIN_1
		
		;CLK_0
		cbi	porta,pinIO6

		rcall	delay_10us	

		;CLK_1
		sbi	porta,pinIO6

		rcall	delay_10us
				
		lsr	temp
		dec	counter
		brne	SER_OUT_1

		;D_toIN_1
		sbi	porta,pinIO7
		;CLK_1
		sbi	porta,pinIO6


		cbi	ddra,pinIO7
		
		pop	counter
		ret		
;-----------------------------------
delay_50us:
		push	counter
		ldi	counter,115
		rjmp	delay_10us_1

delay_10us:	push	counter
		ldi	counter,23
delay_10us_1:		
		dec	counter
		brne	delay_10us_1	

		pop	counter
		ret
;-----------------------------------
invertorLED_ON:

		LED_OUT1_ON	

		ldi	temp,0x00
		sts	buf4094_pinIO,temp
		call	control_outs

		sbi	ddra,pinIO6
		cbi	porta,pinIO6	;IO6 as OUTPUT		

		sbi	ddra,pinIO7
		sbi	porta,pinIO7	;IO7 as OUTPUT	



		ldi	counter,33
invertorLED_ON_1:	
		call	wait_ft0
		dec	counter
		brne	invertorLED_ON_1


		ret

;-------------------------------------
invertor_ON:

		LED_OUT1_ON	

		ldi	temp,0x00
		sts	buf4094_pinIO,temp
		call	control_outs

		sbi	ddra,pinIO6
		cbi	porta,pinIO6	;IO6 as OUTPUT		

		sbi	ddra,pinIO7
		sbi	porta,pinIO7	;IO7 as OUTPUT	



		ldi	counter,70
invertor_ON_1:	
		call	wait_ft0
		dec	counter
		brne	invertor_ON_1


		ret
;--------------------------------------


prep_IO:

		ldi	zl,low(prof_mem)
		ldi	zh,high(prof_mem)

		mov	temp,temp3
		rcall	EEPROM_WR


		cpi	temp3,3
		brne	prep_IO4

		rjmp	prep_IO10_1



prep_IO4:
;		cpi	temp3,4
;		brne	prep_IO5
;
;		sbi	ddrd,LED_OUT1
;		sbi	ddrd,LED_OUT2
;
;		LED_OUT1_OFF	
;		LED_OUT2_ON
;
;		cbi	DDRD,LED_OUT3	;AS INPUT
;
;		rjmp	prep_IO_ret


prep_IO5:	cpi	temp3,5
		brne	prep_IO6


		sbr	fl2,f_tempF2


		rjmp	prep_IO10_1


prep_IO6:	cpi	temp3,6
		breq	prep_IO10_1


	
prep_IO7:	cpi	temp3,7
		breq	prep_IO10_1





prep_IO10:	cpi	temp3,10
		brne	prep_IO11
prep_IO10_1:
		rcall	SELECT_POWER_3V3

		sbr	fl2,f_tempF1

		rjmp	prep_IO52_1



;		rjmp	prep_IO_ret	

	;----------------------------------
prep_IO11:	cpi	temp3,11
		brne	prep_IO12

prep_IO11_1:

		sbi	ddrd,LED_OUT1
		LED_OUT1_OFF	


		ldi	temp,0
		out	ddra,temp

		ldi	temp,0
		out	porta,temp

		ldi	temp,0b11110000
		sts	buf4094_pinIO,temp

		call	control_outs


		rjmp	prep_IO_ret


	;----------------------------------
prep_IO12:	cpi	temp3,12
		breq	prep_IO11_1


prep_IO13:	cpi	temp3,13
		brne	prep_IO15
prep_IO13_1:
		sbi	ddrd,LED_OUT1	;OUT1 OUT2 as output
		sbi	ddrd,LED_OUT2

		LED_OUT1_ON		;светодиоды с общим анодом
		LED_OUT2_ON

		call	prepare_buf

		rjmp	prep_IO_ret

prep_IO15:	cpi	temp3,15
		brne	prep_IO16


		rcall	SELECT_POWER_3V3
		rjmp	prep_IO_ret


prep_IO16:	cpi	temp3,16
		brne	prep_IO17

prep_IO16_1:
		sbi	ddrd,LED_OUT1
		sbi	ddrd,LED_OUT2

		LED_OUT1_OFF	
		LED_OUT2_OFF

		rjmp	prep_IO_ret





prep_IO17:	cpi	temp3,17
		brne	prep_IO18


		sbi	ddrd,LED_OUT1
		sbi	ddrd,LED_OUT2

		LED_OUT1_On	
		LED_OUT2_On

		rjmp	prep_IO_ret


prep_IO18:	cpi	temp3,18
		brne	prep_IO19

		rcall	SELECT_POWER_3V3

		sbi	ddrd,LED_OUT1
		sbi	ddrd,LED_OUT2

		LED_OUT1_On	
		LED_OUT2_On



		rjmp	prep_IO_ret







prep_IO19:	cpi	temp3,19
		brne	prep_IO20


		sbi	ddrd,LED_OUT1
		sbi	ddrd,LED_OUT2

		LED_OUT1_OFF	
		LED_OUT2_ON

		rjmp	prep_IO_ret

prep_IO20:	
		cpi	temp3,20
		brne	prep_IO21


		rjmp	prep_IO_ret

prep_IO21:	
		cpi	temp3,21
		brne	prep_IO22
prep_IO21_1:
		sbi	ddrd,LED_OUT1
		sbi	ddrd,LED_OUT2

		LED_OUT1_OFF	
		LED_OUT2_OFF

		cbi	DDRD,LED_OUT3	;AS INPUT

		rjmp	prep_IO_ret

prep_IO22:	
		cpi	temp3,22
		brne	prep_IO24


		rjmp	prep_IO21_1

;		sbi	ddrd,LED_OUT1
;		sbi	ddrd,LED_OUT2
;
;		LED_OUT1_OFF	
;		LED_OUT2_OFF
;
;		cbi	DDRD,LED_OUT3	;AS INPUT
;
;
;		ldi	temp,0xFF
;		cbr	temp,f_pinIO2
;		sts	buf4094_pinIO,temp
;		call	control_outs

;		rjmp	prep_IO_ret

prep_IO24:	
		cpi	temp3,24
		brne	prep_IO25

;		cbi	DDRD,LED_OUT3	;AS INPUT
;
;		ldi	temp,0xFF
;		cbr	temp,f_pinIO2
;		sts	buf4094_pinIO,temp
;		call	control_outs
;
		rjmp	prep_IO_ret




prep_IO25:	
		cpi	temp3,25
		brne	prep_IO27

;prep_IO25_1:
;		ldi	temp,0x00
;;		cbr	temp,f_pinIO2
;		sts	buf4094_pinIO,temp
;		call	control_outs
;
;
;		sbi	ddrd,LED_OUT1
;		sbi	ddrd,LED_OUT2
;
;		LED_OUT1_OFF	
;		LED_OUT2_OFF
;


		rjmp	prep_IO_ret


prep_IO27:	
		cpi	temp3,27
		brne	prep_IO30


		ldi	temp,0x00
		sts	buf4094_pinIO,temp
		call	control_outs


		rjmp	prep_IO_ret


prep_IO30:	
		cpi	temp3,30
		brne	prep_IO31

		sbr	fl2,f_tempF1

		rjmp	prep_IO36_0



prep_IO31:	
		cpi	temp3,31
		brne	prep_IO32




		ldi	temp,0xFF
		sts	buf4094_pinIO,temp
		call	control_outs

		sbi	ddrd,LED_OUT1
		LED_OUT1_ON

;.equ	pinIO3		=2	;pin 38 sw1_pin
;.equ	pinIO4		=3	;pin 37 D_OUT_pin передача данных дисплеем
;.equ	pinIO5		=4	;pin 36 STB_pin
;.equ	pinIO6		=5	;pin 35 CLK_pin
;.equ	pinIO7		=6	;pin 34 D_IN_pin прием данных дисплеем 

prep_IO31_1:
	
		sbi	ddra,pinIO5
		sbi	ddra,pinIO6
		sbi	ddra,pinIO7

		sbi	porta,pinIO5
		sbi	porta,pinIO6
		sbi	porta,pinIO7




		rjmp	prep_IO_ret


prep_IO32:	
		cpi	temp3,32
		brne	prep_IO33


		ldi	temp,0b11111110
		sts	buf4094_pinIO,temp
		call	control_outs

prep_IO32_1:

		ldi	temp,0b01111110
		out	ddra,temp

		ldi	temp,0b01100000
		out	porta,temp


		rjmp	prep_IO_ret


prep_IO33:	
		cpi	temp3,33
		brne	prep_IO36
prep_IO33_1:
	

		ldi	temp,0b01111110
		out	ddra,temp

		ldi	temp,0b01100000
		out	porta,temp

		sbi	ddrd,LED_OUT1
		sbi	ddrd,LED_OUT2

		cbi	portd,LED_OUT1
		cbi	portd,LED_OUT2


		rjmp	prep_IO_ret	



prep_IO36:	
		cpi	temp3,36
		brne	prep_IO37
prep_IO36_0:
		sbi	ddrd,LED_OUT1
		sbi	ddrd,LED_OUT2

		cbi	portd,LED_OUT1
		cbi	portd,LED_OUT2
		
		
		rjmp	prep_IO31_1

		;rjmp	prep_IO_ret


prep_IO37:	
		cpi	temp3,37
		brne	prep_IO42

		rcall	SELECT_POWER_3V3



		;ldi	temp,0xFF
		;cbr	temp,f_pinIO0
		;cbr	temp,f_pinIO1

		;sts	buf4094_pinIO,temp
		;call	control_outs




		rjmp	prep_IO_ret






prep_IO42:	
		cpi	temp3,42
		brne	prep_IO43

		sbr	fl2,f_tempF1

		rjmp	prep_IO11_1

prep_IO43:	
		cpi	temp3,43
		brne	prep_IO45

		sbr	fl2,f_tempF1
		sbr	fl2,f_tempF2

		rjmp	prep_IO11_1


prep_IO45:	
		cpi	temp3,45
		brne	prep_IO46


		sbi	ddrd,LED_OUT1
		sbi	ddrd,LED_OUT2

		cbi	portd,LED_OUT1
		cbi	portd,LED_OUT2
		rjmp	prep_IO_ret

prep_IO46:	
		cpi	temp3,46
		brne	prep_IO47

		rcall	SELECT_POWER_3V3
		rjmp	prep_IO_ret
		;rjmp	prep_IO20_1


prep_IO47:	
		cpi	temp3,47
		brne	prep_IO48

		rcall	SELECT_POWER_3V3
		rjmp	prep_IO_ret


;		rjmp	prep_IO20_1



prep_IO48:	
		cpi	temp3,48
		brne	prep_IO51

		sbi	ddrd,LED_OUT1
		LED_OUT1_OFF



		rjmp	prep_IO33_1



prep_IO51:	
		cpi	temp3,51
		brne	prep_IO52


		rjmp	prep_IO13_1




prep_IO52:	
		cpi	temp3,52
		brne	prep_IO56

prep_IO52_1:
		sbi	ddrd,LED_OUT1
		sbi	ddrd,LED_OUT2		

	


		LED_OUT1_OFF
		LED_OUT2_ON




		rjmp	prep_IO_ret


prep_IO56:	
		cpi	temp3,56
		brne	prep_IO60


		rjmp	prep_IO52_1



prep_IO60:	
		cpi	temp3,60
		brne	prep_IO72

		sbi	ddrd,LED_OUT2
		LED_OUT2_ON


		rjmp	prep_IO_ret

prep_IO72:	
		cpi	temp3,72
		brne	prep_IO76

		rjmp	prep_IO21_1


prep_IO76:	
		cpi	temp3,76
		brne	prep_IO77
prep_IO76_1:
		cbi	DDRD,LED_OUT3	;AS INPUT
		sbi	portD,LED_OUT3	;pullup resistor enable

		rjmp	prep_IO11_1


prep_IO77:	
		cpi	temp3,77
		brne	prep_IO82

		sbr	fl2,f_tempF1

		rjmp	prep_IO76_1


prep_IO82:	
		cpi	temp3,82
		brne	prep_IO84

		rjmp	prep_IO13_1

prep_IO84:	
		cpi	temp3,84
		brne	prep_IO85


		rjmp	prep_IO16_1

	

prep_IO85:	
;		cpi	temp3,85
;		brne	prep_IO86

;		rjmp	prep_IO_ret
prep_IO_ret:

		ret

;--------------------------------------------
SELECT_POWER_3V3:
		lds	temp,buf4094_out
		cbr	temp,f_rel3	;подать питание 3,3v
		sts	buf4094_out,temp
		call	control_outs

		ret
;--------------------------------------------------
EEPROM_WR:	cli

		sbic 	EECR,EEWE
		rjmp 	EEPROM_WR
		
		out	eearh,zh
		out	eearl,zl
		out	EEDR,temp
		nop
		nop
 		sbi 	EECR,EEMWE
 		sbi 	EECR,EEWE
	

EEPROM_WR2: 	sbic 	EECR,EEWE
		rjmp 	EEPROM_WR2 		

		sei
		ret		
;------------------------------------------------
LOAD_EE_DATA:	cli

LOAD_EE_DATA2: 	sbic 	EECR,EEWE
		rjmp 	LOAD_EE_DATA2

		out	eearh,zh
		out	eearl,zl

  		sbi 	eecr,eere 	;прочитать
LOAD_EE_DATA1: 	sbic 	eecr,eere ;
 		rjmp 	LOAD_EE_DATA1 	;если еще не прочитано,то перейти
 		in 	temp,EEDR
 
		sei
		ret 

;--------------------------------------------------------------------




.cseg
;				1	2
code2_dig0:	.db	0b00111100,0b00100100
code2_dig1:	.db	0b00100000,0b00000100
code2_dig2:	.db	0b00111100,0b00011000
code2_dig3:	.db	0b00111000,0b00001100
code2_dig4:	.db	0b00100000,0b00111100
code2_dig5:	.db	0b00011000,0b00111100
code2_dig6:	.db	0b00011100,0b00111100
code2_dig7:	.db	0b00110000,0b00000100
code2_dig8:	.db	0b00111100,0b00111100
code2_dig9:	.db	0b00111000,0b00111100



code_dig0:	.db	0b00010001,0b00001111
code_dig1:	.db	0b00010000,0b00000001
code_dig2:	.db	0b00001110,0b00001111
code_dig3:	.db	0b00011100,0b00000111
code_dig4:	.db	0b00011111,0b00000001
code_dig5:	.db	0b00011111,0b00000110
code_dig6:	.db	0b00011111,0b00001110
code_dig7:	.db	0b00010000,0b00000011
code_dig8:	.db	0b00011111,0b00001111
code_dig9:	.db	0b00011111,0b00000111
;			       0        1         2           3         4           5          6          7         8          9
led_dig:	.db	0b00000011,0b10011111,0b00100101,0b00001101,0b10011001,0b01001001,0b01000001,0b00011111,0b00000001,0b00001001


code3_dig0:	.db	0b11111010;,0b00000000
code3_dig1:	.db	0b10000010;,0b00000000
code3_dig2:	.db	0b10111001;,0b00000000
code3_dig3:	.db	0b10101011;,0b00000000
code3_dig4:	.db	0b11000011;,0b00000000
code3_dig5:	.db	0b01101011;,0b00000000
code3_dig6:	.db	0b01111011;,0b00000000
code3_dig7:	.db	0b10100010;,0b00000000
code3_dig8:	.db	0b11111011;,0b00000000
code3_dig9:	.db	0b11101011;,0b00000000



;bl_trOK:	.DB	6,_CR,_LF,_O,_K,_CR,_LF
;bl_tr_error:	.DB	9,_CR,_LF,_E,_R,_R,_O,_R,_CR,_LF
;bl_tr_ready:	.DB	9,_CR,_LF,_R,_E,_A,_D,_Y,_CR,_LF
;bl_tr_name:	.DB	7,_CR,_LF,_N,_A,_M,_E,_strr
;bl_tr_cmd:	.DB	5,_CR,_LF,_C,_M,_D
;bl_tr_cmd_e:	.DB	4,_C,_M,_D,_strr




;Hdata186_0:	.DB	3,0x86,0x00,0b11010110	;TDA9885
;Hdata186_1:	.DB	3,0x86,0x01,0b01110000  ;TDA9885
;Hdata186_2:	.DB	3,0x86,0x02,0b00001101	;data mode IF 5,5 MHz
;Hdata186_3:	.DB	3,0x86,0x02,0b00001111	;data mode IF 6,5 MHz
;---- SECAM 93MHz ------------------------
;Hdata1C0:	.DB	5,0xC0,0x0A,0x42,0xC8,0x01;,0xD8,0x60	;TDA6500

;---- PAL 210MHz ------------------------
;Hdata2C0:	.DB	5,0xC0,0x13,0x66,0xC8,0x02;,0xD8,0x60	;TDA6500
;

;---- PAL 487MHz ------------------------
;Hdata3C0:	.DB	5,0xC0,0x29,0x0A,0xC8,0x04;,0xD8,0x60	;TDA6500





;================== THOMSON ===============================
;---- SECAM 93MHz ------------------------
;Tdata186_0:	.DB	3,0x84,0x00,0xD6	;TDA9885
;Tdata186_1:	.DB	3,0x84,0x01,0x70    	;TDA9885
;Tdata186_2:	.DB	3,0x84,0x02,0x0F	;TDA9885
;Tdata1C0:	.DB	5,0xC0,0x0A,0x50,0xC8,0x01;,0xD8,0x60	;TDA6500




;---- PAL 210MHz ------------------------
;Tdata2C0:	.DB	5,0xC0,0x13,0x66,0xC8,0x02;0xD8,0x60	;TDA6500


;---- PAL 487MHz ------------------------
;Tdata3C0:	.DB	5,0xC0,0x29,0x0A,0xC8,0x08;,0xD8,0x60	;TDA6500



Globo_str1:	.DB	7,0xB1,0x82,0x01,0x01,0x82,0x01,0x01
Globo_str3:	.DB	7,0xB1,0x41,0x88,0x88,0x41,0x88,0x88

Globo_str2:	.DB	7,0xB1,0xC1,0x00,0x00,0xC1,0x00,0x00





;///////////////////////////////////////////////////////////////////////////////////////
lcd_string_start1:	.DB	_sp,_T,_E,_S,_T,_sp,_C,_Om,_Nm,_Tm,_Rm,_Om,_Lm,_Lm,_Em,_Rm
			.DB	_sp,_sp,_sp,_sp,_sp,_sp,_Vm,_3,_dp,_1,_3,_0,_sp,_sp,_sp,_sp	;v.3.130

lcd_string_start4:	.DB	_M,_Em,_Mm,_Om,_Rm,_Ym,_sp,_E,_R,_R,_O,_R,_sp,_sp,_sp,_sp

lcd_string_ready:	.DB	_R,_Em,_Am,_Dm,_Ym,_sp,_Tm,_Om,_sp,_Tm,_Em,_Sm,_Tm,_sp,_sp,_sp

lcd_string_start5:	.DB	_sp,_S,_Em,_Lm,_Em,_Cm,_Tm,_sp,_D,_E,_V,_I,_C,_E,_sp,_sp
			.DB	_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp

lcd_string_testON:	.DB	_Dm,_Em,_Vm,_Im,_Cm,_Em,_sp,_Tm,_Em,_Sm,_Tm,_Em,_Dm,_sp,_sp,_sp

lcd_string_testOK:	.DB	_T,_Em,_Sm,_Tm,_sp,_O,_K,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp

lcd_string_ERROR:	.DB	_E,_Rm,_Rm,_Om,_Rm,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp


blanc_screen:		.DB	_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp
			.DB	_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp



lcd_string_rdbld:	.DB	_sp,_T,_E,_S,_T,_sp,_C,_Om,_Nm,_Tm,_Rm,_Om,_Lm,_Lm,_Em,_Rm
			.DB	_U,_P,_D,_A,_T,_E,_sp,_S,_O,_F,_T,_W,_A,_R,_E,_sp	

;===============================================================================================
sel_device1:		.DB	_0,_1,_sp,_E,_R,_I,_sp,_1,_5,_L,_E,_J,_1,_0,_sp,_sp
			.DB	_K,_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,_E,_D,_Sm,_zp,_k,_e,_y,_sp,_sp,_sp,_sp,_sp

sel_device85:		.DB	_8,_5,_sp,_H,_mi,_3,_2,_0,_0,_sp,_sp,_sp,_sp,_sp,_sp,_sp
			.DB	_9,_sp,_K,_Em,_Ym,_Sm,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp

sel_device86:		.DB	_8,_6,_sp,_B,_B,_K,_2,_2,_3,_0,_sp,_sp,_sp,_sp,_sp,_sp
			.DB	_7,_sp,_Km,_Em,_Ym,_Sm,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp

sel_device87:		.DB	_8,_7,_sp,_E,_R,_I,_mi,_4,_2,_P,_C,_2,_0,_sp,_sp,_sp
			.DB	_7,_sp,_Km,_Em,_Ym,_Sm,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp,_sp





;===============================================================================================
;байты 0-15: верхняя,нижняя границы послед.кнопок,
;байт 16: проверяемые кнопки (0-проверяется, 1-не проверяется)
;байт 17: 	бит 0 - (1- для проверки кнопок IN6, Pullup resistor = 100kOm)
;		бит 1 - (1- ИК не проверяется)
;		бит 2 - (1- LED не проверяется)
;;		бит 3 - (0- ADC0 1-ADC1 проверить кнопки)
;		бит 4 - (1- проверить аудиовыход - телеф.гнездо)
;		бит 5 - (1- IN0 puldown)
;		бит 6 - (1- дополнит задержка 1 сек перед проверкой кнопок)





prof1_data:	.DB	0x1F,0x15,0x4B,0x41,0x70,0x66,0x1A,0x11,0x05,0x00,0x58,0x4D,0x44,0x3A,0,0,0b10000000,0b00000110
prof2_data:	.DB	0x20,0x16,0x4B,0x41,0x70,0x66,0x58,0x4D,0x44,0x3A,0x1A,0x11,0x05,0x00,0,0,0b10000000,0b00000110
prof3_data:	.DB	0x65,0x59,0x83,0x78,0x05,0x00,0x46,0x3A,0x2E,0x23,0x19,0x10,0,0,0,0,0b11000000,0b00100000
prof4_data:	.DB	0x05,0x00,0x81,0x78,0x39,0x30,0x56,0x4B,0x70,0x65,0x5B,0x51,0x91,0x88,0,0,0b10000000,0b00000010
prof5_data:	.DB	0x26,0x20,0x31,0x2A,0x05,0x00,0x18,0x12,0x12,0x0B,0x0A,0x05,0,0,0,0,0b11000000,0b00100000
prof6_data:	.DB	0x73,0x60,0x95,0x82,0x20,0x10,0x65,0x52,0x56,0x40,0x3A,0x22,0,0,0,0,0b11000100,0b00000000
prof7_data:	.DB	0x83,0x70,0xA5,0x92,0x20,0x10,0x65,0x52,0x49,0x36,0x36,0x22,0,0,0,0,0b11000100,0b00000000
prof8_data:	.DB	0x6B,0x63,0x47,0x3E,0x25,0x1D,0x6A,0x62,0x05,0x00,0x41,0x39,0x54,0x4A,0,0,0b10000000,0b00000110
prof9_data:	.DB	0x6B,0x63,0x47,0x3E,0x85,0x7A,0x26,0x1B,0x05,0x00,0x6B,0x61,0x54,0x4A,0x42,0x37,0b00000000,0b00000110
prof10_data:	.DB	0x83,0x70,0xA5,0x92,0x20,0x10,0x65,0x52,0x49,0x36,0x36,0x22,0,0,0,0,0b11000000,0b00000000
prof11_data:	.DB	0x05,0x00,0x05,0x00,0x44,0x3A,0xB5,0xAA,0x82,0x77,0x44,0x3A,0x82,0x77,0,0,0b11111111,0b00000010
prof12_data:	.DB	0x05,0x00,0x05,0x00,0x44,0x3A,0xB5,0xAA,0x82,0x77,0x44,0x3A,0x82,0x77,0,0,0b11111111,0b00000010
prof13_data:	.DB	0x05,0x00,0x62,0x59,0x33,0x2A,0x48,0x40,0x11,0x08,0x21,0x17,0x82,0x77,0,0,0b11000000,0b00000000
prof14_data:	.DB	0x05,0x00,0x11,0x08,0x21,0x17,0x48,0x40,0x11,0x08,0x21,0x17,0x82,0x77,0,0,0b11111000,0b00000110
prof15_data:	.DB	0x05,0x00,0x86,0x7E,0xC5,0xC1,0x05,0x00,0x44,0x39,0x85,0x7B,0xC6,0xC2,0,0,0b10000000,0b00000110
prof16_data:	.DB	0x55,0x4F,0x37,0x31,0x26,0x1E,0x1B,0x14,0x12,0x0B,0x0A,0x04,0x03,0x00,0,0,0b10000000,0b00000000
prof17_data:	.DB	0x07,0x00,0xB1,0xA8,0xCB,0xC3,0x93,0x88,0x74,0x69,0x55,0x4A,0x32,0x27,0,0,0b10000000,0b00000010

prof18_data:	.DB	0x42,0x37,0x90,0x85,0x9F,0x94,0x80,0x75,0x70,0x65,0x60,0x55,0x4C,0x44,0,0,0b10000000,0b01000010

prof19_data:	.DB	0x05,0x00,0x81,0x78,0x39,0x30,0x56,0x4B,0x70,0x65,0x5B,0x51,0x91,0x88,0,0,0b10000000,0b00000110
prof20_data:	.DB	0x05,0x00,0x8A,0x80,0xC8,0xBA,0x05,0x00,0x46,0x3A,0x8A,0x80,0xC8,0xBA,0,0,0b10000000,0b00000111
prof21_data:	.DB	0x05,0,0x1F,0x12,0x35,0x2A,0x52,0x49,0x6F,0x64,0xA0,0x9A,0x8A,0x80,0,0,0b11111111,0b00000000
prof22_data:	.DB	0x10,0x05,0x34,0x28,0x61,0x5A,0x42,0x38,0x59,0x4E,0x7A,0x70,0x8A,0x80,0,0,0b11000000,0b00000110
prof23_data:	.DB	0x05,0x00,0x86,0x7D,0xF5,0xE8,0x86,0x7D,0xCB,0xC2,0x05,0x00,0x5A,0x50,0,0,0b10000000,0b00000110
prof24_data:	.DB	0x05,0,0x1F,0x12,0x35,0x2A,0x52,0x49,0x6F,0x64,0xA0,0x9A,0x8A,0x80,0,0,0b11111111,0b00000000
prof25_data:	.DB	0x05,0,0x1F,0x12,0x35,0x2A,0x52,0x49,0x6F,0x64,0xA0,0x9A,0x8A,0x80,0,0,0b11111111,0b00000010
prof26_data:	.DB	0x79,0x6F,0x56,0x4A,0x2B,0x22,0x42,0x38,0x13,0x07,0x1F,0x12,0x67,0x5A,0,0,0b11000000,0b00000110
prof27_data:	.DB	0xF0,0xE6,0x90,0x85,0xCA,0xC0,0x57,0x4D,0xB0,0xA4,0xFF,0xFA,0x00,0x00,0,0,0b11111111,0b00000010
prof28_data:	.DB	0x7A,0x70,0x57,0x4D,0x2B,0x22,0x42,0x37,0x13,0x08,0x1B,0x11,0x00,0x00,0,0,0b11000000,0b00000110
prof29_data:	.DB	0x05,0x00,0x11,0x08,0x21,0x17,0x33,0x29,0x48,0x40,0x7A,0x6E,0x62,0x57,0,0,0b10000000,0b00000110
prof30_data:	.DB	0x05,0,0x1F,0x12,0x35,0x2A,0x52,0x49,0x6F,0x64,0xA0,0x9A,0x8A,0x80,0,0,0b11111111,0b00000000
prof31_data:	.DB	0x05,0,0x1F,0x12,0x35,0x2A,0x52,0x49,0x6F,0x64,0xA0,0x9A,0x8A,0x80,0,0,0b11111111,0b00000000
prof32_data:	.DB	0x05,0,0x1F,0x12,0x35,0x2A,0x52,0x49,0x6F,0x64,0xA0,0x9A,0x8A,0x80,0,0,0b11111111,0b00000000
prof33_data:	.DB	0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0,0,0b11111111,0b00000000
prof34_data:	.DB	0x52,0x44,0x0D,0x02,0x1D,0x11,0x42,0x36,0x5A,0x4D,0x6E,0x62,0x82,0x75,0,0,0b10000000,0b00000110
prof35_data:	.DB	0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0,0,0b11111111,0b00000000
prof36_data:	.DB	0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0,0,0b11111111,0b00000000
prof37_data:	.DB	0x7B,0x75,0x83,0x7E,0x8A,0x85,0x91,0x8B,0x98,0x92,0x9F,0x99,0xA6,0xA0,0,0,0b10000000,0b00000110
prof38_data:	.DB	0x7B,0x75,0x83,0x7E,0x8A,0x85,0x91,0x8B,0x98,0x92,0x9F,0x99,0xA6,0xA0,0,0,0b11111111,0b00000000
prof39_data:	.DB	0x05,0x00,0x62,0x59,0x33,0x2A,0x48,0x40,0x11,0x08,0x21,0x17,0x7A,0x70,0,0,0b10000000,0b00000110
prof40_data:	.DB	0x20,0x15,0x4B,0x42,0x70,0x65,0x58,0x4E,0x44,0x3A,0x1B,0x11,0x05,0x00,0,0,0b10000000,0b00000010
prof41_data:	.DB	0x4B,0x42,0x71,0x65,0x05,0x00,0x1B,0x13,0x44,0x3A,0x58,0x4E,0x1F,0x15,0,0,0b10000000,0b00000110
prof42_data:	.DB	0x05,0x00,0x05,0x00,0x44,0x3A,0xB5,0xAA,0x82,0x77,0x44,0x3A,0x82,0x77,0,0,0b11111111,0b00000010
prof43_data:	.DB	0x05,0x00,0x05,0x00,0x44,0x3A,0xB5,0xAA,0x82,0x77,0x44,0x3A,0x82,0x77,0,0,0b11111111,0b00000010
prof44_data:	.DB	0x5A,0x53,0x77,0x71,0x9F,0x97,0x0F,0x07,0x21,0x18,0x51,0x48,0x8C,0x84,0,0,0b10000000,0b00000110
prof45_data:	.DB	0x05,0,0x1F,0x12,0x35,0x2A,0x52,0x49,0x6F,0x64,0xA0,0x9A,0x8A,0x80,0,0,0b11111111,0b00000000
prof46_data:	.DB	0x36,0x2F,0x54,0x4B,0x71,0x68,0x9D,0x94,0x89,0x81,0xB2,0xA8,0x00,0x00,0,0,0b11000000,0b00000110
prof47_data:	.DB	0x36,0x2F,0x54,0x4B,0x71,0x68,0x9D,0x94,0x89,0x81,0xB2,0xA8,0x00,0x00,0,0,0b11100000,0b00000110
prof48_data:	.DB	0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0,0,0b11111111,0b00000000
prof49_data:	.DB	0x05,0x00,0x28,0x20,0x6C,0x65,0x45,0x3C,0x11,0x07,0x61,0x58,0x00,0x00,0,0,0b11000000,0b00000110
prof50_data:	.DB	0x05,0x00,0x4B,0x42,0x5A,0x51,0x1B,0x12,0x6A,0x61,0x33,0x29,0x49,0x40,0,0,0b10000000,0b00000110
prof51_data:	.DB	0x05,0x00,0x4B,0x42,0x5A,0x51,0x1B,0x12,0x6A,0x61,0x33,0x29,0x49,0x40,0,0,0b11111111,0b00000000
prof52_data:	.DB	0xA9,0x9F,0xDA,0xD0,0x05,0x00,0x75,0x6A,0x4A,0x41,0x2A,0x21,0x49,0x40,0,0,0b11000000,0b00000000
prof53_data:	.DB	0x05,0x00,0x43,0x39,0x33,0x29,0x11,0x07,0x62,0x57,0x25,0x1A,0x6A,0x61,0,0,0b10000000,0b00000110
prof54_data:	.DB	0x99,0x90,0x69,0x60,0x4E,0x45,0x8B,0x82,0x52,0x47,0x2B,0x20,0x12,0x07,0,0,0b10000000,0b00000110
prof55_data:	.DB	0xA9,0x9F,0xDA,0xD0,0x05,0x00,0x75,0x6A,0x4A,0x41,0x2A,0x21,0x49,0x40,0,0,0b11000000,0b00000110
prof56_data:	.DB	0xA9,0x9F,0xDA,0xD0,0x05,0x00,0x75,0x6A,0x4A,0x41,0x2A,0x21,0x49,0x40,0,0,0b11111111,0b00000000
prof57_data:	.DB	0x10,0x05,0x1B,0x12,0x33,0x29,0x4C,0x42,0x61,0x55,0x86,0x7A,0x98,0x8B,0,0,0b10000000,0b00000110
prof58_data:	.DB	0x10,0x05,0x1B,0x12,0x33,0x29,0x4C,0x42,0x61,0x55,0x86,0x7A,0x98,0x8B,0xB8,0xAD,0b00000000,0b00000010
prof59_data:	.DB	0x6D,0x62,0x10,0x05,0x1B,0x12,0x33,0x29,0x4C,0x42,0x61,0x55,0x86,0x7A,0,0,0b10000000,0b00000110
prof60_data:	.DB	0xA9,0x9F,0xDA,0xD0,0x05,0x00,0x75,0x6A,0x4A,0x41,0x2A,0x21,0x49,0x40,0,0,0b11000000,0b00000010
prof61_data:	.DB	0x35,0x29,0x5B,0x52,0x78,0x6D,0xD2,0xC7,0xAC,0xA2,0x8D,0x83,0x00,0x00,0,0,0b11000000,0b00000110
prof62_data:	.DB	0x1A,0x11,0x51,0x48,0x66,0x5B,0x5B,0x50,0x31,0x25,0x7A,0x70,0x05,0x00,0,0,0b10000000,0b00000110
prof63_data:	.DB	0x12,0x08,0x32,0x28,0x62,0x58,0x12,0x08,0x32,0x28,0x62,0x58,0x00,0x00,0,0,0b11000000,0b00000110
prof64_data:	.DB	0x2C,0x22,0x49,0x3F,0x71,0x65,0x12,0x09,0x36,0x2C,0x64,0x59,0x00,0x00,0,0,0b11000000,0b00000110
prof65_data:	.DB	0x1F,0x15,0x44,0x3A,0x58,0x4D,0x05,0x00,0x1A,0x11,0x70,0x66,0x4B,0x41,0,0,0b10000000,0b00000110
prof66_data:	.DB	0x4E,0x45,0x6B,0x61,0x99,0x8E,0x8D,0x85,0x52,0x48,0x2A,0x21,0x11,0x07,0,0,0b10000000,0b00000110
prof67_data:	.DB	0x4E,0x45,0x6B,0x61,0x99,0x8D,0x2A,0x21,0x11,0x07,0x8E,0x85,0x52,0x48,0,0,0b10000000,0b00000110
prof68_data:	.DB	0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0x58,0x4D,0,0,0b11111111,0b00000010
prof69_data:	.DB	0x2E,0x27,0x04,0x00,0x0A,0x04,0x11,0x0B,0x19,0x13,0x04,0x00,0x1B,0x16,0,0,0b10000000,0b00000010
prof70_data:	.DB	0x78,0x70,0x93,0x8A,0x81,0x78,0x05,0x00,0x6B,0x63,0x04,0x00,0x1B,0x16,0,0,0b11100000,0b00000010
prof71_data:	.DB	0x05,0x00,0xB2,0xA4,0xD5,0xC8,0x96,0x89,0x81,0x74,0xC8,0xBB,0x86,0x7A,0,0,0b10000000,0b00000010
prof72_data:	.DB	0x6D,0x62,0x10,0x05,0x1B,0x12,0x33,0x29,0x4C,0x42,0x61,0x55,0x86,0x7A,0,0,0b10000000,0b00000000
prof73_data:	.DB	0x98,0x8B,0xB8,0xAD,0xC5,0xB9,0x1B,0x12,0x33,0x29,0x4C,0x42,0x61,0x55,0,0,0b11111000,0b00000110
prof74_data:	.DB	0x7F,0x76,0x91,0x87,0xCB,0xC1,0x3F,0x35,0x89,0x7F,0xC9,0xC0,0x05,0x00,0,0,0b10000000,0b00000010
prof75_data:	.DB	0x7F,0x76,0x91,0x87,0xCB,0xC1,0x3F,0x35,0x89,0x7F,0xC9,0xC0,0x05,0x00,0,0,0b10000000,0b00000010
prof76_data:	.DB	0x05,0x00,0x05,0x00,0x44,0x3A,0xB5,0xAA,0x82,0x77,0x44,0x3A,0x82,0x77,0,0,0b11111111,0b00000010
prof77_data:	.DB	0x05,0x00,0x05,0x00,0x44,0x3A,0xB5,0xAA,0x82,0x77,0x44,0x3A,0x82,0x77,0,0,0b11111111,0b00000010
prof78_data:	.DB	0x7F,0x76,0x91,0x87,0xCB,0xC1,0x3F,0x35,0x89,0x7F,0xC9,0xC0,0x05,0x00,0,0,0b11111111,0b00000010
prof79_data:	.DB	0x98,0x8D,0x82,0x75,0x72,0x65,0x5A,0x50,0x3A,0x30,0x1A,0x10,0x05,0x00,0,0,0b10000000,0b00000110
prof80_data:	.DB	0x05,0x00,0x79,0x6E,0x21,0x17,0x12,0x08,0x49,0x3E,0x32,0x28,0x62,0x58,0,0,0b10000000,0b00000110
prof81_data:	.DB	0x79,0x6E,0x21,0x17,0x12,0x08,0x49,0x3E,0x32,0x28,0x62,0x58,0,0,0x05,0x00,0b11000000,0b00000110
prof82_data:	.DB	0x79,0x6E,0x21,0x17,0x12,0x08,0x49,0x3E,0x32,0x28,0x62,0x58,0,0,0x05,0x00,0b11111111,0b00000000
prof83_data:	.DB	0x82,0x75,0x70,0x63,0x5A,0x4E,0x3A,0x30,0x1B,0x10,0x05,0x00,0,0,0x98,0x8D,0b11000000,0b00000110
prof84_data:	.DB	0x05,0x00,0x21,0x17,0x12,0x08,0x49,0x3E,0x32,0x28,0x62,0x58,0,0,0x05,0x00,0b11111110,0b00000000
prof85_data:	.DB	0x05,0x00,0x1B,0x13,0x3B,0x32,0x58,0x4D,0x6E,0x64,0x82,0x75,0xB5,0xAE,0xAD,0xA3,0b00000000,0b00000010
prof86_data:	.DB	0x05,0x00,0x1B,0x13,0x25,0x1A,0x3A,0x30,0x1B,0x10,0x05,0x00,0,0,0x98,0x8D,0b11111000,0b00000010
prof87_data:	.DB	0x05,0x00,0x3A,0x30,0x20,0x16,0x11,0x07,0x4D,0x42,0x41,0x39,0x38,0x30,0,0,0b10000000,0b00000110












prof13_1_data:	.DB	0x62,0x59,0x33,0x2A,0x48,0x40,0x11,0x08,0x21,0x17,0x7A,0x6F,0x82,0x77,0,0,0b11000000,0b00000000
prof58_1_data:	.DB	0xC5,0xB9,0x1B,0x12,0x33,0x29,0x4C,0x42,0x61,0x55,0x86,0x7A,0x98,0x8B,0,0,0b11111110,0b00000110
prof69_1_data:	.DB	0x20,0x1B,0x19,0x14,0x5A,0x51,0x1B,0x12,0x6A,0x61,0x33,0x29,0x49,0x40,0,0,0b11111100,0b00000110
prof82_1_data:	.DB	0x05,0x00,0x19,0x14,0x5A,0x51,0x1B,0x12,0x6A,0x61,0x33,0x29,0x49,0x40,0,0,0b11111110,0b00000110
prof85_1_data:	.DB	0x98,0x8D,0x70,0x63,0x5A,0x4E,0x3A,0x30,0x1B,0x10,0x05,0x00,0,0,0x98,0x8D,0b11111110,0b00000010
prof86_1_data:	.DB	0x05,0x00,0x70,0x63,0x5A,0x4E,0x3A,0x30,0x1B,0x10,0x05,0x00,0,0,0x98,0x8D,0b11111110,0b00001110
prof86_2_data:	.DB	0x32,0x28,0x70,0x63,0x5A,0x4E,0x3A,0x30,0x1B,0x10,0x05,0x00,0,0,0x98,0x8D,0b11111110,0b00000110
prof86_3_data:	.DB	0x20,0x15,0x12,0x06,0x5A,0x4E,0x3A,0x30,0x1B,0x10,0x05,0x00,0,0,0x98,0x8D,0b11111100,0b00001110




SatStringChDown: .DB	0x00,0x18,0x06,0xE6,0x18,0x1E
SatStringChUp: .DB	0x00,0x18,0x06,0xE6,0x1E,0x1E
SatStringVolDown: .DB	0x00,0x18,0x06,0xE6,0x06,0x1E
SatStringVolUp: .DB	0x00,0x18,0x06,0xE6,0x78,0x1E
SatStringStdBy: .DB	0x00,0x18,0x00,0x78,0x00,0x00


SatIrDataKey1:	.DB	0x01,0x5B,0x00,0xAC
		.DB	0x00,0x16,0x00,0x15
		.DB	0x00,0x16,0x00,0x15
		.DB	0x00,0x16,0x00,0x40
		.DB	0x00,0x15,0x00,0x16
		.DB	0x00,0x15,0x00,0x16
		.DB	0x00,0x15,0x00,0x16
		.DB	0x00,0x15,0x00,0x16
		.DB	0x00,0x15,0x00,0x16
		.DB	0x00,0x15,0x00,0x40
		.DB	0x00,0x16,0x00,0x41
		.DB	0x00,0x15,0x00,0x41
		.DB	0x00,0x15,0x00,0x40
		.DB	0x00,0x15,0x00,0x41
		.DB	0x00,0x15,0x00,0x41
		.DB	0x00,0x15,0x00,0x42
		.DB	0x00,0x14,0x00,0x41
		.DB	0x00,0x15,0x00,0x41
		.DB	0x00,0x15,0x00,0x15
		.DB	0x00,0x16,0x00,0x16
		.DB	0x00,0x15,0x00,0x16
		.DB	0x00,0x15,0x00,0x40
		.DB	0x00,0x16,0x00,0x16
		.DB	0x00,0x15,0x00,0x15
		.DB	0x00,0x15,0x00,0x16
		.DB	0x00,0x15,0x00,0x17
		.DB	0x00,0x14,0x00,0x41
		.DB	0x00,0x15,0x00,0x41
		.DB	0x00,0x15,0x00,0x40
		.DB	0x00,0x16,0x00,0x15
		.DB	0x00,0x16,0x00,0x40
		.DB	0x00,0x16,0x00,0x40
		.DB	0x00,0x16,0x00,0x40
		.DB	0x00,0x16,0x00,0x00	;0x00,0x16,0x05,0xD7
		.DB	0x01,0x5A,0x00,0x56
		.DB	0x00,0x16,0x00,0x00




;1 -  (кнопки посл.)(индекс кнопок:1(POWER),2(SOURCE),3(MENU),4(VOL-),5(VOL+),6(CH-),7(CH+)) (выв.PWR_K через 1k2, выв.K0 через 3k9, выв.K1 непосредств.)
;2 -  (кнопки посл.)(индекс кнопок:1(POWER),2(SOURCE),3(MENU),4(CH-),5(CH+),6(VOL-),7(VOL+)) (выв.PWR_K через 1k2, выв.K0 через 3k9, выв.K1 непосредств.)
;3 - (ИФК,Leds,Light sensor)
;4 - (кнопки посл.)(индекс кнопок:1(POWER),2(MENU),3(VOL-),4(VOL+),5(CH-),6(CH+),7(SOURCE)) (pin6(ref.GND) непоср, 7 через 2k7, 8 через 5k1)
;5 -  (ИФК,Leds,Light sensor)
;6 - (ИФК,Leds,Light sensor)
;7 - 	5 кнопок,ИФК,светодиоды,Light sensor
;8 - (кнопки посл.) (индекс кнопок:1(SW7),2(SW1),3(SW2),4(SW4),5(SW3),6(SW6),7(SW5))
;9 -  (кнопки посл.) (индекс кнопок:1(SW7),2(SW1),3(SW8),3(SW2),4(SW3),5(SW4),6(SW5),7(SW6))
;10 -	6 кнопок,ИФК,светодиоды,Light sensor 
;11 - 
;12 -
;13 - (ИФК,Leds,кнопки посл.)
;14 - (3 кнопки посл.)
;15 - (кнопки посл.)
;16 - (ИФК,Leds,кнопки посл.)(индекс кнопок:1(POWER),2(TV/AV),3(MENU),4(V-),5(V+),6(PR-),7(PR+))
;17 - (Leds,кнопки посл.)(индекс кнопок:1(POWER),2(SOURCE),3(MENU),4(VOL+),5(VOL-),6(CH+),7(CH-))
;18 -(кнопки MCU) (индекс кнопок:1(POWER),2(SOURCE),3(MENU),4(VOL+),5(VOL-),6(CH+),7(CH-))
;19 -  	
;20 -(кнопки) (исп.дораб.контроллер IN6-pullup 100kOm) (индекс кнопок:1(POWER),2(SOURCE),3(MENU),4(VOL+),5(VOL-),6(CH+),7(CH-)) key0 и key1 соединить вместе
;21 - ИФК, leds

;22 - 6 кнопок) (индекс кнопок:1(POWER),2(CH-),3(CH+),4(HOME),5(VOL-),6(VOL+)) (key1 напрямую, key2 через 2,7кОм с key1)

;23 - (кнопки) разъем 4пин (2пин и 4пин - вместе, 1пин через рез 5,1кОм на 2 и 4 пин, 3пин на GND)
;24 -  ИФК, Light sensor
;25 -  (3- out1, 4-out2, 5- IO5, 6- IO6, 7- IO7)
;26 - 
;27 -  (кросс плата) 
;28 - 
;29 - (кнопки посл.)(индекс кнопок: 1(POWER),2(P+),3(P-),4(V+),5(V-),6(INPUT),7(MENU))
;30 - display c VFD контроллером
;31 - 
;32 - 
;33 - 
;34 - (кнопки посл.) (индекс кнопок:1(SW7),2(SW4),3(SW3),4(SW2),5(SW1),6(SW5),7(SW6))
;35 
;36 - 
;37 -  кнопки сенсорные
;38 -ИФК
;39 - (кнопки посл.)(индекс кнопок:1(POWER),2(MENU),3(V+),4(V-),5(P+),6(P-),7(TV/AV))
;40 -  (кнопки посл.+ три кнопки DVD) (индекс кнопок:1(STBY),2(SOURCE),3(MENU),4(CH-),5(CH+),6(VOL-),7(VOL+)) (выв.PWR_K через 1k2, выв.K0 через 3k9, выв.K1 непосредств.)
;41 -  (кнопки посл.) (индекс кнопок:,1(SOURCE),2(MENU),3(VOL+),4(VOL-),5(CH+),6(CH-),7(STBY)) 
;42 - Инвертор узкие разъемы
;43 -  Инвертор узкие разъемы
;44 - (кнопки) разъем 4пин  (нога3 через 3k8)
;45 - (LED,IR)
;46 -(6 кнопок) с кабелем
;47 -  (5 кнопок) с кабелем
;48 - display with MCU
;49 -   (6 кнопок) (индекс кнопок:1(POWER),2(CH-),3(CH+),4(MENU),5(V-),6(V+)) (key1 через 1,2кОм соед. с key2 и pwr)
;50 -  (кнопки посл.) (индекс кнопок:,1(POWER),2(TV/AV),3(MENU),4(CH-),5(CH+),6(VOL-),7(VOL+)) (ON-подкл. непосредств.,К1-через 3к8,К0-через 1к0)
;51 - (IR,LEDs (OA)) 
;52 -(MONE) 	кнопки,ИФК,светодиоды,Light sensor 
;53 -  (индекс кнопок:,1(SW021),2(SW022),3(SW016),4(SW019),5(SW020),6(SW017),7(SW018)) пин3 через 1к0
;54 -  (индекс кнопок:,1(SW021),2(SW022),3(SW016),4(SW019),5(SW020),6(SW017),7(SW018)) пин2 через 2к2
;55 - 	кнопки
;56 - 	ИФК,светодиод,Light sensor
;57 -  (кнопки парал.)(индекс кнопок:1(POWER),2(MENU),3(VOL-),4(VOL+),5(CH-),6(CH+),7(TV/AV)) резисторы на каждую кнопку 470,1k0,2k2,3k8,5k6,10k,12k7
;58 -  (кнопки парал.)(индекс кнопок:1(MENU),2(VOL-),3(VOL+),4(CH-),5(CH+),6(TV/AV),7(OPEN),8(STOP),9(PLAY)) резисторы на каждую кнопку 470,1k0,2k2,3k8,5k6,10k,12k7,22k,27k
;59 -   (кнопки парал.)(индекс кнопок:1(POWER),2(MENU),3(VOL-),4(VOL+),5(CH-),6(CH+),7(TV/AV)) резисторы на каждую кнопку 6k7,470,1k0,2k2,3k8,5k6,10k
;60 -    Кнопки
;61 -   (6 кнопок) (индекс кнопок:1(POWER),2(CH-),3(CH+),4(MENU),5(V-),6(V+)) (key1 напрямую, key2 через 1,2кОм с key1)
;62 - 
;63 -  (6 кнопок) (индекс кнопок:1(POWER),2(CH-),3(CH+),4(MENU),5(V-),6(V+)) (key1 через 1,2кОм соед. с key2 и pwr)
;64 -    (6 кнопок) (индекс кнопок:1(POWER),2(CH-),3(CH+),4(MENU),5(V-),6(V+)) (key1 напрямую, key2 через 1,2кОм с key1)
;65 - (кнопки посл.)(индекс кнопок:1(POWER),2(CH+),3(CH-),4(VOL+),5(VOL-),6(MENU),7(SOURCE)) (выв.PWR_K через 1k2, выв.K0 через 3k9, выв.K1 непосредств.)
;66 -  (индекс кнопок:,1(SW021),2(SW022),3(SW016),4(SW019),5(SW020),6(SW017),7(SW018)) пин2 через 2к2
;67 -   (кнопки парал.) (индекс кнопок:,1(SW021),2(SW022),3(SW016),4(SW019),5(SW020),6(SW017),7(SW018)) пин2 через 2к2
;68 - display with MCU (pin JP1(board)-pin DB15: 1-13,2-7,3-6,4-15,5-5,7-4,8-3,9-2,10-15)доп провод соед.pin7(DB15)-нога 14 ATMega16(отсоединить от MAX232)
;69 - (кнопки посл.) (индекс кнопок:,1(POWER),2(TV/AV),3(MENU),4(CH-),5(CH+),6(VOL-),7(VOL+)) (ON-подкл. непосредств.,К1-через 3к8,К0-через 1к0)
;70 - (кнопки DVD .) (индекс кнопок:,1(PREV),2(NEXT),3(PLAY),4(STOP),5(EJECT)) резисторы (GND-K1 5k6, K1-K2 2k7, K2-K3 6k7)
;71 -  (кнопки посл 7шт.) (индекс кнопок:,1(POWER),2(SOURCE),3(MENU),4(CH-),5(CH+),6(VOL-),7(VOL+)) (KT1-подкл. непосредств.,КT0-через 8к9)
;72 -  (кнопки парал.+ ИФК, светодиоды)(индекс кнопок:1(POWER),2(MENU),3(VOL-),4(VOL+),5(CH-),6(CH+),7(TV/AV)) резисторы на каждую кнопку 6k7,470,1k0,2k2,3k8,5k6,10k
;73 - (кнопки DVD парал.)(индекс кнопок:1(OPEN),2(STOP),3(PLAY)) резисторы на каждую кнопку 12k7,22k,27k
;74 -кнопки посл 7шт.) (индекс кнопок:,1(SW1),2(SW2),3(SW3),4(SW4),5(SW5),6(SW6),7(SW7)) (KT1-подкл. непосредств.,КT0-через 8к9)
;75 -  (кнопки посл 7шт.+ разъем USB) (индекс кнопок:,1(SW1),2(SW2),3(SW3),4(SW4),5(SW5),6(SW6),7(SW7)) (KT1-подкл. непосредств.,КT0-через 8к9) (USBvcc - pin2, ...)
;76 - инвертор LED (12v-pin5,ADJ-pin6,ON-pin7,MetAnalog-pin3,RelON-pin9,Swicher-pin11)
;77 - инвертор LED (12v-pin5,ADJ-pin6,ON-pin7,MetAnalog-pin3,RelON-pin9,Swicher-pin11)
;78 -  (кнопки посл.) (индекс кнопок:,1(MENU),2(CH-),3(CH+),4(V-),5(V+),6(TV/AV),7(PLAY),8(OPEN),9(POWER)) (4pin 1-GND,2-непоср,3-2к7,4-3к8) (3pin 1-1k0,2-1k2,3-GND)
;79 -  (кнопки парал.) (индекс кнопок:,1(POWER),2(TV/AV),3(MENU),4(CH-),5(CH+),6(VOL-),7(VOL+)) (POWER-12k8.,TV/AV-9k0....6k8,4k7,2k7,1k0,0R)
;80 -  (кнопки посл.)(индекс кнопок:1(POWER),2(AV),3(P-),4(P+),5(V-),6(V+),7(Menu))
;81 -  (кнопки посл.)(индекс кнопок:1(AV),2(P-),3(P+),4(V-),5(V+),6(Menu))
;82 - (IR,LEDs (OA)+кнопка)
;83 -  (кнопки парал.) (индекс кнопок:1(TV/AV),2(CH+),3(CH-),4(VOL+),5(VOL-),6(MENU)) (TV/AV-9k0....6k8,4k7,2k7,1k0,0R)
;84 -  (IR,LEDs (OK)+кнопка)
;85 - (кнопки парал. 9шт) (индекс кнопок:1(Menu),2(VOL-),3(VOL+),4(CH-),5(CH+),6(TV/AV),7(OPEN),8(STOP),9(PLAY)) (0R,1k0,2k7,4k7,6k8,9k0,22k,17k8,12k8)
;86 -(1930) (кнопки посл.) (индекс кнопок:,1(POWER),2(TV/AV),3(MENU),4(CH-),5(CH+),6(VOL-),7(VOL+)) (ON-подкл. непосредств.,К0-на ADC1,К1-через 1к0)
;87 - (кнопки посл.) (индекс кнопок:,1(POWER),2(TV/AV),3(MENU),4(VOL-),5(VOL+),6(CH-),7(CH+)) K1- непоср, К3 - через 2k7



