Skip to content

Commit 2bee299

Browse files
committed
refactor: use *SPI everywhere to make consistant for implementations.
Fixes #4663 "in reverse" by making SPI a pointer everywhere, as discussed in the comments. Signed-off-by: deadprogram <ron@hybridgroup.com>
1 parent cab3834 commit 2bee299

31 files changed

+99
-101
lines changed

src/machine/board_feather-stm32f405.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,15 @@ const (
186186
)
187187

188188
var (
189-
SPI1 = SPI{
189+
SPI1 = &SPI{
190190
Bus: stm32.SPI2,
191191
AltFuncSelector: AF5_SPI1_SPI2,
192192
}
193-
SPI2 = SPI{
193+
SPI2 = &SPI{
194194
Bus: stm32.SPI3,
195195
AltFuncSelector: AF6_SPI3,
196196
}
197-
SPI3 = SPI{
197+
SPI3 = &SPI{
198198
Bus: stm32.SPI1,
199199
AltFuncSelector: AF5_SPI1_SPI2,
200200
}

src/machine/board_lgt92.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ var (
8484
I2C0 = I2C1
8585

8686
// SPI
87-
SPI0 = SPI{
87+
SPI0 = &SPI{
8888
Bus: stm32.SPI1,
8989
}
90-
SPI1 = &SPI0
90+
SPI1 = SPI0
9191
)
9292

9393
func init() {

src/machine/board_maixbit_baremetal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import "device/kendryte"
66

77
// SPI on the MAix Bit.
88
var (
9-
SPI0 = SPI{
9+
SPI0 = &SPI{
1010
Bus: kendryte.SPI0,
1111
}
12-
SPI1 = SPI{
12+
SPI1 = &SPI{
1313
Bus: kendryte.SPI1,
1414
}
1515
)

src/machine/board_mksnanov3.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ const (
8989

9090
// Since the first interface is named SPI1, both SPI0 and SPI1 refer to SPI1.
9191
var (
92-
SPI0 = SPI{
92+
SPI0 = &SPI{
9393
Bus: stm32.SPI1,
9494
AltFuncSelector: AF5_SPI1_SPI2,
9595
}
96-
SPI1 = &SPI0
96+
SPI1 = SPI0
9797
)
9898

9999
const (

src/machine/board_nucleol031k6.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ var (
8686
I2C0 = I2C1
8787

8888
// SPI
89-
SPI0 = SPI{
89+
SPI0 = &SPI{
9090
Bus: stm32.SPI1,
9191
AltFuncSelector: 0,
9292
}
93-
SPI1 = &SPI0
93+
SPI1 = SPI0
9494
)
9595

9696
func init() {

src/machine/board_stm32f469disco.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ const (
5959
// Since the first interface is named SPI1, both SPI0 and SPI1 refer to SPI1.
6060
// TODO: implement SPI2 and SPI3.
6161
var (
62-
SPI0 = SPI{
62+
SPI0 = &SPI{
6363
Bus: stm32.SPI1,
6464
AltFuncSelector: AF5_SPI1_SPI2,
6565
}
66-
SPI1 = &SPI0
66+
SPI1 = SPI0
6767
)
6868

6969
const (

src/machine/board_stm32f4disco.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ const (
8686
// Since the first interface is named SPI1, both SPI0 and SPI1 refer to SPI1.
8787
// TODO: implement SPI2 and SPI3.
8888
var (
89-
SPI0 = SPI{
89+
SPI0 = &SPI{
9090
Bus: stm32.SPI1,
9191
AltFuncSelector: AF5_SPI1_SPI2,
9292
}
93-
SPI1 = &SPI0
93+
SPI1 = SPI0
9494
)
9595

9696
const (

src/machine/machine_atmega.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ type SPI struct {
257257
}
258258

259259
// Configure is intended to setup the SPI interface.
260-
func (s SPI) Configure(config SPIConfig) error {
260+
func (s *SPI) Configure(config SPIConfig) error {
261261

262262
// This is only here to help catch a bug with the configuration
263263
// where a machine missed a value.
@@ -330,7 +330,7 @@ func (s SPI) Configure(config SPIConfig) error {
330330
}
331331

332332
// Transfer writes the byte into the register and returns the read content
333-
func (s SPI) Transfer(b byte) (byte, error) {
333+
func (s *SPI) Transfer(b byte) (byte, error) {
334334
s.spdr.Set(uint8(b))
335335

336336
for !s.spsr.HasBits(s.spsrSPIF) {

src/machine/machine_atmega1280.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ func (pwm PWM) Set(channel uint8, value uint32) {
927927
}
928928

929929
// SPI configuration
930-
var SPI0 = SPI{
930+
var SPI0 = &SPI{
931931
spcr: avr.SPCR,
932932
spdr: avr.SPDR,
933933
spsr: avr.SPSR,

src/machine/machine_atmega1284p.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (p Pin) getPortMask() (*volatile.Register8, uint8) {
7171
}
7272

7373
// SPI configuration
74-
var SPI0 = SPI{
74+
var SPI0 = &SPI{
7575
spcr: avr.SPCR,
7676
spsr: avr.SPSR,
7777
spdr: avr.SPDR,

0 commit comments

Comments
 (0)