ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
c6_hosted_report.c
Go to the documentation of this file.
1
33
34#include <stddef.h>
35#include <stdint.h>
36
37#include "c6_hosted.h"
38#include "esp_hosted_os_abstraction.h"
40#include "ra8_board_ek_ra8d2.h"
41#include "ra8_esp_hosted_pins.h"
42#include "ra8_spi.h"
43
54static volatile uint32_t s_c6_hosted_events;
55
70static void c6_hosted_print_route(const char* label, ra8_esp_hosted_pin_t pin)
71{
72 const uint8_t irq = ra8_esp_hosted_pin_irq_num((ra8_port_pin_t)pin);
73 c6_hosted_puts("c6_hosted_init: ");
75 if (irq == (uint8_t)k_ra8_esp_hosted_irq_none) {
76 c6_hosted_puts(" irq=none path=software-edge-detector poll_ms=");
78 } else {
79 c6_hosted_puts(" irq=");
80 c6_hosted_put_u32((uint32_t)irq);
81 c6_hosted_puts(" path=icu-edge");
82 }
83 c6_hosted_puts("\r\n");
84}
85
101static void
102c6_hosted_read_sideband(const char* label, void* gpio_port, int32_t gpio_pin, int32_t active)
103{
104 c6_hosted_puts("c6_hosted_init: sideband ");
105 c6_hosted_puts(label);
106 if (gpio_pin < 0) {
107 c6_hosted_puts(" unwired\r\n");
108 return;
109 }
110 const int32_t level = (int32_t)g_h.funcs->_h_read_gpio(gpio_port, (uint32_t)gpio_pin);
111 c6_hosted_puts(" level=");
112 c6_hosted_put_i32(level);
113 c6_hosted_puts(" active_level=");
114 c6_hosted_put_i32(active);
115 c6_hosted_puts((level == active) ? " state=asserted\r\n" : " state=deasserted\r\n");
116}
117
118void c6_hosted_print_banner(uint32_t cpuclk_hz, uint32_t pclka_hz)
119{
120 c6_hosted_puts("\r\nc6_hosted_init: EK-RA8D2 <-> ESP32-C6 esp-hosted port bring-up\r\n");
121 c6_hosted_puts("c6_hosted_init: port=port/esp-hosted (RA8D2 + ThreadX) "
122 "driver=esp-hosted-mcu\r\n");
123 c6_hosted_puts("c6_hosted_init: cpuclk0_hz=");
124 c6_hosted_put_u32(cpuclk_hz);
125 c6_hosted_puts(" pclka_hz=");
126 c6_hosted_put_u32(pclka_hz);
127 c6_hosted_puts("\r\nc6_hosted_init: spi sci=");
129 c6_hosted_puts(" mode=");
131 c6_hosted_puts(" sck_hz=");
133 c6_hosted_puts("\r\n");
134}
135
151
153{
154 c6_hosted_read_sideband("handshake",
156 (int32_t)H_GPIO_HANDSHAKE_Pin,
157 (int32_t)H_HS_VAL_ACTIVE);
158 c6_hosted_read_sideband("data_ready",
160 (int32_t)H_GPIO_DATA_READY_Pin,
161 (int32_t)H_DR_VAL_ACTIVE);
162}
163
164void c6_hosted_on_event(void* ctx,
165 const char* base,
166 int32_t event_id,
167 const void* data,
168 size_t data_len)
169{
170 (void)ctx;
171 (void)data;
173 c6_hosted_puts("c6_hosted_init: event base=");
174 c6_hosted_puts((base != nullptr) ? base : "(null)");
175 c6_hosted_puts(" id=");
176 c6_hosted_put_i32(event_id);
177 c6_hosted_puts(" len=");
178 c6_hosted_put_u32((uint32_t)data_len);
179 c6_hosted_puts("\r\n");
180}
181
183{
184 return s_c6_hosted_events;
185}
Shared contract for the esp-hosted port bring-up application.
void c6_hosted_puts(const char *text)
Write a NUL-terminated string to the board console.
void c6_hosted_put_i32(int32_t value)
Emit a signed 32-bit value in decimal.
void c6_hosted_put_u32(uint32_t value)
Emit an unsigned 32-bit value in decimal.
void c6_hosted_print_pin(const char *label, ra8_esp_hosted_pin_t pin)
Print one packed board pin as <label>=port<n>.pin<n>.
@ k_c6_hosted_sck_hz
SPI bit rate: the 5 MHz upstream recommends for first light, an order above the probe's 1 MHz.
Definition c6_hosted.h:61
@ k_c6_hosted_edge_poll_ms
Poll period for a side-band pin with no ICU channel.
Definition c6_hosted.h:63
void c6_hosted_print_gpio(const char *label, const void *gpio_port, int32_t gpio_pin)
Print an H_GPIO_*_Port / H_GPIO_*_Pin pair as one field.
void c6_hosted_print_banner(uint32_t cpuclk_hz, uint32_t pclka_hz)
Print the port identity, the clocks and the SPI parameters.
void c6_hosted_report_sideband(void)
Sample both side-band lines through the vtable and report them.
uint32_t c6_hosted_event_count(void)
Report how many events c6_hosted_on_event has seen.
static void c6_hosted_print_route(const char *label, ra8_esp_hosted_pin_t pin)
Print the interrupt path the port takes for one side-band pin.
void c6_hosted_print_pin_map(void)
Print the resolved pin map, bus pins and side-band alike.
static volatile uint32_t s_c6_hosted_events
Number of events c6_hosted_on_event has been handed.
void c6_hosted_on_event(void *ctx, const char *base, int32_t event_id, const void *data, size_t data_len)
Report an event the port delivered from the vendored core.
static void c6_hosted_read_sideband(const char *label, void *gpio_port, int32_t gpio_pin, int32_t active)
Sample one side-band input through the OS-abstraction vtable.
esp-hosted port header: transport selection, side-band pin map, link polarity.
#define H_GPIO_HANDSHAKE_Pin
Pin index of the HANDSHAKE input, or -1 when it is not wired.
#define H_GPIO_HANDSHAKE_Port
Opaque port handle of the HANDSHAKE input.
#define H_HS_VAL_ACTIVE
Level read back on HANDSHAKE when it is asserted.
#define H_GPIO_PIN_RESET
Pin index of the co-processor reset output, or -1 when unwired.
#define H_GPIO_DATA_READY_Port
Opaque port handle of the DATA_READY input.
#define H_GPIO_PORT_RESET
Opaque port handle of the co-processor reset output.
#define H_DR_VAL_ACTIVE
Level read back on DATA_READY when a frame is waiting.
#define H_GPIO_DATA_READY_Pin
Pin index of the DATA_READY input, or -1 when it is not wired.
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
@ k_ra8_board_pmod1_sci_channel
Pmod1 (J26) Simple-SPI is SCI2.
ra8_board_eth_pin_t pin
Pin.
struct hosted_config_t g_h
The handle the vendored core dereferences to reach the vtable.
THE single point of change for the RA8 <-> ESP32-C6 harness map.
ra8_esp_hosted_pin_t
RA8-side pin assignment for every esp-hosted link signal.
@ k_ra8_esp_hosted_pin_chip_select
Chip select, RA8 output.
@ k_ra8_esp_hosted_pin_data_ready
DATA_READY, RA8 input, C6 output.
@ k_ra8_esp_hosted_pin_copi
Controller-out peripheral-in data, RA8 output, routed to the SCI channel rather than driven as a GPIO...
@ k_ra8_esp_hosted_pin_cipo
Controller-in peripheral-out data, RA8 input, routed to the SCI channel rather than sampled as a GPIO...
@ k_ra8_esp_hosted_pin_sck
Serial clock, RA8 output, routed to the SCI channel.
@ k_ra8_esp_hosted_pin_handshake
HANDSHAKE, RA8 input, C6 output.
@ k_ra8_esp_hosted_irq_none
No ICU channel routes this pin.
uint8_t ra8_esp_hosted_pin_irq_num(ra8_port_pin_t pin)
Report the ICU external-interrupt channel that serves a pin.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
SPI_B controller driver (RA8D2 Type-B SPI peripheral).
@ k_ra8_spi_mode_3
CPOL=1, CPHA=1.
Definition ra8_spi.h:65