ts-7000
[Top] [All Lists]

[ts-7000] TSDIO - DIO generic driver for TS-7260

To:
Subject: [ts-7000] TSDIO - DIO generic driver for TS-7260
From: "Guillermo Prandi" <>
Date: Fri, 28 Jul 2006 19:28:39 -0000
I've been busy writing some generic code for performing digital I/O
with the TS-7260 board. I was needing to detect interrupts generated
from an outside source from user space. I'd like to share the code
with the community. Your comments will be very much appreciated.

README file contents:

TS-DIO driver
-------------

This software is distributed under the GNU GENERAL PUBLIC LICENSE
Version 2.
See accompannying LICENSE file for further details.

This program is intended as a generic driver for digital I/O on port
DIO1 (pins 1,3,5,7,9,11,13,15) of the TS-7260. Other boards based on
the Cyrrus Logic 9301/9302 microcontroller might benefit of this
driver if devices are connected to port B.

There are three kind of accesses: read, write and interrupt. Read and
interrupt
accesses put the port in input mode, whilst write access puts the
port in
output mode. In addition, bits can be read/write either individually
or as
an 8-bit port. For interrupt access, only individual bits can be
accessed.

For input modes (read and interrupt), the debounce feature of the I/O
port
can be activated.

Accesses can have binary or text semantics, the latter being more
adequate
for shell script access.

This software was tested with Technology System's TS-7260 SBC,
compiled under Linux version 2.4.26 TS11.

----------------------------------------------------------------------
-

Installation:

Change the current directory to your Linux compilation directory.
First, copy tsdio.c to drivers/char/ inside your Linux compilation
directory. Then apply the patch to the Makefile using:

patch -p0 < drivers_char_Makefile.patch

(You must be standing on the Linux source base directory and
not in drivers/char; change the source path for the patch as
necessary.)

Compile and install the Linux image. While booting, you should
see the following message:

tsdio: initialized with major 238

----------------------------------------------------------------------
-

Major device number is 238

Minor device configuration:

        76543210

        t0d00bbb                configured as input (read only)
        t0001bbb                configured as output (read/write)
        ted10bbb                configured for interrupt catch (read
only)
        t0d11000                configured as input (all 8 bits at
once)
        t0011001                configured as output (all 8 bits at
once)

        bbb = DIO port number
        d = use debouncing
        e = edge (0 = falling, 1 = rising)
        t = use text-compatible semantics (0 = binary, 1 = text)

        Example:

        For a motor switch controlled by DIO_2 (pin 5 on DIO1 header),
        use:

        mknod /dev/motorctrl c 238 138

        echo 1 > /dev/motorctrl # Turn on
        echo 0 > /dev/motorctrl # Turn off

        For a push button on DIO_1 (pin 3 on DIO1 header) which is
        normally high, use:

        mknod /dev/pushbutton1 c 238 177

        while read x < /dev/pushbutton1 ; true
        do echo "Pressed!"
        done

        If you've got devfs installed, you can use the automatic
        devices created during boot:

        /dev/tsdio/[t]read{0-7}[db]
        /dev/tsdio/[t]write{0-7}
        /dev/tsdio/[t]intr{0-7}{r,f}[db]
        /dev/tsdio/[t]readall[db]
        /dev/tsdio/[t]writeall

Binary semantics:

        A read from a single-bit binary 'read' or 'write' device will
repeat
        port reads for the number of characters requested and return
        '1' or '0' for each read depending on the port's state.
        No special timing considerations are taken.

        A read from a single-bit binary 'intr' device will return
        a '1' character for each interrupt processed since the device
        was opened.  If no interrupts are pending, the read will
either
        block or return 0 bytes, depending on the setting of the
O_NONBLOCK
        flag on the open file.

        A read from a byte-wide binary 'read' or 'write' device will
repeat
        port reads for the number of characters requested and return
        the current port status on each read. No special timing
considerations
        are taken.

        A write on a single-bit binary 'write' device will set the
port state
        to either high or low depending on the bit 0 of each
character written
        to the device. No special timing considerations are taken.

        A write on a byte-wide binary 'write' device will set the
port state
        according to the each character written to the device. No
special
        timing considerations are taken.

        A read from a 'write' device will reflect the state of a
previous
        write operation (or the initial device state, if no write was
        performed).

        Opening a 'read' or 'intr' device will make the port(s) be set
        as input if they were previously output.

        Opening a 'write' device will make the port(s) be set as
output
        if they were previously input. The port(s) state will remain
        unchanged.

        Closing a 'read' or 'intr' device will leave the port(s) as
input.

        Closing a 'write' device will leave the port(s) as output, in
its
        current state.

        Any port (either single bit or byte-wide) can be opened
multiple
        times, provided the open modes are compatible and they are not
        opened for interrupt processing ('intr') twice.

Text semantics: differences from binary semantics

        A read from a single-bit text device will only return one byte
        ('1' or '0') and then report end of file.

        A read from a byte-wide text device will only return one byte
        reflecting the port status and then report end of file.

        A write to a single-bit text device will ignore any characters
        different from '1' and '0'.







Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/



<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU