Created
May 22, 2020 22:21
-
-
Save sago35/95c2213093ac3565865be310e5c432a2 to your computer and use it in GitHub Desktop.
A workaround for crashes when trying to use SAMD5x FPU on windows version of tinygo
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
// +build atsamd51 | |
// Put this file in the main package directory | |
// https://github.com/tinygo-org/tinygo/issues/944#issuecomment-597065613 | |
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0439b/BEHBJHIG.html | |
package main | |
import ( | |
"runtime/volatile" | |
"unsafe" | |
) | |
func init() { | |
enableCortexM4FPU() | |
} | |
func enableCortexM4FPU() { | |
cpacraddr := (*uint32)(unsafe.Pointer(uintptr(0xE000ED88))) | |
tmp := *cpacraddr | |
tmp |= (0xF << 20) | |
volatile.StoreUint32(cpacraddr, tmp) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment