// Program - Blinky
// Description - Blink LED
// Author - TL Fong
// Version - 0.44
// Date - 2013jul13hkt1153
// Hardware - Somy ARM Cortex M0 LPC1114/301 Learning Board
// Software - Keil uVision 4.71.2.0 ARM CC
// Somy Configuration -
// LED1 - P1.8
// ****************************************************************************
#include <stdio.h>
#include "LPC11xx.h"
#include "timer.h"
LPC_GPIO_TypeDef *getGpioStructPointer(int gpioStructNumber)
{
LPC_GPIO_TypeDef *gpioStructPointer;
switch(gpioStructNumber)
{
case 0:
gpioStructPointer = LPC_GPIO0;
break;
case 1:
gpioStructPointer = LPC_GPIO1;
break;
default:
break;
}
return gpioStructPointer;
}
void setPortPinDirection03(int gpioStructNumber, int pinNumber)
{
LPC_GPIO_TypeDef *gpioStructPointer;
gpioStructPointer = getGpioStructPointer(gpioStructNumber);
gpioStructPointer->DIR |= (1 << pinNumber);
}
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 blinky(int ledNumber, int onTime, int offTime, int blinkCount)
{
int count;
switch( ledNumber )
{
case 1:
setPortPinDirection03(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()
{
setPortPinDirection03(1, 8); // LED 1 = gpioStructure 1, pin 8
blinky(1, 5, 10, 20); // LED off 0.5 sec, on 1 sec, 20 times
}
// ****************************************************************************
// End of Program
// ****************************************************************************
No comments:
Post a Comment