Subversion Repositories Code-Repo

Compare Revisions

Ignore whitespace Rev 126 → Rev 127

/PIC Stuff/PIC_27J13/interrupts.c
1,9 → 1,9
#include "maindefs.h"
#include "interrupts.h"
#include "uart.h"
#include "i2c.h"
#include "spi.h"
#include "adc.h"
#include "interrupts.h"
 
//----------------------------------------------------------------------------
// Note: This code for processing interrupts is configured to allow for high and
/PIC Stuff/PIC_27J13/main.c
9,14 → 9,19
#include "oled_ssd1306.h"
#include "oled_ssd1331.h"
#include "adc.h"
#include <usart.h>
#include "xbee.h"
#include <delays.h>
#include <string.h>
 
#pragma config WDTEN = OFF // Turn off watchdog timer
#pragma config XINST = OFF // Turn off extended instruction set
#ifdef USE_EXT_OSC
#pragma config OSC = HSPLL // Use external oscillator (101)
#pragma config PLLDIV = 3 // Set PPL prescaler to 3 (to get 4MHz)
#else
#pragma config OSC = INTOSCPLL // Use internal oscillator
#pragma config PLLDIV = 2 // Set PPL prescaler to 2 (to get 4MHz)
#endif
#pragma config CFGPLLEN = ON // Enable PLL on startup
#pragma config PLLSEL = PLL96 // Use 96MHz PLL 4MHz -> 96MHz / 2 = 48MHz
//#pragma config SOSCSEL = HIGH // High Power T1OSC/SOSC circuit selected
77,7 → 82,7
 
while (1) {
 
length = UART1_Read((char *) buffer);
length = UART1_Read_Buffer((unsigned char *) buffer);
if (length != 0) {
UART1_WriteB((char *) buffer, length);
}
249,7 → 254,7
NFC_SAMConfig();
 
memset(cardData, 0, 24);
 
while (1) {
// // This query will hang until the NFC chip replies (card detected)
272,6 → 277,26
// }
// }
 
// // This query will hang until the NFC chip replies (card detected)
// length = NFC_readPassiveTargetID(cardData);
// if (length) {
// DBG_PRINT_MAIN("Cards Found: %u\r\n", length);
// DBG_PRINT_MAIN("UID Length: %d bytes\r\n", cardData[0].NFCID_LEN);
// DBG_PRINT_MAIN("UID: ");
// for (i = 0; i < cardData[0].NFCID_LEN; i++) {
// DBG_PRINT_MAIN("%02X ", cardData[0].NFCID[i]);
// }
// DBG_PRINT_MAIN("\r\n");
// if (length == 2) {
// DBG_PRINT_MAIN("UID Length: %d bytes\r\n", cardData[1].NFCID_LEN);
// DBG_PRINT_MAIN("UID: ");
// for (i = 0; i < cardData[1].NFCID_LEN; i++) {
// DBG_PRINT_MAIN("%02X ", cardData[1].NFCID[i]);
// }
// DBG_PRINT_MAIN("\r\n");
// }
// }
 
// This query will not wait for a detection before responding
length = NFC_pollTargets(1, 1, cardData);
if (!length) {
280,7 → 305,7
if (memcmp(&cardData[0].NFCID, &cardData_prev[0].NFCID, cardData[0].NFCID_LEN) == 0) {
// Do nothing
} else if (memcmp(&cardData[0].NFCID, &cardData_prev[1].NFCID, cardData[0].NFCID_LEN) == 0) {
memcpy((char *)&cardData_prev[0], (const char *)&cardData[0], 12);
memcpy((char *) &cardData_prev[0], (const char *) &cardData[0], 12);
} else {
DBG_PRINT_MAIN("UID: ");
for (i = 0; i < cardData[0].NFCID_LEN; i++) {
287,7 → 312,7
DBG_PRINT_MAIN("%02X ", cardData[0].NFCID[i]);
}
DBG_PRINT_MAIN("\r\n");
memcpy((char *)&cardData_prev[0], (const char *)&cardData[0], 12);
memcpy((char *) &cardData_prev[0], (const char *) &cardData[0], 12);
}
memset(&cardData_prev[1], 0, 12);
} else if (length == 2) {
296,8 → 321,8
// Do nothing
} else if (memcmp(&cardData[0].NFCID, &cardData_prev[1].NFCID, cardData[0].NFCID_LEN) == 0 &&
memcmp(&cardData[1].NFCID, &cardData_prev[0].NFCID, cardData[1].NFCID_LEN) == 0) {
memcpy((char *)&cardData_prev[0], (const char *)&cardData[0], 12);
memcpy((char *)&cardData_prev[1], (const char *)&cardData[1], 12);
memcpy((char *) &cardData_prev[0], (const char *) &cardData[0], 12);
memcpy((char *) &cardData_prev[1], (const char *) &cardData[1], 12);
} else if (memcmp(&cardData[0].NFCID, &cardData_prev[0].NFCID, cardData[0].NFCID_LEN) == 0) {
// First card matched
DBG_PRINT_MAIN("UID2: ");
305,7 → 330,7
DBG_PRINT_MAIN("%02X ", cardData[1].NFCID[i]);
}
DBG_PRINT_MAIN("\r\n");
memcpy(&cardData_prev[1], (const char *)&cardData[1], 12);
memcpy(&cardData_prev[1], (const char *) &cardData[1], 12);
} else if (memcmp(&cardData[1].NFCID, &cardData_prev[1].NFCID, cardData[1].NFCID_LEN) == 0) {
// Second card matched
DBG_PRINT_MAIN("UID1: ");
313,7 → 338,7
DBG_PRINT_MAIN("%02X ", cardData[0].NFCID[i]);
}
DBG_PRINT_MAIN("\r\n");
memcpy((char *)&cardData_prev[0], (const char *)&cardData[0], 12);
memcpy((char *) &cardData_prev[0], (const char *) &cardData[0], 12);
} else {
// No match
DBG_PRINT_MAIN("UID1: ");
321,13 → 346,13
DBG_PRINT_MAIN("%02X ", cardData[0].NFCID[i]);
}
DBG_PRINT_MAIN("\r\n");
memcpy((char *)&cardData_prev[0], (const char *)&cardData[0], 12);
memcpy((char *) &cardData_prev[0], (const char *) &cardData[0], 12);
DBG_PRINT_MAIN("UID2: ");
for (i = 0; i < cardData[1].NFCID_LEN; i++) {
DBG_PRINT_MAIN("%02X ", cardData[1].NFCID[i]);
}
DBG_PRINT_MAIN("\r\n");
memcpy((char *)&cardData_prev[1], &cardData[1], 12);
memcpy((char *) &cardData_prev[1], (const char *) &cardData[1], 12);
}
}
}
732,7 → 757,7
 
while (1) {
// ADC read from AN0-AN2 and prints to display
ADC_Start(ADC_CHANNEL_AN0);
ADC_Start(ADC_CHANNEL_AN2);
GFX_fillRect(0, 0, GFX_width(), 8, SSD1331_BLACK);
GFX_setCursor(0, 0);
while (!ADC_Get_Result(&x));
744,7 → 769,7
while (!ADC_Get_Result(&y));
GFX_writeString("Y: %u", y);
 
ADC_Start(ADC_CHANNEL_AN2);
ADC_Start(ADC_CHANNEL_AN0);
GFX_fillRect(0, 16, GFX_width(), 8, SSD1331_BLACK);
GFX_setCursor(0, 16);
while (!ADC_Get_Result(&z));
754,16 → 779,136
 
#endif
 
#ifdef _TEST_XBEE
 
void main(void) {
unsigned int i, length = 0;
unsigned char buffer[100];
 
XBEE_RX_DATA_PACKET_FRAME *rx_data_frame;
 
/* --------------------- Oscillator Configuration --------------------- */
// OSCTUNEbits.PLLEN = 1; // Enable 4x PLL
OSCCONbits.IRCF = 0b111; // Set INTOSC postscaler to 8MHz
OSCCONbits.SCS = 0b00; // Use 96MHz PLL as primary clock source
/* -------------------------------------------------------------------- */
 
// Set all ports as digial I/O
ANCON0 = 0xFF;
ANCON1 = 0x1F;
 
UART1_Init(); // Initialize the UART handler code
XBee_Init();
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
 
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
while (1) {
 
//#define _ROUTER
#define _COORDINATOR
 
#ifdef _ROUTER
XBEE_TX_DATA_PACKET_FRAME *tx_data_frame;
tx_data_frame = (void *) buffer;
tx_data_frame->frame_type = XBEE_TX_DATA_PACKET;
tx_data_frame->frame_id = 1;
tx_data_frame->destination_64.UPPER_32.long_value = 0x00000000;
tx_data_frame->destination_64.LOWER_32.long_value = 0x00000000;
tx_data_frame->destination_16.INT_16.int_value = 0xFEFF;
tx_data_frame->broadcast_radius = 0;
tx_data_frame->options = 0;
tx_data_frame->data[0] = 0x54;
tx_data_frame->data[1] = 0x78;
tx_data_frame->data[2] = 0x32;
tx_data_frame->data[3] = 0x43;
tx_data_frame->data[4] = 0x6F;
tx_data_frame->data[5] = 0x6F;
tx_data_frame->data[6] = 0x72;
tx_data_frame->data[7] = 0x11;
XBee_Process_Transmit_Frame(buffer, XBEE_TX_DATA_PACKET_FRAME_SIZE + 8);
Delay10KTCYx(255);
Delay10KTCYx(255);
Delay10KTCYx(255);
Delay10KTCYx(255);
Delay10KTCYx(255);
Delay10KTCYx(255);
Delay10KTCYx(255);
Delay10KTCYx(255);
#endif
 
#ifdef _COORDINATOR
length = XBee_Get_Received_Frame(buffer);
if (length != 0) {
switch (*(unsigned char *) buffer) {
case XBEE_RX_AT_COMMAND_RESPONSE:
DBG_PRINT_MAIN("XBEE: parsing recieved AT command response frame\r\n");
break;
case XBEE_RX_DATA_PACKET:
rx_data_frame = (void *)buffer;
DBG_PRINT_MAIN("XBEE: parsing recieved data recieved frame\r\n");
XBee_ConvertEndian64(&(rx_data_frame->source_64));
XBee_ConvertEndian16(&(rx_data_frame->source_16));
DBG_PRINT_MAIN("Source 64: %08lX %08lX Source 16: %04X Options: %X\r\n", \\
rx_data_frame->source_64.UPPER_32.long_value, \\
rx_data_frame->source_64.LOWER_32.long_value, \\
rx_data_frame->source_16.INT_16.int_value, \\
rx_data_frame->recieve_options);
DBG_PRINT_MAIN("Data: ");
for (i = 0; i < length - XBEE_RX_DATA_PACKET_FRAME_SIZE; i++) {
DBG_PRINT_MAIN("%02X ", rx_data_frame->data[i]);
}
DBG_PRINT_MAIN("\r\n");
break;
case XBEE_RX_DATA_TX_STATUS:
DBG_PRINT_MAIN("XBEE: parsing recieved TX status frame\r\n");
break;
case XBEE_RX_IO_DATA_SAMPLE:
DBG_PRINT_MAIN("XBEE: parsing recieved IO data sample frame\r\n");
break;
case XBEE_RX_EXPLICIT_COMMAND:
DBG_PRINT_MAIN("XBEE: parsing recieved explicit command frame\r\n");
break;
case XBEE_RX_REMOTE_AT_COMMAND_RESPONSE:
DBG_PRINT_MAIN("XBEE: parsing recieved remote AT command frame\r\n");
break;
case XBEE_RX_ROUTE_RECORD:
DBG_PRINT_MAIN("XBEE: parsing recieved route record frame\r\n");
break;
case XBEE_RX_NODE_IDENTIFICATION:
DBG_PRINT_MAIN("XBEE: parsing recieved node identification frame\r\n");
break;
case XBEE_RX_FRAME_MODEM_STATUS:
DBG_PRINT_MAIN("XBEE: parsing recieved modem status frame\r\n");
break;
default:
DBG_PRINT_MAIN("??\r\n");
break;
}
}
#endif
 
}
}
#endif
 
#if !defined(_TEST_UART) && !defined(_TEST_I2C_MASTER) && \
!defined(_TEST_I2C_SLAVE) && !defined(_TEST_SPI) && \
!defined(_TEST_NFC) && !defined(_TEST_LED_BACKPACK) && \
!defined(_TEST_SSD1306_OLED) && !defined(_TEST_SSD1331_OLED) && \
!defined(_TEST_ADC)
!defined(_TEST_ADC) && !defined(_TEST_XBEE)
 
void main(void) {
unsigned char length = 0;
unsigned char buffer[60];
 
// NFC stuff
NFC_FIRMWARE_VERSION version;
NFC_TargetDataMiFare cardData[2];
NFC_TargetDataMiFare cardData_prev[2];
 
/* --------------------- Oscillator Configuration --------------------- */
// OSCTUNEbits.PLLEN = 1; // Enable 4x PLL
OSCCONbits.IRCF = 0b111; // Set INTOSC postscaler to 8MHz
774,15 → 919,14
ANCON0 = 0xF8;
ANCON1 = 0x1F;
 
UART1_Init(); // Initialize the UART handler code
I2C_Init(); // Initialize the I2C handler code
SPI2_Init(SPI2_FOSC_8); // Initialize the SPI module
SSD1331_Init(); // Initialize the SSD1331 OLED display (uses SPI2)
// NFC_Init(); // Initialize the NFC chip (uses I2C)
LED_Init(); // Initialize the LED backpack (uses I2C)
UART1_Init();
I2C_Init();
NFC_Init();
SPI2_Init(SPI2_FOSC_8);
SSD1331_Init();
 
I2C_Configure_Master(I2C_400KHZ);
 
interrupt_enable(); // Enable high-priority interrupts and low-priority interrupts
interrupt_init(); // Initialize the interrupt priorities
 
789,20 → 933,60
DBG_PRINT_MAIN("\r\nBegin Program\r\n");
 
SSD1331_Begin();
LED_Start();
memset(buffer, 0, 60);
memset(cardData, 0, 24);
memset(cardData_prev, 0, 24);
GFX_clearScreen();
GFX_setRotation(3);
GFX_setRotation(0);
GFX_setCursor(0, 0);
 
version = NFC_getFirmwareVersion();
while (!version.IC) {
GFX_appendString("Waiting for NFC board..\r");
Delay10KTCYx(3);
version = NFC_getFirmwareVersion();
}
GFX_appendString("PN5%X Ver. %d.%d\r", version.IC, version.Ver, version.Rev);
NFC_SAMConfig();
 
while (1) {
 
// Reads input from UART and prints to display
length = UART1_Read_Buffer(buffer);
if (length != 0) {
buffer[length] = 0;
GFX_appendString("%s", buffer);
LED_writeNum(length-1);
// This query will not wait for a detection before responding
length = NFC_pollTargets(1, 1, cardData);
if (!length) {
memset(cardData_prev, 0, 24);
} else if (length == 1) {
if (memcmp(&cardData[0].NFCID, &cardData_prev[0].NFCID, cardData[0].NFCID_LEN) == 0) {
// Do nothing
} else if (memcmp(&cardData[0].NFCID, &cardData_prev[1].NFCID, cardData[0].NFCID_LEN) == 0) {
memcpy((char *) &cardData_prev[0], (const char *) &cardData[0], 12);
} else {
GFX_appendString("UID: %02X %02X %02X %02X\n", cardData[0].NFCID[0], cardData[0].NFCID[1], cardData[0].NFCID[2], cardData[0].NFCID[3]);
memcpy((char *) &cardData_prev[0], (const char *) &cardData[0], 12);
}
memset(&cardData_prev[1], 0, 12);
} else if (length == 2) {
if (memcmp(&cardData[0].NFCID, &cardData_prev[0].NFCID, cardData[0].NFCID_LEN) == 0 &&
memcmp(&cardData[1].NFCID, &cardData_prev[1].NFCID, cardData[1].NFCID_LEN) == 0) {
// Do nothing
} else if (memcmp(&cardData[0].NFCID, &cardData_prev[1].NFCID, cardData[0].NFCID_LEN) == 0 &&
memcmp(&cardData[1].NFCID, &cardData_prev[0].NFCID, cardData[1].NFCID_LEN) == 0) {
memcpy((char *) &cardData_prev[0], (const char *) &cardData[0], 12);
memcpy((char *) &cardData_prev[1], (const char *) &cardData[1], 12);
} else if (memcmp(&cardData[0].NFCID, &cardData_prev[0].NFCID, cardData[0].NFCID_LEN) == 0) {
// First card matched
GFX_appendString("UID: %02X %02X %02X %02X\n", cardData[1].NFCID[0], cardData[1].NFCID[1], cardData[1].NFCID[2], cardData[1].NFCID[3]);
memcpy(&cardData_prev[1], (const char *) &cardData[1], 12);
} else if (memcmp(&cardData[1].NFCID, &cardData_prev[1].NFCID, cardData[1].NFCID_LEN) == 0) {
// Second card matched
GFX_appendString("UID: %02X %02X %02X %02X\n", cardData[0].NFCID[0], cardData[0].NFCID[1], cardData[0].NFCID[2], cardData[0].NFCID[3]);
memcpy((char *) &cardData_prev[0], (const char *) &cardData[0], 12);
} else {
// No match
GFX_appendString("UID: %02X %02X %02X %02X\n", cardData[0].NFCID[0], cardData[0].NFCID[1], cardData[0].NFCID[2], cardData[0].NFCID[3]);
memcpy((char *) &cardData_prev[0], (const char *) &cardData[0], 12);
GFX_appendString("UID: %02X %02X %02X %02X\n", cardData[1].NFCID[0], cardData[1].NFCID[1], cardData[1].NFCID[2], cardData[1].NFCID[3]);
memcpy((char *) &cardData_prev[1], (const char *) &cardData[1], 12);
}
}
}
}
/PIC Stuff/PIC_27J13/maindefs.h
4,6 → 4,12
#include <p18f27j13.h>
#include "uart.h"
 
// Option to enable/disable internal oscillator
//#define USE_EXT_OSC
 
//#define UART1_RX_TO_BUFFER
#define UART1_RX_TO_XBEE
 
#define _DEBUG
//#define _TEST_UART
//#define _TEST_I2C_MASTER
14,6 → 20,7
//#define _TEST_SSD1306_OLED
//#define _TEST_SSD1331_OLED
//#define _TEST_ADC
#define _TEST_XBEE
 
// Option to choose between active OLED displays
//#define GFX_SSD1306
25,7 → 32,7
#define DBG_PRINT_UART(x) UART1_WriteS(x)
#define DBG_PRINT_I2C(x) UART1_WriteS(x)
#define DBG_PRINT_SPI(x) UART1_WriteS(x)
#define DBG_PRINT_XBEE(x)
#define DBG_PRINT_XBEE(x) UART1_WriteS(x)
#define DBG_PRINT_PORTB_INT(x)
#define DBG_PRINT_INT(x)
#define DBG_PRINT_BUFFER(x)
/PIC Stuff/PIC_27J13/nbproject/Makefile-default.mk
41,11 → 41,11
DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE}
 
# Object Files Quoted if spaced
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/main.o ${OBJECTDIR}/i2c.o ${OBJECTDIR}/interrupts.o ${OBJECTDIR}/led_backpack.o ${OBJECTDIR}/nfc.o ${OBJECTDIR}/spi.o ${OBJECTDIR}/uart.o ${OBJECTDIR}/oled_ssd1306.o ${OBJECTDIR}/glcdfont.o ${OBJECTDIR}/Adafruit_GFX.o ${OBJECTDIR}/oled_ssd1331.o ${OBJECTDIR}/adc.o
POSSIBLE_DEPFILES=${OBJECTDIR}/main.o.d ${OBJECTDIR}/i2c.o.d ${OBJECTDIR}/interrupts.o.d ${OBJECTDIR}/led_backpack.o.d ${OBJECTDIR}/nfc.o.d ${OBJECTDIR}/spi.o.d ${OBJECTDIR}/uart.o.d ${OBJECTDIR}/oled_ssd1306.o.d ${OBJECTDIR}/glcdfont.o.d ${OBJECTDIR}/Adafruit_GFX.o.d ${OBJECTDIR}/oled_ssd1331.o.d ${OBJECTDIR}/adc.o.d
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/main.o ${OBJECTDIR}/i2c.o ${OBJECTDIR}/interrupts.o ${OBJECTDIR}/led_backpack.o ${OBJECTDIR}/nfc.o ${OBJECTDIR}/spi.o ${OBJECTDIR}/uart.o ${OBJECTDIR}/oled_ssd1306.o ${OBJECTDIR}/glcdfont.o ${OBJECTDIR}/Adafruit_GFX.o ${OBJECTDIR}/oled_ssd1331.o ${OBJECTDIR}/adc.o ${OBJECTDIR}/xbee.o
POSSIBLE_DEPFILES=${OBJECTDIR}/main.o.d ${OBJECTDIR}/i2c.o.d ${OBJECTDIR}/interrupts.o.d ${OBJECTDIR}/led_backpack.o.d ${OBJECTDIR}/nfc.o.d ${OBJECTDIR}/spi.o.d ${OBJECTDIR}/uart.o.d ${OBJECTDIR}/oled_ssd1306.o.d ${OBJECTDIR}/glcdfont.o.d ${OBJECTDIR}/Adafruit_GFX.o.d ${OBJECTDIR}/oled_ssd1331.o.d ${OBJECTDIR}/adc.o.d ${OBJECTDIR}/xbee.o.d
 
# Object Files
OBJECTFILES=${OBJECTDIR}/main.o ${OBJECTDIR}/i2c.o ${OBJECTDIR}/interrupts.o ${OBJECTDIR}/led_backpack.o ${OBJECTDIR}/nfc.o ${OBJECTDIR}/spi.o ${OBJECTDIR}/uart.o ${OBJECTDIR}/oled_ssd1306.o ${OBJECTDIR}/glcdfont.o ${OBJECTDIR}/Adafruit_GFX.o ${OBJECTDIR}/oled_ssd1331.o ${OBJECTDIR}/adc.o
OBJECTFILES=${OBJECTDIR}/main.o ${OBJECTDIR}/i2c.o ${OBJECTDIR}/interrupts.o ${OBJECTDIR}/led_backpack.o ${OBJECTDIR}/nfc.o ${OBJECTDIR}/spi.o ${OBJECTDIR}/uart.o ${OBJECTDIR}/oled_ssd1306.o ${OBJECTDIR}/glcdfont.o ${OBJECTDIR}/Adafruit_GFX.o ${OBJECTDIR}/oled_ssd1331.o ${OBJECTDIR}/adc.o ${OBJECTDIR}/xbee.o
 
 
CFLAGS=
148,6 → 148,12
${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_PK3=1 -p$(MP_PROCESSOR_OPTION) -oi -mL -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/adc.o adc.c
@${DEP_GEN} -d ${OBJECTDIR}/adc.o
${OBJECTDIR}/xbee.o: xbee.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/xbee.o.d
${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -D__MPLAB_DEBUGGER_PK3=1 -p$(MP_PROCESSOR_OPTION) -oi -mL -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/xbee.o xbee.c
@${DEP_GEN} -d ${OBJECTDIR}/xbee.o
else
${OBJECTDIR}/main.o: main.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
221,6 → 227,12
${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -oi -mL -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/adc.o adc.c
@${DEP_GEN} -d ${OBJECTDIR}/adc.o
${OBJECTDIR}/xbee.o: xbee.c nbproject/Makefile-${CND_CONF}.mk
@${MKDIR} ${OBJECTDIR}
@${RM} ${OBJECTDIR}/xbee.o.d
${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -oi -mL -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/xbee.o xbee.c
@${DEP_GEN} -d ${OBJECTDIR}/xbee.o
endif
 
# ------------------------------------------------------------------------------------
/PIC Stuff/PIC_27J13/nbproject/Makefile-genesis.properties
1,5 → 1,5
#
#Sun Jul 15 15:38:32 EDT 2012
#Sat Jul 21 14:17:00 EDT 2012
default.com-microchip-mplab-nbide-toolchainC18-C18LanguageToolchain.md5=db1c0674398f590b65c1c1c4fb1e2b92
default.languagetoolchain.dir=C\:\\Program Files (x86)\\Microchip\\mplabc18\\v3.40\\bin
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=485c926ba2cd86275d1848ca44c226c5
/PIC Stuff/PIC_27J13/nbproject/configurations.xml
15,6 → 15,7
<itemPath>Adafruit_GFX.h</itemPath>
<itemPath>oled_ssd1331.h</itemPath>
<itemPath>adc.h</itemPath>
<itemPath>xbee.h</itemPath>
</logicalFolder>
<logicalFolder name="LibraryFiles"
displayName="Library Files"
44,6 → 45,7
<itemPath>Adafruit_GFX.c</itemPath>
<itemPath>oled_ssd1331.c</itemPath>
<itemPath>adc.c</itemPath>
<itemPath>xbee.c</itemPath>
</logicalFolder>
<logicalFolder name="ExternalFiles"
displayName="Important Files"
/PIC Stuff/PIC_27J13/oled_ssd1331.c
70,12 → 70,12
 
// set x and y coordinate
buffer[0] = (SSD1331_CMD_SETCOLUMN);
buffer[1] = (x);
buffer[2] = (SSD1331_LCDWIDTH - 1);
buffer[1] = (x); // Start x address
buffer[2] = (SSD1331_LCDWIDTH - 1); // End x address
 
buffer[3] = (SSD1331_CMD_SETROW);
buffer[4] = (y);
buffer[5] = (SSD1331_LCDHEIGHT - 1);
buffer[4] = (y); // Start y address
buffer[5] = (SSD1331_LCDHEIGHT - 1); // End y address
 
LATBbits.LATB5 = 0; // D/C low (cmd)
SPI2_Write(buffer, 6);
/PIC Stuff/PIC_27J13/uart.c
1,5 → 1,6
#include "maindefs.h"
#include "uart.h"
#include "xbee.h"
#include <string.h>
#include <stdio.h>
 
59,8 → 60,7
unsigned char c;
if (PIR1bits.RC1IF) { // Check if data receive flag is set
c = RCREG1;
 
#ifdef UART1_RECV_BUFFER
#ifdef UART1_RX_TO_BUFFER
// Save received data into buffer
uart_1_data.buffer_in[uart_1_data.buffer_in_write_ind] = c;
if (uart_1_data.buffer_in_write_ind == MAXUARTBUF - 1) {
86,12 → 86,12
uart_1_data.buffer_in_len_tmp = 0;
}
#endif
#ifdef UART1_RECV_XBEE
 
#ifdef UART1_RX_TO_XBEE
XBee_Serial_In(c);
#endif
}
 
if (RCSTAbits.OERR == 1) {
if (RCSTA1bits.OERR == 1) {
// We've overrun the USART and must reset
RCSTA1bits.CREN = 0; // Reset UART1
RCSTA1bits.CREN = 1;
137,7 → 137,7
for (i = 0; i < uart_1_data.buffer_out_len; i++) {
TXREG1 = uart_1_data.buffer_out[i];
Nop();
while(!PIR1bits.TX1IF); // Wait for byte to be transmitted
while (!PIR1bits.TX1IF); // Wait for byte to be transmitted
}
#else
va_list args;
158,10 → 158,9
for (i = 0; i < length; i++) {
TXREG1 = msg[i];
Nop();
while(!PIR1bits.TX1IF); // Wait for byte to be transmitted
while (!PIR1bits.TX1IF); // Wait for byte to be transmitted
}
#else
unsigned char i;
while (TXSTA1bits.TXEN); // Wait for previous message to finish sending
uart_1_data.buffer_out_len = length;
uart_1_data.buffer_out_ind = 1;
173,6 → 172,21
#endif
}
 
void UART1_WriteC(const unsigned char c) {
#ifdef _DEBUG
TXREG1 = c;
Nop();
while (!PIR1bits.TX1IF);
#else
while (TXSTA1bits.TXEN);
uart_1_data.buffer_out_len = 1;
uart_1_data.buffer_out_ind = 1;
TXREG1 = c;
TXSTA1bits.TXEN = 1;
#endif
 
}
 
unsigned char UART1_Buffer_Len() {
return uart_1_data.buffer_in_len;
}
/PIC Stuff/PIC_27J13/uart.h
27,6 → 27,7
void UART1_Send_Interrupt_Handler(void);
void UART1_WriteS(const rom char *fmt, ...);
void UART1_WriteB(const char *msg, unsigned char length);
void UART1_WriteC(const unsigned char c);
unsigned char UART1_Buffer_Len(void);
unsigned char UART1_Read_Buffer(unsigned char *buffer);
#endif
/PIC Stuff/PIC_27J13/xbee.c
1,150 → 1,134
#include "maindefs.h"
#include "msg_queues.h"
#include "xbee.h"
#include <usart.h>
#include <delays.h>
#include <string.h>
 
static XBEE_DATA *xbee_data_ptr;
static void *xbee_data_array_ptr;
static XBEE_DATA xbee_data;
static void *xbee_data_frame;
static void *xbee_frame;
 
/* Initialize variables used by this library */
void xbee_init(XBEE_DATA *xd) {
TRISBbits.TRISB0 = 1; // RB0 is CTS, set by XBee chip
TRISBbits.TRISB1 = 0; // RB1 is RTS, set by PIC
void XBee_Init() {
XBEE_CTS_TRIS = 1; // RB0 is CTS, set by XBee chip
XBEE_RTS_TRIS = 0; // RB1 is RTS, set by PIC
 
LATBbits.LATB0 = 0; // Pin set high to signal stop sending data to XBee
LATBbits.LATB1 = 0; // Pin set high to indicate stop sending data to PIC
XBEE_CTS_LAT = 0; // Pin set high to signal stop sending data to XBee
XBEE_RTS_LAT = 0; // Pin set high to indicate stop sending data to PIC
 
xbee_data_ptr = xd;
xbee_data_ptr->dataind = 0;
xbee_data_ptr->checksum_sum = 0;
xbee_data_ptr->read_state = XBEE_STATE_READ_START;
xbee_data.dataind = 0;
xbee_data.checksum_sum = 0;
xbee_data.frame_rdy = 0;
xbee_data.escape_flag = 0;
xbee_data.read_state = XBEE_STATE_READ_START;
 
// memset(&xbee_data, 0, 32);
// Grab a pointer to where the unique frame array starts
xbee_data_array_ptr = &(xbee_data_ptr->rcv_frame.FRAME);
xbee_data_frame = &(xbee_data.rcv_frame.FRAME);
xbee_frame = &(xbee_data.rcv_frame);
}
 
/* Here we handle the serial input from the UART interrupt */
void xbee_read_serial(unsigned char c) {
void XBee_Serial_In(unsigned char c) {
// For some reason writing the length straight to xbee_data doesnt seem to work
// so we work around it by pointing to the length bytes directly
XBEE_ADDRESS_16 *length = xbee_frame + 1;
 
#ifdef XBEE_USE_ESCAPE_CHAR
if (c == XBEE_ESCAPE_CHAR) {
// Next byte needs is an escaped char
xbee_data.escape_flag = 1;
return;
}
 
if (xbee_data.escape_flag) {
// XOR byte with 0x20 to get escaped char
c ^= XBEE_ESCAPE_VAL;
xbee_data.escape_flag = 0;
}
#endif
 
// Reset on start bit and start saving data
if (c == XBEE_START_DELIMITER) {
// On detect start delimiter, clear out initial array
xbee_data_ptr->dataind = 0;
xbee_data_ptr->checksum_sum = 0;
xbee_data_ptr->rcv_frame.start_delimiter = XBEE_START_DELIMITER;
xbee_data_ptr->read_state = XBEE_STATE_READ_LENGTH_HIGH;
xbee_data.dataind = 0;
xbee_data.checksum_sum = 0;
xbee_data.frame_rdy = 0;
xbee_data.read_state = XBEE_STATE_READ_LENGTH_HIGH;
*((unsigned char *)xbee_frame) = XBEE_START_DELIMITER;
} else {
switch(xbee_data_ptr->read_state) {
switch (xbee_data.read_state) {
case XBEE_STATE_READ_START:
// Do nothing and wait till start bit is read
break;
case XBEE_STATE_READ_LENGTH_HIGH:
// Read length (MSB)
xbee_data_ptr->rcv_frame.length.INT_16.char_value[1] = c;
xbee_data_ptr->read_state = XBEE_STATE_READ_LENGTH_LOW;
length->INT_16.char_value[1] = c;
xbee_data.read_state = XBEE_STATE_READ_LENGTH_LOW;
break;
case XBEE_STATE_READ_LENGTH_LOW:
// Read length (LSB)
xbee_data_ptr->rcv_frame.length.INT_16.char_value[0] = c;
xbee_data_ptr->read_state = XBEE_STATE_READ_FRAME_DATA;
length->INT_16.char_value[0] = c;
xbee_data.read_state = XBEE_STATE_READ_FRAME_DATA;
break;
case XBEE_STATE_READ_FRAME_DATA:
// Read unique frame data
if (xbee_data_ptr->dataind < xbee_data_ptr->rcv_frame.length.INT_16.int_value) {
*((char*)xbee_data_array_ptr + xbee_data_ptr->dataind) = c;
xbee_data_ptr->checksum_sum += c;
xbee_data_ptr->dataind++;
if (xbee_data.dataind < xbee_data.rcv_frame.length.INT_16.int_value) {
*((char*) xbee_data_frame + xbee_data.dataind) = c;
xbee_data.checksum_sum += c;
xbee_data.dataind++;
}
// If total length is read, the next byte is the expected checksum
if (xbee_data_ptr->dataind == xbee_data_ptr->rcv_frame.length.INT_16.int_value) {
xbee_data_ptr->read_state = XBEE_STATE_READ_CHECKSUM;
if (xbee_data.dataind == xbee_data.rcv_frame.length.INT_16.int_value) {
xbee_data.read_state = XBEE_STATE_READ_CHECKSUM;
}
break;
case XBEE_STATE_READ_CHECKSUM:
// Calculate and compare checksum
if (0xFF - xbee_data_ptr->checksum_sum == c) {
if (0xFF - xbee_data.checksum_sum == c) {
// Frame was recieved successfully
xbee_process_recieved_frame();
xbee_data_ptr->read_state = XBEE_STATE_READ_START;
xbee_data.frame_rdy = 1;
// XBee_Process_Received_Frame();
} else {
// If checksum does not match, drop frame
// If checksum does not match, drop frame
DBG_PRINT_XBEE("XBEE: checksum mismatch\r\n");
xbee_data_ptr->read_state = XBEE_STATE_READ_START;
}
xbee_data.read_state = XBEE_STATE_READ_START;
break;
}
}
}
 
/* This is called when a full frame arrives to process the frame data */
void xbee_process_recieved_frame() {
char ret_status;
// Here we want to process each frame and send the data to Main()
// Send the frame to main() with the message type depending on the frame type
switch(*((unsigned char *) xbee_data_array_ptr)) {
/* This processes the frame data within the interrupt. Dont use this. */
void XBee_Process_Received_Frame() {
// DBG_PRINT_XBEE("Length: %d\r\n", xbee_data.rcv_frame.length.INT_16.int_value);
// Here we process the received frame depending on the frame type
switch (*((unsigned char *) xbee_data_frame)) {
case XBEE_RX_AT_COMMAND_RESPONSE:
DBG_PRINT_XBEE("XBEE: parsing recieved AT command response frame\r\n");
ret_status = MQ_sendmsg_ToMainFromHigh(xbee_data_ptr->rcv_frame.length.INT_16.char_value[0], MSGTYPE_XBEE_RX_AT_COMMAND_RESPONSE, (void *)xbee_data_array_ptr);
if (ret_status < 0) {
DBG_PRINT_XBEE("XBEE: (ERROR) send message to main failed with error %x\r\n", ret_status);
}
break;
case XBEE_RX_DATA_PACKET:
DBG_PRINT_XBEE("XBEE: parsing recieved data recieved frame\r\n");
ret_status = MQ_sendmsg_ToMainFromHigh(xbee_data_ptr->rcv_frame.length.INT_16.char_value[0], MSGTYPE_XBEE_RX_DATA_PACKET, (void *)xbee_data_array_ptr);
if (ret_status < 0) {
DBG_PRINT_XBEE("XBEE: (ERROR) send message to main failed with error %x\r\n", ret_status);
}
DBG_PRINT_XBEE("XBEE: parsing recieved data frame\r\n");
break;
case XBEE_RX_DATA_TX_STATUS:
DBG_PRINT_XBEE("XBEE: parsing recieved TX status frame\r\n");
ret_status = MQ_sendmsg_ToMainFromHigh(xbee_data_ptr->rcv_frame.length.INT_16.char_value[0], MSGTYPE_XBEE_RX_DATA_TX_STATUS, (void *)xbee_data_array_ptr);
if (ret_status < 0) {
DBG_PRINT_XBEE("XBEE: (ERROR) send message to main failed with error %x\r\n", ret_status);
}
break;
case XBEE_RX_IO_DATA_SAMPLE:
DBG_PRINT_XBEE("XBEE: parsing recieved IO data sample frame\r\n");
ret_status = MQ_sendmsg_ToMainFromHigh(xbee_data_ptr->rcv_frame.length.INT_16.char_value[0], MSGTYPE_XBEE_RX_IO_DATA_SAMPLE, (void *)xbee_data_array_ptr);
if (ret_status < 0) {
DBG_PRINT_XBEE("XBEE: (ERROR) send message to main failed with error %x\r\n", ret_status);
}
break;
case XBEE_RX_EXPLICIT_COMMAND:
DBG_PRINT_XBEE("XBEE: parsing recieved explicit command frame\r\n");
ret_status = MQ_sendmsg_ToMainFromHigh(xbee_data_ptr->rcv_frame.length.INT_16.char_value[0], MSGTYPE_XBEE_RX_EXPLICIT_COMMAND, (void *)xbee_data_array_ptr);
if (ret_status < 0) {
DBG_PRINT_XBEE("XBEE: (ERROR) send message to main failed with error %x\r\n", ret_status);
}
break;
case XBEE_RX_REMOTE_AT_COMMAND_RESPONSE:
DBG_PRINT_XBEE("XBEE: parsing recieved remote AT command frame\r\n");
ret_status = MQ_sendmsg_ToMainFromHigh(xbee_data_ptr->rcv_frame.length.INT_16.char_value[0], MSGTYPE_XBEE_RX_REMOTE_AT_COMMAND_RESPONSE, (void *)xbee_data_array_ptr);
if (ret_status < 0) {
DBG_PRINT_XBEE("XBEE: (ERROR) send message to main failed with error %x\r\n", ret_status);
}
break;
case XBEE_RX_ROUTE_RECORD:
DBG_PRINT_XBEE("XBEE: parsing recieved route record frame\r\n");
ret_status = MQ_sendmsg_ToMainFromHigh(xbee_data_ptr->rcv_frame.length.INT_16.char_value[0], MSGTYPE_XBEE_RX_ROUTE_RECORD, (void *)xbee_data_array_ptr);
if (ret_status < 0) {
DBG_PRINT_XBEE("XBEE: (ERROR) send message to main failed with error %x\r\n", ret_status);
}
break;
case XBEE_RX_NODE_IDENTIFICATION:
DBG_PRINT_XBEE("XBEE: parsing recieved node identification frame\r\n");
ret_status = MQ_sendmsg_ToMainFromHigh(xbee_data_ptr->rcv_frame.length.INT_16.char_value[0], MSGTYPE_XBEE_RX_NODE_IDENTIFICATION, (void *)xbee_data_array_ptr);
if (ret_status < 0) {
DBG_PRINT_XBEE("XBEE: (ERROR) send message to main failed with error %x\r\n", ret_status);
}
break;
case XBEE_RX_FRAME_MODEM_STATUS:
DBG_PRINT_XBEE("XBEE: parsing recieved modem status frame\r\n");
ret_status = MQ_sendmsg_ToMainFromHigh(xbee_data_ptr->rcv_frame.length.INT_16.char_value[0], MSGTYPE_XBEE_RX_FRAME_MODEM_STATUS, (void *)xbee_data_array_ptr);
if (ret_status < 0) {
DBG_PRINT_XBEE("XBEE: (ERROR) send message to main failed with error %x\r\n", ret_status);
}
break;
default:
DBG_PRINT_XBEE("XBEE: (ERROR) unrecognized frame type\r\n");
151,58 → 135,74
}
}
 
//void xbee_process_transmit_frame_interrupt(void) {
// unsigned char i;
// char length;
//
// if (MQ_peek_FromMainToHigh() == MSGTYPE_XBEE_TX_FRAME) {
// length = MQ_recvmsg_FromMainToHigh(MSGLEN, (unsigned char *) xbee_data_ptr->msgtype, (void *) xbee_data_array_ptr);
// xbee_data_ptr->checksum_sum = 0;
// Write2USART(XBEE_START_DELIMITER);
// while (Busy2USART());
// Write2USART(0x00);
// while (Busy2USART());
// Write2USART(length);
// while (Busy2USART());
// for (i = 0; i < length; i++) {
// Write2USART(*((unsigned char *) xbee_data_array_ptr + i));
// xbee_data_ptr->checksum_sum += *((unsigned char *) xbee_data_array_ptr + i);
// while (Busy2USART());
// }
// Write2USART(0xFF - xbee_data_ptr->checksum_sum);
// while (Busy2USART());
// }
//}
unsigned int XBee_Get_Received_Frame(unsigned char *frame) {
if (!xbee_data.frame_rdy) {
return 0;
} else {
memcpy(frame, xbee_data_frame, xbee_data.rcv_frame.length.INT_16.int_value);
xbee_data.frame_rdy = 0; // Reset frame ready status
return xbee_data.rcv_frame.length.INT_16.int_value;
}
}
 
void xbee_process_transmit_frame(void *data, unsigned char length) {
unsigned char i;
unsigned char checksum = 0;
void XBee_Process_Transmit_Frame(unsigned char *data, unsigned char length) {
#ifdef XBEE_USE_ESCAPE_CHAR
unsigned int i = 0;
unsigned char chksum = 0;
 
Write2USART(XBEE_START_DELIMITER);
while (Busy2USART() || xbee_read_CTS());
Write2USART(0x00);
while (Busy2USART() || xbee_read_CTS());
Write2USART(length);
while (Busy2USART() || xbee_read_CTS());
// Write the start bit and length
UART1_WriteC(XBEE_START_DELIMITER);
UART1_WriteC(0);
UART1_WriteC(length);
 
// Write the frame data
for (i = 0; i < length; i++) {
Write2USART(*((unsigned char *) data + i));
checksum += *((unsigned char *) data + i);
while (Busy2USART() || xbee_read_CTS());
chksum += data[i];
if (data[i] == XBEE_START_DELIMITER || \
data[i] == XBEE_ESCAPE_CHAR || \
data[i] == XBEE_XON || \
data[i] == XBEE_XOFF) {
UART1_WriteC(XBEE_ESCAPE_CHAR);
UART1_WriteC(data[i] ^ XBEE_ESCAPE_VAL);
} else {
UART1_WriteC(data[i]);
}
}
Write2USART(0xFF - checksum);
while (Busy2USART());
// Write the checksum
if (chksum == XBEE_START_DELIMITER || \
chksum == XBEE_ESCAPE_CHAR || \
chksum == XBEE_XON || \
chksum == XBEE_XOFF) {
UART1_WriteC(XBEE_ESCAPE_CHAR);
UART1_WriteC(chksum ^ XBEE_ESCAPE_VAL);
} else {
UART1_WriteC(0xFF - chksum);
}
#else
unsigned int i = 0;
unsigned char chksum = 0;
 
UART1_WriteC(XBEE_START_DELIMITER);
UART1_WriteC(0);
UART1_WriteC(length);
for (i = 0; i < length; i++) {
chksum += data[i];
UART1_WriteC(data[i]);
}
UART1_WriteC(0xFF - chksum);
#endif
}
 
void xbee_set_RTS(unsigned char c) {
void XBee_Set_RTS(unsigned char c) {
if (c) {
LATBbits.LATB1 = 1; // Set high to stop receiving data
XBEE_RTS_LAT = 1; // Set high to stop receiving data
} else {
LATBbits.LATB1 = 0; // Set low to resume receiving data
XBEE_RTS_LAT = 0; // Set low to resume receiving data
}
}
 
unsigned char xbee_read_CTS() {
unsigned char c = PORTBbits.RB0;
unsigned char XBee_Read_CTS() {
unsigned char c = XBEE_CTS_PORT;
if (c) {
return 0x1; // High indicates stop sending data
} else {
209,3 → 209,27
return 0x0; // Low indicates ok to send data
}
}
 
void XBee_ConvertEndian64(XBEE_ADDRESS_64 *src) {
char tmp[2];
tmp[0] = src->UPPER_32.char_value[3];
tmp[1] = src->UPPER_32.char_value[2];
src->UPPER_32.char_value[3] = src->UPPER_32.char_value[0];
src->UPPER_32.char_value[2] = src->UPPER_32.char_value[1];
src->UPPER_32.char_value[1] = tmp[1];
src->UPPER_32.char_value[0] = tmp[0];
 
tmp[0] = src->LOWER_32.char_value[3];
tmp[1] = src->LOWER_32.char_value[2];
src->LOWER_32.char_value[3] = src->LOWER_32.char_value[0];
src->LOWER_32.char_value[2] = src->LOWER_32.char_value[1];
src->LOWER_32.char_value[1] = tmp[1];
src->LOWER_32.char_value[0] = tmp[0];
}
 
void XBee_ConvertEndian16(XBEE_ADDRESS_16 *src) {
char tmp;
tmp = src->INT_16.char_value[0];
src->INT_16.char_value[0] = src->INT_16.char_value[1];
src->INT_16.char_value[1] = tmp;
}
/PIC Stuff/PIC_27J13/xbee.h
1,15 → 1,29
#ifndef __xbee_h
#define __xbee_h
 
#define XBEE_BUFFER_SIZE MSGLEN
#define XBEE_START_DELIMITER 0x7E
#define XBEE_BUFFER_SIZE 256
 
#define XBEE_CTS_TRIS TRISBbits.TRISB0
#define XBEE_RTS_TRIS TRISBbits.TRISB1
#define XBEE_CTS_LAT LATBbits.LATB0
#define XBEE_RTS_LAT LATBbits.LATB1
#define XBEE_CTS_PORT PORTBbits.RB0
 
// If API mode = 2 is enabled
#define XBEE_USE_ESCAPE_CHAR
 
#define XBEE_ESCAPE_VAL 0x20
#define XBEE_START_DELIMITER 0x7E
#define XBEE_ESCAPE_CHAR 0x7D
#define XBEE_XON 0x11
#define XBEE_XOFF 0x13
 
// Expected 'next' state
#define XBEE_STATE_READ_START 10
#define XBEE_STATE_READ_LENGTH_HIGH 11
#define XBEE_STATE_READ_LENGTH_LOW 12
#define XBEE_STATE_READ_FRAME_DATA 14
#define XBEE_STATE_READ_CHECKSUM 15
#define XBEE_STATE_READ_FRAME_DATA 13
#define XBEE_STATE_READ_CHECKSUM 14
 
// Command Frame Type
#define XBEE_TX_AT_COMMAND 0x08
237,20 → 251,25
// Overall Data Structure
typedef struct __xbee_data {
XBEE_FRAME rcv_frame;
unsigned char dataind;
unsigned int dataind;
unsigned char checksum_sum;
unsigned char read_state;
unsigned char msgtype;
unsigned char frame_rdy;
unsigned char escape_flag;
} XBEE_DATA;
 
 
void xbee_init(XBEE_DATA *);
void xbee_read_serial(unsigned char);
void xbee_process_recieved_frame(void);
//void xbee_process_transmit_frame_interrupt(void);
void xbee_process_transmit_frame(void *data, unsigned char length);
void XBee_Init(void);
void XBee_Serial_In(unsigned char);
void XBee_Process_Received_Frame(void);
void XBee_Process_Transmit_Frame(unsigned char *data, unsigned char length);
 
void xbee_set_RTS(unsigned char);
unsigned char xbee_read_CTS(void);
unsigned int XBee_Get_Received_Frame(unsigned char *frame);
 
void XBee_Set_RTS(unsigned char);
unsigned char XBee_Read_CTS(void);
 
void XBee_ConvertEndian64(XBEE_ADDRESS_64 *src);
void XBee_ConvertEndian16(XBEE_ADDRESS_16 *src);
 
#endif