Last active
October 9, 2020 15:44
-
-
Save elfmimi/5f931783cbbac2844c5aae29cb9995fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# NAME=gd32vf103-blinker | |
# PREFIX=~/.platformio/packages/toolchain-gd32v/bin/riscv-nuclei-elf- | |
# LDSCRIPT=$(cygpath -ma ~/.platformio/packages/framework-gd32vf103-sdk/RISCV/env_Eclipse/GD32VF103xB.lds) | |
# ${PREFIX}as -march=rv32ic -o ${NAME}.o ${NAME}.S | |
# ${PREFIX}ld -T ${LDSCRIPT} -o ${NAME}.elf ${NAME}.o | |
# ${PREFIX}objcopy -O binary ${NAME}.elf ${NAME}.bin | |
.text | |
.global _start | |
_start: | |
lui a0, %hi(_start0800) | |
jr %lo(_start0800)(a0) | |
_start0800: | |
# enable and reset GPIOA and GPIOC | |
li a0, 0x40021000 | |
li a1, 0x14 # 0x04 == APB2EN.PAEN == APB2RST.PARST | |
# 0x10 == APB2EN.PCEN == APB2RST.PCRST | |
sw a1, 0x18(a0) # APB2EN | |
sw a1, 0x0C(a0) # APB2RST | |
sw zero, 0x0C(a0) # APB2RST | |
# PA12 to output (default is 0, that is low) | |
# This is to counter-act external pull-up on PA12(USBDP) . | |
li a0,0x40010800 | |
lw a1,0x04(a0) | |
li a2, 0xFFF0FFFF | |
and a1, a1, a2 | |
li a2, 0x00030000 | |
or a1, a1, a2 | |
sw a1, 0x04(a0) | |
# PC13 to output | |
li a0,0x40011000 | |
lw a1,0x04(a0) | |
li a2, 0xFF0FFFFF | |
and a1, a1, a2 | |
li a2, 0x00300000 | |
or a1, a1, a2 | |
sw a1, 0x04(a0) | |
li a1, 0x2000 | |
loop: | |
sw a1, 0x14(a0) | |
li a2,0x200000 | |
loop1: | |
addi a2, a2, -1 | |
bnez a2, loop1 | |
sw a1, 0x10(a0) | |
li a2,0x100000 | |
loop2: | |
addi a2, a2, -1 | |
bnez a2, loop2 | |
j loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment