Changeset 35d9acb3 in rtems


Ignore:
Timestamp:
01/07/00 18:52:14 (24 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
1d54d3b
Parents:
09e0df6
Message:

Patch from John M. Mills <jmills@…> to correct the baseline
serial drivers used in the 'gensh2' BSP for the Hitachi sh7045 CPU.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libcpu/sh/sh7045/sci/sci.c

    r09e0df6 r35d9acb3  
    5151#include <rtems/score/iosh7045.h>
    5252#include <sh/sh7_sci.h>
    53 #include <sh/io_types.h>
     53#include <sh/sh7_pfc.h>
     54/* #include <sh/io_types.h> */
    5455#include <sh/sci.h>
     56
     57#ifndef STANDALONE_EVB
     58#define STANDALONE_EVB 0
     59#endif
     60
     61/*
     62 * NOTE: Some SH variants have 3 sci devices
     63 */
     64 
     65#define SCI_MINOR_DEVICES       2
     66 
     67/*
     68 * FIXME: sh7045 register names match Hitachi data book,
     69 *  but conflict with RTEMS sh7032 usage.
     70 */
     71
     72#define SH_SCI_BASE_0   SCI_SMR0
     73#define SH_SCI_BASE_1   SCI_SMR1
     74
     75#define SH_SCI_DEF_COMM_0   B9600 | CS8
     76#define SH_SCI_DEF_COMM_1   B38400 | CS8
     77/*  #define SH_SCI_DEF_COMM_1   B9600 | CS8 */
    5578
    5679struct scidev_t {
    5780  char *                        name ;
     81  unsigned32                    addr ;
    5882  rtems_device_minor_number     minor ;
    5983  unsigned short                opened ;
    6084  tcflag_t                      cflags ;
    61 } sci_device[2] =
    62 {
    63   { "/dev/sci0", 0, 0, B9600 | CS8 },
    64   { "/dev/sci1", 1, 0, B9600 | CS8 }
     85} sci_device[SCI_MINOR_DEVICES] =
     86{
     87  { "/dev/sci0", SH_SCI_BASE_0, 0, 0, SH_SCI_DEF_COMM_0 },
     88  { "/dev/sci1", SH_SCI_BASE_1, 1, 0, SH_SCI_DEF_COMM_1 }
    6589} ;
    6690
    6791/*  local data structures maintain hardware configuration */
     92#if UNUSED
     93static sci_setup_t sio_param[2];
     94#endif
     95
     96/*  imported from scitab.rel */
    6897extern int _sci_get_brparms(
    6998  tcflag_t      cflag,
     
    71100  unsigned char *brr );
    72101
    73 #if UNUSED
    74 static sci_setup_t sio_param[2];
    75 #endif
    76 
    77 /* local functions operate SCI ports 0 and 1 */
    78 /* called from polling routines or ISRs */
     102/* Translate termios' tcflag_t into sci settings */
     103static int _sci_set_cflags(
     104  struct scidev_t      *sci_dev,
     105  tcflag_t      c_cflag )
     106{
     107  unsigned8     smr ;
     108  unsigned8     brr ;
     109 
     110  if ( c_cflag & CBAUD )
     111  {
     112    if ( _sci_get_brparms( c_cflag, &smr, &brr ) != 0 )
     113      return -1 ;
     114  }
     115                   
     116  if ( c_cflag & CSIZE )
     117  {
     118    if ( c_cflag & CS8 )
     119      smr &= ~SCI_SEVEN_BIT_DATA;
     120    else if ( c_cflag & CS7 )
     121      smr |= SCI_SEVEN_BIT_DATA;
     122    else
     123      return -1 ;
     124  }
     125
     126  if ( c_cflag & CSTOPB )
     127    smr |= SCI_STOP_BITS_2;
     128  else
     129    smr &= ~SCI_STOP_BITS_2;
     130
     131  if ( c_cflag & PARENB )
     132    smr |= SCI_PARITY_ON ;
     133  else
     134    smr &= ~SCI_PARITY_ON ;
     135
     136  if ( c_cflag & PARODD )
     137    smr |= SCI_ODD_PARITY ;
     138  else
     139    smr &= ~SCI_ODD_PARITY;
     140   
     141  write8( smr, sci_dev->addr + SCI_SMR );
     142  write8( brr, sci_dev->addr + SCI_BRR );
     143 
     144  return 0 ;
     145}
     146
     147/*
     148 * local functions operate SCI ports 0 and 1
     149 * called from polling routines or ISRs
     150 */
    79151rtems_boolean wrtSCI0(unsigned char ch)
    80152{
     
    243315  unsigned8 temp8;
    244316  unsigned16 temp16;
    245   unsigned char smr ;
    246   unsigned char brr ;
    247317 
    248318  unsigned      a ;
Note: See TracChangeset for help on using the changeset viewer.