How to speed up setting a pin?

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by mhjerde on Fri May 13 23:26:49 MST 2011
I need a fast way to set a pin to the value of an argument (0 or 1). The MCU is an LPC1768. This is what the code looks like now:

    // foo is either 0 or 1

    switch (foo)
        case 0:
            LPC_GPIO0->FIOCLR = (1 << LCD_RS_PIN);    // set low
        case 1:
            LPC_GPIO0->FIOSET = (1 << LCD_RS_PIN);    // set high
Is there a way to set the pin directly to the value of foo and avoid an if-else or switch statement? foo is passed as an argument. I feel like I'm missing something embarrassingly obvious!!