altos: Pull more interfaces out of ao.h and move to separate files
[fw/altos] / src / core / ao_packet.h
1 /*
2  * Copyright © 2012 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 2 of the License.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
16  */
17
18 #ifndef _AO_PACKET_H_
19 #define _AO_PACKET_H_
20
21 /*
22  * ao_packet.c
23  *
24  * Packet-based command interface
25  */
26
27 #define AO_PACKET_MAX           64
28 #define AO_PACKET_SYN           (uint8_t) 0xff
29
30 struct ao_packet {
31         uint8_t         addr;
32         uint8_t         len;
33         uint8_t         seq;
34         uint8_t         ack;
35         uint8_t         d[AO_PACKET_MAX];
36         uint8_t         callsign[AO_MAX_CALLSIGN];
37 };
38
39 struct ao_packet_recv {
40         struct ao_packet        packet;
41         int8_t                  rssi;
42         uint8_t                 status;
43 };
44
45 extern __xdata struct ao_packet_recv ao_rx_packet;
46 extern __xdata struct ao_packet ao_tx_packet;
47 extern __xdata struct ao_task   ao_packet_task;
48 extern __xdata uint8_t ao_packet_enable;
49 extern __xdata uint8_t ao_packet_master_sleeping;
50 extern __pdata uint8_t ao_packet_rx_len, ao_packet_rx_used, ao_packet_tx_used;
51
52 void
53 ao_packet_send(void);
54
55 uint8_t
56 ao_packet_recv(void);
57
58 void
59 ao_packet_flush(void);
60
61 void
62 ao_packet_putchar(char c) __reentrant;
63
64 char
65 ao_packet_pollchar(void) __critical;
66
67 #if PACKET_HAS_MASTER
68 /* ao_packet_master.c */
69
70 void
71 ao_packet_master_init(void);
72 #endif
73
74 #if PACKET_HAS_SLAVE
75 /* ao_packet_slave.c */
76
77 void
78 ao_packet_slave_start(void);
79
80 void
81 ao_packet_slave_stop(void);
82
83 void
84 ao_packet_slave_init(uint8_t enable);
85
86 #endif
87
88 #endif /* _AO_PACKET_H_ */