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);
}