sdk:examples: add led_toggle

Signed-off-by: liangkangnan <liangkangnan@163.com>
verilator
liangkangnan 2022-08-20 15:00:17 +08:00
parent ed2644b66e
commit 22407f4b1f
4 changed files with 49 additions and 0 deletions

8
sdk/examples/led_toggle/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Object files
*.o
*.ko
*.obj
*.bin
*.dump
*.mem
gpio

View File

@ -0,0 +1,20 @@
RISCV_ARCH := rv32im
RISCV_ABI := ilp32
RISCV_MCMODEL := medlow
TARGET = led_toggle
#CFLAGS += -DSIMULATION
#CFLAGS += -O2
#ASM_SRCS +=
#LDFLAGS +=
#INCLUDES += -I.
C_SRCS := \
main.c \
BSP_DIR = ../../bsp
include ../../bsp/bsp.mk

View File

@ -0,0 +1 @@
每500ms翻转GPIO电平。

View File

@ -0,0 +1,20 @@
#include <stdint.h>
#include "../../bsp/include/gpio.h"
#include "../../bsp/include/utils.h"
#include "../../bsp/include/pinmux.h"
int main()
{
// IO7用作GPIO7
pinmux_set_io7_func(IO7_GPIO7);
// gpio7输出模式
gpio_set_mode(GPIO7, GPIO_MODE_OUTPUT);
while (1) {
gpio_set_output_data(GPIO7, 1); // GPIO7输出高
busy_wait(500000);
gpio_set_output_data(GPIO7, 0); // GPIO7输出低
busy_wait(500000);
}
}