[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reading input data from par0



Mikael Starvik wrote:
>There is a bidirectional buffer between ETRAX and the parallel port.
>The direction of this buffer is set by changing the oe bit in
>R_PAR0_CTRL_DATA. Examples on how to do this can be found in
>http://developer.axis.com/doc/software/linux/device_drivers-howto.html
>
>/Mikael
>
>-----Original Message-----
>From: owner-dev-etrax@xxxxxxx.com [mailto:owner-dev-etrax@xxxxxxx.com] On Behalf Of Ion
>Sent: Tuesday, July 01, 2003 12:58 PM
>To: dev-etrax
>Subject: Reading data from par0
>
>
>Hi
>I want to read data(d0-d7,input/output) from the parallel port
>par0.Normally,when I want to read data from an input/output port I need
>high impedance at the entrance. Is it enough If I read the register
>R_PAR0_STATUS_DATA(0-7) to get this high impedance and apply an
>input?When can I apply an input, and when can I read it, in what moment?
>
>Thanks
>Ion Cadierno Gomez
>Mondragon Unibertsitatea(Arrasate)
>Basque Country
>
Hi
I'm trying and this is what I do. What is wrong by reading data from par0?
When the driver starts and I read data I have 0x04
When I write in the par0 and after if I read I always read FF and I can't read any data like input
 
static ssize_t driver_read (struct file * filep, char * buff, size_t count,
loff_t * offp)
{
*buff = (unsigned char) *R_PAR0_STATUS_DATA;
return count;
}
static ssize_t driver_write (struct file * filep, const char * buff,
size_t count, loff_t * offp)
{
 
*R_PAR0_CTRL_DATA = PAR_OE | *buff;
*R_PAR0_CTRL_DATA = 0;
 
return count;
}
static int __init etrax_CAN_sja1000_init(void)
{
if (register_chrdev(MAJOR_NUMBER, DEVICE_FILE, &driverCAN_fops))
{
printk("unable to get major %d for SJA1000 CAN controller\n", MAJOR_NUMBER);
}
*R_PAR0_CONFIG = 0x00000060; /*Manual-mode, enable port, inmediate mode change*/
return SUCCESS;
}
module_init(etrax_CAN_sja1000_init);