Exemple #1
0
// TODO: Implement!
int platformInit(void)
{
	//Low level init: Clock and Interrupt controller
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);

	// Disable the jtag gpio
	GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable, ENABLE);

	// adcInit();

	timInit();

	nrf24l01Init();

	nrf24l01SetAddress();
	// nrf24l01ConnectCheck();

	// mpu9150Init();
	// mpu9150Status();

	return 0;
}
Exemple #2
0
// TODO: Implement!
int platformInit ( void )
{
	uint8_t i = 0;
	int checksum = 0;

	//Low level init: Clock and Interrupt controller
	NVIC_PriorityGroupConfig ( NVIC_PriorityGroup_4 );

	// Disable the jtag gpio
	GPIO_PinRemapConfig ( GPIO_Remap_SWJ_JTAGDisable, ENABLE );

	ledInit();

	ledSet ( 0, 0 );
	ledSet ( 1, 0 );
	ledSet ( 2, 0 );

	delay_ms ( 500 );
	ledSet ( 0, 1 );
	delay_ms ( 500 );
	ledSet ( 1, 1 );
	delay_ms ( 500 );
	ledSet ( 2, 1 );

	delay_ms ( 500 );

	uartInit();

	DEBUG_PRINT ( "Too young too simple, sometimes naive.\n" );
	DEBUG_PRINT ( "I'm a journalist from Hongkong.\n" );
	DEBUG_PRINT ( "I could run very fast.\n" );
	DEBUG_PRINT ( "------------------------------\n" );

	DEBUG_PRINT ( "uart init successfully.\n" );

	ledSet ( 0, 0 );

	// adcInit();

	DEBUG_PRINT ( "test motor.\n" );

	timInit();

	DEBUG_PRINT ( "waking up driver.\n" );

	wakeupDriver();

	timSetPulse ( TIM2, 3, 0 );
	timSetPulse ( TIM3, 3, 0 );
	timSetPulse ( TIM4, 3, 0 );
	timSetPulse ( TIM2, 4, 0 );
	timSetPulse ( TIM3, 4, 0 );
	timSetPulse ( TIM4, 4, 0 );

	delay_ms ( 500 );

	timSetPulse ( TIM2, 4, 500 );
	timSetPulse ( TIM3, 4, 500 );
	timSetPulse ( TIM4, 4, 500 );

	delay_ms ( 500 );

	timSetPulse ( TIM2, 3, 0 );
	timSetPulse ( TIM3, 3, 0 );
	timSetPulse ( TIM4, 3, 0 );
	timSetPulse ( TIM2, 4, 0 );
	timSetPulse ( TIM3, 4, 0 );
	timSetPulse ( TIM4, 4, 0 );

	delay_ms ( 500 );

	timSetPulse ( TIM2, 3, 500 );
	timSetPulse ( TIM3, 3, 500 );
	timSetPulse ( TIM4, 3, 500 );

	delay_ms ( 500 );

	timSetPulse ( TIM2, 3, 0 );
	timSetPulse ( TIM3, 3, 0 );
	timSetPulse ( TIM4, 3, 0 );
	timSetPulse ( TIM2, 4, 0 );
	timSetPulse ( TIM3, 4, 0 );
	timSetPulse ( TIM4, 4, 0 );

	ledSet ( 1, 0 );

	delay_ms ( 200 );

	nrf24l01Init();

	i = nrf24l01ConnectCheck();

	nrf24l01SetAddress();
	// i = nrf24l01ConnectCheck();

	if ( i == 1 )
	{
		checksum --;
		ledSet ( 2, 0 );
	}

	delay_ms ( 1000 );

	// mpu9150Init();
	// i = mpu9150Status();

	// if(!i)
	// {
	//  checksum --;
	//  ledSet(1, 0);
	// }

	if ( checksum > 0 )
	{
		delay_ms ( 1000 );

		timSetPulse ( TIM2, 3, 0 );
		timSetPulse ( TIM3, 3, 0 );
		timSetPulse ( TIM4, 3, 0 );
		timSetPulse ( TIM2, 4, 0 );
		timSetPulse ( TIM3, 4, 0 );
		timSetPulse ( TIM4, 4, 0 );
		// timSetPulse(TIM2, 4, 999);
		// timSetPulse(TIM3, 4, 999);
		// timSetPulse(TIM4, 4, 999);

		while ( 1 )
		{

			ledSet ( 0, 1 );
			ledSet ( 1, 1 );
			ledSet ( 2, 1 );
			delay_ms ( 100 );
			ledSet ( 0, 0 );
			ledSet ( 1, 0 );
			ledSet ( 2, 0 );
			delay_ms ( 100 );
		}
	}

	ledSet ( 0, 0 );
	ledSet ( 1, 0 );
	ledSet ( 2, 0 );

	delay_ms ( 500 );

	ledSet ( 0, 1 );
	ledSet ( 1, 1 );
	ledSet ( 2, 1 );

	delay_ms ( 500 );

	ledSet ( 0, 0 );
	ledSet ( 1, 0 );
	ledSet ( 2, 0 );

	return 0;
}