From 8def9863d22795c398814ce17c4def85de187c6b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 11 Feb 2010 13:32:12 -0600 Subject: [PATCH] (untested) support for muxed encoders --- src/hal/drivers/mesa-hostmot2/encoder.c | 2 ++ src/hal/drivers/mesa-hostmot2/hostmot2.c | 3 +++ src/hal/drivers/mesa-hostmot2/hostmot2.h | 2 ++ src/hal/drivers/mesa-hostmot2/pins.c | 23 +++++++++++++++++++++++ 4 files changed, 30 insertions(+), 0 deletions(-) diff --git a/src/hal/drivers/mesa-hostmot2/encoder.c b/src/hal/drivers/mesa-hostmot2/encoder.c index e1b2d26..34a7573 100644 --- a/src/hal/drivers/mesa-hostmot2/encoder.c +++ b/src/hal/drivers/mesa-hostmot2/encoder.c @@ -180,6 +180,8 @@ int hm2_encoder_parse_md(hostmot2_t *hm2, int md_index) { hm2_module_descriptor_t *md = &hm2->md[md_index]; int r; + HM2_ERR("hm2_encoder_parse_md() ne=%d inst=%d\n", hm2->config.num_encoders, + md->instances); // // some standard sanity checks diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2.c b/src/hal/drivers/mesa-hostmot2/hostmot2.c index e8e3b3e..1fb5a02 100644 --- a/src/hal/drivers/mesa-hostmot2/hostmot2.c +++ b/src/hal/drivers/mesa-hostmot2/hostmot2.c @@ -171,6 +171,8 @@ const char *hm2_get_general_function_name(int gtag) { case HM2_GTAG_STEPGEN: return "StepGen"; case HM2_GTAG_PWMGEN: return "PWMGen"; case HM2_GTAG_TRANSLATIONRAM: return "TranslationRAM"; + case HM2_GTAG_MUXED_ENCODER: return "Muxed Encoder"; + case HM2_GTAG_MUXED_ENCODER_SEL: return "Muxed Encoder Select"; default: { static char unknown[100]; rtapi_snprintf(unknown, 100, "(unknown-gtag-%d)", gtag); @@ -594,6 +596,7 @@ static int hm2_parse_module_descriptors(hostmot2_t *hm2) { break; case HM2_GTAG_ENCODER: + case HM2_GTAG_MUXED_ENCODER: md_accepted = hm2_encoder_parse_md(hm2, md_index); break; diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2.h b/src/hal/drivers/mesa-hostmot2/hostmot2.h index cc8953f..020a790 100644 --- a/src/hal/drivers/mesa-hostmot2/hostmot2.h +++ b/src/hal/drivers/mesa-hostmot2/hostmot2.h @@ -95,6 +95,8 @@ #define HM2_GTAG_STEPGEN (5) #define HM2_GTAG_PWMGEN (6) #define HM2_GTAG_TRANSLATIONRAM (11) +#define HM2_GTAG_MUXED_ENCODER (12) +#define HM2_GTAG_MUXED_ENCODER_SEL (13) diff --git a/src/hal/drivers/mesa-hostmot2/pins.c b/src/hal/drivers/mesa-hostmot2/pins.c index 6bff378..e4f1762 100644 --- a/src/hal/drivers/mesa-hostmot2/pins.c +++ b/src/hal/drivers/mesa-hostmot2/pins.c @@ -44,6 +44,22 @@ static const char* hm2_get_pin_secondary_name(hm2_pin_t *pin) { switch (pin->sec_tag) { + case HM2_GTAG_MUXED_ENCODER: + switch (sec_pin) { + case 1: return "Muxed A"; + case 2: return "Muxed B"; + case 3: return "Muxed Index"; + case 4: return "Muxed IndexMask"; + } + break; + + case HM2_GTAG_MUXED_ENCODER_SEL: + switch (sec_pin) { + case 1: return "Mux Select 0"; + case 2: return "Mux Select 1"; + } + break; + case HM2_GTAG_ENCODER: switch (sec_pin) { case 1: return "A"; @@ -335,6 +351,13 @@ void hm2_configure_pins(hostmot2_t *hm2) { // encoder and pwmgen just get all their enabled instances' pins hm2_pins_allocate_all(hm2, HM2_GTAG_ENCODER, hm2->encoder.num_instances); hm2_pins_allocate_all(hm2, HM2_GTAG_PWMGEN, hm2->pwmgen.num_instances); + + // muxed encoder gets the sel pins + hm2_pins_allocate_all(hm2, HM2_GTAG_MUXED_ENCODER_SEL, + hm2->encoder.num_instances); + // and about half as many I/Os as you'd expect + hm2_pins_allocate_all(hm2, HM2_GTAG_MUXED_ENCODER, + (hm2->encoder.num_instances+1)/2); } -- 1.6.6.1