Exemplo n.º 1
0
static int export_pin(int num, int dir, vti_struct * addr)
{
    int retval;
    if (dir != 0)
	retval =
	    export_output_pin(outpinnum++, &(addr->port[num / 8][num % 8]));
    else
	retval =
	    export_input_pin(inputpinnum++, &(addr->port[num / 8][num % 8]));
    if (retval != 0)
	return retval;
    return 0;
}
Exemplo n.º 2
0
static int export_port(int portnum, parport_t * port)
{
    int retval, msg;

    /* This function exports a lot of stuff, which results in a lot of
       logging if msg_level is at INFO or ALL. So we save the current value
       of msg_level and restore it later.  If you actually need to log this
       function's actions, change the second line below */
    msg = rtapi_get_msg_level();
    rtapi_set_msg_level(RTAPI_MSG_WARN);

    retval = 0;
    /* declare input pins (status port) */
    retval += export_input_pin(portnum, 15, port->status_in, 0);
    retval += export_input_pin(portnum, 13, port->status_in, 1);
    retval += export_input_pin(portnum, 12, port->status_in, 2);
    retval += export_input_pin(portnum, 10, port->status_in, 3);
    retval += export_input_pin(portnum, 11, port->status_in, 4);
    if (port->data_dir != 0) {
	/* declare input pins (data port) */
	retval += export_input_pin(portnum, 2, port->data_in, 0);
	retval += export_input_pin(portnum, 3, port->data_in, 1);
	retval += export_input_pin(portnum, 4, port->data_in, 2);
	retval += export_input_pin(portnum, 5, port->data_in, 3);
	retval += export_input_pin(portnum, 6, port->data_in, 4);
	retval += export_input_pin(portnum, 7, port->data_in, 5);
	retval += export_input_pin(portnum, 8, port->data_in, 6);
	retval += export_input_pin(portnum, 9, port->data_in, 7);
    } else {
	/* declare output pins (data port) */
	retval += export_output_pin(portnum, 2,
	    port->data_out, port->data_inv, port->data_reset, 0);
	retval += export_output_pin(portnum, 3,
	    port->data_out, port->data_inv, port->data_reset, 1);
	retval += export_output_pin(portnum, 4,
	    port->data_out, port->data_inv, port->data_reset, 2);
	retval += export_output_pin(portnum, 5,
	    port->data_out, port->data_inv, port->data_reset, 3);
	retval += export_output_pin(portnum, 6,
	    port->data_out, port->data_inv, port->data_reset, 4);
	retval += export_output_pin(portnum, 7,
	    port->data_out, port->data_inv, port->data_reset, 5);
	retval += export_output_pin(portnum, 8,
	    port->data_out, port->data_inv, port->data_reset, 6);
	retval += export_output_pin(portnum, 9,
	    port->data_out, port->data_inv, port->data_reset, 7);
	retval += hal_param_u32_newf(HAL_RW, &port->reset_time, comp_id, 
			"parport.%d.reset-time", portnum);
	retval += hal_param_u32_newf(HAL_RW, &port->debug1, comp_id, 
			"parport.%d.debug1", portnum);
	retval += hal_param_u32_newf(HAL_RW, &port->debug2, comp_id, 
			"parport.%d.debug2", portnum);
	port->write_time = 0;
    }
    if(port->use_control_in == 0) {
	/* declare output variables (control port) */
	retval += export_output_pin(portnum, 1,
	    port->control_out, port->control_inv, port->control_reset, 0);
	retval += export_output_pin(portnum, 14,
	    port->control_out, port->control_inv, port->control_reset, 1);
	retval += export_output_pin(portnum, 16,
	    port->control_out, port->control_inv, port->control_reset, 2);
	retval += export_output_pin(portnum, 17,
	    port->control_out, port->control_inv, port->control_reset, 3);
    } else {
	/* declare input variables (control port) */
        retval += export_input_pin(portnum, 1, port->control_in, 0);
        retval += export_input_pin(portnum, 14, port->control_in, 1);
        retval += export_input_pin(portnum, 16, port->control_in, 2);
        retval += export_input_pin(portnum, 17, port->control_in, 3);
    }

    /* restore saved message level */
    rtapi_set_msg_level(msg);
    return retval;
}