Ejemplo n.º 1
0
int main()
{
	int TxData, RxData;
	int i;

	// Open device
	if( zgb_initialize(DEFAULT_DEVICEINDEX) == 0 )
	{
		printf( "Failed to open Zig2Serial!\n" );
		printf( "Press any key to terminate...\n" );
		getchar();
		return 0;
	}
	else
		printf( "Succeed to open Zig2Serial!\n" );

	while(1)
	{
		printf( "Press any key to continue!(press ESC to quit)\n" );
		if(getchar() == 0x1b)
			break;

		// Wait user's input
		printf( "Input number to transmit: " );
		if(scanf("%d", &TxData));

		// Transmit data
		if(zgb_tx_data(TxData) == 0)
			printf( "Failed to transmit\n" );

		for( i=0; i<TIMEOUT_TIME; i++)
		{
			// Verify data recieved
			if(zgb_rx_check() == 1)
			{
				// Get data verified
				RxData = zgb_rx_data();
				printf( "Recieved: %d\n", RxData );
				break;
			}

			sleep(1);
		}

		if(i == TIMEOUT_TIME)
			printf( "Timeout: Failed to recieve\n" );
	}

	// Close device
	zgb_terminate();
	printf( "Press any key to terminate...\n" );
	getchar();
	return 0;
}
Ejemplo n.º 2
0
int main(void)
{
	int RcvData;

	DDRC  = 0x7F;
	PORTC = 0x7E;

	PORTD &= ~0x80;	//PORT_LINK_PLUGIN = 0;   // no pull up
	PORTD &= ~0x20;	//PORT_ENABLE_RXD_LINK_PC = 0;
	PORTD |= 0x40;	//PORT_ENABLE_RXD_LINK_ZIGBEE = 1;

	zgb_initialize( 0 ); // Not using device index
	sei();	// Interrupt Enable	
	
	while(1)
	{
		if(zgb_rx_check() == 1)
		{
			RcvData = zgb_rx_data();
			if(RcvData & RC100_BTN_1)
				PORTC &= ~LED_MANAGE;
			else
				PORTC |= LED_MANAGE;
			
			if(RcvData & RC100_BTN_2)
				PORTC &= ~LED_PROGRAM;
			else
				PORTC |= LED_PROGRAM;
				
			if(RcvData & RC100_BTN_3)
				PORTC &= ~LED_PLAY;
			else
				PORTC |= LED_PLAY;
		}
	}

	return 0;
}
Ejemplo n.º 3
0
void System_Configuration(void)
{

	__disable_interrupt();
	/* System Clocks Configuration */
	RCC_Configuration();
	   
	/* NVIC configuration */
	NVIC_Configuration();


	/* Configure the GPIO ports */
	GPIO_Configuration();



	/* Unlock the Flash Program Erase controller */
	FLASH_Unlock();

	/* USART Configuration */
	USART_Configuration(USART_DXL,Baudrate_DXL);
	//dxl_initialize(USART_DXL,Baudrate_DXL);
	zgb_initialize(0);
	//USART_Configuration(USART_ZIGBEE,Baudrate_ZIGBEE);

	//USART_Configuration(USART_PC,1000000);
	//USART_Configuration(USART_PC,3000000);
	USART_Configuration(USART_PC,Baudrate_PC);


	/* ADC Configuration */
	ADC_Configuration();
	
	

	SysTick_Configuration();
	
	Timer_Configuration();


	SPI_Configuration();

	Buzzer_Configuration();


	GPIO_ResetBits(PORT_ENABLE_TXD, PIN_ENABLE_TXD);	// TX Disable
	GPIO_SetBits(PORT_ENABLE_RXD, PIN_ENABLE_RXD);	// RX Enable
	GPIO_SetBits(PORT_SIG_ACC_CS,PIN_SIG_ACC_CS);
	GPIO_SetBits(PORT_SIG_GYRO_CS,PIN_SIG_GYRO_CS);

	__enable_interrupt();



	Gyro_Configuration();
	ACC_Configuration();






}