//debug code int main(void){ unsigned char i; unsigned char * data; // char string[20]; // global to assist in debugging // unsigned long n; // // Set the clocking to run at 50MHz from the PLL. // SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); SysTick_Init(); Output_Init(); Output_Color(15); UART_Init(); // initialize UART Xbee_Init(12); SYSCTL_RCGC2_R |= SYSCTL_RCGC2_GPIOG; i = 0; i += 1; GPIO_PORTG_DEN_R |= 0x04; GPIO_PORTG_DIR_R |= 0x04; GPIO_PORTG_DATA_R &= ~0x04; // OutCRLF(); // for(i='A'; i<='Z'; i=i+1){// print the uppercase alphabet // UART_OutChar(i); // } // OutCRLF(); // UART_OutChar(' '); // for(i='a'; i<='z'; i=i+1){// print the lowercase alphabet // UART_OutChar(i); // } // OutCRLF(); // UART_OutChar('-'); // UART_OutChar('-'); // UART_OutChar('>'); // EnableInterrupts(); while(1){ // UART_OutString("InString: "); // UART_InString(string,19); // UART_OutString(" OutString="); UART_OutString(string); OutCRLF(); // UART_OutString("InUDec: "); n=UART_InUDec(); // UART_OutString(" OutUDec="); UART_OutUDec(n); OutCRLF(); // UART_OutString("InUHex: "); n=UART_InUHex(); // UART_OutString(" OutUHex="); UART_OutUHex(n); OutCRLF(); // WaitForInterrupt(); GPIO_PORTG_DATA_R ^= 0x04; data = receiveData(); if (data!=0) printf("%c", data[0] + 0x20); //XBee_RecieveRxFrame(); // XBee_TxStatus(); // XBee_Display(); } }
int main( void ) { int fd; /* File descriptor for the port */ fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY); if (fd == -1) { /* * Could not open the port. */ perror("open_port: Unable to open /dev/ttyUSB0 - "); } system("stty -F /dev/ttyUSB0 9600"); int ldisc = 17; ioctl(fd, TIOCSETD, &ldisc); fcntl(fd, F_SETFL, FNDELAY); struct termios options; tcgetattr(fd, &options); cfsetispeed(&options, B9600); cfsetospeed(&options, B9600); options.c_cflag |= (CLOCAL | CREAD | CS8); options.c_cflag &= ~(CSIZE | CSTOPB | PARENB); options.c_cflag |= CRTSCTS; tcsetattr(fd, TCSANOW, &options); Xbee_Init(fd); unsigned char msg[5] = { 0x48, 0x65, 0x6c, 0x6c, 0x6f }; ssize_t retVal; unsigned short to = 0x0001; int i = 0; while (1) { Xbee_SendTransmitMessage(to, msg, 5); usleep(100000); printf("Sent: %d\n", i++); } return 0 ; }