Project

General

Profile

Statistics
| Revision:

root / branches / wireless / code / lib / include / libwireless / xbee.h @ 1935

History | View | Annotate | Download (4.29 KB)

1 18 bcoltin
/**
2 1617 dsschult
 * Copyright (c) 2009 Colony Project
3 242 bcoltin
 *
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25
26
/**
27 18 bcoltin
 * @file xbee.h
28
 * @brief Contains definitions for using the XBee
29
 *
30
 * Contains definitions for interfacing with the
31
 * XBee module, from either a robot or a computer.
32
 * To use a robot, define ROBOT in wl_defs.h, and
33
 * to use a computer, don't define ROBOT.
34
 *
35 1617 dsschult
 * @author Colony Project, CMU Robotics Club
36 18 bcoltin
 **/
37
38 191 bcoltin
#ifndef XBEE_H
39
#define XBEE_H
40
41 1617 dsschult
// need this for C99 int types
42
#ifndef STDINT_H
43
#define STDINT_H
44
#include <stdint.h>
45 138 bcoltin
#endif
46
47 1617 dsschult
48 138 bcoltin
/**
49 18 bcoltin
 * @defgroup xbee XBee
50
 * @brief Interface with the XBee module
51
 *
52
 * Interface with the XBee module.
53
 *
54
 * @{
55
 **/
56 1617 dsschult
57
 /**@defgroup xbee_const xbee constants
58
  * @brief These are constants used for the xbee module.
59
  * @{ **/
60
61
#ifndef XBEE_BAUD
62
/** @brief The XBee baud rate **/
63 1683 bwasserm
#define XBEE_BAUD 9600 //115200
64 1617 dsschult
#endif
65
66
/**@name xbee options
67
 * @{ **/
68
69 60 bcoltin
/**@brief Unset PAN, uses XBee default **/
70 18 bcoltin
#define XBEE_PAN_DEFAULT 0xFFFF
71 60 bcoltin
/**@brief Unset channel, uses XBee default **/
72
#define XBEE_CHANNEL_DEFAULT 0
73 18 bcoltin
/**@brief Broadcast to all robots in the PAN **/
74
#define XBEE_BROADCAST 0xFFFF
75
/**@brief No special options **/
76
#define XBEE_OPTIONS_NONE 0x00
77
/**@brief Do not receive a TX_STATUS message from this packet **/
78
#define XBEE_OPTIONS_DISABLE_RESPONSE 0x01
79
/**@brief Send the packet to all PANS **/
80
#define XBEE_OPTIONS_BROADCAST_ALL_PANS 0x04
81
/**@brief A transmit status packet **/
82
#define XBEE_TX_STATUS 0x89
83
/**@brief A packet received from another XBee **/
84
#define XBEE_RX 0x81
85
86 1617 dsschult
/**@}
87
 * @name xbee frame types
88
 * @{ **/
89
90 1935 bwasserm
// TODO: add doxygen comments for all of these definitions
91 1617 dsschult
92
/*Frame Types*/
93
#define XBEE_FRAME_START 0x7E
94
#define XBEE_FRAME_STATUS 0x8A
95
#define XBEE_FRAME_AT_COMMAND 0x08
96
#define XBEE_FRAME_AT_COMMAND_RESPONSE 0x88
97
#define XBEE_FRAME_TX_REQUEST_64 0x00
98
#define XBEE_FRAME_TX_REQUEST_16 0x01
99
#define XBEE_FRAME_TX_STATUS XBEE_TX_STATUS
100
#define XBEE_FRAME_RX_64 0x80
101
#define XBEE_FRAME_RX_16 XBEE_RX
102
103
/** @} **/
104
105
/**@} **/ // end const group
106
107
/**
108
 * @defgroup xbee_funcs Xbee Functions
109
 * @brief These are the public xbee functions.
110
 * @{
111
 **/
112
113 18 bcoltin
/**@brief Initialize the XBee library **/
114 1617 dsschult
int8_t xbee_init(void);
115 18 bcoltin
/**@brief Uninitialize the XBee library **/
116 1617 dsschult
int8_t xbee_terminate(void);
117 1683 bwasserm
/**@brief Send an array of bytes to the xbee in API mode **/
118 1617 dsschult
int8_t xbee_send(uint8_t* buf, uint16_t size);
119 1683 bwasserm
/**@brief Send byte to the xbee in API mode **/
120
int8_t xbee_sendc(uint8_t byte);
121 1617 dsschult
/**@brief Add a buffer to the checksum value **/
122
int8_t xbee_checksum_add(uint8_t *buf, uint8_t len, uint8_t* sum);
123
/**@brief Send a frame header to the xbee **/
124 1683 bwasserm
int8_t xbee_send_header(uint16_t len);
125 18 bcoltin
/**@brief Send a packet to the XBee **/
126 1617 dsschult
int8_t xbee_send_packet(uint8_t* packet, uint8_t len, uint16_t dest, uint8_t options, uint8_t frame);
127 18 bcoltin
/**@brief Set the PAN ID for the XBee **/
128 1683 bwasserm
int8_t xbee_set_pan(uint16_t id);
129 18 bcoltin
/**@brief Get the XBee's PAN ID **/
130 1683 bwasserm
uint16_t xbee_get_pan(void);
131 60 bcoltin
/**@brief Set the channel the XBee is currently using **/
132 1617 dsschult
int8_t xbee_set_channel(uint8_t channel);
133 60 bcoltin
/**@brief Get the channel the XBee is currently using **/
134 1617 dsschult
int8_t xbee_get_channel(void);
135 18 bcoltin
/**@brief Get the XBee's 16-bit address **/
136 1617 dsschult
uint16_t xbee_get_address(void);
137 1452 dsschult
/**@brief Reset XBee **/
138 1617 dsschult
int8_t xbee_reset(void); // TODO: implement this function
139 18 bcoltin
140 1617 dsschult
/**@} **/ //end xbee_funcs group
141 18 bcoltin
142 1617 dsschult
/**@} **/ //end defgroup
143
144 191 bcoltin
#endif