forked from tinygo-org/tinygo
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
microbit: WIP on getting Microbit to work with TinyGo
Signed-off-by: Ron Evans <ron@hybridgroup.com>
- Loading branch information
1 parent
6e9ce73
commit 7e5afe3
Showing
6 changed files
with
75 additions
and
8 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
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,40 @@ | ||
// +build nrf,microbit | ||
|
||
package machine | ||
|
||
import "device/nrf" | ||
|
||
// LEDs on the BBC:Microbit (nRF51 dev board) | ||
const ( | ||
LED = LED1 | ||
LED1 = 1 | ||
) | ||
|
||
// Buttons on the BBC:Microbit (nRF51 dev board) | ||
const ( | ||
BUTTON = BUTTON1 | ||
BUTTON1 = 5 | ||
BUTTON2 = 11 | ||
) | ||
|
||
func SetLEDS(on bool) { | ||
nrf.GPIO.DIRSET = nrf.RegValue(0xfff0) | ||
// v = 0 // All pins to GND so no LED lid | ||
// | MASK_LED_ROW_0 | ||
// | MASK_LED_ROW_1 | ||
// | MASK_LED_ROW_2 | ||
// | MASK_LED_COL_0 | ||
// | MASK_LED_COL_1 | ||
// | MASK_LED_COL_2 | ||
// | MASK_LED_COL_3 | ||
// | MASK_LED_COL_4 | ||
// | MASK_LED_COL_5 | ||
// | MASK_LED_COL_6 | ||
// | MASK_LED_COL_7 | ||
// | MASK_LED_COL_8 | ||
if on { | ||
nrf.GPIO.OUTSET = nrf.RegValue(0xfff0) | ||
} else { | ||
nrf.GPIO.OUTCLR = nrf.RegValue(0xfff0) | ||
} | ||
} |
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
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
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,8 @@ | ||
{ | ||
"llvm-target": "armv7em-none-eabi", | ||
"build-tags": ["microbit", "nrf51", "nrf", "arm", "js", "wasm"], | ||
"linker": "arm-none-eabi-gcc", | ||
"pre-link-args": ["-nostdlib", "-nostartfiles", "-mcpu=cortex-m4", "-mthumb", "-T", "targets/nrf51.ld", "-Wl,--gc-sections", "-fno-exceptions", "-fno-unwind-tables", "-ffunction-sections", "-fdata-sections", "-Os", "-DNRF51", "-DS110", "-DNRF51_S110", "-Ilib/CMSIS/CMSIS/Include", "lib/nrfx/mdk/system_nrf51.c", "src/device/nrf/nrf51.s"], | ||
"objcopy": "arm-none-eabi-objcopy", | ||
"flash": "nrfjprog -f nrf51 --sectorerase --program {hex} --reset" | ||
} |
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, LENGTH = 256K /* .text */ | ||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K | ||
} | ||
|
||
_stack_size = 2K; | ||
|
||
INCLUDE "targets/arm.ld" |