Advertisement
Guest User

Untitled

a guest
Mar 16th, 2011
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. /* Autogenerated by /home/andypugh/emc2-dev/bin/comp on Wed Mar 16 22:14:07 2011 -- do not edit */
  2. #include "rtapi.h"
  3. #ifdef RTAPI
  4. #include "rtapi_app.h"
  5. #endif
  6. #include "rtapi_string.h"
  7. #include "rtapi_errno.h"
  8. #include "hal.h"
  9.  
  10. static int comp_id;
  11.  
  12. #ifdef MODULE_INFO
  13. MODULE_INFO(emc2, "component:hm2_7i65:Support for the Mesa 7i65 Octuple Servo Card");
  14. MODULE_INFO(emc2, "pin:test:bit:0:out::None:None");
  15. MODULE_INFO(emc2, "funct:_:1:");
  16. MODULE_INFO(emc2, "license:GPL");
  17. MODULE_INFO(emc2, "author:Andy Pugh");
  18. MODULE_LICENSE("GPL");
  19. #endif // MODULE_INFO
  20.  
  21.  
  22. struct state {
  23. struct state *_next;
  24. hal_bit_t *test;
  25. };
  26. struct state *inst=0;
  27. struct state *first_inst=0, *last_inst=0;
  28.  
  29. static void _(struct state *inst, long period);
  30. static int get_data_size(void);
  31. static int extra_setup(struct state *inst, char *prefix, long extra_arg);
  32. #undef TRUE
  33. #define TRUE (1)
  34. #undef FALSE
  35. #define FALSE (0)
  36. #undef true
  37. #define true (1)
  38. #undef false
  39. #define false (0)
  40.  
  41. static int export(char *prefix, long extra_arg) {
  42. char buf[HAL_NAME_LEN + 1];
  43. int r = 0;
  44. int sz = sizeof(struct state) + get_data_size();
  45. struct state *inst = hal_malloc(sz);
  46. memset(inst, 0, sz);
  47. r = extra_setup(inst, prefix, extra_arg);
  48. if(r != 0) return r;
  49. r = hal_pin_bit_newf(HAL_OUT, &(inst->test), comp_id,
  50. "%s.test", prefix);
  51. if(r != 0) return r;
  52. rtapi_snprintf(buf, sizeof(buf), "%s", prefix);
  53. r = hal_export_funct(buf, (void(*)(void *inst, long))_, inst, 1, 0, comp_id);
  54. if(r != 0) return r;
  55. if(last_inst) last_inst->_next = inst;
  56. last_inst = inst;
  57. if(!first_inst) first_inst = inst;
  58. return 0;
  59. }
  60. static int get_count(void);
  61. int rtapi_app_main(void) {
  62. int r = 0;
  63. int i;
  64. int count = get_count();
  65. comp_id = hal_init("hm2_7i65");
  66. if(comp_id < 0) return comp_id;
  67. for(i=0; i<count; i++) {
  68. char buf[HAL_NAME_LEN + 1];
  69. rtapi_snprintf(buf, sizeof(buf), "hm2-7i65.%d", i);
  70. r = export(buf, i);
  71. }
  72. if(r) {
  73. hal_exit(comp_id);
  74. } else {
  75. hal_ready(comp_id);
  76. }
  77. return r;
  78. }
  79.  
  80. void rtapi_app_exit(void) {
  81. hal_exit(comp_id);
  82. }
  83.  
  84. #undef FUNCTION
  85. #define FUNCTION(name) static void name(struct state *inst, long period)
  86. #undef EXTRA_SETUP
  87. #define EXTRA_SETUP() static int extra_setup(struct state *inst, char *prefix, long extra_arg)
  88. #undef EXTRA_CLEANUP
  89. #define EXTRA_CLEANUP() static void extra_cleanup(void)
  90. #undef fperiod
  91. #define fperiod (period * 1e-9)
  92. #undef test
  93. #define test (*inst->test)
  94.  
  95.  
  96. #line 11 "hal/components/mesa_7i65.comp"
  97.  
  98. #include "../hal/drivers/mesa-hostmot2/hostmot2.h"
  99.  
  100. static char *bspi_chans[16];
  101. RTAPI_MP_ARRAY_STRING(bspi_chans, 16, "Description of each motor");
  102.  
  103. FUNCTION(_){
  104.  
  105. }
  106.  
  107. EXTRA_SETUP(){
  108. hm2_bspi_instance_t *b;
  109. int r;
  110. HM2_PRINT_NO_LL("entering EXTRA_SETUP");
  111. r = hm2_get_bspi(b, bspi_chans[extra_arg]);
  112. HM2_PRINT_NO_LL("found bspi names %s\n",b->name);
  113. return 0;
  114. }
  115.  
  116. int get_count(void){
  117. int i;
  118. HM2_PRINT_NO_LL("Entering get_count\n");
  119. for (i = 0; bspi_chans[i] != NULL && i < 16 ; i++){
  120. HM2_PRINT_NO_LL("%s\n", bspi_chans[i]);
  121. }
  122. return i;
  123. }
  124.  
  125. static int get_data_size(void) { return 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement