bit.h

Bit access macros for Cortex-M based CPUs.

CPU_HAS_BITBAND

Flag for telling if the CPU has hardware bit band support.

1
1 || 0 (1 for Cortex-M3 and up, 0 for Cortex-M0)
void * bitband_addr(volatile void * ptr, uintptr_t bit)

Convert bit band region address and bit number to bit band alias address.

Parameters

ptr:base address in non bit banded memory
bit:bit number within the word

Return values

  • Address of the bit within the bit band memory region
void bit_set32(volatile uint32_t * ptr, uint8_t bit)

Set a single bit in the 32 bit word pointed to by ptr.

The effect is the same as for the following snippet:

1
*ptr |= (1 << bit);

There is a read-modify-write cycle occurring within the core, but this cycle is atomic and can not be disrupted by IRQs

Parameters

ptr:pointer to target word
bit:bit number within the word

void bit_set16(volatile uint16_t * ptr, uint8_t bit)

Set a single bit in the 16 bit word pointed to by ptr.

The effect is the same as for the following snippet:

1
*ptr |= (1 << bit);

There is a read-modify-write cycle occurring within the core, but this cycle is atomic and can not be disrupted by IRQs

Parameters

ptr:pointer to target word
bit:bit number within the word

void bit_set8(volatile uint8_t * ptr, uint8_t bit)

Set a single bit in the 8 bit byte pointed to by ptr.

The effect is the same as for the following snippet:

1
*ptr |= (1 << bit);

There is a read-modify-write cycle occurring within the core, but this cycle is atomic and can not be disrupted by IRQs

Parameters

ptr:pointer to target byte
bit:bit number within the byte

void bit_clear32(volatile uint32_t * ptr, uint8_t bit)

Clear a single bit in the 32 bit word pointed to by ptr.

The effect is the same as for the following snippet:

1
*ptr &= ~(1 << bit);

There is a read-modify-write cycle occurring within the core, but this cycle is atomic and can not be disrupted by IRQs

Parameters

ptr:pointer to target word
bit:bit number within the word

void bit_clear16(volatile uint16_t * ptr, uint8_t bit)

Clear a single bit in the 16 bit word pointed to by ptr.

The effect is the same as for the following snippet:

1
*ptr &= ~(1 << bit);

There is a read-modify-write cycle occurring within the core, but this cycle is atomic and can not be disrupted by IRQs

Parameters

ptr:pointer to target word
bit:bit number within the word

void bit_clear8(volatile uint8_t * ptr, uint8_t bit)

Clear a single bit in the 8 bit byte pointed to by ptr.

The effect is the same as for the following snippet:

1
*ptr &= ~(1 << bit);

There is a read-modify-write cycle occurring within the core, but this cycle is atomic and can not be disrupted by IRQs

Parameters

ptr:pointer to target byte
bit:bit number within the byte