;
; File generated by cc65 v 2.13.1
;
	.fopt		compiler,"cc65 v 2.13.1"
	.setcpu		"6502"
	.smart		on
	.autoimport	on
	.case		on
	.debuginfo	on
	.importzp	sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
	.macpack	longbranch
	.dbg		file, "../../../io/src/onewire.c", 4573, 1267200496
	.dbg		file, "C:\Programme\cc65\include/stdio.h", 5964, 1262467470
	.dbg		file, "C:\Programme\cc65\include/stddef.h", 2972, 1262467470
	.dbg		file, "C:\Programme\cc65\include/stdarg.h", 2817, 1262467470
	.dbg		file, "../../../data/inc/types.h", 1544, 1267200498
	.dbg		file, "../../../io/inc/gpio.h", 4272, 1267200496
	.dbg		file, "../../../io/inc/onewire.h", 1206, 1267200496
	.export		_onewire_reset
	.export		_onewire_sendbyte
	.export		_onewire_getbyte
	.export		_onewire_readrom
	.export		_onewire_readmem
	.export		_onewire_waitprog
	.export		_onewire_sendbit

; ---------------------------------------------------------------
; unsigned char __near__ onewire_reset (void)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_onewire_reset: near

.segment	"CODE"

;
; GPIO_SET   = ONE_WIRE;
;
	.dbg	line, "../../../io/src/onewire.c", 28
	lda     #$40
	sta     $2000
;
; TIMER = 30;
;
	.dbg	line, "../../../io/src/onewire.c", 29
	lda     #$1E
	sta     $2004
;
; while(TIMER)
;
	.dbg	line, "../../../io/src/onewire.c", 30
L0009:	lda     $2004
;
; ;
;
	.dbg	line, "../../../io/src/onewire.c", 31
	bne     L0009
;
; GPIO_CLEAR = ONE_WIRE;
;
	.dbg	line, "../../../io/src/onewire.c", 32
	lda     #$40
	sta     $2001
;
; TIMER = 110;
;
	.dbg	line, "../../../io/src/onewire.c", 33
	lda     #$6E
	sta     $2004
;
; while(TIMER)
;
	.dbg	line, "../../../io/src/onewire.c", 34
L0013:	lda     $2004
;
; ;
;
	.dbg	line, "../../../io/src/onewire.c", 35
	bne     L0013
;
; GPIO_SET   = ONE_WIRE;
;
	.dbg	line, "../../../io/src/onewire.c", 36
	lda     #$40
	sta     $2000
;
; TIMER = 14;
;
	.dbg	line, "../../../io/src/onewire.c", 37
	lda     #$0E
	sta     $2004
;
; while(TIMER)
;
	.dbg	line, "../../../io/src/onewire.c", 38
L001D:	lda     $2004
;
; ;
;
	.dbg	line, "../../../io/src/onewire.c", 39
	bne     L001D
;
; return !(GPIO_IN & ONE_WIRE);
;
	.dbg	line, "../../../io/src/onewire.c", 40
	lda     $2001
	ldx     #$00
	and     #$40
	jmp     bnega
	.dbg	line

.endproc

; ---------------------------------------------------------------
; void __near__ onewire_sendbyte (unsigned char)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_onewire_sendbyte: near

.segment	"CODE"

;
; BYTE b = 200;
;
	.dbg	line, "../../../io/src/onewire.c", 57
	lda     #$C8
	jsr     pusha
;
; while(!(GPIO_IN & ONE_WIRE) && b) {
;
	.dbg	line, "../../../io/src/onewire.c", 58
L0045:	lda     $2001
	and     #$40
	bne     L0046
	tay
	lda     (sp),y
	beq     L0046
;
; TIMER = 1;
;
	.dbg	line, "../../../io/src/onewire.c", 59
	lda     #$01
	sta     $2004
;
; while(TIMER)
;
	.dbg	line, "../../../io/src/onewire.c", 60
L004F:	lda     $2004
;
; ;
;
	.dbg	line, "../../../io/src/onewire.c", 61
	bne     L004F
;
; b--;
;
	.dbg	line, "../../../io/src/onewire.c", 62
	tay
	lda     (sp),y
	sec
	sbc     #$01
	sta     (sp),y
;
; }
;
	.dbg	line, "../../../io/src/onewire.c", 63
	jmp     L0045
;
; for(b=0;b<8;b++) {
;
	.dbg	line, "../../../io/src/onewire.c", 65
L0046:	lda     #$00
	tay
L00C8:	sta     (sp),y
	cmp     #$08
	jcs     incsp2
;
; onewire_sendbit(byte & 0x01); // lsb first
;
	.dbg	line, "../../../io/src/onewire.c", 66
	iny
	lda     (sp),y
	and     #$01
	jsr     pusha
	jsr     _onewire_sendbit
;
; byte >>= 1;
;
	.dbg	line, "../../../io/src/onewire.c", 67
	ldy     #$01
	lda     (sp),y
	lsr     a
	sta     (sp),y
;
; for(b=0;b<8;b++) {
;
	.dbg	line, "../../../io/src/onewire.c", 65
	dey
	lda     (sp),y
	clc
	adc     #$01
	jmp     L00C8
	.dbg	line

.endproc

; ---------------------------------------------------------------
; unsigned char __near__ onewire_getbyte (void)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_onewire_getbyte: near

.segment	"CODE"

;
; while(TIMER)
;
	.dbg	line, "../../../io/src/onewire.c", 75
	jsr     decsp3
L0061:	lda     $2004
;
; ;
;
	.dbg	line, "../../../io/src/onewire.c", 76
	bne     L0061
;
; for(out=0,b=0;b<8;b++) {
;
	.dbg	line, "../../../io/src/onewire.c", 78
	tay
	sta     (sp),y
	ldy     #$02
L00C9:	sta     (sp),y
	cmp     #$08
	bcs     L0066
;
; TIMER = 14;
;
	.dbg	line, "../../../io/src/onewire.c", 79
	lda     #$0E
	sta     $2004
;
; while(TIMER)
;
	.dbg	line, "../../../io/src/onewire.c", 80
L0072:	lda     $2004
;
; ;
;
	.dbg	line, "../../../io/src/onewire.c", 81
	bne     L0072
;
; GPIO_CLEAR = ONE_WIRE;
;
	.dbg	line, "../../../io/src/onewire.c", 82
	lda     #$40
	sta     $2001
;
; TIMER = 1;
;
	.dbg	line, "../../../io/src/onewire.c", 83
	lda     #$01
	sta     $2004
;
; while(TIMER)
;
	.dbg	line, "../../../io/src/onewire.c", 84
L007C:	lda     $2004
;
; ;
;
	.dbg	line, "../../../io/src/onewire.c", 85
	bne     L007C
;
; GPIO_SET   = ONE_WIRE;
;
	.dbg	line, "../../../io/src/onewire.c", 86
	lda     #$40
	sta     $2000
;
; TIMER = 1;
;
	.dbg	line, "../../../io/src/onewire.c", 87
	lda     #$01
	sta     $2004
;
; while(TIMER)
;
	.dbg	line, "../../../io/src/onewire.c", 88
L0086:	lda     $2004
;
; ;
;
	.dbg	line, "../../../io/src/onewire.c", 89
	bne     L0086
;
; r = GPIO_IN & ONE_WIRE;
;
	.dbg	line, "../../../io/src/onewire.c", 90
	lda     $2001
	and     #$40
	ldy     #$01
	sta     (sp),y
;
; out >>= 1;
;
	.dbg	line, "../../../io/src/onewire.c", 91
	dey
	lda     (sp),y
	lsr     a
	sta     (sp),y
;
; if(r)
;
	.dbg	line, "../../../io/src/onewire.c", 92
	iny
	lda     (sp),y
	beq     L0067
;
; out |= 0x80;
;
	.dbg	line, "../../../io/src/onewire.c", 93
	dey
	lda     (sp),y
	ora     #$80
	sta     (sp),y
;
; for(out=0,b=0;b<8;b++) {
;
	.dbg	line, "../../../io/src/onewire.c", 78
L0067:	ldy     #$02
	lda     (sp),y
	clc
	adc     #$01
	jmp     L00C9
;
; TIMER = 10;
;
	.dbg	line, "../../../io/src/onewire.c", 95
L0066:	lda     #$0A
	sta     $2004
;
; return out;
;
	.dbg	line, "../../../io/src/onewire.c", 96
	ldx     #$00
	lda     (sp,x)
;
; }
;
	.dbg	line, "../../../io/src/onewire.c", 97
	jmp     incsp3
	.dbg	line

.endproc

; ---------------------------------------------------------------
; unsigned char __near__ onewire_readrom (__near__ unsigned char*)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_onewire_readrom: near

.segment	"CODE"

;
; if(onewire_reset()) {
;
	.dbg	line, "../../../io/src/onewire.c", 103
	jsr     decsp1
	jsr     _onewire_reset
	tax
	jeq     incsp3
;
; onewire_sendbyte(0x33);
;
	.dbg	line, "../../../io/src/onewire.c", 104
	lda     #$33
	jsr     pusha
	jsr     _onewire_sendbyte
;
; for(p=0;p<8;p++)
;
	.dbg	line, "../../../io/src/onewire.c", 105
	lda     #$00
	tay
L00CA:	sta     (sp),y
	cmp     #$08
	bcs     L009D
;
; rom[p] = onewire_getbyte();
;
	.dbg	line, "../../../io/src/onewire.c", 106
	lda     (sp),y
	clc
	iny
	adc     (sp),y
	pha
	lda     #$00
	iny
	adc     (sp),y
	tax
	pla
	jsr     pushax
	jsr     _onewire_getbyte
	ldy     #$00
	jsr     staspidx
;
; for(p=0;p<8;p++)
;
	.dbg	line, "../../../io/src/onewire.c", 105
	ldy     #$00
	lda     (sp),y
	clc
	adc     #$01
	jmp     L00CA
;
; return 1;
;
	.dbg	line, "../../../io/src/onewire.c", 107
L009D:	ldx     #$00
	lda     #$01
	jmp     incsp3
	.dbg	line

.endproc

; ---------------------------------------------------------------
; unsigned char __near__ onewire_readmem (unsigned char)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_onewire_readmem: near

.segment	"CODE"

;
; if(onewire_reset()) {
;
	.dbg	line, "../../../io/src/onewire.c", 173
	jsr     decsp1
	jsr     _onewire_reset
	tax
	jeq     incsp2
;
; onewire_sendbyte(0xCC); // skip rom
;
	.dbg	line, "../../../io/src/onewire.c", 174
	lda     #$CC
	jsr     pusha
	jsr     _onewire_sendbyte
;
; onewire_sendbyte(0xF0); // read memory
;
	.dbg	line, "../../../io/src/onewire.c", 175
	lda     #$F0
	jsr     pusha
	jsr     _onewire_sendbyte
;
; onewire_sendbyte(offset); // starting address
;
	.dbg	line, "../../../io/src/onewire.c", 176
	ldy     #$01
	lda     (sp),y
	jsr     pusha
	jsr     _onewire_sendbyte
;
; onewire_sendbyte(0); // high byte
;
	.dbg	line, "../../../io/src/onewire.c", 177
	lda     #$00
	jsr     pusha
	jsr     _onewire_sendbyte
;
; p = onewire_getbyte();
;
	.dbg	line, "../../../io/src/onewire.c", 178
	jsr     _onewire_getbyte
	ldy     #$00
	sta     (sp),y
;
; return p;
;
	.dbg	line, "../../../io/src/onewire.c", 179
	ldx     #$00
	lda     (sp),y
	jmp     incsp2
	.dbg	line

.endproc

; ---------------------------------------------------------------
; void __near__ onewire_waitprog (void)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_onewire_waitprog: near

.segment	"CODE"

;
; for(p=0;p<12;p++) {
;
	.dbg	line, "../../../io/src/onewire.c", 188
	jsr     decsp1
	lda     #$00
	tay
L00CB:	sta     (sp),y
	cmp     #$0C
	jcs     incsp1
;
; TIMER = 250;
;
	.dbg	line, "../../../io/src/onewire.c", 189
	lda     #$FA
	sta     $2004
;
; while(TIMER)
;
	.dbg	line, "../../../io/src/onewire.c", 190
L00C4:	lda     $2004
;
; ;
;
	.dbg	line, "../../../io/src/onewire.c", 191
	bne     L00C4
;
; for(p=0;p<12;p++) {
;
	.dbg	line, "../../../io/src/onewire.c", 188
	tay
	lda     (sp),y
	clc
	adc     #$01
	jmp     L00CB
	.dbg	line

.endproc

; ---------------------------------------------------------------
; void __near__ onewire_sendbit (unsigned char)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_onewire_sendbit: near

.segment	"CODE"

;
; while(TIMER)
;
	.dbg	line, "../../../io/src/onewire.c", 45
L0025:	lda     $2004
;
; ;
;
	.dbg	line, "../../../io/src/onewire.c", 46
	bne     L0025
;
; GPIO_CLEAR = ONE_WIRE;
;
	.dbg	line, "../../../io/src/onewire.c", 47
	lda     #$40
	sta     $2001
;
; TIMER = (bit)?4:15;
;
	.dbg	line, "../../../io/src/onewire.c", 48
	ldy     #$00
	lda     (sp),y
	beq     L0030
	lda     #$04
	jmp     L0032
L0030:	lda     #$0F
L0032:	sta     $2004
;
; while(TIMER)
;
	.dbg	line, "../../../io/src/onewire.c", 49
L0034:	lda     $2004
;
; ;
;
	.dbg	line, "../../../io/src/onewire.c", 50
	bne     L0034
;
; GPIO_SET   = ONE_WIRE;
;
	.dbg	line, "../../../io/src/onewire.c", 51
	lda     #$40
	sta     $2000
;
; TIMER = (bit)?8:2;
;
	.dbg	line, "../../../io/src/onewire.c", 52
	ldy     #$00
	lda     (sp),y
	beq     L003F
	lda     #$08
	jmp     L0041
L003F:	lda     #$02
L0041:	sta     $2004
;
; }
;
	.dbg	line, "../../../io/src/onewire.c", 53
	jmp     incsp1
	.dbg	line

.endproc

