Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. git diff
  2. diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2.c b/src/hal/drivers/mesa-hostmot2/hostmot2.c
  3. index db155f4..e9c724f 100644
  4. --- a/src/hal/drivers/mesa-hostmot2/hostmot2.c
  5. +++ b/src/hal/drivers/mesa-hostmot2/hostmot2.c
  6. @@ -804,6 +804,18 @@ int hm2_md_is_consistent(
  7. static int hm2_parse_module_descriptors(hostmot2_t *hm2) {
  8. int md_index, md_accepted;
  9.  
  10. + hm2->dpll_module_present = 0;
  11. + for (md_index = 0; md_index < hm2->num_mds; md_index ++) {
  12. + hm2_module_descriptor_t *md = &hm2->md[md_index];
  13. +
  14. + if (md->gtag == HM2_GTAG_HM2DPLL) {
  15. + hm2->dpll_module_present = 1;
  16. + break;
  17. + } else if (md->gtag == 0) {
  18. + break;
  19. + }
  20. + }
  21. +
  22. // Run through once looking for IO Ports in case other modules
  23. // need them
  24. for (md_index = 0; md_index < hm2->num_mds; md_index ++) {
  25. diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2.h b/src/hal/drivers/mesa-hostmot2/hostmot2.h
  26. index 81cd41a..6f118e3 100644
  27. --- a/src/hal/drivers/mesa-hostmot2/hostmot2.h
  28. +++ b/src/hal/drivers/mesa-hostmot2/hostmot2.h
  29. @@ -717,6 +717,13 @@ typedef struct {
  30. } hm2_stepgen_instance_t;
  31.  
  32.  
  33. +// these hal params affect all encoder instances
  34. +typedef struct {
  35. + struct {
  36. + hal_s32_t *dpll_timer_num;
  37. + } pin;
  38. +} hm2_stepgen_module_global_t;
  39. +
  40. typedef struct {
  41. int num_instances;
  42. hm2_stepgen_instance_t *instance;
  43. @@ -724,6 +731,10 @@ typedef struct {
  44. rtapi_u32 clock_frequency;
  45. rtapi_u8 version;
  46.  
  47. + // module-global HAL objects...
  48. + hm2_stepgen_module_global_t *hal;
  49. + rtapi_u32 written_dpll_timer_num;
  50. +
  51. // write this (via TRAM) every hm2_<foo>.write
  52. rtapi_u32 step_rate_addr;
  53. rtapi_u32 *step_rate_reg;
  54. @@ -752,6 +763,8 @@ typedef struct {
  55. rtapi_u32 table_sequence_length_addr;
  56.  
  57. rtapi_u32 master_dds_addr;
  58. +
  59. + rtapi_u32 dpll_timer_num_addr;
  60. } hm2_stepgen_t;
  61.  
  62. //
  63. @@ -991,6 +1004,7 @@ typedef struct {
  64. hm2_module_descriptor_t md[HM2_MAX_MODULE_DESCRIPTORS];
  65. int num_mds;
  66.  
  67. + int dpll_module_present;
  68. int use_serial_numbers;
  69.  
  70. hm2_pin_t *pin;
  71. diff --git a/src/hal/drivers/mesa-hostmot2/stepgen.c b/src/hal/drivers/mesa-hostmot2/stepgen.c
  72. index a119b8b..0d48879 100644
  73. --- a/src/hal/drivers/mesa-hostmot2/stepgen.c
  74. +++ b/src/hal/drivers/mesa-hostmot2/stepgen.c
  75. @@ -384,6 +384,20 @@ static void hm2_stepgen_update_mode(hostmot2_t *hm2, int i) {
  76. }
  77.  
  78.  
  79. +static void hm2_stepgen_set_dpll_timer(hostmot2_t *hm2) {
  80. + rtapi_u32 data = 0;
  81. +
  82. + if ((*hm2->stepgen.hal->pin.dpll_timer_num < -1) || (*hm2->stepgen.hal->pin.dpll_timer_num > 4)) {
  83. + *hm2->stepgen.hal->pin.dpll_timer_num = 0;
  84. + }
  85. + if (*hm2->stepgen.hal->pin.dpll_timer_num > -1) {
  86. + data = (*hm2->stepgen.hal->pin.dpll_timer_num << 12) | (1 << 15);
  87. + }
  88. + hm2->llio->write(hm2->llio, hm2->stepgen.dpll_timer_num_addr, &data, sizeof(rtapi_u32));
  89. + hm2->stepgen.written_dpll_timer_num = *hm2->stepgen.hal->pin.dpll_timer_num;
  90. +}
  91. +
  92. +
  93. void hm2_stepgen_write(hostmot2_t *hm2) {
  94. int i;
  95.  
  96. @@ -418,6 +432,11 @@ void hm2_stepgen_write(hostmot2_t *hm2) {
  97. hm2->llio->write(hm2->llio, hm2->stepgen.mode_addr + (i * sizeof(rtapi_u32)), &hm2->stepgen.mode_reg[i], sizeof(rtapi_u32));
  98. }
  99. }
  100. + if (hm2->dpll_module_present) {
  101. + if (*hm2->stepgen.hal->pin.dpll_timer_num != hm2->stepgen.written_dpll_timer_num) {
  102. + hm2_stepgen_set_dpll_timer(hm2);
  103. + }
  104. + }
  105. }
  106.  
  107.  
  108. @@ -502,6 +521,12 @@ static void hm2_stepgen_force_write_master_dds(hostmot2_t *hm2) {
  109. );
  110. }
  111.  
  112. +static void hm2_stepgen_force_write_dpll_timer(hostmot2_t *hm2) {
  113. + if (hm2->dpll_module_present) {
  114. + hm2_stepgen_set_dpll_timer(hm2);
  115. + }
  116. +}
  117. +
  118.  
  119. void hm2_stepgen_force_write(hostmot2_t *hm2) {
  120. if (hm2->stepgen.num_instances == 0) return;
  121. @@ -511,6 +536,7 @@ void hm2_stepgen_force_write(hostmot2_t *hm2) {
  122. hm2_stepgen_force_write_pulse_width_time(hm2);
  123. hm2_stepgen_force_write_pulse_idle_width(hm2);
  124. hm2_stepgen_force_write_master_dds(hm2);
  125. + hm2_stepgen_force_write_dpll_timer(hm2);
  126. }
  127.  
  128.  
  129. @@ -612,6 +638,14 @@ int hm2_stepgen_parse_md(hostmot2_t *hm2, int md_index) {
  130. }
  131.  
  132.  
  133. + // allocate the module-global HAL shared memory
  134. + hm2->stepgen.hal = (hm2_stepgen_module_global_t *)hal_malloc(sizeof(hm2_stepgen_module_global_t));
  135. + if (hm2->stepgen.hal == NULL) {
  136. + HM2_ERR("out of memory!\n");
  137. + r = -ENOMEM;
  138. + goto fail0;
  139. + }
  140. +
  141. hm2->stepgen.instance = (hm2_stepgen_instance_t *)hal_malloc(hm2->stepgen.num_instances * sizeof(hm2_stepgen_instance_t));
  142. if (hm2->stepgen.instance == NULL) {
  143. HM2_ERR("out of memory!\n");
  144. @@ -632,6 +666,7 @@ int hm2_stepgen_parse_md(hostmot2_t *hm2, int md_index) {
  145. hm2->stepgen.table_sequence_data_setup_addr = md->base_address + (7 * md->register_stride);
  146. hm2->stepgen.table_sequence_length_addr = md->base_address + (8 * md->register_stride);
  147. hm2->stepgen.master_dds_addr = md->base_address + (9 * md->register_stride);
  148. + hm2->stepgen.dpll_timer_num_addr = md->base_address + (10 * md->register_stride);
  149.  
  150. r = hm2_register_tram_write_region(hm2, hm2->stepgen.step_rate_addr, (hm2->stepgen.num_instances * sizeof(rtapi_u32)), &hm2->stepgen.step_rate_r
  151. if (r < 0) {
  152. @@ -686,6 +721,16 @@ int hm2_stepgen_parse_md(hostmot2_t *hm2, int md_index) {
  153. {
  154. int i;
  155. char name[HAL_NAME_LEN + 1];
  156. +
  157. + if (hm2->dpll_module_present) {
  158. + rtapi_snprintf(name, sizeof(name), "%s.stepgen.timer-number", hm2->llio->name);
  159. + r = hal_pin_s32_new(name, HAL_IN, &(hm2->stepgen.hal->pin.dpll_timer_num), hm2->llio->comp_id);
  160. + if (r < 0) {
  161. + HM2_ERR("error adding timer number param, aborting\n");
  162. + return -EINVAL;
  163. + }
  164. + }
  165. +
  166. for (i = 0; i < hm2->stepgen.num_instances; i ++) {
  167.  
  168. // Work out if table setup registers are needed.
  169. (END)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement