-
Notifications
You must be signed in to change notification settings - Fork 0
/
devices.go
105 lines (86 loc) · 1.75 KB
/
devices.go
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
package devices
//go:generate go run generate.go
import (
"fmt"
"strings"
)
type MCU struct {
name string
signature uint16
flashPageSize uint16
flashSize uint16
nrwwOffset uint16
eepromSize uint16
eear byte
eearSize byte
eedr byte
eedrSize byte
eecr byte
eecrSize byte
spmcsr byte
spmcsrSize byte
sp byte
spSize byte
sreg byte
sregSize byte
dwenMask byte
}
func GetAll() []*MCU {
return mcus
}
func GetBySignature(signature uint16) (*MCU, error) {
for _, mcu := range mcus {
if signature == mcu.signature {
return mcu, nil
}
}
return nil, fmt.Errorf("devices: MCU lookup failed for signature: 0x%04x", signature)
}
func GetByName(name string) (*MCU, error) {
lcName := strings.ToLower(name)
for _, mcu := range mcus {
if lcName == strings.ToLower(mcu.name) {
return mcu, nil
}
}
return nil, fmt.Errorf("devices: MCU lookup failed for name: %s", name)
}
func (m *MCU) Name() string {
return m.name
}
func (m *MCU) Signature() uint16 {
return m.signature
}
func (m *MCU) FlashPageSize() uint16 {
return m.flashPageSize
}
func (m *MCU) FlashSize() uint16 {
return m.flashSize
}
func (m *MCU) NRWWOffset() uint16 {
return m.nrwwOffset
}
func (m *MCU) EEPROMSize() uint16 {
return m.eepromSize
}
func (m *MCU) EEAR() SFR {
return SFR{m.eear, m.eearSize}
}
func (m *MCU) EEDR() SFR {
return SFR{m.eedr, m.eedrSize}
}
func (m *MCU) EECR() SFR {
return SFR{m.eecr, m.eecrSize}
}
func (m *MCU) SPMCSR() SFR {
return SFR{m.spmcsr, m.spmcsrSize}
}
func (m *MCU) SP() SFR {
return SFR{m.sp, m.spSize}
}
func (m *MCU) SREG() SFR {
return SFR{m.sreg, m.sregSize}
}
func (m *MCU) DWENMask() byte {
return m.dwenMask
}