machine: add Device constant
This field contains the microcontroller name that we're compiling for, or "generic" if we're not running on a microcontroller.
Этот коммит содержится в:
родитель
6b0f2cd697
коммит
3d73ee77d3
16 изменённых файлов: 41 добавлений и 0 удалений
|
@ -10,6 +10,13 @@ var (
|
||||||
ErrNoPinChangeChannel = errors.New("machine: no channel available for pin interrupt")
|
ErrNoPinChangeChannel = errors.New("machine: no channel available for pin interrupt")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Device is the running program's chip name, such as "ATSAMD51J19A" or
|
||||||
|
// "nrf52840". It is not the same as the CPU name.
|
||||||
|
//
|
||||||
|
// The constant is some hardcoded default value if the program does not target a
|
||||||
|
// particular chip but instead runs in WebAssembly for example.
|
||||||
|
const Device = deviceName
|
||||||
|
|
||||||
// PinMode sets the direction and pull mode of the pin. For example, PinOutput
|
// PinMode sets the direction and pull mode of the pin. For example, PinOutput
|
||||||
// sets the pin as an output and PinInputPullup sets the pin as an input with a
|
// sets the pin as an output and PinInputPullup sets the pin as an input with a
|
||||||
// pull-up.
|
// pull-up.
|
||||||
|
|
|
@ -16,6 +16,8 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deviceName = sam.Device
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PinAnalog PinMode = 1
|
PinAnalog PinMode = 1
|
||||||
PinSERCOM PinMode = 2
|
PinSERCOM PinMode = 2
|
||||||
|
|
|
@ -16,6 +16,8 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deviceName = sam.Device
|
||||||
|
|
||||||
func CPUFrequency() uint32 {
|
func CPUFrequency() uint32 {
|
||||||
return 120000000
|
return 120000000
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deviceName = avr.DEVICE
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PinInput PinMode = iota
|
PinInput PinMode = iota
|
||||||
PinInputPullup
|
PinInputPullup
|
||||||
|
|
|
@ -9,6 +9,8 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deviceName = esp.Device
|
||||||
|
|
||||||
const peripheralClock = 80000000 // 80MHz
|
const peripheralClock = 80000000 // 80MHz
|
||||||
|
|
||||||
// CPUFrequency returns the current CPU frequency of the chip.
|
// CPUFrequency returns the current CPU frequency of the chip.
|
||||||
|
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deviceName = esp.Device
|
||||||
|
|
||||||
// CPUFrequency returns the current CPU frequency of the chip.
|
// CPUFrequency returns the current CPU frequency of the chip.
|
||||||
// Currently it is a fixed frequency but it may allow changing in the future.
|
// Currently it is a fixed frequency but it may allow changing in the future.
|
||||||
func CPUFrequency() uint32 {
|
func CPUFrequency() uint32 {
|
||||||
|
|
|
@ -7,6 +7,8 @@ import (
|
||||||
"runtime/volatile"
|
"runtime/volatile"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deviceName = esp.Device
|
||||||
|
|
||||||
func CPUFrequency() uint32 {
|
func CPUFrequency() uint32 {
|
||||||
return 80000000 // 80MHz
|
return 80000000 // 80MHz
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deviceName = sifive.Device
|
||||||
|
|
||||||
func CPUFrequency() uint32 {
|
func CPUFrequency() uint32 {
|
||||||
return 320000000 // 320MHz
|
return 320000000 // 320MHz
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,10 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Not sure what name to pick here. Not using ARM7TDMI because that's the CPU
|
||||||
|
// name, not the device name.
|
||||||
|
const deviceName = "GBA"
|
||||||
|
|
||||||
// Interrupt numbers as used on the GameBoy Advance. Register them with
|
// Interrupt numbers as used on the GameBoy Advance. Register them with
|
||||||
// runtime/interrupt.New.
|
// runtime/interrupt.New.
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -4,6 +4,8 @@ package machine
|
||||||
|
|
||||||
// Dummy machine package that calls out to external functions.
|
// Dummy machine package that calls out to external functions.
|
||||||
|
|
||||||
|
const deviceName = "generic"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
UART0 = &UART{0}
|
UART0 = &UART{0}
|
||||||
USB = &UART{100}
|
USB = &UART{100}
|
||||||
|
|
|
@ -10,6 +10,8 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deviceName = kendryte.Device
|
||||||
|
|
||||||
func CPUFrequency() uint32 {
|
func CPUFrequency() uint32 {
|
||||||
return 390000000
|
return 390000000
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ import (
|
||||||
|
|
||||||
// Peripheral abstraction layer for the MIMXRT1062
|
// Peripheral abstraction layer for the MIMXRT1062
|
||||||
|
|
||||||
|
const deviceName = nxp.Device
|
||||||
|
|
||||||
func CPUFrequency() uint32 {
|
func CPUFrequency() uint32 {
|
||||||
return 600000000
|
return 600000000
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ var (
|
||||||
ErrTxInvalidSliceSize = errors.New("SPI write and read slices must be same size")
|
ErrTxInvalidSliceSize = errors.New("SPI write and read slices must be same size")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deviceName = nrf.Device
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PinInput PinMode = (nrf.GPIO_PIN_CNF_DIR_Input << nrf.GPIO_PIN_CNF_DIR_Pos) | (nrf.GPIO_PIN_CNF_INPUT_Connect << nrf.GPIO_PIN_CNF_INPUT_Pos)
|
PinInput PinMode = (nrf.GPIO_PIN_CNF_DIR_Input << nrf.GPIO_PIN_CNF_DIR_Pos) | (nrf.GPIO_PIN_CNF_INPUT_Connect << nrf.GPIO_PIN_CNF_INPUT_Pos)
|
||||||
PinInputPullup PinMode = PinInput | (nrf.GPIO_PIN_CNF_PULL_Pullup << nrf.GPIO_PIN_CNF_PULL_Pos)
|
PinInputPullup PinMode = PinInput | (nrf.GPIO_PIN_CNF_PULL_Pullup << nrf.GPIO_PIN_CNF_PULL_Pos)
|
||||||
|
|
|
@ -37,6 +37,8 @@ import (
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deviceName = nxp.Device
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PinInput PinMode = iota
|
PinInput PinMode = iota
|
||||||
PinInputPullUp
|
PinInputPullUp
|
||||||
|
|
|
@ -8,6 +8,8 @@ import (
|
||||||
"runtime/interrupt"
|
"runtime/interrupt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const deviceName = rp.Device
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// GPIO pins
|
// GPIO pins
|
||||||
GPIO0 Pin = 0
|
GPIO0 Pin = 0
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
package machine
|
package machine
|
||||||
|
|
||||||
|
import "device/stm32"
|
||||||
|
|
||||||
|
const deviceName = stm32.Device
|
||||||
|
|
||||||
// Peripheral abstraction layer for the stm32.
|
// Peripheral abstraction layer for the stm32.
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче