Macros | Functions
hw_types.h File Reference

This file contains the in-line functions required to read/write values from/to the hardware registers. This file also contains field manipulation macros to get and set field values. More...

Macros

#define HW_GET_FIELD(regVal, REG_FIELD)   (((regVal) & (uint32_t) REG_FIELD##_MASK) >> (uint32_t) REG_FIELD##_SHIFT)
 Macro to extract a field value. This macro extracts the field value from a 32-bit variable (which contains the register value). This macro does not read from actual register address, and only extracts the field from a variable. More...
 
#define HW_SET_FIELD(regVal, REG_FIELD, fieldVal)
 Macro to write a specific field value. This macro first clears the specified field value and then performs "OR" of the field value which is shifted and masked. This will set the field value at its desired position. More...
 
#define HW_WR_FIELD32(regAddr, REG_FIELD, fieldVal)
 This macro calls read-modify-write API for 32 bit register. It also frames the mask and shift from register field macro. More...
 
#define HW_WR_FIELD16(regAddr, REG_FIELD, fieldVal)
 This macro calls read-modify-write API for 16 bit register. It also frames the mask and shift from register field macro. More...
 
#define HW_WR_FIELD8(regAddr, REG_FIELD, fieldVal)
 This macro calls read-modify-write API for 8 bit register. It also frames the mask and shift from register field macro. More...
 
#define HW_RD_FIELD32(regAddr, REG_FIELD)
 This macro calls read field API for 32 bit register. It also frames the mask and shift from register field macro. More...
 
#define HW_RD_FIELD16(regAddr, REG_FIELD)
 This macro calls read field API for 16 bit register. It also frames the mask and shift from register field macro. More...
 
#define HW_RD_FIELD8(regAddr, REG_FIELD)
 This macro calls read field API for 8 bit register. It also frames the mask and shift from register field macro. More...
 

Functions

static uint32_t HW_RD_REG32 (uint32_t addr)
 This function reads a 32-bit value from a hardware register and returns the value. More...
 
static void HW_WR_REG32 (uint32_t addr, uint32_t value)
 This function writes a 32-bit value to a hardware register. More...
 
static uint16_t HW_RD_REG16 (uint32_t addr)
 This function reads a 16-bit value from a hardware register and returns the value. More...
 
static void HW_WR_REG16 (uint32_t addr, uint16_t value)
 This function writes a 16-bit value to a hardware register. More...
 
static uint8_t HW_RD_REG8 (uint32_t addr)
 This function reads a 8-bit value from a hardware register and returns the value. More...
 
static void HW_WR_REG8 (uint32_t addr, uint8_t value)
 This function writes a 8-bit value to a hardware register. More...
 
static void HW_WR_FIELD32_RAW (uint32_t addr, uint32_t mask, uint32_t shift, uint32_t value)
 This function reads a 32 bit register, modifies specific set of bits and writes back to the register. More...
 
static void HW_WR_FIELD16_RAW (uint32_t addr, uint16_t mask, uint32_t shift, uint16_t value)
 This function reads a 16 bit register, modifies specific set of bits and writes back to the register. More...
 
static void HW_WR_FIELD8_RAW (uint32_t addr, uint8_t mask, uint32_t shift, uint8_t value)
 This function reads a 8 bit register, modifies specific set of bits and writes back to the register. More...
 
static uint32_t HW_RD_FIELD32_RAW (uint32_t addr, uint32_t mask, uint32_t shift)
 This function reads a 32 bit register, masks specific set of bits and the left shifted value. More...
 
static uint16_t HW_RD_FIELD16_RAW (uint32_t addr, uint16_t mask, uint32_t shift)
 This function reads a 16 bit register, masks specific set of bits and the left shifted value. More...
 
static uint8_t HW_RD_FIELD8_RAW (uint32_t addr, uint8_t mask, uint32_t shift)
 This function reads a 8 bit register, masks specific set of bits and the left shifted value. More...
 

Detailed Description

This file contains the in-line functions required to read/write values from/to the hardware registers. This file also contains field manipulation macros to get and set field values.

Macro Definition Documentation

#define HW_GET_FIELD (   regVal,
  REG_FIELD 
)    (((regVal) & (uint32_t) REG_FIELD##_MASK) >> (uint32_t) REG_FIELD##_SHIFT)

Macro to extract a field value. This macro extracts the field value from a 32-bit variable (which contains the register value). This macro does not read from actual register address, and only extracts the field from a variable.

Parameters
regVal32-bit variable containing the register value.
REG_FIELDPeripheral register bit field name, whose value has to be extracted.
#define HW_RD_FIELD16 (   regAddr,
  REG_FIELD 
)
Value:
(HW_RD_FIELD16_RAW(regAddr, (uint16_t) REG_FIELD##_MASK, \
(uint32_t) REG_FIELD##_SHIFT))
static uint16_t HW_RD_FIELD16_RAW(uint32_t addr, uint16_t mask, uint32_t shift)
This function reads a 16 bit register, masks specific set of bits and the left shifted value...
Definition: hw_types.h:439

This macro calls read field API for 16 bit register. It also frames the mask and shift from register field macro.

Parameters
regAddrRegister Address.
REG_FIELDPeripheral register bit field name, from which specified bit-field value has to be read.
Return values
Valueof the bit-field
#define HW_RD_FIELD32 (   regAddr,
  REG_FIELD 
)
Value:
(HW_RD_FIELD32_RAW(regAddr, (uint32_t) REG_FIELD##_MASK, \
(uint32_t) REG_FIELD##_SHIFT))
static uint32_t HW_RD_FIELD32_RAW(uint32_t addr, uint32_t mask, uint32_t shift)
This function reads a 32 bit register, masks specific set of bits and the left shifted value...
Definition: hw_types.h:427

This macro calls read field API for 32 bit register. It also frames the mask and shift from register field macro.

Parameters
regAddrRegister Address.
REG_FIELDPeripheral register bit field name, from which specified bit-field value has to be read.
Return values
Valueof the bit-field
#define HW_RD_FIELD8 (   regAddr,
  REG_FIELD 
)
Value:
(HW_RD_FIELD8_RAW(regAddr, (uint8_t) REG_FIELD##_MASK, \
(uint32_t) REG_FIELD##_SHIFT))
static uint8_t HW_RD_FIELD8_RAW(uint32_t addr, uint8_t mask, uint32_t shift)
This function reads a 8 bit register, masks specific set of bits and the left shifted value...
Definition: hw_types.h:451

This macro calls read field API for 8 bit register. It also frames the mask and shift from register field macro.

Parameters
regAddrRegister Address.
REG_FIELDPeripheral register bit field name, from which specified bit-field value has to be read.
Return values
Valueof the bit-field
#define HW_SET_FIELD (   regVal,
  REG_FIELD,
  fieldVal 
)
Value:
((regVal) = ((regVal) & (uint32_t) (~(uint32_t) REG_FIELD##_MASK)) | \
((((uint32_t) fieldVal) << (uint32_t) REG_FIELD##_SHIFT) & \
(uint32_t) REG_FIELD##_MASK))

Macro to write a specific field value. This macro first clears the specified field value and then performs "OR" of the field value which is shifted and masked. This will set the field value at its desired position.

Parameters
regVal32-bit variable containing the register value.
REG_FIELDPeripheral register bit field name, to which specified value has to be set.
fieldValValue of the field which has to be set.
#define HW_WR_FIELD16 (   regAddr,
  REG_FIELD,
  fieldVal 
)
Value:
(HW_WR_FIELD16_RAW(regAddr, (uint16_t) REG_FIELD##_MASK, \
(uint32_t) REG_FIELD##_SHIFT, (uint16_t) fieldVal))
static void HW_WR_FIELD16_RAW(uint32_t addr, uint16_t mask, uint32_t shift, uint16_t value)
This function reads a 16 bit register, modifies specific set of bits and writes back to the register...
Definition: hw_types.h:397

This macro calls read-modify-write API for 16 bit register. It also frames the mask and shift from register field macro.

Parameters
regAddrRegister Address.
REG_FIELDPeripheral register bit field name, to which specified value has to be set.
fieldValValue of the field which has to be set.
#define HW_WR_FIELD32 (   regAddr,
  REG_FIELD,
  fieldVal 
)
Value:
(HW_WR_FIELD32_RAW(regAddr, (uint32_t) REG_FIELD##_MASK, \
(uint32_t) REG_FIELD##_SHIFT, (uint32_t) fieldVal))
static void HW_WR_FIELD32_RAW(uint32_t addr, uint32_t mask, uint32_t shift, uint32_t value)
This function reads a 32 bit register, modifies specific set of bits and writes back to the register...
Definition: hw_types.h:382

This macro calls read-modify-write API for 32 bit register. It also frames the mask and shift from register field macro.

Parameters
regAddrRegister Address.
REG_FIELDPeripheral register bit field name, to which specified value has to be set.
fieldValValue of the field which has to be set.
#define HW_WR_FIELD8 (   regAddr,
  REG_FIELD,
  fieldVal 
)
Value:
(HW_WR_FIELD8_RAW(regAddr, (uint8_t) REG_FIELD##_MASK, \
(uint32_t) REG_FIELD##_SHIFT, (uint8_t) fieldVal))
static void HW_WR_FIELD8_RAW(uint32_t addr, uint8_t mask, uint32_t shift, uint8_t value)
This function reads a 8 bit register, modifies specific set of bits and writes back to the register...
Definition: hw_types.h:412

This macro calls read-modify-write API for 8 bit register. It also frames the mask and shift from register field macro.

Parameters
regAddrRegister Address.
REG_FIELDPeripheral register bit field name, to which specified value has to be set.
fieldValValue of the field which has to be set.

Function Documentation

static uint16_t HW_RD_FIELD16_RAW ( uint32_t  addr,
uint16_t  mask,
uint32_t  shift 
)
inlinestatic

This function reads a 16 bit register, masks specific set of bits and the left shifted value.

Parameters
addrAddress of the memory mapped hardware register.
maskMask for the bit field.
shiftBit field shift from LSB.
Return values
Bit-fieldvalue (absolute value - shifted to LSB position)
static uint32_t HW_RD_FIELD32_RAW ( uint32_t  addr,
uint32_t  mask,
uint32_t  shift 
)
inlinestatic

This function reads a 32 bit register, masks specific set of bits and the left shifted value.

Parameters
addrAddress of the memory mapped hardware register.
maskMask for the bit field.
shiftBit field shift from LSB.
Return values
Bit-fieldvalue (absolute value - shifted to LSB position)
static uint8_t HW_RD_FIELD8_RAW ( uint32_t  addr,
uint8_t  mask,
uint32_t  shift 
)
inlinestatic

This function reads a 8 bit register, masks specific set of bits and the left shifted value.

Parameters
addrAddress of the memory mapped hardware register.
maskMask for the bit field.
shiftBit field shift from LSB.
Return values
Bit-fieldvalue (absolute value - shifted to LSB position)
static uint16_t HW_RD_REG16 ( uint32_t  addr)
inlinestatic

This function reads a 16-bit value from a hardware register and returns the value.

Parameters
addrAddress of the memory mapped hardware register.
Return values
Unsigned16-bit value read from a register.
static uint32_t HW_RD_REG32 ( uint32_t  addr)
inlinestatic

This function reads a 32-bit value from a hardware register and returns the value.

Parameters
addrAddress of the memory mapped hardware register.
Return values
Unsigned32-bit value read from a register.
static uint8_t HW_RD_REG8 ( uint32_t  addr)
inlinestatic

This function reads a 8-bit value from a hardware register and returns the value.

Parameters
addrAddress of the memory mapped hardware register.
Return values
Unsigned8-bit value read from a register.
static void HW_WR_FIELD16_RAW ( uint32_t  addr,
uint16_t  mask,
uint32_t  shift,
uint16_t  value 
)
inlinestatic

This function reads a 16 bit register, modifies specific set of bits and writes back to the register.

Parameters
addrAddress of the memory mapped hardware register.
maskMask for the bit field.
shiftBit field shift from LSB.
valueValue to be written to bit-field.
static void HW_WR_FIELD32_RAW ( uint32_t  addr,
uint32_t  mask,
uint32_t  shift,
uint32_t  value 
)
inlinestatic

This function reads a 32 bit register, modifies specific set of bits and writes back to the register.

Parameters
addrAddress of the memory mapped hardware register.
maskMask for the bit field.
shiftBit field shift from LSB.
valueValue to be written to bit-field.
static void HW_WR_FIELD8_RAW ( uint32_t  addr,
uint8_t  mask,
uint32_t  shift,
uint8_t  value 
)
inlinestatic

This function reads a 8 bit register, modifies specific set of bits and writes back to the register.

Parameters
addrAddress of the memory mapped hardware register.
maskMask for the bit field.
shiftBit field shift from LSB.
valueValue to be written to bit-field.
static void HW_WR_REG16 ( uint32_t  addr,
uint16_t  value 
)
inlinestatic

This function writes a 16-bit value to a hardware register.

Parameters
addrAddress of the memory mapped hardware register.
valueunsigned 16-bit value which has to be written to the register.
static void HW_WR_REG32 ( uint32_t  addr,
uint32_t  value 
)
inlinestatic

This function writes a 32-bit value to a hardware register.

Parameters
addrAddress of the memory mapped hardware register.
valueunsigned 32-bit value which has to be written to the register.
static void HW_WR_REG8 ( uint32_t  addr,
uint8_t  value 
)
inlinestatic

This function writes a 8-bit value to a hardware register.

Parameters
addrAddress of the memory mapped hardware register.
valueunsigned 8-bit value which has to be written to the register.

Copyright 2016, Texas Instruments Incorporated