Skip to content

Commit 9f3109f

Browse files
pcw-mesaandypugh
authored andcommitted
Add OutM simple output module support
1 parent 92cfdf7 commit 9f3109f

6 files changed

Lines changed: 372 additions & 2 deletions

File tree

docs/man/man9/hostmot2.9

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,35 @@ The state of this SSR instance's NNth output. Set to 0 to make
13741374
the output pins act like an open switch (no connection), set to 1 to
13751375
make them act like a closed switch.
13761376

1377+
.TP
1378+
(bit in) invert-NN
1379+
Inverts the state of this SSR instance's NNth output, defaults to 0.
1380+
When invert-NN is set to 1, SSR output NN is closed when the out-NN
1381+
pin is 0 and open when the out-NN pin is 1
1382+
1383+
.SH OutM Simple output module
1384+
1385+
OutMs have names like
1386+
"hm2_\fI<BoardType>\fR.\fI<BoardNum>\fR.OutM.\fI<Instance>\fR".
1387+
"Instance" is a two-digit number that corresponds to the HostMot2 OutM
1388+
instance number. There are 'num_outms' instances, starting
1389+
with 00.
1390+
1391+
Each instance has between 1 and 32 output pins.
1392+
1393+
Pins:
1394+
1395+
.TP
1396+
(bit in) out-NN
1397+
The sets the state of this OutM instance's NNth output. Normally the output
1398+
pin follows the state of this pin but may be inverted by the invert-nn hal pin
1399+
1400+
.TP
1401+
(bit in) invert-NN
1402+
Inverts the state of the this OutM instance's NNth output, defaults to 0.
1403+
When invert-NN is set to 1, OutM output NN is high when the out-NN
1404+
pin is 0 and low when the out-NN pin is 1
1405+
13771406
.SH xy2mod
13781407

13791408
The xy2mod is a xy2-100 galvanometer interface. It supports 16 and 18 bit

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ hostmot2-objs := \
912912
hal/drivers/mesa-hostmot2/resolver.o \
913913
hal/drivers/mesa-hostmot2/sserial.o \
914914
hal/drivers/mesa-hostmot2/ssr.o \
915+
hal/drivers/mesa-hostmot2/outm.o \
915916
hal/drivers/mesa-hostmot2/stepgen.o \
916917
hal/drivers/mesa-hostmot2/tp_pwmgen.o \
917918
hal/drivers/mesa-hostmot2/tram.o \

src/hal/drivers/mesa-hostmot2/hostmot2.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ static void hm2_write(void *void_hm2, long period) {
142142
hm2_stepgen_prepare_tram_write(hm2, period);
143143
hm2_sserial_prepare_tram_write(hm2, period);
144144
hm2_bspi_prepare_tram_write(hm2, period);
145-
hm2_ssr_prepare_tram_write(hm2);
146-
//UARTS need to be explicity handled by an external component
145+
hm2_ssr_prepare_tram_write(hm2);
146+
hm2_outm_prepare_tram_write(hm2);
147+
//UARTS need to be explicitly handled by an external component
147148
hm2_tram_write(hm2);
148149

149150
// these usually do nothing
@@ -311,6 +312,7 @@ const char *hm2_get_general_function_name(int gtag) {
311312
case HM2_GTAG_HM2DPLL: return "Hostmot2 DPLL";
312313
case HM2_GTAG_INMUX: return "InMux Input Mux";
313314
case HM2_GTAG_INM: return "InM Input Module";
315+
case HM2_GTAG_OUTM: return "OutM Output Module";
314316
case HM2_GTAG_XY2MOD: return "xy2mod Galvo interface";
315317
case HM2_GTAG_DPAINTER: return "Data Painter";
316318
case HM2_GTAG_SSR: return "SSR";
@@ -390,6 +392,7 @@ static int hm2_parse_config_string(hostmot2_t *hm2, char *config_string) {
390392
hm2->config.num_xy2mods = -1;
391393
hm2->config.num_leds = -1;
392394
hm2->config.num_ssrs = -1;
395+
hm2->config.num_outms = -1;
393396
hm2->config.enable_raw = 0;
394397
hm2->config.firmware = NULL;
395398

@@ -444,6 +447,14 @@ static int hm2_parse_config_string(hostmot2_t *hm2, char *config_string) {
444447
token += 9;
445448
hm2->config.num_inms = simple_strtol(token, NULL, 0);
446449

450+
} else if (strncmp(token, "num_outms=", 10) == 0) {
451+
token += 9;
452+
hm2->config.num_outms = simple_strtol(token, NULL, 0);
453+
454+
} else if (strncmp(token, "num_ssrs=", 9) == 0) {
455+
token += 9;
456+
hm2->config.num_ssrs = simple_strtol(token, NULL, 0);
457+
447458
} else if (strncmp(token, "num_xy2mods=", 12) == 0) {
448459
token += 12;
449460
hm2->config.num_xy2mods = simple_strtol(token, NULL, 0);
@@ -534,6 +545,8 @@ static int hm2_parse_config_string(hostmot2_t *hm2, char *config_string) {
534545
HM2_DBG(" num_rcpwmgens=%d\n", hm2->config.num_rcpwmgens);
535546
HM2_DBG(" num_inmuxs=%d\n", hm2->config.num_inmuxs);
536547
HM2_DBG(" num_inms=%d\n", hm2->config.num_inms);
548+
HM2_DBG(" num_outms=%d\n", hm2->config.num_outms);
549+
HM2_DBG(" num_ssrs=%d\n", hm2->config.num_ssrs);
537550
HM2_DBG(" num_xy2mods=%d\n", hm2->config.num_xy2mods);
538551
HM2_DBG(" num_3pwmgens=%d\n", hm2->config.num_tp_pwmgens);
539552
HM2_DBG(" sserial_port_0=%8.8s\n"
@@ -1027,6 +1040,10 @@ static int hm2_parse_module_descriptors(hostmot2_t *hm2) {
10271040
case HM2_GTAG_SSR:
10281041
md_accepted = hm2_ssr_parse_md(hm2, md_index);
10291042
break;
1043+
1044+
case HM2_GTAG_OUTM:
1045+
md_accepted = hm2_outm_parse_md(hm2, md_index);
1046+
break;
10301047

10311048
case HM2_GTAG_RCPWMGEN:
10321049
md_accepted = hm2_rcpwmgen_parse_md(hm2, md_index);
@@ -1104,6 +1121,7 @@ static void hm2_cleanup(hostmot2_t *hm2) {
11041121
hm2_sserial_cleanup(hm2);
11051122
hm2_bspi_cleanup(hm2);
11061123
hm2_ssr_cleanup(hm2);
1124+
hm2_outm_cleanup(hm2);
11071125
hm2_rcpwmgen_cleanup(hm2);
11081126

11091127
// free all the tram entries
@@ -1124,6 +1142,7 @@ void hm2_print_modules(hostmot2_t *hm2) {
11241142
hm2_bspi_print_module(hm2);
11251143
hm2_ioport_print_module(hm2);
11261144
hm2_ssr_print_module(hm2);
1145+
hm2_outm_print_module(hm2);
11271146
hm2_watchdog_print_module(hm2);
11281147
hm2_inmux_print_module(hm2);
11291148
hm2_inm_print_module(hm2);
@@ -1790,5 +1809,6 @@ void hm2_force_write(hostmot2_t *hm2) {
17901809
// ioport is written. Initialization of the SSR requires that
17911810
// the IO Port pin directions is set appropriately.
17921811
hm2_ssr_force_write(hm2);
1812+
hm2_outm_force_write(hm2);
17931813
}
17941814

src/hal/drivers/mesa-hostmot2/hostmot2.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
#define HM2_GTAG_DPAINTER (42)
124124
#define HM2_GTAG_XY2MOD (43)
125125
#define HM2_GTAG_RCPWMGEN (44)
126+
#define HM2_GTAG_OUTM (45)
126127
#define HM2_GTAG_LIOPORT (64) // Not supported
127128
#define HM2_GTAG_LED (128)
128129

@@ -1359,6 +1360,36 @@ typedef struct {
13591360
rtapi_u32 *rate_reg;
13601361
} hm2_ssr_t;
13611362

1363+
//
1364+
// OUTM
1365+
//
1366+
1367+
typedef struct {
1368+
struct {
1369+
1370+
struct {
1371+
hal_bit_t *out[32];
1372+
hal_bit_t *invert[32];
1373+
} pin;
1374+
1375+
} hal;
1376+
1377+
rtapi_u32 written_data;
1378+
1379+
} hm2_outm_instance_t;
1380+
1381+
typedef struct {
1382+
int num_instances;
1383+
hm2_outm_instance_t *instance;
1384+
1385+
rtapi_u8 version;
1386+
rtapi_u32 clock_freq;
1387+
1388+
rtapi_u32 data_addr;
1389+
rtapi_u32 *data_reg;
1390+
1391+
} hm2_outm_t;
1392+
13621393

13631394
//
13641395
// raw peek/poke access
@@ -1423,6 +1454,7 @@ typedef struct {
14231454
int num_inms;
14241455
int num_xy2mods;
14251456
int num_ssrs;
1457+
int num_outms;
14261458
char sserial_modes[4][8];
14271459
int enable_raw;
14281460
char *firmware;
@@ -1471,6 +1503,7 @@ typedef struct {
14711503
hm2_xy2mod_t xy2mod;
14721504
hm2_led_t led;
14731505
hm2_ssr_t ssr;
1506+
hm2_outm_t outm;
14741507

14751508
hm2_raw_t *raw;
14761509

@@ -1814,6 +1847,17 @@ void hm2_ssr_prepare_tram_write(hostmot2_t *hm2);
18141847
void hm2_ssr_print_module(hostmot2_t *hm2);
18151848

18161849

1850+
//
1851+
// OUTM functions
1852+
//
1853+
1854+
int hm2_outm_parse_md(hostmot2_t *hm2, int md_index);
1855+
void hm2_outm_cleanup(hostmot2_t *hm2);
1856+
void hm2_outm_force_write(hostmot2_t *hm2);
1857+
void hm2_outm_prepare_tram_write(hostmot2_t *hm2);
1858+
void hm2_outm_print_module(hostmot2_t *hm2);
1859+
1860+
18171861
//
18181862
// the raw interface lets you peek and poke the hostmot2 instance from HAL
18191863
//

0 commit comments

Comments
 (0)