Revision 1617
wl: clean up unit tests
xbee.h | ||
---|---|---|
1 | 1 |
/** |
2 |
* Copyright (c) 2007 Colony Project
|
|
2 |
* Copyright (c) 2009 Colony Project
|
|
3 | 3 |
* |
4 | 4 |
* Permission is hereby granted, free of charge, to any person |
5 | 5 |
* obtaining a copy of this software and associated documentation |
... | ... | |
32 | 32 |
* To use a robot, define ROBOT in wl_defs.h, and |
33 | 33 |
* to use a computer, don't define ROBOT. |
34 | 34 |
* |
35 |
* @author Brian Coltin, Colony Project, CMU Robotics Club
|
|
35 |
* @author Colony Project, CMU Robotics Club |
|
36 | 36 |
**/ |
37 | 37 |
|
38 | 38 |
#ifndef XBEE_H |
39 | 39 |
#define XBEE_H |
40 | 40 |
|
41 |
/** |
|
42 |
* The port to use the XBee from on the computer. |
|
43 |
* Also, a backup port if the other is used. |
|
44 |
**/ |
|
45 |
#ifndef ROBOT |
|
46 |
#define XBEE_PORT_DEFAULT "/dev/ttyUSB1" |
|
41 |
// need this for C99 int types |
|
42 |
#ifndef STDINT_H |
|
43 |
#define STDINT_H |
|
44 |
#include <stdint.h> |
|
47 | 45 |
#endif |
48 | 46 |
|
47 |
|
|
49 | 48 |
/** |
50 | 49 |
* @defgroup xbee XBee |
51 | 50 |
* @brief Interface with the XBee module |
... | ... | |
54 | 53 |
* |
55 | 54 |
* @{ |
56 | 55 |
**/ |
57 |
|
|
58 |
/*Definitions*/ |
|
56 |
|
|
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 |
#define XBEE_BAUD 115200 |
|
64 |
#endif |
|
65 |
|
|
66 |
/**@name xbee options |
|
67 |
* @{ **/ |
|
68 |
|
|
59 | 69 |
/**@brief Unset PAN, uses XBee default **/ |
60 | 70 |
#define XBEE_PAN_DEFAULT 0xFFFF |
61 | 71 |
/**@brief Unset channel, uses XBee default **/ |
... | ... | |
73 | 83 |
/**@brief A packet received from another XBee **/ |
74 | 84 |
#define XBEE_RX 0x81 |
75 | 85 |
|
86 |
/**@} |
|
87 |
* @name xbee frame types |
|
88 |
* @{ **/ |
|
89 |
|
|
90 |
// TODO: add comments for all of these definitions |
|
91 |
|
|
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 |
|
|
76 | 113 |
/**@brief Initialize the XBee library **/ |
77 |
int xbee_lib_init(void);
|
|
114 |
int8_t xbee_init(void);
|
|
78 | 115 |
/**@brief Uninitialize the XBee library **/ |
79 |
void xbee_terminate(void); |
|
80 |
/**@brief Get a packet from the XBee **/ |
|
81 |
int xbee_get_packet(unsigned char* packet); |
|
116 |
int8_t xbee_terminate(void); |
|
117 |
/**@brief Send a byte to the xbee **/ |
|
118 |
int8_t xbee_putc(uint8_t c); |
|
119 |
/**@brief Read a byte form the xbee **/ |
|
120 |
int16_t xbee_getc(void); |
|
121 |
/**@brief Read a byte from the xbee (nonblocking) **/ |
|
122 |
int8_t xbee_getc_nb(uint8_t *c); |
|
123 |
/**@brief Send an array of bytes to the xbee **/ |
|
124 |
int8_t xbee_send(uint8_t* buf, uint16_t size); |
|
125 |
/**@brief Add a buffer to the checksum value **/ |
|
126 |
int8_t xbee_checksum_add(uint8_t *buf, uint8_t len, uint8_t* sum); |
|
127 |
/**@brief Send a frame header to the xbee **/ |
|
128 |
int8_t xbee_send_header(uint8_t type, uint16_t len); |
|
82 | 129 |
/**@brief Send a packet to the XBee **/ |
83 |
int xbee_send_packet(char* packet, int len, int dest, char options, char frame);
|
|
130 |
int8_t xbee_send_packet(uint8_t* packet, uint8_t len, uint16_t dest, uint8_t options, uint8_t frame);
|
|
84 | 131 |
/**@brief Set the PAN ID for the XBee **/ |
85 |
int xbee_set_pan_id(int id);
|
|
132 |
int8_t xbee_set_pan_id(uint16_t id);
|
|
86 | 133 |
/**@brief Get the XBee's PAN ID **/ |
87 |
unsigned int xbee_get_pan_id(void);
|
|
134 |
uint16_t xbee_get_pan_id(void);
|
|
88 | 135 |
/**@brief Set the channel the XBee is currently using **/ |
89 |
int xbee_set_channel(int channel);
|
|
136 |
int8_t xbee_set_channel(uint8_t channel);
|
|
90 | 137 |
/**@brief Get the channel the XBee is currently using **/ |
91 |
int xbee_get_channel(void); |
|
138 |
int8_t xbee_get_channel(void);
|
|
92 | 139 |
/**@brief Get the XBee's 16-bit address **/ |
93 |
unsigned int xbee_get_address(void); |
|
94 |
/**@brief Set the com port on a computer, undefined on the robot**/ |
|
95 |
void xbee_set_com_port(char* port); |
|
140 |
uint16_t xbee_get_address(void); |
|
96 | 141 |
/**@brief Reset XBee **/ |
97 |
int xbee_reset(void);
|
|
142 |
int8_t xbee_reset(void); // TODO: implement this function
|
|
98 | 143 |
|
99 |
/**@}**/ //end defgroup
|
|
144 |
/**@} **/ //end xbee_funcs group
|
|
100 | 145 |
|
146 |
/**@} **/ //end defgroup |
|
147 |
|
|
101 | 148 |
#endif |
Also available in: Unified diff