aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/runtime
diff options
context:
space:
mode:
authorBCG <[email protected]>2020-01-06 05:53:43 -0500
committerRon Evans <[email protected]>2020-01-06 11:53:43 +0100
commitecff6f8e0c8ab70874debc39783552eb3a5ff6bf (patch)
treed937888cd73f80f07bbe8a6a85008835fd4b875d /src/runtime
parent7363bdc2985f2c062f72a570b48da00ec5a850cd (diff)
downloadtinygo-ecff6f8e0c8ab70874debc39783552eb3a5ff6bf.tar.gz
tinygo-ecff6f8e0c8ab70874debc39783552eb3a5ff6bf.zip
Adafruit PyPortal Support (#800)
* machine/PyPortal: implementation, also includes refinements for other members of samd51x familty.
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/runtime_atsamd51j20.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/runtime/runtime_atsamd51j20.go b/src/runtime/runtime_atsamd51j20.go
new file mode 100644
index 000000000..84655ef59
--- /dev/null
+++ b/src/runtime/runtime_atsamd51j20.go
@@ -0,0 +1,43 @@
+// +build sam,atsamd51,atsamd51j20
+
+package runtime
+
+import (
+ "device/sam"
+)
+
+func initSERCOMClocks() {
+ // Turn on clock to SERCOM0 for UART0
+ sam.MCLK.APBAMASK.SetBits(sam.MCLK_APBAMASK_SERCOM0_)
+ sam.GCLK.PCHCTRL[7].Set((sam.GCLK_PCHCTRL_GEN_GCLK1 << sam.GCLK_PCHCTRL_GEN_Pos) |
+ sam.GCLK_PCHCTRL_CHEN)
+
+ // sets the "slow" clock shared by all SERCOM
+ sam.GCLK.PCHCTRL[3].Set((sam.GCLK_PCHCTRL_GEN_GCLK1 << sam.GCLK_PCHCTRL_GEN_Pos) |
+ sam.GCLK_PCHCTRL_CHEN)
+
+ // Turn on clock to SERCOM1
+ sam.MCLK.APBAMASK.SetBits(sam.MCLK_APBAMASK_SERCOM1_)
+ sam.GCLK.PCHCTRL[8].Set((sam.GCLK_PCHCTRL_GEN_GCLK1 << sam.GCLK_PCHCTRL_GEN_Pos) |
+ sam.GCLK_PCHCTRL_CHEN)
+
+ // Turn on clock to SERCOM2
+ sam.MCLK.APBBMASK.SetBits(sam.MCLK_APBBMASK_SERCOM2_)
+ sam.GCLK.PCHCTRL[23].Set((sam.GCLK_PCHCTRL_GEN_GCLK1 << sam.GCLK_PCHCTRL_GEN_Pos) |
+ sam.GCLK_PCHCTRL_CHEN)
+
+ // Turn on clock to SERCOM3
+ sam.MCLK.APBBMASK.SetBits(sam.MCLK_APBBMASK_SERCOM3_)
+ sam.GCLK.PCHCTRL[24].Set((sam.GCLK_PCHCTRL_GEN_GCLK1 << sam.GCLK_PCHCTRL_GEN_Pos) |
+ sam.GCLK_PCHCTRL_CHEN)
+
+ // Turn on clock to SERCOM4
+ sam.MCLK.APBDMASK.SetBits(sam.MCLK_APBDMASK_SERCOM4_)
+ sam.GCLK.PCHCTRL[34].Set((sam.GCLK_PCHCTRL_GEN_GCLK1 << sam.GCLK_PCHCTRL_GEN_Pos) |
+ sam.GCLK_PCHCTRL_CHEN)
+
+ // Turn on clock to SERCOM5
+ sam.MCLK.APBDMASK.SetBits(sam.MCLK_APBDMASK_SERCOM5_)
+ sam.GCLK.PCHCTRL[35].Set((sam.GCLK_PCHCTRL_GEN_GCLK1 << sam.GCLK_PCHCTRL_GEN_Pos) |
+ sam.GCLK_PCHCTRL_CHEN)
+}