vendorer periiph host
This commit is contained in:
1 parent
4bed603e6d
commit
b2305a992b
6 files changed
+76
-7
No files matched your search
@@ -2,7 +2,7 @@ module go-orange
|
|||||||
|
|
||||||
go 1.22
|
go 1.22
|
||||||
|
|
||||||
replace periph.io/x/host/v3 v3.8.2 => github.com/didiercrunch/host/v3 v3.8.2
|
replace periph.io/x/host/v3 v3.8.2 => github.com/didiercrunch/host/v3 v3.8.3-0.20240727134510-3ddf0ec6acb8
|
||||||
|
|
||||||
require (
|
require (
|
||||||
periph.io/x/conn/v3 v3.7.0
|
periph.io/x/conn/v3 v3.7.0
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
github.com/didiercrunch/host/v3 v3.8.2 h1:3FCnaC7Dyf6RKBTwUbS5pDA4k3/XttijMmi4PBQgNh8=
|
github.com/didiercrunch/host/v3 v3.8.3-0.20240727134510-3ddf0ec6acb8 h1:Fe73Ns7pPH6rqbDhiKUHEkCwTaasuv8JQAQwEqlq+Es=
|
||||||
github.com/didiercrunch/host/v3 v3.8.2/go.mod h1:yFL76AesNHR68PboofSWYaQTKmvPXsQH2Apvp/ls/K4=
|
github.com/didiercrunch/host/v3 v3.8.3-0.20240727134510-3ddf0ec6acb8/go.mod h1:yFL76AesNHR68PboofSWYaQTKmvPXsQH2Apvp/ls/K4=
|
||||||
github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg=
|
github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg=
|
||||||
github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||||
periph.io/x/conn/v3 v3.7.0 h1:f1EXLn4pkf7AEWwkol2gilCNZ0ElY+bxS4WE2PQXfrA=
|
periph.io/x/conn/v3 v3.7.0 h1:f1EXLn4pkf7AEWwkol2gilCNZ0ElY+bxS4WE2PQXfrA=
|
||||||
|
|||||||
Vendored
+1
-1
@@ -13,7 +13,7 @@ periph.io/x/conn/v3/pin
|
|||||||
periph.io/x/conn/v3/pin/pinreg
|
periph.io/x/conn/v3/pin/pinreg
|
||||||
periph.io/x/conn/v3/spi
|
periph.io/x/conn/v3/spi
|
||||||
periph.io/x/conn/v3/spi/spireg
|
periph.io/x/conn/v3/spi/spireg
|
||||||
# periph.io/x/host/v3 v3.8.2 => github.com/didiercrunch/host/v3 v3.8.2
|
# periph.io/x/host/v3 v3.8.2 => github.com/didiercrunch/host/v3 v3.8.3-0.20240727134510-3ddf0ec6acb8
|
||||||
## explicit; go 1.20
|
## explicit; go 1.20
|
||||||
periph.io/x/host/v3
|
periph.io/x/host/v3
|
||||||
periph.io/x/host/v3/allwinner
|
periph.io/x/host/v3/allwinner
|
||||||
|
|||||||
+65
-2
@@ -969,8 +969,12 @@ var cpuPins = []Pin{
|
|||||||
{number: 46, name: "GPIO46", defaultPull: gpio.PullUp},
|
{number: 46, name: "GPIO46", defaultPull: gpio.PullUp},
|
||||||
}
|
}
|
||||||
|
|
||||||
// This excludes the functions in and out.
|
// The alternate function mapping tables exclude the functions in and out.
|
||||||
var mapping = [][6]pin.Func{
|
// Mapping may be overridden during driverGPIO.Init().
|
||||||
|
var mapping = mapping283x
|
||||||
|
|
||||||
|
// BCM238x specific alternate function mapping (the default).
|
||||||
|
var mapping283x = [][6]pin.Func{
|
||||||
{"I2C0_SDA"}, // 0
|
{"I2C0_SDA"}, // 0
|
||||||
{"I2C0_SCL"},
|
{"I2C0_SCL"},
|
||||||
{"I2C1_SDA"},
|
{"I2C1_SDA"},
|
||||||
@@ -1020,6 +1024,64 @@ var mapping = [][6]pin.Func{
|
|||||||
{""},
|
{""},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BCM2711 specific alternate function mapping; mostly compatible to
|
||||||
|
// mapping283x, with the exception that there is no user-accessible SPI2
|
||||||
|
// (the original SPI2-related positions have been assigned
|
||||||
|
// corresponding SPI0 functions). Also, since there is an additional
|
||||||
|
// PWM1 device, the original PWM0/PWM1 entries had to be
|
||||||
|
// renamed into PWM0_0, PWM0_1.
|
||||||
|
// The table has been generated from BCM2711's specification,
|
||||||
|
// slightly adjusted to match the original mapping's naming.
|
||||||
|
var mapping2711 = [][6]pin.Func{
|
||||||
|
{"I2C0_SDA", "", "", "SPI3_CS0", "UART2_TX", "I2C6_SDA"}, // 0
|
||||||
|
{"I2C0_SCL", "", "", "SPI3_MISO", "UART2_RX", "I2C6_SCL"},
|
||||||
|
{"I2C1_SDA", "", "", "SPI3_MOSI", "UART2_CTS", "I2C3_SDA"},
|
||||||
|
{"I2C1_SCL", "", "", "SPI3_CLK", "UART2_RTS", "I2C3_SCL"},
|
||||||
|
{"CLK0", "", "", "SPI4_CS0", "UART3_TX", "I2C3_SDA"},
|
||||||
|
{"CLK1", "", "", "SPI4_MISO", "UART3_RX", "I2C3_SCL"}, // 5
|
||||||
|
{"CLK2", "", "", "SPI4_MOSI", "UART3_CTS", "I2C4_SDA"},
|
||||||
|
{"SPI0_CS1", "", "", "SPI4_CLK", "UART3_RTS", "I2C4_SCL"},
|
||||||
|
{"SPI0_CS0", "", "", "", "UART4_TX", "I2C4_SDA"},
|
||||||
|
{"SPI0_MISO", "", "", "", "UART4_RX", "I2C4_SCL"},
|
||||||
|
{"SPI0_MOSI", "", "", "", "UART4_CTS", "I2C5_SDA"}, // 10
|
||||||
|
{"SPI0_CLK", "", "", "", "UART4_RTS", "I2C5_SCL"},
|
||||||
|
{"PWM0_0", "", "", "SPI5_CS0", "UART5_TX", "I2C5_SDA"},
|
||||||
|
{"PWM0_1", "", "", "SPI5_MISO", "UART5_RX", "I2C5_SCL"},
|
||||||
|
{"UART0_TX", "", "", "SPI5_MOSI", "UART5_CTS", "UART1_TX"},
|
||||||
|
{"UART0_RX", "", "", "SPI5_CLK", "UART5_RTS", "UART1_RX"}, // 15
|
||||||
|
{"", "", "", "UART0_CTS", "SPI1_CS2", "UART1_CTS"},
|
||||||
|
{"", "", "", "UART0_RTS", "SPI1_CS1", "UART1_RTS"},
|
||||||
|
{"I2S_SCK", "", "", "SPI6_CS0", "SPI1_CS0", "PWM0_0"},
|
||||||
|
{"I2S_WS", "", "", "SPI6_MISO", "SPI1_MISO", "PWM0_1"},
|
||||||
|
{"I2S_DIN", "", "", "SPI6_MOSI", "SPI1_MOSI", "CLK0"}, // 20
|
||||||
|
{"I2S_DOUT", "", "", "SPI6_CLK", "SPI1_CLK", "CLK1"},
|
||||||
|
{"", "", "", "", "", "I2C6_SDA"},
|
||||||
|
{"", "", "", "", "", "I2C6_SCL"},
|
||||||
|
{"", "", "", "", "", "SPI3_CS1"},
|
||||||
|
{"", "", "", "", "", "SPI4_CS1"}, // 25
|
||||||
|
{"", "", "", "", "", "SPI5_CS1"},
|
||||||
|
{"", "", "", "", "", "SPI6_CS1"},
|
||||||
|
{"I2C0_SDA", "", "I2S_SCK", "", "", ""},
|
||||||
|
{"I2C0_SCL", "", "I2S_WS", "", "", ""},
|
||||||
|
{"", "", "I2S_DIN", "UART0_CTS", "", "UART1_CTS"}, // 30
|
||||||
|
{"", "", "I2S_DOUT", "UART0_RTS", "", "UART1_RTS"},
|
||||||
|
{"CLK0", "", "", "UART0_TX", "", "UART1_TX"},
|
||||||
|
{"", "", "", "UART0_RX", "", "UART1_RX"},
|
||||||
|
{"CLK0"},
|
||||||
|
{"SPI0_CS1"}, // 35
|
||||||
|
{"SPI0_CS0", "", "UART0_TX", "", "", ""},
|
||||||
|
{"SPI0_MISO", "", "UART0_RX", "", "", ""},
|
||||||
|
{"SPI0_MOSI", "", "UART0_RTS", "", "", ""},
|
||||||
|
{"SPI0_CLK", "", "UART0_CTS", "", "", ""},
|
||||||
|
{"PWM1_0", "", "", "", "SPI0_MISO", "UART1_TX"}, // 40
|
||||||
|
{"PWM1_1", "", "", "", "SPI0_MOSI", "UART1_RX"},
|
||||||
|
{"CLK1", "", "", "", "SPI0_CLK", "UART1_RTS"},
|
||||||
|
{"CLK2", "", "", "", "SPI0_CS0", "UART1_CTS"},
|
||||||
|
{"CLK1", "I2C0_SDA", "I2C1_SDA", "", "SPI0_CS1", ""},
|
||||||
|
{"PWM0_1", "I2C0_SCL", "I2C1_SCL", "", "SPI0_CS2", ""}, // 45
|
||||||
|
{""},
|
||||||
|
}
|
||||||
|
|
||||||
// function specifies the active functionality of a pin. The alternative
|
// function specifies the active functionality of a pin. The alternative
|
||||||
// function is GPIO pin dependent.
|
// function is GPIO pin dependent.
|
||||||
type function uint8
|
type function uint8
|
||||||
@@ -1305,6 +1367,7 @@ func (d *driverGPIO) Init() (bool, error) {
|
|||||||
// BCM2711 (and perhaps future versions?) uses a simpler way to
|
// BCM2711 (and perhaps future versions?) uses a simpler way to
|
||||||
// setup internal pull resistors.
|
// setup internal pull resistors.
|
||||||
d.useLegacyPull = false
|
d.useLegacyPull = false
|
||||||
|
mapping = mapping2711
|
||||||
}
|
}
|
||||||
// Page 6.
|
// Page 6.
|
||||||
// Virtual addresses in kernel mode will range between 0xC0000000 and
|
// Virtual addresses in kernel mode will range between 0xC0000000 and
|
||||||
|
|||||||
+5
-1
@@ -5,6 +5,7 @@
|
|||||||
package bcm283x
|
package bcm283x
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"periph.io/x/host/v3/cpu"
|
"periph.io/x/host/v3/cpu"
|
||||||
@@ -17,7 +18,10 @@ func ReadTime() time.Duration {
|
|||||||
if drvDMA.timerMemory == nil {
|
if drvDMA.timerMemory == nil {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return (time.Duration(drvDMA.timerMemory.high)<<32 | time.Duration(drvDMA.timerMemory.low)) * time.Microsecond
|
// Use atomic package to safely access memory
|
||||||
|
high := atomic.LoadUint32(&drvDMA.timerMemory.high)
|
||||||
|
low := atomic.LoadUint32(&drvDMA.timerMemory.low)
|
||||||
|
return (time.Duration(high)<<32 | time.Duration(low)) * time.Microsecond
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nanospin spins the CPU without calling into the kernel code if possible.
|
// Nanospin spins the CPU without calling into the kernel code if possible.
|
||||||
|
|||||||
+2
@@ -6,6 +6,7 @@ package distro
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,6 +31,7 @@ func DTModel() string {
|
|||||||
func DTCompatible() []string {
|
func DTCompatible() []string {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
|
fmt.Println("\n\n\n\n\tdidier: Deep in the dependencies...\n\n\n\n\n")
|
||||||
|
|
||||||
if dtCompatible == nil {
|
if dtCompatible == nil {
|
||||||
dtCompatible = []string{}
|
dtCompatible = []string{}
|
||||||
|
|||||||
Reference in new issue
Block a user