summaryrefslogtreecommitdiff
path: root/digital/ai/src/twi_master/mimot.h
blob: 78806154973b5454af3fc2f8a277ef6f563b2e66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef mimot_h
#define mimot_h
/* mimot.h */
/* ai - Robot Artificial Intelligence. {{{
 *
 * Copyright (C) 2010 Nicolas Schodet
 *
 * APBTeam:
 *        Web: http://apbteam.org/
 *      Email: team AT apbteam DOT org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * }}} */
#include "asserv.h"

/**
 * Provide interface to mimot board using the TWI protocol.
 */

/** Mimot TWI address. */
#define MIMOT_TWI_ADDRESS 6

/** Length of status buffer (not including CRC). */
#define MIMOT_STATUS_LENGTH 7

/** Initialise module. */
void
mimot_init (void);

/** Called when a new status buffer is received, update the mimot
 * information. */
void
mimot_status_cb (uint8_t *status);

/** Return motor0 last command status. */
asserv_status_e
mimot_motor0_cmd_status (void);

/** Return motor1 last command status. */
asserv_status_e
mimot_motor1_cmd_status (void);

/** Return input port state. */
uint8_t
mimot_get_input (void);

/** Get motor0 position in steps. */
uint16_t
mimot_get_motor0_position (void);

/** Get motor1 position in steps. */
uint16_t
mimot_get_motor1_position (void);

/** Reset mimot board. */
void
mimot_reset (void);

/** Set motor0 position in steps. */
void
mimot_set_motor0_position (uint16_t position);

/** Set motor1 position in steps. */
void
mimot_set_motor1_position (uint16_t position);

/** Move motor0 to absolute position in steps. */
void
mimot_move_motor0_absolute (uint16_t position, uint16_t speed);

/** Move motor1 to absolute position in steps. */
void
mimot_move_motor1_absolute (uint16_t position, uint16_t speed);

/** Reset motor0 to zero position. */
void
mimot_motor0_zero_position (int16_t speed);

/** Reset motor1 to zero position. */
void
mimot_motor1_zero_position (int16_t speed);

/** Find zero position. */
void
mimot_motor0_find_zero (int16_t speed, uint8_t use_switch,
			uint16_t reset_position);

/** Find zero position. */
void
mimot_motor1_find_zero (int16_t speed, uint8_t use_switch,
			uint16_t reset_position);

/** Clamp motor0. */
void
mimot_motor0_clamp (int16_t speed, int16_t pwm);

/** Clamp motor1. */
void
mimot_motor1_clamp (int16_t speed, int16_t pwm);

/** Free motor0. */
void
mimot_motor0_free (void);

/** Free motor1. */
void
mimot_motor1_free (void);

/** Set raw output for motor. */
void
mimot_motor_output_set (uint8_t motor, int16_t pwm);

#endif /* mimot_h */