I am not really sure what does ulConfig |= ulMode;
mean? If
void gpio_setup_mode(unsigned long ulGpioNum, unsigned long ulMode, unsigned long ulInvert)
{
unsigned long ulConfig = ulInvert;
ulConfig |= ulMode;
s_ptGPIO->auiCFG[ulGpioNum] = ulConfig;
}
and
gpio_setup_mode(GPIO8, GPIO_MODE_OUTPUT, GPIO_NOINVERT);
where GPIO8, GPIO_MODE_OUTPUT, GPIO_NOINVERT
#define GPIO8 8
#define GPIO_NOINVERT 0x00000000
#define GPIO_MODE_OUTPUT 0x00000011
ulConfig |= ulMode;
is equivalent to
ulConfig = ulConfig | ulMode;
The |
-operator performs a binary "or" operation between the two operants.
From the C11-Standard (Draft):
6.5.12 Bitwise inclusive OR operator
[...]
Contrains
2 Each of the operands shall have integer type.
Semantics
[...]
4 The result of the | operator is the bitwise inclusive OR of the operands (that is, each bit in the result is set if and only if at least one of the corresponding bits in the converted operands is set).
User contributions licensed under CC BY-SA 3.0