need some help to understand this code

Apr 23, 2022 at 12:36am
I am new in c++ coding in this chapter I can not understand the meaning of " mask = 0x4<<16;"
Last edited on Apr 25, 2022 at 12:06pm
Apr 23, 2022 at 12:47am
The "brevity"* of your post could be interpreted as laziness or rudeness by some. You could at least explain how you came upon this code instead of having us have to search for it ourselves.

It's some OpenWrt (embedded operating systems programming on Linux) code for "GPIO chip intialization [sic] and handlers".
https://github.com/cgoder/openwrt_rtk/blob/master/rtk_openwrt_sdk/target/linux/rtkmips/files/arch/mips/rtl8197f/gpio.c

*To anyone else reading, what's a word like "brevity" or "terseness", but with only negative connotations?
Laconic, perhaps? But that seems more neutral.
Last edited on Apr 23, 2022 at 12:50am
Apr 23, 2022 at 8:48am
thanks for your interesting , I can not switch gpio30 to be active_high , do you have any advice ?
Apr 25, 2022 at 12:25pm
Why did you remove the code from your OP?
Apr 25, 2022 at 12:46pm
0x4 << 16 means take the hex number 4 (which is 100 binary) and shift left by 16 bits giving 1000000000000000000 which is 0x40000 (hex). So mask is set to 0x40000.

Last edited on Apr 25, 2022 at 12:46pm
Topic archived. No new replies allowed.