rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
inj_line_id.h File Reference

Which of two wires carries SCL, read from I2C (Inter-Integrated Circuit) traffic the injector only listens to. Pure C: the RP2350 build feeds it the edges core 1 recorded on GP4 and GP5, the host suite feeds it synthetic ones. More...

#include <stdbool.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  inj_edge_t
struct  inj_line_result_t

Macros

#define INJ_LINE_GLITCH   2u
#define INJ_LINE_IDLE_NS   10000u
#define INJ_LINE_MIN_TX   20u
#define INJ_LINE_MIN_AGREE_PCT   95u
#define INJ_LINE_GP4   0x1u
#define INJ_LINE_GP5   0x2u

Enumerations

enum  inj_wiring_t {
  INJ_WIRING_NONE = 0 , INJ_WIRING_OK , INJ_WIRING_SWAPPED , INJ_WIRING_IDLE ,
  INJ_WIRING_LOW , INJ_WIRING_NOISE
}

Functions

void inj_line_classify (uint8_t first, const inj_edge_t *edges, uint32_t n, uint32_t samples, uint32_t rate_ksps, inj_line_result_t *out)
const char * inj_wiring_name (inj_wiring_t v)

Detailed Description

Which of two wires carries SCL, read from I2C (Inter-Integrated Circuit) traffic the injector only listens to. Pure C: the RP2350 build feeds it the edges core 1 recorded on GP4 and GP5, the host suite feeds it synthetic ones.

Rules, per transaction (a stretch of activity between two idle spans):

  • Idle is both lines high for at least 10us. A repeated START keeps both high for half a bit: 1.25us at 400kHz, 5us at 100kHz.
  • START: out of idle, the line that falls first is SDA.
  • STOP: into idle, the line that rises last is SDA.
  • A transaction names a line when both rules name it. A transaction cut by the start or the end of the window is not counted.
  • A level that lasts less than INJ_LINE_GLITCH samples is a glitch and is dropped before any rule is applied.

Verdict: at least INJ_LINE_MIN_TX transactions that name a line, and at least half of all transactions; of those that name a line, at least INJ_LINE_MIN_AGREE_PCT percent name the same one. A transaction that names no line, such as a poll of an absent address, is left out of the agreement.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ INJ_LINE_GLITCH

#define INJ_LINE_GLITCH   2u

samples

◆ INJ_LINE_IDLE_NS

#define INJ_LINE_IDLE_NS   10000u

both high this long is idle

◆ INJ_LINE_MIN_AGREE_PCT

#define INJ_LINE_MIN_AGREE_PCT   95u

of them, those that agree

◆ INJ_LINE_MIN_TX

#define INJ_LINE_MIN_TX   20u

transactions that name a line

Function Documentation

◆ inj_line_classify()

void inj_line_classify ( uint8_t first,
const inj_edge_t * edges,
uint32_t n,
uint32_t samples,
uint32_t rate_ksps,
inj_line_result_t * out )

Classify n edges taken over samples samples at rate_ksps ksample/s. first is the state at sample 0; edges are in order of at, each a change from the state before it (a repeat is ignored).

◆ inj_wiring_name()

const char * inj_wiring_name ( inj_wiring_t v)

The verdict's word: ok, swapped, idle, low, noise, or none.