mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[ion] Use a C API for logging
Change-Id: I0aaa139b3434b62618f5e8d6ac88fe164bca4c2b
This commit is contained in:
@@ -2,9 +2,8 @@ SFLAGS += -Iion/include -DKD_CONFIG_H=1
|
||||
include ion/src/$(PLATFORM)/Makefile
|
||||
|
||||
objs += $(addprefix ion/src/shared/, \
|
||||
c.o \
|
||||
events.o \
|
||||
log_integer.o \
|
||||
log_uint32.o \
|
||||
)
|
||||
|
||||
tests += $(addprefix ion/test/,\
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef ION_C_H
|
||||
#define ION_C_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void ion_log_print_string(const char * message);
|
||||
void ion_log_print_integer(uint32_t integer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,15 +1,28 @@
|
||||
#ifndef ION_LOG_H
|
||||
#define ION_LOG_H
|
||||
|
||||
// Ion offers a C-compatible logging API
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Ion {
|
||||
namespace Log {
|
||||
#ifdef DEBUG
|
||||
|
||||
void print(const char * message);
|
||||
void print(uint32_t number);
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void ion_log_string(const char * message);
|
||||
void ion_log_uint32(uint32_t integer);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define ion_log_print_string(m) ((void)0)
|
||||
#define ion_log_print_uint32(i) ((void)0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,6 @@ objs += $(addprefix ion/src/shared/, \
|
||||
events.o \
|
||||
events_stdin.o \
|
||||
log_printf.o \
|
||||
log_integer.o \
|
||||
power.o \
|
||||
)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
// This is achieved by writing to the ITM register, which is sent through the
|
||||
// Cortex Debug bus
|
||||
|
||||
void Ion::Log::print(const char * message) {
|
||||
void ion_log_string(const char * message) {
|
||||
char character = 0;
|
||||
while ((character = *message++) != 0) {
|
||||
if (ITM.TER()->get(0)) {
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#include <ion.h>
|
||||
#include <ion/c.h>
|
||||
|
||||
void ion_log_print_integer(uint32_t i) {
|
||||
Ion::Log::print(i);
|
||||
}
|
||||
|
||||
void ion_log_print_string(const char * message) {
|
||||
Ion::Log::print(message);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <ion/log.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void Ion::Log::print(const char * message) {
|
||||
void ion_log_string(const char * message) {
|
||||
printf("%s", message);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <ion/log.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void Ion::Log::print(uint32_t i) {
|
||||
#ifdef DEBUG
|
||||
|
||||
void ion_log_uint32(uint32_t i) {
|
||||
char buffer[9];
|
||||
for (int j=0; j<8; j++) {
|
||||
uint8_t v = (i & 0xF);
|
||||
@@ -9,5 +10,7 @@ void Ion::Log::print(uint32_t i) {
|
||||
i = i >> 4;
|
||||
}
|
||||
buffer[8] = 0;
|
||||
print(buffer);
|
||||
ion_log_string(buffer);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <private/memconfig.h>
|
||||
|
||||
#if LIBA_LOG_DYNAMIC_MEMORY
|
||||
#include <ion/c.h>
|
||||
#include <ion/log.h>
|
||||
#endif
|
||||
|
||||
extern char _heap_start;
|
||||
|
||||
Reference in New Issue
Block a user