68 lines
1.0 KiB
C
68 lines
1.0 KiB
C
#include "stdint.h"
|
|
#include "stdio.h"
|
|
#include "stdarg.h"
|
|
#include "head.h"
|
|
#include "rtthread.h"
|
|
|
|
#define PRINT_BASE_ADDR *(uint8_t *)0x40000000
|
|
|
|
int my_putc(int c) {
|
|
PRINT_BASE_ADDR = c;
|
|
return c;
|
|
}
|
|
|
|
|
|
int my_puts(const char *s,int len) {
|
|
for (int i = 0;i < len;i++) {
|
|
my_putc(s[i]);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static char g_print_buff[1024];
|
|
int my_printf(const char* fmt, ...) {
|
|
int len = 0;
|
|
va_list args;
|
|
va_start(args, fmt);
|
|
len = vsnprintf(g_print_buff, 1024, fmt, args);
|
|
va_end(args);
|
|
my_puts(g_print_buff, len);
|
|
return len;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char g_string[] = "string from ram";
|
|
|
|
|
|
|
|
|
|
void task1(void* par) {
|
|
(void)par;
|
|
while (1) {
|
|
my_printf("task1: %s\n", g_string);
|
|
rt_thread_delay(500);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
{
|
|
my_printf("Hello World! %s\n", "Andy");
|
|
// cpu_test();
|
|
|
|
rt_thread_t t = rt_thread_create("task1", task1, 0, 1024, 10, 10);
|
|
(void)t;
|
|
rt_thread_startup(t);
|
|
my_printf("enter while 1\n");
|
|
while (1) {
|
|
my_printf("main: %s\n", g_string);
|
|
rt_thread_delay(1000);
|
|
}
|
|
return 0;
|
|
} |