Пример #1
1
void spi2serial_main(void) {
    uint8_t status;
    /* TODO load listening address from flash. */
    uint8_t thisAddr[5]= {97, 83, 22, 222, 121};

    init_stdio_USART2();
    init_delay();

    SPI2_Init();

    delay_ms(10);

    nrf24l01Init();

    delay_ms(100);
    status = nRF24_Check();

    if (status == 1) {
        for (;;);
    }
    nrfSetRxMode(92, 5, thisAddr);
    init_node_link();

    for (;;) {
        status = SPI2Serial_Loop();
        if (status) {
            nrfSetRxMode(92, 5, thisAddr);
        }
    }
}
Пример #2
0
void node_main(void) {
    uint8_t status;
    /* TODO load listening address from flash. */
    uint8_t thisAddr[5]= {97, 89, 64, 222, 121};

    init_stdio_USART2();
    init_delay();

    SPI2_Init();

    delay_ms(10);

    nrf24l01Init();

    delay_ms(100);
    status = nRF24_Check();

    if (status == 1) {
        for (;;);
    }
    printf("nRF check OK!\n");

    nrfSetRxMode(92, 5, thisAddr);
    init_node_link();
    printf("init_node_link OK!\n");
    nRF_Task_Init();
    /* From now on, controls and sensors can be initialized. */
    init_switches();
    printf("init_switches OK!\n");

    for (;;) {
        nRF_Task_Loop();
        delay_ms(1);
    }
}
Пример #3
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;
}
Пример #4
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;
}