gph-2746c - interface · the 8255 ppi controllers. as the result, you do not have to consider the...

56
PPI(PCI/C-PCI)Linux/RT www.interface.co.jp GPH-2746C Programmable Peripheral Interface Board Driver Software for Linux/RT Help for Linux

Upload: others

Post on 20-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

  • PPI(PCI/C-PCI)Linux/RT

    www.interface.co.jp

    GPH-2746CProgrammable Peripheral Interface Board Driver Software for Linux/RT

    Help for Linux

  • GPH-2746C Help for Linux

    Contents

    Copyright 2004 Interface Corporation. All rights reserved.

    2

    Chapter 1 Introduction.......................................................................................................31.1 Summary .............................................................................................................................................................. 31.2 Features................................................................................................................................................................ 3

    Chapter 2 Product Specifications ......................................................................................42.1 Operating Environments ....................................................................................................................................... 42.2 Target Products .................................................................................................................................................... 42.3 Functional Specifications ...................................................................................................................................... 5

    Chapter 3 Installation and Board Configuration.................................................................63.1 Installing the Linux Driver Software ...................................................................................................................... 63.2 Loading the Driver Modules.................................................................................................................................. 63.3 Configuring the Device Numbers .......................................................................................................................... 63.4 Programming ........................................................................................................................................................ 83.5 Compiling the Program ......................................................................................................................................... 83.6 Running the Program............................................................................................................................................ 83.7 Unloading the Driver Modules............................................................................................................................... 83.8 Programming Guide.............................................................................................................................................. 9

    3.8.1 Initializing a Board.................................................................................................................................. 93.8.2 Input/Output ........................................................................................................................................... 93.8.3 Timer...................................................................................................................................................... 93.8.4 Interrupt................................................................................................................................................ 103.8.5 Closing the Board ................................................................................................................................ 10

    3.9 Selecting a 8255 Controller................................................................................................................................. 113.10 Describing a 8255 PPI Controller Function ....................................................................................................... 12

    3.10.1 Port A, Port B, and Port C.................................................................................................................. 123.10.2 Group A and Group B Controls .......................................................................................................... 133.10.3 Control Word...................................................................................................................................... 133.10.4 Mode Selection .................................................................................................................................. 133.10.5 Bit Set/Reset Feature......................................................................................................................... 143.10.6 Operating Modes ............................................................................................................................... 15

    Chapter 4 Reference.......................................................................................................224.1 List of Functions.................................................................................................................................................. 22

    4.1.1 PpiOpen............................................................................................................................................... 234.1.2 PpiClose............................................................................................................................................... 244.1.3 PpiControl ............................................................................................................................................ 254.1.4 PpiInputPort ......................................................................................................................................... 264.1.5 PpiOutputPort ...................................................................................................................................... 284.1.6 PpiSetEventMask................................................................................................................................. 304.1.7 PpiGetEventMask ................................................................................................................................ 324.1.8 PpiSetEventConfig............................................................................................................................... 344.1.9 PpiGetEventConfig .............................................................................................................................. 364.1.10 PpiSetTimerConfig............................................................................................................................. 384.1.11 PpiGetTimerConfig ............................................................................................................................ 404.1.12 PpiGetTimerCount ............................................................................................................................. 424.1.13 PpiGetResetInStatus ......................................................................................................................... 444.1.14 PpiRegistIsr........................................................................................................................................ 454.1.15 PpiCommonGetPciDeviceInfo............................................................................................................ 464.1.16 CallBackProc ..................................................................................................................................... 49

    4.2 Return Values ..................................................................................................................................................... 504.3 Kylix .................................................................................................................................................................... 51

    4.3.1 Function Definitions ............................................................................................................................. 514.3.2 Example ............................................................................................................................................... 52

    4.4 Test Driver .......................................................................................................................................................... 54

    Chapter 5 Sample Programs...........................................................................................555.1 How to Compile the Sample Programs (C) ......................................................................................................... 555.2 How to Compile the Sample Programs (Kylix) .................................................................................................... 55

    Chapter 6 Important Information .....................................................................................566.1 Limited Warranty................................................................................................................................................. 566.2 Copyrights and Intellectual Property Rights ........................................................................................................ 566.3 Warning Regarding Medical and Clinical Use of Interface Products................................................................... 566.4 Limitation of Liability ........................................................................................................................................... 566.5 Trademark .......................................................................................................................................................... 56

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    3

    Chapter 1 Introduction1.1 Summary

    The GPH-2746C software controls Interface digital input/output boards with the 8255 PPI controllers fromyour application running on Linux or RTLinux. Application software should link a Lib provided and controlthe digital input/output boards with the 8255 PPI controllers through the application programming interface.This document includes the information for using the GPH-2746C on Linux.

    1.2 Features- The GPH-2746C is a hierarchy architecture driver and standardized for our digital input/output boards with

    the 8255 PPI controllers. As the result, you do not have to consider the board type except board specificfeatures.

    - The GPH-2746C supports three operation modes of the 8255 PPI controllers. - The commands to input and output for each port are available by the operation mode of the 8255 PPI

    controllers. - When interrupt events occur, events are signaled. And then, you can handle interrupt events at the user

    mode. - The Help system explains how to use the supported functions. Refer to it as you develop your programs.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    4

    Chapter 2 Product Specifications2.1 Operating Environments

    The following table shows operating environments for the GPH-2746C.

    Interface Single BoardComputers

    Contact us.

    Interface Mother Boards Contact us.Computer Intel Architecture-32 (IBM PC/AT compatibles)Driver Type Character driverLoading Method Loadable moduleMajor Number Automatic assignmentSource Code Open Policy Driver module: Partially open

    Library source code: closeCommon module: open

    Build Support Makefile providedKernel Version IBM PC/AT compatibles

    - Kernel 2.2.x - Kernel 2.4.xInterface SH-CPU board - Kernel 2.4.x

    Library Version glibc 2.1.3 or laterPDF formatHelp FileText format

    2.2 Target Products- PCI expansion boards (PCI series)

    PCI-2746C PCI-2747A

    - CompactPCI board (CTP series)

    CTP-2746

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    5

    2.3 Functional SpecificationsFunction Description/Specification

    Number of boards 255 boards (max.) (Up to 16 boards of the same model may be controlled.)Synchronous input/output usingthe control signals

    PPI boards can both synchronously input data from external circuits by usingthe STB and ACK signals, as well as synchronously output data to externalcircuits. Please refer to the corresponding board user's manual for thebehavior of the input and output circuit if you use the control signals.

    Interrupt events When an interrupt event occurs, the function that is specified by the user canbe called. The following signals can trigger an interrupt:• 1PC0 (8255 controller_1, Port C, PC0)• 1PC3 (8255 controller_1, Port C, PC3) or IR.IN1

    * PCI-2747A does not have IR.IN1.• 2PC0 (8255 controller_2, Port C, PC0)

    * PCI-2747A does not have 8255 controller_2.• 2PC3 (8255 controller_2, Port C, PC3) or IR.IN2

    * PCI-2747A does not have 8255 controller_2 and IR.IN2.• Interval timer• External reset signal input (RSTIN)

    Interrupt mask You can selectively mask or unmask desired interrupts.Interval timer The interval timer can be used to generate an interrupt to the host computer

    at every timer cycle. It is recommended that you use interrupt timer intervalgreater than or equal to 10 ms. (10 ms to 1500 ms)

    External Reset Signal Input(RSTIN)

    The RSTIN signal resets the board. When RSTIN is asserted, the board isreset to its default setting. A reset will stop the interval timer.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    6

    Chapter 3 Installation and Board Configuration3.1 Installing the Linux Driver Software

    1. Install the board into the open slot according to the manual of your board.2. Run Linux.3. Install the Linux driver software according to the instructions of the installer.

    #sh install

    Please refer to the readme.txt for details of how to install the driver software.

    3.2 Loading the Driver ModulesLoad the GPH-2746C driver modules with insppi.sh. Run a shell script for loading the driver modules.cd /usr/src/interface/gph2746C/*/linux/drivers

    #sh insppi.sh

    Note: * The following names are applicable to the GPH-2746C.- Intel Architecture-32: i386- SH-4: sh4

    3.3 Configuring the Device Numbers1. Start the device number setting utility dpg0101.

    #/usr/bin/dpg0101

    2. When the device number setting utility starts, the following information and prompt will be displayed.**************************************************

    Setup Utility

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

    Version: 1.20-06

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

    Copyright 2003, 2004 Interface Corporation.

    All rights reserved.

    **************************************************

    Enter the model number of the product: GPG/GPH-

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    7

    3. Enter 2746 and press the Enter key. The software searches every Interface digital input/output boardswith the 8255 PPI controllers boards installed on the system, then displays information about them.========================================

    Ref.ID | Model | RSW1 | Device No.

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

    1 | PCI-2746C | 0 | 1

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

    2 | PCI-2746C | 1 | 2

    ========================================

    Code Description

    Ref. ID Reference ID of the boardModel Model number of the boardRSW1 RSW1 setting valueDevice No. Device number assigned to the board.

    4. Select the command.************* Command ************

    1. Change the device number.

    2. Delete the device number.

    3. Load new device setting file.

    4. Run the initialization program.

    5. Run the CardBus ID setup utility.

    99.Exit the program.

    **********************************

    Enter the command number:

    No. Command Description

    1 Change the device number. Changes the device number of the board.2 Delete the device number. Deletes the device number. To delete it, enter the ID of the

    board.3 Load new device setting file. Loads other device setting file.4 Run the initialization program. The GPH-2746C doesn’t support this command.5 Run the CardBus ID setup

    utility.The GPH-2746C doesn’t support this command.

    99 Exit the program. Exit the device number setting utility.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    8

    3.4 ProgrammingWrite your program. You can refer to “Chapter 5 Sample Programs,” for more details aboutprogramming.

    3.5 Compiling the ProgramCompile your program. Type the command as follows. The following line shows an example for sample.cas file name.#gcc -o sample sample.c -lgpg2746

    3.6 Running the ProgramRun the program as follows.#./sample

    Refer to “3.8 Programming Guide,” for more details of how to program.

    3.7 Unloading the Driver ModulesWhen you unload the driver modules after finishing your hardware control, you need to run a shell scriptfor unloading the driver modules on the same directory that you used to load them.#cd /usr/src/interface/gph2746c//linux/drivers

    #rm rmppi.sh

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    9

    3.8 Programming Guide3.8.1 Initializing a Board

    The PpiOpen function initializes a board.

    nDeviceNumber = 1;

    nRet = PpiOpen(nDeviceNumber, 0 );

    The device driver assigns device number by using the device number setting program. The digitalinput/output boards with the 8255 PPI controllers are uniquely identified with the device number. Specifiythe device number when you call the function. 00000000h is returned to nRet after the board is successfullyinitialized. The nRet allows you to reference the board and must be specified when a function is called. Ifyou use two or more PPI boards, you need to call the PpiOpen function at each device. The initializedboard must be closed by the PpiClose function before the application is terminated.

    3.8.2 Input/OutputThe PpiControl function configures the operation mode and input/output direction of ports. Refer to“3.10 Describing a 8255 PPI Controller Function,” for more details.PpiControl( hDeviceHandle, FBIPPI_8255_CONTROLLER1, bControlData );

    The PpiInputPort function reads the data from each port of the 8255 PPI controller.PpiInputPort( hDeviceHandle, FBIPPI_8255_CONTROLLER1,FBIPPI_PORT_A,

    &bValue );

    The PpiOutputPort function writes the data to each port of the 8255 PPI controller.PpiOutputPort( hDeviceHandle, FBIPPI_8255_CONTROLLER2,FBIPPI_PORT_B,

    bValue );

    3.8.3 TimerThe PpiSetTimerConfig function programs a base clock and a divisor of the timer. The PpiGetTimerConfigfunction retrieves the settings of the base clock and the divisor of the timer. The PpiGetTimerCountfunction reads a tick count from the timer on the board.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    10

    3.8.4 InterruptThe following signals can be used to request service from the host computer.

    1INTRA (1PC3)1INTRB (1PC0) or IR.IN12INTRA (2PC3)2INTRB (2PC0) or IR.IN2Interval timerRSTIN

    INTRA (PC3)INTRB (PC0)Interval timerRSTIN

    The PpiRegistIsr function registers the callback routine that is called when an interrupt occurs. Please maskthe interrupt event correctly and select the polarity of the edge and interrupt sources. The PpiSetEventMaskor PpiSetEventConfig function configures above things. And the PpiGetEventMask or PpiGetEventConfigfunction retrieves above things.

    3.8.5 Closing the BoardThe PpiClose function closes the board and releases the resources.

    PpiClose(nDeviceNumber );

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    11

    3.9 Selecting a 8255 ControllerThe PCI-2746C and CTP-2746 have two 8255 PPI controllers. The PCI-2747A has one 8255 PPIcontroller. The functional block diagrams are shown below. PCI-2746C and CTP-2746 Block Diagram

    PCI-2747A Block Diagram

    Use FBIPPI_8255_CONTROLER1 or FBIPPI_8255_CONTROLER2 to select one of two 8255 controllerson the PCI-2746C and CTP-2746. Use FBIPPI_8255_CONTROLER1 for the PCI-2747A.

    Signals PA0 through PA7, PB0 through PB7, and PC0 through PC7 on the PCI-2747A are referred to as1PA0 through 1PA7, 1PB0 through 1PB7, and 1PC0 through 1PC7, respectively, in this documentation.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    12

    3.10 Describing a 8255 PPI Controller FunctionThe 8255 PPI controller is a general purpose digital programmable I/O device to interface peripheralequipment. It provides 24 I/O pins and is programmed to be input, output, status signal input, andcontrol signal output.

    Note: The PCI-2746C and CTP-2746 provide two controllers, and the PCI-2747A provides onecontroller. Put the number of “1” or “2” in front of PAx, PBx, and PCx when using thePCI-2746C and CTP-2746. “1” or “2” is used in order to distinguish between controller_1 andcontroller_2.

    The following table shows the correspondence between pins and models.

    Pin Model

    1PA0 through 1PA72PA0 through 2PA71PB0 through 1PB72PB0 through 2PB71PC0 through 1PC72PC0 through 2PC7

    PCI-2746C, CTP-2746

    PA0 through PA7PB0 through PB7PC0 through PC7

    PCI-2747A

    3.10.1 Port A, Port B, and Port CThe 8255 PPI controller has three I/O ports of 8 bits. They are called Port A, Port B, and Port C and eachhas its own special features.

    Input 8-bit data input latch or bufferPort A

    Output 8-bit data output latch or bufferInput 8-bit data input latch or buffer

    Port BOutput 8-bit data output latch or bufferInput 8-bit input buffer (no latch)Output 8-bit data output latch or buffer

    Port C This port can be divided into two ports of 4 bits depending on the operation mode.Each 4-bit port can be used for the control signal outputs and status signal inputsin conjunction with Port A and Port B.

    The following table shows the correspondence between pins and ports.

    Pin Port

    PA0 through PA7 Port APB0 through PB7 Port BPC0 through PC7 Port C

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    13

    3.10.2 Group A and Group B ControlsThe Port A, Port B, and Port C can be divided into two control groups. They are called Group A andGroup B.

    Control Group Port

    Group A Port A and Port C upperGroup B Port B and Port C lower

    3.10.3 Control WordThe control word contains information that initialize the functional configuration of 8255 PPI controller.Bit D7 selects a command type: mode set or bit set/reset. If D7 is 1, the control word contains a modedefinition command. If D7 is 0, the control word contains bit set/reset command.

    Control Word (byte data of 8-bit)D7 D6 D5 D4 D3 D2 D1 D0

    3.10.4 Mode SelectionThe 8255 PPI controller is used in three major modes of operation.

    Mode Description

    MODE 0 Basic input/outputMODE 1 Strobed input/outputMODE 2 Bi-directional bus

    You can select the operation mode for each group by using the PpiControl function. The following showthe possible combinations.

    • Group A: MODE 0, Group B: MODE 0• Group A: MODE 0, Group B: MODE 1• Group A: MODE 1, Group B: MODE 0• Group A: MODE 1, Group B: MODE 1• Group A: MODE 2, Group B: MODE 0• Group A: MODE 2, Group B: MODE 1

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    14

    The following table shows the mode definition format.

    0 OutputD0

    Port C lower1 Input0 Output

    D1Port B

    1 Input0 MODE 0

    D2

    Group B

    Mode selection1 MODE 10 Output

    D3Port C upper

    1 Input0 Output

    D4Group A

    Port A1 Input0 MODE 0

    D5, D6Mode selection

    1 MODE 10 Bit set/reset

    D7Command type

    1 Mode set

    3.10.5 Bit Set/Reset FeatureWhen using Port C for the control signal outputs and status signal inputs, the bits can be set or reset byusing the PpiControl function. And this operation disables or enables interrupt request signals.

    Bit set of control signal/control data to reset0 (D7) X X X D3 D2 D1 D0

    The following table shows the bit set/reset format.

    0 Reset

    D0 Bit set/reset

    1 Set

    Bit 0 1 2 3 4 5 6 7D1

    D1 0 1 0 1 0 1 0 1D2 D2 0 0 1 1 0 0 1 1D3

    Port CBit selection

    D3 0 0 0 0 1 1 1 1D7 Command type Specify 0 and select the bit set/reset.

    Note: When the board is reset or the mode is selected, all bits are reset automatically.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    15

    3.10.6 Operating Modes(1) MODE 0

    The MODE 0 provides the basic input/output operation. In this mode, each port provides buffered input(not latched) and latched output operations. After selecting the mode, the specified port outputs the low-level signal. And the output value is retrieved by reading the specified port. Each of Port A, Port B, Port Cupper, and Port C lower can be configured as an input port or output port individually by using thePpiControl function.

    MODE 0 Port Definition1 (D7) 0 (D6) 0 (D5) D4 D3 0 (D2) D1 D0

    0 OutputD0 Port C lower PC0 through PC3(PC0 through PC2)*1 1 Input

    0 OutputD1 Port B1 Input

    D2

    Group B

    Mode selection 0 MODE 00 OutputD3 Port C upper PC4 through PC71 Input0 OutputD4 Port A1 Input

    D5, D6

    Group A

    Mode selection 00 MODE 0D7 Command type 1 Mode set

    Note: *1 When the Group A is in MODE 1 or MODE 2, the available bits of Port C for Group B are PC0through PC2.

    (2) MODE 1In MODE 1, the control signals and status signals are used for the input/output control (handshake I/O).The Group A contains Port A (PA0 through PA7) for the data port and Port C upper (PC3 through PC7) forthe control/status port. The Group B contains Port B (PB0 through PB7) for the data port and Port C lower(PC0 through PC2) for the control/status port. The data are written to Port C by using the bit set/resetfunction.

    MODE 1 Port Definition1(D7) 0 (D6) 1(D5) D4 D3 1 (D2) D1 D0

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    16

    0 OutputD0 Port C PC3*2

    1 Input0 OutputD1 Port B1 Input

    D2

    Group B

    Mode selection 1 MODE 10 OutputD3 PC6 and PC7

    (When Port A is input.)PC4 and PC5(When Port A is output.)

    1 Input

    0 OutputD4 Port A1 Input

    D5, D6

    Group A

    Mode selection 01 MODE 1D7 Command type 1 Mode set

    Note: *2 PC3 is available only when the Group A is in MODE 0. Otherwise PC3 belongs to Group A.

    Function of Port C in MODE 1Signal Input Port Control Output Port ControlPC0 INTR (Interrupt request) INTR (Interrupt request)PC1 IBF (Input buffer full F/F) OBF (Output buffer full F/F)PC2 STB (Strobe input)

    INTE (Interrupt enable flag)ACK (Data acknowledge input)INTE (Interrupt enable flag)

    Group B

    PC3 Input/output*3 Input/output*3

    PC3 INTR (Interrupt request) INTR (Interrupt request)PC4 STB (Strobe input)

    INTE (Interrupt Enable flag)Input/output

    PC4 STB (Strobe input)INTE (Interrupt Enable flag)

    Input/output

    PC5 IBF (Input buffer full F/F) Input/outputPC6 Input/output ACK (Data acknowledge input)

    INTE (Interrupt enable flag)

    Group A

    PC7 Input/output OBF (Output Buffer Full F/F)

    Notes:• *3 While Group A operates in MODE 0, the PC3 signal is applicable to input/output.• In MODE1, Port A and Port B use the signals on Port C to control data transfers.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    17

    STB (Strobe input): When this signal goes low-level, the data port latches the data from peripheral.

    IBF (Input buffer full F/F): When this signal is high-level, it means the input buffer is full of data. It notifies peripherals that the

    input port is in not-ready state. This signal goes high-level when the STB signal changes to low-level.After CPU reads out data from the input buffer, this signal goes low-level. The initial value is low-level.

    INTR (Interrupt request): This signal can be used for an interrupt signal to request service from the CPU when it is high-level.

    INTE (Interrupt enable flag): The interrupts are disabled (bit: 1) or enabled (bit: 0) by using the bit set/reset function. The STB signal

    operates correctly even if the INTE flag is overwritten.

    The statuses of the IBF, INTR, and INTE signals can be retrieved by reading Port C at input port inMODE 1.

    MODE 1 (Group A) Input

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    18

    MODE 1 (Group B) Input

    MODE 1 Input Timing

    Note: * The STB signal should keep high-level until the IBF signal goes low-level. The latch data inside theport is overwritten if the STB signal changes to low-level before the IBF signal goes low-level.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    19

    OBF (Output buffer full F/F): This signal goes low-level when the data from the CPU are latched into the output port. It requests

    peripheral to receive the data. This signal goes low-level after the CPU writes data to the output port.This signal goes high-level after peripheral receives the data. The initial value is high-level.

    ACK (Data acknowledge input): A peripheral uses this signal to notify the completion of receiving the data from the output port. The

    peripheral asserts this signal to low-level when receiving the data.

    INTR (Interrupt request): This signal goes high-level after peripheral receives the data. And it can be used for an interrupt signal to

    request new data from the CPU.

    INTE (Interrupt enable flag): The interrupts are disabled (bit: 1) or enabled (bit: 0) by using the bit set/reset function. The ACK signal

    operates correctly even if the INTE flag is overwritten.

    The statuses of the OBF, INTR, and INTE signals can be retrieved by reading Port C at output port inMODE 1.

    MODE 1 (Group A) Output

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    20

    MODE 1 (Group B) Output

    MODE 1 Output Timing

    Note: * Do not write the data while the OBF signal is low-level. Failure to observe this caution might resultin the change of the port output.

    (3) MODE 2This mode uses only Group A. Port A is used for the bi-directional 8-bit data port by the control of thecontrol/status signals (5 bits of Port C upper). This operates in a similar manner to MODE 1.

    Port C Function in Group A at MODE 2

    Signal Function

    PC3 INTR (Interrupt request)

    PC4STB (Strobe input)INTE2 (Interrupt enable flag)

    PC5 IBF (Input buffer full F/F)

    PC6ACK (Data acknowledge input)INTE1 (Interrupt enable flag)

    PC7 OBF (Output buffer full F/F)

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    21

    The bi-directional data transfer is controlled by the ACK and STB signals. In this mode, WIE and RIE arecontrolled by the bit set/reset function. Refer to MODE 1 about the operations and functions of each signal.The statuses of the OBF, IBF, INTR, INTE1, and INTE2 signals can be retrieved by reading Port C.

    The input operation is similar to MODE 1. The differences of the output operation between MODE 2 andMODE 1 are following:

    • When the ACK signal is low-level, Port A outputs the data.• The data from the output port cannot be read back.

    MODE 2 Input/Output Timing

    (4) Special Mode CombinationNot all of bits in Port C are used for the control/status signals. And the remaining bits can be used asfollows:

    • If programmed as inputs, all input lines can be accessed during reading Port C.• If programmed as outputs, the port C upper bits (PC4 through PC7) and port C lower bits (PC0

    through PC3) are individually written by using the set/reset function. Port C lower bits (PC0 throughPC2) are written in 3-bit.

    In MODE 1, the I/O direction of PC6 and PC7 or PC4 and PC5 is configured by bit 3 of the control word.The I/O direction of PC3 is configured by bit 0. The data 1 means the input port, and the data 0 means theoutput port. The data lines that are set as input are placed on the system bus by reading Port C. To writedata to bits that are set as output, operate the bit set twice.

  • GPH-6106 Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    22

    Chapter 4 Reference4.1 List of Functions

    No. Function Description

    1 PpiOpen Opens a digital I/O board with the 8255 PPI controller andenables to access to the board.

    2 PpiClose Closes the digital I/O board with the 8255 PPI controller andreleases the resources.

    3 PpiControl Writes a control word.4 PpiInputPort Reads the data from the port.5 PpiOutputPort Writes the data to the port.6 PpiSetEventMask Masks interrupt events.7 PpiGetEventMask Retrieves interrupt mask settings.8 PpiSetEventConfig Assigns interrupt sources and configures interrupt signals.9 PpiGetEventConfig Retrieves the assignment of interrupt sources and interrupt signal

    configurations.10 PpiSetTimerConfig Configures the interval timer.11 PpiGetTimerConfig Retrieves the configuration data of the interval timer.12 PpiGetTimerCount Retrieves the counter value of the interval timer.13 PpiGetResetInStatus Retrieves the status of the external reset input signal.14 PpiRegistIsr Configures the callback routine that is called when an interrupt

    occurs.15 PpiCommonGetPciDeviceInfo Retrieves the board information such as the device ID, resource

    assignment, RSW1 value, and so on.16 CallBackProc Is a placeholder for a callback routine. The function is called

    when interrupts occur.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    23

    4.1.1 PpiOpenThe PpiOpen function opens a digital I/O board with the 8255 PPI controller and enables to access to theboard.

    int PpiOpen(

    int nDevice,

    unsigned long ulFlag

    );

    ParameternDevice Specifies the device number to open.

    ulFlag Specifies an open flag.

    Flag Description

    FBIPPI_FLAG_SHARE Specifies that any other applicationcan share the device.

    0Specifies that the device is openedexclusively.

    Return ValueThe PpiOpen function returns FBIPPI_ERROR_SUCCESS if the process is successfully completed.Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_NOT_DEVICE- FBIPPI_ERROR_NOT_OPEN- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_ALREADY_OPEN

    Exampleint nRet;

    int nDevice = 1;

    nRet = PpiOpen(nDevice, 0);

    Open an digital I/O board with the 8255 PPI controller specified by nDevice.

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    24

    4.1.2 PpiCloseThe PpiClose function closes the digital I/O board with the 8255 PPI controller and releases the resources.

    int PpiClose(

    int nDevice

    );

    ParameternDevice Specifies the device number to close.

    Return ValueThe PpiClose function returns FBIPPI_ERROR_SUCCESS if the process is successfully completed.Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER

    Exampleint nDevice = 1;

    int nRet;

    nRet = PpiClose(nDevice);

    Close the digital I/O board with the 8255 PPI controller specified by nDevice.

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    25

    4.1.3 PpiControlThe PpiControl function writes a control word.

    Int PpiControl(

    int nDevice,

    unsigned long ulController,

    unsigned char bControlData

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    ulController Specifies the 8255 controller to be programmed.

    Code Controller

    FBIPPI_8255_CONTROLLER1 8255 controller_1FBIPPI_8255_CONTROLLER2 8255 controller_2

    Note: For the PCI-2747A, specify FBIPPI_8255_CONTROLLER1 only.

    bControlData Specifies a control word. Refer to “3.10 Describing a 8255 PPI Controller Function,”on the mode and port definitions.

    Return ValueThe PpiControl function returns FBIPPI_ERROR_SUCCESS if the process is successfully completed.Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

    Exampleint nDevice = 1;

    int nRet;

    nRet = PpiControl(nDevice, FBIPPI_8255_CONTROLLER1, 0x99 );

    Program the 8255 controller_1 on the board specified by nDevice.- Configure both Group A and Group B to operate in MODE 0.- Configure Port A and Port C as input and Port B as output.

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    26

    4.1.4 PpiInputPortThe PpiInputPort function reads the data from the port.

    int PpiInputPort (

    int nDevice,

    unsigned long ulController,

    unsigned long ulPort,

    unsigned char *pbValue

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    ulController Specifies the 8255 controller to be programmed.

    Code Controller

    FBIPPI_8255_CONTROLLER1 8255 controller_1FBIPPI_8255_CONTROLLER2 8255 controller_2

    Note: For the PCI-2747A, specify FBIPPI_8255_CONTROLLER1 only.

    ulPort Specifies the port to be read.

    Code Port

    FBIPPI_PORT_A Port A

    FBIPPI_PORT_B Port BFBIPPI_PORT_C Port C

    pbValue Points to a variable to receive the read data.Data Format

    bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0D7 D6 D5 D4 D3 D2 D1 D0

    If the bit is 1, the corresponding signal is high-level.If the bit is 0, the corresponding signal is low-level.

    Return ValueThe PpiInputPort function returns FBIPPI_ERROR_SUCCESS if the process is successfully completed.Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    27

    Exampleint nDevice = 1;

    unsigned char bValue;

    nRet = PpiInputPort(nDevice, FBIPPI_8255_CONTROLLER1, FBIPPI_PORT_A,

    &bValue );

    Read the data from Port A of the 8255 controller_1 on the board specified by nDevice.

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    28

    4.1.5 PpiOutputPortThe PpiOutputPort function writes the data to the port.

    int PpiOutputPort(

    int nDevice,

    unsigned long ulController,

    unsigned long ulPort,

    unsigned char bValue

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    ulController Specifies the 8255 controller to be programmed.

    Code Controller

    FBIPPI_8255_CONTROLLER1 8255 controller_1FBIPPI_8255_CONTROLLER2 8255 controller_2

    Note: For the PCI-2747A, specify FBIPPI_8255_CONTROLLER1 only.

    ulPort Specifies the port to be written.

    Code Port

    FBIPPI_PORT_A Port A

    FBIPPI_PORT_B Port BFBIPPI_PORT_C Port C

    bValue Specifies the data to write.Data Format

    bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0D7 D6 D5 D4 D3 D2 D1 D0

    If the bit is 1, the corresponding signal is high-level.If the bit is 0, the corresponding signal is low-level.

    Return ValueThe PpiOutputPort function returns FBIPPI_ERROR_SUCCESS if the process is successfully completed.Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    29

    Exampleint nDevice = 1;

    int nRet;

    nRet = PpiOutputPort(nDevice, FBIPPI_8255_CONTROLLER1, FBIPPI_PORT_A, 1 );

    Write the data to Port A of the 8255 controller_1 on the board specified by nDevice.

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    30

    4.1.6 PpiSetEventMaskThe PpiSetEventMask function masks interrupt events.

    int PpiSetEventMask(

    int nDevice,

    unsigned char bEventMask

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    bEventMask Specifies a mask data of interrupt sources.

    bit7, bit6 bit5 bit4 bit3 bit2 bit1 bit0Reserved SIGR SIGT SIG4 SIG3 SIG2 SIG1

    SIGR: External interrupt maskSIGT: Timer interrupt maskSIG1 through SIG4: Mask bits for interrupt sources specified by the

    PpiSetEventConfig function. 0: Mask 1: Unmask

    bit7, bit6 bit5 bit4 bit3, bit2 bit1 bit0Reserved SIGR SIGT Reserved SIG2 SIG1

    SIGR: External interrupt maskSIGT: Timer interrupt maskSIG1 and SIG2: Mask bits for interrupt sources specified by the PpiSetEventConfig

    function. 0: Mask 1: UnmaskAll interrupt sources are masked at the default settings. When the PCI bus is reset oran external reset is asserted, interrupt sources except SIGR are masked. In this case,the mask setting of SIGR is not changed.

    Return ValueThe PpiSetEventMask function returns FBIPPI_ERROR_SUCCESS if the process is successfullycompleted. Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    31

    Exampleint nDevice = 1;

    int nRet;

    nRet = PpiSetEventMask(nDevice, 0x36);

    For the PCI-2746C and CTP-2746, mask interrupt sources, SIG1 and SIG4, on the board specified bynDevice.For the PCI-2747A, mask interrupt source SIG1 on the board specified by nDevice.

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    32

    4.1.7 PpiGetEventMaskThe PpiGetEventMask function retrieves interrupt mask settings.

    int PpiGetEventMask(

    int nDevice,

    unsigned char *pbEventMask

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    pbEventMask Points to a variable to receive an interrupt mask.

    bit7, bit6 bit5 bit4 bit3 bit2 bit1 bit0Reserved SIGR SIGT SIG4 SIG3 SIG2 SIG1

    SIGR: External interrupt maskSIGT: Timer interrupt maskSIG1 through SIG4: Mask bits for interrupt sources specified by the

    PpiSetEventConfig function. 0: Mask 1: Unmask

    bit7, bit6 bit5 bit4 bit3, bit2 bit1 bit0Reserved SIGR SIGT Reserved SIG2 SIG1

    SIGR: External interrupt maskSIGT: Timer interrupt maskSIG1 and SIG2: Mask bits for interrupt sources specified by the PpiSetEventConfig

    function. 0: Mask 1: UnmaskAll interrupt sources are masked at the default settings. When the PCI bus is reset oran external reset is asserted, interrupt sources except SIGR are masked. In this case,the mask setting of SIGR is not changed.

    Return ValueThe PpiGetEventMask function returns FBIPPI_ERROR_SUCCESS if the process is successfullycompleted. Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    33

    Exampleint nDevice = 1;

    int nRet;

    unsigned char bEventMask;

    nRet = PpiGetEventMask(nDevice, &bEventMask);

    Retrieve the status of interrupt masks on the board specified by nDevice.

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    34

    4.1.8 PpiSetEventConfigThe PpiSetEventConfig function assigns interrupt sources and configures interrupt signals.

    int PpiSetEventConfig(

    int nDevice,

    unsigned char bEventConfig

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    bEventConfig Specifies the data to assign interrupt sources and configure interrupt signals.

    bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0EDS4 EDS3 EDS2 EDS1 SIG4 SIG3 SIG2 SIG1

    EDS1 through EDS4:Active interrupt edges of SIG1 through SIG4

    0: High-to-low (falling edge)1: Low-to-high (rising edge)

    SIG1 through SIG4: Interrupt sourcesInterrupt signal for SIG1

    0: 1PC3 (8255 controller_1, Port C, pin 1PC3)1: Reserved

    Interrupt signal for SIG20: 1PC0 (8255 controller_1, Port C, pin 1PC0)1: IR.IN1

    Interrupt signal for SIG30: 2PC3 (8255 controller_2, Port C, pin 2PC3)1: Reserved

    Interrupt signal for SIG40: 2PC0 (8255 controller_2, Port C, pin 2PC0)1: IR.IN2

    When the PCI bus is reset, the external reset signal is asserted, or the power is turnedon, the setting is set to 0. When in MODE 0, the interrupt request signals from 1PC3,1PC0, 2PC3, and 2PC0 cannot be generated.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    35

    bit7, bit6 bit5 bit4 bit3, bit2 bit1 bit0Reserved EDS2 EDS1 Reserved SIG2 SIG1

    EDS1 and EDS2:Active interrupt edges of SIG1 and SIG2

    0: High-to-low (falling edge)1: Low-to-high (rising edge)

    SIG1 and SIG2: Interrupt sourcesInterrupt signal for SIG1

    0: PC3 (8255 controller_1, Port C, pin PC3)1: Reserved

    Interrupt signal for SIG20: PC0 (8255 controller_1, Port C, pin PC0)1: Reserved

    When the PCI bus is reset, the external reset signal is asserted, or the power is turnedon, the setting is set to 0. When in MODE 0, the interrupt request signals from PC3and PC0 cannot be generated.

    Return ValueThe PpiSetEventConfig function returns FBIPPI_ERROR_SUCCESS if the process is successfullycompleted. Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

    Exampleint nDevice = 1;

    int nRet;

    nRet = PpiSetEventConfig(nDevice, 0xAA);

    For the PCI-2746C, select and configure the interrupt sources and active interrupt edges as follows.

    Interrupt Source Signal Active Interrupt Edge

    1PC3 Falling edgeIR.IN1 Rising edge2PC3 Falling edgeIR.IN2 Rising edge

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    36

    4.1.9 PpiGetEventConfigThe PpiGetEventConfig function retrieves the assignment of interrupt sources and interrupt signalconfigurations.

    int PpiGetEventConfig(

    int nDevice,

    unsigned char *pbEventConfig

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    pbEventConfig Points to a variable to receive the interrupt sources and interruptsignal configurations.

    bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0EDS4 EDS3 EDS2 EDS1 SIG4 SIG3 SIG2 SIG1

    EDS1 through EDS4:Active interrupt edges of SIG1 through SIG4

    0: High-to-low (falling edge)1: Low-to-high (rising edge)

    SIG1 through SIG4: Interrupt sourcesInterrupt signal for SIG1

    0: 1PC3 (8255 controller_1, Port C, pin 1PC3)1: Reserved

    Interrupt signal for SIG20: 1PC0 (8255 controller_1, Port C, pin 1PC0)1: IR.IN1

    Interrupt signal for SIG30: 2PC3 (8255 controller_2, Port C, pin 2PC3)1: Reserved

    Interrupt signal for SIG40: 2PC0 (8255 controller_2, Port C, pin 2PC0)1: IR.IN2

    When the PCI bus is reset, the external reset signal is asserted, or the power isturned on, the setting is set to 0. When in MODE 0, the interrupt request signalsfrom 1PC3, 1PC0, 2PC3, and 2PC0 cannot be generated.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    37

    bit7, bit6 bit5 bit4 bit3, bit2 bit1 bit0Reserved EDS2 EDS1 Reserved SIG2 SIG1

    EDS1 and EDS2:Active interrupt edges of SIG1 and SIG2

    0: High-to-low (falling edge)1: Low-to-high (rising edge)

    SIG1 and SIG2: Interrupt sourcesInterrupt signal for SIG1

    0: PC3 (8255 controller_1, Port C, pin PC3)1: Reserved

    Interrupt signal for SIG20: PC0 (8255 controller_1, Port C, pin PC0)1: Reserved

    When the PCI bus is reset, the external reset signal is asserted, or the power is turnedon, the setting is set to 0. When in MODE 0, the interrupt request signals from PC3and PC0 cannot be generated.

    Return ValueThe PpiGetEventConfig function returns FBIPPI_ERROR_SUCCESS if the process is successfullycompleted. Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

    Exampleint nDevice = 1;

    int nRet;

    unsigned char bEventConfig;

    nRet = PpiGetEventConfig(nDevice, &bEventConfig);

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    38

    4.1.10 PpiSetTimerConfigThe PpiSetTimerConfig function configures the interval timer.

    int PpiSetTimerConfig(

    int nDevice,

    unsigned char bTimerConfigValue

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    bTimerConfigValue Specifies the timer configuration data. The interval timer event frequency isobtained by dividing the base clock frequency by the clock divisor. The clockdivisor is specified by CTL1, CTL2, CTL3, and CTL4. The base clockfrequency is specified by CTL5, CTL6, and CTL7.

    bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0Reserved CTL7 CTL6 CTL5 CTL4 CTL3 CTL2 CTL1

    Clock Divisor (CTL1 through CTL4)

    Clock Divisor CTL4 CTL3 CTL2 CTL1

    Timer is not enabled. 0 0 0 01 0 0 0 12 0 0 1 03 0 0 1 14 0 1 0 05 0 1 0 16 0 1 1 07 0 1 1 18 1 0 0 09 1 0 0 110 1 0 1 011 1 0 1 112 1 1 0 013 1 1 0 114 1 1 1 015 1 1 1 1

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    39

    Base Clock Frequency (CTL5 through CTL7)Base Clock Frequency CTL7 CTL6 CTL5

    100 kHz 0 0 010 kHz 0 0 11 kHz 0 1 0100 Hz 0 1 110 Hz 1 0 0

    Return ValueThe PpiSetTimerConfig function returns FBIPPI_ERROR_SUCCESS if the process is successfullycompleted. Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

    Exampleint nDevice = 1;

    int nRet;

    unsigned char bTimerConfigValue = 0x38;

    nRet = PpiSetTimerConfig(nDevice, bTimerConfigValue);

    Configure the timer base clock and clock divisor to 100 Hz and 8, respectively on the board specified bynDevice.

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    40

    4.1.11 PpiGetTimerConfigThe PpiGetTimerConfig function retrieves the configuration data of the interval timer.

    int PpiGetTimerConfig(

    int nDevice,

    unsigned char *pbTimerConfigValue

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    pbTimerConfigValue Points to a variable to receive the interval timer settings. The interval timerevent frequency is obtained by dividing the base clock frequency by the clockdivisor. The clock divisor is specified by CTL1, CTL2, CTL3, and CTL4. Thebase clock frequency is specified by CTL5, CTL6, and CTL7.

    bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0Reserved CTL7 CTL6 CTL5 CTL4 CTL3 CTL2 CTL1

    Clock Divisor (CTL1 through CTL4)Clock Divisor CTL4 CTL3 CTL2 CTL1

    Timer is not enabled. 0 0 0 01 0 0 0 12 0 0 1 03 0 0 1 14 0 1 0 05 0 1 0 16 0 1 1 07 0 1 1 18 1 0 0 09 1 0 0 110 1 0 1 011 1 0 1 112 1 1 0 013 1 1 0 114 1 1 1 015 1 1 1 1

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    41

    Base Clock Frequency (CTL5 through CTL7)Base Clock Frequency CTL7 CTL6 CTL5

    100 kHz 0 0 010 kHz 0 0 11 kHz 0 1 0100 Hz 0 1 110 Hz 1 0 0

    Return ValueThe PpiGetTimerConfig function returns FBIPPI_ERROR_SUCCESS if the process is successfullycompleted. Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

    Exampleint nDevice = 1;

    int nRet;

    unsigned char bTimerConfigValue;

    nRet = PpiGetTimerConfig(nDevice, &bTimerConfigValue);

    Retrieve the interval timer configuration on the board specified by nDevice

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    42

    4.1.12 PpiGetTimerCountThe PpiGetTimerCount function retrieves the counter value of the interval timer.

    int PpiGetTimerCount(

    int nDevice,

    unsigned char *pbTimerCount

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    pbTimerCount Points to a variable to receive the count of the interval timer. The counter value iscontained these 4-bit.

    bit7 through bit4 bit3 bit2 bit1 bit0Reserved CTL4 CTL3 CTL2 CTL1

    Count CTL4 CTL3 CTL2 CTL1

    0 0 0 0 01 0 0 0 12 0 0 1 03 0 0 1 14 0 1 0 05 0 1 0 16 0 1 1 07 0 1 1 18 1 0 0 09 1 0 0 110 1 0 1 011 1 0 1 112 1 1 0 013 1 1 0 114 1 1 1 015 1 1 1 1

    Return ValueThe PpiGetTimerCount function returns FBIPPI_ERROR_SUCCESS if the process is successfullycompleted. Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    43

    Examplesint nDevice = 1;

    int nRet;

    unsigned char bTimerCount;

    nRet = PpiGetTimerCount(nDevice, &bTimerCount);

    Retrieve the counter value of the timer on the board specified by nDevice.

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    44

    4.1.13 PpiGetResetInStatusThe PpiGetResetInStatus function retrieves the status of the external reset signal.

    int PpiGetResetInStatus(

    int nDevice,

    unsigned char *pbResetInStatus

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    pbResetInStatus Points to a variable to receive the status of the external reset signal. 0: External reset signal is deasserted. 1: External reset signal is asserted.

    Return ValueThe PpiGetResetInStatus function returns FBIPPI_ERROR_SUCCESS if the process is successfullycompleted. Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

    CommentWhile the external reset signal is asserted, you cannot configure interrupt masks or sources. If the board isreset by the external reset signal, make sure that the signal has been deasserted by using thePpiGetResetInStatus function. Then please setup the board again.

    Examplesint nDevice = 1;

    unsig unsigned char bResetInStatus;ned char bResetInStatus;

    nRet = PpiGetResetInStatus(nDevice, &bResetInStatus);

    Retrieve the status of the external reset signal on the board specified by nDevice.

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    45

    4.1.14 PpiRegistIsrThe PpiRegistIsr function configures the callback routine that is called when an interrupt occurs. To callthe callback routine, interrupt source settings and unmasking the interrupt source are required by using thePpiSetEventConfig and PpiSetEventMask functions after calling this function.

    int PpiRegistIsr(

    Int nDevice,

    unsigned long ulUserData,

    PPPICALLBACK pCallBackProc

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    ulUserData Specifies a user-defined data passed to the callback routine.

    pCallBackProc Specifies an address of user callback routine. If you do not use a callbackroutine, specify NULL. Refer to “4.1.16 CallBackProc,” for more details.

    Return ValueThe PpiRegistIsr function returns FBIPPI_ERROR_SUCCESS if the process is successfully completed.Otherwise, this function returns the following codes. Please refer to the error codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

    Exampleint nDevice = 1;

    int nRet;

    void CallBackProc(unsigned long ulUserData, unsigned char bEvent,

    unsigned short nDeviceNum)

    {

    .

    .

    .

    }

    nRet = PpiRegistIsr(nDevice, 0x00007000, CallBackProc );

    Configure the callback routine, CallBackProc, and pass 7000h as the user-defined data on the boardspecified by nDevice.

    ReferenceRefer to “3.8 Programming Guide.”

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    46

    4.1.15 PpiCommonGetPciDeviceInfoThe PpiCommonGetPciDeviceInfo function retrieves the board information such as the device ID, resourceassignment, RSW1 value, and so on. This function allows you to determine the board to be controlled.

    int PpiCommonGetPciDeviceInfo(

    int nDevice

    unsigned short *pwDeviceID,

    unsigned short *pwVendorID,

    unsigned long *pulClassCode,

    unsigned char *pbRevisionID,

    unsigned long *pulBaseAddress0,

    unsigned long *pulBaseAddress1,

    unsigned long *pulBaseAddress2,

    unsigned long *pulBaseAddress3,

    unsigned long *pulBaseAddress4,

    unsigned long *pulBaseAddress5,

    unsigned short *pnSubsystemID,

    unsigned short *pnSubsystemVendorId,

    unsigned char *pbInterrputLine,

    unsigned long *pulBoardID

    );

    ParametersnDevice Specifies the device number specified by the PpiOpen function.

    pwDeviceID Points to a variable to receive the device ID.Example:2746 (ABAh in hexadecimal) is for the PCI-2746C and CTP-2746.

    pwVendorID Points to a variable to receive the vendor ID. The vendor ID ofInterface Corporation is 1147h in hexadecimal.

    pulClassCode Points to a variable to receive the class code of the device.

    pbRevisionID Points to a variable to receive the revision ID of the device.

    pulBaseAddress0 Points to a variable to receive the base address 0 of the board. TheI/O ports address of the board will be retrieved. Mask the value withFFFCh to retrieve the actual I/O port address.

    pulBaseAddress1 Points to a variable to receive the base address 1 of the board. Notused for Interface digital input/output boards with the 8255 PPIcontrollers.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    47

    (Continued)pulBaseAddress2 Points to a variable to receive the base address 2 of the board. Not

    used for Interface digital input/output boards with the 8255 PPIcontrollers.

    pulBaseAddress3 Points to a variable to receive the base address 3 of the board. Notused for Interface digital input/output boards with the 8255 PPIcontrollers.

    pulBaseAddress4 Points to a variable to receive the base address 4 of the board. Notused for Interface digital input/output boards with the 8255 PPIcontrollers.

    pulBaseAddress5 Points to a variable to receive the base address 5 of the board. Notused for Interface digital input/output boards with the 8255 PPIcontrollers.

    pnSubsystemID Points to a variable to receive the subsystem ID of the board. Thismember identifies a type of the product.

    Type Value

    PCI board 0001hCompactPCI board 0101h

    pnSubsystemVendorId Points to a variable to receive the subsystem vendor ID of the board.

    pbInterrputLine Points to a variable to receive the interrupt line of the board.

    pulBoardID Points to a variable to receive the board ID of the board. The boardID means RSW1 value of the board.

    Return ValueThe PpiCommonGetPciDeviceInfo function returns FBIPPI_ERROR_SUCCESS if the process issuccessfully completed. Otherwise, this function returns the following codes. Please refer to theerror codes.

    - FBIPPI_ERROR_SUCCESS- FBIPPI_ERROR_INVALID_DEVICE_NUMBER- FBIPPI_ERROR_PARAMETER

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    48

    Exampleint nDevice = 1;

    int nRet;

    unsigned short wDeviceID, wVendorID;

    unsigned long ulClassCode;

    unsigned char bRevisionID;

    unsigned long ulBaseAddress0, ulBaseAddress1, ulBaseAddress2;

    unsigned long ulBaseAddress3, ulBaseAddress4, ulBaseAddress5;

    unsigned short nSubsystemID, nSubsystemVendorID;

    unsigned char bInterruptLine;

    unsigned long ulBoardID;

    // Retrieve the board information.

    nRet = PpiCommonGetPciDeviceInfo(

    nDevice, // Device number

    &wDeviceID, // Device ID

    &wVendorID, // Vendor ID

    &ulClassCode, // Class code

    &bRevisionID, // Revision ID

    &ulBaseAddress0, // Base Address Register 0

    &ulBaseAddress1, // Base Address Register 1

    &ulBaseAddress2, // Base Address Register 2

    &ulBaseAddress3, // Base Address Register 3

    &ulBaseAddress4, // Base Address Register 4

    &ulBaseAddress5, // Base Address Register 5

    &nSubsystemID, // Subsystem ID

    &nSubsystemVendorID, // Subsystem Vendor ID

    &bInterruptLine, // Interrupt Line

    &ulBoardID // Board ID

    );

    Retrieve the configuration registers and the board ID (RSW1) on the board specified by nDevice.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    49

    4.1.16 CallBackProcThe CallBackProc function is a placeholder for a callback routine. Use the PpiRegistIsr function to set thecallback routine function.

    int CallBackProc(

    int ulUserData,

    unsigned char bEvent,

    unsigned short nDeviceNum

    );

    ParametersulUserData Information that a user specified to send the callback function.

    bEvent Indicates interrupt sources.

    bit7, bit6 bit5 bit4 bit3 bit2 bit1 bit0Reserved SIGR SIGT SIG4 SIG3 SIG2 SIG1

    SIG1 through SIG4: Interrupt sources specified by the DioSetIrqConfig functionSIGT: Timer interruptSIGR: External interrupt

    nDeviceNum Indicates device number of the board that the interrupt occurs.

    Return ValueThis function has no return value.

    ExampleRefer to “4.1.14 PpiRegistIsr,” for more details.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    50

    4.2 Return Values

    Error Code Value DescriptionComments/Solutions

    FBIPPI_ERROR_SUCCESS 0 The process wassuccessfullycompleted.

    -

    FBIPPI_ERROR_NOT_DEVICE C0000001h The specified drivercannot be called.

    The specified device isnot found. Make surethat the specifieddevice numbercorrectly installed inyour computer.

    FBIPPI_ERROR_NOT_OPEN C0000002h The specified drivercannot be opened.

    Errors occurred whilethe system opens thedevice.

    FBIPPI_ERROR_INVALID_DEVICE_NUMBER C0000003h The device number isinvalid.

    Use the device numberspecified by thePpiOpen function.

    FBIPPI_ERROR_DEVICE_ALREADY_OPEN C0000004h The specified devicecannot be openedbecause it has alreadybeen opened byanother process.

    The device used byanother process cannotbe accessed.

    FBIPPI_ERROR_INVALID_PARAMETER C0001021h The specifiedparameter is invalid.

    Specify correct value.The specifiedargument value is outof the range.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    51

    4.3 KylixIn this document, all examples of programs are written in C. This section contains helpful information forKylix programmers.

    4.3.1 Function Definitions

    C Kylixint PpiInputPort( 1)function PpiInputPort(int nDevice, 2)nDevice: Integer3);

    unsigned long ulController, ulController: Cardinal;

    unsigned long ulPort, ulPort: Cardinal;

    unsigned char* pbValue 4)var pbValue: Cardinal

    ); ): 5) Integer; 6) cdecl; external‘gpg2746.so’;

    1) In Kylix, a function-module that has a return value uses the function reserved word.A function-module that has no return value uses the procedure reserved word.

    2) In Kylix, a variable is written in front of the data type of that.3) In Kylix, data type are written in the different way of C. Example)

    C Kylix

    int Integer

    long Longint

    unsigned long Cardin alunsigned char Byte

    void* pointer

    4) When you write a variable passed by reference, write var in front of the variable.5) In Kylix, data type is written at the end of the variable argument list.6) To call the library function, write cdecl;external ‘library name’;. To call the callback

    routine, you do not need to write external ‘library name’;.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    52

    4.3.2 ExampleThe following programs show how to open the board and use the callback routine.

    CLPPPICALLBACK CallBackProc(unsigned long ulUserData, unsigned char

    bEvent, unsigned short nDeviceNum);

    void main()

    {

    int nRet;

    nRet = PpiOpen(nDevice, 0);

    nRet = PpiRegistIsr(nDevice, 0, CallBackProc);

    nRet = PpiSetEventConfig(nDevice, 0xAA);

    nRet = PpiSetEventMask(nDevice, 0x36);

    }

    void CallBackProc(unsigned long ulUserData, unsigned char bEvent,

    unsigned short nDeviceNum)

    {

    // Write processing of the callback routine.

    }

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    53

    Kylix1)var

    procedure CallBackProc(ulUserData:Cardinal, bEvent:Byte,

    nDeviceNum:Word ); LPPPICALLBACK ;cdecl;

    procedure TForm1.FormCreate(Sender: TObject);

    var

    nRet:Integer;

    2)begin

    nRet 3):= PpiOpen(nDevice, 0);

    nRet := PpiRegistIsr(nDevice, 0, 4)@CallBackProc);

    nRet := PpiSetEventConfig(nDevice, 5)$AA);

    nRet := PpiSetEventMask(nDevice, $36);

    end;

    procedure CallBackProc(ulUserData:Cardinal, bEvent: Byte,

    nDeviceNum:Word ); LPPPICALLBACK ;cdecl

    begin

    // Write processing of the callback routine.

    end;

    1) Declare a variable or function after the var reserved word.2) Write codes between begin and end;.3) In Kylix, the assignment operator is :=.4) In Kylix, the address operator is @.5) In Kylix, a leading $ means hexadecimal.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    54

    4.4 Test DriverThe GPH-2746C has the test driver capable of checking the functions of the GPH-2746C without using theboard. To use the test driver, link libgpg2746t.so instead of libgpg2746.so.

    The following shows the example to compile the test.c program that uses the test driver.

    #gcc -o test test.c –lgpg2746t

    Each function checks whether parameters are correctly specified or not. Refer to description of eachfunction. As error codes, refer to ”4.2 Return Values,” for details.

    Function Description

    PpiOpen The process is always successfully completed.PpiClose Returns an error if the PpiOpen function has not been called.PpiControl The process is always successfully completed.PpiInputPort 55h is always received.PpiOutputPort The process is always successfully completed.PpiSetEventMask The process is always successfully completed.PpiGetEventMask Retrieves the value specified by the PpiSetEventMask function.PpiSetEventConfig The process is always successfully completed.PpiGetEventConfig Retrieves the value specified by the PpiSetEventConfig function.PpiSetTimerConfig The process is always successfully completed.PpiGetTimerConfig Retrieves the value specified by the PpiSetTimerConfig function.PpiGetTimerCount 0 is always received.PpiGetResetInStatus 0 is always received.PpiRegistIsr The process is always successfully completed. The callback routine is not

    supported in the test driver.PpiCommonGetPciDeviceInfo 0 is always received.

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    55

    Chapter 5 Sample ProgramsExecutable files of the sample programs are not included with this product. Please make your executablefiles before you use the sample programs.

    The sample programs are located in the following directory.- C/usr/src/interface/gph2746C//linux/samples/c

    - Kylix/usr/src/interface/gph2746C//linux/samples/kylix

    Note: Software for the SH-4 CPU board does not have sample programs for kylix.

    Item Sub Folder Name Description

    Input sample program ppiin Sample program for input data with the allpins. (MODE 0)

    Output sample program ppiout Sample program for output data with the allpins. (MODE 0)

    Interrupt sample program event Sample program for interrupt event

    5.1 How to Compile the Sample Programs (C)Compile the sample programs in each sample program’s directory as follows.#cd /usr/src/interface/gph2746c//linux/samples/c

    #make

    5.2 How to Compile the Sample Programs (Kylix)Compile the sample programs in the kylix directory as follows.#cd /usr/src/interface/gpg2746c//linux/samples/kylix

    #make

  • GPH-2746C Help for Linux

    Copyright 2004 Interface Corporation. All rights reserved.

    56

    Chapter 6 Important Information

    6.1 Limited WarrantyInterface does not warrant uninterrupted or error-free operations of the software product. The entire risks asto the quality of or arising out of use or performance of the software products, if any, remains with you.

    Interface believes that information contained in the document is accurate. The document is carefullyreviewed for technical accuracy. Interface reserves the right to make changes to subsequent editions of thisdocument without prior notice to holders of this edition. Interface is not liable for any damages arising outof or related to this document or the information contained in it.

    Charts and tables contained in this document are only for illustration purposes and may vary dependingupon a user's specific application.

    All official specifications in metric. English unit supplied for convenience.

    6.2 Copyrights and Intellectual Property RightsInterface owns all titles and intellectual property rights in and to the products. The products includescomputer software, may include audio/visual content such as images, text, or pictures.

    No part of this publication may not be reproduced or altered in any form or by any means without writtenprior permission of Interface Corporation.

    6.3 Warning Regarding Medical and Clinical Use of Interface ProductsInterface products are not designed with components intended to ensure a level of reliability suitable foruse under conditions that might cause serious injury or depth.

    Interface products are not designed with components and testing intended to ensure a level of reliabilitysuitable for use in treatment and diagnosis of human.

    Applications of Interface products involving medical or clinical treatment can create a potential foraccidental injury caused by product failure, or by errors on the part of the user or application engineer.

    6.4 Limitation of LiabilityInterface will not be liable for any special, incidental, indirect, or consequential damages whatsoever(including, but not limited to, damages for lost of profits or confidential or other information, for businessinterruption, for personal injury, for loss of privacy), even if interface, or any reseller has been advised ofthe possibility of such damages.

    Customer's right to recover damages caused by fault or negligence on the part of Interface Corporationshall be limited to the amount paid by the customer for that product.

    6.5 TrademarkProducts and company names are trademarks, registered trademarks, or servicemarks of their respectiveowners.

    Chapter 1 Introduction1.1 Summary1.2 Features

    Chapter 2 Product Specifications2.1 Operating Environments2.2 Target Products2.3 Functional Specifications

    Chapter 3 Installation and Board Configuration3.1 Installing the Linux Driver Software3.2 Loading the Driver Modules3.3 Configuring the Device Numbers3.4 Programming3.5 Compiling the Program3.6 Running the Program3.7 Unloading the Driver Modules3.8 Programming Guide3.8.1 Initializing a Board3.8.2 Input/Output3.8.3 Timer3.8.4 Interrupt3.8.5 Closing the Board

    3.9 Selecting a 8255 Controller3.10 Describing a 8255 PPI Controller Function3.10.1 Port A, Port B, and Port C3.10.2 Group A and Group B Controls3.10.3 Control Word3.10.4 Mode Selection3.10.5 Bit Set/Reset Feature3.10.6 Operating Modes

    Chapter 4 Reference4.1 List of Functions4.1.1 PpiOpen4.1.2 PpiClose4.1.3 PpiControl4.1.4 PpiInputPort4.1.5 PpiOutputPort4.1.6 PpiSetEventMask4.1.7 PpiGetEventMask4.1.8 PpiSetEventConfig4.1.9 PpiGetEventConfig4.1.10 PpiSetTimerConfig4.1.11 PpiGetTimerConfig4.1.12 PpiGetTimerCount4.1.13 PpiGetResetInStatus4.1.14 PpiRegistIsr4.1.15 PpiCommonGetPciDeviceInfo4.1.16 CallBackProc

    4.2 Return Values4.3 Kylix4.3.1 Function Definitions4.3.2 Example

    4.4 Test Driver

    Chapter 5 Sample Programs5.1 How to Compile the Sample Programs (C)5.2 How to Compile the Sample Programs (Kylix)

    Chapter 6 Important Information6.1 Limited Warranty6.2 Copyrights and Intellectual Property Rights6.3 Warning Regarding Medical and Clinical Use of Interface Pro...6.4 Limitation of Liability6.5 Trademark