lowlevel(3)
π lowlevel(3) β low level register access, bestie edition π
ok so this is lowlevel(3), a page from the Library Functions Manual π. It's the low-level register access corner of the bcm2835 world. Buckle up, we're going deep into the metal β¨
πΈ NAME πΈ
lowlevel β low level register access
β¨ SYNOPSIS β¨
π§ Functions
uint32_t * bcm2835_regbase (uint8_t regbase)
uint32_t bcm2835_peri_read (volatile uint32_t *paddr)
uint32_t bcm2835_peri_read_nb (volatile uint32_t *paddr)
void bcm2835_peri_write (volatile uint32_t *paddr, uint32_t value)
void bcm2835_peri_write_nb (volatile uint32_t *paddr, uint32_t value)
void bcm2835_peri_set_bits (volatile uint32_t *paddr, uint32_t value,
uint32_t mask)
π¦ Detailed Description π¦
These functions are the β¨low level register accessβ¨ girls. They give you direct access to registers, and you should not generally need to use them. Like, genuinely. They're the backstage pass β powerful, but you probably don't need to be back there π
π Function Documentation π
π uint32_t bcm2835_peri_read (volatile uint32_t * paddr) [extern]
Reads a 32 bit value from a peripheral address WITH a memory barrier before and after each read. It's safe, but it's slow. The MB before protects this read from any in-flight reads that didn't use a MB. The MB after protects subsequent reads from another peripheral. literally a little bodyguard for your read π«Ά
Parameters
paddrβ Physical address to read from. SeeBCM2835_GPIO_BASEetc.
Returns
- the value read from the 32 bit register
See also
- Physical Addresses
π uint32_t bcm2835_peri_read_nb (volatile uint32_t * paddr) [extern]
Reads a 32 bit value from a peripheral address WITHOUT the read barriers. ngl this one is the speedrun version and you only get to use it when:
- your code has previously called
bcm2835_peri_read()for a register within the same peripheral, and no read or write to another peripheral has occurred since. - your code has called
bcm2835_memory_barrier()since the last access to ANOTHER peripheral.
Parameters
paddrβ Physical address to read from. SeeBCM2835_GPIO_BASEetc.
Returns
- the value read from the 32 bit register
See also
- Physical Addresses
π void bcm2835_peri_set_bits (volatile uint32_t * paddr, uint32_t value, uint32_t mask) [extern]
Alters a number of bits in a 32 bit peripheral register. The way that it works is: it reads the current value, then alters the bits defined as 1 in mask, according to the bit value in value. All other bits that are 0 in the mask are unaffected π
Use this to alter a subset of the bits in a register. Memory barriers are used.
Note that this is NOT atomic; an interrupt routine can cause unexpected results. π so like, be aware, bestie.
Parameters
paddrβ Physical address to read from. SeeBCM2835_GPIO_BASEetc.valueβ The 32 bit value to write, masked in bymask.maskβ Bitmask that defines the bits that will be altered in the register.
See also
- Physical Addresses
β void bcm2835_peri_write (volatile uint32_t * paddr, uint32_t value) [extern]
Writes a 32 bit value to a peripheral address WITH a memory barrier before and after each write. This is safe, but slow. The MB before ensures that any in-flight write to another peripheral completes before this write is issued. The MB after ensures that subsequent reads and writes to another peripheral will see the effect of this write.
This is a tricky optimization; if you aren't sure, use the barrier version.
Parameters
paddrβ Physical address to read from. SeeBCM2835_GPIO_BASEetc.valueβ The 32 bit value to write
See also
- Physical Addresses
πΈ void bcm2835_peri_write_nb (volatile uint32_t * paddr, uint32_t value) [extern]
Writes a 32 bit value to a peripheral address without the write barrier. You should only use this when:
- your code has previously called
bcm2835_peri_write()for a register within the same peripheral, and no other peripheral access has occurred since. - your code has called
bcm2835_memory_barrier()since the last access to ANOTHER peripheral.
This is a tricky optimization; if you aren't sure, use the barrier version.
Parameters
paddrβ Physical address to read from. SeeBCM2835_GPIO_BASEetc.valueβ The 32 bit value to write
See also
- Physical Addresses
π¦ uint32_t * bcm2835_regbase (uint8_t regbase) [extern]
Gets the base of a register. iconic behaviour honestly π
Parameters
regbaseβ You can use one of the common valuesBCM2835_REGBASE_*inbcm2835RegisterBase
Returns
- the register base
See also
- Physical Addresses
π Author π
Generated automatically by Doxygen for bcm2835 from the source code. not a human writing this, just a robot doing its little thing π€β¨
ok that's the whole page bestie, you ate that ππ this was bcm2835, Version 1.75, lowlevel(3), mwah, go touch some registers (safely) ππ§
π¦ where this page comes from
- debian trixie: libbcm2835-dev 1.75+ds-1 Β· GPL-3.0-only
- ubuntu noble: libbcm2835-dev 1.75+ds-1 Β· GPL-3.0-only
- ubuntu questing: libbcm2835-dev 1.75+ds-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms