Example #1
0
int main(void) {
    // LCD Screen
    lcd_init();
    terminal_init();

    // Input
    input_init();

    // Set power LED
    DDRB |= (1 << PINB6);
    clear_bit(PORTB, PINB6);

    // Radio
    uint8_t local_addr[] = { 0x1B, 0x1B, 0x1B, 0x1B, 0x1B };
    uint8_t robot_addr[] = { 0x0A, 0x0A, 0x0A, 0x0A, 0x0A };
    spi_init();
    nrf24_init();
    nrf24_config(47, sizeof(RemoteCommand)); // Channel 7
    nrf24_set_rx_addr(local_addr);
    nrf24_set_tx_addr(robot_addr);

    // Ready to go!
    sei();

    RemoteMode mode = MODE_MANUAL;

    while (1)
    {
        input_update(&input_state);

        switch (mode) {
        case MODE_MANUAL:
            UpdateManualMode(&input_state);
            break;
        case MODE_AUTO:
            asm("nop"::);
            break;
        case MODE_MENU:
            asm("nop"::);
            break;
        }
    }
}
Example #2
0
void setup(void) {
	uint8_t s = SREG;
	uint8_t m = MCUCR;
	uint8_t i, addrs[6];

	wdt_disable();
	serial_init();
	timer_init();
	spi_init();
	nrf24_init();
	sei();

	/*
	 * Set our radio address and the remote end's radio address, read
	 * the addresses from EEPROM where they need to be saved first.
	 */
	for (i = 0; i < 6; i ++)
		addrs[i] = eeprom_read(i);

	nrf24_set_rx_addr(addrs + 0);
	nrf24_set_tx_addr(addrs + 3);

	/* Write something to say hello */
	serial_write_str("SREG:");
	serial_write_hex16(s);
	serial_write_str(", MCUCR:");
	serial_write_hex16(m);
	serial_write_str(", our addr: ");
	serial_write1(addrs[0]);
	serial_write1(addrs[1]);
	serial_write1(addrs[2]);
	serial_write_eol();

	nrf24_rx_mode();

	serial_set_handler(handle_input);
}
Example #3
0
static void update_rx_addr(uint8_t addr) {
	uint8_t addr3[3] = { addr + 21, addr + 22, addr + 23 };

	nrf24_set_rx_addr(addr3);
}