Bit access macros with bit-banding support for Cortex-M based CPUs.
More...
Bit access macros with bit-banding support for Cortex-M based CPUs.
- Author
- Joakim NohlgÄrd joaki.nosp@m.m.no.nosp@m.hlgar.nosp@m.d@ei.nosp@m.stec..nosp@m.se
Definition in file bit.h.
#include <stdint.h>
#include "cpu.h"
Go to the source code of this file.
#define | CPU_HAS_BITBAND 1 || 0 (1 if CPU implements bit-banding, 0 if not) |
| Flag to check if the CPU has hardware bit band support.
|
|
#define | CPU_HAS_SRAM_BITBAND 1 || 0 |
| Flag to check if bit-banding is supported for all of SRAM.
|
|
|
static volatile void * | bitband_addr (volatile void *ptr, uintptr_t bit) |
| Convert bit band region address and bit number to bit band alias address.
|
|
static void | bit_set32 (volatile uint32_t *ptr, uint8_t bit) |
| Set a single bit in the 32 bit word pointed to by ptr .
|
|
static void | bit_set16 (volatile uint16_t *ptr, uint8_t bit) |
| Set a single bit in the 16 bit word pointed to by ptr .
|
|
static void | bit_set8 (volatile uint8_t *ptr, uint8_t bit) |
| Set a single bit in the 8 bit byte pointed to by ptr .
|
|
static void | bit_clear32 (volatile uint32_t *ptr, uint8_t bit) |
| Clear a single bit in the 32 bit word pointed to by ptr .
|
|
static void | bit_clear16 (volatile uint16_t *ptr, uint8_t bit) |
| Clear a single bit in the 16 bit word pointed to by ptr .
|
|
static void | bit_clear8 (volatile uint8_t *ptr, uint8_t bit) |
| Clear a single bit in the 8 bit byte pointed to by ptr .
|
|
static bool | bit_check32 (volatile uint32_t *ptr, uint8_t bit) |
| Checks if a single bit in the 32 bit word pointed to by ptr is set.
|
|
static bool | bit_check16 (volatile uint16_t *ptr, uint8_t bit) |
| Checks if a single bit in the 16 bit word pointed to by ptr is set.
|
|
static bool | bit_check8 (volatile uint8_t *ptr, uint8_t bit) |
| Checks if a single bit in the 8 bit byte pointed to by ptr is set.
|
|
◆ CPU_HAS_BITBAND
#define CPU_HAS_BITBAND 1 || 0 (1 if CPU implements bit-banding, 0 if not) |
Flag to check if the CPU has hardware bit band support.
Definition at line 37 of file bit.h.
◆ CPU_HAS_SRAM_BITBAND
#define CPU_HAS_SRAM_BITBAND 1 || 0 |
Flag to check if bit-banding is supported for all of SRAM.
Bit-banding in SRAM is only supported (if available at all) for a 1 MiB region in the address space. If not all of SRAM is mapped there, it is safest to not use bit-banding at all. Luckily, only few vendors decided to implement partially broken bit-banding.
- Return values
-
1 | All of SRAM is bit-banding capable |
0 | (At least one part) SRAM is not bit-banding capable |
Definition at line 49 of file bit.h.
◆ bit_check16()
static bool bit_check16 |
( |
volatile uint16_t * |
ptr, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Checks if a single bit in the 16 bit word pointed to by ptr
is set.
The effect is the same as for the following snippet:
- Parameters
-
[in] | ptr | pointer to target word |
[in] | bit | bit number within the word |
Definition at line 229 of file bit.h.
◆ bit_check32()
static bool bit_check32 |
( |
volatile uint32_t * |
ptr, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Checks if a single bit in the 32 bit word pointed to by ptr
is set.
The effect is the same as for the following snippet:
- Parameters
-
[in] | ptr | pointer to target word |
[in] | bit | bit number within the word |
Definition at line 212 of file bit.h.
◆ bit_check8()
static bool bit_check8 |
( |
volatile uint8_t * |
ptr, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Checks if a single bit in the 8 bit byte pointed to by ptr
is set.
The effect is the same as for the following snippet:
- Parameters
-
[in] | ptr | pointer to target byte |
[in] | bit | bit number within the byte |
Definition at line 246 of file bit.h.
◆ bit_clear16()
static void bit_clear16 |
( |
volatile uint16_t * |
ptr, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Clear a single bit in the 16 bit word pointed to by ptr
.
The effect is the same as for the following snippet:
There is a read-modify-write cycle occurring within the core, but this cycle is atomic and can not be disrupted by IRQs
- Parameters
-
[in] | ptr | pointer to target word |
[in] | bit | bit number within the word |
Definition at line 175 of file bit.h.
◆ bit_clear32()
static void bit_clear32 |
( |
volatile uint32_t * |
ptr, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Clear a single bit in the 32 bit word pointed to by ptr
.
The effect is the same as for the following snippet:
There is a read-modify-write cycle occurring within the core, but this cycle is atomic and can not be disrupted by IRQs
- Parameters
-
[in] | ptr | pointer to target word |
[in] | bit | bit number within the word |
Definition at line 155 of file bit.h.
◆ bit_clear8()
static void bit_clear8 |
( |
volatile uint8_t * |
ptr, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Clear a single bit in the 8 bit byte pointed to by ptr
.
The effect is the same as for the following snippet:
There is a read-modify-write cycle occurring within the core, but this cycle is atomic and can not be disrupted by IRQs
- Parameters
-
[in] | ptr | pointer to target byte |
[in] | bit | bit number within the byte |
Definition at line 195 of file bit.h.
◆ bit_set16()
static void bit_set16 |
( |
volatile uint16_t * |
ptr, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Set a single bit in the 16 bit word pointed to by ptr
.
The effect is the same as for the following snippet:
There is a read-modify-write cycle occurring within the core, but this cycle is atomic and can not be disrupted by IRQs
- Parameters
-
[in] | ptr | pointer to target word |
[in] | bit | bit number within the word |
Definition at line 115 of file bit.h.
◆ bit_set32()
static void bit_set32 |
( |
volatile uint32_t * |
ptr, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Set a single bit in the 32 bit word pointed to by ptr
.
The effect is the same as for the following snippet:
There is a read-modify-write cycle occurring within the core, but this cycle is atomic and can not be disrupted by IRQs
- Parameters
-
[in] | ptr | pointer to target word |
[in] | bit | bit number within the word |
Definition at line 95 of file bit.h.
◆ bit_set8()
static void bit_set8 |
( |
volatile uint8_t * |
ptr, |
|
|
uint8_t |
bit |
|
) |
| |
|
inlinestatic |
Set a single bit in the 8 bit byte pointed to by ptr
.
The effect is the same as for the following snippet:
There is a read-modify-write cycle occurring within the core, but this cycle is atomic and can not be disrupted by IRQs
- Parameters
-
[in] | ptr | pointer to target byte |
[in] | bit | bit number within the byte |
Definition at line 135 of file bit.h.
◆ bitband_addr()
static volatile void * bitband_addr |
( |
volatile void * |
ptr, |
|
|
uintptr_t |
bit |
|
) |
| |
|
inlinestatic |
Convert bit band region address and bit number to bit band alias address.
- Parameters
-
[in] | ptr | base address in non bit banded memory |
[in] | bit | bit number within the word |
- Returns
- Address of the bit within the bit band memory region
Definition at line 74 of file bit.h.