xbee.c File Reference

XBee Interface. More...

#include <lights.h>
#include <string.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <time.h>
#include <wl_defs.h>
#include <wireless.h>
#include <eeprom.h>
#include "xbee.h"

Defines

#define NUM_LAST_PACKETS   10
#define XBEE_API_OFF   0x00
#define XBEE_API_ON   0x10
#define XBEE_API_ESCAPE   0x20
#define XBEE_API_MASK   0x30
#define XBEE_COMMAND_WAIT   0x80
#define XBEE_COMMAND_RESPONSE   0xC0
#define XBEE_COMMAND_NONE   0x00
#define XBEE_COMMAND_MASK   0xC0
#define XBEE_NOT_INITD   0xF0
#define LAST_PACKET_MASK   0x0F
#define ESCAPE_MARKER   0x7D
#define ESCAPE_XOR   0x20
#define ESCAPE1   0x7E
#define ESCAPE2   0x7D
#define ESCAPE3   0x11
#define ESCAPE4   0x13
#define PORT   UDR1
#define FLAG   (UCSR1A & (1<<RXC1))

Functions

int8_t xbee_putc (uint8_t c)
int16_t xbee_getc (void)
int8_t xbee_getc_nb (uint8_t *c)
int8_t xbee_send_read_at_command (uint8_t *command)
int8_t xbee_basic_buf_add (uint8_t *ptr, uint8_t byte)
uint8_t xbee_basic_buf_get (uint8_t *ptr)
int8_t xbee_other_buf_add (uint8_t *ptr, uint8_t byte)
int8_t check_last_receive (uint16_t source, uint8_t framenum)
uint8_t getStatus (uint8_t mask)
void setStatus (uint8_t mask, uint8_t value)
void ackhandle (uint8_t num, uint8_t val)
 ISR (USART1_RX_vect)
uint8_t xbee_other_buf_get (uint8_t *ptr)
int8_t xbee_init ()
 Initialize the XBee library.
int8_t xbee_terminate ()
 Uninitialize the XBee library.
int8_t xbee_sendc (uint8_t byte)
 Send byte to the xbee in API mode.
int8_t xbee_send (uint8_t *buf, uint16_t size)
 Send an array of bytes to the xbee in API mode.
int8_t xbee_checksum_add (uint8_t *buf, uint8_t len, uint8_t *sum)
 Add a buffer to the checksum value.
int8_t xbee_send_header (uint16_t len)
 Send a frame header to the xbee.
int8_t xbee_send_packet (uint8_t *packet, uint8_t len, uint16_t dest, uint8_t options, uint8_t frame)
 Send a packet to the XBee.
int8_t xbee_set_pan (uint16_t id)
 Set the PAN ID for the XBee.
uint16_t xbee_get_pan ()
 Get the XBee's PAN ID.
int8_t xbee_set_channel (uint8_t channel)
 Set the channel the XBee is currently using.
int8_t xbee_get_channel (void)
 Get the channel the XBee is currently using.
uint16_t xbee_get_address (void)
 Get the XBee's 16-bit address.

Variables

uint8_t xbee_basic_buf [PACKET_BUFFER_SIZE]
uint8_t basic_buf_first = (PACKET_BUFFER_SIZE-1)
uint8_t basic_buf_last = 0
uint8_t xbee_other_buf [PACKET_BUFFER_SIZE]
uint8_t other_buf_first = (PACKET_BUFFER_SIZE-1)
uint8_t other_buf_last = 0
struct {
   uint16_t   source
   uint8_t   framenum
lastPacket [NUM_LAST_PACKETS]
uint8_t xbee_status = XBEE_NOT_INITD

Detailed Description

XBee Interface.

Copyright (c) 2009 Colony Project

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Implementation of low level communication with the XBee in API mode.

Author:
Colony Project, CMU Robotics Club

Variable Documentation

uint8_t xbee_basic_buf[PACKET_BUFFER_SIZE]

Definition for wireless library receive packet structure

Basic Buffer Packet: byte 1: length of source+data bytes 2-3: source bytes 4-n: data

Other Buffer Packet: byte 1: length of group+source+data byte 2: group number bytes 3-4: source bytes 5-n: data

Referenced by wl_get_basic(), and xbee_init().

Generated on Thu May 6 13:17:00 2010 for libwireless by  doxygen 1.6.3