ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
c6_sideband.c File Reference

Pmod1 side-band sampling, wire test, pull-up contest, chip-select hunt. More...

#include <stdint.h>
#include "c6_probe.h"
#include "ra8_board_ek_ra8d2.h"
#include "ra8_err.h"
#include "ra8_port_utils.h"
#include "ra8_time.h"
Include dependency graph for c6_sideband.c:

Go to the source code of this file.

Functions

ra8_err_t c6_probe_sideband_init (void)
 Claim the four Pmod1 side-band pins as no-pull digital inputs.
void c6_probe_sample_sideband (c6_sideband_sample_t *out)
 Read every Pmod1 side-band pin into one sample.
const char * c6_probe_sideband_name (uint8_t idx)
 Name a side-band pin for the console.
void c6_probe_print_sideband (const char *label, const c6_sideband_sample_t *s)
 Print a labelled side-band sample as label P006=1 P402=0 ....
void c6_probe_vote (const c6_sideband_sample_t *pre, const c6_sideband_sample_t *mid, const c6_sideband_sample_t *post, c6_probe_stats_t *st)
 Fold one transaction's three samples into the classification votes.
uint8_t c6_probe_best (const uint32_t *votes, uint8_t ignore, uint32_t min_votes)
 Pick the side-band pin that won the vote outright, or report none.
static ra8_err_t internal_pull_read (ra8_port_pin_t pin, uint8_t *out_low)
 Hold one pin against the internal pull-up and count the low reads.
ra8_err_t c6_probe_pull_contest (c6_probe_stats_t *st)
 Find which side-band pins an external driver is holding low.
uint8_t c6_probe_sunk_pin (const c6_probe_stats_t *st, uint8_t ignore)
 Name the one pin that lost every read of the pull-up contest.
void c6_probe_resolve_map (const c6_probe_stats_t *st, uint8_t *hs_idx, uint8_t *dr_idx)
 Resolve the HANDSHAKE and DATA_READY side-band map from the accumulated evidence.
static ra8_err_t internal_kick_net (ra8_port_pin_t pin, ra8_level_t level, uint8_t *out_level)
 Drive one net to a level, release it, and sample what it settles to.
c6_wire_kind_t c6_probe_wire_kind (uint8_t after_high, uint8_t after_low)
 Classify one Pmod1 net from its two drive-and-release samples.
void c6_probe_wire_test (void)
 Run the drive-and-release test over every Pmod1 muxed net.
static bool internal_cs_try (uint8_t idx, c6_probe_stats_t *st)
 Assert one candidate chip-select and report any side-band response.
uint8_t c6_probe_cs_hunt (c6_probe_stats_t *st)
 Find which MCU pin the board's Pmod1 mux has wired to the C6's chip-select, and identify HANDSHAKE at the same time.

Variables

static const ra8_port_pin_t k_c6_sideband_pin [k_c6_sb_count]
 The four Pmod1 side-band pins, in c6_sideband_idx_t order.
static const char *const k_c6_sideband_label [k_c6_sb_count+1U]
 Console labels for k_c6_sideband_pin, same order.
static const ra8_port_pin_t k_c6_wire_pin [k_c6_wire_count]
 The five Pmod1 muxed-net candidates, in c6_wire_idx_t order.
static const char *const k_c6_wire_label [k_c6_wire_count+1U]
 Console labels for k_c6_wire_pin, same order.

Detailed Description

Pmod1 side-band sampling, wire test, pull-up contest, chip-select hunt.

Tag
[Ring 6 / APP] {World: S}

Everything the probe knows about the physical side of the Pmod1 link lives here. Three facts about the C6 image in coprocessor/esp32c6/ make these diagnostics possible without any working data path:

  • It is built with CONFIG_ESP_SPI_DEASSERT_HS_ON_CS=y, so the C6 drops HANDSHAKE from its chip-select edge interrupt (gpio_disable_hs_isr_handler in esp-hosted-mcu the C6's peripheral-side SPI driver) and re-raises it when the next transaction is queued (spi_post_setup_cb). Merely asserting a candidate chip-select therefore makes a live C6 answer on a side-band pin – no clock, no payload required.
  • It holds DATA_READY low whenever its transmit queue is empty, which is most of the time. That pin is therefore identified not by watching it move but by the pull-up contest in c6_probe_pull_contest: an input with the internal pull-up engaged that still reads low is being sunk by something off-chip.
  • HANDSHAKE and DATA_READY are push-pull outputs, so the RA8 must never drive the side-band pins; they are only ever read here, with the pull-up contest's brief weak pull as the sole exception.
Since
0.1.0

Definition in file c6_sideband.c.

Function Documentation

◆ c6_probe_best()

uint8_t c6_probe_best ( const uint32_t * votes,
uint8_t ignore,
uint32_t min_votes )

Pick the side-band pin that won the vote outright, or report none.

A winner must clear two bars, and both exist because the bench produced the failure they prevent. It must reach min_votes, so one transition on a floating pin cannot name a mapping; and it must be a strict winner, so a tie is reported as unresolved rather than silently broken by table order. Reporting "unresolved" is a useful answer here – claiming the wrong pin is not.

Parameters
[in]votesPer-pin vote counters.
[in]ignoreIndex to skip, or k_c6_sb_count to skip nothing.
[in]min_votesSmallest vote count that may claim a mapping; must be at least one.
Returns
Winning pin index, or k_c6_sb_count when none qualifies.
Return values
k_c6_sb_countNo pin reached min_votes, the top score was tied, votes was NULL, or min_votes was zero.
Precondition
votes is non-NULL for a winner to be reported.
ignore is a valid index or k_c6_sb_count.
Postcondition
The returned index is either a strict winner or k_c6_sb_count.
votes is unmodified.
Note
Pure function; safe from any context.
Example:
const uint8_t hs = c6_probe_best(stats.hs_vote,
(uint8_t)k_c6_sb_count,
@ k_c6_sb_count
Side-band pin count.
Definition c6_probe.h:177
@ k_c6_probe_min_votes
Votes required to claim a mapping.
Definition c6_probe.h:114
uint8_t c6_probe_best(const uint32_t *votes, uint8_t ignore, uint32_t min_votes)
Pick the side-band pin that won the vote outright, or report none.
See also
c6_probe_resolve_map
Since
0.1.0

Definition at line 180 of file c6_sideband.c.

References k_c6_sb_count.

Referenced by c6_probe_resolve_map(), c6_probe_run(), and c6_probe_sweep_mode().

◆ c6_probe_cs_hunt()

uint8_t c6_probe_cs_hunt ( c6_probe_stats_t * st)

Find which MCU pin the board's Pmod1 mux has wired to the C6's chip-select, and identify HANDSHAKE at the same time.

The C6 image sets CONFIG_ESP_SPI_DEASSERT_HS_ON_CS=y, so its chip-select edge interrupt drops HANDSHAKE the moment chip-select is asserted and re-raises it once the next transaction is queued (gpio_disable_hs_isr_handler / spi_post_setup_cb in the C6's peripheral-side SPI driver). Asserting each muxed-net candidate in turn and watching for a side-band pin to drop therefore needs no clock, no payload and no working data path: the pin that provokes the drop is the real chip-select, and the pin that drops is HANDSHAKE.

Parameters
[in,out]stStatistics block; handshake votes are accumulated here.
Returns
Index into the muxed-net table of the pin that reached the C6.
Return values
k_c6_wire_countNo candidate provoked a side-band response.
Precondition
The console is up and the Pmod1 SPI pins are unclaimed.
st is non-NULL.
Postcondition
Every tested pin is left unclaimed.
st->hs_vote records every observed drop.
Note
Safe against contention: every candidate is an input on the C6.
Example:
const uint8_t cs = c6_probe_cs_hunt(&stats);
uint8_t c6_probe_cs_hunt(c6_probe_stats_t *st)
Find which MCU pin the board's Pmod1 mux has wired to the C6's chip-select, and identify HANDSHAKE at...
See also
c6_probe_wire_test
Since
0.1.0

Definition at line 485 of file c6_sideband.c.

References c6_probe_puts(), internal_cs_try(), k_c6_wire_count, and k_c6_wire_label.

Referenced by main().

◆ c6_probe_print_sideband()

void c6_probe_print_sideband ( const char * label,
const c6_sideband_sample_t * s )

Print a labelled side-band sample as label P006=1 P402=0 ....

Parameters
[in]labelShort prefix, already indented by the caller.
[in]sSample to print; ignored when NULL.
Precondition
The board UART console has been initialised.
s is non-NULL for anything to be printed.
Postcondition
Exactly one console line was emitted when s is non-NULL.
Neither argument is modified.
Note
Not thread-safe.
See also
c6_probe_sample_sideband
Since
0.1.0

Definition at line 141 of file c6_sideband.c.

References c6_probe_put_u32(), c6_probe_puts(), c6_probe_sideband_name(), k_c6_sb_count, and c6_sideband_sample_t::level.

Referenced by internal_cs_try(), internal_one_xfer(), and main().

◆ c6_probe_pull_contest()

ra8_err_t c6_probe_pull_contest ( c6_probe_stats_t * st)
nodiscard

Find which side-band pins an external driver is holding low.

Re-claims each side-band pin as an input with the RA8D2's internal pull-up engaged, reads it k_c6_probe_pull_samples times, and restores it to a no-pull input. A pin with nothing on it is pulled high and reads high every time; a pin that keeps reading low is losing a current fight to something off-chip, which nothing floating can imitate. That is the strongest "this pin is connected" evidence the probe can gather, and it needs no cooperation from the C6 whatsoever.

It is what identifies DATA_READY. An esp-hosted peripheral with an empty transmit queue holds DATA_READY low by design, so across a whole probe run that pin moves once at most, and usually where nothing is sampling. The pin that matters most is therefore the one a transition-counting rule cannot see – and the one this rule reads without ambiguity.

One line per pin is printed, so the raw count is in the log even when the verdict is unresolved.

Parameters
[in,out]stStatistics block; pull_low and pull_samples are written.
Returns
ra8_err_t error code.
Return values
k_ra8_okEvery pin was tested and restored to a no-pull input.
k_ra8_err_null_ptrst was NULL.
k_ra8_err_gpio_conflictA side-band pin is owned elsewhere.
Precondition
c6_probe_sideband_init has claimed the side-band pins.
The chip-select is released and no transaction is in flight.
Postcondition
On success every side-band pin is a no-pull input again.
On success st->pull_samples is k_c6_probe_pull_samples.
Warning
Timing is part of the measurement, in both directions. Run it only with the chip-select released – HANDSHAKE is legitimately low while it is asserted, and would read as a sunk pin. Run it only after the transaction sweep as well: a freshly-booted C6 holds DATA_READY high for its queued INIT event until the first transaction drains it, so an early contest finds nothing sunk.
Note
Not thread-safe; boot-time diagnostic only.
Example:
if (c6_probe_pull_contest(&stats) != k_ra8_ok) { panic(); }
ra8_err_t c6_probe_pull_contest(c6_probe_stats_t *st)
Find which side-band pins an external driver is holding low.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
See also
c6_probe_sunk_pin
Since
0.1.0

Definition at line 269 of file c6_sideband.c.

References c6_probe_put_u32(), c6_probe_puts(), c6_probe_sideband_name(), internal_pull_read(), k_c6_probe_pull_samples, k_c6_sb_count, k_c6_sideband_pin, k_ra8_err_null_ptr, k_ra8_ok, c6_probe_stats_t::pull_low, and c6_probe_stats_t::pull_samples.

Referenced by c6_probe_run().

◆ c6_probe_resolve_map()

void c6_probe_resolve_map ( const c6_probe_stats_t * st,
uint8_t * hs_idx,
uint8_t * dr_idx )

Resolve the HANDSHAKE and DATA_READY side-band map from the accumulated evidence.

The whole identification policy lives here, in one place, ranked by how hard the evidence is to fake:

  1. HANDSHAKE is the pin that wins the vote outright – more chip-select-tracking transitions than any other pin, and at least k_c6_probe_min_votes of them. The C6 drives that edge itself, so repeated transitions in step with a line the probe controls are not something noise produces.
  2. DATA_READY is the pin that loses the pull-up contest outright, excluding whichever pin took HANDSHAKE. An idle esp-hosted peripheral holds DATA_READY low, and only a real connection can hold a pin down against the pull-up.
  3. Failing that, DATA_READY falls back to the drain-transition vote under the same threshold – the only evidence available if the C6 had a frame queued and drained it during the run.

Any step that cannot decide yields k_c6_sb_count, and the caller prints unresolved. That is deliberate: the previous policy took the highest vote unconditionally, and a single noise transition on an unconnected pin was enough to publish a wrong pin map that read exactly like a measured one.

Parameters
[in]stAccumulated evidence.
[out]hs_idxResolved HANDSHAKE index, or k_c6_sb_count.
[out]dr_idxResolved DATA_READY index, or k_c6_sb_count.
Precondition
All three pointers are non-NULL.
st holds the evidence of a completed run.
Postcondition
*hs_idx and *dr_idx are valid indices or k_c6_sb_count.
*hs_idx != *dr_idx unless both are k_c6_sb_count.
Note
Pure with respect to st; safe from any context.
Example:
uint8_t hs = 0U;
uint8_t dr = 0U;
c6_probe_resolve_map(&stats, &hs, &dr);
void c6_probe_resolve_map(const c6_probe_stats_t *st, uint8_t *hs_idx, uint8_t *dr_idx)
Resolve the HANDSHAKE and DATA_READY side-band map from the accumulated evidence.
See also
c6_probe_pull_contest
Since
0.1.0

Definition at line 313 of file c6_sideband.c.

References c6_probe_best(), c6_probe_sunk_pin(), c6_probe_stats_t::dr_vote, c6_probe_stats_t::hs_vote, k_c6_probe_min_votes, and k_c6_sb_count.

Referenced by c6_probe_run().

◆ c6_probe_sample_sideband()

void c6_probe_sample_sideband ( c6_sideband_sample_t * out)

Read every Pmod1 side-band pin into one sample.

Parameters
[out]outDestination sample; ignored when NULL.
Precondition
Every side-band pin was configured as an input.
out is non-NULL for the sample to be stored.
Postcondition
On success every out->level entry is 0 or 1.
A pin whose read fails is recorded as 0 rather than left stale.
Note
Not thread-safe.
Example:
void c6_probe_sample_sideband(c6_sideband_sample_t *out)
Read every Pmod1 side-band pin into one sample.
One simultaneous reading of every side-band pin.
Definition c6_probe.h:194
See also
c6_probe_print_sideband
Since
0.1.0

Definition at line 121 of file c6_sideband.c.

References k_c6_sb_count, k_c6_sideband_pin, k_ra8_level_high, k_ra8_level_low, k_ra8_ok, c6_sideband_sample_t::level, and ra8_gpio_read().

Referenced by internal_cs_try(), internal_transfer(), internal_wait_ready(), and main().

◆ c6_probe_sideband_init()

ra8_err_t c6_probe_sideband_init ( void )
nodiscard

Claim the four Pmod1 side-band pins as no-pull digital inputs.

No internal pull is applied for sampling: the C6 drives HANDSHAKE and DATA_READY push-pull, and holding a pull-up during the run would make an unconnected pin indistinguishable from an asserted one – precisely the distinction this app exists to make. c6_probe_pull_contest engages the pull-up briefly and on purpose, then restores the pins to this state.

Returns
ra8_err_t error code.
Return values
k_ra8_okAll four side-band pins are inputs.
k_ra8_err_gpio_conflictA pin is already owned elsewhere.
k_ra8_err_gpio_invalid_portBoard pin table disagrees with the HAL.
Precondition
ra8_mstp_init has run so PFS writes land.
No other driver owns the Pmod1 side-band pins.
Postcondition
On success every side-band pin is a digital input.
No side-band pin is left driven.
Note
Not thread-safe; boot-time only.
See also
c6_probe_sample_sideband
Since
0.1.0

Definition at line 110 of file c6_sideband.c.

References k_c6_sb_count, k_c6_sideband_pin, k_ra8_ok, k_ra8_pull_none, and ra8_gpio_input_init().

Referenced by c6_probe_setup_or_halt().

◆ c6_probe_sideband_name()

const char * c6_probe_sideband_name ( uint8_t idx)

Name a side-band pin for the console.

Parameters
[in]idxSide-band index, or k_c6_sb_count for "unresolved".
Returns
Static label for the pin.
Return values
unresolvedidx was out of range.
Precondition
idx is a valid index or k_c6_sb_count.
The returned pointer is never freed by the caller.
Postcondition
The returned string is NUL-terminated.
No state is modified.
Note
Pure function; safe from any context.
See also
c6_probe_print_sideband
Since
0.1.0

Definition at line 135 of file c6_sideband.c.

References k_c6_sb_count, and k_c6_sideband_label.

Referenced by c6_probe_print_map(), c6_probe_print_sideband(), and c6_probe_pull_contest().

◆ c6_probe_sunk_pin()

uint8_t c6_probe_sunk_pin ( const c6_probe_stats_t * st,
uint8_t ignore )

Name the one pin that lost every read of the pull-up contest.

Reads the verdict out of the evidence c6_probe_pull_contest gathered: a pin qualifies only when pull_low equals pull_samples, i.e. it read low on every single sample taken against the pull-up.

Two conditions are deliberately reported as "no answer" rather than as a winner. Unanimity is required because a pin that reads low only sometimes is being driven by something that is not an idle DATA_READY – a coupled edge, a shared ground bounce – and naming it would be a guess. Uniqueness is required because two sunk pins mean the caller's exclusion (typically the resolved HANDSHAKE) has not narrowed the field to one, and picking either by table order is the exact failure this whole mechanism exists to prevent.

Parameters
[in]stStatistics block filled by c6_probe_pull_contest.
[in]ignoreIndex to skip, or k_c6_sb_count to skip nothing.
Returns
Index of the uniquely sunk pin, or k_c6_sb_count.
Return values
k_c6_sb_countNo pin was sunk, more than one was, the contest was never run, or st was NULL.
Precondition
st is non-NULL for a verdict to be reported.
ignore is a valid index or k_c6_sb_count.
Postcondition
st is unmodified.
The returned index is unique, or k_c6_sb_count.
Note
Pure function; safe from any context.
Example:
const uint8_t dr = c6_probe_sunk_pin(&stats, hs_idx);
uint8_t c6_probe_sunk_pin(const c6_probe_stats_t *st, uint8_t ignore)
Name the one pin that lost every read of the pull-up contest.
See also
c6_probe_pull_contest
Since
0.1.0

Definition at line 294 of file c6_sideband.c.

References k_c6_sb_count, c6_probe_stats_t::pull_low, and c6_probe_stats_t::pull_samples.

Referenced by c6_probe_resolve_map().

◆ c6_probe_vote()

void c6_probe_vote ( const c6_sideband_sample_t * pre,
const c6_sideband_sample_t * mid,
const c6_sideband_sample_t * post,
c6_probe_stats_t * st )

Fold one transaction's three samples into the classification votes.

HANDSHAKE is the pin that is high before the transfer and low while the chip-select is asserted, because the C6 is built with CONFIG_ESP_SPI_DEASSERT_HS_ON_CS=y and clears it from its chip-select edge interrupt (gpio_disable_hs_isr_handler in the C6's peripheral-side SPI driver). That is a genuine identification: the pin moves, twice per transaction, in step with a line the probe itself drives.

The DATA_READY vote is far weaker and must not be read as its equal. It counts a pin that was high before the transfer and still low well after it, which is what the C6 does when it drains a queued frame (get_next_tx_buffer). That is a once-per-boot event: the C6 raises DATA_READY for its queued INIT event and lowers it when the first transaction takes it, after which the pin stays low and every later pre sample is already low, so the vote cannot fire again. Worse, that single transition usually lands between transactions – during the chip-select hunt, say – where nothing is sampling, so in practice the counter often stays at zero for the correctly-wired pin. The vote proves DATA_READY when it fires and says nothing at all when it does not, which is why c6_probe_resolve_map prefers the pull-up contest and keeps this counter only as a fallback.

Parameters
[in]preSample taken with the chip-select released.
[in]midSample taken with the chip-select asserted.
[in]postSample taken after the chip-select was released again.
[in,out]stStatistics block to accumulate into.
Precondition
All four pointers are non-NULL.
The three samples come from the same transaction, in order.
Postcondition
Vote counters only ever grow.
ever_high / ever_low reflect all three samples.
Note
Not thread-safe.
Example:
c6_probe_vote(&pre, &mid, &post, &stats);
void c6_probe_vote(const c6_sideband_sample_t *pre, const c6_sideband_sample_t *mid, const c6_sideband_sample_t *post, c6_probe_stats_t *st)
Fold one transaction's three samples into the classification votes.
See also
c6_probe_best
Since
0.1.0

Definition at line 156 of file c6_sideband.c.

References c6_probe_stats_t::dr_vote, c6_probe_stats_t::ever_high, c6_probe_stats_t::ever_low, c6_probe_stats_t::hs_vote, k_c6_sb_count, and c6_sideband_sample_t::level.

Referenced by internal_one_xfer().

◆ c6_probe_wire_kind()

c6_wire_kind_t c6_probe_wire_kind ( uint8_t after_high,
uint8_t after_low )

Classify one Pmod1 net from its two drive-and-release samples.

Parameters
[in]after_highLevel read after driving the net high and releasing.
[in]after_lowLevel read after driving the net low and releasing.
Returns
The termination classification.
Return values
k_c6_wire_floatingHeld both driven levels: nothing attached.
k_c6_wire_low_sideSnapped low both times: pull-down or driver.
k_c6_wire_high_sideSnapped high both times: pull-up or driver.
k_c6_wire_oddInverted pair; not physically expected.
Precondition
Both samples come from the same net, high test first.
Each sample is 0 or 1.
Postcondition
Exactly one classification is returned.
Neither argument is modified.
Note
Pure function; safe from any context.
Example:
const c6_wire_kind_t k = c6_probe_wire_kind(1U, 0U); // floating
c6_wire_kind_t c6_probe_wire_kind(uint8_t after_high, uint8_t after_low)
Classify one Pmod1 net from its two drive-and-release samples.
c6_wire_kind_t
What the drive-and-release test says is on the far end of a net.
Definition c6_probe.h:250
See also
c6_probe_wire_test
Since
0.1.0

Definition at line 384 of file c6_sideband.c.

References k_c6_wire_floating, k_c6_wire_high_side, k_c6_wire_low_side, and k_c6_wire_odd.

Referenced by c6_probe_wire_test().

◆ c6_probe_wire_test()

void c6_probe_wire_test ( void )

Run the drive-and-release test over every Pmod1 muxed net.

Prints one line per candidate so the log states, without inference, what terminates each MCU pin that the board's Pmod1 mux might connect to J26.

Precondition
The console is up and the Pmod1 SPI pins are unclaimed.
ra8_time_init has run so the settle delays are real.
Postcondition
Every tested pin is left unclaimed, ready for PFS routing.
Exactly k_c6_wire_count result lines were printed.
Note
Not thread-safe; boot-time diagnostic only.
Example:
void c6_probe_wire_test(void)
Run the drive-and-release test over every Pmod1 muxed net.
See also
c6_probe_cs_hunt
Since
0.1.0

Definition at line 398 of file c6_sideband.c.

References c6_probe_put_u32(), c6_probe_puts(), c6_probe_wire_kind(), internal_kick_net(), k_c6_wire_count, k_c6_wire_label, k_c6_wire_pin, k_ra8_level_high, k_ra8_level_low, and k_ra8_ok.

Referenced by main().

◆ internal_cs_try()

bool internal_cs_try ( uint8_t idx,
c6_probe_stats_t * st )
static

Assert one candidate chip-select and report any side-band response.

Drives the candidate high, samples, drives it low for a settle period, samples again, restores it high and releases it. A live C6 on the other end answers the falling edge by dropping HANDSHAKE, so a pin that went from high to low between the two samples both proves the candidate is the chip-select and names HANDSHAKE.

Parameters
[in]idxOne-based index into k_c6_wire_pin.
[in,out]stStatistics block; handshake votes accumulate here.
Returns
true when at least one side-band pin dropped.
Return values
trueThe C6 answered this candidate's chip-select edge.
falseNothing on the far end reacted, or the drive failed.
Precondition
The candidate pin is unclaimed and is an input on the C6.
st is non-NULL.
Postcondition
The candidate pin is released before returning.
One console line was printed for this candidate.
Note
Not thread-safe; boot-time diagnostic only.
Since
0.1.0

Definition at line 453 of file c6_sideband.c.

References c6_probe_print_sideband(), c6_probe_puts(), c6_probe_sample_sideband(), c6_probe_stats_t::hs_vote, k_c6_probe_cs_hold_ms, k_c6_probe_settle_ms, k_c6_sb_count, k_c6_wire_label, k_c6_wire_pin, k_ra8_level_high, k_ra8_level_low, k_ra8_ok, c6_sideband_sample_t::level, pin, ra8_delay_ms(), ra8_gpio_output_init(), ra8_gpio_release(), and ra8_gpio_write().

Referenced by c6_probe_cs_hunt().

◆ internal_kick_net()

ra8_err_t internal_kick_net ( ra8_port_pin_t pin,
ra8_level_t level,
uint8_t * out_level )
static

Drive one net to a level, release it, and sample what it settles to.

Claims the pin as a push-pull output at level, holds it long enough for the net to charge, then releases the claim and re-claims it as a no-pull input before sampling. A net with no termination keeps the driven level on its own capacitance for far longer than the settle delay; a terminated net snaps back within microseconds.

Parameters
[in]pinBoard pin to exercise.
[in]levelLevel to drive before releasing.
[out]out_levelLevel read back after release; ignored when NULL.
Returns
ra8_err_t error code.
Return values
k_ra8_okThe net was driven, released and sampled.
k_ra8_err_null_ptrout_level was NULL.
k_ra8_err_gpio_conflictThe pin is owned by another driver.
Precondition
The pin is not currently routed to a peripheral.
out_level is non-NULL.
Postcondition
The pin is released (unclaimed) on every success path.
*out_level is 0 or 1 on success.
Note
Not thread-safe; boot-time diagnostic only.
Since
0.1.0

Definition at line 355 of file c6_sideband.c.

References k_c6_probe_cs_hold_ms, k_ra8_err_null_ptr, k_ra8_level_high, k_ra8_level_low, k_ra8_ok, k_ra8_pull_none, pin, ra8_delay_ms(), ra8_gpio_input_init(), ra8_gpio_output_init(), ra8_gpio_read(), and ra8_gpio_release().

Referenced by c6_probe_wire_test().

◆ internal_pull_read()

ra8_err_t internal_pull_read ( ra8_port_pin_t pin,
uint8_t * out_low )
static

Hold one pin against the internal pull-up and count the low reads.

Releases the probe's no-pull claim, re-claims the pin as an input with the pull-up engaged, samples it, and restores the no-pull claim on every exit path so a failure part-way through cannot leave the run sampling through a pull-up.

Parameters
[in]pinSide-band pin to test.
[out]out_lowNumber of reads that came back low.
Returns
ra8_err_t error code.
Return values
k_ra8_okEvery sample was taken and the pin restored to no-pull.
k_ra8_err_null_ptrout_low was NULL.
k_ra8_err_gpio_conflictThe pin is owned by another driver.
Precondition
The pin is currently claimed as a no-pull input.
out_low is non-NULL.
Postcondition
The pin is a no-pull input again on every success path.
On success *out_low counts a full k_c6_probe_pull_samples reads; a short count is only ever returned alongside an error.
Note
Not thread-safe; boot-time diagnostic only.
Since
0.1.0

Definition at line 231 of file c6_sideband.c.

References k_c6_probe_pull_samples, k_c6_probe_pull_settle_ms, k_ra8_err_null_ptr, k_ra8_level_high, k_ra8_level_low, k_ra8_ok, k_ra8_pull_none, k_ra8_pull_up, pin, ra8_delay_ms(), ra8_gpio_input_init(), ra8_gpio_read(), and ra8_gpio_release().

Referenced by c6_probe_pull_contest().

Variable Documentation

◆ k_c6_sideband_label

const char* const k_c6_sideband_label[k_c6_sb_count+1U]
static
Initial value:
= {
"P006",
"P402",
"P412",
"P413",
"unresolved",
}

Console labels for k_c6_sideband_pin, same order.

A fifth entry backs the "no pin resolved" case so callers never index past the table.

Note
Read-only; used only for log formatting.
Warning
Index with c6_probe_sideband_name, not directly.
Since
0.1.0

Definition at line 67 of file c6_sideband.c.

Referenced by c6_probe_sideband_name().

◆ k_c6_sideband_pin

const ra8_port_pin_t k_c6_sideband_pin[k_c6_sb_count]
static
Initial value:
= {
}
@ k_ra8_board_pmod1_gpio_a
Pmod1.9 GPIO, P412.
@ k_ra8_board_pmod1_gpio_b
Pmod1.10 GPIO, P413.
@ k_ra8_board_pmod1_irq
Pmod1.7 IRQ (IRQ11-DS), P006.
@ k_ra8_board_pmod1_reset
Pmod1.8 RESET, P402.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.

The four Pmod1 side-band pins, in c6_sideband_idx_t order.

Sourced from the board layer so no EK-RA8D2 pin fact is re-encoded here.

Note
Read-only; consumed by c6_probe_sample_sideband.
Warning
Never drive these pins: the C6 drives two of them push-pull.
Since
0.1.0

Definition at line 51 of file c6_sideband.c.

Referenced by c6_probe_pull_contest(), c6_probe_sample_sideband(), and c6_probe_sideband_init().

◆ k_c6_wire_label

const char* const k_c6_wire_label[k_c6_wire_count+1U]
static
Initial value:
= {
"P800(J26-1 in UART mux)",
"P801(J26-2)",
"P802(J26-3)",
"P803(J26-4 in SPI mux)",
"P804(J26-1 in SPI mux)",
"none",
}

Console labels for k_c6_wire_pin, same order.

A sixth entry backs the "no candidate reached the C6" case.

Note
Read-only; used only for log formatting.
Warning
Bounds-check before indexing; the table is one longer than k_c6_wire_count on purpose.
Since
0.1.0

Definition at line 101 of file c6_sideband.c.

Referenced by c6_probe_cs_hunt(), c6_probe_wire_test(), and internal_cs_try().

◆ k_c6_wire_pin

const ra8_port_pin_t k_c6_wire_pin[k_c6_wire_count]
static
Initial value:
= {
}
@ k_ra8_board_pmod1_uart_cts
Pmod1 UART CTS (CTS2), P800.
@ k_ra8_board_pmod1_spi_copi
Pmod1.2 COPI (MOSI2/TXD2 per UM),P801.
@ k_ra8_board_pmod1_spi_sck
Pmod1.4 SCK (SCK2), P803.
@ k_ra8_board_pmod1_spi_cs
Pmod1.1 CS (SS2/IRQ14), P804.
@ k_ra8_board_pmod1_spi_cipo
Pmod1.3 CIPO (MISO2/RXD2 per UM),P802.

The five Pmod1 muxed-net candidates, in c6_wire_idx_t order.

Board pins only; nothing here re-encodes an EK-RA8D2 pin fact.

Note
Read-only; consumed by c6_probe_wire_test and c6_probe_cs_hunt.
Warning
Every entry must be an input on the C6 side, so the probe's brief drive can never contend with the peripheral.
Since
0.1.0

Definition at line 84 of file c6_sideband.c.

Referenced by c6_probe_wire_test(), and internal_cs_try().