#include <GLOBAL.h>
#include <stdlib.h>
#include <stdbool.h>
#include <msp430x41x2.h>
#define LedOneOut P6DIR |= BIT2
#define LedOneHig P6OUT |= BIT2
#define LedOneLow P6OUT &=~ BIT2
#define LedTwoOut P6DIR |= BIT5
#define LedTwoHig P6OUT |= BIT5
#define LedTwoLow P6OUT &= ~ BIT5
#define LedThrOut P6DIR |= BIT6
#define LedThrHig P6OUT |= BIT6
#define LedThrLow P6OUT &=~ BIT6
void LedSet(bool LedSt,unsigned char LedData)
{
if(LedSt)
{
if(LedData&0x01){LedOneHig;}else{LedOneLow;}
if(LedData&0x02){LedTwoHig;}else{LedTwoLow;}
if(LedData&0x04){LedThrHig;}else{LedThrLow;}
}
else
{
if(LedData&0x01){LedOneLow;}else{LedOneHig;}
if(LedData&0x02){LedTwoLow;}else{LedTwoHig;}
if(LedData&0x04){LedThrLow;}else{LedThrHig;}
}
}
void LedCircumgyrate(void) // led1 on
{
unsigned int i;
for(i=10;i<200;i+=5)
{
LedOneLow;
Delay(i);
LedOneHig;
Delay(200-i);
}
LedOneLow;
}
void LedFlicker(void) // led1 on
{
unsigned int i;
for(i=10;i<200;i+=5)
{
LedOneLow;
Delay(i);
LedOneHig;
Delay(200-i);
}
LedOneLow;
}
void LedOn(void) // led1 on
{
LedSet(1,LedOnDate);
Delay(50000);
}
void LedOff(void) // led1 on
{
LedSet(0,LedOnDate);
Delay(50000);
}
void LedPwmOn(void) // led1 on
{
unsigned int k;
for(k=0;k<800;k++)
{
LedSet(1,LedOnDate);
Delay(k);
LedSet(1,LedOffDate);
Delay(800-k);
}
LedSet(1,LedOnDate);
}
void LedPwmOff(void) // led1 off
{
unsigned int k;
for(k=0;k<800;k++)
{
LedSet(1,LedOffDate);
Delay(k);
LedSet(1,LedOnDate);
Delay(800-k);
}
LedSet(1,LedOffDate);
}
void LedPwm(void)
{
unsigned char i,k;
for(i=0;i<8;i++)
{
LedOnDate=i;
LedOffDate=~i;
LedPwmOn();
LedPwmOff();
}
for(i=1;i<9;i++)
{
for(k=0;k<8;k++)
{
LedOnDate=i;
LedOn();
LedOff();
}
}
for(i=0;i<8;i++)
{
LedOnDate=i;
LedOffDate=~i;
LedPwmOn();
LedPwmOff();
}
for(i=1;i<9;i++)
{
for(k=0;k<8;k++)
{
LedOnDate=i;
LedOn();
LedOff();
}
}
} |