Skip to content

(low priority) demo-stm32h7-nucleo question - bsrr set_bit() #2033

Answered by dancrossnyc
SandyWalsh asked this question in Q&A
Discussion options

You must be logged in to vote

Those set two separate bits: "BS" vs "BR". w is the argument to the closure, and is a BSRR as in https://github.com/stm32-rs/stm32-rs-nightlies/blob/master/stm32f3/src/stm32f373/gpioa/bsrr.rs.

In the code snippet you highlighted above, if addr has the low bit set, set w's bs2, otherwise, set br2. Writing a 1 to bs2 (e.g., via bs2.set_bit()) sets pin 2, thus turning it on; similarly, writing a 1 to br2 resets the pin, thus turning it off.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@SandyWalsh
Comment options

@dancrossnyc
Comment options

Answer selected by SandyWalsh
@SandyWalsh
Comment options

@dancrossnyc
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants