Your question is Set Register Bit with Mask. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
In NXP Semiconductors embedded software, register updates are often done with bit masks. Given a 32-bit unsigned register value, write a function that sets the 5th bit and returns the updated register.
Assume bit positions are 0-indexed from the least significant bit, so the 5th bit means bit index 4.
reg representing a 32-bit unsigned register value.def set_fifth_bit(reg):