// ****************************************************************************
// Program - Blink LED
// Description - Blink LED
// Author - TL Fong
// Version - 0.36
// Date - 2013jul11hkt1205
// License - Free
// Hardware - Somy ARM Cortex M0 LPC1114/301 Learning Board
// Software - Keil uVision 4.71.2.0 ARM compiler toolchain
// Hardware configuration notes
// 1. LED1 is connected to PIO1-8
// ****************************************************************************
#include <stdio.h>
#include "LPC11xx.h"
#include "timer.h"
void setPortPinOutput(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 setPort1Pin8ToOutput() // PIO1_8 for LED1 set to output
{
LPC_GPIO1->DIR |= (1 << 8);
}
void setPort1Pin8Low() // PIO1_8 Low = LED1 on
{
LPC_GPIO1->DATA &= ~(1 << 8);
}
void setPort1Pin8High() // PIO1_8 High = LED1 off
{
LPC_GPIO1->DATA |= (1 << 8);
}
int main()
{
// setPort1Pin8ToOutput(); // PIO1_8 for LED1 pin set to output
setPortPinOutput(1, 8);
while (1)
{
setPort1Pin8Low(); // LED on
delayTenthSecond(5);
setPort1Pin8High(); // LED off
delaySecond(1);
}
}
// ****************************************************************************
// End of Program
// ****************************************************************************
No comments:
Post a Comment