ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
c6_cam_console.c
Go to the documentation of this file.
1
17
18#include <stddef.h>
19#include <stdint.h>
20
21#include "c6_camera_server.h"
22#include "ra8_board_ek_ra8d2.h"
23
31
32void c6_cam_puts(const char* text)
33{
34 if (text == nullptr) {
35 return;
36 }
37 uint32_t length = 0U;
38 while ((length < (uint32_t)k_c6_cam_console_text_max) && (text[length] != '\0')) {
39 length++;
40 }
41 (void)ra8_board_uart_console_write((const uint8_t*)text, (size_t)length);
42}
43
44void c6_cam_put_u32(uint32_t value)
45{
46 uint8_t reverse[k_c6_cam_decimal_digits] = {};
47 uint8_t output[k_c6_cam_decimal_digits] = {};
48 uint32_t count = 0U;
49 do {
50 reverse[count] = (uint8_t)('0' + (uint8_t)(value % (uint32_t)k_c6_cam_decimal_digits));
51 value /= (uint32_t)k_c6_cam_decimal_digits;
52 count++;
53 } while ((value != 0U) && (count < (uint32_t)k_c6_cam_decimal_digits));
54 for (uint32_t i = 0U; i < count; i++) {
55 output[i] = reverse[count - 1U - i];
56 }
57 (void)ra8_board_uart_console_write(output, (size_t)count);
58}
59
60void c6_cam_put_ip(uint32_t ip)
61{
62 static const uint8_t k_shifts[4] = {(uint8_t)k_c6_cam_ipv4_high_shift, 16U, 8U, 0U};
63 for (uint32_t i = 0U; i < 4U; i++) {
64 if (i != 0U) {
65 c6_cam_puts(".");
66 }
67 c6_cam_put_u32((ip >> k_shifts[i]) & (uint32_t)k_c6_cam_ipv4_octet_mask);
68 }
69}
void c6_cam_put_u32(uint32_t value)
Write one unsigned decimal value to SCI8.
c6_cam_console_t
Bounded formatting sizes and IPv4 extraction constants.
@ k_c6_cam_ipv4_high_shift
Shift of the first IPv4 octet.
@ k_c6_cam_ipv4_octet_mask
Mask selecting one IPv4 octet.
@ k_c6_cam_console_text_max
Bounded console string length.
@ k_c6_cam_decimal_digits
Digits in a 32-bit decimal rendering.
void c6_cam_put_ip(uint32_t ip)
Write one IPv4 address to SCI8.
void c6_cam_puts(const char *text)
Write a bounded NUL-terminated string to SCI8.
Shared contracts for ESP32-C6 browser camera servers.
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.