void CheckButtons(void)
{
	uint8_t statmp;
	uint8_t checkack;
	if (!ioport_get_value(GPIO_PUSH_BUTTON_4))
	{
		delay_ms(20);
		if (!ioport_get_value(GPIO_PUSH_BUTTON_4))
		{
			ioport_set_pin_low(LED4_GPIO);
			TX_BUF[0] = DATA;
			nrf24l01_TX_config_master(TX_BUF);
			Check_ACK_master(1); 

			delay_ms(100);
			ioport_set_pin_high(LED4_GPIO);
			//nrf24l01_RX_config();
			
			while(!ioport_get_value(GPIO_PUSH_BUTTON_4));	//wait the button the release
			DATA <<= 1;
			if(!DATA)
			   DATA = 0x01;
			   
		}
	}
}
Exemple #2
0
/**
 * \brief Check for presence of required jumpers
 *
 * This function checks that the two jumpers on header J1 and J2 are present.
 * The jumpers should connect:
 * - PC2 to PC4 (RXD to SS on header J1)
 * - PB2 to PA4 (ADC2 to ADC4 on header J2)
 *
 * \return \c true if both jumpers are present, \c false otherwise
 */
static bool main_check_jumpers(void)
{
    /* Check jumper presence by driving one pin high, and setting the other
     * as input with pull-down
     */
    ioport_configure_pin(J1_PIN2, IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
    ioport_configure_pin(J1_PIN4, IOPORT_DIR_INPUT | IOPORT_PULL_DOWN);

    ioport_configure_pin(J2_PIN2, IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
    ioport_configure_pin(J2_PIN4, IOPORT_DIR_INPUT | IOPORT_PULL_DOWN);

    if (!ioport_get_value(J1_PIN4) || !ioport_get_value(J2_PIN4)) {
        return false;
    } else {
        return true;
    }
}