initial commit
This commit is contained in:
11
sdk/software/examples/hello_world/Makefile
Normal file
11
sdk/software/examples/hello_world/Makefile
Normal file
@@ -0,0 +1,11 @@
|
||||
TARGET = hello_world
|
||||
|
||||
CFLAGS += -O3 -g
|
||||
|
||||
C_SRCS := $(wildcard ./*.c )
|
||||
|
||||
OBJDIR = obj
|
||||
COMMON_DIR = ../../bsp
|
||||
GCC_DIR=../../../toolchains/loongson-gnu-toolchain-8.3-x86_64-loongarch32r-linux-gnusf-v2.0
|
||||
PICOLIBC_DIR=../../../toolchains/picolibc
|
||||
include ../../bsp/common.mk
|
||||
36
sdk/software/examples/hello_world/main.c
Normal file
36
sdk/software/examples/hello_world/main.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
//BSP板级支持包所需全局变量
|
||||
unsigned long UART_BASE = 0xbf000000; //UART16550的虚地址
|
||||
unsigned long CONFREG_TIMER_BASE = 0xbf20f100; //CONFREG计数器的虚地址
|
||||
unsigned long CONFREG_CLOCKS_PER_SEC = 50000000L; //CONFREG时钟频率
|
||||
unsigned long CORE_CLOCKS_PER_SEC = 33000000L; //处理器核时钟频率
|
||||
|
||||
#define CPSIZE 12
|
||||
char src[CPSIZE] = "this is src";
|
||||
char dst[CPSIZE] = "this is dst";
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
int a = 100;
|
||||
float b = 3.2564;
|
||||
double c = 5478.47563;
|
||||
char *str;
|
||||
|
||||
printf("Hello Loongarch32r!\n");
|
||||
printf("a = %d\n", a);
|
||||
printf("b = %f\n", b);
|
||||
printf("c = %lf\n", c);
|
||||
|
||||
str = (char *)malloc(6);
|
||||
strcpy(str, "ABCDE");
|
||||
printf("String = %s, Address = 0x%x\n", str, str);
|
||||
|
||||
memcpy(dst, src, CPSIZE);
|
||||
printf("%s\n", dst);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user