code wiki / (root) / nx_robot_signal.nx

nx_robot_signal.nx

buildroot/runtime/nx_robot_signal.nx

4299 B94 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind librarytopic robot
docsdependenciesstructsconstsfunctions

about

nx_robot_signal.nx -- SOVEREIGN hardware SIGNAL/REGISTER rung (the lowest robot-control layer, beneath the driver). A real stepper driver chip (A4988/DRV8825 class) does NOT consume an integer "output" -- it consumes a STEP/DIR digital WAVEFORM on GPIO pins: a rising edge on STEP = one motor micro-step, DIR level = direction. A servo/ESC consumes a PWM bit pattern. This rung MODELS the GPIO register and GENERATES those actual signals from the pulse plan (nx_robot_step, the rung above feeds DOWN into this one) -- building from the hardware rung up. 100% Nishi, integer-only. NEVER-BRICK (#26) BY CONSTRUCTION at the register level: * a write to a NON-allowed pin is REJECTED (can't poke arbitrary hardware registers); * a pin level is normalized to {0,1} (can't write a garbage register value); * PWM duty is clamped to [0, PERIOD] (can't command an out-of-range / >100% pulse). GPIO modeled as arrays (pins[bit]=level, allowed[bit]=writable?) = a faithful register model with no undefined bit-twiddling. Binding pins[] to a real board's MMIO base address is the bench step. license_tier: ORIGINAL expect_exit: 0

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_robot_step.nx nx_robot_signal.nx nx_robot_signal_gate.nx

imports: nx_syscalls.nxnx_robot_step.nx

imported by: nx_robot_signal_gate.nx

structs

none

consts

17const SIG_STEP_BIT: i64 = 0
18const SIG_DIR_BIT: i64 = 1
19const SIG_PWM_PERIOD: i64 = 100

functions

22func gpio_new(nbits: i64) -> *i64
called by 1: main calls 1: sys_mmap
30func gpio_write(pins: *i64, allowed: *i64, bit: i64, level: i64) -> i64
called by 2: gen_step_dirmain
38func gpio_write_raw(pins: *i64, bit: i64, level: i64) -> i64 { pins[bit] = level; return level }
called by 1: main
39func gpio_read(pins: *i64, bit: i64) -> i64 { return pins[bit] }
called by 1: main
44func gen_step_dir(puls: *i64, naxes: i64, nt: i64, axis: i64, dir: i64,
called by 1: main calls 1: gpio_write
65func count_rising(trace: *i64, nw: i64, bit: i64) -> i64
called by 1: main
82func gen_pwm(duty: i64, pat: *i64) -> i64
called by 1: main
90func count_high(pat: *i64, n: i64) -> i64
called by 1: main