Esempio n. 1
0
void radioInitSetup() {
    /*
     * Initialize the SPI connection, configure the I/O pins,
     * and set the register defaults
     */
    Radio_Init();

    /*
     * Configure pipe 0 as a receiver.  Pipe 0 has to be enabled
     * for the radio's link layer protocol to work.  This line
     * shouldn't be necessary since pipe 0 is enabled by default,
     * but it's nice to be explicit.
     */
    Radio_Configure_Rx(RADIO_PIPE_0, RemoteStationAddr, ENABLE);

    /*
     * Configure the radio's data rate (must match the other radio)
     * and the broadcast power
     */
    Radio_Configure(RADIO_2MBPS, RADIO_HIGHEST_POWER);

    /*
     * set the address to send to, dangling prepositions be damned.
     */
    Radio_Set_Tx_Addr(BaseStationAddr);

}
Esempio n. 2
0
int main()
{
	init();
	pinMode(14, OUTPUT);
	pinMode(15, OUTPUT);
	digitalWrite(15, LOW);

	pinMode(radioPowerPin, OUTPUT);		// power cycle radio
	digitalWrite(radioPowerPin, LOW);
	delay(100);
	digitalWrite(radioPowerPin, HIGH);
	delay(100);

	pinMode(sonarPowerPin, OUTPUT);
	pinMode(sonarGroundPin, OUTPUT);
	digitalWrite(sonarGroundPin, LOW);
	digitalWrite(sonarPowerPin, HIGH);
	Sonar_Init();

	Radio_Init();
	Radio_Configure(RADIO_2MBPS, RADIO_HIGHEST_POWER);
	Radio_Configure_Rx(RADIO_PIPE_0, sensor_address, ENABLE);



	for (;;)
	{
		if (radio_flag)
		{
			radio_flag = 0;
			Radio_Receive(&packet);				// assumption: radio FIFO contains just one packet
			if (packet.type == REQUEST_ECHO)
			{
				Sonar_PreTrigger();
				Radio_Set_Tx_Addr(packet.payload.request.return_address);
				packet.type = CONFIRM_ECHO;
				packet.payload.confirm.station_id = STATION_ID;
				Radio_Transmit(&packet, RADIO_WAIT_FOR_TX);
				// sonar is triggered as soon as the explorer acknowledges it received the confirmation
				Sonar_Trigger();
				delay(50);
				digitalWrite(14, LOW);
			}
			packet.type = EMPTY;
		}
	}

	for (;;);
	return 0;
}
Esempio n. 3
0
void Net_SetNodeAddress(net_address addr) {
    //TODO: write to EEPROM
    Radio_Configure_Rx(0, addr, 1, 1);
    memcpy(_node_address, addr, sizeof(_node_address));
}
Esempio n. 4
0
void Net_Init(net_handlers* handlers) {
    Radio_Init();
    Radio_Configure(110, RADIO_250KBPS, RADIO_HIGH_POWER);
    Radio_Configure_Rx(1, NET_BROADCAST, 1, 0);
    _handlers = handlers;
}