AMC 68VZ328 software manual Functions, Digital Inputs and Outputs

Page 93

I/O Functions

The low level functions used to manipulate the I/O channels are the system calls open, lseek, read, write, close, and ioctl. The I/O channels are accessed through 3 character drivers for the digital I/O, ADC, and DAC. The uses of these functions are demonstrated in the sample programs fir.c, xor_iodimm.c, and even_parity_iodimm.c.

Digital Inputs and Outputs

For the digital input and output pins, each channel corresponds to one byte, where channel 0 is the 0th byte, channel 1 is the 1st byte, etc. The device can be accessed by a handle to the node /dev/io0 for both read and write. When writing to the pin, 0 will be low (0V) and non-0 will be high (as shipped, 12V, or if strapped, VIO). When reading a pin, the driver will read back 0 for a low signal, and 255 for a high signal. lseek should be used to position the file pointer for access to I/O channels. There are 8 digital inputs and 4 digital outputs, so channels [0-3] can be written to and read from, but channels [4-7] can only be read.

Specific to the digital outputs, there are ioctl calls to pass control information to the device driver. Each ioctl call takes three parameters, the handle, a descriptor of the desired command, and an integer, though in some cases the integer is ignored.

result=ioctl(handle, PIC_SETUP0, PIC_SETUP_PUSH_PULL)

Each of the command descriptors are listed below. If any of them are unsuccessful executing the function, an error will return. Please note that the PWM channels are currently not supported. Both PWM0 and PWM1 cannot be used at the same time since PWM0 is connected to the low-side driver and PWM1 is connected to the high-side driver.

DAC_POWER_DOWN should be used to power down the DAC once it is no longer needed. Note that the argument is ignored for this ioctl call.

PIC_SETUP0, PIC_SETUP1, PIC_SETUP2, PIC_SETUP3 will configure each digital out channel according to the integer specified in the argument. Each of the argument values are described below.

PIC_SETUP_LO_SIDE will configure an output pin as a low-side driver. PIC_SETUP_HI_SIDE will configure an output pin as a high-side driver. PIC_SETUP_PUSH_PULL will configure an output pin as a push-pull output. PIC_SETUP_HI_Z will configure an output pin into a high impedance state.

Analog I/O

For both the ADC and the DAC, each channel corresponds to 2 bytes, such that channel 0 is the 0th and 1st bytes, channel 1 is the 2nd and 3rd bytes, etc. The data in the bytes is binary encoded, in little endian format where the least significant bit is at the lower offset in the file. Values that can be written or read from the channels are unipolar from 0 to 4095, corresponding to 0 to 4.095V, thus there is 1mV per count. lseek should be used to move around the file to access I/O channels. For both reads and writes, as few as 1 or as many as all analog I/O channels can be accessed at once.

www.amctechcorp.com

93

Image 93
Contents DimmPCITM 68VZ328 Hardware / Software Manual Copyright notice Contact InformationDimmPCITM Software Development Kit NETdimm Developers Kit Quick Start Guide Etc/issue Page This page left intentionally blank Launching Linux at the embedded IntroductionPage System Requirements What’s on the CD?This page left intentionally blank UC68VZ328 Embedded Microcontroller FeaturesCPU Module BackplaneCPU Module Description General DescriptionBackplane Description CPU Architecture ArchitectureMCU Core System MemoryMemory Map Memory Map MemoryLayout of the Flash and Flash Schematic Layout of the Flash Sdram Viewing the Ethernet MAC ID Ethernet ControllerNETdimm Ethernet Schematic IOdimm Digital I/ODigital Output Schematic Analog Output Schematic Analog Input Schematic Digital to Analog Converter Schematic RS-232 WatchdogHighlights Usage LCD Interface LCD SchematicDimmPCITM signals for System Slot DimmPCITM Signal DescriptionsPCI Maximum Ratings Electrical CharacteristicsThis page left intentionally blank Installation Installing the dimmPCI TM SystemBuilder Kit Before beginningConfiguring and compiling the µClinux kernel Customizing the filesystem Creating a ROM imageAccessing your dimmPCI development board via the serial port Accessing the Network Static IPDynamic IP Compiling your own source code Accessing your dimmPCI development board via telnetUsing NFS to streamline the development cycle Home directory/dimmpci/source Method Updating Applications on your dimmPCI moduleThis page left intentionally blank Loader Programming the uC68VZ328Oops Cd /opt/boottools/oops Oops -p /dev/ttyS0 -k kernel.bin Page Page This page left intentionally blank Sample Code AppendixClose the file afterwards fclose filehandle Page Longwatchdogid #include unistd.h #include stdio.h int main void This page left intentionally blank Journalling Flash File System Umount /usr Sbin/mkjffs /dev/flash0 Page This page left intentionally blank Development Tool Chains Normal Usage of the PIC-COFFTool Chain Page This page left intentionally blank Introduction D1 Application NoteKernel and Filesystem Configuration YES Kernel and Filesystem Configuration Flow ChartAvailable Digital I/O Pins List of all available digital I/O pins Dimmio structure description Programming StructureDigital I/O Functions Page In0 In1 In2 In3 In4 In5 In6 In7 Out0 Even Parity Sample ProgramsMknod io1 c 123 Page This page left intentionally blank Abstract D2 Application NoteRequirements Kernel ConfigurationAgain, from the main menu under Network device support Kernel Configuration Flow Chart AtCommandPrompt Filesystem Configuration Cd /opt/filesystem name make clean Make Modifications to ‘rc’ file Filesystem Configuration Flow ChartTesting Host machine ConfigurationPage This page left intentionally blank Application Note Using Multiple NETdimm ModulesInetd based Server & Client Simple Server & ClientPage This page left intentionally blank IOdimm Using Analog and Digital I/O withCd /opt Cp -Rpdx newfs iodimmmfs ADC MAX1203 Category Channel Backplane System Backplane Header Slot Pin Available I/O PinsDigital Inputs and Outputs Functions+ Κ Iodimm/dio Samples/cardspecific/iodimm/dio Page This page left intentionally blank Purpose & basic format of files for oops Using OopsUpload & Flash Download Upload & RunCommon oops program arguments Appendix This page left intentionally blank 104 Licensing, Copyrights & Liability DimmPCITM Software Development Kit DistributionPreamble 106 107 108 109 Appendix How to Apply These Terms to Your New Programs No Warranty111 112 113 This page left intentionally blank 114 References/ Suggested Reading