cryptnox-sdk-esp32 1.0.0
ESP32 SDK for Cryptnox Hardware Wallet
Loading...
Searching...
No Matches
ESP32Logger.cpp File Reference

Implementation of ESP32Logger — ESP32 UART0 logging backend. More...

#include "ESP32Logger.h"
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include "driver/uart.h"
Include dependency graph for ESP32Logger.cpp:

Go to the source code of this file.

Functions

static uint32_t clamp_base (int base)
static void uart_write_str (const char *str)
static void write_uint_to_uart (uint32_t value, uint32_t base)

Variables

static const uart_port_t UART_LOG_PORT = UART_NUM_0
static const uint8_t UART_RX_FLOW_THRESH_NONE = static_cast<uint8_t>(0U)
static const uint32_t NUM_BUF_SIZE = 33U
static const uint32_t NUM_BASE_MIN = 2U
static const uint32_t NUM_BASE_MAX = 16U
static const size_t ELEMENT_SIZE = 1U
static const char LOGGER_NEWLINE [] = "\r\n"
static const char HEX_CHARS [] = "0123456789ABCDEF"

Detailed Description

Implementation of ESP32Logger — ESP32 UART0 logging backend.

Routes all CW_Logger output through the ESP-IDF UART driver on UART0. Full API documentation lives on the declarations in ESP32Logger.h.

Warning
Do not ship this logger in production firmware; it exposes APDU traces and PIN values on the serial console (LOW-03).

Definition in file ESP32Logger.cpp.

Function Documentation

◆ clamp_base()

uint32_t clamp_base ( int base)
static

Clamp base to the valid [NUM_BASE_MIN, NUM_BASE_MAX] range; returns DEC on out-of-range input.

Definition at line 50 of file ESP32Logger.cpp.

References NUM_BASE_MAX, and NUM_BASE_MIN.

Referenced by ESP32Logger::print(), ESP32Logger::print(), ESP32Logger::print(), and ESP32Logger::print().

◆ uart_write_str()

void uart_write_str ( const char * str)
static

Transmit a NUL-terminated string to stdout via fwrite.

Definition at line 62 of file ESP32Logger.cpp.

References ELEMENT_SIZE.

Referenced by ESP32Logger::print(), ESP32Logger::print(), and ESP32Logger::println().

◆ write_uint_to_uart()

void write_uint_to_uart ( uint32_t value,
uint32_t base )
static

Convert value to ASCII digits in the given base and write the result to stdout.

Definition at line 69 of file ESP32Logger.cpp.

References HEX_CHARS, and NUM_BUF_SIZE.

Referenced by ESP32Logger::print(), ESP32Logger::print(), ESP32Logger::print(), and ESP32Logger::print().

Variable Documentation

◆ ELEMENT_SIZE

const size_t ELEMENT_SIZE = 1U
static

Definition at line 40 of file ESP32Logger.cpp.

Referenced by uart_write_str().

◆ HEX_CHARS

const char HEX_CHARS[] = "0123456789ABCDEF"
static

Definition at line 43 of file ESP32Logger.cpp.

Referenced by write_uint_to_uart().

◆ LOGGER_NEWLINE

const char LOGGER_NEWLINE[] = "\r\n"
static

Definition at line 42 of file ESP32Logger.cpp.

Referenced by ESP32Logger::println().

◆ NUM_BASE_MAX

const uint32_t NUM_BASE_MAX = 16U
static

Definition at line 39 of file ESP32Logger.cpp.

Referenced by clamp_base().

◆ NUM_BASE_MIN

const uint32_t NUM_BASE_MIN = 2U
static

Definition at line 38 of file ESP32Logger.cpp.

Referenced by clamp_base().

◆ NUM_BUF_SIZE

const uint32_t NUM_BUF_SIZE = 33U
static

Definition at line 37 of file ESP32Logger.cpp.

Referenced by write_uint_to_uart().

◆ UART_LOG_PORT

const uart_port_t UART_LOG_PORT = UART_NUM_0
static

Definition at line 33 of file ESP32Logger.cpp.

Referenced by ESP32Logger::begin().

◆ UART_RX_FLOW_THRESH_NONE

const uint8_t UART_RX_FLOW_THRESH_NONE = static_cast<uint8_t>(0U)
static

Definition at line 34 of file ESP32Logger.cpp.

Referenced by ESP32Logger::begin().