uint32_t IEEE802154::init(uint16_t panid)
{
	IEEE802154_DBG_FUNC_ENTER();

	void *pvMac;
	uint32_t version;

	version = u32AppApiInit(MlmeDcfmIndGetBuf, MlmeDcfmIndPost, this,
			        McpsDcfmIndGetBuf, McpsDcfmIndPost, this);
	IEEE802154_DBG_PRINTLN("pvAppApiGetMacHandle");
	pvMac = pvAppApiGetMacHandle();

	IEEE802154_DBG_PRINTLN("MAC_psPibGetHandle");
	(void)MAC_psPibGetHandle(pvMac);

	IEEE802154_DBG_PRINTF("MAC_vPibSetPanId: 0x%x", panid);
	IEEE802154_DBG_PRINTLN("");
	
	MAC_vPibSetPanId(pvMac, panid);
	
	/* Enable receiver to be on when idle */
	IEEE802154_DBG_PRINTLN("MAC_vPibSetRxOnWhenIdle");
	MAC_vPibSetRxOnWhenIdle(pvMac, 1, FALSE);

	return version;
}
Ejemplo n.º 2
0
/****************************************************************************
 *
 * NAME: vInitSystem
 *
 * DESCRIPTION: Initialise the radio system
 *
 * RETURNS:
 * void
 *
 ****************************************************************************/
PRIVATE void vInitSystem(void)
{
	// Setup interface to MAC
	(void) u32AHI_Init();
	(void) u32AppQApiInit(NULL,mcpsCallback , NULL);


	loadSettings();


	if (useHighPowerModule == TRUE)
	{
		//max power for europe including antenna gain is 10dBm
		// TODO see if we can use more power as rx antenna is lower gain
		//??? boost is +2.5 ant is 1 and power set to 4 = 7.5 ????
		vAHI_HighPowerModuleEnable(TRUE, TRUE);
#ifdef JN5168
		eAppApiPlmeSet(PHY_PIB_ATTR_TX_POWER, 34+10*2);
#else
		bAHI_PhyRadioSetPower(2);
#endif
	}
	// Initialise end device state
	sEndDeviceData.eState = E_STATE_IDLE;
	sEndDeviceData.u8TxPacketSeqNb = 0;
	sEndDeviceData.u8RxPacketSeqNb = 0;
	sEndDeviceData.u8ChannelSeqNo = 0;

	// Set up the MAC handles. Must be called AFTER u32AppQApiInit()
	s_pvMac = pvAppApiGetMacHandle();
	s_psMacPib = MAC_psPibGetHandle(s_pvMac);

	// Set Pan ID in PIB (also sets match register in hardware)
	MAC_vPibSetPanId(s_pvMac, PAN_ID);

	// Enable receiver to be on when idle
	MAC_vPibSetRxOnWhenIdle(s_pvMac, TRUE, FALSE);

	// sometimes useful during development
	// all messages are passed up from lower levels
	// MAC_vPibSetPromiscuousMode(s_pvMac, TRUE, FALSE);


	module_MAC_ExtAddr_s* macptr = (module_MAC_ExtAddr_s*)pvAppApiGetMacAddrLocation();

	//moved to after u32AHI_Init() for jn5148
	randomizeHopSequence(((uint32) macptr->u32H) ^ ((uint32) macptr->u32L));

#if (defined JN5148 || defined JN5168)
	/* Enable TOF ranging. */
//	vAppApiTofInit(TRUE);
#endif

}
Ejemplo n.º 3
0
void
ieee_init()
{
  void *mac;
  MAC_Pib_s *pib;

  if (process_is_running(&ieee_process))
    return;

  /* initialize ieee_eventhandler and event queue*/
  rxq_init();

  /* setup mac <-> app interface */
  u32AppApiInit((PR_GET_BUFFER) rxq_mlme_alloc, (PR_POST_CALLBACK) ieee_process_poll, NULL,
                (PR_GET_BUFFER) rxq_mcps_alloc, (PR_POST_CALLBACK) ieee_process_poll, NULL);

  /* get mac and pib handles */
  mac   = pvAppApiGetMacHandle();
  pib   = MAC_psPibGetHandle(mac);

  /* do a full reset */
  req_reset(true);

  /* set panid and default parameters */
  MAC_vPibSetPanId(mac, IEEE802154_PANDID);
  MAC_vPibSetRxOnWhenIdle(mac, true, false);

  /* allocate an event for this process */
  ieee_event = process_alloc_event();
  pib->bAutoRequest = true;

  /* bandwidth control, smaller interframe gap and higher data rate,
   * this is not standard conform! */
#if defined(__BA2__) && defined(JENNIC_CONF_JN5148_FASTDATARATE)
  vAHI_BbcSetHigherDataRate(E_AHI_BBC_CTRL_DATA_RATE_1_MBPS);
  vAHI_BbcSetInterFrameGap(48);
#endif

  process_start(&ieee_process, NULL);
}