@@ -86,14 +86,14 @@ RTAPI_MP_STRING(cfg, "config string"); */
8686*/
8787
8888typedef struct {
89- void * io_base ;
90- hal_float_t * dac_out [3 ]; /* ptrs for dac output */
91- hal_float_t * position [3 ]; /* ptrs for encoder input */
92- hal_bit_t * digital_in [47 ]; /* ptrs for digital input pins 0 - 45 */
93- hal_bit_t * digital_out [25 ]; /* ptrs for digital output pins 0 - 20 */
94- __u16 raw_counts_old [3 ];
95- __s32 counts [3 ];
96- hal_float_t pos_scale ; /*! \todo scale for position command FIXME should be one per axis */
89+ void * io_base ;
90+ hal_real_t dac_out [3 ]; /* ptrs for dac output */
91+ hal_real_t position [3 ]; /* ptrs for encoder input */
92+ hal_bool_t digital_in [47 ]; /* ptrs for digital input pins 0 - 45 */
93+ hal_bool_t digital_out [25 ]; /* ptrs for digital output pins 0 - 20 */
94+ rtapi_u16 raw_counts_old [3 ];
95+ rtapi_s32 counts [3 ];
96+ hal_real_t pos_scale ; /*! \todo scale for position command FIXME should be one per axis */
9797} evoreg_t ;
9898
9999/* pointer to array of evoreg_t structs in shared memory, 1 per port */
@@ -172,8 +172,8 @@ int rtapi_app_main(void)
172172
173173 /* Export DAC pin's */
174174 for ( num_dac = 1 ; num_dac <=MAX_DAC ; num_dac ++ ) {
175- retval = hal_pin_float_newf ( HAL_IN , & (port_data_array -> dac_out [num_dac - 1 ]),
176- comp_id , "evoreg.%d.dac-%02d-out" , 1 , num_dac );
175+ retval = hal_pin_new_real ( comp_id , HAL_IN , & (port_data_array -> dac_out [num_dac - 1 ]),
176+ 0.0 , "evoreg.%d.dac-%02d-out" , 1 , num_dac );
177177 if (retval < 0 ) {
178178 rtapi_print_msg (RTAPI_MSG_ERR ,
179179 "EVOREG: ERROR: port %d var export failed with err=%i\n" , n + 1 ,
@@ -185,8 +185,8 @@ int rtapi_app_main(void)
185185
186186 /* Export Encoder pin's */
187187 for ( num_enc = 1 ; num_enc <=MAX_ENC ; num_enc ++ ) {
188- retval = hal_pin_float_newf ( HAL_OUT , & (port_data_array -> position [num_enc - 1 ]),
189- comp_id , "evoreg.%d.position-%02d-in" , 1 , num_enc );
188+ retval = hal_pin_new_real ( comp_id , HAL_OUT , & (port_data_array -> position [num_enc - 1 ]),
189+ 0.0 , "evoreg.%d.position-%02d-in" , 1 , num_enc );
190190 if (retval < 0 ) {
191191 rtapi_print_msg (RTAPI_MSG_ERR ,
192192 "EVOREG: ERROR: port %d var export failed with err=%i\n" , n + 1 ,
@@ -200,8 +200,8 @@ int rtapi_app_main(void)
200200
201201 /* export write only HAL pin's for the input bit */
202202 for ( i = 0 ; i <=45 ;i ++ ) {
203- retval += hal_pin_bit_newf ( HAL_OUT , & (port_data_array -> digital_in [i ]),
204- comp_id , "evoreg.%d.pin-%02d-in" , 1 , i );
203+ retval += hal_pin_new_bool ( comp_id , HAL_OUT , & (port_data_array -> digital_in [i ]),
204+ 0 , "evoreg.%d.pin-%02d-in" , 1 , i );
205205
206206 /* export another write only HAL pin for the same bit inverted */
207207 /*
@@ -218,8 +218,8 @@ int rtapi_app_main(void)
218218
219219 /* export read only HAL pin's for the output bit */
220220 for ( i = 0 ; i <=23 ;i ++ ) {
221- retval += hal_pin_bit_newf ( HAL_IN , & (port_data_array -> digital_out [i ]),
222- comp_id , "evoreg.%d.pin-%02d-out" , 1 , i );
221+ retval += hal_pin_new_bool ( comp_id , HAL_IN , & (port_data_array -> digital_out [i ]),
222+ 0 , "evoreg.%d.pin-%02d-out" , 1 , i );
223223
224224 /* export another read only HAL pin for the same bit inverted */
225225 /*
@@ -235,8 +235,8 @@ int rtapi_app_main(void)
235235 }
236236
237237 /* export parameter for scaling */
238- retval = hal_param_float_newf ( HAL_RW , & (port_data_array -> pos_scale ),
239- comp_id , "evoreg.%d.position-scale" , 1 );
238+ retval = hal_param_new_real ( comp_id , HAL_RW , & (port_data_array -> pos_scale ),
239+ 0.0 , "evoreg.%d.position-scale" , 1 );
240240 if (retval != 0 ) {
241241 return retval ;
242242 }
@@ -278,9 +278,9 @@ static void update_port(void *arg, long period)
278278 port = arg ;
279279
280280/* write DAC's */
281- writew ((* (port -> dac_out [0 ])/10 * 0x7fff ), (char * )port -> io_base + 0x60 );
282- writew ((* (port -> dac_out [1 ])/10 * 0x7fff ), (char * )port -> io_base + 0x80 );
283- writew ((* (port -> dac_out [2 ])/10 * 0x7fff ), (char * )port -> io_base + 0xa0 );
281+ writew ((hal_get_real (port -> dac_out [0 ])/10 * 0x7fff ), (char * )port -> io_base + 0x60 );
282+ writew ((hal_get_real (port -> dac_out [1 ])/10 * 0x7fff ), (char * )port -> io_base + 0x80 );
283+ writew ((hal_get_real (port -> dac_out [2 ])/10 * 0x7fff ), (char * )port -> io_base + 0xa0 );
284284
285285/* Read Encoders, improve the 16bit hardware counters to 32bit and scale the values */
286286 raw_counts [0 ] = (__u16 ) readw (port -> io_base );
@@ -296,29 +296,30 @@ static void update_port(void *arg, long period)
296296 port -> counts [2 ] += (__s16 ) (raw_counts [2 ] - port -> raw_counts_old [2 ]);
297297 port -> raw_counts_old [2 ] = raw_counts [2 ];
298298
299- * port -> position [0 ] = port -> counts [0 ] * port -> pos_scale ;
300- * port -> position [1 ] = port -> counts [1 ] * port -> pos_scale ;
301- * port -> position [2 ] = port -> counts [2 ] * port -> pos_scale ;
299+ rtapi_real pos_scale = hal_get_real (port -> pos_scale );
300+ hal_set_real (port -> position [0 ], port -> counts [0 ] * pos_scale );
301+ hal_set_real (port -> position [1 ], port -> counts [1 ] * pos_scale );
302+ hal_set_real (port -> position [2 ], port -> counts [2 ] * pos_scale );
302303
303304
304305/* read digital inputs */
305306 tmp = readw ((char * )port -> io_base + 0x20 ); /* digital input 0-15 */
306307 mask = 0x01 ;
307308 for (pin = 0 ; pin < 16 ; pin ++ ) {
308- * port -> digital_in [pin ] = (tmp & mask ) ? 1 :0 ;
309+ hal_set_bool ( port -> digital_in [pin ], (tmp & mask ) ? 1 :0 ) ;
309310 mask <<= 1 ;
310311 }
311312 tmp = readw ((char * )port -> io_base + 0x40 ); /* digital input 16-31 */
312313 mask = 0x01 ;
313314 for (pin = 16 ; pin < 32 ; pin ++ ) {
314- * port -> digital_in [pin ] = (tmp & mask ) ? 1 :0 ;
315+ hal_set_bool ( port -> digital_in [pin ], (tmp & mask ) ? 1 :0 ) ;
315316 mask <<= 1 ;
316317 }
317318
318319 tmp = readw ((char * )port -> io_base + 0x60 ); /* digital input 32-45 */
319320 mask = 0x01 ;
320321 for (pin = 32 ; pin < 46 ; pin ++ ) {
321- * port -> digital_in [pin ] = (tmp & mask ) ? 1 :0 ;
322+ hal_set_bool ( port -> digital_in [pin ], (tmp & mask ) ? 1 :0 ) ;
322323 mask <<= 1 ;
323324 }
324325
@@ -327,21 +328,21 @@ static void update_port(void *arg, long period)
327328 tmp = 0x0 ;
328329 mask = 0x01 ;
329330 for (pin = 0 ; pin < 16 ; pin ++ ) {
330- if (port -> digital_out [pin ]) {
331+ if (hal_get_bool ( port -> digital_out [pin ]) ) {
331332 tmp |= mask ;
332- mask <<= 1 ;
333333 }
334+ mask <<= 1 ;
334335 }
335336 writew ( tmp , (char * )port -> io_base + 0x20 ); /* digital output 0-15 */
336337
337338
338339 tmp = 0x0 ;
339340 mask = 0x01 ;
340341 for (pin = 16 ; pin < 24 ; pin ++ ) {
341- if (port -> digital_out [pin ]) {
342+ if (hal_get_bool ( port -> digital_out [pin ]) ) {
342343 tmp |= mask ;
343- mask <<= 1 ;
344344 }
345+ mask <<= 1 ;
345346 }
346347 writew ( tmp , (char * )port -> io_base + 0x40 ); /* digital output 16-23 */
347348
0 commit comments