CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
Console.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <cstdarg>
5
6namespace cdc::serial {
7
14class Console {
15public:
19 static void init();
20
24 static void printf(const char* format, ...) __attribute__((format(printf, 1, 2)));
25
29 static void vprintf(const char* format, va_list args);
30
34 static void print(const char* str);
35
39 static void putchar(char c);
40
45 static int getchar();
46
50 static void flush();
51
55 static bool available();
56
60 static void showPrompt();
61
62private:
63 Console() = delete; // Static-only class
64};
65
66// Convenience macros
67#define CONSOLE_PRINTF(...) cdc::serial::Console::printf(__VA_ARGS__)
68#define CONSOLE_PRINT(s) cdc::serial::Console::print(s)
69
70} // namespace cdc::serial
struct __attribute__((packed))
Definition ccid.h:65
static void print(const char *str)
Prints raw string to console.
Definition Console.cpp:56
static void showPrompt()
Prints standard shell prompt.
Definition Console.cpp:98
static void static void vprintf(const char *format, va_list args)
Prints formatted text with explicit varargs list.
Definition Console.cpp:43
static void flush()
Flushes pending console output.
Definition Console.cpp:82
static void printf(const char *format,...) __attribute__((format(printf
Prints formatted text to console.
Definition Console.cpp:30
static bool available()
Checks whether console input is available.
Definition Console.cpp:90
static void putchar(char c)
Writes a single character to console.
Definition Console.cpp:66
static int getchar()
Reads one character from console input.
Definition Console.cpp:74
static void init()
Initializes console wrapper state.
Definition Console.cpp:19