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")
|
||||
)
|
||||
|
||||
// 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
|
||||
// sets the pin as an output and PinInputPullup sets the pin as an input with a
|
||||
// pull-up.
|
||||
|
|
|
@ -16,6 +16,8 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
const deviceName = sam.Device
|
||||
|
||||
const (
|
||||
PinAnalog PinMode = 1
|
||||
PinSERCOM PinMode = 2
|
||||
|
|
|
@ -16,6 +16,8 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
const deviceName = sam.Device
|
||||
|
||||
func CPUFrequency() uint32 {
|
||||
return 120000000
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
const deviceName = avr.DEVICE
|
||||
|
||||
const (
|
||||
PinInput PinMode = iota
|
||||
PinInputPullup
|
||||
|
|
|
@ -9,6 +9,8 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
const deviceName = esp.Device
|
||||
|
||||
const peripheralClock = 80000000 // 80MHz
|
||||
|
||||
// CPUFrequency returns the current CPU frequency of the chip.
|
||||
|
|
|
@ -8,6 +8,8 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
const deviceName = esp.Device
|
||||
|
||||
// CPUFrequency returns the current CPU frequency of the chip.
|
||||
// Currently it is a fixed frequency but it may allow changing in the future.
|
||||
func CPUFrequency() uint32 {
|
||||
|
|
|
@ -7,6 +7,8 @@ import (
|
|||
"runtime/volatile"
|
||||
)
|
||||
|
||||
const deviceName = esp.Device
|
||||
|
||||
func CPUFrequency() uint32 {
|
||||
return 80000000 // 80MHz
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
const deviceName = sifive.Device
|
||||
|
||||
func CPUFrequency() uint32 {
|
||||
return 320000000 // 320MHz
|
||||
}
|
||||
|
|
|
@ -9,6 +9,10 @@ import (
|
|||
"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
|
||||
// runtime/interrupt.New.
|
||||
const (
|
||||
|
|
|
@ -4,6 +4,8 @@ package machine
|
|||
|
||||
// Dummy machine package that calls out to external functions.
|
||||
|
||||
const deviceName = "generic"
|
||||
|
||||
var (
|
||||
UART0 = &UART{0}
|
||||
USB = &UART{100}
|
||||
|
|
|
@ -10,6 +10,8 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
const deviceName = kendryte.Device
|
||||
|
||||
func CPUFrequency() uint32 {
|
||||
return 390000000
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import (
|
|||
|
||||
// Peripheral abstraction layer for the MIMXRT1062
|
||||
|
||||
const deviceName = nxp.Device
|
||||
|
||||
func CPUFrequency() uint32 {
|
||||
return 600000000
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ var (
|
|||
ErrTxInvalidSliceSize = errors.New("SPI write and read slices must be same size")
|
||||
)
|
||||
|
||||
const deviceName = nrf.Device
|
||||
|
||||
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)
|
||||
PinInputPullup PinMode = PinInput | (nrf.GPIO_PIN_CNF_PULL_Pullup << nrf.GPIO_PIN_CNF_PULL_Pos)
|
||||
|
|
|
@ -37,6 +37,8 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
const deviceName = nxp.Device
|
||||
|
||||
const (
|
||||
PinInput PinMode = iota
|
||||
PinInputPullUp
|
||||
|
|
|
@ -8,6 +8,8 @@ import (
|
|||
"runtime/interrupt"
|
||||
)
|
||||
|
||||
const deviceName = rp.Device
|
||||
|
||||
const (
|
||||
// GPIO pins
|
||||
GPIO0 Pin = 0
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
package machine
|
||||
|
||||
import "device/stm32"
|
||||
|
||||
const deviceName = stm32.Device
|
||||
|
||||
// Peripheral abstraction layer for the stm32.
|
||||
|
||||
const (
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче