Giter Site home page Giter Site logo

Comments (4)

rockytriton avatar rockytriton commented on May 25, 2024

for the GPFSEL1 register, bits 12-14 control gpio 14 and bits 15-17 control gpio 15. (7 << 12) is putting 111 in the bits 12-14 and &= ~ is clearing them, essentially. 2 << 12 is setting bits 12-14 as 010. Same goes for the 15-17 bits.

from raspberry-pi-os.

remi-boivin avatar remi-boivin commented on May 25, 2024

@rockytriton Thx for your answer. It's more clear for me. I've a last question how we choose 010 and 111 ?
According to
image
010 it's use to choose the 5th alternative function and 111 it's to choose the 3rd alternative function but according to
image
the 15th GPIO 3rd alternative function isn't RXD1. So I'm a little but confused.

for the GPFSEL1 register, bits 12-14 control gpio 14 and bits 15-17 control gpio 15. (7 << 12) is putting 111 in the bits 12-14 and &= ~ is clearing them, essentially. 2 << 12 is setting bits 12-14 as 010. Same goes for the 15-17 bits.

from raspberry-pi-os.

rockytriton avatar rockytriton commented on May 25, 2024

15th GPIO alt 5 = RXD1. From the table at the top 010 sets alt 5. The 111 is just to mask all 3 bits so we can clear them first before setting the values.

selector &= ~(7<<15);

That creates a mask with 15 to 17 bits set to 111, then ~ inverts the bits so all bits are set except for 15 to 17, then selector &= that to ensure that bits 15 to 17 are cleared (set to 0) but the remaining bits on selector are left as-is. Now that we clear those 3 bits, we can set the value to 010 by ORing it with this line:

selector |= 2<<15;

from raspberry-pi-os.

remi-boivin avatar remi-boivin commented on May 25, 2024

@rockytriton Okay thank you very much for your explanations :)

15th GPIO alt 5 = RXD1. From the table at the top 010 sets alt 5. The 111 is just to mask all 3 bits so we can clear them first before setting the values.

selector &= ~(7<<15);

That creates a mask with 15 to 17 bits set to 111, then ~ inverts the bits so all bits are set except for 15 to 17, then selector &= that to ensure that bits 15 to 17 are cleared (set to 0) but the remaining bits on selector are left as-is. Now that we clear those 3 bits, we can set the value to 010 by ORing it with this line:

selector |= 2<<15;

from raspberry-pi-os.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.