OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [g-sercom.ads] - Blame information for rev 750

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 706 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--           G N A T . S E R I A L _ C O M M U N I C A T I O N S            --
6
--                                                                          --
7
--                                 S p e c                                  --
8
--                                                                          --
9
--                    Copyright (C) 2007-2010, AdaCore                      --
10
--                                                                          --
11
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16
-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
17
--                                                                          --
18
-- As a special exception under Section 7 of GPL version 3, you are granted --
19
-- additional permissions described in the GCC Runtime Library Exception,   --
20
-- version 3.1, as published by the Free Software Foundation.               --
21
--                                                                          --
22
-- You should have received a copy of the GNU General Public License and    --
23
-- a copy of the GCC Runtime Library Exception along with this program;     --
24
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
27
-- GNAT was originally developed  by the GNAT team at  New York University. --
28
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29
--                                                                          --
30
------------------------------------------------------------------------------
31
 
32
--  Serial communications package, implemented on Windows and GNU/Linux
33
 
34
with Ada.Streams;
35
with Interfaces.C;
36
 
37
package GNAT.Serial_Communications is
38
 
39
   Serial_Error : exception;
40
   --  Raised when a communication problem occurs
41
 
42
   type Port_Name is new String;
43
   --  A serial com port name
44
 
45
   function Name (Number : Positive) return Port_Name;
46
   --  Returns a possible port name for the given legacy PC architecture serial
47
   --  port number (COM<number>: on Windows, ttyS<number-1> on Linux).
48
   --  Note that this function does not support other kinds of serial ports
49
   --  nor operating systems other than Windows and Linux. For all other
50
   --  cases, an explicit port name can be passed directly to Open.
51
 
52
   type Data_Rate is
53
     (B1200, B2400, B4800, B9600, B19200, B38400, B57600, B115200);
54
   --  Speed of the communication
55
 
56
   type Data_Bits is (CS8, CS7);
57
   --  Communication bits
58
 
59
   type Stop_Bits_Number is (One, Two);
60
   --  One or two stop bits
61
 
62
   type Parity_Check is (None, Even, Odd);
63
   --  Either no parity check or an even or odd parity
64
 
65
   type Serial_Port is new Ada.Streams.Root_Stream_Type with private;
66
 
67
   procedure Open
68
     (Port : out Serial_Port;
69
      Name : Port_Name);
70
   --  Open the given port name. Raises Serial_Error if the port cannot be
71
   --  opened.
72
 
73
   procedure Set
74
     (Port      : Serial_Port;
75
      Rate      : Data_Rate        := B9600;
76
      Bits      : Data_Bits        := CS8;
77
      Stop_Bits : Stop_Bits_Number := One;
78
      Parity    : Parity_Check     := None;
79
      Block     : Boolean          := True;
80
      Timeout   : Duration         := 10.0);
81
   --  The communication port settings. If Block is set then a read call
82
   --  will wait for the whole buffer to be filed. If Block is not set then
83
   --  the given Timeout (in seconds) is used. Note that the timeout precision
84
   --  may be limited on some implementation (e.g. on GNU/Linux the maximum
85
   --  precision is a tenth of seconds).
86
 
87
   overriding procedure Read
88
     (Port   : in out Serial_Port;
89
      Buffer : out Ada.Streams.Stream_Element_Array;
90
      Last   : out Ada.Streams.Stream_Element_Offset);
91
   --  Read a set of bytes, put result into Buffer and set Last accordingly.
92
   --  Last is set to Buffer'First - 1 if no byte has been read, unless
93
   --  Buffer'First = Stream_Element_Offset'First, in which case the exception
94
   --  Constraint_Error is raised instead.
95
 
96
   overriding procedure Write
97
     (Port   : in out Serial_Port;
98
      Buffer : Ada.Streams.Stream_Element_Array);
99
   --  Write buffer into the port
100
 
101
   procedure Close (Port : in out Serial_Port);
102
   --  Close port
103
 
104
private
105
 
106
   type Port_Data;
107
   type Port_Data_Access is access Port_Data;
108
 
109
   type Serial_Port is new Ada.Streams.Root_Stream_Type with record
110
      H : Port_Data_Access;
111
   end record;
112
 
113
   Data_Rate_Value : constant array (Data_Rate) of Interfaces.C.unsigned :=
114
                       (B1200   =>   1_200,
115
                        B2400   =>   2_400,
116
                        B4800   =>   4_800,
117
                        B9600   =>   9_600,
118
                        B19200  =>  19_200,
119
                        B38400  =>  38_400,
120
                        B57600  =>  57_600,
121
                        B115200 => 115_200);
122
 
123
end GNAT.Serial_Communications;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.