lowlevel(3)

πŸ“¦
version 1.75 Β· 4 versions
, in debian trixie, ubuntu noble, ubuntu questing

πŸ’– 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. See BCM2835_GPIO_BASE etc.

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. See BCM2835_GPIO_BASE etc.

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. See BCM2835_GPIO_BASE etc.
  • value β€” The 32 bit value to write, masked in by mask.
  • 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. See BCM2835_GPIO_BASE etc.
  • 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. See BCM2835_GPIO_BASE etc.
  • 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 values BCM2835_REGBASE_* in bcm2835RegisterBase

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