From 6380ad5ed549e565b8e5e0794240d273ab466209 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Fri, 21 Feb 2020 14:19:46 +0100 Subject: [PATCH] semihosting: add example --- examples/semihosting/semihosting.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/semihosting/semihosting.go diff --git a/examples/semihosting/semihosting.go b/examples/semihosting/semihosting.go new file mode 100644 index 0000000..d3a6611 --- /dev/null +++ b/examples/semihosting/semihosting.go @@ -0,0 +1,23 @@ +package main + +// A small example that demonstrates how SemiHosting can be used. +// You could use it with a board that supports GDB, such as the BBC micro:bit: +// 1. Compile and debug it: +// tinygo gdb -target=microbit -ocd-output tinygo.org/x/drivers/examples/semihosting +// 2. Enable semihosting in the GDB shell: +// monitor arm semihosting enable +// 3. Start the program: +// continue + +import ( + "time" + + "tinygo.org/x/drivers/semihosting" +) + +func main() { + for { + semihosting.Stdout.Write([]byte("hello world!\n")) + time.Sleep(time.Second) + } +}