ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
c6_console.c
Go to the documentation of this file.
1
18
19#include <stddef.h>
20#include <stdint.h>
21
22#include "c6_probe.h"
23#include "ra8_board_ek_ra8d2.h"
24
25void c6_probe_puts(const char* text)
26{
27 if (text == nullptr) {
28 return;
29 }
30 uint32_t len = 0U;
31 while (len < (uint32_t)k_c6_probe_str_max && text[len] != '\0') {
32 len++;
33 }
34 (void)ra8_board_uart_console_write((const uint8_t*)text, (size_t)len);
35}
36
38void c6_probe_put_u32(uint32_t value)
39{
40 uint8_t digits[k_c6_fmt_dec_digits] = {};
41 uint32_t count = 0U;
42 uint32_t rest = value;
43 do {
44 digits[count] = (uint8_t)('0' + (uint8_t)(rest % (uint32_t)k_c6_fmt_dec_radix));
45 rest = rest / (uint32_t)k_c6_fmt_dec_radix;
46 count++;
47 } while (rest != 0U && count < (uint32_t)k_c6_fmt_dec_digits);
48
49 uint8_t out[k_c6_fmt_dec_digits] = {};
50 for (uint32_t i = 0U; i < count; i++) {
51 out[i] = digits[count - 1U - i];
52 }
53 (void)ra8_board_uart_console_write(out, (size_t)count);
54}
55
56void c6_probe_put_hex(uint32_t value, uint8_t digits)
57{
58 if (digits == 0U || digits > (uint8_t)k_c6_fmt_hex_max) {
59 return;
60 }
61 uint8_t out[k_c6_fmt_hex_max] = {};
62 for (uint8_t i = 0U; i < digits; i++) {
63 const uint8_t shift = (uint8_t)((digits - 1U - i) * (uint8_t)k_c6_fmt_hex_bits);
64 const uint8_t nibble = (uint8_t)((value >> shift) & (uint32_t)k_c6_fmt_hex_mask);
65 out[i] = (nibble < (uint8_t)k_c6_fmt_hex_alpha)
66 ? (uint8_t)('0' + nibble)
67 : (uint8_t)('a' + (uint8_t)(nibble - (uint8_t)k_c6_fmt_hex_alpha));
68 }
69 (void)ra8_board_uart_console_write(out, (size_t)digits);
70}
void c6_probe_puts(const char *text)
Emit a bounded, NUL-terminated ASCII literal on the console.
Definition c6_console.c:25
void c6_probe_put_u32(uint32_t value)
Implementation of c6_probe_put_u32() – reversed division loop.
Definition c6_console.c:38
void c6_probe_put_hex(uint32_t value, uint8_t digits)
Emit a value as fixed-width lowercase hexadecimal.
Definition c6_console.c:56
Shared contract for the EK-RA8D2 <-> ESP32-C6 esp-hosted SPI probe.
@ k_c6_fmt_dec_radix
Base ten.
Definition c6_probe.h:136
@ k_c6_fmt_dec_digits
"4294967295" is ten digits.
Definition c6_probe.h:137
@ k_c6_fmt_hex_max
A uint32_t is eight nibbles.
Definition c6_probe.h:138
@ k_c6_fmt_hex_bits
Bits per nibble.
Definition c6_probe.h:139
@ k_c6_fmt_hex_alpha
First nibble printed as a letter.
Definition c6_probe.h:141
@ k_c6_fmt_hex_mask
Nibble mask.
Definition c6_probe.h:140
@ k_c6_probe_str_max
Longest console literal accepted.
Definition c6_probe.h:111
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_uart_console_write(const uint8_t *data, size_t len)
Polled blocking write to the J-Link OB VCOM console.