Subversion Repositories shark

Rev

Rev 1550 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1606 tullio 1
/*
2
 * Project: S.Ha.R.K
3
 *
4
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
5
 *
6
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
7
 *
8
 *
9
 * http://www.sssup.it
10
 * http://retis.sssup.it
11
 * http://hartik.sssup.it
12
 */
13
 
14
/*
15
 * This program is free software; you can redistribute it and/or modify
16
 * it under the terms of the GNU General Public License as published by
17
 * the Free Software Foundation; either version 2 of the License, or
18
 * (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
 *
29
 */
30
 
1284 giacomo 31
#include "kernel/kern.h"
1464 giacomo 32
#include "drivers/shark_keyb26.h"
1479 giacomo 33
#include "unistd.h"
1284 giacomo 34
 
35
#include "servo.h"
36
 
1479 giacomo 37
#define N_SEND 10000
1284 giacomo 38
 
39
int main () {
40
 
1479 giacomo 41
  int res, i = 0, k;
1284 giacomo 42
 
1479 giacomo 43
  srand(sys_gettime(NULL));
1284 giacomo 44
 
1478 giacomo 45
  cprintf("(Open Com2)");
1481 giacomo 46
  res = servo_open(COM2, 19200);
1478 giacomo 47
  cprintf("(Res = %d)",res);
1284 giacomo 48
 
1478 giacomo 49
  cprintf("(Servo Turn On 0)");
1477 giacomo 50
  res = servo_turn_on(COM2, 0);
1478 giacomo 51
  cprintf("(Res = %d)",res);
1284 giacomo 52
 
1479 giacomo 53
  while(i < N_SEND) {
1284 giacomo 54
 
1479 giacomo 55
    cprintf("(Cycle = %d)",i);
1284 giacomo 56
 
1479 giacomo 57
    k = rand() % 180 - 90;
1284 giacomo 58
 
1481 giacomo 59
    cprintf("(Set Servo 0 %d)",k);
1479 giacomo 60
    res = servo_set_angle_sec(COM2, 0, ANGLE2SEC(k,0,0));
61
    cprintf("(Res = %d)",res);
62
 
1481 giacomo 63
    udelay(100000);
1479 giacomo 64
 
65
    i++;
66
 
67
  }
68
 
1477 giacomo 69
  servo_close(COM2);
1284 giacomo 70
 
1550 pj 71
  exit(0);
1284 giacomo 72
 
73
  return 0;
74
 
75
}
76