-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardware_gpio_debug.go
115 lines (105 loc) · 2.48 KB
/
hardware_gpio_debug.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
106
107
108
109
110
111
112
113
114
115
//go:build !production
package sdk
import (
"fmt"
"strings"
)
//////////////////////////////////////////////////////////////////////////////
// STRINGIFY
func (v GPIO_pin) String() string {
return fmt.Sprint("GP", uint(v))
}
func (v GPIO_function) String() string {
switch v {
case GPIO_FUNC_XIP:
return "GPIO_FUNC_XIP"
case GPIO_FUNC_SPI:
return "GPIO_FUNC_SPI"
case GPIO_FUNC_UART:
return "GPIO_FUNC_UART"
case GPIO_FUNC_I2C:
return "GPIO_FUNC_I2C"
case GPIO_FUNC_PWM:
return "GPIO_FUNC_PWM"
case GPIO_FUNC_SIO:
return "GPIO_FUNC_SIO"
case GPIO_FUNC_PIO0:
return "GPIO_FUNC_PIO0"
case GPIO_FUNC_PIO1:
return "GPIO_FUNC_PIO1"
case GPIO_FUNC_GPCK:
return "GPIO_FUNC_GPCK"
case GPIO_FUNC_USB:
return "GPIO_FUNC_USB"
case GPIO_FUNC_NULL:
return "GPIO_FUNC_NULL"
default:
return fmt.Sprintf("GPIO_function(0x%02X)", uint(v))
}
}
func (v GPIO_override) String() string {
switch v {
case GPIO_OVERRIDE_NORMAL:
return "GPIO_OVERRIDE_NORMAL"
case GPIO_OVERRIDE_INVERT:
return "GPIO_OVERRIDE_INVERT"
case GPIO_OVERRIDE_LOW:
return "GPIO_OVERRIDE_LOW"
case GPIO_OVERRIDE_HIGH:
return "GPIO_OVERRIDE_HIGH"
default:
return fmt.Sprintf("GPIO_override(0x%02X)", uint(v))
}
}
func (v GPIO_slew_rate) String() string {
switch v {
case GPIO_SLEW_RATE_SLOW:
return "GPIO_SLEW_RATE_SLOW"
case GPIO_SLEW_RATE_FAST:
return "GPIO_SLEW_RATE_FAST"
default:
return fmt.Sprintf("GPIO_slew_rate(0x%02X)", uint(v))
}
}
func (v GPIO_drive_strength) String() string {
switch v {
case GPIO_DRIVE_STRENGTH_2MA:
return "GPIO_DRIVE_STRENGTH_2MA"
case GPIO_DRIVE_STRENGTH_4MA:
return "GPIO_DRIVE_STRENGTH_4MA"
case GPIO_DRIVE_STRENGTH_8MA:
return "GPIO_DRIVE_STRENGTH_8MA"
case GPIO_DRIVE_STRENGTH_12MA:
return "GPIO_DRIVE_STRENGTH_12MA"
default:
return fmt.Sprintf("GPIO_drive_strength(0x%02X)", uint(v))
}
}
func (v GPIO_irq_level) _String() string {
switch v {
case GPIO_IRQ_LEVEL_NONE:
return "GPIO_IRQ_LEVEL_NONE"
case GPIO_IRQ_LEVEL_LOW:
return "GPIO_IRQ_LEVEL_LOW"
case GPIO_IRQ_LEVEL_HIGH:
return "GPIO_IRQ_LEVEL_HIGH"
case GPIO_IRQ_EDGE_FALL:
return "GPIO_IRQ_EDGE_FALL"
case GPIO_IRQ_EDGE_RISE:
return "GPIO_IRQ_EDGE_RISE"
default:
return fmt.Sprintf("GPIO_irq_level(0x%02X)", uint(v))
}
}
func (v GPIO_irq_level) String() string {
if v == GPIO_IRQ_LEVEL_NONE {
return v._String()
}
str := ""
for f := GPIO_irq_level(1); f <= GPIO_IRQ_LEVEL_MAX; f <<= 1 {
if v&f != 0 {
str += f._String() + "|"
}
}
return strings.Trim(str, "|")
}