lpcware

LPC 1227 and GPIO

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by drvrh on Tue Jul 21 03:42:23 MST 2015
Hello,

I wrote my library for GPIO for LPC1227 and working in past but now doesn't work.

I have in main:

GPIOSetDir(0, 16, OUTPUT);
GPIOSetValue(0, 16, LOW);


In IO.c I have:

void GPIOSetValue( uint32_t portNum, uint32_t bitPosi, uint32_t bitVal )
{
  if (bitVal == 0)
  {
  switch (portNum) {
case 0:
LPC_GPIO0 -> CLR = (1 << bitPosi);
break;
case 1:
LPC_GPIO1 -> CLR = (1 << bitPosi);
break;
case 2:
LPC_GPIO2 -> CLR = (1 << bitPosi);
default:
break;
}
  }
  else if (bitVal >= 1)
  {
  switch (portNum){
  case 0:
  LPC_GPIO0 -> SET = (1 << bitPosi);
  break;
  case 1:
  LPC_GPIO1 -> SET = (1 << bitPosi);
  break;
  case 2:
  LPC_GPIO2 -> SET = (1 << bitPosi);
  break;
  }
  }
}

void GPIOSetDir( uint32_t portNum, uint32_t bitPosi, uint32_t dir )
{
  if(dir)
  switch (portNum) {
case 0:
LPC_GPIO0-> DIR |= 1 << bitPosi;
break;
case 1:
LPC_GPIO1-> DIR |= 1 << bitPosi;
break;
case 2:
LPC_GPIO2 -> DIR |= 1 << bitPosi;
break;
default:
break;
}
  else
  switch (portNum) {
case 0:
LPC_GPIO0 -> DIR &= ~(1 << bitPosi);
break;
case 1:
LPC_GPIO1 -> DIR &= ~(1 << bitPosi);
break;
case 2:
LPC_GPIO2 -> DIR &= ~(1 << bitPosi);
break;
default:
break;
}
}


Where I have a problem?

Original Attachment has been moved to: IO_0.c.zip

Original Attachment has been moved to: IO_0.h.zip

Outcomes