/************************************
标题:LEDs.h
软件平台:CCS v5.2
硬件平台:毕设控制板
主频:60M
欢迎
http://greatech.taobao.com
author:小船
data:2013-02-23
*************************************/
#ifndef LEDS_H_
#define LEDS_H_
#include "PeripheralHeaderIncludes.h"
#define no_config_leds_by_funtion
#define LED0 0x00000200
#define LED1 0x00020000
#define LED2 0x00040000
#define LED3 0x02000000
#define LEDA_on(LED_num) GpioDataRegs.GPACLEAR.all = LED_num
#define LEDA_off(LED_num) GpioDataRegs.GPASET.all = LED_num
#define LEDA_toggle(LED_num) GpioDataRegs.GPATOGGLE.all = LED_num
#define LEDB_on(LED_num) GpioDataRegs.GPBCLEAR.all = LED_num
#define LEDB_off(LED_num) GpioDataRegs.GPBSET.all = LED_num
#define LEDB_toggle(LED_num) GpioDataRegs.GPBTOGGLE.all = LED_num
#ifdef config_leds_by_funtion
enum LED_action {on, off, toggle};
void LEDs(Uint32 LED_num, enum LED_action action);
#endif
void LEDs_init();
#endif /* LEDS_H_ */
/************************************
标题:LEDs.c
软件平台:CCS v5.2
硬件平台:毕设控制板
主频:60M
欢迎光临
http://greatech.taobao.com
author:小船
data:2013-02-23
*************************************/
#include "LEDs.h"
void LEDs_init()
{
EALLOW;
//使能上拉电阻
GpioCtrlRegs.GPBPUD.bit.GPIO41 = 1;
GpioCtrlRegs.GPAPUD.bit.GPIO25 = 1;
GpioCtrlRegs.GPAPUD.bit.GPIO18 = 1;
GpioCtrlRegs.GPAPUD.bit.GPIO17 = 1;
//选择GPIO功能
GpioCtrlRegs.GPBMUX1.bit.GPIO41 = 0x0;
GpioCtrlRegs.GPAMUX2.bit.GPIO25 = 0x0;
GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 0x0;
GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 0x0;
//方向
GpioCtrlRegs.GPBDIR.bit.GPIO41 = 1;
GpioCtrlRegs.GPADIR.bit.GPIO25 = 1;
GpioCtrlRegs.GPADIR.bit.GPIO17 = 1;
GpioCtrlRegs.GPADIR.bit.GPIO18 = 1;
EDIS;
LEDB_off(LED0);
LEDA_off(LED1|LED2|LED3);
}
#ifdef config_leds_by_funtion
void LEDs(Uint32 LED_num, enum LED_action action)
{
if(LED_num != )
{
switch (action)
{
case on:{
GpioDataRegs.GPBCLEAR.all = LED_num;
break;
}
case off:{
GpioDataRegs.GPBSET.all = LED_num;
break;
}
case toggle:{
GpioDataRegs.GPBTOGGLE.all = LED_num;
break;
}
}
}
else
{
switch (action)
{
case on:{
GpioDataRegs.GPACLEAR.all = LED_num;
break;
}
case off:{
GpioDataRegs.GPASET.all = LED_num;
break;
}
case toggle:{
GpioDataRegs.GPATOGGLE.all = LED_num;
break;
}
}
}
}
#endif