blob: 89a370414e60326798e05d15605326cfe7129343 (
plain)
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
//go:build tkey
// Hand written file based on https://github.com/tillitis/tkey-libs/blob/main/include/tkey/tk1_mem.h
package tkey
import (
"runtime/volatile"
"unsafe"
)
// Peripherals
var (
TRNG = (*TRNG_Type)(unsafe.Pointer(TK1_MMIO_TRNG_BASE))
TIMER = (*TIMER_Type)(unsafe.Pointer(TK1_MMIO_TIMER_BASE))
UDS = (*UDS_Type)(unsafe.Pointer(TK1_MMIO_UDS_BASE))
UART = (*UART_Type)(unsafe.Pointer(TK1_MMIO_UART_BASE))
TOUCH = (*TOUCH_Type)(unsafe.Pointer(TK1_MMIO_TOUCH_BASE))
TK1 = (*TK1_Type)(unsafe.Pointer(TK1_MMIO_TK1_BASE))
)
// Memory sections
const (
TK1_ROM_BASE uintptr = 0x00000000
TK1_RAM_BASE uintptr = 0x40000000
TK1_MMIO_BASE uintptr = 0xc0000000
TK1_MMIO_TRNG_BASE uintptr = 0xc0000000
TK1_MMIO_TIMER_BASE uintptr = 0xc1000000
TK1_MMIO_UDS_BASE uintptr = 0xc2000000
TK1_MMIO_UART_BASE uintptr = 0xc3000000
TK1_MMIO_TOUCH_BASE uintptr = 0xc4000000
TK1_MMIO_FW_RAM_BASE uintptr = 0xd0000000
TK1_MMIO_TK1_BASE uintptr = 0xff000000
)
// Memory section sizes
const (
TK1_RAM_SIZE uintptr = 0x20000
TK1_MMIO_SIZE uintptr = 0x3fffffff
)
type TRNG_Type struct {
_ [36]byte
STATUS volatile.Register32
_ [88]byte
ENTROPY volatile.Register32
}
type TIMER_Type struct {
_ [32]byte
CTRL volatile.Register32
STATUS volatile.Register32
PRESCALER volatile.Register32
TIMER volatile.Register32
}
type UDS_Type struct {
_ [64]byte
DATA [8]volatile.Register32
}
type UART_Type struct {
_ [128]byte
RX_STATUS volatile.Register32
RX_DATA volatile.Register32
RX_BYTES volatile.Register32
_ [116]byte
TX_STATUS volatile.Register32
TX_DATA volatile.Register32
}
type TOUCH_Type struct {
_ [36]byte
STATUS volatile.Register32
}
type TK1_Type struct {
NAME0 volatile.Register32
NAME1 volatile.Register32
VERSION volatile.Register32
_ [16]byte
SWITCH_APP volatile.Register32
_ [4]byte
LED volatile.Register32
GPIO volatile.Register16
APP_ADDR volatile.Register32
APP_SIZE volatile.Register32
BLAKE2S volatile.Register32
_ [72]byte
CDI_FIRST [8]volatile.Register32
_ [32]byte
UDI_FIRST [2]volatile.Register32
_ [62]byte
RAM_ADDR_RAND volatile.Register16
_ [2]byte
RAM_DATA_RAND volatile.Register16
_ [126]byte
CPU_MON_CTRL volatile.Register16
_ [2]byte
CPU_MON_FIRST volatile.Register32
CPU_MON_LAST volatile.Register32
_ [60]byte
SYSTEM_RESET volatile.Register16
_ [66]byte
SPI_EN volatile.Register32
SPI_XFER volatile.Register32
SPI_DATA volatile.Register32
}
const (
TK1_MMIO_TIMER_CTRL_START_BIT = 0
TK1_MMIO_TIMER_CTRL_STOP_BIT = 1
TK1_MMIO_TIMER_CTRL_START = 1 << TK1_MMIO_TIMER_CTRL_START_BIT
TK1_MMIO_TIMER_CTRL_STOP = 1 << TK1_MMIO_TIMER_CTRL_STOP_BIT
TK1_MMIO_TK1_LED_R_BIT = 2
TK1_MMIO_TK1_LED_G_BIT = 1
TK1_MMIO_TK1_LED_B_BIT = 0
TK1_MMIO_TK1_GPIO1_BIT = 0
TK1_MMIO_TK1_GPIO2_BIT = 1
TK1_MMIO_TK1_GPIO3_BIT = 2
TK1_MMIO_TK1_GPIO4_BIT = 3
)
|