|
|
@@ -13,7 +13,6 @@ from jsonschema import Draft202012Validator
|
|
|
|
|
|
|
|
|
PROFILE = "prod2u-normal-multiproject-115200-v1"
|
|
|
-MOTOR_COMPAT_PROFILE = "prod2u-motor-compat-intake-v1"
|
|
|
SCHEMA_PATH = Path(__file__).resolve().parents[1] / "schemas" / "project.schema.json"
|
|
|
SOURCE_CLOSURE_PATH = Path(__file__).resolve().parents[1] / "config" / "source_closure.json"
|
|
|
|
|
|
@@ -185,42 +184,10 @@ def _validate_project(payload: Mapping[str, Any]) -> None:
|
|
|
_keys(boot_targets, {"ptc", "fan"}, "outputs.boot_targets")
|
|
|
_require(boot_targets == {"ptc": 0, "fan": 10}, "boot target mapping mismatch")
|
|
|
|
|
|
- motor_compat = payload["profile"] == MOTOR_COMPAT_PROFILE
|
|
|
doors = _object(payload["doors"], "doors")
|
|
|
- door_keys = {"scope", "chamber_controlled", "intake_actuator", "intake_motor_profile_available", "exhaust_axes", "solenoid"}
|
|
|
- if motor_compat:
|
|
|
- door_keys = door_keys | {"intake_motor"}
|
|
|
- _keys(doors, door_keys, "doors")
|
|
|
- _require(doors["intake_actuator"] in {"solenoid", "motor"}, "invalid intake actuator")
|
|
|
- if motor_compat:
|
|
|
- _require(doors["intake_actuator"] == "motor", "motor-compat profile requires intake_actuator=motor")
|
|
|
- _require(doors["intake_motor_profile_available"] is True, "motor-compat profile must mark intake motor available")
|
|
|
- intake_motor = _object(doors["intake_motor"], "doors.intake_motor")
|
|
|
- _require(intake_motor.get("evidence_status") == "blocked", "intake motor physical mapping must stay blocked")
|
|
|
- _require(intake_motor.get("package") is False, "intake motor must not enter production package/ADC")
|
|
|
- else:
|
|
|
- _require(doors["intake_actuator"] == "solenoid", "default intake actuator must be solenoid")
|
|
|
- solenoid = _object(doors["solenoid"], "doors.solenoid")
|
|
|
- solenoid_keys = {"signal", "evidence_status", "open_level", "closed_level", "inactive_level", "notes"}
|
|
|
- if solenoid.get("ball"):
|
|
|
- solenoid_keys = solenoid_keys | {"ball", "connector", "connector_pin"}
|
|
|
- _keys(solenoid, solenoid_keys, "doors.solenoid")
|
|
|
- _require(solenoid["signal"] == "intake_solenoid_out", "solenoid signal must be intake_solenoid_out")
|
|
|
- _require(solenoid["open_level"] in {"high", "low"} and solenoid["closed_level"] in {"high", "low"}, "invalid solenoid levels")
|
|
|
- _require(solenoid["inactive_level"] in {"high", "low"}, "invalid solenoid inactive level")
|
|
|
- if motor_compat:
|
|
|
- _require(solenoid.get("evidence_status") == "blocked", "motor-compat solenoid must stay blocked")
|
|
|
- _require(not solenoid.get("ball"), "motor-compat solenoid must not bind a package ball")
|
|
|
- elif solenoid.get("ball"):
|
|
|
- _require(
|
|
|
- solenoid["evidence_status"] in {"inferred", "confirmed"},
|
|
|
- "assigned solenoid ball requires inferred or confirmed evidence_status",
|
|
|
- )
|
|
|
- _require(isinstance(solenoid["ball"], str) and solenoid["ball"], "invalid solenoid ball")
|
|
|
- _require(isinstance(solenoid["connector"], str) and solenoid["connector"], "invalid solenoid connector")
|
|
|
- _integer(solenoid["connector_pin"], "doors.solenoid.connector_pin", minimum=1)
|
|
|
- else:
|
|
|
- _require(solenoid.get("evidence_status") == "blocked", "unbound solenoid must stay blocked")
|
|
|
+ _keys(doors, {"scope", "chamber_controlled", "door_axes"}, "doors")
|
|
|
+ door_axes = _list(doors["door_axes"], "doors.door_axes", 3)
|
|
|
+ _require(door_axes == ["x", "y", "z"], "door_axes must be x,y,z")
|
|
|
|
|
|
motors = _object(payload["motors"], "motors")
|
|
|
_keys(
|
|
|
@@ -256,63 +223,67 @@ def _validate_project(payload: Mapping[str, Any]) -> None:
|
|
|
_require(isinstance(motors["command_values"], list) and motors["command_values"], "invalid motor commands")
|
|
|
_require(motors["heartbeat_value"] in motors["command_values"], "motor heartbeat is not a command")
|
|
|
mapping = _object(motors["mapping"], "motors.mapping")
|
|
|
- if motor_compat:
|
|
|
- _require(motors["count"] == 3 and motors["order"] == ["x", "y", "intake"], "motor-compat axis order must be x,y,intake")
|
|
|
- _keys(mapping, {"x", "y", "intake"}, "motors.mapping")
|
|
|
- for axis in ("x", "y"):
|
|
|
- item = _object(mapping[axis], f"motors.mapping.{axis}")
|
|
|
- _keys(item, {"axis", "role", "step_ball", "dir_ball"}, f"motors.mapping.{axis}")
|
|
|
- _require(item["axis"] == axis and item["role"] == "exhaust", f"motor {axis} role mismatch")
|
|
|
- intake_map = _object(mapping["intake"], "motors.mapping.intake")
|
|
|
- _require(intake_map.get("axis") == "intake", "intake mapping axis mismatch")
|
|
|
- _require(intake_map.get("evidence_status") == "blocked", "intake motor balls must stay blocked")
|
|
|
- _require(intake_map.get("package") is False, "intake motor must not enter ADC")
|
|
|
- _require(intake_map.get("step_ball") in (None, ""), "intake step_ball must be unset for non-production")
|
|
|
- _require(intake_map.get("dir_ball") in (None, ""), "intake dir_ball must be unset for non-production")
|
|
|
- else:
|
|
|
- _require(motors["count"] == 2, "production motor count must be 2")
|
|
|
- _keys(mapping, {"x", "y"}, "motors.mapping")
|
|
|
- for axis in ("x", "y"):
|
|
|
- item = _object(mapping[axis], f"motors.mapping.{axis}")
|
|
|
- _keys(item, {"axis", "role", "step_ball", "dir_ball"}, f"motors.mapping.{axis}")
|
|
|
- _require(item["axis"] == axis and item["role"] == "exhaust", f"motor {axis} role mismatch")
|
|
|
+ _require(motors["count"] == 3 and motors["order"] == ["x", "y", "z"], "production motor count/order must be x,y,z")
|
|
|
+ _keys(mapping, {"x", "y", "z"}, "motors.mapping")
|
|
|
+ for axis in ("x", "y", "z"):
|
|
|
+ item = _object(mapping[axis], f"motors.mapping.{axis}")
|
|
|
+ required = {"axis", "role", "step_ball", "dir_ball"}
|
|
|
+ _require(required <= set(item), f"motors.mapping.{axis} missing required keys")
|
|
|
+ _require(item["axis"] == axis and item["role"] == "door", f"motor {axis} role mismatch")
|
|
|
enable = _object(motors["enable_n"], "motors.enable_n")
|
|
|
- _keys(enable, {"ball", "active_level", "policy"}, "motors.enable_n")
|
|
|
+ _require({"ball", "active_level", "policy"} <= set(enable), "motors.enable_n missing required keys")
|
|
|
_require(isinstance(enable["ball"], str) and enable["ball"], "invalid motor enable ball")
|
|
|
_require(enable["active_level"] == "low", "motor enable must be active low")
|
|
|
- _require(enable["policy"] == "shared_constant_low", "motor enable policy mismatch")
|
|
|
+ _require(enable["policy"] == "permanent_high", "motor enable policy must be permanent_high")
|
|
|
|
|
|
limits = _object(payload["limits"], "limits")
|
|
|
_keys(limits, {"limit_count", "active_level", "functional_use", "runtime_use", "startup", "channels"}, "limits")
|
|
|
- expected_limits = 3 if motor_compat else 2
|
|
|
- _require(limits["limit_count"] == len(limits["channels"]) == expected_limits, "limit count/list mismatch")
|
|
|
+ _require(limits["limit_count"] == len(limits["channels"]) == 6, "limit count/list mismatch")
|
|
|
_require(limits["active_level"] == "high" and limits["functional_use"] is True, "limit policy mismatch")
|
|
|
- _require(limits["runtime_use"] is False, "runtime limit use must be false")
|
|
|
+ _require(limits["runtime_use"] is True, "runtime limit use must be true")
|
|
|
startup = _object(limits["startup"], "limits.startup")
|
|
|
- _keys(startup, {"enabled", "direction_value", "direction_meaning", "burst_step_count", "burst_step_rate_hz", "inter_burst_ms", "max_bursts", "axis_order", "limit_stop_during_burst", "stop_semantics", "additional_rising_edges_after_synchronized_limit", "runtime_limit_use"}, "limits.startup")
|
|
|
+ _keys(
|
|
|
+ startup,
|
|
|
+ {
|
|
|
+ "enabled",
|
|
|
+ "direction_value",
|
|
|
+ "direction_meaning",
|
|
|
+ "close_step_count",
|
|
|
+ "backoff_step_count",
|
|
|
+ "step_rate_hz",
|
|
|
+ "axis_order",
|
|
|
+ "limit_stop_during_move",
|
|
|
+ "stop_semantics",
|
|
|
+ "additional_rising_edges_after_synchronized_limit",
|
|
|
+ "runtime_limit_use",
|
|
|
+ },
|
|
|
+ "limits.startup",
|
|
|
+ )
|
|
|
_require(startup["enabled"] is True, "startup must be enabled")
|
|
|
_require(startup["direction_meaning"] == "close", "startup direction must be close")
|
|
|
- _require(startup["limit_stop_during_burst"] is True, "startup limit stop during burst must be enabled")
|
|
|
+ _require(startup["limit_stop_during_move"] is True, "startup limit stop during move must be enabled")
|
|
|
_require(startup["stop_semantics"] == "finish_current_high_pulse_then_no_next_rising_edge", "unsupported stop semantics")
|
|
|
_require(startup["additional_rising_edges_after_synchronized_limit"] == 0, "additional rising edges after limit must be zero")
|
|
|
- _require(startup["runtime_limit_use"] is False, "startup runtime limit use must be false")
|
|
|
+ _require(startup["runtime_limit_use"] is True, "startup runtime limit use must be true")
|
|
|
_integer(startup["direction_value"], "limits.startup.direction_value", minimum=0)
|
|
|
- _integer(startup["burst_step_count"], "limits.startup.burst_step_count", minimum=1)
|
|
|
- _integer(startup["burst_step_rate_hz"], "limits.startup.burst_step_rate_hz", minimum=1)
|
|
|
- _integer(startup["inter_burst_ms"], "limits.startup.inter_burst_ms", minimum=0)
|
|
|
- _integer(startup["max_bursts"], "limits.startup.max_bursts", minimum=1)
|
|
|
- _require(len(startup["axis_order"]) == limits["limit_count"], "startup axis order mismatch")
|
|
|
- if motor_compat:
|
|
|
- _require(startup["axis_order"] == ["x", "y", "intake"], "motor-compat startup axis order mismatch")
|
|
|
+ _integer(startup["close_step_count"], "limits.startup.close_step_count", minimum=1)
|
|
|
+ _integer(startup["backoff_step_count"], "limits.startup.backoff_step_count", minimum=0)
|
|
|
+ _integer(startup["step_rate_hz"], "limits.startup.step_rate_hz", minimum=1)
|
|
|
+ _require(startup["close_step_count"] == 5000, "startup close step count must be 5000")
|
|
|
+ _require(startup["backoff_step_count"] == 500, "startup backoff step count must be 500")
|
|
|
+ _require(len(startup["axis_order"]) == 3 and startup["axis_order"] == ["x", "y", "z"], "startup axis order mismatch")
|
|
|
+ expected_limit_names = [
|
|
|
+ "x_limit_ls",
|
|
|
+ "x_limit_hs",
|
|
|
+ "y_limit_ls",
|
|
|
+ "y_limit_hs",
|
|
|
+ "z_limit_ls",
|
|
|
+ "z_limit_hs",
|
|
|
+ ]
|
|
|
for index, item in enumerate(limits["channels"]):
|
|
|
entry = _object(item, f"limits.channels[{index}]")
|
|
|
- if motor_compat and entry.get("name") == "intake_limit_raw":
|
|
|
- _require(entry.get("evidence_status") == "blocked", "intake limit must stay blocked")
|
|
|
- _require(entry.get("package") is False, "intake limit must not enter ADC")
|
|
|
- _require(entry.get("ball") in (None, ""), "intake limit ball must be unset")
|
|
|
- else:
|
|
|
- _keys(entry, {"name", "ball"}, f"limits.channels[{index}]")
|
|
|
- _require(entry["name"] in {"x_limit_raw", "y_limit_raw"}, "invalid limit name")
|
|
|
+ _keys(entry, {"name", "ball", "connector", "connector_pin", "side"}, f"limits.channels[{index}]")
|
|
|
+ _require(entry["name"] == expected_limit_names[index], "invalid limit channel order/name")
|
|
|
|
|
|
temperature = _object(payload["temperature"], "temperature")
|
|
|
_keys(
|
|
|
@@ -358,8 +329,14 @@ def _validate_project(payload: Mapping[str, Any]) -> None:
|
|
|
"x_dir",
|
|
|
"y_step",
|
|
|
"y_dir",
|
|
|
- "x_limit_raw",
|
|
|
- "y_limit_raw",
|
|
|
+ "z_step",
|
|
|
+ "z_dir",
|
|
|
+ "x_limit_ls",
|
|
|
+ "x_limit_hs",
|
|
|
+ "y_limit_ls",
|
|
|
+ "y_limit_hs",
|
|
|
+ "z_limit_ls",
|
|
|
+ "z_limit_hs",
|
|
|
},
|
|
|
"pins",
|
|
|
)
|
|
|
@@ -371,13 +348,11 @@ def _validate_project(payload: Mapping[str, Any]) -> None:
|
|
|
"FAN pin/list mismatch",
|
|
|
)
|
|
|
_require(pins["motor_en_n"] == enable["ball"], "motor enable pin mismatch")
|
|
|
- _require(pins["x_step"] == mapping["x"]["step_ball"] and pins["x_dir"] == mapping["x"]["dir_ball"], "X motor pin mismatch")
|
|
|
- _require(pins["y_step"] == mapping["y"]["step_ball"] and pins["y_dir"] == mapping["y"]["dir_ball"], "Y motor pin mismatch")
|
|
|
- production_limit_balls = [item["ball"] for item in limits["channels"] if item["name"] in {"x_limit_raw", "y_limit_raw"}]
|
|
|
- _require([pins["x_limit_raw"], pins["y_limit_raw"]] == production_limit_balls, "limit pin mismatch")
|
|
|
- # Motor-compat intake axis/limit must never appear in production pins/ADC.
|
|
|
- pin_blob = json.dumps(dict(pins), sort_keys=True)
|
|
|
- _require("intake" not in pin_blob.lower(), "intake motor/limit must not appear in production pins")
|
|
|
+ for axis in ("x", "y", "z"):
|
|
|
+ _require(pins[f"{axis}_step"] == mapping[axis]["step_ball"], f"{axis} step pin mismatch")
|
|
|
+ _require(pins[f"{axis}_dir"] == mapping[axis]["dir_ball"], f"{axis} dir pin mismatch")
|
|
|
+ for channel in limits["channels"]:
|
|
|
+ _require(pins[channel["name"]] == channel["ball"], f"{channel['name']} pin mismatch")
|
|
|
|
|
|
resources = _object(payload["resource_policy"], "resource_policy")
|
|
|
_keys(
|
|
|
@@ -430,7 +405,7 @@ def _validate_project(payload: Mapping[str, Any]) -> None:
|
|
|
"fan_offset",
|
|
|
"chamber_ptc_offset",
|
|
|
"chamber_ptc_count",
|
|
|
- "intake_door_offset",
|
|
|
+ "z_door_offset",
|
|
|
"exhaust_x_offset",
|
|
|
"exhaust_y_offset",
|
|
|
"legacy_payload_length_rejected",
|
|
|
@@ -444,8 +419,8 @@ def _validate_project(payload: Mapping[str, Any]) -> None:
|
|
|
_require(set_all["fan_offset"] == 0, "SET_ALL FAN offset mismatch")
|
|
|
_require(set_all["chamber_ptc_offset"] == outputs["fan_count"], "SET_ALL chamber PTC offset mismatch")
|
|
|
_require(set_all["chamber_ptc_count"] == outputs["chamber_ptc_count"], "SET_ALL chamber PTC count mismatch")
|
|
|
- _require(set_all["intake_door_offset"] == set_all["chamber_ptc_offset"] + set_all["chamber_ptc_count"], "SET_ALL intake offset mismatch")
|
|
|
- _require(set_all["exhaust_x_offset"] == set_all["intake_door_offset"] + 1, "SET_ALL exhaust X offset mismatch")
|
|
|
+ _require(set_all["z_door_offset"] == set_all["chamber_ptc_offset"] + set_all["chamber_ptc_count"], "SET_ALL Z offset mismatch")
|
|
|
+ _require(set_all["exhaust_x_offset"] == set_all["z_door_offset"] + 1, "SET_ALL exhaust X offset mismatch")
|
|
|
_require(set_all["exhaust_y_offset"] == set_all["exhaust_x_offset"] + 1, "SET_ALL exhaust Y offset mismatch")
|
|
|
_require(set_all["payload_length"] == set_all["exhaust_y_offset"] + 1, "SET_ALL length mismatch")
|
|
|
_require(set_all["legacy_payload_length_rejected"] == 14, "legacy payload length marker mismatch")
|
|
|
@@ -478,11 +453,6 @@ def load_project(path: Path) -> dict[str, Any]:
|
|
|
project_path = Path(path)
|
|
|
payload = json.loads(project_path.read_text(encoding="utf-8"))
|
|
|
_require(isinstance(payload, dict), "project root must be an object")
|
|
|
- # Motor-compat is a non-production variant; validate via Python contract, not the
|
|
|
- # production JSON schema (which freezes the 2-axis solenoid package).
|
|
|
- if payload.get("profile") == MOTOR_COMPAT_PROFILE:
|
|
|
- _validate_project(payload)
|
|
|
- return payload
|
|
|
schema = json.loads(SCHEMA_PATH.read_text(encoding="utf-8"))
|
|
|
errors = sorted(Draft202012Validator(schema).iter_errors(payload), key=lambda error: list(error.absolute_path))
|
|
|
if errors:
|
|
|
@@ -496,12 +466,6 @@ def _active_interface(project: Mapping[str, Any]) -> tuple[tuple[str, str], ...]
|
|
|
outputs = project["outputs"]
|
|
|
pins = project["pins"]
|
|
|
motors = project["motors"]
|
|
|
- # Base interface: clock+UART+I2C+PWM+EN+X/Y STEP/DIR+X/Y limit.
|
|
|
- # Intake motor / intake limit stay blocked. Production solenoid LOCs only when
|
|
|
- # doors.solenoid.ball is assigned with non-blocked evidence_status.
|
|
|
- limit_channels = [
|
|
|
- item for item in project["limits"]["channels"] if item["name"] in {"x_limit_raw", "y_limit_raw"}
|
|
|
- ]
|
|
|
interface = (
|
|
|
("sys_clk", project["device"]["clock_ball"]),
|
|
|
("host_uart_rx", pins["host_uart_rx"]),
|
|
|
@@ -515,12 +479,10 @@ def _active_interface(project: Mapping[str, Any]) -> tuple[tuple[str, str], ...]
|
|
|
("x_dir", motors["mapping"]["x"]["dir_ball"]),
|
|
|
("y_step", motors["mapping"]["y"]["step_ball"]),
|
|
|
("y_dir", motors["mapping"]["y"]["dir_ball"]),
|
|
|
- *tuple((item["name"], item["ball"]) for item in limit_channels),
|
|
|
+ ("z_step", motors["mapping"]["z"]["step_ball"]),
|
|
|
+ ("z_dir", motors["mapping"]["z"]["dir_ball"]),
|
|
|
+ *tuple((item["name"], item["ball"]) for item in project["limits"]["channels"]),
|
|
|
)
|
|
|
- solenoid = project["doors"]["solenoid"]
|
|
|
- ball = solenoid.get("ball")
|
|
|
- if ball and solenoid.get("evidence_status") != "blocked":
|
|
|
- interface = interface + ((solenoid["signal"], ball),)
|
|
|
return interface
|
|
|
|
|
|
|
|
|
@@ -599,19 +561,17 @@ def _render_params(project: Mapping[str, Any]) -> str:
|
|
|
temperature = project["temperature"]
|
|
|
uart = project["uart"]
|
|
|
watchdog = project["watchdog"]
|
|
|
- motor_compat = project["profile"] == MOTOR_COMPAT_PROFILE
|
|
|
- axis_count = 3 if motor_compat else 2
|
|
|
- intake_solenoid = 0 if motor_compat else 1
|
|
|
+ axis_count = motors["count"]
|
|
|
_require(motors["dir_setup_cycles"] % watchdog["tick_clks"] == 0, "motor direction setup is not an integral tick count")
|
|
|
motor_dir_setup_ticks = motors["dir_setup_cycles"] // watchdog["tick_clks"]
|
|
|
frame_inter_byte_timeout_cycles = project["device"]["clock_hz"] * project["timeouts"]["frame_inter_byte_ms"] // 1000
|
|
|
- startup_inter_burst_ticks = startup["inter_burst_ms"] * 1000 // watchdog["tick_us"]
|
|
|
startup_dir_bit = startup["direction_value"]
|
|
|
startup_dir_mask = f"{axis_count}'b" + (str(startup_dir_bit) * axis_count)
|
|
|
lines = [
|
|
|
"// Generated from project.json. Do not edit.",
|
|
|
- f"`define P4_PROFILE_MOTOR_COMPAT {1 if motor_compat else 0}",
|
|
|
f"`define P4_AXIS_COUNT {axis_count}",
|
|
|
+ f"`define P4_LIMIT_COUNT {limits['limit_count']}",
|
|
|
+ f"`define P4_RUNTIME_LIMIT_USE {1 if limits['runtime_use'] else 0}",
|
|
|
f"`define P4_CLOCK_HZ {project['device']['clock_hz']}",
|
|
|
f"`define P4_UART_BAUD {uart['baud']}",
|
|
|
f"`define P4_UART_CLKS_PER_BIT {uart['clks_per_bit']}",
|
|
|
@@ -628,10 +588,9 @@ def _render_params(project: Mapping[str, Any]) -> str:
|
|
|
f"`define P4_CHAMBER_PTC_COUNT {outputs['chamber_ptc_count']}",
|
|
|
f"`define P4_SET_ALL_FAN_OFFSET {project['protocol']['set_all']['fan_offset']}",
|
|
|
f"`define P4_SET_ALL_CHAMBER_PTC_OFFSET {project['protocol']['set_all']['chamber_ptc_offset']}",
|
|
|
- f"`define P4_SET_ALL_INTAKE_DOOR_OFFSET {project['protocol']['set_all']['intake_door_offset']}",
|
|
|
+ f"`define P4_SET_ALL_Z_DOOR_OFFSET {project['protocol']['set_all']['z_door_offset']}",
|
|
|
f"`define P4_SET_ALL_EXHAUST_X_OFFSET {project['protocol']['set_all']['exhaust_x_offset']}",
|
|
|
f"`define P4_SET_ALL_EXHAUST_Y_OFFSET {project['protocol']['set_all']['exhaust_y_offset']}",
|
|
|
- f"`define P4_INTAKE_ACTUATOR_SOLENOID {intake_solenoid}",
|
|
|
f"`define P4_MOTOR_OPEN_DIR 1'b{motors['open_dir_value']}",
|
|
|
f"`define P4_MOTOR_CLOSE_DIR 1'b{motors['close_dir_value']}",
|
|
|
f"`define P4_FRAME_INTER_BYTE_TIMEOUT_CYCLES {frame_inter_byte_timeout_cycles}",
|
|
|
@@ -657,9 +616,10 @@ def _render_params(project: Mapping[str, Any]) -> str:
|
|
|
f"`define P4_WATCHDOG_FAN_TARGET 8'h{watchdog['target']['fan']:02X}",
|
|
|
f"`define P4_STARTUP_ENABLED {1 if startup['enabled'] else 0}",
|
|
|
f"`define P4_STARTUP_DIR_MASK {startup_dir_mask}",
|
|
|
- f"`define P4_STARTUP_BURST_STEPS {startup['burst_step_count']}",
|
|
|
- f"`define P4_STARTUP_MAX_BURSTS {startup['max_bursts']}",
|
|
|
- f"`define P4_STARTUP_INTER_BURST_TICKS {startup_inter_burst_ticks}",
|
|
|
+ f"`define P4_STARTUP_CLOSE_STEPS {startup['close_step_count']}",
|
|
|
+ f"`define P4_STARTUP_BACKOFF_STEPS {startup['backoff_step_count']}",
|
|
|
+ f"`define P4_STARTUP_STEP_RATE_HZ {startup['step_rate_hz']}",
|
|
|
+ f"`define P4_MOTOR_ENABLE_POLICY_PERMANENT_HIGH {1 if motors['enable_n']['policy'] == 'permanent_high' else 0}",
|
|
|
]
|
|
|
lines.extend(
|
|
|
f"`define P4_TEMP_DEVICE_ADDR_{index} 7'h{address:02X}"
|
|
|
@@ -697,8 +657,9 @@ def generate_project(project_path: Path, output_root: Path) -> dict[str, Any]:
|
|
|
"schema": "prod2u-simple-host-contract-v1",
|
|
|
"project_id": project["project_id"],
|
|
|
"profile": project["profile"],
|
|
|
- "intake_actuator": project["doors"]["intake_actuator"],
|
|
|
- "axis_count": 3 if project["profile"] == MOTOR_COMPAT_PROFILE else 2,
|
|
|
+ "axis_count": project["motors"]["count"],
|
|
|
+ "limit_count": project["limits"]["limit_count"],
|
|
|
+ "runtime_limit_use": project["limits"]["runtime_use"],
|
|
|
"uart": project["uart"],
|
|
|
"protocol": project["protocol"],
|
|
|
"commands": {
|
|
|
@@ -717,9 +678,9 @@ def generate_project(project_path: Path, output_root: Path) -> dict[str, Any]:
|
|
|
"ptc_chamber_2",
|
|
|
"ptc_chamber_3",
|
|
|
"ptc_chamber_4",
|
|
|
- "intake_door",
|
|
|
- "exhaust_x",
|
|
|
- "exhaust_y",
|
|
|
+ "door_z",
|
|
|
+ "door_x",
|
|
|
+ "door_y",
|
|
|
],
|
|
|
},
|
|
|
"get_temperature": {"type": "0x02", "payload_length": 0, "response": "TEMPERATURE_DATA"},
|
|
|
@@ -747,76 +708,25 @@ def generate_project(project_path: Path, output_root: Path) -> dict[str, Any]:
|
|
|
"all_invalid_temperature": _frame_hex(0x82, bytes([0xFF] * project["temperature"]["value_count"])),
|
|
|
},
|
|
|
)
|
|
|
- # Production TD source closure is solenoid-only; motor-compat keeps a separate
|
|
|
- # non-production note rather than mutating the active TD manifest.
|
|
|
- if project["profile"] == MOTOR_COMPAT_PROFILE:
|
|
|
- sources = [
|
|
|
- f"src/generated/{params_name}",
|
|
|
- "src/common/uart_rx_byte.v",
|
|
|
- "src/common/uart_tx_byte.v",
|
|
|
- "src/common/crc16_serial.v",
|
|
|
- "src/common/frame_rx.v",
|
|
|
- "src/common/frame_tx.v",
|
|
|
- "src/common/payload_ram.v",
|
|
|
- "src/modules/output_target_ram.v",
|
|
|
- "src/modules/pwm_scheduler.v",
|
|
|
- "src/modules/shared_500us_tick.v",
|
|
|
- "src/modules/host_watchdog.v",
|
|
|
- "src/modules/startup_close_seek.v",
|
|
|
- "src/modules/door_motor_engine.v",
|
|
|
- "src/modules/door_action_dispatcher.v",
|
|
|
- "src/modules/i2c_word_reader.v",
|
|
|
- "src/modules/temperature_reader.v",
|
|
|
- "src/modules/temperature_ram.v",
|
|
|
- "src/project/command_controller.v",
|
|
|
- "src/project/project_adapter_motor_compat.v",
|
|
|
- "src/rtl/prod2u_por.v",
|
|
|
- "src/rtl/prod2u_p4_i2c_stop_start_read.v",
|
|
|
- "src/top/prod2u_p4_motor_compat_top.v",
|
|
|
- ]
|
|
|
- source_payload = {
|
|
|
- "schema": "prod2u-simple-source-manifest-template-v1",
|
|
|
- "project_id": project["project_id"],
|
|
|
- "profile": project["profile"],
|
|
|
- "production": False,
|
|
|
- "sources": sources,
|
|
|
- "generated_from": "project.json",
|
|
|
- "contract": {
|
|
|
- "uart": project["uart"],
|
|
|
- "protocol": project["protocol"],
|
|
|
- "set_all_payload_length": summary["set_all_payload_len"],
|
|
|
- "temperature_frame_length": summary["temperature_frame_len"],
|
|
|
- "axis_count": 3,
|
|
|
- "intake_actuator": "motor",
|
|
|
- },
|
|
|
- "active_interface": [
|
|
|
- {"signal": signal, "ball": ball}
|
|
|
- for signal, ball in render_adc(project)
|
|
|
- ],
|
|
|
- "blocked_physical": [
|
|
|
- "intake_step",
|
|
|
- "intake_dir",
|
|
|
- "intake_limit_raw",
|
|
|
- "intake_solenoid_out",
|
|
|
- ],
|
|
|
- }
|
|
|
- else:
|
|
|
- source_payload = {
|
|
|
- "schema": "prod2u-simple-source-manifest-template-v1",
|
|
|
- "project_id": project["project_id"],
|
|
|
- "sources": list(_load_source_closure()),
|
|
|
- "generated_from": "project.json",
|
|
|
- "contract": {
|
|
|
- "uart": project["uart"],
|
|
|
- "protocol": project["protocol"],
|
|
|
- "set_all_payload_length": summary["set_all_payload_len"],
|
|
|
- "temperature_frame_length": summary["temperature_frame_len"],
|
|
|
- },
|
|
|
- "active_interface": [
|
|
|
- {"signal": signal, "ball": ball}
|
|
|
- for signal, ball in render_adc(project)
|
|
|
- ],
|
|
|
- }
|
|
|
+ source_payload = {
|
|
|
+ "schema": "prod2u-simple-source-manifest-template-v1",
|
|
|
+ "project_id": project["project_id"],
|
|
|
+ "sources": list(_load_source_closure()),
|
|
|
+ "generated_from": "project.json",
|
|
|
+ "contract": {
|
|
|
+ "uart": project["uart"],
|
|
|
+ "protocol": project["protocol"],
|
|
|
+ "set_all_payload_length": summary["set_all_payload_len"],
|
|
|
+ "temperature_frame_length": summary["temperature_frame_len"],
|
|
|
+ "axis_count": project["motors"]["count"],
|
|
|
+ "limit_count": project["limits"]["limit_count"],
|
|
|
+ "runtime_limit_use": project["limits"]["runtime_use"],
|
|
|
+ },
|
|
|
+ "active_interface": [
|
|
|
+ {"signal": signal, "ball": ball}
|
|
|
+ for signal, ball in render_adc(project)
|
|
|
+ ],
|
|
|
+ }
|
|
|
_write_json(output / "td-source-manifest.json", source_payload)
|
|
|
(output / f"{project['project_id'].replace('-', '_')}.adc").write_text(
|
|
|
render_adc_text(project), encoding="ascii", newline="\n"
|