📄 hid_mouse_led.c
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2005-2006
Part of BlueLab 3.5.2-release
FILE NAME
hid_mouse_led.c
DESCRIPTION
This file contains the LED control task.
NOTES
*/
/****************************************************************************
Header files
*/
#include "hid_mouse.h"
#include <pio.h>
#include <vm.h>
/* Internal messages */
enum
{
LED_INTERNAL_UPDATE
};
static void appLedHandleInternalUpdate(appLedTaskData *theLed)
{
if (theLed->onPeriod < 0)
#ifdef HW_DEV_1409
theLed->state = 0xFF;
#else
theLed->state = LED_PIO_MASK;
#endif
else if (theLed->offPeriod < 0)
theLed->state = 0;
else
#ifdef HW_DEV_1409
theLed->state ^= 0xFF;
#else
theLed->state ^= LED_PIO_MASK;
#endif
#ifdef HW_DEV_1409
PioSetAuxDac(1, theLed->state);
#else
PioSet(LED_PIO_MASK, theLed->state);
#endif
if (theLed->state)
{
#ifdef HW_DEV_1409
VmDeepSleepEnable(FALSE);
#endif
if (theLed->onPeriod > 0)
MessageSendLater(&theLed->task, LED_INTERNAL_UPDATE, 0, theLed->onPeriod);
}
else
{
#ifdef HW_DEV_1409
VmDeepSleepEnable(TRUE);
#endif
if (theLed->offPeriod > 0)
MessageSendLater(&theLed->task, LED_INTERNAL_UPDATE, 0, theLed->offPeriod);
}
}
static void appLedHandler(Task task, MessageId id, Message message)
{
if (id == LED_INTERNAL_UPDATE)
appLedHandleInternalUpdate((appLedTaskData *)task);
}
void appLedInit(appLedTaskData *theLed)
{
theLed->task.handler = appLedHandler;
theLed->state = 0;
theLed->priority = -1;
}
void appLedUpdate(appLedTaskData *theLed, int onPeriod, int offPeriod, uint8 priority)
{
theLed->onPeriodTable[priority] = onPeriod;
theLed->offPeriodTable[priority] = offPeriod;
appLedSetPriority(theLed, priority);
}
void appLedSetPriority(appLedTaskData *theLed, uint8 priority)
{
theLed->onPeriod = theLed->onPeriodTable[priority];
theLed->offPeriod = theLed->offPeriodTable[priority];
theLed->priority = priority;
/* Cancel LED update message */
MessageCancelAll(&theLed->task, LED_INTERNAL_UPDATE);
/* Post update message to LED task */
MessageSend(&theLed->task, LED_INTERNAL_UPDATE, 0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -