GPIOsetdir & gpiosetvalue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

GPIOsetdir & gpiosetvalue

1,896 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Deepak Bansal on Sat Sep 08 00:08:29 MST 2012
Below are two function in CMSIS code which I use. It works until I have to write single bit, But suppose I have to write 8 bit value on PORT0, then should I have to call this function 8 time. or there is anyway by which I can do this in single call



/**********************************************************************/

void GPIOSetValue( uint32_t portNum, uint32_t bitPosi, uint32_t bitVal )
{
  LPC_GPIO[portNum]->MASKED_ACCESS[(1<<bitPosi)] = (bitVal<<bitPosi);
}

/*****************************************************************************
** Function name:GPIOSetDir
**
** Descriptions:Set the direction in GPIO port
**
** parameters:port num, bit position, direction (1 out, 0 input)
** Returned value:None
**
*****************************************************************************/
void GPIOSetDir( uint32_t portNum, uint32_t bitPosi, uint32_t dir )
{
  if(dir)
LPC_GPIO[portNum]->DIR |= 1<<bitPosi;
  else
LPC_GPIO[portNum]->DIR &= ~(1<<bitPosi);
}
0 Kudos
Reply
4 Replies

1,552 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Deepak Bansal on Sun Sep 09 21:40:10 MST 2012
Hi find a manual but they don't have library description in it.
Or might be I find it wrong.
Can you please refer what manual are you referring.
0 Kudos
Reply

1,552 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Sat Sep 08 10:26:53 MST 2012
LPC_GPIO[portNum]->MASKED_ACCESS[MY_BIT_MASK] = MY_VALUE;

And, why don't you Read The Fine Manual?
0 Kudos
Reply

1,552 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Deepak Bansal on Sat Sep 08 02:12:38 MST 2012

Quote: gbm
You don't need to call any function. Just write the bits you want to the port, optionally using masking so that you update only the selected bits.
And, don't forget to Read The Fine Manual.




Hey I tried the above functions by oring bits. But didn't work for me.
like Bit0 | Bit 1 in fuction call.
0 Kudos
Reply

1,552 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gbm on Sat Sep 08 01:14:16 MST 2012
You don't need to call any function. Just write the bits you want to the port, optionally using masking so that you update only the selected bits.
And, don't forget to Read The Fine Manual.
0 Kudos
Reply