⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 manual_performing_digital_io_operations.html

📁 Diamond公司Dscud通用驱动使用说明手册
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"        "http://www.w3.org/TR/html4/loose.dtd"><html lang="en"><head><title>Performing Digital IO Operations - Universal Driver Documentation</title><meta http-equiv="Content-type" content="text/html; charset=iso-8859-1"><meta name="robots" content="index,follow"><link rel="shortcut icon" href="/favicon.ico"><link rel="stylesheet" href="/dscud/style/wikiprintable.css"><script type="text/javascript" src="/dscud/style/wikibits.js"></script><style type='text/css'><!--a.new, #quickbar a.new { color: #CC2200; }#quickbar { position: absolute; top: 4px; left: 4px; border-right: 1px solid gray; }#article { margin-left: 152px; margin-right: 4px; }//--></style></head><body bgcolor='#FFFFFF'><div class='titlebox'><h1 class='pagetitle'>Performing Digital IO Operations</h1><span class='subtitle'>Universal Driver Documentation</span></div><div class='navbox'><a href="manual_Main_Page.html" class='printable' title ="Main Page">Main Page</a> || <a href="manual_Table_of_Contents.html" class='printable' title ="Table of Contents">Table_of_Contents</a> || <a href="http://www.diamondsystems.com/">Diamond Systems Website</a></div></div><div class='bodytext'><h3><a name="Description"> Description </a></h3>
<p>
The driver supports four types of direct digital I/O operations: input bit, input byte, output bit, and output byte. Digital I/O is fairly straightforward - to perform digital input, you provide a pointer to the storage variable and indicate the port number and bit number if relevant. To perform digital output, you provide the output value and the output port and bit number, if relevant.
<p>
The four Universal Driver functions described here are <tt><a href="manual_DscDIOInputByte.html" class='printable' title ="DscDIOInputByte">dscDIOInputByte</a>()</tt>, <tt><a href="manual_DscDIOInputBit.html" class='printable' title ="DscDIOInputBit">dscDIOInputBit</a>()</tt>, <tt><a href="manual_DscDIOOutputByte.html" class='printable' title ="DscDIOOutputByte">dscDIOOutputByte</a>()</tt>, <tt><a href="manual_DscDIOOutputBit.html" class='printable' title ="DscDIOOutputBit">dscDIOOutputBit</a>()</tt>, <tt><a href="manual_DscDIOSetBit.html" class='printable' title ="DscDIOSetBit">dscDIOSetBit</a>()</tt>, and <tt><a href="manual_DscDIOClearBit.html" class='printable' title ="DscDIOClearBit">dscDIOClearBit</a>()</tt>.<p><h3><a name="Step-By-Step_Instructions"> Step-By-Step Instructions </a></h3>
<p>
If you are performing digital input, create and initialize a pointer to hold the returned value of type <tt><a href="manual_BYTE.html" class='printable' title ="BYTE">BYTE</a>*</tt>.
<p>
Some boards have digital I/O ports with fixed directions, while others have ports with programmable directions. Make sure the port is set to the required direction, input or output. Use function <tt><a href="manual_DscDIOSetConfig.html" class='printable' title ="DscDIOSetConfig">dscDIOSetConfig</a>()</tt> to set the direction if necessary.
<p>
Call the selected digital I/O function. Pass it a <a href="manual_BYTE.html" class='printable' title ="BYTE">BYTE</a> port value, and either a pointer to or a constant <a href="manual_BYTE.html" class='printable' title ="BYTE">BYTE</a> digital value. If you are performing bit operations, then you will also need to pass in a <a href="manual_BYTE.html" class='printable' title ="BYTE">BYTE</a> value telling the driver which particular bit (0-7) of the DIO port you wish to operate on.<p><h3><a name="Example_of_Usage_for_Digital_I/O_Operations"> Example of Usage for Digital I/O Operations </a></h3>
<p>
<pre>...
DSCB dscb;
BYTE port, bit;
BYTE digital_value;	// the value ranges from 0 to 255 

/* 1. input bit - read bit 3 of port 0 (port 0 is in input mode) */
port = 0;
bit = 3;
if ((result = dscDIOInputBit(dscb, port, bit, &digital_value)) != DE_NONE)
    return result;

/* 2. input byte - read all 8 bits of port 0 (port 0 is in input mode) */
port = 0;
if ((result = dscDIOInputByte(dscb, port, &digital_value)) != DE_NONE)
    return result;

/* 3. output bit - 3 examples (assumes port 2 is in output mode) */
port = 2;
bit = 7;

/* 3a. dscDIOOutputBit(), set bit 7 of port 2 to 1, leave other bits alone */
if ((result = dscDIOOutputBit(dscb, port, bit, 1)) != DE_NONE)
    return result;

/* 3b. dscDIOSetBit(), set bit 7 of port 2 to 1, leave other bits alone */
if ((result = dscDIOSetBit(dscb, port, bit)) != DE_NONE)
    return result;

/* 3c. dscDIOClearBit(), set bit 7 of port 2 to 0, leave other bits alone */
if ((result = dscDIOClearBit(dscb, port, bit)) != DE_NONE)
    return result;

/* 4. output byte - set port 2 to &quot;01010101&quot; (port 2 is in output mode) */
port = 2;
if ((result = dscDIOOutputByte(dscb, port, 0x55)) != DE_NONE)
    return result;
...</pre>
<p></div><p><em> <br> This page was last modified 14:54, 12 Feb 2004.<br>Copyright (c) 2004 Diamond Systems.  All Rights Reserved.</em><!-- Time since request: 0.16 secs. --></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -