⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 led.c

📁 基于cc1000和avr128处理器的指定路由多跳网络的试验程序
💻 C
字号:
/*
****************************************************************************
*              宁波中科集成电路设计中心  版权所有 Copyright 2005
*						http:\\www.nbicc.com
*文件名:  led.c
*程序员:  夏鹏		xpsonny@nbicc.com
*主要内容:led驱动
*
*如有问题或BUG,请登录www.wsn.net.cn 提问或用邮件和作者联系
****************************************************************************
*/

#include "led.h"
#include "os.h"
#include "fun.h"

static uint8_t LedsC_ledsOn;

enum {
	LedsC_RED_BIT = 1, 
	LedsC_GREEN_BIT = 2, 
	LedsC_YELLOW_BIT = 4
};

result_t LedInit(void)
{
	{ uint8_t atomicState = AtomicStart();
    {
		LedsC_ledsOn = 0;
		OSH_SET_RED_LED_PIN();
		OSH_SET_YELLOW_LED_PIN();
		OSH_SET_GREEN_LED_PIN();
    }
    AtomicEnd(atomicState); }
	return SUCCESS;
}

result_t LedYellowOn(void)
{
	{ uint8_t atomicState = AtomicStart();
    {
		OSH_CLR_YELLOW_LED_PIN();
		LedsC_ledsOn |= LedsC_YELLOW_BIT;
    }
    AtomicEnd(atomicState); }
	return SUCCESS;
}

result_t LedYellowOff(void)
{
	{ uint8_t atomicState = AtomicStart();
    {
		OSH_SET_YELLOW_LED_PIN();
		LedsC_ledsOn &= ~LedsC_YELLOW_BIT;
    }
    AtomicEnd(atomicState); }
	return SUCCESS;
}

result_t LedYellowToggle(void)
{
	result_t rval;
	{ uint8_t atomicState = AtomicStart();
    {
		if (LedsC_ledsOn & LedsC_YELLOW_BIT) {
			rval = LedYellowOff();
        }
		else {
			rval = LedYellowOn();
        }
    }
    AtomicEnd(atomicState); }
	return rval;
}

result_t LedRedOff(void)
{
	{ uint8_t atomicState = AtomicStart();
    {
		OSH_SET_RED_LED_PIN();
		LedsC_ledsOn &= ~LedsC_RED_BIT;
    }
    AtomicEnd(atomicState); }
	return SUCCESS;
}

result_t LedRedOn(void)
{
	{ uint8_t atomicState = AtomicStart();
    {
		OSH_CLR_RED_LED_PIN();
		LedsC_ledsOn |= LedsC_RED_BIT;
    }
    AtomicEnd(atomicState); }
	return SUCCESS;
}

result_t LedGreenOn(void)
{
	{ uint8_t atomicState = AtomicStart();
    {
		OSH_CLR_GREEN_LED_PIN();
		LedsC_ledsOn |= LedsC_GREEN_BIT;
    }
    AtomicEnd(atomicState); }
	return SUCCESS;
}

result_t LedGreenOff(void)
{
	{ uint8_t atomicState = AtomicStart();
    {
		OSH_SET_GREEN_LED_PIN();
		LedsC_ledsOn &= ~LedsC_GREEN_BIT;
    }
    AtomicEnd(atomicState); }
	return SUCCESS;
}

result_t LedGreenToggle(void)
{
	result_t rval;
	{ uint8_t atomicState = AtomicStart();
    {
		if (LedsC_ledsOn & LedsC_GREEN_BIT) {
			rval = LedGreenOff();
        }
		else {
			rval = LedGreenOn();
        }
    }
    AtomicEnd(atomicState); }
	return rval;
}

result_t LedRedToggle(void)
{
	result_t rval;
	
	{ uint8_t atomicState = AtomicStart();
    {
		if (LedsC_ledsOn & LedsC_RED_BIT) {
			rval = LedRedOff();
        }
		else {
			rval = LedRedOn();
        }
    }
    AtomicEnd(atomicState); }
	return rval;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -