BUS - Bitfield Read/Write#
BUS register and RAM bit-field read/write API.
API to perform field set/clear/write/read access to RAM and peripheral's registers.
Functions#
Perform a single-bit write operation on a 32-bit word in RAM.
Perform a single-bit read operation on a 32-bit word in RAM.
Perform a single-bit atomic write operation on a peripheral register.
Perform a single-bit atomic read operation on a peripheral register.
Perform an atomic masked set operation on a peripheral register address.
Perform an atomic masked clear operation on the peripheral register address.
Perform peripheral register masked write.
Perform a peripheral register masked read.
Function Documentation#
sl_hal_bus_ram_write_bit#
void sl_hal_bus_ram_write_bit (volatile uint32_t * addr, uint32_t bit, uint32_t val)
Perform a single-bit write operation on a 32-bit word in RAM.
Type | Direction | Argument Name | Description |
---|---|---|---|
volatile uint32_t * | [in] | addr | An address of a 32-bit word in RAM. |
uint32_t | [in] | bit | A bit position to write, 0-31. |
uint32_t | [in] | val | A value to set bit to, 0 or 1. |
sl_hal_bus_ram_read_bit#
unsigned int sl_hal_bus_ram_read_bit (volatile const uint32_t * addr, uint32_t bit)
Perform a single-bit read operation on a 32-bit word in RAM.
Type | Direction | Argument Name | Description |
---|---|---|---|
volatile const uint32_t * | [in] | addr | RAM address. |
uint32_t | [in] | bit | A bit position to read, 0-31. |
Returns
The requested bit shifted to bit position 0 in the return value.
sl_hal_bus_reg_write_bit#
void sl_hal_bus_reg_write_bit (volatile uint32_t * addr, uint32_t bit, uint32_t val)
Perform a single-bit atomic write operation on a peripheral register.
Type | Direction | Argument Name | Description |
---|---|---|---|
volatile uint32_t * | [in] | addr | A peripheral register address. |
uint32_t | [in] | bit | A bit position to write, 0-31. |
uint32_t | [in] | val | A value to set bit to, 0 or 1. |
This function uses built-in hardware 4K-aliased addressing that allows to perform an atomic read-modify-write operation on a single register bit. See the reference manual for more details about alias addressing.
sl_hal_bus_reg_read_bit#
unsigned int sl_hal_bus_reg_read_bit (volatile const uint32_t * addr, uint32_t bit)
Perform a single-bit atomic read operation on a peripheral register.
Type | Direction | Argument Name | Description |
---|---|---|---|
volatile const uint32_t * | [in] | addr | A peripheral register address. |
uint32_t | [in] | bit | A bit position to read, 0-31. |
Returns
The requested bit shifted to bit position 0 in the return value.
sl_hal_bus_reg_set_mask#
void sl_hal_bus_reg_set_mask (volatile uint32_t * addr, uint32_t mask)
Perform an atomic masked set operation on a peripheral register address.
Type | Direction | Argument Name | Description |
---|---|---|---|
volatile uint32_t * | [in] | addr | A peripheral register address. |
uint32_t | [in] | mask | A mask to set. |
A peripheral register masked set provides a set operation of a bit-mask in a peripheral register. All 1s in the mask are set to 1 in the register. All 0s in the mask are not changed in the register. RAMs and special peripherals are not supported.
Note
This function uses built-in hardware 4K-aliased addressing that allows to perform an atomic read-modify-write operation. See the reference manual for more details about alias addressing.
sl_hal_bus_reg_clear_mask#
void sl_hal_bus_reg_clear_mask (volatile uint32_t * addr, uint32_t mask)
Perform an atomic masked clear operation on the peripheral register address.
Type | Direction | Argument Name | Description |
---|---|---|---|
volatile uint32_t * | [in] | addr | A peripheral register address. |
uint32_t | [in] | mask | A mask to clear. |
A peripheral register masked clear provides a clear operation of a bit-mask in a peripheral register. All 1s in the mask are set to 0 in the register. All 0s in the mask are not changed in the register. RAMs and special peripherals are not supported.
Note
This function uses built-in hardware 4K-aliased addressing that allows to perform an atomic read-modify-write operation. See the reference manual for more details about alias addressing.
sl_hal_bus_reg_write_mask#
void sl_hal_bus_reg_write_mask (volatile uint32_t * addr, uint32_t mask, uint32_t val)
Perform peripheral register masked write.
Type | Direction | Argument Name | Description |
---|---|---|---|
volatile uint32_t * | [in] | addr | A peripheral register address. |
uint32_t | [in] | mask | A peripheral register mask. |
uint32_t | [in] | val | A peripheral register value. The value must be shifted to the correct bit position in the register corresponding to the field defined by the mask parameter. The register value must be contained in the field defined by the mask parameter. The register value is masked to prevent involuntary spillage. |
This function first reads the peripheral register and updates only bits that are set in the mask with content of val. Typically, the mask is a bit-field in the register and the value val is within the mask.
Note
The read-modify-write operation is executed in a critical section to guarantee atomicity. Note that atomicity can only be guaranteed if register is modified only by the core, and not by other peripherals (like DMA).
sl_hal_bus_reg_read_mask#
uint32_t sl_hal_bus_reg_read_mask (volatile const uint32_t * addr, uint32_t mask)
Perform a peripheral register masked read.
Type | Direction | Argument Name | Description |
---|---|---|---|
volatile const uint32_t * | [in] | addr | A peripheral register address. |
uint32_t | [in] | mask | A peripheral register mask. |
Read an unshifted and masked value from a peripheral register.
Note
This operation is not hardware accelerated.
Returns
An unshifted and masked register value.