-
Notifications
You must be signed in to change notification settings - Fork 919
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: deadprogram <ron@hybridgroup.com>
- Loading branch information
1 parent
74aadcd
commit 78db459
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
//go:build renasas | ||
|
||
package runtime | ||
|
||
import ( | ||
"device/arm" | ||
"machine" | ||
) | ||
|
||
// machineTicks is provided by package machine. | ||
func machineTicks() uint64 { | ||
return 0 | ||
} | ||
|
||
// machineLightSleep is provided by package machine. | ||
func machineLightSleep(uint64) { | ||
return | ||
} | ||
|
||
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() { | ||
return | ||
} | ||
|
||
func init() { | ||
machineInit() | ||
} | ||
|
||
//export Reset_Handler | ||
func main() { | ||
preinit() | ||
run() | ||
exit(0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"inherits": ["cortex-m4"], | ||
"build-tags": ["ra4m1", "renesas"], | ||
"linkerscript": "targets/ra4m1.ld", | ||
"extra-files": [ | ||
"src/device/renesas/r7fa4m2ad.s" | ||
], | ||
"openocd-transport": "swd", | ||
"openocd-target": "atsame5x" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
MEMORY | ||
{ | ||
FLASH_TEXT (rw) : ORIGIN = 0x00000000+0x4000, LENGTH = 0x00080000-0x4000 /* First 16KB used by bootloader */ | ||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 0x00030000 | ||
} | ||
|
||
_stack_size = 4K; | ||
|
||
INCLUDE "targets/arm.ld" |