Sleep Mode For WSN of Jennic
Sleep mode that base on IEEE 802.15.4 for wireless sensor network of jennic.
e.g:
#include <jendefs.h>
#include <AppHardwareApi.h>
#include <AppQueueApi.h>
// And Add AppQueueApi.c to project.
#include <AppHardwareApi.h>
#include <AppQueueApi.h>
// And Add AppQueueApi.c to project.
#define LIGHT_SWITCH_INPUT_MASK 0x00000800UL // SW2
PUBLIC void AppColdStart(void)
{
u32AHI_Init();
u32AppQApiInit(NULL, NULL, NULL); // Needed Call For Sleep Mode
if (u8AHI_PowerStatus() & 0x01) /* If this is a wake from sleep mode */
{
vGoSleep();
}
else /* else it must be a power on reset */
{
/* Set switch button IO line to inputs */
vAHI_DioSetDirection(LIGHT_SWITCH_INPUT_MASK, 0);
/* Enable wakeup on negative edge of switch input */
vAHI_DioWakeEdge(0, LIGHT_SWITCH_INPUT_MASK);
vAHI_DioWakeEnable(LIGHT_SWITCH_INPUT_MASK, 0);
vGoSleep();
}
while (1)
{
;
}
}
{
u32AHI_Init();
u32AppQApiInit(NULL, NULL, NULL); // Needed Call For Sleep Mode
if (u8AHI_PowerStatus() & 0x01) /* If this is a wake from sleep mode */
{
vGoSleep();
}
else /* else it must be a power on reset */
{
/* Set switch button IO line to inputs */
vAHI_DioSetDirection(LIGHT_SWITCH_INPUT_MASK, 0);
/* Enable wakeup on negative edge of switch input */
vAHI_DioWakeEdge(0, LIGHT_SWITCH_INPUT_MASK);
vAHI_DioWakeEnable(LIGHT_SWITCH_INPUT_MASK, 0);
vGoSleep();
}
while (1)
{
;
}
}
PUBLIC void AppWarmStart(void)
{
AppColdStart();
}
{
AppColdStart();
}
PRIVATE void vGoSleep(void)
{
vAHI_MemoryHold(FALSE);
vAHI_PowerDown(FALSE);
}
{
vAHI_MemoryHold(FALSE);
vAHI_PowerDown(FALSE);
}