2#include <sys/_stdint.h>
3#include "analog_in.hpp"
5#include "configuration.hpp"
26struct output_port_info_struct
32 uint8_t STEP_TEENSY_PIN;
33 uint8_t DIR_TEENSY_PIN;
36 uint8_t STEP_FLEXIO_PIN;
37 uint8_t DIR_FLEXIO_PIN;
38 volatile uint32_t *STEP_PIN_IOMUXC_REGISTER;
39 volatile uint32_t *DIR_PIN_IOMUXC_REGISTER;
40 uint8_t STEP_PIN_IOMUXC_VALUE;
41 uint8_t DIR_PIN_IOMUXC_VALUE;
44 volatile uint32_t *STEP_SHIFTCTRL_REGISTER;
45 volatile uint32_t *DIR_SHIFTCTRL_REGISTER;
46 volatile uint32_t *STEP_SHIFTCFG_REGISTER;
47 volatile uint32_t *DIR_SHIFTCFG_REGISTER;
48 volatile uint32_t *STEP_SHIFTBUF;
49 volatile uint32_t *DIR_SHIFTBUF;
51 volatile uint32_t *TIMCMP_REGISTER;
52 volatile uint32_t *TIMCTL_REGISTER;
53 volatile uint32_t *TIMCFG_REGISTER;
54 uint8_t VREF_TEENSY_PIN;
55 uint8_t ENABLE_TEENSY_PIN;
56 uint8_t LIMIT_TEENSY_PIN;
59struct output_format_struct
61 uint8_t FRAME_LENGTH_US;
62 uint8_t STEP_PULSE_START_TIME_US;
63 uint8_t DIR_PULSE_START_TIME_US;
64 uint8_t SIGNAL_MIN_WIDTH_US;
65 uint8_t SIGNAL_GAP_US;
73#define OUTPUT_FRAME_32US 0
74#define OUTPUT_FRAME_16US 1
75#define OUTPUT_FRAME_8US 2
76#define OUTPUT_FRAME_4US 3
79#define OUTPUT_TRANSMIT_ON_FRAME 1
80#define OUTPUT_TRANSMIT_MANUAL 2
86#define OUTPUT_A_LEGACY 0
87#define OUTPUT_B_LEGACY 1
91#define DIRECTION_FORWARD 1
92#define DIRECTION_REVERSE 0
94#define NUM_AVAILABLE_OUTPUT_PORTS 4
125 void begin(uint8_t port_number, uint8_t output_format, uint8_t transmit_mode);
127 void add_signal(uint8_t signal_index, uint8_t signal_direction);
128 void transmit_frame();
129 void step_now(uint8_t direction);
130 void step_now(uint8_t direction, uint8_t signal_index);
133 float32_t read_drive_current_amps();
134 float32_t read_drive_current_amps(float32_t drive_current_gain_amps_per_volt);
135 void set_drive_current_gain(float32_t amps_per_volt);
136 void enable_driver();
137 void disable_driver();
138 bool read_limit_switch();
141 void enroll(
RPC *rpc,
const String& instance_name);
147 uint8_t format_index;
148 uint8_t transmit_mode;
149 uint8_t FRAME_LENGTH_US;
150 uint8_t STEP_PULSE_START_TIME_US;
151 uint8_t DIR_PULSE_START_TIME_US;
152 uint8_t SIGNAL_MIN_WIDTH_US;
153 uint8_t SIGNAL_GAP_US;
155 static const struct output_port_info_struct port_info[];
156 static const struct output_format_struct output_formats[];
159 volatile uint8_t active_signals[NUM_SIGNALS];
160 volatile uint8_t active_signal_directions[NUM_SIGNALS];
161 volatile uint32_t active_encoded_frame_step;
162 volatile uint32_t active_encoded_frame_dir;
163 volatile float32_t last_drive_current_reading_amps;
168 volatile bool vref_is_configured =
false;
169 volatile bool enable_is_configured =
false;
170 volatile bool limitsw_is_configured =
false;
171 float32_t drive_current_gain_amps_per_volt = 0;
176 void clear_all_signals();
177 void register_output_port();
183void transmit_frames_on_all_output_ports();
185void iterate_across_all_output_ports(
void (*target_function)(
OutputPort *));
187void enable_drivers();
188void disable_drivers();
OutputPorts are modules that convert internal step commands into a frame of pulse signals on the phys...
Definition output_ports.hpp:108
void begin(uint8_t port_number)
Initialize the OutputPort with a port number corresponding to the target physical port on the Stepdan...
OutputPort()
Default constructor for OutputPort. Initializes an OutputPort instance with default,...
RPC class for handling remote procedure calls over serial streams.
Definition rpc.hpp:35