libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
tools.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define GET_REG(REG)   ((uint16_t) *(REG))
 
#define SET_REG(REG, VAL)   (*(REG) = (uint16_t)(VAL))
 
#define CLR_REG_BIT(REG, BIT)   SET_REG((REG), (~(BIT)))
 
#define CLR_REG_BIT_MSK_AND_SET(REG, MSK, BIT, EXTRA_BITS)    SET_REG((REG), (GET_REG((REG)) & (MSK) & (~(BIT))) | (EXTRA_BITS))
 
#define CLR_REG_BIT_MSK(REG, MSK, BIT)    CLR_REG_BIT_MSK_AND_SET((REG), (MSK), (BIT), 0)
 
#define GET_REG_BIT(REG, BIT)   (GET_REG(REG) & (BIT))
 
#define TOG_SET_REG_BIT_MSK_AND_SET(REG, MSK, BIT, EXTRA_BITS)
 
#define TOG_SET_REG_BIT_MSK(REG, MSK, BIT)    TOG_SET_REG_BIT_MSK_AND_SET((REG), (MSK), (BIT), 0)
 

Macro Definition Documentation

◆ CLR_REG_BIT

#define CLR_REG_BIT (   REG,
  BIT 
)    SET_REG((REG), (~(BIT)))

Definition at line 34 of file tools.h.

◆ CLR_REG_BIT_MSK

#define CLR_REG_BIT_MSK (   REG,
  MSK,
  BIT 
)     CLR_REG_BIT_MSK_AND_SET((REG), (MSK), (BIT), 0)

Definition at line 40 of file tools.h.

◆ CLR_REG_BIT_MSK_AND_SET

#define CLR_REG_BIT_MSK_AND_SET (   REG,
  MSK,
  BIT,
  EXTRA_BITS 
)     SET_REG((REG), (GET_REG((REG)) & (MSK) & (~(BIT))) | (EXTRA_BITS))

Definition at line 37 of file tools.h.

◆ GET_REG

#define GET_REG (   REG)    ((uint16_t) *(REG))

Definition at line 28 of file tools.h.

◆ GET_REG_BIT

#define GET_REG_BIT (   REG,
  BIT 
)    (GET_REG(REG) & (BIT))

Definition at line 44 of file tools.h.

◆ SET_REG

#define SET_REG (   REG,
  VAL 
)    (*(REG) = (uint16_t)(VAL))

Definition at line 31 of file tools.h.

◆ TOG_SET_REG_BIT_MSK

#define TOG_SET_REG_BIT_MSK (   REG,
  MSK,
  BIT 
)     TOG_SET_REG_BIT_MSK_AND_SET((REG), (MSK), (BIT), 0)

Definition at line 63 of file tools.h.

◆ TOG_SET_REG_BIT_MSK_AND_SET

#define TOG_SET_REG_BIT_MSK_AND_SET (   REG,
  MSK,
  BIT,
  EXTRA_BITS 
)
Value:
do { \
register uint16_t toggle_mask = GET_REG(REG) & (MSK); \
toggle_mask ^= BIT; \
SET_REG((REG), toggle_mask | (EXTRA_BITS)); \
} while (0)
#define GET_REG(REG)
Definition: tools.h:28

Definition at line 56 of file tools.h.