Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 theseven 1
@
2
@
3
@    Copyright 2010 TheSeven
4
@
5
@
6
@    This file is part of emBIOS.
7
@
8
@    emBIOS is free software: you can redistribute it and/or
9
@    modify it under the terms of the GNU General Public License as
10
@    published by the Free Software Foundation, either version 2 of the
11
@    License, or (at your option) any later version.
12
@
13
@    emBIOS is distributed in the hope that it will be useful,
14
@    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
@    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
@    See the GNU General Public License for more details.
17
@
18
@    You should have received a copy of the GNU General Public License
19
@    along with emBIOS.  If not, see <http://www.gnu.org/licenses/>.
20
@
21
@
22
 
23
 
24
.section .icode.i2csend, "ax", %progbits
25
.align 2
26
.global i2csendbyte
27
.global i2csend
28
.type i2csendbyte, %function
29
.type i2csend, %function
30
i2csendbyte:
31
	mov	r3, #0
32
@fallthrough
33
 
34
i2csend:
35
	stmfd	sp!, {r4,lr}
36
	mov	r12, #0x3C000000
37
	add	r12, r12, #0x00900000
38
	mov	r4, #0
39
	str	r4, [r12,#0x08]
40
	str	r0, [r12,#0x0c]
41
	mov	r4, #0xf0
42
	str	r4, [r12,#0x04]
43
	mov	r4, #0xf3
44
	str	r4, [r12]
45
	bl	i2cwait
46
	str	r1, [r12,#0x0c]
47
	str	r4, [r12]
48
	bl	i2cwait
49
	movs	r3, r3
50
	moveq	r0, r2
51
i2csend_write:
52
	ldrne	r0, [r2], #1
53
	str	r0, [r12,#0x0c]
54
	str	r4, [r12]
55
	bl	i2cwait
56
	subs	r3, r3, #1
57
	bhi	i2csend_write
58
	mov	r0, #0xd0
59
	str	r0, [r12,#0x04]
60
	str	r4, [r12]
61
i2csend_wait:
62
	ldr	r0, [r12,#0x04]
63
	tst	r0, #0x20
64
	bne	i2csend_wait
65
	ldmfd	sp!, {r4,pc}
66
.size i2csendbyte, .-i2csendbyte
67
.size i2csend, .-i2csend
68
 
69
 
70
.section .icode.i2crecv, "ax", %progbits
71
.align 2
72
.global i2crecvbyte
73
.global i2crecv
74
.type i2crecvbyte, %function
75
.type i2crecv, %function
76
i2crecvbyte:
77
	mov	r2, #0
78
	mov	r3, #1
79
@fallthrough
80
 
81
i2crecv:
82
	stmfd	sp!, {r0,r4,lr}
83
	mov	r12, #0x3C000000
84
	add	r12, r12, #0x00900000
85
	mov	r4, #0
86
	str	r4, [r12,#0x08]
87
	str	r0, [r12,#0x0c]
88
	mov	r4, #0xf0
89
	str	r4, [r12,#0x04]
90
	mov	r4, #0xf3
91
	str	r4, [r12]
92
	bl	i2cwait
93
	str	r1, [r12,#0x0c]
94
	str	r4, [r12]
95
	bl	i2cwait
96
	ldr	r0, [sp]
97
	orr	r0, r0, #1
98
	str	r1, [r12,#0x0c]
99
	mov	r0, #0xb0
100
	str	r0, [r12,#0x04]
101
	str	r4, [r12]
102
	bl	i2cwait
103
i2crecv_read:
104
	subs	r3, r3, #1
105
	moveq	r4, #0x73
106
	str	r4, [r12]
107
	bl	i2cwait
108
	ldr	r0, [r12,#0x0c]
109
	movs	r2, r2
110
	strne	r0, [r2], #1
111
	movs	r3, r3
112
	bne	i2crecv_read
113
	mov	r1, #0x90
114
	str	r1, [r12,#0x04]
115
	mov	r1, #0xf3
116
	str	r1, [r12]
117
i2crecv_wait:
118
	ldr	r1, [r12,#0x04]
119
	tst	r1, #0x20
120
	bne	i2crecv_wait
121
	ldmfd	sp!, {r0,r4,pc}
122
.size i2crecvbyte, .-i2crecvbyte
123
.size i2crecv, .-i2crecv
124
 
125
 
126
.section .icode.i2cwait, "ax", %progbits
127
.align 2
128
.global i2cwait
129
.type i2cwait, %function
130
i2cwait:
131
	ldr	r0, [r12]
132
	tst	r0, #0x10
133
	beq	i2cwait
134
	mov	pc, lr
135
.size i2cwait, .-i2cwait