Loading...
Searching...
No Matches
Kinetis Bit Manipulation Engine (BME)

Macros for using decorated memory accesses with the Bit Manipulation Engine available in Kinetis Cortex-M0+ devices. More...

Detailed Description

Macros for using decorated memory accesses with the Bit Manipulation Engine available in Kinetis Cortex-M0+ devices.

Files

file  bme.h
 Macro definitions for the Kinetis Bit Manipulation Engine (BME)
 

Macros

#define BITBAND_FUNCTIONS_PROVIDED   1
 Tell bit.h that we provide CPU specific bit manipulation functions.
 
#define BME_AND_MASK   (1 << 26)
 AND decoration bitmask.
 
#define BME_OR_MASK   (1 << 27)
 OR decoration bitmask.
 
#define BME_XOR_MASK   (3 << 26)
 XOR decoration bitmask.
 
#define BME_LAC1_MASK(BIT)   ((1 << 27) | ((BIT) << 21))
 Load-and-clear 1 bit.
 
#define BME_LAS1_MASK(BIT)   ((3 << 26) | ((BIT) << 21))
 Load-and-set 1 bit.
 
#define BME_BF_MASK(bit, width)   ((1 << 28) | ((bit) << 23) | (((width) - 1 ) << 19))
 Bit field extraction bitmask.
 

Functions

static volatile void * bme_bf_addr (volatile void *ptr, uintptr_t bit, uintptr_t width)
 Bit field address macro.
 
static volatile uint32_t * bme_bitfield32 (volatile uint32_t *ptr, uint8_t bit, uint8_t width)
 Access a bitfield (32 bit load/store)
 
static volatile uint16_t * bme_bitfield16 (volatile uint16_t *ptr, uint8_t bit, uint8_t width)
 Access a bitfield (16 bit load/store)
 
static volatile uint8_t * bme_bitfield8 (volatile uint8_t *ptr, uint8_t bit, uint8_t width)
 Access a bitfield (8 bit load/store)
 
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.
 

Macro Definition Documentation

◆ BITBAND_FUNCTIONS_PROVIDED

#define BITBAND_FUNCTIONS_PROVIDED   1

Tell bit.h that we provide CPU specific bit manipulation functions.

Definition at line 35 of file bme.h.

◆ BME_AND_MASK

#define BME_AND_MASK   (1 << 26)

AND decoration bitmask.

Definition at line 37 of file bme.h.

◆ BME_BF_MASK

#define BME_BF_MASK (   bit,
  width 
)    ((1 << 28) | ((bit) << 23) | (((width) - 1 ) << 19))

Bit field extraction bitmask.

Parameters
bitLSB of the bitfield within the word/halfword/byte
widthNumber of bits to extract

Definition at line 49 of file bme.h.

◆ BME_LAC1_MASK

#define BME_LAC1_MASK (   BIT)    ((1 << 27) | ((BIT) << 21))

Load-and-clear 1 bit.

Definition at line 40 of file bme.h.

◆ BME_LAS1_MASK

#define BME_LAS1_MASK (   BIT)    ((3 << 26) | ((BIT) << 21))

Load-and-set 1 bit.

Definition at line 41 of file bme.h.

◆ BME_OR_MASK

#define BME_OR_MASK   (1 << 27)

OR decoration bitmask.

Definition at line 38 of file bme.h.

◆ BME_XOR_MASK

#define BME_XOR_MASK   (3 << 26)

XOR decoration bitmask.

Definition at line 39 of file bme.h.

Function Documentation

◆ 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:

*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
[in]ptrpointer to target word
[in]bitbit number within the word

Definition at line 225 of file bme.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:

*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
[in]ptrpointer to target word
[in]bitbit number within the word

Definition at line 205 of file bme.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:

*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
[in]ptrpointer to target byte
[in]bitbit number within the byte

Definition at line 245 of file bme.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:

*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
[in]ptrpointer to target word
[in]bitbit number within the word

Definition at line 165 of file bme.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:

*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
[in]ptrpointer to target word
[in]bitbit number within the word

Definition at line 145 of file bme.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:

*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
[in]ptrpointer to target byte
[in]bitbit number within the byte

Definition at line 185 of file bme.h.

◆ bme_bf_addr()

static volatile void * bme_bf_addr ( volatile void *  ptr,
uintptr_t  bit,
uintptr_t  width 
)
inlinestatic

Bit field address macro.

Precondition
The target address must lie within a part of the peripheral address space 0x40000000 - 0x40070000
Parameters
[in]ptrPointer to target register
[in]bitLocation of the LSB of the bitfield within the register
[in]widthWidth of the the bitfield, in bits
Returns
bitfield address as an uintptr_t

Definition at line 63 of file bme.h.

◆ bme_bitfield16()

static volatile uint16_t * bme_bitfield16 ( volatile uint16_t *  ptr,
uint8_t  bit,
uint8_t  width 
)
inlinestatic

Access a bitfield (16 bit load/store)

This macro can be used both for store (*bme_bitfield16(xxx) = y) and load (y = *bme_bitfield16(ptr, bit))

Precondition
The target address must lie within a part of the peripheral address space 0x40000000 - 0x40070000
Parameters
[in]ptrPointer to target register
[in]bitLocation of the LSB of the bitfield within the register
[in]widthWidth of the the bitfield, in bits
Returns
bitfield extracted as a (modifiable) lvalue

Definition at line 103 of file bme.h.

◆ bme_bitfield32()

static volatile uint32_t * bme_bitfield32 ( volatile uint32_t *  ptr,
uint8_t  bit,
uint8_t  width 
)
inlinestatic

Access a bitfield (32 bit load/store)

This macro can be used both for store (*bme_bitfield32(xxx) = y) and load (y = *bme_bitfield32(ptr, bit))

Precondition
The target address must lie within a part of the peripheral address space 0x40000000 - 0x40070000
Parameters
[in]ptrPointer to target register
[in]bitLocation of the LSB of the bitfield within the register
[in]widthWidth of the the bitfield, in bits
Returns
bitfield extracted as a (modifiable) lvalue

Definition at line 83 of file bme.h.

◆ bme_bitfield8()

static volatile uint8_t * bme_bitfield8 ( volatile uint8_t *  ptr,
uint8_t  bit,
uint8_t  width 
)
inlinestatic

Access a bitfield (8 bit load/store)

This macro can be used both for store (*bme_bitfield8(xxx) = y) and load (y = *bme_bitfield8(ptr, bit))

Precondition
The target address must lie within a part of the peripheral address space 0x40000000 - 0x40070000
Parameters
[in]ptrPointer to target register
[in]bitLocation of the LSB of the bitfield within the register
[in]widthWidth of the the bitfield, in bits
Returns
bitfield extracted as a (modifiable) lvalue

Definition at line 123 of file bme.h.