Changeset 6957d53 in multiio


Ignore:
Timestamp:
Feb 17, 2011, 4:39:38 PM (8 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
master
Children:
c531584
Parents:
541e6d8
Message:

2011-02-17 Joel Sherrill <joel.sherrill@…>

  • Makefile, main_pcmmio_adc.c, pcmmio_commands.h, pcmmio_shell.c: Add set mode command. Add capability to read a single ADC. Updates from Ada version.
  • rootfs/set_adc_modes, rootfs/test_adc: New files.
Location:
pcmmio
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • pcmmio/original/ChangeLog

    r541e6d8 r6957d53  
     12011-02-17      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * Makefile, main_pcmmio_adc.c, pcmmio_commands.h, pcmmio_shell.c: Add
     4        set mode command. Add capability to read a single ADC. Updates from
     5        Ada version.
     6        * rootfs/set_adc_modes, rootfs/test_adc: New files.
     7
    182011-02-17      Joel Sherrill <joel.sherrill@oarcorp.com>
    29
  • pcmmio/original/Makefile

    r541e6d8 r6957d53  
    88#
    99
    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
     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
     12
     13MAINS= pcmmio_shell.c
    1214
    1315PGMS=$(MAINS:%.c=${ARCH}/%.exe)
     
    2022#SHARED_CSRCS += mio_io_linux.c
    2123SHARED_CSRCS = mio_io.c kbhit.c
     24SHARED_CSRCS += main_pcmmio_adc_mode.c
    2225SHARED_CSRCS += main_pcmmio_din.c main_pcmmio_dout.c
    2326SHARED_CSRCS += main_pcmmio_adc.c main_pcmmio_dac.c
     
    2528SHARED_CSRCS += main_pcmmio_benchmark.c
    2629SHARED_CSRCS += mio_io_rtems.c
     30SHARED_CSRCS += FilesystemImage.c
    2731
    2832SHARED_COBJS = $(SHARED_CSRCS:%.c=${ARCH}/%.o)
    2933SHARED_CONFIG = ${ARCH}/rtems_config.o
     34
     35CLEAN_ADDITIONS += FilesystemImage FilesystemImage.c FilesystemImage.h
    3036
    3137include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
     
    3339include $(PROJECT_ROOT)/make/leaf.cfg
    3440
     41LDFLAGS += -g
    3542OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS) $(SHARED_COBJS) $(SHARED_CONFIG)
    3643
    37 all:    ${ARCH} $(OBJS) $(PGMS)
     44all:    ${ARCH} FilesystemImage.c FilesystemImage.h $(OBJS) $(PGMS)
    3845
    3946${ARCH}/pcmmio_shell.exe: pcmmio_shell.c $(OBJS)
     
    4249${ARCH}/%.exe: %.c $(OBJS)
    4350        $(CC) $(LDFLAGS) -o $@ $< $(SHARED_COBJS) $(SHARED_CONFIG)
     51
     52FilesystemImage: rootfs/test_adc rootfs/set_adc_modes
     53        (cd rootfs ; tar cf - --exclude=.svn \
     54          --exclude=CVS --exclude=.cvsignore .) >$(@)
     55
     56FilesystemImage.c FilesystemImage.h: FilesystemImage
     57        $(PROJECT_ROOT)/bin/rtems-bin2c FilesystemImage FilesystemImage
     58
     59FilesystemImage.o: FilesystemImage.c
     60        $(CC) $(CFLAGS) $(CPU_CFLAGS) -c $<
     61
  • pcmmio/original/main_pcmmio_adc.c

    r541e6d8 r6957d53  
    3535
    3636void pcmmio_adc_printf(
    37   float *adc
     37  float *adc,
     38  int    channel
    3839)
    3940{
     
    4142
    4243  (void) rtems_clock_get_uptime( &ts );
    43   printf(
    44     "%03ld:%06ld %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f\n"
    45     "%11s%7.4f %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f\n",
    46     ts.tv_sec, ts.tv_nsec/1000,
    47     adc[0], adc[1], adc[2], adc[3], adc[4], adc[5], adc[6], adc[7],
    48     "", adc[8], adc[9], adc[10], adc[11], adc[12], adc[13], adc[14], adc[15]
    49   );
     44  printf( "%03ld:%06ld ", ts.tv_sec, ts.tv_nsec/1000 );
     45
     46  if ( channel == -1 ) {
     47    printf(
     48      "%7.4f %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f\n"
     49      "%11s%7.4f %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f %7.4f\n",
     50      adc[0], adc[1], adc[2], adc[3], adc[4], adc[5], adc[6], adc[7],
     51      "", adc[8], adc[9], adc[10], adc[11], adc[12], adc[13], adc[14], adc[15]
     52    );
     53  } else {
     54    printf( "%7.4f\n", adc[channel] );
     55  }
    5056}
    5157
    5258char pcmmio_adc_usage[] =
    53   "Usage: %s [-i iterations] [-p period] [-v]\n"
     59  "Usage: %s [-i iterations] [-p period] [-v] [channel]\n"
    5460  "Where: maximum iterations defaults to 1\n"
    5561  "       the period is in milliseconds and defaults to 1000\n";
     
    6369  int                 maximum;
    6470  int                 iterations;
     71  int                 channel;
     72  int                 i;
    6573  char                ch;
    6674  bool                changed;
     
    7583   */
    7684  milliseconds = 1000;
    77   maximum = 1;
    78   verbose = false;
     85  maximum      = 1;
     86  channel      = -1;
     87  verbose      = false;
    7988
    8089  memset(&getopt_reent, 0, sizeof(getopt_data));
     
    113122  }
    114123
    115   if ( maximum != 1 )
     124  if ( maximum != 1 ) {
    116125    printf(
    117126      "Polling analog inputs for %d iterations with %d msec period\n",
     
    119128      milliseconds
    120129    );
     130  }
     131
     132  /*
     133   *  Is there a specific ADC we are interested in?
     134   */
     135  i = getopt_reent.optind;
     136  if ( i < argc ) {
     137    if ( rtems_string_to_int( argv[i], &channel, NULL, 0 ) ) {
     138      printf( "ADC (%s) is not a number\n", argv[i] );
     139      return -1;
     140    }
     141    if ( channel < 0 || channel > 15 ) {
     142      puts( "ADC number must be 0-15" );
     143      return -1;
     144    }
     145  }
    121146
    122147  /*
     
    129154    pcmmio_adc_read(adc_current);
    130155   
    131     if ( iterations == 1 )
     156    if ( iterations == 1 ) {
    132157      changed = true;
    133     else if ( memcmp( adc_last, adc_current, sizeof(adc_current) ) )
    134       changed = true;
    135    
     158    } else if ( channel == -1 ) {
     159      if ( memcmp( adc_last, adc_current, sizeof(adc_current) ) )
     160        changed = true;
     161    } else if ( adc_last[channel] != adc_current[channel] ) {
     162       changed = true;
     163    }
     164
    136165    if ( verbose || changed ) {
    137       pcmmio_adc_printf(adc_current);
     166      pcmmio_adc_printf(adc_current, channel);
    138167      memcpy( adc_last, adc_current, sizeof(adc_current) );
    139168      changed = false;
  • pcmmio/original/pcmmio_commands.h

    r541e6d8 r6957d53  
    2020extern rtems_shell_cmd_t Shell_PCMMIO_DIN_Command;
    2121extern rtems_shell_cmd_t Shell_PCMMIO_DOUT_Command;
     22extern rtems_shell_cmd_t Shell_PCMMIO_ADC_Mode_Command;
    2223extern rtems_shell_cmd_t Shell_PCMMIO_ADC_Command;
    2324extern rtems_shell_cmd_t Shell_PCMMIO_DAC_Command;
     
    2930  &Shell_PCMMIO_DOUT_Command, \
    3031  &Shell_PCMMIO_ADC_Command, \
     32  &Shell_PCMMIO_ADC_Mode_Command, \
    3133  &Shell_PCMMIO_DAC_Command, \
    3234  &Shell_PCMMIO_IRQ_Command, \
     
    3638extern rtems_shell_alias_t Shell_PCMMIO_DOUT_Alias;
    3739extern rtems_shell_alias_t Shell_PCMMIO_ADC_Alias;
     40extern rtems_shell_alias_t Shell_PCMMIO_ADC_Mode_Alias;
    3841extern rtems_shell_alias_t Shell_PCMMIO_DAC_Alias;
    3942
     
    4245  &Shell_PCMMIO_DOUT_Alias, \
    4346  &Shell_PCMMIO_ADC_Alias, \
     47  &Shell_PCMMIO_ADC_Mode_Alias, \
    4448  &Shell_PCMMIO_DAC_Alias
    4549 
  • pcmmio/original/pcmmio_shell.c

    r541e6d8 r6957d53  
    1212#include "pcmmio_commands.h"
    1313
     14#include <stdlib.h>
     15
     16#include <rtems/untar.h>
     17/*
     18 *  The tarfile image is built automatically externally.
     19 */
     20#include "FilesystemImage.h"
     21
    1422rtems_task Init(
    1523  rtems_task_argument ignored
    1624)
    1725{
     26  int status;
     27
    1828  /*
    1929   *  Initialize the PCMMIO module to use IRQ6.  Ours is jumpered for 0x300
     
    2636    for (i=1 ; i<=48 ; i++ )
    2737      dio_enab_bit_int(i, 1);
     38  }
     39
     40  /*
     41   * Untar initial filesystem contents from program image
     42   */
     43  printk("Loading filesystem image\n");
     44  status = Untar_FromMemory( (char *)FilesystemImage, FilesystemImage_size );
     45  if ( status ) {
     46    printf("Unable to untar initial filesystem contents\n");
     47    exit(0);   
    2848  }
    2949
     
    7797#define CONFIGURE_INIT_TASK_ATTRIBUTES      RTEMS_FLOATING_POINT
    7898
     99/* We need the full IMFS to create initial files */
     100#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
     101
    79102#define CONFIGURE_STACK_CHECKER_ENABLED
    80103#define CONFIGURE_MALLOC_STATISTICS
Note: See TracChangeset for help on using the changeset viewer.