Subversion Repositories shark

Rev

Rev 1331 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1331 giacomo 1
/*
2
 * Project: HARTIK (HA-rd R-eal TI-me K-ernel)
3
 *
4
 * Coordinators: Giorgio Buttazzo <giorgio@sssup.it>
5
 *               Gerardo Lamastra <gerardo@sssup.it>
6
 *
7
 * Authors     : Paolo Gai <pj@hartik.sssup.it>
8
 * (see authors.txt for full list of hartik's authors)
9
 *
10
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
11
 *
12
 * http://www.sssup.it
13
 * http://retis.sssup.it
14
 * http://hartik.sssup.it
15
 */
16
 
17
/*
18
 * Copyright (C) 2000 Paolo Gai
19
 *
20
 * This program is free software; you can redistribute it and/or modify
21
 * it under the terms of the GNU General Public License as published by
22
 * the Free Software Foundation; either version 2 of the License, or
23
 * (at your option) any later version.
24
 *
25
 * This program is distributed in the hope that it will be useful,
26
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
 * GNU General Public License for more details.
29
 *
30
 * You should have received a copy of the GNU General Public License
31
 * along with this program; if not, write to the Free Software
32
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
33
 *
34
 */
35
 
36
#include <stdlib.h>
37
#include <string.h>
38
#include <math.h>
39
#include <kernel/kern.h>
40
#include <kernel/func.h>
41
#include <semaphore.h>
42
#include "modules/sem.h"
43
#include "modules/hartport.h"
44
#include <drivers/keyb.h>
45
 
46
#include <servo.h>
47
 
48
/* COM Port Constants */
49
#define COM_PORT COM2
50
#define COM_SPEED 115200
51
 
52
#define com(i) ((i) / 12) ? COM2 : COM1
53
#define pin(i) (i) % 12
54
 
55
/* Angle bounds */
56
#define POS_X_MIN          0
57
#define POS_X_MAX        200
58
#define POS_Y_MIN       -200
59
#define POS_Y_MAX        200
60
#define POS_Z_MIN       -150
61
#define POS_Z_MAX        150
62
 
1333 giacomo 63
typedef struct {
64
        int             adc_in;
65
        unsigned char   pwm;
66
} LEG_CFG_STATE;
67
 
1331 giacomo 68
typedef struct { /*describe the position and adc value of a leg*/
69
        int             x;
70
        int             y;
71
        int             z;
1333 giacomo 72
} LEG_POS_STATE;
1331 giacomo 73
 
1333 giacomo 74
typedef struct { /*describe the position and adc value of a leg*/
75
        int             a;
76
        int             b;
77
        int             c;
78
} LEG_ANG_STATE;
79
 
1331 giacomo 80
typedef struct { /*describe the position of a leg in servo angles*/
81
        int     a;
82
        int     b;
83
        int     c;
84
} ANGLES_STATE;
85
 
86
typedef struct {
1333 giacomo 87
        LEG_CFG_STATE   cfg[6];
88
        LEG_POS_STATE   leg[6];
89
        LEG_ANG_STATE   ang[6];
1331 giacomo 90
        char            power;
91
} HEXAPOD_STATE;
92
 
93
/*****************************************/
94
 
1333 giacomo 95
#define EVT_SET_MASK_LEG_ANGLE  0x01
96
#define EVT_SET_MASK_LEG_POS    0x02
97
 
98
#define EVT_STATUS_WAIT         0x01
99
#define EVT_STATUS_EXEC         0x02
100
#define EVT_STATUS_DONE         0x03
101
 
102
struct action_event {
103
 
104
  unsigned char       type;
105
  unsigned char       status;
106
  struct timespec     time;
107
  unsigned char       mask;
108
  unsigned char       data[20]; //Generic data
109
  struct action_event *next;
110
 
111
};
112
 
113
struct action_event *get_first_old_event(struct timespec *time);
114
 
1331 giacomo 115
extern  sem_t           mx_status;
116
extern  HEXAPOD_STATE   status;
117
 
118
void    init_send(void);
119
void    end_send(void);
120
 
121
void    init_key(void);