// Program - Blinky
// Description - Blink LED
// Author - TL Fong
// Version - 0.39
// Date - 2013jul11hkt1310
// License - Free
// Hardware - Somy ARM Cortex M0 LPC1114/301 Learning Board
// Software - Keil uVision 4.71.2.0 ARM compiler toolchain
// Method - Incremental testing
// Hardware configuration notes
// 1. LED1 is connected to PIO1-8
// ****************************************************************************
#include <stdio.h>
#include "LPC11xx.h"
#include "timer.h"
void setPortPinDirection(int portNumber, int pinNumber)
{
switch( portNumber )
{
case 1:
LPC_GPIO1->DIR |= (1 << pinNumber);
break;
case 2:
LPC_GPIO2->DIR |= (1 << pinNumber);
break;
default:
break;
}
}
void setPortPinValue(int portNumber, int pinNumber, int pinValue)
{
switch( portNumber )
{
case 1:
if (pinValue == 1)
LPC_GPIO1->DATA &= ~(1 << pinNumber);
else
LPC_GPIO1->DATA |= (1 << pinNumber);
break;
case 2:
;
break;
default:
break;
}
}
void blinkLed(int ledNumber, int onTime, int offTime, int blinkCount)
{
int count;
switch( ledNumber )
{
case 1:
setPortPinDirection(1, 8);
for (count = 0; count < blinkCount; count--)
{
setPortPinValue(1, 8, 0);
delayTenthSecond(onTime);
setPortPinValue(1, 8, 1);
delayTenthSecond(offTime);
}
break;
case 2:
;
break;
default:
break;
}
}
int main()
{
setPortPinDirection(1, 8);
blinkLed(1, 5, 10, 20);
}
// ****************************************************************************
// End of Program
// ****************************************************************************
No comments:
Post a Comment