
.equ	TR00 = 0
.macro INI_TR00
	cbi DDRD , TR00
	cbi PORTD , TR00
.endm
.macro CHECK_TR00
	sbic PIND , TR00
.endm


.equ CPRDY = 1
.macro INI_CPRDY
        cbi DDRD , CPRDY
		cbi PORTD , CPRDY
.endm 
.macro CHECK_CPRDY
		sbic PIND , CPRDY	
.endm


.equ	HLD = 3
.macro INI_HLD
	sbi DDRD , HLD
	cbi PORTD , HLD
.endm
.macro SET_HLD
	sbi PORTD , HLD
.endm
.macro RES_HLD
	cbi PORTD , HLD
.endm

.equ	IP = 5
.macro INI_IP
	cbi DDRD , IP
	cbi PORTD , IP 
.endm
.macro CHECK_IP_
	sbic PIND , IP
.endm


.equ	DRQ = 7
.macro INI_DRQ
	sbi DDRD , DRQ
	cbi PORTD , DRQ
.endm
.macro SET_DRQ
;	sbi PORTD , DRQ
	cbi DDRD , DRQ
.endm
.macro RES_DRQ
;	cbi PORTD , DRQ
	sbi DDRD , DRQ
.endm
.macro CHECK_DRQ
    in TEMP , PIND
    sbrs TEMP , DRQ
.endm


.equ	STEP = 0
.macro INI_STEP
	sbi DDRC , STEP
	cbi PORTC , STEP
.endm
.macro SET_STEP
	sbi PORTC , STEP
.endm
.macro RES_STEP
	cbi PORTC , STEP
.endm

.equ	DIR = 1
.macro INI_DIR
	sbi DDRC , DIR
	cbi PORTC , DIR
.endm
.macro SET_DIR
	sbi PORTC , DIR
.endm
.macro RES_DIR
	cbi PORTC , DIR
.endm
.macro CHECK_DIR
	sbic PINC , DIR
.endm


.equ	 WG = 0
.macro INI_WG
	sbi DDRE , WG
	cbi PORTE , WG
.endm
.macro SET_WG
	sbi PORTE , WG
.endm
.macro RES_WG
	cbi PORTE , WG
.endm

.equ    INTRQ = 1
.macro INI_INTRQ
	sbi DDRE , INTRQ
	cbi PORTE , INTRQ
.endm
.macro SET_INTRQ
;	sbi PORTE , INTRQ
    cbi DDRE , INTRQ
.endm
.macro RES_INTRQ
;	cbi PORTE , INTRQ
	sbi DDRE , INTRQ
.endm


.equ WRPT = 2
.macro INI_WRPT
		cbi DDRE , WRPT
		cbi PORTE , WRPT
.endm
.macro CHECK_WRPT
		sbic PINE , WRPT
.endm

.equ CLEAR = 3
.macro INI_CLR
	cbi DDRE , CLEAR
	cbi PORTE , CLEAR
.endm
.macro CHECK_CLR
	sbis PINE , CLEAR
.endm

.equ    HRDY = 5
.macro INI_HRDY
	cbi DDRE , HRDY
	cbi PORTE , HRDY 
.endm
.macro CHECK_HRDY
	sbis PINE , HRDY
.endm

.equ    WF_DE = 6
.macro INI_WF_DE
	cbi DDRE , WF_DE
	sbi PORTE , WF_DE 
.endm

.macro SET_WF_DE
    cbi DDRE , WF_DE
	sbi PORTE , WF_DE
.endm
.macro RES_WF_DE
	sbi DDRE , WF_DE
	cbi PORTE , WF_DE
.endm

.macro CHECK_WF_DE
	sbic PINE , WF_DE
.endm



.equ TR43 = 1
.macro INI_TR43
;		sbi DDRE , TR43
;		cbi PORTE , TR43
.endm
.macro SET_TR43
;		cbi PORTE , TR43
.endm
.macro RES_TR43
;		cbi PORTE , TR43
.endm


.macro INI_WRITE
.if OLD_WRITE == 1
		ldi TEMP , ( 1 << UMSEL1 ) | ( 1 << UMSEL0 )
		sts UCSRC , TEMP
		ldi TEMP , 7
		sts UBRRH , CONST00
		sts UBRRL , TEMP
		
.else
		ldi TEMP , ( 1 << UMSEL1 ) ;| ( 1 << UCPOL )
		sts UCSRC , TEMP
.endif
		sts UCSRA , CONST00
		lds TEMP , PMX0
		ori TEMP , (1 << WCE )
		sts PMX0  , TEMP
		ori TEMP , ( 1 << TXD6 )
		sts PMX0 , TEMP 

.endm

.macro START_WRITE
		ldi TEMP , ( 1 << TXEN )
		sts UCSRB , TEMP
.endm

.macro STOP_WRITE
$msw0:	
		lds TEMP1 , UCSRA 
		sbrs TEMP1 ,  UDRE
			rjmp $msw0
		sts UCSRB , CONST00
.endm
.macro STOP_WRITER
		sts UCSRB , CONST00
.endm



