altos: Do not release interrupts from any pollchar function
[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 extern __xdata uint8_t ao_packet_restart;
52
53 void
54 ao_packet_send(void);
55
56 uint8_t
57 ao_packet_recv(void);
58
59 void
60 ao_packet_flush(void);
61
62 void
63 ao_packet_putchar(char c) __reentrant;
64
65 int
66 _ao_packet_pollchar(void);
67
68 #if PACKET_HAS_MASTER
69 /* ao_packet_master.c */
70
71 extern __xdata uint8_t ao_packet_last_rssi;
72
73 void
74 ao_packet_master_init(void);
75 #endif
76
77 #if PACKET_HAS_SLAVE
78 /* ao_packet_slave.c */
79
80 void
81 ao_packet_slave_start(void);
82
83 void
84 ao_packet_slave_stop(void);
85
86 void
87 ao_packet_slave_init(uint8_t enable);
88
89 #endif
90
91 #endif /* _AO_PACKET_H_ */