-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathraspberrypi4b.jinja2
More file actions
119 lines (108 loc) · 4.84 KB
/
Copy pathraspberrypi4b.jinja2
File metadata and controls
119 lines (108 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{#-
SPDX-License-Identifier: MIT
Copyright (c) 2025 Andrew Ellis Page
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-#}
{%- macro SetClear(field, offset, rw, description, shadow) %}
##
## {{ field|capitalize }}
##
{%- for setclr_n in range(2) %}
{{ field }}{{setclr_n}}:
description: "{{ description }}"
offset: 0x{{"%02X" % (offset+4*setclr_n)}}
read-write: "{{ rw }}"
width: 32
# bits
{%- endfor %}
{{ field|lower }}_bits:
{%- for setclr_n in range(2) %}
{%- for i in range(32) %}{% if setclr_n*32+i <=57 %}
gp{{ "%02d" % (setclr_n*32+i) }}:
offset: 0x{{"%02X" % (offset+4*setclr_n)}}
bits: "{{i}}:{{i}}"
read-write: "{{ rw }}"
parent: "GPIO.{{ field }}{{setclr_n}}"
{% if shadow %}shadow: "GPIO.{{ shadow }}{{setclr_n}}"
{% endif -%}
{% endif -%}
{% endfor %}{% endfor -%}
{% endmacro -%}
{{ preamble }}
registers:
GPIO:
# reference section 5.2 of the BCM2837 ARM Peripherals manual
##
## Function select
##
## 000 = GPIO Pin is an input
## 001 = GPIO Pin is an output
## 100 = GPIO Pin takes alternate function 0
## 101 = GPIO Pin takes alternate function 1
## 110 = GPIO Pin takes alternate function 2
## 111 = GPIO Pin takes alternate function 3
## 011 = GPIO Pin takes alternate function 4
## 010 = GPIO Pin takes alternate function 5
{%- for gpio_n in range(6)%}
function{{gpio_n}}:
offset: 0x{{'%02x' % (gpio_n*4)}}
reset: 0x0000
read-write: "rw"
width: 32
description: "000=input, 001=output, 100=alt0, 101=alt1, 110=alt2, 111=alt3, 011=alt4, 010=alt5"
{% endfor -%}
function{{gpio_n}}_bits:
{%- for gpio_n in range(6)%}
{%- for i in range(9, -1, -1) %}{% if gpio_n*10+i<=57 %}
gp{{"%02d" % (gpio_n*10+i)}}:
offset: 0x{{'%02x' % (gpio_n*4)}}
reset: 0x0000
read-write: "rw"
bits: "{{i*3+2}}:{{i*3}}"
parent: "GPIO.function{{gpio_n}}"
{% endif -%}
{%- endfor %}
{%-endfor %}
{{ SetClear("set", 0x1c, "wo", "Output Set", "level") }}
{{ SetClear("clear", 0x28, "wo", "Output Clear", "level") }}
{{ SetClear("level", 0x34, "ro", "0 = pin low, 1 = pin high") }}
{{ SetClear("EventDetect", 0x40, "w1c", "Event Detected") }}
{{ SetClear("RisingEdgeEnable", 0x4C, "rw", "0 = Rising edge detect disabled, 1 = enabled") }}
{{ SetClear("FallingEdgeEnable", 0x58, "rw", "0 = Falling edge detect disabled, 1 = enabled") }}
{{ SetClear("HighDetectEnable", 0x64, "rw", "0 = detect disabled, 1 = enabled") }}
{{ SetClear("LowDetectEnable", 0x70, "rw", "0 = detect disabled, 1 = enabled") }}
{{ SetClear("AsyncRisingDetect", 0x7C, "rw", "0 = detect disabled, 1 = enabled") }}
{{ SetClear("AsyncFallingDetect", 0x88, "rw", "0 = detect disabled, 1 = enabled") }}
{%- for gpio_n in range(4) %}
pull_up_down{{gpio_n}}:
offset: 0x{{'%02x' % (0xe4+(gpio_n*4))}}
reset: 0x0000
read-write: "rw"
width: 32
description: "00 = No resistor, 01 = Pull Up, 10 = Pull Down"
# bits
{% endfor -%}
pull_up_down_bits:
{%- for gpio_n in range(4) %}
{% for i in range(15, -1, -1) %}{% if gpio_n*16+i <=57 %}
gp{{gpio_n*16+i}}:
offset: 0x{{'%02x' % (0xe4+(gpio_n*4))}}
reset: 0x1
read-write: "rw"
bits: "{{i*2+1}}:{{i*2}}"
parent: "GPIO.pull_up_down{{gpio_n}}"
{% endif %}{% endfor %}{% endfor -%}