Add debug uart utility functions.
This commit is contained in:
parent
1990c899dd
commit
0342e03073
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2011, 2016 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -148,6 +148,25 @@ void WriteChar(char c)
|
||||||
outport8(PORT + IER, ier);
|
outport8(PORT + IER, ier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WriteString(const char* str)
|
||||||
|
{
|
||||||
|
Write(str, strlen(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t WriteCallback(void*, const char* chars, size_t size)
|
||||||
|
{
|
||||||
|
Write(chars, size);
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteF(const char* format, ...)
|
||||||
|
{
|
||||||
|
va_list list;
|
||||||
|
va_start(list, format);
|
||||||
|
vcbprintf(NULL, WriteCallback, format, list);
|
||||||
|
va_end(list);
|
||||||
|
}
|
||||||
|
|
||||||
int TryPopChar()
|
int TryPopChar()
|
||||||
{
|
{
|
||||||
// Save the IER and disable interrupts.
|
// Save the IER and disable interrupts.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2011, 2016 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -27,6 +27,9 @@ void Init();
|
||||||
void Read(uint8_t* buffer, size_t size);
|
void Read(uint8_t* buffer, size_t size);
|
||||||
void Write(const void* buffer, size_t size);
|
void Write(const void* buffer, size_t size);
|
||||||
void WriteChar(char c);
|
void WriteChar(char c);
|
||||||
|
void WriteString(const char* str);
|
||||||
|
__attribute__((format(printf, 1, 2)))
|
||||||
|
void WriteF(const char* format, ...);
|
||||||
int TryPopChar();
|
int TryPopChar();
|
||||||
|
|
||||||
} // namespace UART
|
} // namespace UART
|
||||||
|
|
Loading…
Reference in New Issue