runtime: merge common sleep() functions
Этот коммит содержится в:
родитель
7c16f6c904
коммит
7517ac86e4
4 изменённых файлов: 7 добавлений и 17 удалений
|
@ -115,3 +115,8 @@ func sliceCopy(dst, src unsafe.Pointer, dstLen, srcLen lenType, elemSize uintptr
|
||||||
memmove(dst, src, uintptr(n)*elemSize)
|
memmove(dst, src, uintptr(n)*elemSize)
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//go:linkname sleep time.Sleep
|
||||||
|
func sleep(d int64) {
|
||||||
|
sleepTicks(timeUnit(d / tickMicros))
|
||||||
|
}
|
||||||
|
|
|
@ -68,15 +68,10 @@ func putchar(c byte) {
|
||||||
*avr.UDR0 = avr.RegValue(c) // send char
|
*avr.UDR0 = avr.RegValue(c) // send char
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sleep by the given amount.
|
// Sleep this number of ticks of 16ms.
|
||||||
//
|
//
|
||||||
// TODO: not very accurate. Improve accuracy by calibrating on startup and every
|
// TODO: not very accurate. Improve accuracy by calibrating on startup and every
|
||||||
// once in a while.
|
// once in a while.
|
||||||
//go:linkname sleep time.Sleep
|
|
||||||
func sleep(d int64) {
|
|
||||||
sleepTicks(timeUnit(d / tickMicros))
|
|
||||||
}
|
|
||||||
|
|
||||||
func sleepTicks(d timeUnit) {
|
func sleepTicks(d timeUnit) {
|
||||||
currentTime += d
|
currentTime += d
|
||||||
for d != 0 {
|
for d != 0 {
|
||||||
|
|
|
@ -91,11 +91,6 @@ func putchar(c byte) {
|
||||||
nrf.UART0.EVENTS_TXDRDY = 0
|
nrf.UART0.EVENTS_TXDRDY = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname sleep time.Sleep
|
|
||||||
func sleep(d timeUnit) {
|
|
||||||
sleepTicks(d / tickMicros)
|
|
||||||
}
|
|
||||||
|
|
||||||
func sleepTicks(d timeUnit) {
|
func sleepTicks(d timeUnit) {
|
||||||
for d != 0 {
|
for d != 0 {
|
||||||
ticks() // update timestamp
|
ticks() // update timestamp
|
||||||
|
|
|
@ -34,13 +34,8 @@ func putchar(c byte) {
|
||||||
_Cfunc_putchar(int(c))
|
_Cfunc_putchar(int(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:linkname sleep time.Sleep
|
|
||||||
func sleep(d int64) {
|
|
||||||
_Cfunc_usleep(uint(d) / 1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
func sleepTicks(d timeUnit) {
|
func sleepTicks(d timeUnit) {
|
||||||
sleep(int64(d))
|
_Cfunc_usleep(uint(d) / 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return monotonic time in nanoseconds.
|
// Return monotonic time in nanoseconds.
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче