1,7 → 1,7 |
#include "maindefs.h" |
#include "interrupts.h" |
#include "uart.h" |
//#include "i2c.h" |
#include "i2c.h" |
//#include "adc.h" |
//#include "timers.h" |
//#include "xbee.h" |
57,6 → 57,8 |
void main(void) { |
unsigned char i = 0; |
unsigned char length = 0; |
unsigned char result = 0; |
unsigned char test[8] = "ASDF123"; |
unsigned char buffer[100]; |
|
/* --------------------- Oscillator Configuration --------------------- */ |
70,8 → 72,8 |
ANCON1 = 0x1F; |
|
UART1_Init(); // Initialize the UART handler code |
I2C_Init(); // Initialize the I2C handler code |
// xbee_init(&xbee_data); // Initialize the XBee handler code |
// i2c_init(&i2c_data); // Initialize the I2C handler code |
// adc_init(); // Initialize the ADC |
// timers_init(); // Initialize timers |
// port_b_int_init(); // Initialze Port B interrupt handler |
84,11 → 86,67 |
|
// Loop and process recieved messages from interrupts; |
|
// I2C_Configure_Master(); |
I2C_Configure_Slave(0x30); |
|
TRISCbits.TRISC0 = 0; |
TRISCbits.TRISC1 = 0; |
TRISCbits.TRISC2 = 0; |
LATCbits.LATC0 = 0; |
LATCbits.LATC1 = 0; |
LATCbits.LATC2 = 0; |
|
while (1) { |
length = UART1_Read((char *)buffer); |
if (length != 0) { |
UART1_WriteB((char *)buffer, length) ; |
// |
// Delay10KTCYx(255); |
// Delay10KTCYx(255); |
|
/* UART Test */ |
// length = UART1_Read((char *)buffer); |
// if (length != 0) { |
// UART1_WriteB((char *)buffer, length) ; |
// } |
/* UART Test*/ |
|
/* I2C Master Test */ |
// buffer[0] = 0xBB; |
// I2C_Master_Send(0x30, 1, buffer); |
// |
// result = I2C_Get_Status(); |
// while (!result) { |
// result = I2C_Get_Status(); |
// } |
// DBG_PRINT_MAIN("%x ", result); |
// |
// I2C_Master_Recv(0x30, 2); |
// |
// result = I2C_Get_Status(); |
// while (!result) { |
// result = I2C_Get_Status(); |
// } |
// DBG_PRINT_MAIN("%x ", result); |
// |
// I2C_Master_Restart(0x30, 0xBB, 2); |
// |
// result = I2C_Get_Status(); |
// while (!result) { |
// result = I2C_Get_Status(); |
// } |
// DBG_PRINT_MAIN("%x\r\n", result); |
/* I2C Master Test */ |
|
/* I2C Slave Receive Test */ |
result = I2C_Get_Status(); |
while (!result) { |
result = I2C_Get_Status(); |
} |
Delay10KTCYx(255); |
DBG_PRINT_MAIN("%X ", result); |
length = I2C_Read_Buffer(buffer); |
DBG_PRINT_MAIN("%d ", length); |
for (i = 0; i < length; i++) { |
DBG_PRINT_MAIN("%X ", buffer[i]); |
} |
DBG_PRINT_MAIN("\r\n"); |
/* I2C Slave Receive Test */ |
} |
} |