by John Lauer
Two-board Molecule interferometer with onboard RP2040, USB-C data, 15 V USB-C PD power and a JST stage interface.
main
John Lauer
Software 1.3.1: test-stage firmware (J4 TMC2209, HOME, limits, self-test), Stage tab and Calibrate in smi-dash (simulat…
c0c5c9b
// SPDX-License-Identifier: MIT
// Text commands of the board's controller contract (control map,
// firmwareCommands): "laser CODE", "laser off", "laser current", "head MASK",
// "gain MASK", "offset B CODE", "offset C CODE", plus "start", "stop", "info"
// and "hb MS"; "stage ..." lines go to the stage core when the firmware wires it. They run through the control core (smi_ctl.c), so every limit,
// refusal and fault applies; selector and offset commands disarm the laser
// first, as the contract says. Portable: used by the firmware and the host
// stand-in (test/ctl_pty.c).
#ifndef SMI_TEXT_H
#define SMI_TEXT_H
#include "smi_ctl.h"
typedef struct {
smi_ctl_t *ctl;
void *ctx;
uint32_t (*now_us)(void *ctx);
void (*reply)(void *ctx, const char *text); // sent back as an INFO frame
void (*start)(void *ctx);
void (*stop)(void *ctx);
void (*info)(void *ctx);
void (*stage)(void *ctx, const char *line); // "stage ..." commands (smi_stage.c); NULL = absent
int exp_base, gain_base; // "head" mask bit 0 = exp_base, "gain" bit 0 = gain_base
uint16_t laser_cmd; // last accepted laser command code
char line[32]; // line buffer for smi_text_feed
int len;
bool overflow;
} smi_text_t;
void smi_text_command(smi_text_t *x, const char *line);
// Feed one received character; a line ending runs the command. A line longer
// than the buffer is ignored and disarms the laser.
void smi_text_feed(smi_text_t *x, char c);
#endif