Function writing notes - set port pin value

Now I have written a function to set port pin values.  So far so good.

.END

// ****************************************************************************
// Program - Blink LED
// Description - Blink LED
// Author - TL Fong
// Version - 0.38
// Date - 2013jul11hkt1306
// 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;
}
}

int main()
  {
setPortPinDirection(1, 8);
  while (1)
 {    
setPortPinValue(1, 8, 0);
    delayTenthSecond(5);    
setPortPinValue(1, 8, 1);
    delaySecond(1);
    }
  }

// ****************************************************************************
// End of Program
// ****************************************************************************

No comments:

Post a Comment