Skip to content

Commit 99ed706

Browse files
authored
Merge branch 'dev' into spi-tester
2 parents 26de9ec + 156d6e7 commit 99ed706

File tree

18 files changed

+30
-27
lines changed

18 files changed

+30
-27
lines changed

examples/flash/console/spi/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
func main() {
1111
console_example.RunFor(
1212
flash.NewSPI(
13-
&machine.SPI1,
13+
machine.SPI1,
1414
machine.SPI1_SDO_PIN,
1515
machine.SPI1_SDI_PIN,
1616
machine.SPI1_SCK_PIN,

examples/sdcard/console/feather-m4.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func init() {
10-
spi = &machine.SPI0
10+
spi = machine.SPI0
1111
sckPin = machine.SPI0_SCK_PIN
1212
sdoPin = machine.SPI0_SDO_PIN
1313
sdiPin = machine.SPI0_SDI_PIN

examples/sdcard/console/grandcentral-m4.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func init() {
10-
spi = &machine.SPI1
10+
spi = machine.SPI1
1111
sckPin = machine.SDCARD_SCK_PIN
1212
sdoPin = machine.SDCARD_SDO_PIN
1313
sdiPin = machine.SDCARD_SDI_PIN

examples/sdcard/console/m0.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func init() {
10-
spi = &machine.SPI0
10+
spi = machine.SPI0
1111
sckPin = machine.SPI0_SCK_PIN
1212
sdoPin = machine.SPI0_SDO_PIN
1313
sdiPin = machine.SPI0_SDI_PIN

examples/sdcard/console/p1am-100.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func init() {
10-
spi = &machine.SDCARD_SPI
10+
spi = machine.SDCARD_SPI
1111
sckPin = machine.SDCARD_SCK_PIN
1212
sdoPin = machine.SDCARD_SDO_PIN
1313
sdiPin = machine.SDCARD_SDI_PIN

examples/sdcard/console/pygamer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func init() {
10-
spi = &machine.SPI0
10+
spi = machine.SPI0
1111
sckPin = machine.SPI0_SCK_PIN
1212
sdoPin = machine.SPI0_SDO_PIN
1313
sdiPin = machine.SPI0_SDI_PIN

examples/sdcard/console/pyportal.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func init() {
10-
spi = &machine.SPI0
10+
spi = machine.SPI0
1111
sckPin = machine.SPI0_SCK_PIN
1212
sdoPin = machine.SPI0_SDO_PIN
1313
sdiPin = machine.SPI0_SDI_PIN

examples/sdcard/console/wioterminal.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func init() {
10-
spi = &machine.SPI2
10+
spi = machine.SPI2
1111
sckPin = machine.SCK2
1212
sdoPin = machine.SDO2
1313
sdiPin = machine.SDI2

examples/tmc5160/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func main() {
2727
//bind csPin to driverAdddress
2828
driverAddress := uint8(0) // Let's assume we are working with driver at address 0x01
2929
// Step 3. Bind the communication interface to the protocol
30-
comm := tmc5160.NewSPIComm(*spi, csPins)
30+
comm := tmc5160.NewSPIComm(spi, csPins)
3131
// Step 4. Define your stepper like this below
3232
//stepper := tmc5160.NewStepper(angle , gearRatio vSupply rCoil , lCoil , iPeak , rSense , mSteps, fclk )
3333
stepper := tmc5160.NewDefaultStepper() // Default Stepper should be used only for testing.

ili9341/spi_atsamd21.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88
)
99

1010
type spiDriver struct {
11-
bus machine.SPI
11+
bus *machine.SPI
1212
}
1313

14-
func NewSPI(bus machine.SPI, dc, cs, rst machine.Pin) *Device {
14+
func NewSPI(bus *machine.SPI, dc, cs, rst machine.Pin) *Device {
1515
return &Device{
1616
dc: dc,
1717
cs: cs,

ili9341/spi_atsamd51.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88
)
99

1010
type spiDriver struct {
11-
bus machine.SPI
11+
bus *machine.SPI
1212
}
1313

14-
func NewSPI(bus machine.SPI, dc, cs, rst machine.Pin) *Device {
14+
func NewSPI(bus *machine.SPI, dc, cs, rst machine.Pin) *Device {
1515
return &Device{
1616
dc: dc,
1717
cs: cs,

max6675/max6675.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Device struct {
1919
// Create a new Device to read from a MAX6675 thermocouple.
2020
// Pins must be configured before use. Frequency for SPI
2121
// should be 4.3MHz maximum.
22-
func NewDevice(bus drivers.SPI, cs drivers.Pin) *Device {
22+
func NewDevice(bus drivers.SPI, cs machine.Pin) *Device {
2323
return &Device{
2424
bus: bus,
2525
cs: cs,

max72xx/max72xx.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ package max72xx
44

55
import (
66
"machine"
7+
8+
"tinygo.org/x/drivers"
79
)
810

911
type Device struct {
10-
bus machine.SPI
12+
bus drivers.SPI
1113
cs machine.Pin
1214
}
1315

1416
// NewDriver creates a new max7219 connection. The SPI wire must already be configured
1517
// The SPI frequency must not be higher than 10MHz.
1618
// parameter cs: the datasheet also refers to this pin as "load" pin.
17-
func NewDevice(bus machine.SPI, cs machine.Pin) *Device {
19+
func NewDevice(bus drivers.SPI, cs machine.Pin) *Device {
1820
return &Device{
1921
bus: bus,
2022
cs: cs,

p1am/p1am.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import (
1414
)
1515

1616
type P1AM struct {
17-
bus machine.SPI
17+
bus *machine.SPI
18+
1819
slaveSelectPin, slaveAckPin, baseEnablePin machine.Pin
1920

2021
// SkipAutoConfig will skip loading a default configuration into each module.

sx127x/sx127x.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (d *Device) GetRadioEventChan() chan lora.RadioEvent {
4343
}
4444

4545
// New creates a new SX127x connection. The SPI bus must already be configured.
46-
func New(spi machine.SPI, rstPin machine.Pin) *Device {
46+
func New(spi drivers.SPI, rstPin machine.Pin) *Device {
4747
k := Device{
4848
spi: spi,
4949
rstPin: rstPin,

tmc5160/README.MD

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ if err != nil {
183183

184184
## API Reference
185185

186-
NewSPIComm(spi machine.SPI, csPins map[uint8]machine.Pin) *SPIComm
186+
NewSPIComm(spi *machine.SPI, csPins map[uint8]machine.Pin) *SPIComm
187187

188188
Creates a new SPI communication interface for the TMC5160.
189189

tmc5160/spicomm.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ func (e CustomError) Error() string {
1616

1717
// SPIComm implements RegisterComm for SPI-based communication
1818
type SPIComm struct {
19-
spi machine.SPI
19+
spi *machine.SPI
2020
CsPins map[uint8]machine.Pin // Map to store CS pin for each Driver by its address
2121
}
2222

2323
// NewSPIComm creates a new SPIComm instance.
24-
func NewSPIComm(spi machine.SPI, csPins map[uint8]machine.Pin) *SPIComm {
24+
func NewSPIComm(spi *machine.SPI, csPins map[uint8]machine.Pin) *SPIComm {
2525
return &SPIComm{
2626
spi: spi,
2727
CsPins: csPins,
@@ -31,7 +31,7 @@ func NewSPIComm(spi machine.SPI, csPins map[uint8]machine.Pin) *SPIComm {
3131
// Setup initializes the SPI communication with the Driver and configures all CS pins.
3232
func (comm *SPIComm) Setup() error {
3333
// Check if SPI is initialized
34-
if comm.spi == (machine.SPI{}) {
34+
if comm.spi == nil {
3535
return CustomError("SPI not initialized")
3636
}
3737

@@ -66,7 +66,7 @@ func (comm *SPIComm) WriteRegister(register uint8, value uint32, driverAddress u
6666
addressWithWriteAccess := register | 0x80
6767

6868
// Send the address and the data to write (split into 4 bytes)
69-
_, err := spiTransfer40(&comm.spi, addressWithWriteAccess, value)
69+
_, err := spiTransfer40(comm.spi, addressWithWriteAccess, value)
7070
if err != nil {
7171
csPin.High()
7272
return CustomError("Failed to write register")
@@ -88,7 +88,7 @@ func (comm *SPIComm) ReadRegister(register uint8, driverAddress uint8) (uint32,
8888
csPin.Low()
8989

9090
// Step 1: Send a dummy write operation to begin the read sequence
91-
_, err := spiTransfer40(&comm.spi, register, 0x00) // Send dummy data
91+
_, err := spiTransfer40(comm.spi, register, 0x00) // Send dummy data
9292
if err != nil {
9393
csPin.High()
9494
return 0, CustomError("Failed to send dummy write")
@@ -97,7 +97,7 @@ func (comm *SPIComm) ReadRegister(register uint8, driverAddress uint8) (uint32,
9797
time.Sleep(176 * time.Nanosecond)
9898
csPin.Low()
9999
// Step 2: Send the register read request again to get the actual value
100-
response, err := spiTransfer40(&comm.spi, register, 0x00) // Send again to get actual register data
100+
response, err := spiTransfer40(comm.spi, register, 0x00) // Send again to get actual register data
101101
if err != nil {
102102
csPin.High()
103103
return 0, CustomError("Failed to read register")

waveshare-epd/epd1in54/epd1in54.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type Config struct {
2222
}
2323

2424
type Device struct {
25-
bus machine.SPI
25+
bus *machine.SPI
2626
cs machine.Pin
2727
dc machine.Pin
2828
rst machine.Pin
@@ -79,7 +79,7 @@ var partialRefresh = [159]uint8{
7979
}
8080

8181
// New returns a new epd1in54 driver. Pass in a fully configured SPI bus.
82-
func New(bus machine.SPI, csPin, dcPin, rstPin, busyPin machine.Pin) Device {
82+
func New(bus *machine.SPI, csPin, dcPin, rstPin, busyPin machine.Pin) Device {
8383
return Device{
8484
buffer: make([]uint8, (uint32(Width)*uint32(Height))/8),
8585
bus: bus,

0 commit comments

Comments
 (0)