2 * Copyright Droids Corporation
3 * Olivier Matz <zer0@droids-corp.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * Revision : $Id: ax12_user.h,v 1.3 2009-04-07 20:03:48 zer0 Exp $
23 /* This is the ax12 user interface. It initializes the aversive AX12
24 * module so that it works in background, using interrupt driver uart.
26 * Be carreful, a call to AX12 module is synchronous and uses
27 * interruptions, so interrupts must be enabled. On the other side, a
28 * call _must not_ interrupt another one. That's why all calls to the
29 * module are done either in init() functions or in a scheduler event
33 /* XXX do a safe_ax12() function that will retry once or twice if we
34 * see some problems. */
36 #define UART_AX12_NUM 0
38 void ax12_user_init(void);
40 void ax12_dump_stats(void);
42 #define ax12_user_write_byte(ax12, id, addr, data) \
43 __ax12_user_write_byte(ax12, id, addr, data, __LINE__)
45 #define ax12_user_write_int(ax12, id, addr, data) \
46 __ax12_user_write_int(ax12, id, addr, data, __LINE__)
48 #define ax12_user_read_byte(ax12, id, addr, data) \
49 __ax12_user_read_byte(ax12, id, addr, data, __LINE__)
51 #define ax12_user_read_int(ax12, id, addr, data) \
52 __ax12_user_read_int(ax12, id, addr, data, __LINE__)
54 /** @brief Write byte in AX-12 memory
55 * @return Error code from AX-12 (0 means okay) */
56 uint8_t __ax12_user_write_byte(AX12 *ax12, uint8_t id, AX12_ADDRESS address,
57 uint8_t data, uint16_t line);
59 /** @brief Write integer (2 bytes) in AX-12 memory
60 * @return Error code from AX-12 (0 means okay)
63 * address+1 : data high
65 uint8_t __ax12_user_write_int(AX12 *ax12, uint8_t id, AX12_ADDRESS address,
66 uint16_t data, uint16_t line);
68 /** @brief Read byte from AX-12 memory
69 * @return Error code from AX-12 (0 means okay) */
70 uint8_t __ax12_user_read_byte(AX12 *ax12, uint8_t id, AX12_ADDRESS address,
71 uint8_t *val, uint16_t line);
73 /** @brief Write integer (2 bytes) from AX-12 memory
74 * @return Error code from AX-12 (0 means okay) */
75 uint8_t __ax12_user_read_int(AX12 *ax12, uint8_t id, AX12_ADDRESS address,
76 uint16_t *val, uint16_t line);