/**************************************************************************** * * NAME: vInitialiseApp * * DESCRIPTION: * Initialises JenOS modules and application. * * RETURNS: * void * ****************************************************************************/ PRIVATE void vInitialiseApp(void) { #ifdef OVERLAYS_BUILD sInitData.u32ImageOffset = 0; sInitData.prGetMutex = vGrabLock; sInitData.prReleaseMutex = vReleaseLock; sInitData.prOverlayEvent = &vOverlayEvent; OVLY_bInit(&sInitData); #endif /* UART 1 cannot be used as it shares DIO with the LEDS */ DBG_vUartInit(DBG_E_UART_0, DBG_E_UART_BAUD_RATE_115200); /* initialise JenOS modules */ PWRM_vInit(E_AHI_SLEEP_OSCON_RAMON); /* * Initialise the PDM, use an application supplied key (g_sKey), * The key value can be set to the desired value here, or the key in eFuse can be used. * To use the key stored in eFuse set the pointer to the key to Null, and remove the * key structure here. */ PDM_vInit(7, 1, 64 * 1024 , NULL, mutexMEDIA, NULL, &g_sKey); PDUM_vInit(); /* initialise application */ APP_vInitialiseSensorNode(); }
/**************************************************************************** * * NAME: vInitialiseApp * * DESCRIPTION: * Initialises Zigbee stack, hardware and application. * * * RETURNS: * void ****************************************************************************/ PRIVATE void vInitialiseApp(void) { /* * Initialise JenOS modules. Initialise Power Manager even on non-sleeping nodes * as it allows the device to doze when in the idle task. * Parameter options: E_AHI_SLEEP_OSCON_RAMON or E_AHI_SLEEP_DEEP or ... */ PWRM_vInit(E_AHI_SLEEP_OSCON_RAMON); #if JENNIC_CHIP == JN5169 PDM_eInitialise(63, NULL); #else PDM_eInitialise(0, NULL); #endif /* Initialise Protocol Data Unit Manager */ PDUM_vInit(); ZPS_vExtendedStatusSetCallback(vfExtendedStatusCallBack); /* Initialise application */ APP_vInitialiseNode(); DBG_vPrintf(TRACE_START, "\nAPP Start: Tick Timer = %d", u32AHI_TickTimerRead()); DBG_vPrintf(TRACE_START,"\nAPP Start: Initialised"); }
/**************************************************************************** * * NAME: NODE_vInit * * DESCRIPTION: * Initialises Zigbee stack, hardware and application. * ****************************************************************************/ PUBLIC void NODE_vInit(void) { uint32 u32RandomSeed; /* Debug */ DBG_vPrintf(NODE_TRACE, "\n%d NODE < NODE_vInit()", NODE_sData.u32Timer); /* Seed the pseudo random number generator using the hardware random gen */ *((volatile uint32 *)0x02001010) |= (1 << 30); /* clear ready flag */ vAHI_StartRandomNumberGenerator(TRUE /* single shot */, FALSE /* no ints */); while (!bAHI_RndNumPoll()); u32RandomSeed = ((uint32)u16AHI_ReadRandomNumber()) << 16; *((volatile uint32 *)0x02001010) |= (1 << 30); /* clear ready flag */ vAHI_StartRandomNumberGenerator(TRUE /* single shot */, FALSE /* no ints */); while (!bAHI_RndNumPoll()); u32RandomSeed |= u16AHI_ReadRandomNumber(); RND_vInit(u32RandomSeed); DBG_vPrintf(NODE_TRACE, " RND=%08x", u32RandomSeed); /* Initialise JenOS modules */ PWRM_vInit(E_AHI_SLEEP_OSCON_RAMON); DBG_vPrintf(NODE_TRACE, " PWRM"); /* Initialise persistent data */ PDM_vInit(7, 1, 64*1024, NULL, mutexPdmMedia, NULL, NULL); DBG_vPrintf(NODE_TRACE, " PDM"); /* Delete persistent data - always start over for now */ PDM_vDelete(); DBG_vPrintf(NODE_TRACE, "deleted"); PDUM_vInit(); DBG_vPrintf(NODE_TRACE, " PDUM"); /* Initialise ZigbeePro stack */ ZPS_eAplAfInit(); DBG_vPrintf(NODE_TRACE, " ZPS"); /* No state yet */ NODE_sData.eNwkState = NODE_NWKSTATE_NONE; /* Initialise non-zero node structure members */ NODE_sData.u64Address = *(uint64 *) pvAppApiGetMacAddrLocation(); /**< Address of node */ NODE_sData.u16Address = 0xffff; /**< Short address of node */ NODE_sData.u16Parent = 0xffff; /**< Short address of node's parent */ /* Initialise node structure pointer members */ NODE_sData.pvMac = (void *) pvAppApiGetMacHandle(); NODE_sData.psPib = MAC_psPibGetHandle(NODE_sData.pvMac); NODE_sData.pvNwk = ZPS_pvNwkGetHandle(); NODE_sData.psNib = ZPS_psNwkNibGetHandle(NODE_sData.pvNwk); /* Note initial MinBe */ NODE_sData.u8DefPibMinBe = NODE_sData.psPib->u8MinBe_ReadOnly; }
/**************************************************************************** * * NAME: vScheduleSleep * * DESCRIPTION: If we have deep sleep enabled and we attempting to deep sleep * then re-initialise the power manager for deep sleep * ****************************************************************************/ PRIVATE void vScheduleSleep(bool_t bDeepSleep) { #ifdef DEEP_SLEEP_ENABLE if (bDeepSleep) { PWRM_vInit(E_AHI_SLEEP_DEEP); DBG_vPrintf(TRACE_SLEEP_HANDLER, "\nAPP Sleep Handler: Deep Sleep"); } else { PWRM_eScheduleActivity(&sWake, (MAXIMUM_TIME_TO_SLEEP - u32GetNumberOfZCLTicksSinceReport())*APP_TICKS_PER_SECOND , vWakeCallBack); DBG_vPrintf(TRACE_SLEEP_HANDLER, "\nAPP Sleep Handler: Osc on"); } #else PWRM_eScheduleActivity(&sWake, (MAXIMUM_TIME_TO_SLEEP - u32GetNumberOfZCLTicksSinceReport())*APP_TICKS_PER_SECOND , vWakeCallBack); DBG_vPrintf(TRACE_SLEEP_HANDLER, "\nAPP Sleep Handler: Osc on"); #endif }
/**************************************************************************** * * NAME: vInitialiseApp * * DESCRIPTION: * * Initialises Zigbee stack, hardware and application. * * PARAMETERS: Name RW Usage * * * RETURNS: * void * ****************************************************************************/ PRIVATE void vInitialiseApp(void) { /* * Initialise JenOS modules. Initialise Power Manager even on non-sleeping nodes * as it allows the device to doze when in the idle task. * Parameter options: E_AHI_SLEEP_OSCON_RAMON or E_AHI_SLEEP_DEEP or ... */ PWRM_vInit(E_AHI_SLEEP_OSCON_RAMON); bDeepSleep = FALSE; /* Initialise the Persistent Data Manager */ #if JENNIC_CHIP == JN5169 PDM_eInitialise(63, NULL); #else PDM_eInitialise(0, NULL); #endif /* Initialise Protocol Data Unit Manager */ PDUM_vInit(); ZPS_vExtendedStatusSetCallback(vfExtendedStatusCallBack); /* initialise application */ APP_vInitialiseNode(); }