aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/runtime/runtime_rp2350.go
diff options
context:
space:
mode:
authorPatricio Whittingslow <[email protected]>2024-12-18 15:36:30 -0300
committerGitHub <[email protected]>2024-12-18 19:36:30 +0100
commit37f35f8c910b05e2040433448546f41b34535b32 (patch)
tree32bdf01b1c2b8d75e9a7f1a24e5c62be9d432ce0 /src/runtime/runtime_rp2350.go
parent0d13e61d0cbe7aa82678a6dec7dda0115db82397 (diff)
downloadtinygo-37f35f8c910b05e2040433448546f41b34535b32.tar.gz
tinygo-37f35f8c910b05e2040433448546f41b34535b32.zip
Add RP2350 support (#4459)
machine/rp2350: add support * add linker scripts for rp2350 * add bootloader * begin melding rp2040 and rp2350 APIs * add UART * add rp2350 boot patching * Fix RP2350 memory layout (#4626) * Remove rp2040-style second stage bootloader. * Add 'minimum viable' IMAGE_DEF embedded block * Create a pico2 specific target * Implement rp2350 init, clock, and uart support * Merge rp2 reset code back together * Separate chip-specific clock definitions * Clear pad isolation bit on rp2350 * Init UART in rp2350 runtime * Correct usb/serial initialization order * Implement jump-to-bootloader * test: add pico2 to smoketests --------- Signed-off-by: deadprogram <[email protected]> Co-authored-by: Matthew Mets <[email protected]> Co-authored-by: Matt Mets <[email protected]> Co-authored-by: deadprogram <[email protected]>
Diffstat (limited to 'src/runtime/runtime_rp2350.go')
-rw-r--r--src/runtime/runtime_rp2350.go88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/runtime/runtime_rp2350.go b/src/runtime/runtime_rp2350.go
new file mode 100644
index 000000000..f70ec413c
--- /dev/null
+++ b/src/runtime/runtime_rp2350.go
@@ -0,0 +1,88 @@
+//go:build rp2350
+
+package runtime
+
+import (
+ "device/arm"
+ "machine"
+ "machine/usb/cdc"
+)
+
+// machineTicks is provided by package machine.
+func machineTicks() uint64
+
+// machineLightSleep is provided by package machine.
+func machineLightSleep(uint64)
+
+type timeUnit int64
+
+// ticks returns the number of ticks (microseconds) elapsed since power up.
+func ticks() timeUnit {
+ t := machineTicks()
+ return timeUnit(t)
+}
+
+func ticksToNanoseconds(ticks timeUnit) int64 {
+ return int64(ticks) * 1000
+}
+
+func nanosecondsToTicks(ns int64) timeUnit {
+ return timeUnit(ns / 1000)
+}
+
+func sleepTicks(d timeUnit) {
+ if d <= 0 {
+ return
+ }
+
+ if hasScheduler {
+ // With scheduler, sleepTicks may return early if an interrupt or
+ // event fires - so scheduler can schedule any go routines now
+ // eligible to run
+ machineLightSleep(uint64(d))
+ return
+ }
+
+ // Busy loop
+ sleepUntil := ticks() + d
+ for ticks() < sleepUntil {
+ }
+}
+
+func waitForEvents() {
+ arm.Asm("wfe")
+}
+
+func putchar(c byte) {
+ machine.Serial.WriteByte(c)
+}
+
+func getchar() byte {
+ for machine.Serial.Buffered() == 0 {
+ Gosched()
+ }
+ v, _ := machine.Serial.ReadByte()
+ return v
+}
+
+func buffered() int {
+ return machine.Serial.Buffered()
+}
+
+// machineInit is provided by package machine.
+func machineInit()
+
+func init() {
+ machineInit()
+
+ cdc.EnableUSBCDC()
+ machine.USBDev.Configure(machine.UARTConfig{})
+ machine.InitSerial()
+}
+
+//export Reset_Handler
+func main() {
+ preinit()
+ run()
+ exit(0)
+}