Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- git diff
- diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2.c b/src/hal/drivers/mesa-hostmot2/hostmot2.c
- index db155f4..e9c724f 100644
- --- a/src/hal/drivers/mesa-hostmot2/hostmot2.c
- +++ b/src/hal/drivers/mesa-hostmot2/hostmot2.c
- @@ -804,6 +804,18 @@ int hm2_md_is_consistent(
- static int hm2_parse_module_descriptors(hostmot2_t *hm2) {
- int md_index, md_accepted;
- + hm2->dpll_module_present = 0;
- + for (md_index = 0; md_index < hm2->num_mds; md_index ++) {
- + hm2_module_descriptor_t *md = &hm2->md[md_index];
- +
- + if (md->gtag == HM2_GTAG_HM2DPLL) {
- + hm2->dpll_module_present = 1;
- + break;
- + } else if (md->gtag == 0) {
- + break;
- + }
- + }
- +
- // Run through once looking for IO Ports in case other modules
- // need them
- for (md_index = 0; md_index < hm2->num_mds; md_index ++) {
- diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2.h b/src/hal/drivers/mesa-hostmot2/hostmot2.h
- index 81cd41a..6f118e3 100644
- --- a/src/hal/drivers/mesa-hostmot2/hostmot2.h
- +++ b/src/hal/drivers/mesa-hostmot2/hostmot2.h
- @@ -717,6 +717,13 @@ typedef struct {
- } hm2_stepgen_instance_t;
- +// these hal params affect all encoder instances
- +typedef struct {
- + struct {
- + hal_s32_t *dpll_timer_num;
- + } pin;
- +} hm2_stepgen_module_global_t;
- +
- typedef struct {
- int num_instances;
- hm2_stepgen_instance_t *instance;
- @@ -724,6 +731,10 @@ typedef struct {
- rtapi_u32 clock_frequency;
- rtapi_u8 version;
- + // module-global HAL objects...
- + hm2_stepgen_module_global_t *hal;
- + rtapi_u32 written_dpll_timer_num;
- +
- // write this (via TRAM) every hm2_<foo>.write
- rtapi_u32 step_rate_addr;
- rtapi_u32 *step_rate_reg;
- @@ -752,6 +763,8 @@ typedef struct {
- rtapi_u32 table_sequence_length_addr;
- rtapi_u32 master_dds_addr;
- +
- + rtapi_u32 dpll_timer_num_addr;
- } hm2_stepgen_t;
- //
- @@ -991,6 +1004,7 @@ typedef struct {
- hm2_module_descriptor_t md[HM2_MAX_MODULE_DESCRIPTORS];
- int num_mds;
- + int dpll_module_present;
- int use_serial_numbers;
- hm2_pin_t *pin;
- diff --git a/src/hal/drivers/mesa-hostmot2/stepgen.c b/src/hal/drivers/mesa-hostmot2/stepgen.c
- index a119b8b..0d48879 100644
- --- a/src/hal/drivers/mesa-hostmot2/stepgen.c
- +++ b/src/hal/drivers/mesa-hostmot2/stepgen.c
- @@ -384,6 +384,20 @@ static void hm2_stepgen_update_mode(hostmot2_t *hm2, int i) {
- }
- +static void hm2_stepgen_set_dpll_timer(hostmot2_t *hm2) {
- + rtapi_u32 data = 0;
- +
- + if ((*hm2->stepgen.hal->pin.dpll_timer_num < -1) || (*hm2->stepgen.hal->pin.dpll_timer_num > 4)) {
- + *hm2->stepgen.hal->pin.dpll_timer_num = 0;
- + }
- + if (*hm2->stepgen.hal->pin.dpll_timer_num > -1) {
- + data = (*hm2->stepgen.hal->pin.dpll_timer_num << 12) | (1 << 15);
- + }
- + hm2->llio->write(hm2->llio, hm2->stepgen.dpll_timer_num_addr, &data, sizeof(rtapi_u32));
- + hm2->stepgen.written_dpll_timer_num = *hm2->stepgen.hal->pin.dpll_timer_num;
- +}
- +
- +
- void hm2_stepgen_write(hostmot2_t *hm2) {
- int i;
- @@ -418,6 +432,11 @@ void hm2_stepgen_write(hostmot2_t *hm2) {
- hm2->llio->write(hm2->llio, hm2->stepgen.mode_addr + (i * sizeof(rtapi_u32)), &hm2->stepgen.mode_reg[i], sizeof(rtapi_u32));
- }
- }
- + if (hm2->dpll_module_present) {
- + if (*hm2->stepgen.hal->pin.dpll_timer_num != hm2->stepgen.written_dpll_timer_num) {
- + hm2_stepgen_set_dpll_timer(hm2);
- + }
- + }
- }
- @@ -502,6 +521,12 @@ static void hm2_stepgen_force_write_master_dds(hostmot2_t *hm2) {
- );
- }
- +static void hm2_stepgen_force_write_dpll_timer(hostmot2_t *hm2) {
- + if (hm2->dpll_module_present) {
- + hm2_stepgen_set_dpll_timer(hm2);
- + }
- +}
- +
- void hm2_stepgen_force_write(hostmot2_t *hm2) {
- if (hm2->stepgen.num_instances == 0) return;
- @@ -511,6 +536,7 @@ void hm2_stepgen_force_write(hostmot2_t *hm2) {
- hm2_stepgen_force_write_pulse_width_time(hm2);
- hm2_stepgen_force_write_pulse_idle_width(hm2);
- hm2_stepgen_force_write_master_dds(hm2);
- + hm2_stepgen_force_write_dpll_timer(hm2);
- }
- @@ -612,6 +638,14 @@ int hm2_stepgen_parse_md(hostmot2_t *hm2, int md_index) {
- }
- + // allocate the module-global HAL shared memory
- + hm2->stepgen.hal = (hm2_stepgen_module_global_t *)hal_malloc(sizeof(hm2_stepgen_module_global_t));
- + if (hm2->stepgen.hal == NULL) {
- + HM2_ERR("out of memory!\n");
- + r = -ENOMEM;
- + goto fail0;
- + }
- +
- hm2->stepgen.instance = (hm2_stepgen_instance_t *)hal_malloc(hm2->stepgen.num_instances * sizeof(hm2_stepgen_instance_t));
- if (hm2->stepgen.instance == NULL) {
- HM2_ERR("out of memory!\n");
- @@ -632,6 +666,7 @@ int hm2_stepgen_parse_md(hostmot2_t *hm2, int md_index) {
- hm2->stepgen.table_sequence_data_setup_addr = md->base_address + (7 * md->register_stride);
- hm2->stepgen.table_sequence_length_addr = md->base_address + (8 * md->register_stride);
- hm2->stepgen.master_dds_addr = md->base_address + (9 * md->register_stride);
- + hm2->stepgen.dpll_timer_num_addr = md->base_address + (10 * md->register_stride);
- r = hm2_register_tram_write_region(hm2, hm2->stepgen.step_rate_addr, (hm2->stepgen.num_instances * sizeof(rtapi_u32)), &hm2->stepgen.step_rate_r
- if (r < 0) {
- @@ -686,6 +721,16 @@ int hm2_stepgen_parse_md(hostmot2_t *hm2, int md_index) {
- {
- int i;
- char name[HAL_NAME_LEN + 1];
- +
- + if (hm2->dpll_module_present) {
- + rtapi_snprintf(name, sizeof(name), "%s.stepgen.timer-number", hm2->llio->name);
- + r = hal_pin_s32_new(name, HAL_IN, &(hm2->stepgen.hal->pin.dpll_timer_num), hm2->llio->comp_id);
- + if (r < 0) {
- + HM2_ERR("error adding timer number param, aborting\n");
- + return -EINVAL;
- + }
- + }
- +
- for (i = 0; i < hm2->stepgen.num_instances; i ++) {
- // Work out if table setup registers are needed.
- (END)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement