Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4829

C/C++ • Re: Initializing a GPIO bitmask for use with the SDK functions

$
0
0
A more readable way of creating the bitmask:

Code:

// You can also use the shifts directly if you prefer.#define BIT(n)  (1u<<(n))uint32_t gpio_bitmask = BIT(22) | BIT(21) | BIT(16) | BIT(15) | BIT(14);
What the mask does depends on how you configured the pins and which function. For example if a GPIO is configured as input there is no effect if you try to set that GPIO low or high with gpio_put_mask(). It doesn't matter if you initialized GPIOs individually or with mask. You can mix.

Statistics: Posted by pica200 — Mon Jun 10, 2024 11:28 pm



Viewing all articles
Browse latest Browse all 4829

Trending Articles