Subversion Repositories shark

Rev

Rev 282 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
281 giacomo 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Giacomo Guidi       <giacomo@gandalf.sssup.it>
10
 *   (see the web pages for full authors list)
11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
17
 */
18
 
19
/*
20
 * Copyright (C) 2002 Paolo Gai
21
 *
22
 * This program is free software; you can redistribute it and/or modify
23
 * it under the terms of the GNU General Public License as published by
24
 * the Free Software Foundation; either version 2 of the License, or
25
 * (at your option) any later version.
26
 *
27
 * This program is distributed in the hope that it will be useful,
28
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30
 * GNU General Public License for more details.
31
 *
32
 * You should have received a copy of the GNU General Public License
33
 * along with this program; if not, write to the Free Software
34
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
35
 *
36
 */
37
 
38
#include <ll/sys/ll/ll-instr.h>
39
#include "servo.h"
40
 
41
#define THR 0
42
#define RBR 0
43
#define IER 1
44
#define FCR 2
45
#define IIR 2
46
#define LCR 3
47
#define MCR 4
48
#define LSR 5
49
#define MSR 6
50
#define SPad 7
51
 
52
#define barrier() __asm__ __volatile__("" ::: "memory");
53
 
54
#define TIMEOUT 100000 /* us */
55
 
56
int timer_expired = 0;
57
unsigned com_base[] = {0x03F8,0x02F8,0x03E8,0x02E8};
58
 
59
void set_timer_expired(void)
60
{
61
 
62
  timer_expired = 1;
63
 
64
}
65
 
66
unsigned com_read(unsigned port,unsigned reg)
67
{
68
    unsigned b;
69
    if (port > 3 || reg > 7) return(0);
70
    b = ll_in(com_base[port]+reg);
71
    return(b);
72
}
73
 
74
void com_write(unsigned port,unsigned reg,unsigned value)
75
{
76
    if (port > 3 || reg > 7) return;
77
    ll_out(com_base[port]+reg,value);
78
}
79
 
80
int com_send(unsigned port,BYTE b)
81
{
82
    while ((com_read(port,LSR) & 32) == 0 && !timer_expired)
83
      barrier();
84
    if (!timer_expired) {
85
      com_write(port,THR,b);
86
      return 0;
87
    } else {
88
      return -1;
89
    }
90
}
91
 
92
int com_receive(unsigned port)
93
{
94
    while ((com_read(port,LSR) & 1) == 0 && !timer_expired)
95
      barrier();
96
    if (!timer_expired) {
97
      return((int)(com_read(port,RBR)));
98
    } else {
99
      return -1;
100
    }
101
}
102
 
103
int servo_set_RS232_baudrate(int baud)
104
{
105
 
106
 
107
  return 0;
108
 
109
}
110
 
111
int servo_get_RS232_baudrate(void)
112
{
113
 
114
  return 0;
115
 
116
}
117
 
118
int servo_store_RS232_buadrate(void)
119
{
120
 
121
  return 0;
122
 
123
}
124
 
125
int servo_set_period(int period)
126
{
127
 
128
  return 0;
129
 
130
}
131
 
132
int servo_get_period(void)
133
{
134
 
135
  return 0;
136
 
137
}
138
 
139
int servo_store_period(void)
140
{
141
 
142
  return 0;
143
 
144
}
145
 
146
int servo_get_setup_switch(void)
147
{
148
 
149
  return 0;
150
 
151
}
152
 
153
int servo_set_RC5_switch(int data)
154
{
155
 
156
  return 0;
157
 
158
}
159
 
160
 
161
int servo_set_angle(int servo, int angle)
162
{
163
 
164
  return 0;
165
 
166
}
167
 
168
int servo_get_angle(int servo)
169
{
170
 
171
  return 0;
172
 
173
}
174
 
175
int servo_get_analog(int port)
176
{
177
 
178
  return 0;
179
 
180
}
181