Skip to content

Commit b97076a

Browse files
committed
renesas: WIP
Signed-off-by: deadprogram <[email protected]>
1 parent b5626e7 commit b97076a

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

src/runtime/runtime_renesas.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//go:build renasas
2+
3+
package runtime
4+
5+
import (
6+
"device/arm"
7+
"machine"
8+
)
9+
10+
// machineTicks is provided by package machine.
11+
func machineTicks() uint64 {
12+
return 0
13+
}
14+
15+
// machineLightSleep is provided by package machine.
16+
func machineLightSleep(uint64) {
17+
return
18+
}
19+
20+
type timeUnit int64
21+
22+
// ticks returns the number of ticks (microseconds) elapsed since power up.
23+
func ticks() timeUnit {
24+
t := machineTicks()
25+
return timeUnit(t)
26+
}
27+
28+
func ticksToNanoseconds(ticks timeUnit) int64 {
29+
return int64(ticks) * 1000
30+
}
31+
32+
func nanosecondsToTicks(ns int64) timeUnit {
33+
return timeUnit(ns / 1000)
34+
}
35+
36+
func sleepTicks(d timeUnit) {
37+
if d <= 0 {
38+
return
39+
}
40+
41+
if hasScheduler {
42+
// With scheduler, sleepTicks may return early if an interrupt or
43+
// event fires - so scheduler can schedule any go routines now
44+
// eligible to run
45+
machineLightSleep(uint64(d))
46+
return
47+
}
48+
49+
// Busy loop
50+
sleepUntil := ticks() + d
51+
for ticks() < sleepUntil {
52+
}
53+
}
54+
55+
func waitForEvents() {
56+
arm.Asm("wfe")
57+
}
58+
59+
func putchar(c byte) {
60+
machine.Serial.WriteByte(c)
61+
}
62+
63+
func getchar() byte {
64+
for machine.Serial.Buffered() == 0 {
65+
Gosched()
66+
}
67+
v, _ := machine.Serial.ReadByte()
68+
return v
69+
}
70+
71+
func buffered() int {
72+
return machine.Serial.Buffered()
73+
}
74+
75+
// machineInit is provided by package machine.
76+
func machineInit() {
77+
return
78+
}
79+
80+
func init() {
81+
machineInit()
82+
}
83+
84+
//export Reset_Handler
85+
func main() {
86+
preinit()
87+
run()
88+
exit(0)
89+
}

targets/ra4m1.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"inherits": ["cortex-m4"],
3+
"build-tags": ["ra4m1", "renesas"],
4+
"linkerscript": "targets/ra4m1.ld",
5+
"extra-files": [
6+
"src/device/renesas/r7fa4m2ad.s"
7+
],
8+
"openocd-transport": "swd",
9+
"openocd-target": "atsame5x"
10+
}

targets/ra4m1.ld

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
MEMORY
3+
{
4+
FLASH_TEXT (rw) : ORIGIN = 0x00000000+0x4000, LENGTH = 0x00080000-0x4000 /* First 16KB used by bootloader */
5+
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x00030000
6+
}
7+
8+
_stack_size = 4K;
9+
10+
INCLUDE "targets/arm.ld"

0 commit comments

Comments
 (0)