host: migrate functions to subpackage cpu. (#63)

Otherwise this would cause some drivers to import host, which would import
drivers that the user may not desire.

This commit fixes this import loop.
pull/1/head
M-A 10 years ago committed by Thorsten von Eicken
parent f7261fe4df
commit 5cddc1641d

@ -15,7 +15,7 @@ import (
"time"
"github.com/google/periph/conn/gpio"
"github.com/google/periph/host"
"github.com/google/periph/host/cpu"
)
// Clock converts time to a slice of bytes as segments.
@ -184,5 +184,5 @@ func (d *Dev) writeByte(b byte) (bool, error) {
// sleep does a busy loop to act as fast as possible.
func (d *Dev) sleepHalfCycle() {
host.Nanospin(clockHalfCycle)
cpu.Nanospin(clockHalfCycle)
}

@ -17,7 +17,7 @@ import (
"github.com/google/periph/conn/gpio"
"github.com/google/periph/conn/i2c"
"github.com/google/periph/host"
"github.com/google/periph/host/cpu"
)
// Use SkipAddr to skip the address from being sent.
@ -251,7 +251,7 @@ func (i *I2C) readByte() (byte, error) {
// sleep does a busy loop to act as fast as possible.
func (i *I2C) sleepHalfCycle() {
host.Nanospin(i.halfCycle)
cpu.Nanospin(i.halfCycle)
}
var _ i2c.Bus = &I2C{}

@ -19,7 +19,7 @@ import (
"github.com/google/periph/conn/gpio"
"github.com/google/periph/conn/spi"
"github.com/google/periph/host"
"github.com/google/periph/host/cpu"
)
// SPI represents a SPI master implemented as bit-banging on 3 or 4 GPIO pins.
@ -164,7 +164,7 @@ func NewSPI(clk, mosi gpio.PinOut, miso gpio.PinIn, cs gpio.PinOut, speedHz int6
// sleep does a busy loop to act as fast as possible.
func (s *SPI) sleepHalfCycle() {
host.Nanospin(s.halfCycle)
cpu.Nanospin(s.halfCycle)
}
var _ spi.Conn = &SPI{}

Loading…
Cancel
Save