Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Autogenerated by /home/andypugh/emc2-dev/bin/comp on Wed Mar 16 22:14:07 2011 -- do not edit */
- #include "rtapi.h"
- #ifdef RTAPI
- #include "rtapi_app.h"
- #endif
- #include "rtapi_string.h"
- #include "rtapi_errno.h"
- #include "hal.h"
- static int comp_id;
- #ifdef MODULE_INFO
- MODULE_INFO(emc2, "component:hm2_7i65:Support for the Mesa 7i65 Octuple Servo Card");
- MODULE_INFO(emc2, "pin:test:bit:0:out::None:None");
- MODULE_INFO(emc2, "funct:_:1:");
- MODULE_INFO(emc2, "license:GPL");
- MODULE_INFO(emc2, "author:Andy Pugh");
- MODULE_LICENSE("GPL");
- #endif // MODULE_INFO
- struct state {
- struct state *_next;
- hal_bit_t *test;
- };
- struct state *inst=0;
- struct state *first_inst=0, *last_inst=0;
- static void _(struct state *inst, long period);
- static int get_data_size(void);
- static int extra_setup(struct state *inst, char *prefix, long extra_arg);
- #undef TRUE
- #define TRUE (1)
- #undef FALSE
- #define FALSE (0)
- #undef true
- #define true (1)
- #undef false
- #define false (0)
- static int export(char *prefix, long extra_arg) {
- char buf[HAL_NAME_LEN + 1];
- int r = 0;
- int sz = sizeof(struct state) + get_data_size();
- struct state *inst = hal_malloc(sz);
- memset(inst, 0, sz);
- r = extra_setup(inst, prefix, extra_arg);
- if(r != 0) return r;
- r = hal_pin_bit_newf(HAL_OUT, &(inst->test), comp_id,
- "%s.test", prefix);
- if(r != 0) return r;
- rtapi_snprintf(buf, sizeof(buf), "%s", prefix);
- r = hal_export_funct(buf, (void(*)(void *inst, long))_, inst, 1, 0, comp_id);
- if(r != 0) return r;
- if(last_inst) last_inst->_next = inst;
- last_inst = inst;
- if(!first_inst) first_inst = inst;
- return 0;
- }
- static int get_count(void);
- int rtapi_app_main(void) {
- int r = 0;
- int i;
- int count = get_count();
- comp_id = hal_init("hm2_7i65");
- if(comp_id < 0) return comp_id;
- for(i=0; i<count; i++) {
- char buf[HAL_NAME_LEN + 1];
- rtapi_snprintf(buf, sizeof(buf), "hm2-7i65.%d", i);
- r = export(buf, i);
- }
- if(r) {
- hal_exit(comp_id);
- } else {
- hal_ready(comp_id);
- }
- return r;
- }
- void rtapi_app_exit(void) {
- hal_exit(comp_id);
- }
- #undef FUNCTION
- #define FUNCTION(name) static void name(struct state *inst, long period)
- #undef EXTRA_SETUP
- #define EXTRA_SETUP() static int extra_setup(struct state *inst, char *prefix, long extra_arg)
- #undef EXTRA_CLEANUP
- #define EXTRA_CLEANUP() static void extra_cleanup(void)
- #undef fperiod
- #define fperiod (period * 1e-9)
- #undef test
- #define test (*inst->test)
- #line 11 "hal/components/mesa_7i65.comp"
- #include "../hal/drivers/mesa-hostmot2/hostmot2.h"
- static char *bspi_chans[16];
- RTAPI_MP_ARRAY_STRING(bspi_chans, 16, "Description of each motor");
- FUNCTION(_){
- }
- EXTRA_SETUP(){
- hm2_bspi_instance_t *b;
- int r;
- HM2_PRINT_NO_LL("entering EXTRA_SETUP");
- r = hm2_get_bspi(b, bspi_chans[extra_arg]);
- HM2_PRINT_NO_LL("found bspi names %s\n",b->name);
- return 0;
- }
- int get_count(void){
- int i;
- HM2_PRINT_NO_LL("Entering get_count\n");
- for (i = 0; bspi_chans[i] != NULL && i < 16 ; i++){
- HM2_PRINT_NO_LL("%s\n", bspi_chans[i]);
- }
- return i;
- }
- static int get_data_size(void) { return 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement