@@ -88,10 +88,10 @@ typedef struct {
8888 char count_detected ;
8989 char index_detected ;
9090 char latch_detected ;
91- rtapi_s32 raw_count ;
92- rtapi_u32 timestamp ;
93- rtapi_s32 index_count ;
94- rtapi_s32 latch_count ;
91+ rtapi_sint raw_count ;
92+ rtapi_uint timestamp ;
93+ rtapi_sint index_count ;
94+ rtapi_sint latch_count ;
9595} atomic ;
9696
9797/* this structure contains the runtime data for a single counter
@@ -120,10 +120,10 @@ typedef struct {
120120 hal_bool_t latch_in ; /* c:r counter latch input */
121121 hal_bool_t latch_rising ; /* u:r latch on rising edge? */
122122 hal_bool_t latch_falling ; /* u:r latch on falling edge? */
123- rtapi_s32 raw_count ; /* c:rw captured raw_count */
124- rtapi_u32 timestamp ; /* c:rw captured timestamp */
125- rtapi_s32 index_count ; /* c:rw captured index count */
126- rtapi_s32 latch_count ; /* c:rw captured index count */
123+ rtapi_sint raw_count ; /* c:rw captured raw_count */
124+ rtapi_uint timestamp ; /* c:rw captured timestamp */
125+ rtapi_sint index_count ; /* c:rw captured index count */
126+ rtapi_sint latch_count ; /* c:rw captured index count */
127127 hal_sint_t count ; /* c:w captured binary count value */
128128 hal_sint_t count_latch ; /* c:w captured binary count value */
129129 hal_real_t min_speed ; /* c:r minimum velocity to estimate nonzero */
@@ -140,7 +140,7 @@ typedef struct {
140140 int gaps ; /* gap counter (unlikely to ever be > 1) */
141141} counter_t ;
142142
143- static rtapi_u32 timebase ; /* master timestamp for all counters */
143+ static rtapi_uint timebase ; /* master timestamp for all counters */
144144
145145/* pointer to array of counter_t structs in shmem, 1 per counter */
146146static counter_t * counter_array ;
@@ -273,12 +273,12 @@ int rtapi_app_main(void)
273273 cntr -> buf [0 ].index_detected = 0 ;
274274 cntr -> buf [1 ].index_detected = 0 ;
275275 cntr -> bp = & (cntr -> buf [0 ]);
276- hal_set_si32 (cntr -> raw_counts , 0 );
276+ hal_set_sint (cntr -> raw_counts , 0 );
277277 cntr -> raw_count = 0 ;
278278 cntr -> timestamp = 0 ;
279279 cntr -> index_count = 0 ;
280280 cntr -> latch_count = 0 ;
281- hal_set_si32 (cntr -> count , 0 );
281+ hal_set_sint (cntr -> count , 0 );
282282 hal_set_real (cntr -> min_speed , 1.0 );
283283 hal_set_real (cntr -> pos , 0.0 );
284284 hal_set_real (cntr -> pos_latch , 0.0 );
@@ -332,7 +332,7 @@ static void update(void *arg, long period)
332332 cntr = arg ;
333333 for (n = 0 ; n < howmany ; n ++ ) {
334334 buf = (atomic * ) cntr -> bp ;
335- hal_set_si32 (cntr -> dt , hal_get_si32 (cntr -> dt ) + period );
335+ hal_set_sint (cntr -> dt , hal_get_sint (cntr -> dt ) + period );
336336 /* get state machine current state */
337337 state = cntr -> state ;
338338 /* add input bits to state code */
@@ -352,15 +352,15 @@ static void update(void *arg, long period)
352352 }
353353 /* should we count? */
354354 if (state & SM_CNT_UP_MASK ) {
355- if (hal_get_si32 (cntr -> missing_teeth ) && hal_get_si32 (cntr -> dt ) > hal_get_si32 (cntr -> limit_dt )){
355+ if (hal_get_sint (cntr -> missing_teeth ) && hal_get_sint (cntr -> dt ) > hal_get_sint (cntr -> limit_dt )){
356356 cntr -> gaps ++ ;
357357 }
358- buf -> raw_count = hal_set_si32 (cntr -> raw_counts , hal_get_si32 (cntr -> raw_counts ) + 1 );
358+ buf -> raw_count = hal_set_sint (cntr -> raw_counts , hal_get_sint (cntr -> raw_counts ) + 1 );
359359 buf -> timestamp = timebase ;
360360 buf -> count_detected = 1 ;
361- hal_set_si32 (cntr -> dt , 0 );
361+ hal_set_sint (cntr -> dt , 0 );
362362 } else if (state & SM_CNT_DN_MASK ) {
363- buf -> raw_count = hal_set_si32 (cntr -> raw_counts , hal_get_si32 (cntr -> raw_counts ) - 1 );
363+ buf -> raw_count = hal_set_sint (cntr -> raw_counts , hal_get_sint (cntr -> raw_counts ) - 1 );
364364 buf -> timestamp = timebase ;
365365 buf -> count_detected = 1 ;
366366 }
@@ -376,7 +376,7 @@ static void update(void *arg, long period)
376376 /* test for index enabled and rising edge on phase Z */
377377 if ((state & cntr -> Zmask ) == 1 ) {
378378 /* capture counts, reset Zmask */
379- buf -> index_count = hal_get_si32 (cntr -> raw_counts );
379+ buf -> index_count = hal_get_sint (cntr -> raw_counts );
380380 buf -> index_detected = 1 ;
381381 cntr -> Zmask = 0 ;
382382 }
@@ -388,7 +388,7 @@ static void update(void *arg, long period)
388388 if ((rising && hal_get_bool (cntr -> latch_rising ))
389389 || (falling && hal_get_bool (cntr -> latch_falling ))) {
390390 buf -> latch_detected = 1 ;
391- buf -> latch_count = hal_get_si32 (cntr -> raw_counts );
391+ buf -> latch_count = hal_get_sint (cntr -> raw_counts );
392392 }
393393 cntr -> old_latch = latch ;
394394
@@ -407,8 +407,8 @@ static void capture(void *arg, long period)
407407 counter_t * cntr ;
408408 atomic * buf ;
409409 int n ;
410- rtapi_s32 delta_counts ;
411- rtapi_u32 delta_time ;
410+ rtapi_sint delta_counts ;
411+ rtapi_uint delta_time ;
412412 double vel , interp ;
413413
414414 cntr = arg ;
@@ -465,26 +465,26 @@ static void capture(void *arg, long period)
465465 running count of edges seen since startup. The
466466 public "count" is the difference between raw_count
467467 and index_count, so it will become zero. */
468- cntr -> raw_count = hal_get_si32 (cntr -> raw_counts );
468+ cntr -> raw_count = hal_get_sint (cntr -> raw_counts );
469469 cntr -> index_count = cntr -> raw_count ;
470470 }
471471 /* process data from update() */
472472 if ( buf -> count_detected ) {
473- rtapi_s32 missing_teeth = hal_get_si32 (cntr -> missing_teeth );
473+ rtapi_sint missing_teeth = hal_get_sint (cntr -> missing_teeth );
474474 /* one or more counts in the last period */
475475 buf -> count_detected = 0 ;
476476 delta_time = buf -> timestamp - cntr -> timestamp ;
477477 delta_counts = buf -> raw_count - cntr -> raw_count ;
478478 // lowpass the gap detector deliberately ignoring missing teeth
479479 // see https://github.com/LinuxCNC/linuxcnc/issues/2635
480480 if (delta_counts != 0 ){
481- rtapi_s32 limit_dt = hal_get_si32 (cntr -> limit_dt );
481+ rtapi_sint limit_dt = hal_get_sint (cntr -> limit_dt );
482482 limit_dt *= 0.9 ;
483483 limit_dt += 0.1 * ((missing_teeth + 0.5 ) * (delta_time / delta_counts ));
484- hal_set_si32 (cntr -> limit_dt , limit_dt );
484+ hal_set_sint (cntr -> limit_dt , limit_dt );
485485 }
486486 // correct counts for tooth gap
487- hal_set_si32 (cntr -> raw_counts , hal_get_si32 (cntr -> raw_counts ) + missing_teeth * cntr -> gaps );
487+ hal_set_sint (cntr -> raw_counts , hal_get_sint (cntr -> raw_counts ) + missing_teeth * cntr -> gaps );
488488 cntr -> raw_count = buf -> raw_count + missing_teeth * cntr -> gaps ;
489489 delta_counts += missing_teeth * cntr -> gaps ;
490490 cntr -> gaps = 0 ;
@@ -500,7 +500,7 @@ static void capture(void *arg, long period)
500500 if ( cntr -> counts_since_timeout ) {
501501 /* calc time since last count */
502502 delta_time = timebase - cntr -> timestamp ;
503- if (hal_get_si32 (cntr -> missing_teeth ) && delta_time > 1.5 * hal_get_si32 (cntr -> limit_dt )){
503+ if (hal_get_sint (cntr -> missing_teeth ) && delta_time > 1.5 * hal_get_sint (cntr -> limit_dt )){
504504 // dont update the velocity in the tooth gap
505505 } else if ( delta_time < 1e9 / ( hal_get_real (cntr -> min_speed ) * cntr -> scale )) {
506506 /* not to long, estimate vel if a count arrived now */
@@ -527,11 +527,11 @@ static void capture(void *arg, long period)
527527 }
528528 hal_set_real (cntr -> vel_rpm , hal_get_real (cntr -> vel ) * 60.0 );
529529 /* compute net counts */
530- hal_set_si32 (cntr -> count , cntr -> raw_count - cntr -> index_count );
531- hal_set_si32 (cntr -> count_latch , cntr -> latch_count - cntr -> index_count );
530+ hal_set_sint (cntr -> count , cntr -> raw_count - cntr -> index_count );
531+ hal_set_sint (cntr -> count_latch , cntr -> latch_count - cntr -> index_count );
532532 /* scale count to make floating point position */
533- hal_set_real (cntr -> pos , hal_get_si32 (cntr -> count ) * cntr -> scale );
534- hal_set_real (cntr -> pos_latch , hal_get_si32 (cntr -> count_latch ) * cntr -> scale );
533+ hal_set_real (cntr -> pos , hal_get_sint (cntr -> count ) * cntr -> scale );
534+ hal_set_real (cntr -> pos_latch , hal_get_sint (cntr -> count_latch ) * cntr -> scale );
535535 /* add interpolation value */
536536 delta_time = timebase - cntr -> timestamp ;
537537 interp = hal_get_real (cntr -> vel ) * (delta_time * 1e-9 );
@@ -604,19 +604,19 @@ static int export_encoder(counter_t * addr,char * prefix)
604604 }
605605
606606 /* export parameter for raw counts */
607- retval = hal_pin_new_si32 (comp_id , HAL_OUT , & (addr -> raw_counts ), 0 ,
607+ retval = hal_pin_new_sint (comp_id , HAL_OUT , & (addr -> raw_counts ), 0 ,
608608 "%s.rawcounts" , prefix );
609609 if (retval != 0 ) {
610610 return retval ;
611611 }
612612 /* export pin for counts captured by capture() */
613- retval = hal_pin_new_si32 (comp_id , HAL_OUT , & (addr -> count ), 0 ,
613+ retval = hal_pin_new_sint (comp_id , HAL_OUT , & (addr -> count ), 0 ,
614614 "%s.counts" , prefix );
615615 if (retval != 0 ) {
616616 return retval ;
617617 }
618618 /* export pin for counts latched by capture() */
619- retval = hal_pin_new_si32 (comp_id , HAL_OUT , & (addr -> count_latch ), 0 ,
619+ retval = hal_pin_new_sint (comp_id , HAL_OUT , & (addr -> count_latch ), 0 ,
620620 "%s.counts-latched" , prefix );
621621 if (retval != 0 ) {
622622 return retval ;
@@ -676,7 +676,7 @@ static int export_encoder(counter_t * addr,char * prefix)
676676 return retval ;
677677 }
678678 /* export pin for missing-tooth index */
679- retval = hal_pin_new_si32 (comp_id , HAL_IN , & (addr -> missing_teeth ), 0 ,
679+ retval = hal_pin_new_sint (comp_id , HAL_IN , & (addr -> missing_teeth ), 0 ,
680680 "%s.missing-teeth" , prefix );
681681 if (retval != 0 ) {
682682 return retval ;
@@ -686,13 +686,13 @@ static int export_encoder(counter_t * addr,char * prefix)
686686#if 0
687687 // These two, 'dt' and 'limit_dt' are used in the code and if they are
688688 // used, then they must be created to allocate storage.
689- retval = hal_param_new_si32 (comp_id , HAL_RO , & (addr -> dt ), 0 ,
689+ retval = hal_param_new_sint (comp_id , HAL_RO , & (addr -> dt ), 0 ,
690690 "%s.dt" , prefix );
691691 if (retval != 0 ) {
692692 return retval ;
693693 }
694694
695- retval = hal_param_new_si32 (comp_id , HAL_RO , & (addr -> limit_dt ), 0 ,
695+ retval = hal_param_new_sint (comp_id , HAL_RO , & (addr -> limit_dt ), 0 ,
696696 "%s.limit_dt" , prefix );
697697 if (retval != 0 ) {
698698 return retval ;
0 commit comments