include: common: Add sys_set_bits and set_clear_bits inline functions
Add new common inline functions sys_set_bits and set_clear_bits to set and clear multiple bits via bit mask in single function call. Signed-off-by: Siew Chin Lim <elly.siew.chin.lim@intel.com>
This commit is contained in:
parent
43cb00df08
commit
5b6c59397e
2 changed files with 34 additions and 0 deletions
|
@ -42,6 +42,20 @@ static ALWAYS_INLINE int sys_test_bit(mem_addr_t addr, unsigned int bit)
|
|||
return temp & (1 << bit);
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void sys_set_bits(mem_addr_t addr, unsigned int mask)
|
||||
{
|
||||
uint32_t temp = *(volatile uint32_t *)addr;
|
||||
|
||||
*(volatile uint32_t *)addr = temp | mask;
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void sys_clear_bits(mem_addr_t addr, unsigned int mask)
|
||||
{
|
||||
uint32_t temp = *(volatile uint32_t *)addr;
|
||||
|
||||
*(volatile uint32_t *)addr = temp & ~mask;
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE
|
||||
void sys_bitfield_set_bit(mem_addr_t addr, unsigned int bit)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue