STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
actuator_board_pins.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4
5// define actuator board pins to be imported where needed
7struct Layout {
8 // Ethernet pins (same for all DAQv2 boards)
12 int ETH_CS;
15
16 // Actuator GPIO pins (1-indexed: ACTUATOR_1 through ACTUATOR_10)
27
28 // Current sense pins (for future use, ignored for now)
39
40 // Status LED
41 int LED;
42};
43
45 // ETH_MOSI, ETH_MISO, ETH_SCLK, ETH_CS, ETH_INT, ETH_RST
46 40, 41, 39, 38, 37, 21,
47
48 // ACTUATOR_1 through ACTUATOR_10
49 // Pre-remap order (Jan 2026): 7, 5, 48, 21, 36, 6, 4, 47, 14, 35.
50 // ACTUATOR_4 is GPIO 47 and ACTUATOR_8 is GPIO 21 (the team, 2026-11-06).
51 // Both were typed as 21, so commanding either drove the same pin (#163).
52 4, 6, 14, 47, 35, 5, 7, 21, 48, 36,
53
54 // CURRENT_SENSE_1 through CURRENT_SENSE_10
55 // Hardware mapping: 1→18, 2→9, 3→13, 4→11, 5→1, 6→17, 7→8, 8→10, 9→12, 10→2
56 18, 9, 13, 11, 1, 17, 8, 10, 12, 2,
57
58 // LED
59 15};
60
61#if __cplusplus >= 201402L
62// Two actuators on one GPIO means commanding one fires the other (#163).
63constexpr bool actuatorPinsDistinct(const Layout& l) {
64 const int pins[] = {l.ACTUATOR_1, l.ACTUATOR_2, l.ACTUATOR_3, l.ACTUATOR_4,
65 l.ACTUATOR_5, l.ACTUATOR_6, l.ACTUATOR_7, l.ACTUATOR_8,
66 l.ACTUATOR_9, l.ACTUATOR_10};
67 for (int i = 0; i < 10; ++i)
68 for (int j = i + 1; j < 10; ++j)
69 if (pins[i] == pins[j])
70 return false;
71 return true;
72}
73static_assert(actuatorPinsDistinct(Actuator_Board),
74 "two actuators share a GPIO in actuator_board_pins.h");
75#endif
76
77// Maximum number of actuators supported by hardware (physical pin limit)
78// Actual number of actuators in use should be determined dynamically from
79// config/CSV at runtime
80constexpr int MAX_ACTUATORS = 10;
81// For backward compatibility, keep NUM_ACTUATORS as MAX_ACTUATORS
82// But prefer using runtime config/CSV to determine actual count
84
85// Get actuator pin number by 1-indexed actuator ID
86// Returns the GPIO pin number for the given actuator (1-10)
87inline int getActuatorPin(uint8_t actuator_id) {
88 switch (actuator_id) {
89 case 1:
90 return Actuator_Board.ACTUATOR_1;
91 case 2:
92 return Actuator_Board.ACTUATOR_2;
93 case 3:
94 return Actuator_Board.ACTUATOR_3;
95 case 4:
96 return Actuator_Board.ACTUATOR_4;
97 case 5:
98 return Actuator_Board.ACTUATOR_5;
99 case 6:
100 return Actuator_Board.ACTUATOR_6;
101 case 7:
102 return Actuator_Board.ACTUATOR_7;
103 case 8:
104 return Actuator_Board.ACTUATOR_8;
105 case 9:
106 return Actuator_Board.ACTUATOR_9;
107 case 10:
108 return Actuator_Board.ACTUATOR_10;
109 default:
110 return -1; // Invalid actuator ID
111 }
112}
113
114// Get current sense pin number by 1-indexed actuator ID (1-10)
115// Returns the GPIO pin number for the given current sense pin
116inline int getCurrentSensePin(uint8_t actuator_id) {
117 switch (actuator_id) {
118 case 1:
119 return Actuator_Board.CURRENT_SENSE_1;
120 case 2:
121 return Actuator_Board.CURRENT_SENSE_2;
122 case 3:
123 return Actuator_Board.CURRENT_SENSE_3;
124 case 4:
125 return Actuator_Board.CURRENT_SENSE_4;
126 case 5:
127 return Actuator_Board.CURRENT_SENSE_5;
128 case 6:
129 return Actuator_Board.CURRENT_SENSE_6;
130 case 7:
131 return Actuator_Board.CURRENT_SENSE_7;
132 case 8:
133 return Actuator_Board.CURRENT_SENSE_8;
134 case 9:
135 return Actuator_Board.CURRENT_SENSE_9;
136 case 10:
137 return Actuator_Board.CURRENT_SENSE_10;
138 default:
139 return -1; // Invalid actuator ID
140 }
141}
142} // namespace actuator_board_pins
int getActuatorPin(uint8_t actuator_id)
int getCurrentSensePin(uint8_t actuator_id)
constexpr Layout Actuator_Board