rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
iomcu.h
Go to the documentation of this file.
1
26#ifndef IOMCU_H
27#define IOMCU_H
28
29#include <stdbool.h>
30#include <stdint.h>
31#include <string.h>
32
33#include "hardware/gpio.h"
34
35#include "heartbeat.h"
36#include "hitec_line.h"
37#include "hitec_port.h"
38#include "iomcu_pins.h"
39#include "kst_line.h"
40#include "kst_port.h"
41#include "link_dev.h"
42#include "link_pages.h"
43#include "out_stage.h"
44#include "out_store.h"
45#include "outputs.h"
46#include "outputs_hw.h"
47#include "pdmini.h"
48#include "prog_port.h"
49#include "safety_gate.h"
50#include "sense_core1.h"
51#include "sense_page.h"
52#include "servo_page.h"
53#include "supply_page.h"
54#include "tone_page.h"
55
56/* ------------------------------------------------------------- the pages */
57
61typedef struct {
62 uint16_t identity[LINK_ID_COUNT];
63 uint16_t control[LINK_CT_COUNT];
64 uint16_t status[LINK_ST_COUNT];
65 uint16_t bench[LINK_BN_COUNT];
66 uint16_t channels[LINK_CH_COUNT]; /* what each output is asked for */
67 uint16_t chan_cfg[LINK_CC_COUNT];
68 uint16_t slots[LINK_OS_COUNT];
70
75
79#define IOMCU_CAPABILITIES \
80 ((uint16_t)(LINK_CAP_SERVO_PWM | LINK_CAP_ESC_DRIVE | LINK_CAP_ESC_TELEM))
81
92extern supply_page_t s_supply;
93extern pdmini_t s_pd;
94extern bool s_pd_open; /* the UART claimed for its pins */
95extern uint8_t s_pd_rate;
100extern bool s_supply_unsaved;
104extern bool s_supply_attach;
112extern sense_page_t s_sense;
120extern tone_page_t s_tone;
129extern sense_cmd_t s_sense_cmd; /* core 1's order as last built */
134extern uint16_t s_run_gen;
139extern bool s_edge_set;
140extern uint16_t s_edge_gen;
141extern uint64_t s_edge_us;
146extern uint64_t s_base_reserved;
154extern prog_port_t s_prog;
159#define IOMCU_PROG_PORTS 4u
168extern kst_port_t s_kst;
169extern kst_line_t s_kst_line;
178extern hitec_port_t s_hitec;
179extern hitec_line_t s_hitec_line;
180extern link_dev_t s_dev;
181
194extern outputs_t s_outputs;
195
196#define CH_THROTTLE LINK_OUT_CHANNELS /* bank channel 8, off the page */
197
205
209extern uint32_t s_frames;
210
220extern uint32_t s_refused;
221
241extern uint32_t s_now_ms;
242
246extern bool s_beat_level;
247
252extern bool s_can_up;
253extern uint32_t s_can_echoes;
254extern uint32_t s_can_overflows;
255
259extern uint32_t s_last_rx_ms;
260
264extern out_stage_t s_stage;
265
266/* ------------------------------------------------------- the page handlers */
267
268/* iomcu_pages.c */
277void identity_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
286void control_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
296uint8_t control_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in);
305void status_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
314void bench_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
323void channels_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
333uint8_t channels_write(void *ctx, uint8_t off, uint8_t n,
334 const uint16_t *in);
343void chan_cfg_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
353uint8_t chan_cfg_write(void *ctx, uint8_t off, uint8_t n,
354 const uint16_t *in);
363void slots_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
373uint8_t slots_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in);
382void servo_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
392uint8_t servo_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in);
401void prog_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
411uint8_t prog_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in);
412
413/* iomcu_kst.c */
422void kst_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
432uint8_t kst_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in);
433
434/* iomcu_hitec.c */
443void hitec_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
453uint8_t hitec_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in);
454
455/* iomcu_sense.c */
464void supply_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
474uint8_t supply_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in);
483void sense_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
493uint8_t sense_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in);
502void servo_sense_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
512uint8_t servo_sense_write(void *ctx, uint8_t off, uint8_t n,
513 const uint16_t *in);
522void servo_win_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
531void sense_map_rd(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
541uint8_t sense_map_wr(void *ctx, uint8_t off, uint8_t n, const uint16_t *in);
550void sense_win_a_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
559void sense_win_b_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
568void sense_limit_rd(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
578uint8_t sense_limit_wr(void *ctx, uint8_t off, uint8_t n,
579 const uint16_t *in);
580
581/* iomcu_tone.c */
590void tone_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
600uint8_t tone_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in);
601
602/* iomcu_bind.c */
611void bind_cfg_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
621uint8_t bind_cfg_write(void *ctx, uint8_t off, uint8_t n,
622 const uint16_t *in);
631void bind_out_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
641uint8_t bind_out_write(void *ctx, uint8_t off, uint8_t n,
642 const uint16_t *in);
651void bind_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
661uint8_t bind_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in);
670void catalogue_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
679void shape_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
688void artwork_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
697void art_data_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
707uint8_t art_data_write(void *ctx, uint8_t off, uint8_t n,
708 const uint16_t *in);
717void pads_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out);
718
719/* ---------------------------------------------- shared between the files */
720
721/* iomcu_pages.c */
727void save_outputs(const iomcu_state_t *s);
731void ports_apply(void);
739void hw_apply_only(uint8_t may_bind);
743void hw_apply(void);
755uint8_t chan_cfg_take(iomcu_state_t *s, const uint16_t *next,
756 const uint16_t *slots, bool save);
766uint8_t slots_take(iomcu_state_t *s, const uint16_t *next, bool save);
767
768/* iomcu_kst.c: the port's hardware, which main() hands to kst_port_init() */
777uint8_t kst_hw_pin(void *ctx, uint8_t port);
786bool kst_hw_take(void *ctx, uint8_t port, uint8_t pin);
792void kst_hw_give(void *ctx);
799void kst_hw_supply(void *ctx, supply_port_view_t *out);
813bool kst_hw_supply_set(void *ctx, bool on, uint16_t mv, uint16_t ma);
814
815/* iomcu_hitec.c: the port's hardware, which main() hands to
816 * hitec_port_init() beside kst_hw_pin() and the supply's two */
828bool hitec_hw_take(void *ctx, uint8_t port, uint8_t pin, uint8_t family,
829 uint8_t drive, uint8_t rx);
835void hitec_hw_give(void *ctx);
841void hitec_hw_abort(void *ctx);
848void hitec_hw_run(void *ctx, hitec_port_run_t *out);
849
850/* iomcu_sense.c */
854void capabilities_update(void);
861bool supply_rewire(void);
873uint8_t supply_take(uint8_t off, uint8_t n, const uint16_t *in,
874 bool checked);
875
876/* iomcu_tone.c */
883uint64_t tone_taken(void);
890bool tone_rewire(void);
891
892/* iomcu_can.c */
896void heartbeat_init(void);
903void can_start(void);
910void can_service(uint32_t now);
911
912/* iomcu_report.c: every 3s at most, from the main loop */
918void can_report(uint32_t now);
919
928void reset_start(void);
929
930/* ------------------------------------------------------ the inline helpers */
931
940static inline void status_gate(iomcu_state_t *s)
941{
942 uint16_t faults = 0;
943 safety_gate_status(&s_beat, &s_dev, s->control,
944 &s->status[LINK_ST_STATE], &faults);
945 if (out_store_is_off()) {
946 faults |= (uint16_t)LINK_FAULT_STORE_OFF;
947 }
948 s->status[LINK_ST_FAULTS] = faults;
949}
950
956static inline uint8_t bound_slots(void)
957{
958 uint8_t bound = 0u;
959 for (uint8_t i = 0; i < OUT_MAX_SLOTS; ++i) {
960 if (outputs_hw_bound(i)) {
961 bound |= (uint8_t)(1u << i);
962 }
963 }
964 return bound;
965}
966
975static inline bool heartbeat_edge(void)
976{
977 const bool level = gpio_get(IOMCU_HEARTBEAT_PIN);
978 if (level == s_beat_level) {
979 return false;
980 }
981 s_beat_level = level;
982 return true;
983}
984
991static inline uint8_t ports_quiet(void)
992{
993 return (uint8_t)(kst_port_quiet_mask(&s_kst)
995}
996
1002static inline uint8_t ports_wire(void)
1003{
1004 return (uint8_t)(kst_port_pin_mask(&s_kst)
1006}
1007
1019
1026static inline bool ports_hold_supply(void)
1027{
1030}
1031
1038static inline uint8_t ports_pulsing(void)
1039{
1040 return (uint8_t)(prog_port_pwm(&s_prog) & outputs_hw_ports_bound()
1041 & ~ports_quiet());
1042}
1043
1049static inline void reserve_held(void)
1050{
1052 | supply_page_pins(&s_supply)
1056}
1057
1063static inline void sense_build(sense_cmd_t *cmd)
1064{
1065 memset(cmd, 0, sizeof(*cmd));
1066 sense_page_cmd(&s_sense, cmd);
1067 cmd->run_gen = s_run_gen;
1068 cmd->edge_set = s_edge_set && s_edge_gen == s_sense.cap_gen;
1069 cmd->edge_us = s_edge_us;
1070}
1071
1080static inline void sense_order(void)
1081{
1082 sense_build(&s_sense_cmd);
1083 sense_core1_order(&s_sense_cmd);
1084}
1085
1093static inline void sense_sync(void)
1094{
1096 return;
1097 }
1098 const uint64_t was = s_sense.held;
1100 if (s_sense.held != was) {
1101 reserve_held();
1102 }
1103}
1104
1105#endif /* IOMCU_H */
#define s
Short name for esc_stick_s inside the five stick-class files.
Definition esc_stick_panel_int.h:295
The safety heartbeat: the panel's signal that it is running, and the IOmcu's judgement of whether to ...
The Hitec wire on one RP2350 pin: a hitec_driver_t made of one PIO (programmable input/output) state ...
bool hitec_port_supply_hold(const hitec_port_t *p)
The port holds the SUPPLY page (supply_page_hold()): every state but LINK_HITEC_FREE,...
Definition hitec_port.c:968
uint8_t hitec_port_quiet_mask(const hitec_port_t *p)
Bit n: programming port n renders no PWM pulse.
Definition hitec_port.c:943
uint8_t hitec_port_pin_mask(const hitec_port_t *p)
Bit n: programming port n's pin is the wire driver's.
Definition hitec_port.c:949
void hitec_port_other_mask(hitec_port_t *p, uint8_t mask)
Bit n: the KST page holds programming port n (kst_port_quiet_mask()). OPEN on it is refused with LINK...
Definition hitec_port.c:961
Raw transactions of the Hitec servo wire on a programming port, and their link page (0x34).
uint8_t bind_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the BIND page.
Definition iomcu_bind.c:131
bool s_supply_unsaved
Wiring taken and not yet in flash: no ON until it is, so a restart in the run finds the wiring that d...
Definition main.c:76
servo_page_t s_servo
The SERVO page: the PWM target's frame rate and the sweep.
Definition main.c:71
bool kst_hw_take(void *ctx, uint8_t port, uint8_t pin)
Takes the programming port's pin for the KST wire driver.
Definition iomcu_kst.c:31
void bind_out_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the BIND_OUT page.
Definition iomcu_bind.c:50
void sense_map_rd(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the SENSE_MAP page.
Definition iomcu_sense.c:228
bool s_can_up
The CAN controller, its echoes and its receive overruns; see iomcu_can.c.
Definition iomcu_can.c:67
iomcu_state_t s_state
The register images of the pages in iomcu_state_t.
Definition main.c:70
uint32_t s_frames
Requests this end has answered, published on the STATUS page.
Definition main.c:95
uint8_t hitec_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the HITEC page.
Definition iomcu_hitec.c:63
static void sense_order(void)
Sent whenever something in it changes; core 1 takes it at its next tick.
Definition iomcu.h:1080
void slots_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the OUTPUTS page.
Definition iomcu_pages.c:321
void kst_hw_supply(void *ctx, supply_port_view_t *out)
Fills the supply view of the KST port.
Definition iomcu_kst.c:48
void art_data_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the ART_DATA page.
Definition iomcu_bind.c:223
void kst_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the KST page.
Definition iomcu_kst.c:66
void hitec_hw_run(void *ctx, hitec_port_run_t *out)
Reports the timing of the last HITEC run.
Definition iomcu_hitec.c:49
void sense_win_b_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the SENSE_WIN_B page.
Definition iomcu_sense.c:270
heartbeat_mon_t s_beat
The panel's safety line, as judged in firmware.
Definition main.c:94
void hw_apply(void)
Makes the silicon agree with the bank, binding every slot.
Definition iomcu_pages.c:243
bool supply_rewire(void)
Rebinds the supply's PD mini UART to the wiring in force.
Definition iomcu_sense.c:36
void artwork_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the ARTWORK page.
Definition iomcu_bind.c:200
void servo_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the SERVO page.
Definition iomcu_pages.c:409
static void sense_build(sense_cmd_t *cmd)
Core 1's order, from the page as it stands, the run and the edge.
Definition iomcu.h:1063
static uint8_t ports_quiet(void)
The programming ports out of PWM: held by the KST page or the HITEC page, in any state but PWM and fr...
Definition iomcu.h:991
uint8_t supply_take(uint8_t off, uint8_t n, const uint16_t *in, bool checked)
Takes a SUPPLY write into the supply's wiring and output state.
Definition iomcu_sense.c:93
void can_service(uint32_t now)
Empties the CAN receive buffers and answers each frame.
Definition iomcu_can.c:97
uint8_t chan_cfg_take(iomcu_state_t *s, const uint16_t *next, const uint16_t *slots, bool save)
Takes a whole CHAN_CFG page into force, when it passes the checks.
Definition iomcu_pages.c:274
static uint8_t ports_pulsing(void)
The ports that render their pulse while the bank drives: bound, switched on, and not out of PWM for a...
Definition iomcu.h:1038
static uint8_t ports_wire(void)
The programming ports whose pin a wire driver holds.
Definition iomcu.h:1002
void hw_apply_only(uint8_t may_bind)
Makes the silicon agree with the bank, binding only the slots in may_bind.
Definition iomcu_pages.c:231
void servo_win_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the SERVO_WIN page.
Definition iomcu_sense.c:310
void hitec_hw_give(void *ctx)
Gives the programming port's pin back from the HITEC wire driver.
Definition iomcu_hitec.c:36
void hitec_hw_abort(void *ctx)
Aborts the HITEC operation in progress.
Definition iomcu_hitec.c:43
bool tone_rewire(void)
Makes the phase tap's capture agree with the TONE page's pin.
Definition iomcu_tone.c:102
uint8_t bind_cfg_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the BIND_CFG page.
Definition iomcu_bind.c:43
uint8_t tone_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the TONE page.
Definition iomcu_tone.c:128
void bind_cfg_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the BIND_CFG page.
Definition iomcu_bind.c:37
void channels_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the CHANNELS page.
Definition iomcu_pages.c:108
out_stage_t s_stage
The binding BIND_CFG and BIND_OUT hold prepared; see iomcu_bind.c.
Definition iomcu_bind.c:30
void bind_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the BIND page.
Definition iomcu_bind.c:122
static void sense_sync(void)
Core 1's newest snapshot into the pages, when there is one.
Definition iomcu.h:1093
uint8_t kst_hw_pin(void *ctx, uint8_t port)
Returns the pin of a programming port for the KST wire driver.
Definition iomcu_kst.c:22
void save_outputs(const iomcu_state_t *s)
Asks for the output configuration to be saved.
Definition iomcu_pages.c:85
uint8_t chan_cfg_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the CHAN_CFG page.
Definition iomcu_pages.c:308
static void status_gate(iomcu_state_t *s)
STATUS's state and fault registers.
Definition iomcu.h:940
void control_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the CONTROL page.
Definition iomcu_pages.c:32
void servo_sense_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the SERVO_SENSE page.
Definition iomcu_sense.c:214
static void ports_exclusive(void)
Each wire page told which ports the other holds: neither takes a port the other has.
Definition iomcu.h:1014
uint16_t s_run_gen
Moves on each edge of the bank into driving: core 1 starts the run's peaks and the INA228's totals on...
Definition main.c:82
static void reserve_held(void)
What no output may have: the board's own pins, and the ones the supply, the sensor bus and the phase ...
Definition iomcu.h:1049
uint8_t supply_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the SUPPLY page.
Definition iomcu_sense.c:169
uint8_t channels_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the CHANNELS page.
Definition iomcu_pages.c:116
void tone_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the TONE page.
Definition iomcu_tone.c:107
kst_port_t s_kst
The KST page: the wire protocol for KST and Chaservo servos on a programming port (shared/outputs/kst...
Definition main.c:88
uint8_t s_pd_rate
Definition main.c:75
uint32_t s_refused
CAN frames received and refused since power-up, published on the STATUS page (LINK_ST_REFUSED_LO and ...
Definition main.c:96
void sense_limit_rd(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the SENSE_LIMIT page.
Definition iomcu_sense.c:283
void ports_apply(void)
Makes the programming ports' pins agree with the PROG page.
Definition iomcu_pages.c:205
uint32_t s_last_rx_ms
When a frame was last taken out of the controller; see iomcu_can.c.
Definition iomcu_can.c:81
uint8_t servo_sense_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the SERVO_SENSE page.
Definition iomcu_sense.c:323
void supply_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the SUPPLY page.
Definition iomcu_sense.c:81
void can_start(void)
Brings up the CAN controller at IOMCU_CAN_BITRATE.
Definition iomcu_can.c:83
outputs_t s_outputs
Every output, behind one set of rules.
Definition main.c:93
bool s_supply_attach
New wiring taken, the UART to attach once it is saved.
Definition main.c:77
uint32_t s_now_ms
The pass's clock, used by everything the pass reaches – including the page callbacks,...
Definition main.c:97
uint8_t sense_limit_wr(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the SENSE_LIMIT page.
Definition iomcu_sense.c:290
static uint8_t bound_slots(void)
The slots the silicon has bound, one bit each.
Definition iomcu.h:956
uint8_t control_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the CONTROL page.
Definition iomcu_pages.c:542
hitec_port_t s_hitec
The HITEC page: raw transactions of the Hitec wire on a programming port (shared/outputs/hitec_port....
Definition main.c:90
bool hitec_hw_take(void *ctx, uint8_t port, uint8_t pin, uint8_t family, uint8_t drive, uint8_t rx)
Takes the programming port's pin for the HITEC wire driver.
Definition iomcu_hitec.c:24
void bench_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the BENCH page.
Definition iomcu_pages.c:57
uint64_t s_base_reserved
What the board and this application hold, before the supply and the sensor bus take their pins.
Definition main.c:86
void can_report(uint32_t now)
Prints the console report when 3s have passed.
Definition iomcu_report.c:178
void shape_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the SHAPE page.
Definition iomcu_bind.c:169
void reset_start(void)
Reads why this start happened, once at boot, and prints it.
Definition iomcu_report.c:90
uint64_t tone_taken(void)
Returns the pins the phase tap may not take now.
Definition iomcu_tone.c:22
void identity_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the IDENTITY page.
Definition iomcu_pages.c:24
uint8_t slots_take(iomcu_state_t *s, const uint16_t *next, bool save)
Takes a whole OUTPUTS page (slots) into force, when it passes the checks.
Definition iomcu_pages.c:441
bool kst_hw_supply_set(void *ctx, bool on, uint16_t mv, uint16_t ma)
Sets the supply of the KST port.
Definition iomcu_kst.c:56
uint8_t bind_out_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the BIND_OUT page.
Definition iomcu_bind.c:56
void sense_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the SENSE page.
Definition iomcu_sense.c:178
tone_page_t s_tone
The TONE page: the phase tap's set-up, kept, and the beeps core 1 hears on it.
Definition main.c:79
bool s_edge_set
The capture's PWM edge, stamped by outputs_hw for capture order s_edge_gen.
Definition main.c:83
uint8_t slots_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the OUTPUTS page.
Definition iomcu_pages.c:529
uint8_t kst_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the KST page.
Definition iomcu_kst.c:72
void chan_cfg_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the CHAN_CFG page.
Definition iomcu_pages.c:259
void status_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the STATUS page.
Definition iomcu_pages.c:40
void capabilities_update(void)
Refreshes the IDENTITY page's capability word.
Definition iomcu_sense.c:26
bool s_beat_level
The heartbeat line's level at the last sample; see iomcu_can.c.
Definition iomcu_can.c:39
static bool heartbeat_edge(void)
Sample the line; returns whether its level changed since the last sample.
Definition iomcu.h:975
void kst_hw_give(void *ctx)
Gives the programming port's pin back from the KST wire driver.
Definition iomcu_kst.c:41
void hitec_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the HITEC page.
Definition iomcu_hitec.c:57
uint8_t servo_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the SERVO page.
Definition iomcu_pages.c:420
void pads_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the PADS page.
Definition iomcu_bind.c:250
void prog_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the PROG page.
Definition iomcu_pages.c:331
sense_page_t s_sense
The SENSE and SERVO_SENSE pages: the current monitors' set-up, kept, and the pins it holds.
Definition main.c:78
uint8_t sense_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the SENSE page.
Definition iomcu_sense.c:191
uint8_t prog_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the PROG page.
Definition iomcu_pages.c:349
static bool ports_hold_supply(void)
A wire page holds the SUPPLY page: the KST port out of PWM, or the HITEC port held,...
Definition iomcu.h:1026
uint8_t art_data_write(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the ART_DATA page.
Definition iomcu_bind.c:234
void sense_win_a_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the SENSE_WIN_A page.
Definition iomcu_sense.c:263
sense_snap_t s_sense_snap
Core 1's last snapshot.
Definition main.c:80
prog_port_t s_prog
The PROG page: the programming ports, outputs of their own kind with their own pins (shared/outputs/p...
Definition main.c:87
void catalogue_read(void *ctx, uint8_t off, uint8_t n, uint16_t *out)
Reads the CATALOGUE page.
Definition iomcu_bind.c:154
uint8_t sense_map_wr(void *ctx, uint8_t off, uint8_t n, const uint16_t *in)
Writes the SENSE_MAP page.
Definition iomcu_sense.c:235
IOmcu pin map for the module build: a Waveshare RP2350-CAN (RP2350A, 4 MB flash) with its XL2515 CAN ...
#define IOMCU_HEARTBEAT_PIN
The safety heartbeat from the panel's PANEL_HEARTBEAT_PIN, by a direct wire: no board carries the ret...
Definition iomcu_pins.h:46
The KST wire on one RP2350 pin: a kst_driver_t made of one PIO (programmable input/output) state mach...
The KST programming protocol on a programming port, and its link page (0x32).
uint8_t kst_port_quiet_mask(const kst_port_t *p)
Bit n: programming port n renders no PWM pulse.
Definition kst_port.c:1274
void kst_port_other_mask(kst_port_t *p, uint8_t mask)
Bit n: the HITEC page holds programming port n (hitec_port_quiet_mask()).
Definition kst_port.c:1292
uint8_t kst_port_pin_mask(const kst_port_t *p)
Bit n: programming port n's pin is the wire driver's, not the PWM generator's.
Definition kst_port.c:1299
link_kst_state_t kst_port_state(const kst_port_t *p)
Where the port is.
Definition kst_port.c:1269
A binding prepared beside the one in force, and taken whole.
bool out_store_is_off(void)
Whether out_store_off() has been called.
Definition out_store.c:315
The output configuration, kept in the IOmcu's own flash.
The intermediary every output goes through: one set of rules for arming, clamping,...
void outputs_reserve_pins(outputs_t *o, uint64_t mask)
Declare the pins this build must never drive, one bit per pin.
Definition outputs.c:83
#define OUT_MAX_SLOTS
Slots in a bank: driver configurations, each rendering channels.
Definition outputs.h:49
bool outputs_hw_bound(uint8_t slot)
Whether slot slot is configured and bound to real silicon.
Definition outputs_hw.c:170
uint8_t outputs_hw_ports_bound(void)
The ports whose function holds their pin, bit n for port n: bound to the generator or to DShot,...
Definition outputs_hw.c:560
The seam between the output bank and the pins.
void heartbeat_init(void)
Set the heartbeat's pin up as an output, low.
Definition panel_control.c:58
The WeAct PD Power Mini V1 Buck on its UART: the codec and a driver that talks to it one transaction ...
The programming ports and their link page (0x33).
uint8_t prog_port_pwm(const prog_port_t *p)
Bit n: port n's pulse is switched on.
Definition prog_port.c:698
uint64_t prog_port_pins(const prog_port_t *p)
Every pin the ports hold, one bit per pin.
Definition prog_port.c:683
The IOmcu's decision to arm, once a pass and at every CONTROL write.
void safety_gate_status(const heartbeat_mon_t *beat, const link_dev_t *dev, const uint16_t *control, uint16_t *state, uint16_t *faults)
The STATUS page's state register and the two fault bits this decision owns (LINK_FAULT_LINK_SILENT,...
Definition safety_gate.c:99
void sense_core1_order(const sense_cmd_t *cmd)
A new order for core 1, taken at its next tick.
Definition sense_core1.c:182
bool sense_core1_snapshot(sense_snap_t *out)
The newest snapshot into out when one has arrived since the last call; false, and out untouched,...
Definition sense_core1.c:192
Core 1: the sensor bus, read on a 1ms tick, and the hand-over to core 0.
The SENSE, SERVO_SENSE and SERVO_WIN link pages at the IOmcu: the I2C bus of the two current monitors...
void sense_page_cmd(const sense_page_t *p, sense_cmd_t *cmd)
The order for core 1 from the page: the set-up and its generation, and the capture's.
Definition sense_page.c:561
uint64_t sense_page_held(const sense_page_t *p)
Those and the pins core 1 has not let go of yet (sense_page_t.held): a bus moved or closed keeps its ...
Definition sense_page.c:114
void sense_page_publish(sense_page_t *p, const sense_snap_t *s, uint16_t run_gen)
What core 1 read into the read-only registers of both pages, when s was taken under the set-up in for...
Definition sense_page.c:886
The SERVO link page at the IOmcu: the frame rate of the tester's target and the sweep that drives it ...
Definition heartbeat.h:118
One line.
Definition hitec_line.h:109
What the driver says about the line and the running transaction.
Definition hitec_port.h:130
The state of one Hitec port: the hardware, the staged registers, the running or last transaction and ...
Definition hitec_port.h:180
Register images of the pages the IOmcu holds, one array per page.
Definition iomcu.h:61
uint16_t chan_cfg[LINK_CC_COUNT]
Definition iomcu.h:67
uint16_t slots[LINK_OS_COUNT]
Definition iomcu.h:68
One line.
Definition kst_line.h:78
The state of one KST port: the hardware, the session, the staged registers and the running or last op...
Definition kst_port.h:253
The CHAN_CFG and OUTPUTS pages prepared beside the bank in force.
Definition out_stage.h:30
The state of a bank of channels and slots.
Definition outputs.h:143
Driver state: what is asked, what is known, and the transaction under way.
Definition pdmini.h:290
The state of the programming ports: the PROG page's registers and which ports hold their pin.
Definition prog_port.h:99
What core 0 asks for.
Definition sense_svc.h:82
uint64_t edge_us
Definition sense_svc.h:92
uint16_t run_gen
Definition sense_svc.h:87
bool edge_set
Definition sense_svc.h:91
The state of the SENSE page: its three register images, the generations, the pins and the map and lim...
Definition sense_page.h:78
uint16_t cap_gen
Definition sense_page.h:85
uint64_t held
Definition sense_page.h:92
What core 1 hands back after each step.
Definition sense_svc.h:100
The SERVO page state: its registers, the sweep, and the hold.
Definition servo_page.h:59
The SUPPLY page state: registers, and the wiring change in hand.
Definition supply_page.h:65
The supply as a programming port sees it (kst_port.h).
Definition supply_page.h:85
The TONE page state: the set-up, what core 1 last reported, and the beep ring of the capture.
Definition tone_page.h:49
The SUPPLY link page at the IOmcu: a PD mini on a PIO UART, its wiring, what it is to do and what it ...
uint64_t supply_page_pins(const supply_page_t *p)
The pins it holds, as a reservation mask; 0 while not enabled.
Definition supply_page.c:50
The TONE link page at the IOmcu: the phase tap that hears an ESC's (electronic speed controller) beep...
uint64_t tone_page_pins(const tone_page_t *p)
The pin as a reservation mask; 0 unless the capture is wanted.
Definition tone_page.c:57