Skip to content

Commit b7b49dd

Browse files
committed
Fix CI problems, handle errors correctly and enrich documentation.
* Add the 2022 copyright header on all changed files. * Document all functions, vars and structs. * Propagate unhandled errors. * Add me to the list of contributors.
1 parent 5444382 commit b7b49dd

File tree

9 files changed

+55
-21
lines changed

9 files changed

+55
-21
lines changed

AUTHORS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ Max Ekman <[email protected]>
1212
Rifiniti, Inc
1313
Stephan Sperber
1414
Thorsten von Eicken <[email protected]>
15-
15+
Aaron Fischer <[email protected]>

allwinner/detect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016 The Periph Authors. All rights reserved.
1+
// Copyright 2022 The Periph Authors. All rights reserved.
22
// Use of this source code is governed under the Apache License, Version 2.0
33
// that can be found in the LICENSE file.
44

allwinner/gpio.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016 The Periph Authors. All rights reserved.
1+
// Copyright 2022 The Periph Authors. All rights reserved.
22
// Use of this source code is governed under the Apache License, Version 2.0
33
// that can be found in the LICENSE file.
44

allwinner/h3.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// Copyright 2022 The Periph Authors. All rights reserved.
2+
// Use of this source code is governed under the Apache License, Version 2.0
3+
// that can be found in the LICENSE file.
4+
5+
// This file contains pin mapping information that is specific to the Allwinner
6+
// H2+ and H3 model.
7+
18
package allwinner
29

310
import (
@@ -7,7 +14,9 @@ import (
714
"periph.io/x/host/v3/sysfs"
815
)
916

10-
// Page 74 (Chapter 3.2 GPIO Multiplexing Functions)
17+
// mappingH3 describes the mapping of the H3 processor GPIO pins to their
18+
// functions. The mappings source is the official H3 Datasheet, version 1.0,
19+
// page 74 (chapter 3.2 GPIO Multiplexing Functions).
1120
// http://dl.linux-sunxi.org/H3/Allwinner_H3_Datasheet_V1.0.pdf
1221
var mappingH3 = map[string][5]pin.Func{
1322
"PA0": {"UART2_TX", "JTAG_MS", "", "", "PA_EINT0"},
@@ -124,6 +133,9 @@ var mappingH3 = map[string][5]pin.Func{
124133
"PL11": {"S_CIR_RX", "", "", "", "S_PL_EINT12"},
125134
}
126135

136+
// mapH3Pins uses mappingH3 to set the altFunc fields of all the GPIO pings and
137+
// mark them as available. This is called if the generic allwinner processor
138+
// code detects a H2+ or H3 processor.
127139
func mapH3Pins() error {
128140
for name, altFuncs := range mappingH3 {
129141
pin := cpupins[name]

orangepi/doc.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// copyright 2016 the periph authors. all rights reserved.
2-
// use of this source code is governed under the apache license, version 2.0
3-
// that can be found in the license file.
1+
// Copyright 2022 The Periph Authors. All rights reserved.
2+
// Use of this source code is governed under the Apache License, Version 2.0
3+
// that can be found in the LICENSE file.
44

5-
// package orangepi contains Orange Pi hardware logic.
5+
// Package orangepi contains Orange Pi hardware logic.
66
//
7-
// requires armbian jessie server.
7+
// Requires armbian jessie server.
88
//
9-
// physical
9+
// # Physical
1010
//
1111
// http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/index.html
1212
package orangepi

orangepi/orangepi.go

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
// Copyright 2016 The Periph Authors. All rights reserved.
1+
// Copyright 2022 The Periph Authors. All rights reserved.
22
// Use of this source code is governed under the Apache License, Version 2.0
33
// that can be found in the LICENSE file.
44

5+
// Orange Pi pin out.
6+
57
package orangepi
68

79
import (
@@ -17,8 +19,11 @@ import (
1719
"periph.io/x/host/v3/distro"
1820
)
1921

22+
// Present return true if a Orange Pi board is detected.
2023
func Present() bool {
2124
if isArm {
25+
// This works for the Orange Pi Zero, not sure if other Orange Pi boards
26+
// match the same DTModel prefix.
2227
return strings.HasPrefix(distro.DTModel(), "OrangePi")
2328
}
2429

@@ -72,11 +77,13 @@ var (
7277
FUN1_13 pin.Pin = allwinner.PL11 // IR-RX
7378
)
7479

75-
func registerHeaders(model string) {
80+
// registerHeaders registers the headers for various Orange Pi boards. Currently
81+
// only Orange Pi Zero is supported.
82+
func registerHeaders(model string) error {
7683
// http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/details/Orange-Pi-Zero.html
7784
if strings.Contains(model, boardZero) {
7885
// 26pin expansion port
79-
pinreg.Register("PA", [][]pin.Pin{
86+
if err := pinreg.Register("PA", [][]pin.Pin{
8087
{PA1_1, PA1_2},
8188
{PA1_3, PA1_4},
8289
{PA1_5, PA1_6},
@@ -90,10 +97,12 @@ func registerHeaders(model string) {
9097
{PA1_21, PA1_22},
9198
{PA1_23, PA1_24},
9299
{PA1_25, PA1_26},
93-
})
100+
}); err != nil {
101+
return err
102+
}
94103

95104
// 13pin function interface
96-
pinreg.Register("FUN", [][]pin.Pin{
105+
if err := pinreg.Register("FUN", [][]pin.Pin{
97106
{FUN1_1},
98107
{FUN1_2},
99108
{FUN1_3},
@@ -107,25 +116,37 @@ func registerHeaders(model string) {
107116
{FUN1_11},
108117
{FUN1_12},
109118
{FUN1_13},
110-
})
119+
}); err != nil {
120+
return err
121+
}
111122
}
123+
124+
return nil
112125
}
113126

127+
// driver implements periph.Driver.
114128
type driver struct {
115129
}
116130

131+
// String is the text representation of the board.
117132
func (d *driver) String() string {
118133
return "orangepi"
119134
}
120135

136+
// Prerequisites load drivers before the actual driver is loaded. For
137+
// these boards, we do not need any prerequisites.
121138
func (d *driver) Prerequisites() []string {
122139
return nil
123140
}
124141

142+
// After this driver is loaded, we need to load generic Allwinner drivers
143+
// for the GPIO pins which are identical on all Allwinner CPUs.
125144
func (d *driver) After() []string {
126145
return []string{"allwinner-gpio", "allwinner-gpio-pl"}
127146
}
128147

148+
// Init initializes the driver by checking its presence and if found, the
149+
// driver will be registered.
129150
func (d *driver) Init() (bool, error) {
130151
if !Present() {
131152
return false, errors.New("borad Orange Pi not detected")
@@ -136,10 +157,11 @@ func (d *driver) Init() (bool, error) {
136157
return true, fmt.Errorf("orangepi: failed to obtain model")
137158
}
138159

139-
registerHeaders(model)
140-
return true, nil
160+
err := registerHeaders(model)
161+
return true, err
141162
}
142163

164+
// init register the driver.
143165
func init() {
144166
if isArm {
145167
driverreg.MustRegister(&drv)

orangepi/orangepi_arm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016 The Periph Authors. All rights reserved.
1+
// Copyright 2022 The Periph Authors. All rights reserved.
22
// Use of this source code is governed under the Apache License, Version 2.0
33
// that can be found in the LICENSE file.
44

orangepi/orangepi_arm64.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016 The Periph Authors. All rights reserved.
1+
// Copyright 2022 The Periph Authors. All rights reserved.
22
// Use of this source code is governed under the Apache License, Version 2.0
33
// that can be found in the LICENSE file.
44

orangepi/orangepi_other.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2016 The Periph Authors. All rights reserved.
1+
// Copyright 2022 The Periph Authors. All rights reserved.
22
// Use of this source code is governed under the Apache License, Version 2.0
33
// that can be found in the LICENSE file.
44

0 commit comments

Comments
 (0)