|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Minimal SEGGER RTT logging demo for EK-RA8D2. More...
#include <stddef.h>#include <stdint.h>#include <string.h>#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_time.h"Go to the source code of this file.
Data Structures | |
| struct | rtt_buf_t |
| One direction of an RTT channel (matches SEGGER layout). More... | |
| struct | rtt_cb_t |
| SEGGER RTT control block. More... | |
Enumerations | |
| enum | rtt_demo_const_t : uint32_t { k_rtt_demo_period_ms = 1000U , k_rtt_up_buf_bytes = 1024U , k_rtt_down_buf_bytes = 32U , k_rtt_decimal_base = 10U , k_rtt_max_digits = 10U , k_rtt_msg_buf_bytes = 32U } |
| Demo tunables. More... | |
Functions | |
| static void | internal_panic_halt (void) |
| Park the core after an unrecoverable RTT demo failure. | |
| static void | internal_init (void) |
| Initialise the RTT control block in place. | |
| static ra8_err_t | internal_write (const uint8_t *data, uint32_t len) |
Push len bytes into channel 0's up-buffer (non-blocking). | |
| static uint8_t | internal_format_line (uint32_t counter, char *buf) |
Format "rtt_log_demo: NNN\r\n" into buf. | |
| static void | internal_setup_or_halt (void) |
| Bring CGC + SysTick + LED1 + RTT control block up. | |
| void | main (void) |
| Publish a monotonically increasing RTT line once per second. | |
Variables | |
| static uint8_t | s_rtt_up_buf [k_rtt_up_buf_bytes] |
| Up-buffer storage for channel 0. | |
| static uint8_t | s_rtt_down_buf [k_rtt_down_buf_bytes] |
| Down-buffer storage for channel 0. | |
| static rtt_cb_t | s_rtt_cb |
| The control block itself. | |
Minimal SEGGER RTT logging demo for EK-RA8D2.
Allocates a SEGGER-compatible RTT control block in SRAM and writes a counter line into the up-buffer once per second. The on-board J-Link OB picks the block up by scanning RAM for the magic string "SEGGER RTT"; JLinkRTTViewer on the host then renders the stream live with no UART pin needed.
The control-block layout matches SEGGER_RTT.h (ring buffer with read/write indices). Channel 0 is the standard "Terminal" up-buffer. We keep a 1 KiB up-buffer and a 32 byte down-buffer (unused here).
Sequence:
Definition in file main.c.
| enum rtt_demo_const_t : uint32_t |
|
static |
Format "rtt_log_demo: NNN\r\n" into buf.
Copies the fixed prefix, converts the counter through a bounded reverse digit buffer, and appends CRLF without a NUL terminator.
| [in] | counter | Number to render in base-10 ASCII. |
| [out] | buf | Output buffer (>= k_rtt_msg_buf_bytes). |
| 17..26 | Complete line length, depending on counter width. |
Definition at line 199 of file main.c.
References k_rtt_decimal_base, k_rtt_max_digits, and RA8_INTERNAL.
|
static |
Initialise the RTT control block in place.
The id is written byte-by-byte (rather than as a string literal) so a search for "SEGGER RTT" in the firmware image only matches the runtime control block, not a stale literal pool entry.
s_rtt_cb.id begins with S E G G E R sp R T T. Definition at line 118 of file main.c.
References k_rtt_down_buf_bytes, k_rtt_up_buf_bytes, RA8_INTERNAL, s_rtt_cb, s_rtt_down_buf, and s_rtt_up_buf.
Referenced by internal_setup_or_halt().
|
static |
Park the core after an unrecoverable RTT demo failure.
Repeatedly executes WFI while preserving the ring and clock state.
Definition at line 95 of file main.c.
References RA8_INTERNAL.
|
static |
Bring CGC + SysTick + LED1 + RTT control block up.
Initializes clocks, the delay service, LED1, and the in-SRAM RTT descriptor in dependency order, halting on a failed HAL operation.
Definition at line 232 of file main.c.
References internal_init(), internal_panic_halt(), k_ra8_board_led1, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, and ra8_time_init().
|
staticnodiscard |
Push len bytes into channel 0's up-buffer (non-blocking).
| [in] | data | Bytes to enqueue. |
| [in] | len | Byte count; data fitting beyond head is dropped. |
| k_ra8_ok | Bytes were appended (or dropped silently). |
| k_ra8_err_null_ptr | data was NULL. |
Definition at line 163 of file main.c.
References rtt_buf_t::buf, k_ra8_err_null_ptr, k_ra8_ok, RA8_INTERNAL, rtt_buf_t::rd_off, s_rtt_cb, rtt_buf_t::size, and rtt_buf_t::wr_off.
Referenced by main().
| void main | ( | void | ) |
Publish a monotonically increasing RTT line once per second.
The application entry point Reset_Handler hands control to.
Initializes channel zero, formats and enqueues each counter line, toggles LED1, and delays before incrementing the next sample.
Definition at line 261 of file main.c.
References internal_format_line(), internal_panic_halt(), internal_setup_or_halt(), internal_write(), k_ra8_board_led1, k_ra8_ok, k_rtt_demo_period_ms, k_rtt_msg_buf_bytes, ra8_board_led_toggle(), ra8_delay_ms(), and ra8_isr_globals_enable().
|
static |
The control block itself.
Definition at line 83 of file main.c.
Referenced by internal_init(), and internal_write().
|
static |
Down-buffer storage for channel 0.
Definition at line 80 of file main.c.
Referenced by internal_init().
|
static |
Up-buffer storage for channel 0.
Definition at line 77 of file main.c.
Referenced by internal_init().