//go:build fe310 && !qemu package runtime import ( "device/riscv" ) // ticksToNanoseconds converts RTC ticks (at 32768Hz) to nanoseconds. func ticksToNanoseconds(ticks timeUnit) int64 { // The following calculation is actually the following, but with both sides // reduced to reduce the risk of overflow: // ticks * 1e9 / 32768 return int64(ticks) * 1953125 / 64 } // nanosecondsToTicks converts nanoseconds to RTC ticks (running at 32768Hz). func nanosecondsToTicks(ns int64) timeUnit { // The following calculation is actually the following, but with both sides // reduced to reduce the risk of overflow: // ns * 32768 / 1e9 return timeUnit(ns * 64 / 1953125) } func exit(code int) { abort() } func abort() { // lock up forever for { riscv.Asm("wfi") } }