Changes in / [13bdbee:1662ede] in multiio


Ignore:
Location:
pcmmio
Files:
20 added
13 edited

Legend:

Unmodified
Added
Removed
  • pcmmio/original/Makefile

    r13bdbee r1662ede  
    1 # $Header$
    21#
    3 # $Id$
    4 #
    5 # $Log$
     2#  $Id$
    63#
    74
    8 MAJOR = 115
     5RTEMS_MAKEFILE_PATH=${HOME}/centaur/install/i386-rtems4.10/pc386/
     6#
     7#  RTEMS_MAKEFILE_PATH is typically set in an environment variable
     8#
    99
    10 CFLAGS += -DMAJOR_NUM=$(MAJOR)
     10#MAINS= buffered.c dacbuff.c dacout.c flash.c getall.c getvolt.c \
     11#  poll.c repeat.c simple_rtems.c pcmmio_shell.c
    1112
    12 # Test Makefile
     13MAINS= pcmmio_shell.c
    1314
    14 ifneq ($(KERNELRELEASE),)
    15         obj-m := pcmmio.o
    16 else
    17         KERNELDIR ?= /lib/modules/$(shell uname -r)/build
    18         PWD := $(shell pwd)
     15PGMS=$(MAINS:%.c=${ARCH}/%.exe)
    1916
    20 default:
    21         $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
    22 endif
     17# optional managers required
     18MANAGERS=all
     19#DEFINES += -DTESTING
    2320
    24 mio_io.o: mio_io.c mio_io.h Makefile
    25         gcc -c $(CFLAGS) mio_io.c
     21# C source names
     22#SHARED_CSRCS += mio_io_linux.c
     23SHARED_CSRCS = mio_io.c kbhit.c
     24SHARED_CSRCS += main_pcmmio_adc_mode.c
     25SHARED_CSRCS += main_pcmmio_din.c main_pcmmio_dout.c
     26SHARED_CSRCS += main_pcmmio_adc.c main_pcmmio_dac.c
     27SHARED_CSRCS += main_pcmmio_irq.c
     28SHARED_CSRCS += main_pcmmio_benchmark.c
     29SHARED_CSRCS += mio_io_rtems.c
     30SHARED_CSRCS += FilesystemImage.c
    2631
    27 nodes:
    28         mknod pcmmio c $(MAJOR) 0
    29         chmod a+rw pcmmio
     32SHARED_COBJS = $(SHARED_CSRCS:%.c=${ARCH}/%.o)
     33SHARED_CONFIG = ${ARCH}/rtems_config.o
    3034
    31 all:    default nodes poll flash getvolt dacout getall repeat buffered dacbuff
     35CLEAN_ADDITIONS += FilesystemImage FilesystemImage.c FilesystemImage.h
    3236
    33 dacbuff: dacbuff.c mio_io.o mio_io.h Makefile kbhit.c
    34         gcc $(CFLAGS) -static dacbuff.c kbhit.c mio_io.o -o dacbuff
    35         chmod a+x dacbuff
    36        
    37 buffered: buffered.c mio_io.o mio_io.h Makefile kbhit.c
    38         gcc $(CFLAGS) -static buffered.c kbhit.c mio_io.o -o buffered
    39         chmod a+x buffered
    40        
    41 repeat: repeat.c mio_io.o mio_io.h Makefile kbhit.c
    42         gcc $(CFLAGS) -D_REENTRANT -static repeat.c kbhit.c mio_io.o -o repeat -lpthread
    43         chmod a+x repeat
     37include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
     38include $(RTEMS_CUSTOM)
     39include $(PROJECT_ROOT)/make/leaf.cfg
    4440
    45 flash: flash.c mio_io.h kbhit.c mio_io.o Makefile
    46         gcc $(CFLAGS) -static flash.c kbhit.c mio_io.o -o flash
    47         chmod a+x flash
     41LDFLAGS += -g
     42OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) $(SHARED_COBJS) $(SHARED_CONFIG)
    4843
    49 getvolt: getvolt.c mio_io.h mio_io.o Makefile
    50         gcc $(CFLAGS) -static getvolt.c mio_io.o -o getvolt
    51         chmod a+x getvolt
     44all:    ${ARCH} FilesystemImage.c FilesystemImage.h $(OBJS) $(PGMS)
    5245
    53 getall: getall.c mio_io.h mio_io.o Makefile
    54         gcc $(CFLAGS) -static getall.c mio_io.o -o getall
    55         chmod a+x getall
     46${ARCH}/pcmmio_shell.exe: pcmmio_shell.c $(OBJS)
     47        $(CC) $(LDFLAGS) -o $@ $< $(SHARED_COBJS)
    5648
    57 dacout: dacout.c mio_io.h mio_io.o Makefile
    58         gcc $(CFLAGS) -static dacout.c mio_io.o -o dacout
    59         chmod a+x dacout
     49${ARCH}/%.exe: %.c $(OBJS)
     50        $(CC) $(LDFLAGS) -o $@ $< $(SHARED_COBJS) $(SHARED_CONFIG)
    6051
    61 poll:  poll.c mio_io.o mio_io.h Makefile
    62         gcc $(CFLAGS) -D_REENTRANT -static poll.c mio_io.o -o poll -lpthread
    63         chmod a+x poll
    64  
    65 clean:
    66         rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions pcmmio
     52FilesystemImage: rootfs/test_adc rootfs/set_adc_modes
     53        (cd rootfs ; tar cf - --exclude=.svn \
     54          --exclude=CVS --exclude=.cvsignore .) >$(@)
    6755
     56FilesystemImage.c FilesystemImage.h: FilesystemImage
     57        $(PROJECT_ROOT)/bin/rtems-bin2c FilesystemImage FilesystemImage
    6858
     59FilesystemImage.o: FilesystemImage.c
     60        $(CC) $(CFLAGS) $(CPU_CFLAGS) -c $<
     61
  • pcmmio/original/buffered.c

    r13bdbee r1662ede  
    33/*
    44*
    5 * $Header$
    6 *
    75* $Id$
    86*
    9 * $Log$
     7* Compile for GNU/Linux with:
    108*
    11 *       Compile with :
    12 *
    13 *               gcc buffered.c kbhit.c mio_io.o -o buffered -lpthread
     9*   gcc buffered.c kbhit.c mio_io.o -o buffered -lpthread
    1410*
    1511*
    16 *       This program demonstrates the adc_buffered_channel_conversions function
    17 *       which allows for a programmed sequence of conversions to be accomplished
    18 *       with a single call.
    19 *
     12*  This program demonstrates the adc_buffered_channel_conversions function
     13*  which allows for a programmed sequence of conversions to be accomplished
     14*  with a single call.
    2015*/
    21 
    2216
    2317/* Our IOCTL definitions and all function prototypes */
  • pcmmio/original/dacbuff.c

    r13bdbee r1662ede  
    33/*
    44*
    5 * $Header$
    6 *
    75* $Id$
    86*
    9 * $Log$
    107*
    11 *       Compile with :
     8* Compile for GNU/Linux with:
    129*
    13 *               gcc dacbuff.c kbhit.c mio_io.o -o dacbuff
     10*     gcc dacbuff.c kbhit.c mio_io.o -o dacbuff
    1411*
    1512*
    16 *       This program demonstrates the adc_buffered_channel_conversions function
    17 *       which allows for a programmed sequence of conversions to be accomplished
    18 *       with a single call.
    19 *
     13* This program demonstrates the adc_buffered_channel_conversions function
     14* which allows for a programmed sequence of conversions to be accomplished
     15* with a single call.
    2016*/
    21 
    2217
    2318#include "mio_io.h"   
  • pcmmio/original/dacout.c

    r13bdbee r1662ede  
    11/* dacout.c WinSystems PCM-MIO driver Demonstration Program
    2 *
    3 *  $Header$
    42*
    53*  $Id$
    64*
    7 *  $Log$
     5* Compile for GNU/Linux with:
     6*
     7*   gcc dacout.c mio_io.o -o dacout
    88*
    99*
    10 *  Compile with :
    11 *
    12 *
    13 *       gcc dacout.c mio_io.o -o dacout
    14 *
    15 *
    16 *       This extremely simple program uses the set_dac_voltage function to update
    17 *   the dac output to a specific voltage.
     10* This extremely simple program uses the set_dac_voltage function to update
     11*  the dac output to a specific voltage.
    1812*/
    1913
  • pcmmio/original/flash.c

    r13bdbee r1662ede  
    11/* Flash.c WinSystems PCM-MIO driver Demonstration Program
    2 *
    3 *  $Header$
    42*
    53*  $Id$
    64*
    7 $Log$
     5Compile for GNU/Linux with:
    86*
     7*    gcc flash.c kbhit.c mio_io.o -o flash
    98*
    10 *  Compile with :
    11 *
    12 *
    13 *       gcc flash.c kbhit.c mio_io.o -o flash
    14 *
    15 *   This very simple program, toggles each of the 48  DIO lines in succession, holding it low
    16 *   for 250ms and then releasing it.
     9*  This very simple program, toggles each of the 48  DIO lines in succession,
     10*  holding it low for 250ms and then releasing it.
    1711*
    1812*/
     
    2822
    2923#include <stdio.h>
     24#include <stdlib.h>
    3025#include <unistd.h>
    3126#include "mio_io.h"
  • pcmmio/original/getall.c

    r13bdbee r1662ede  
    1 /* getall.c Demonstration program for use with the WinSystems PCM-MIO Linux driver
    2 *
    3 *       $Header$
    4 *
    5 *       $Id$
    6 *
    7 *       $Log$
    8 *
    9 *       Compile with :
    10 *
    11 *                       gcc -static getall.c mio_io.o -o getall
    12 */
     1/*
     2 * Demonstration program for use with the WinSystems PCM-MIO driver
     3 *
     4 *      $Id$
     5 *
     6 * Compile for GNU/Linux with:
     7 *
     8 *    gcc -static getall.c mio_io.o -o getall
     9 */
    1310
    1411#include <stdio.h>
     
    1613#include "mio_io.h"
    1714
    18 /* This program demonstrates usage of the adc_convert_all_channels function call.
    19    This allows for all 16 channels to be quickly converted and the results passed
    20    back in an 16 element array. Note that this function does not return voltage values,
    21    it returns raw 16-bit data directly from the converter.
    22 */
     15/* This program demonstrates usage of the adc_convert_all_channels
     16 * function call.  This allows for all 16 channels to be quickly converted
     17 * and the results passed back in an 16 element array. Note that this
     18 * function does not return voltage values, it returns raw 16-bit data
     19 * directly from the converter.
     20 */
    2321
    2422
  • pcmmio/original/getvolt.c

    r13bdbee r1662ede  
    11/* getvolt.c WinSystems PCM-MIO driver Demonstration Program
    2 *
    3 *  $Header$
    4 *
    5 *  $Id$
    6 *
    7 *  $Log$
    8 *
    9 *
    10 *  Compile with :
    11 *
    12 *
    13 *       gcc getvolt.c mio_io.o -o getvolt
    14 *
    15 *
    16 *       This program demonstrates the adc_auto_get_channel_voltage
    17 *       function. It reads the voltage on the channel specified
    18 *       prints the value and then exits.
    19 *
    20 */
     2 *
     3 *  $Id$
     4 *
     5 * Compile for GNU/Linux with:
     6 *
     7 *
     8 *   gcc getvolt.c mio_io.o -o getvolt
     9 *
     10 *
     11 * This program demonstrates the adc_auto_get_channel_voltage
     12 * function. It reads the voltage on the channel specified
     13 * prints the value and then exits.
     14 */
    2115
    2216#include <stdio.h>
  • pcmmio/original/kbhit.c

    r13bdbee r1662ede  
    1 /* $Header$
    2 *
    3 *
    4 *   Filename : $RCSfile$
    5 *
    6 *   $Id$
    7 *
    8 *   $Log$
    9 *   Revision 1.1  2005/04/19 20:39:11  steve
    10 *   Initial revision
    11 *
    12 *
    13 *
    14 */
     1/*
     2 * $Id$
     3 */
    154
    165
    176/* These functions are from the Wrox Press Book "Beginning Linux
    18    Programming - Second Edition" by Richard Stones and Neil Matthew.
    19    (C) 1996 & 1999 and are included here in compliance with the GNU
    20    Public license.
    21 
    22 */
     7 * Programming - Second Edition" by Richard Stones and Neil Matthew.
     8 * (C) 1996 & 1999 and are included here in compliance with the GNU
     9 * Public license.
     10 */
    2311
    2412#include <stdio.h>
    2513#include <termios.h>
    26 #include <term.h>
    27 #include <curses.h>
     14#if defined(__linux__)
     15  #include <term.h>
     16  #include <curses.h>
     17#endif
    2818#include <unistd.h>
    2919
  • pcmmio/original/mio_io.c

    r13bdbee r1662ede  
    1 /* mio_io.c WinSystems support module file for the  PCM-MIO Linux driver */
    2 /*
    3 *  $Header$
    4 *
    5 *  $Id$
    6 *
    7 *  $Log$
    8 *
    9 *  This file implements all of the supported 'C' language functions. Where necessary
    10 *  ioctl call are made into the kernel driver to access the actual hardware.
    11 */
     1/* mio_io.c
     2 * WinSystems support module file for the PCM-MIO Linux and RTEMS drivers
     3 *
     4 *  $Id$
     5 *
     6 *  This file implements all of the supported 'C' language functions.
     7 *  Where necessary calls are made into a porting layer to access the
     8 *  actual hardware.
     9 */
    1210
    1311#define LIB_DEFINED
     
    1816
    1917#include <stdio.h>
    20 #include <fcntl.h>      /* open */
    21 #include <unistd.h>     /* exit */
    22 #include <sys/ioctl.h>  /* ioctl */
    2318
    2419/* These image variable help out where a register is not
     
    7772
    7873
    79 /**************************************************************************
    80 *
    81 *               USER LIBRARY FUNCTIONS
    82 *
    83 ***************************************************************************
    84 */
    85 
    86 int handle = 0;
    87 char *device_id ="pcmmio";
    88 char *dev_id    = "/dev/pcmmio";
    89 
    9074///////////////////////////////////////////////////////////////////////////////
    9175//
     
    9882        mio_error_code = MIO_SUCCESS;
    9983
    100     if(check_handle())   /* Check for chip available */
     84        if(check_handle())   /* Check for chip available */
    10185                return -1;
    10286
     
    344328///////////////////////////////////////////////////////////////////////////////
    345329//
    346 //              MIO_READ_IRQ_ASSIGNED
    347 //
    348 //////////////////////////////////////////////////////////////////////////////
    349 
    350 int mio_read_irq_assigned(void)
    351 {
    352 unsigned char val;
    353 
    354         mio_error_code = MIO_SUCCESS;
    355 
    356         if(check_handle())   /* Check for chip available */
    357                 return -1;
    358 
    359 
    360         /* All of our programming of the hardware is handled at this level so that
    361            all of the routines that need to shove and IRQ value into hardware will
    362            use this call.
    363    */
    364 
    365     val = ioctl(handle,READ_IRQ_ASSIGNED,NULL);
    366 
    367         return val & 0xff;
    368 }
    369 
    370 
    371 ///////////////////////////////////////////////////////////////////////////////
    372 //
    373330//              SET_DAC_SPAN
    374331//
     
    476433int set_dac_voltage(int channel, float voltage)
    477434{
    478 unsigned short  value;
     435unsigned short  value = 0;
    479436float bit_val;
    480437
     
    544501        return 0;
    545502}
    546 
    547 ///////////////////////////////////////////////////////////////////////////////
    548 //
    549 //              READ_DIO_BYTE
    550 //
    551 //////////////////////////////////////////////////////////////////////////////
    552 
    553 unsigned char read_dio_byte(int offset)
    554 {
    555 int val;
    556 
    557         mio_error_code = MIO_SUCCESS;
    558 
    559         if(check_handle())   /* Check for chip available */
    560                 return -1;
    561 
    562         /* All bit operations are handled at this level so we need only
    563         read and write bytes from the actual hardware using the driver
    564         to handle our ioctl call for it.
    565         */
    566 
    567     val = ioctl(handle,READ_DIO_BYTE,offset);
    568 
    569         return (unsigned char) (val & 0xff);;
    570 }
    571 
    572 ///////////////////////////////////////////////////////////////////////////////
    573 //
    574 //              MIO_READ_REG
    575 //
    576 //////////////////////////////////////////////////////////////////////////////
    577 
    578 unsigned char mio_read_reg(int offset)
    579 {
    580 int val;
    581 
    582         mio_error_code = MIO_SUCCESS;
    583 
    584         if(check_handle())   /* Check for chip available */
    585                 return -1;
    586 
    587 
    588         /* This is a catchall register read routine that allows reading of
    589            ANY of the registers on the PCM-MIO. It is used primarily for
    590            retreiving control and access values in the hardware.
    591    */
    592 
    593      val = ioctl(handle,MIO_READ_REG,offset);
    594 
    595         return (unsigned char) (val & 0xff);
    596 }
    597 
    598 ///////////////////////////////////////////////////////////////////////////////
    599 //
    600 //              MIO_WRITE_REG
    601 //
    602 //////////////////////////////////////////////////////////////////////////////
    603 
    604 int mio_write_reg(int offset, unsigned char value)
    605 {
    606 unsigned short param;
    607 int val;
    608 
    609         mio_error_code = MIO_SUCCESS;
    610 
    611         if(check_handle())   /* Check for chip available */
    612                 return -1;
    613 
    614         param = offset & 0xff;
    615 
    616         param = param | (value << 8);
    617    
    618         /* This function like the previous allow unlimited
    619            write access to ALL of the registers on the PCM-MIO
    620    */
    621 
    622         val = ioctl(handle,MIO_WRITE_REG,param);
    623        
    624         return 0;
    625 }
    626 
    627 
    628 ///////////////////////////////////////////////////////////////////////////////
    629 //
    630 //              WRITE_DIO_BYTE
    631 //
    632 //////////////////////////////////////////////////////////////////////////////
    633 
    634 int write_dio_byte(int offset, unsigned char value)
    635 {
    636 unsigned short param;
    637 int val;
    638 
    639         mio_error_code = MIO_SUCCESS;
    640 
    641         if(check_handle())   /* Check for chip available */
    642                 return -1;
    643 
    644         param = offset & 0xff;
    645 
    646         param = param | (value << 8);
    647    
    648         /* All bit operations for the DIO are handled at this level
    649            and we need the driver to allow access to the actual
    650            DIO registers to update the value.
    651     */
    652 
    653         val = ioctl(handle,WRITE_DIO_BYTE,param);
    654        
    655         return 0;
    656 }
    657 
    658 
    659 ///////////////////////////////////////////////////////////////////////////////
    660 //
    661 //              WRITE_DAC_COMMAND
    662 //
    663 //////////////////////////////////////////////////////////////////////////////
    664 
    665 int write_dac_command(int dac_num,unsigned char value)
    666 {
    667 unsigned short param;
    668 int val;
    669 
    670         mio_error_code = MIO_SUCCESS;
    671 
    672         if(check_handle())   /* Check for chip available */
    673                 return -1;
    674 
    675         param = dac_num & 0xff;
    676 
    677         param = param | (value << 8);
    678 
    679         val = ioctl(handle,WRITE_DAC_COMMAND,param);
    680 
    681         return 0;
    682 }
    683 
    684503
    685504///////////////////////////////////////////////////////////////////////////////
     
    1124943///////////////////////////////////////////////////////////////////////////////
    1125944//
    1126 //              WRITE_ADC_COMMAND
    1127 //
    1128 //////////////////////////////////////////////////////////////////////////////
    1129 
    1130 int write_adc_command(int adc_num,unsigned char value)
    1131 {
    1132 unsigned short param;
    1133 int ret_val;
    1134 
    1135         mio_error_code = MIO_SUCCESS;
    1136 
    1137         if(check_handle())   /* Check for chip available */
    1138                 return -1;
    1139 
    1140         param = adc_num & 0xff;
    1141 
    1142         param = param | (value << 8);
    1143 
    1144     ret_val = ioctl(handle,WRITE_ADC_COMMAND,param);
    1145 
    1146         return 0;
    1147 }
    1148 
    1149 ///////////////////////////////////////////////////////////////////////////////
    1150 //
    1151945//              BUFFERED_DAC_OUTPUT
    1152946//
     
    1172966                x++;
    1173967        }
    1174 }
    1175 
    1176 ///////////////////////////////////////////////////////////////////////////////
    1177 //
    1178 //              WRITE_DAC_DATA
    1179 //
    1180 //////////////////////////////////////////////////////////////////////////////
    1181 
    1182 int write_dac_data(int dac_num, unsigned short value)
    1183 {
    1184 int ret_val;
    1185 unsigned char buffer[3];
    1186 
    1187         mio_error_code = MIO_SUCCESS;
    1188 
    1189         if(check_handle())   /* Check for chip available */
    1190                 return -1;
    1191 
    1192         buffer[0] = dac_num;
    1193         buffer[1] = value & 0xff;
    1194         buffer[2] = value >> 8;
    1195 
    1196     ret_val = ioctl(handle,WRITE_DAC_DATA,buffer);
    1197        
    1198         return 0;
    1199 }
    1200 
    1201 ///////////////////////////////////////////////////////////////////////////////
    1202 //
    1203 //              DAC_READ_STATUS
    1204 //
    1205 //////////////////////////////////////////////////////////////////////////////
    1206 
    1207 unsigned char dac_read_status(int dac_num)
    1208 {
    1209 int ret_val;
    1210 
    1211         mio_error_code = MIO_SUCCESS;
    1212 
    1213         if(check_handle())   /* Check for chip available */
    1214                 return -1;
    1215 
    1216     ret_val = ioctl(handle,READ_DAC_STATUS,dac_num);
    1217 
    1218         return ret_val & 0xff;
    1219 }
    1220 
    1221 ///////////////////////////////////////////////////////////////////////////////
    1222 //
    1223 //              ADC_READ_STATUS
    1224 //
    1225 //////////////////////////////////////////////////////////////////////////////
    1226 
    1227 unsigned char adc_read_status(int adc_num)
    1228 {
    1229 int ret_val;
    1230 
    1231         mio_error_code = MIO_SUCCESS;
    1232 
    1233         if(check_handle())   /* Check for chip available */
    1234                 return -1;
    1235 
    1236     ret_val = ioctl(handle,READ_ADC_STATUS,adc_num);
    1237 
    1238         return (ret_val & 0xff);
    1239968}
    1240969
     
    13291058}
    13301059
    1331 ///////////////////////////////////////////////////////////////////////////////
    1332 //
    1333 //              ADC_READ_CONVERSION_DATA
    1334 //
    1335 //////////////////////////////////////////////////////////////////////////////
    1336 
    1337 unsigned short adc_read_conversion_data(int channel)
    1338 {
    1339 int ret_val;
    1340 int adc_num;
    1341 
    1342         mio_error_code = MIO_SUCCESS;
    1343 
    1344         if(check_handle())   /* Check for chip available */
    1345                 return -1;
    1346 
    1347         if(channel > 7)
    1348                 adc_num = 1;
    1349         else
    1350                 adc_num = 0;
    1351 
    1352     ret_val = ioctl(handle,READ_ADC_DATA,adc_num);
    1353        
    1354         return (ret_val & 0xffff);
    1355 }
    1356 
    1357 
    13581060////////////////////////////////////////////////////////////////////////////////
    13591061//
     
    17941496}
    17951497
    1796 
    1797 int dio_get_int(void)
    1798 {
    1799 int c;
    1800 
    1801     c=ioctl(handle,DIO_GET_INT,NULL);
    1802 
    1803     return (c & 0xff);
    1804 
    1805 }
    1806 
    1807 
    1808 int wait_adc_int(int adc_num)
    1809 {
    1810 int c;
    1811 
    1812 
    1813     if(check_handle())   /* Check for chip available */
    1814                 return -1;
    1815 
    1816         if(adc_num)
    1817             c=ioctl(handle,WAIT_A2D_INT_1,NULL);
    1818         else
    1819             c=ioctl(handle,WAIT_A2D_INT_2,NULL);
    1820 
    1821 
    1822     return (c & 0xff);
    1823 
    1824 }
    1825 
    1826 
    1827 int wait_dac_int(int dac_num)
    1828 {
    1829 int c;
    1830 
    1831     if(check_handle())   /* Check for chip available */
    1832                 return -1;
    1833 
    1834         if(dac_num)
    1835             c=ioctl(handle,WAIT_DAC_INT_1,NULL);
    1836         else
    1837             c=ioctl(handle,WAIT_DAC_INT_2,NULL);
    1838 
    1839     return (c & 0xff);
    1840 
    1841 }
    1842 
    1843 
    1844 int wait_dio_int(void)
    1845 {
    1846 int c;
    1847 
    1848 
    1849     if(check_handle())   /* Check for chip available */
    1850                 return -1;
    1851 
    1852     c=ioctl(handle,WAIT_DIO_INT,NULL);
    1853 
    1854     return (c & 0xff);
    1855 
    1856 }
    1857 
    1858 
    1859 
    1860 int check_handle(void)
    1861 {
    1862     if(handle > 0)      /* If it's already a valid handle */
    1863                 return 0;
    1864 
    1865     if(handle == -1)    /* If it's already been tried */
    1866         {
    1867                 mio_error_code = MIO_OPEN_ERROR;
    1868                 sprintf(mio_error_string,"MIO - Unable to open device PCMMIO");
    1869                 return -1;
    1870         }
    1871 
    1872     /* Try opening the device file, in case it hasn't been opened yet */
    1873 
    1874     handle = open(device_id,0);
    1875 
    1876         /* Try an alternate open at /dev */
    1877 
    1878         if(handle < 0)
    1879                 handle = open(dev_id,0);
    1880 
    1881     if(handle > 0)      /* If it's now a valid handle */
    1882                 return 0;
    1883 
    1884         mio_error_code = MIO_OPEN_ERROR;
    1885         sprintf(mio_error_string,"MIO - Unable to open device PCMMIO");
    1886     handle = -1;
    1887         return -1;
    1888 }
    1889 
  • pcmmio/original/mio_io.h

    r13bdbee r1662ede  
    77 */
    88
    9 /* $Log$
    10 *
    11 */
     9/* $Id$ */
    1210
    1311#ifndef CHARDEV_H
    1412#define CHARDEV_H
    1513
     14#if defined(__linux__)
    1615#include <linux/ioctl.h>
    1716
     
    5857#define DEVICE_FILE_NAME "pcmmio"
    5958
    60 
    61 #endif
    62 
    63 /* These are the error codes doe mio_error_code */
     59#endif
     60
     61#endif
     62
     63/* These are the error codes for mio_error_code */
    6464
    6565#define MIO_SUCCESS 0
     
    118118char mio_error_string[128];
    119119float adc_bitval[16] = {.00, .00, .00, .00, .00, .00, 00, .00,
    120                                                            .00, .00, .00, .00, .00, .00, .00, .00 };
     120                        .00, .00, .00, .00, .00, .00, .00, .00 };
    121121
    122122unsigned short adc_adjust[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
    123123
    124124float adc_offset[16] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
    125                                                 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
     125                        0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
    126126
    127127#else
     
    143143#endif
    144144
     145/* part of the porting layer */
     146int check_handle(void);
     147int mio_read_irq_assigned(void);
    145148
    146149int disable_dio_interrupt(void);
     
    153156int wait_dac_ready(int channel);
    154157int set_dac_output(int channel, unsigned short dac_value);
    155 int set_dac_voltage(int channel, float voltage);
    156158int set_dac_voltage(int channel, float voltage);
    157159unsigned char read_dio_byte(int offset);
     
    183185int dio_clr_int(int bit_number);
    184186int dio_get_int(void);
     187int dio_get_int_with_timestamp(
     188  unsigned long long *timestamp
     189);
    185190int wait_adc_int(int adc_num);
    186191int wait_dac_int(int dac_num);
    187192int wait_dio_int(void);
    188193
    189 
    190 
    191 
    192 
    193 
    194 
    195 
    196 
    197 
    198 
    199 
    200 
    201 
    202 
    203 
    204 
    205 
    206 
    207 
    208 
    209 
    210 
    211 
    212 
    213 
    214 
    215 
    216 
    217 
    218 
    219 
    220 
    221 
    222 
    223 
    224 
    225 
    226 
    227 
    228 
    229 
     194#if defined(__rtems__)
     195  void pcmmio_initialize(
     196    unsigned short _base_port,
     197    unsigned short _irq
     198  );
     199
     200  void flush_buffered_ints(void);
     201  int wait_adc_int_with_timeout(int adc_num, int milliseconds);
     202  int wait_dac_int_with_timeout(int dac_num, int milliseconds);
     203  int wait_dio_int_with_timeout(int milliseconds);
     204  int wait_dio_int_with_timestamp(
     205    int                 milliseconds,
     206    unsigned long long *timestamp
     207  );
     208  int dio_get_missed_interrupts(void);
     209#endif
     210
  • pcmmio/original/pcmmio.c

    r13bdbee r1662ede  
    1 /* PCMMIO.C    WinSystems PCM-MIO Linux Driver */
    2 
    3 /*
    4  * $Header$
     1/*
     2 * WinSystems PCM-MIO Linux Device Driver
     3 *
    54 * $Id$
    6  *
    7  * Filename : $RCSfile$
    8  *
    9  * $Log$
    10  *
    11  *
    12  * WinSystems PCM-MIO Linux Device Driver
    135 */
    146
     
    10251017}
    10261018
    1027        
  • pcmmio/original/poll.c

    r13bdbee r1662ede  
    1 /* Poll.c Demonstration program for WinSystems PCM-MIO Driver */
    2 
    3 /*
    4 *
    5 * $Header$
    6 *
    7 * $Id$
    8 *
    9 * $Log$
    10 *
    11 */
    12 
    13 /* This program demonstrates one manner in which an unprivledged
    14    application running in user space can sychronize to hardware events
    15    handled by a device driver running in Kernel space.
    16 */
    17 
     1/* poll.c
     2 * Demonstration program for WinSystems PCM-MIO Driver
     3 *
     4 * $Id$
     5 */
     6
     7/* This program demonstrates one manner in which an unprivileged
     8 * application running in user space can synchronize to hardware events
     9 * handled by a device driver running in Kernel space.
     10 */
    1811
    1912#include "mio_io.h"   
     
    2720
    2821
    29 /* This function will be a sub-processe using the Posix threads
     22/* This function will be a sub-processes using the Posix threads
    3023   capability of Linux. This thread will simulate a type of
    3124   Interrupt service routine in that it will start up and then suspend
  • pcmmio/original/repeat.c

    r13bdbee r1662ede  
    1 /* repeat.c Demonstration program for WinSystems PCM-MIO Driver */
    2 
    3 /*
    4 *
    5 * $Header$
    6 *
    7 * $Id$
    8 *
    9 * $Log$
    10 *
    11 *       Compile with :
    12 *
    13 *               gcc repeat.c kbhit.c mio_io.o -o repeat
    14 *
    15 *
    16 *       This program demonstrates the adc_convert_single_repeated function
    17 *       which allows for a sequence of conversions to be accomplished
    18 *       with a single call on the same channel.
    19 *
    20 */
     1/* repeat.c
     2 * Demonstration program for WinSystems PCM-MIO Driver
     3 *
     4 * $Id$
     5 *
     6 * Compile for GNU/Linux with:
     7 *
     8 *    gcc repeat.c kbhit.c mio_io.o -o repeat
     9 *
     10 * This program demonstrates the adc_convert_single_repeated function
     11 * which allows for a sequence of conversions to be accomplished
     12 * with a single call on the same channel.
     13 */
    2114
    2215#include "mio_io.h"   
Note: See TracChangeset for help on using the changeset viewer.