コード例 #1
0
ファイル: p2p.c プロジェクト: scubasonar/hardware-pinoccio
char p2p_init()
{
    char cfg_location = '?';

    /* === read node configuration data ===================================== */
    /* 1st trial: read from EEPROM */
    if (get_node_config_eeprom(&NodeConfig, 0) == 0)
    {
        /* using EEPROM config */;
        cfg_location = 'E';
    }
    /* 2nd trial: read from FLASHEND */
    else if (get_node_config(&NodeConfig) == 0)
    {
        /* using FLASHEND config */;
        cfg_location = 'F';
    }
    /* 3rd trial: read default values compiled into the application */
    else
    {
        /* using application default config */;
        memcpy_P(&NodeConfig, (PGM_VOID_P) & nc_flash, sizeof(node_config_t));
        cfg_location = 'D';
    }

    radio_init(rxbuf, sizeof(rxbuf)/sizeof(rxbuf[0]));
    radio_set_state(STATE_OFF);

    radio_set_param(RP_IDLESTATE(STATE_OFF));
    radio_set_param(RP_CHANNEL(NodeConfig.channel));
    radio_set_param(RP_SHORTADDR(NodeConfig.short_addr));
    radio_set_param(RP_PANID(NodeConfig.pan_id));

    return cfg_location;
}
コード例 #2
0
void app_init(void)
{
    LED_INIT();
    KEY_INIT();
    hif_init(HIF_DEFAULT_BAUDRATE);
    timer_init();
    radio_init(RxFrame, sizeof(RxFrame));
    radio_set_state(STATE_OFF);
    radio_set_param(RP_CHANNEL(CHANNEL));
    radio_set_param(RP_IDLESTATE(STATE_RXAUTO));
    radio_set_param(RP_SHORTADDR(RT_ADDR));
    radio_set_param(RP_PANID(RT_PANID));
#if RADIO_TYPE == RADIO_AT86RF212
    radio_set_param(RP_DATARATE(OQPSK100));
#endif
}
コード例 #3
0
ファイル: MxRadio.cpp プロジェクト: examyes/SMeshStudio
void cMxRadio::begin(channel_t chan,uint16_t panid,uint16_t localaddress,bool needackval,bool autotxval,bool autorxval,char autoretrycount)
{
	setautotx=autotxval;
	setautorx=autorxval;
	needack=needackval;
	radio_init(rxFrameBuffer, MAX_FRAME_SIZE);

	//////////////////////////////
#ifdef SR_MAX_FRAME_RETRES
	trx_bit_write(SR_MAX_FRAME_RETRES,autoretrycount & 0Xf);//for auto wake up
	//////////////////////////////
#endif


	if(!needack)
		txTmpBuffer[0] = 0x41;
	else
		txTmpBuffer[0] = 0x61; //ack required
	txTmpBuffer[1] = 0x88;
	txTmpBuffer[2] =  0;
	txTmpBuffer[3]=(uint8_t)(panid & 0xFF );
	txTmpBuffer[4]=(uint8_t)((panid>>8) & 0xFF );
	txTmpBuffer[5] = 0xFF; //dest address low byte
	txTmpBuffer[6] = 0xFF; //dest address hight byte
	txTmpBuffer[7] = (uint8_t)(localaddress & 0xFF );
	txTmpBuffer[8] = (uint8_t)((localaddress>>8) & 0xFF );
	setParam(phyPanId,(uint16_t)panid );
	setParam(phyShortAddr,(uint16_t)localaddress );

	radio_set_param(RP_CHANNEL(chan));

	// default to receiver
	if (setautorx)
		radio_set_state(STATE_RXAUTO);
	else
		radio_set_state(STATE_RX);
#ifdef ENABLE_DIG3_DIG4
	trx_bit_write(SR_PA_EXT_EN, 1);
#endif
}
コード例 #4
0
ファイル: MxRadio.cpp プロジェクト: examyes/SMeshStudio
/**
 * @brief Radio Initialization
 *
 * Overload for radio initalization that allows for the user to set a custom frame header
 *
 * @param chan channel number for the radio to use, 11 to 26
 * @param frameHeader HeadSize byte custom frame header
 */
void cMxRadio::begin(channel_t chan, uint8_t* frameHeader)
{
	radio_init(rxFrameBuffer, MAX_FRAME_SIZE);

	if (frameHeader)
	{
		// copy custom frame header
		int i;
		for (i = 0; i < HeadSize; i++)
			txTmpBuffer[i] = frameHeader[i];
	}
	else
	{
		txTmpBuffer[0] = 0x41;
		txTmpBuffer[1] = 0x88;
		txTmpBuffer[2] =  0;
		txTmpBuffer[3]=0xCD;
		txTmpBuffer[4]=0xAB;
		txTmpBuffer[5] = 0xFF; //dest address low byte
		txTmpBuffer[6] = 0xFF; //dest address hight byte
		txTmpBuffer[7] = 0x01;;
		txTmpBuffer[8] = 0x00;;
	}

	// set the channel
	radio_set_param(RP_CHANNEL(chan));

	// default to receiver
	if (setautorx)
		radio_set_state(STATE_RXAUTO);
	else
		radio_set_state(STATE_RX);

#ifdef ENABLE_DIG3_DIG4
	trx_bit_write(SR_PA_EXT_EN, 1);
#endif

}
コード例 #5
0
/**
 * @brief Radio Initialization
 *
 * The function initializes all IO ressources,
 * needed for the usage of the radio and performs
 * a reset to the radio.
 * It prepares the frame header.
 * Then it sets the channel number and defaults to RX state.
 *
 * @param chan channel number for the radio to use, 11 to 26
 * @param frameHeader 7 byte custom frame header, or null if you want to use a default frame header
 */
void zr_init(channel_t chan, uint8_t* frameHeader)
{
	user_radio_error = 0;
	user_radio_irq = 0;
	zr_attach_receive_frame(zr_onReceiveFrame);
	zr_attach_tx_done(zr_onTxDone);
	
	radio_init(zr_rxFrameBuffer, MAX_FRAME_SIZE);
	
	if (frameHeader)
	{
		// copy custom frame header
		int i;
		for (i = 0; i < 7; i++)
			zr_txTmpBuffer[i] = frameHeader[i];
	}
	else
	{
		// fixed frame header
		zr_txTmpBuffer[0] = 0x01; zr_txTmpBuffer[1] = 0x80; zr_txTmpBuffer[2] =  0; zr_txTmpBuffer[3] = 0x11; zr_txTmpBuffer[4] = 0x22; zr_txTmpBuffer[5] = 0x33; zr_txTmpBuffer[6] = 0x44;
	}
	
	// set the channel
	radio_set_param(RP_CHANNEL(chan));
	
	// default to receiver
	radio_set_state(STATE_RX);
	
	#ifdef ENABLE_DIG3_DIG4
	trx_bit_write(SR_PA_EXT_EN, 1);
	#endif
	
	ZR_RFRX_LED_OUTPUT();
	ZR_RFTX_LED_OUTPUT();
	ZR_RFRX_LED_OFF();
	ZR_RFTX_LED_OFF();
}
コード例 #6
0
/**
 * @brief Sets Radio Channel
 *
 * changes the radio channel by setting the radio channel state
 *
 * @param chan channel number, 11 to 26
 */
void zr_setChannel(channel_t chan)
{
	radio_set_param(RP_CHANNEL(chan));
}
コード例 #7
0
/**
 * @brief radio_set_param Wrapper
 *
 * set a radio parameter
 *
 * see radio.h for more info
 */
void zr_setParam(radio_attribute_t attr, radio_param_t parm)
{
	radio_set_param(attr, parm);
}
コード例 #8
0
ファイル: MxRadio.cpp プロジェクト: examyes/SMeshStudio
/**
 * @brief Sets Radio Channel
 *
 * changes the radio channel by setting the radio channel state
 *
 * @param chan channel number, 11 to 26
 */
void cMxRadio::setChannel(channel_t chan)
{
	radio_set_param(RP_CHANNEL(chan));
}
コード例 #9
0
ファイル: MxRadio.cpp プロジェクト: examyes/SMeshStudio
/**
 * @brief radio_set_param Wrapper
 *
 * set a radio parameter
 *
 * see radio.h for more info
 */
void cMxRadio::setParam(radio_attribute_t attr, radio_param_t parm)
{
	radio_set_param(attr, parm);
}