Changeset 5ebe1e8 in multiio


Ignore:
Timestamp:
Dec 11, 2009, 7:30:22 PM (9 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
master
Children:
2e9b49f
Parents:
8b61cb4
Message:

2009-12-11 Joel Sherrill <joel.sherrill@…>

  • README: Add section on RTEMS Configuration needed by driver.
  • mio_io_rtems.c: Switch to using a message queue for transmitting discrete interrupt changes to the task level.
  • pcmmio_shell.c: Modify application configuration to take into account one less barrier and the new message queue.
Location:
pcmmio/original
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pcmmio/original/ChangeLog

    r8b61cb4 r5ebe1e8  
     12009-12-11      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * README: Add section on RTEMS Configuration needed by driver.
     4        * mio_io_rtems.c: Switch to using a message queue for transmitting
     5        discrete interrupt changes to the task level.
     6        * pcmmio_shell.c: Modify application configuration to take into
     7        account one less barrier and the new message queue.
     8
    192009-12-11      Joel Sherrill <joel.sherrill@oarcorp.com>
    210
  • pcmmio/original/README

    r8b61cb4 r5ebe1e8  
    4242  );
    4343  int dio_get_missed_interrupts(void);
     44
     45RTEMS Configuration
     46===================
     47The driver needs:
     48
     49+ 3 Classic API Barriers
     50+ 1 Classic API Message Queue
     51  - 1024 buffers of sizeof(din_messsage_t) (should be 12 bytes)
     52
     53The pcmmio_shell example is probably over configured but is a
     54working guide.
    4455
    4556RTEMS Shell Commands
  • pcmmio/original/mio_io_rtems.c

    r8b61cb4 r5ebe1e8  
    4545rtems_id wq_dio;
    4646
     47/*
     48 *  Limits on number of buffered discrete input interrupts in
     49 *  the message queue.
     50 */
     51#define MAXIMUM_BUFFERED_DISCRETE_INTERRUPTS 1024
     52
     53///////////////////////////////////////////////////////////////////////////////
     54typedef struct {
     55  unsigned long long timestamp;
     56  int                pin;
     57} din_message_t;
     58
    4759unsigned int pcmmio_dio_missed_interrupts;
    4860
     
    5567);
    5668
    57 ///////////////////////////////////////////////////////////////////////////////
    5869//
    5970//    MIO_READ_IRQ_ASSIGNED
     
    390401)
    391402{
    392   int i;
    393   int sc;
    394 
    395   if (check_handle())   /* Check for chip available */
    396     return -1;
    397 
    398   if((i = get_buffered_int(NULL)))
    399     return i;
    400 
    401   sc = interruptible_sleep_on(&wq_dio, milliseconds);
    402   if ( sc != 0 )
    403     return sc;
    404 
    405   i = get_buffered_int(timestamp);
    406 
    407   return i;
     403  rtems_status_code  rc;
     404  din_message_t      din;
     405  size_t             received;
     406
     407  if (check_handle())   /* Check for chip available */
     408    return -1;
     409
     410  rc = rtems_message_queue_receive(
     411    wq_dio,
     412    &din,
     413    &received,
     414    RTEMS_DEFAULT_OPTIONS,
     415    RTEMS_MILLISECONDS_TO_TICKS(milliseconds)
     416  );
     417  if ( rc == RTEMS_UNSATISFIED )
     418    return -1;
     419
     420  if ( rc == RTEMS_TIMEOUT )
     421    return -1;
     422
     423  if ( rc != RTEMS_SUCCESSFUL ) {
     424    printk( "wait_dio_int_with_timestamp - error %d\n", rc );
     425    exit( 0 );
     426  }
     427
     428  if (timestamp)
     429    *timestamp = din.timestamp;
     430  return din.pin;
    408431}
    409432
     
    463486 printk( "Unable to create PCMMIO Barrier\n" );
    464487 exit(1);
     488}
     489
     490/*
     491 *  RTEMS barrier create helper
     492 */
     493void pcmmio_din_queue_create(
     494  rtems_name  name,
     495  rtems_id   *id
     496)
     497{
     498  rtems_status_code rc;
     499
     500  rc = rtems_message_queue_create(
     501    name,
     502    MAXIMUM_BUFFERED_DISCRETE_INTERRUPTS,
     503    sizeof(din_message_t),
     504    RTEMS_DEFAULT_ATTRIBUTES,
     505    id
     506  );
     507  if ( rc == RTEMS_SUCCESSFUL )
     508    return;
     509
     510  printk( "Unable to create PCMMIO DIN IRQ Message Queue\n" );
     511  exit(1);
    465512}
    466513
     
    558605)
    559606{
    560   /* reset discrete interrupt input counters */
    561   flush_buffered_ints();
    562 
    563607  /* hardware configuration information */
    564608  base_port                    = _base_port;
     
    570614  pcmmio_barrier_create( rtems_build_name( 'd', 'a', 'c', '1' ), &wq_dac_1 );
    571615  pcmmio_barrier_create( rtems_build_name( 'd', 'a', 'c', '2' ), &wq_dac_2 );
    572   pcmmio_barrier_create( rtems_build_name( 'd', 'i', 'o', ' ' ), &wq_dio );
     616  pcmmio_din_queue_create( rtems_build_name( 'd', 'i', 'o', ' ' ), &wq_dio );
    573617
    574618  if ( base_port )
     
    600644 */
    601645
    602 /* We will buffer up the transition interrupts and will pass them on
    603    to waiting applications
    604 */
    605 
    606 #define MAX_INTS 1024
    607 
    608 typedef struct {
    609   unsigned char      line;
    610   unsigned long long timestamp;
    611 } DIO_Int_t;
    612 
    613 static DIO_Int_t int_buffer[MAX_INTS];
    614 static int       inptr = 0;
    615 static int       outptr = 0;
    616 
    617646/* real copy is in mio_io.c */
    618647extern unsigned char adc2_port_image;
     
    662691    int_num = get_int();
    663692    if (int_num) {
    664       #ifdef DEBUG
    665         printk("<1>Buffering DIO interrupt on bit %d\n",int_num);
    666       #endif
    667 
    668       /*
    669        * Buffer the interrupt
    670        *
    671        * NOTE: No need to worry about disabling interrupts,
    672        *       we are in interrupts.
    673        */
    674 
    675       int_buffer[inptr].timestamp = rdtsc();
    676       int_buffer[inptr].line = int_num;
    677       inptr++;
    678       if (inptr == MAX_INTS)
    679         inptr = 0;
     693      rtems_status_code  rc;
     694      din_message_t      din;
     695
     696      din.timestamp = rdtsc();
     697      din.pin       = int_num;
     698
     699      rc = rtems_message_queue_send( wq_dio, &din, sizeof(din_message_t) );
     700      if ( rc != RTEMS_SUCCESSFUL ) {
     701        pcmmio_dio_missed_interrupts++;
     702        #ifdef DEBUG
     703          printk("<1>Missed DIO interrupt\n" );
     704        #endif
     705     }
     706     #ifdef DEBUG
     707       printk("<1>Buffering DIO interrupt on bit %d\n",int_num);
     708     #endif
    680709
    681710      /* Clear the interrupt */
     
    809838void flush_buffered_ints(void)
    810839{
    811   inptr = 0;
    812   outptr = 0;
     840  rtems_status_code  rc;
     841  size_t             flushed;
     842
     843  rc = rtems_message_queue_flush( wq_dio, &flushed );
     844  if ( rc != RTEMS_SUCCESSFUL ) {
     845    printk( "flushed_buffered_int - error %d\n", rc );
     846    exit( 0 );
     847  }
    813848}
    814849
     
    817852)
    818853{
    819   rtems_interrupt_level level;
    820   int                   line;
     854  rtems_status_code  rc;
     855  din_message_t      din;
     856  int                line;
     857  size_t             received;
    821858
    822859  if (irq == 0) {
     
    827864  }
    828865
    829   line = 0;
    830 
    831   rtems_interrupt_disable( level );
    832     if (outptr != inptr) {
    833       if ( timestamp )
    834         *timestamp = int_buffer[outptr].timestamp;
    835       line = int_buffer[outptr].line;
    836       outptr++;
    837       if (outptr == MAX_INTS)
    838         outptr = 0;
    839     }
    840   rtems_interrupt_enable( level );
    841  
    842   return line;
     866  rc = rtems_message_queue_receive(
     867    wq_dio,
     868    &din,
     869    &received,
     870    RTEMS_NO_WAIT,
     871    0
     872  );
     873  if ( rc == RTEMS_UNSATISFIED )
     874    return 0;
     875
     876  if ( rc != RTEMS_SUCCESSFUL ) {
     877    printk( "get_buffered_int - error %d\n", rc );
     878    exit( 0 );
     879  }
     880
     881  if (timestamp)
     882    *timestamp = din.timestamp;
     883  return din.pin;
    843884}
    844885
  • pcmmio/original/pcmmio_shell.c

    r8b61cb4 r5ebe1e8  
    6363#define CONFIGURE_MAXIMUM_TASKS                  20
    6464#define CONFIGURE_MAXIMUM_SEMAPHORES             20
    65 #define CONFIGURE_MAXIMUM_BARRIERS                4
     65#define CONFIGURE_MAXIMUM_BARRIERS                3
     66#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES          1
    6667#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
     68
     69/*
     70 * discrete in messages are 12 bytes and there are 1024 of them
     71 */
     72#define CONFIGURE_MESSAGE_BUFFER_MEMORY \
     73        CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE(1024, 12)
    6774
    6875#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
Note: See TracChangeset for help on using the changeset viewer.