CC26xx Driver Library
[ddi.h] Digital to Digital Interface

Functions

static uint32_t DDI32RegRead (uint32_t ui32Base, uint32_t ui32Reg)
 Read the value in a 32 bit register. More...
 
static void DDI32BitsSet (uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Val)
 Set specific bits in a DDI slave register. More...
 
static void DDI32BitsClear (uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Val)
 Clear specific bits in a 32 bit DDI register. More...
 
static void DDI8SetValBit (uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Byte, uint16_t ui16Mask, uint16_t ui16Val)
 Set a value on any 8 bits inside a 32 bit register in the DDI slave. More...
 
static void DDI16SetValBit (uint32_t ui32Base, uint32_t ui32Reg, bool bWriteHigh, uint32_t ui32Mask, uint32_t ui32Val)
 Set a value on any 16 bits inside a 32 bit register aligned on a half-word boundary in the DDI slave. More...
 
void DDI32RegWrite (uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Val)
 Write a 32 bit value to a register in the DDI slave. More...
 
void DDI16BitWrite (uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32WrData)
 Write a single bit using a 16-bit maskable write. More...
 
void DDI16BitfieldWrite (uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift, uint16_t ui32Data)
 Write a bit field via the DDI using 16-bit maskable write. More...
 
uint16_t DDI16BitRead (uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask)
 Read a bit via the DDI using 16-bit read. More...
 
uint16_t DDI16BitfieldRead (uint32_t ui32Base, uint32_t ui32Reg, uint32_t ui32Mask, uint32_t ui32Shift)
 Read a bit field via the DDI using 16-bit read. More...
 

Detailed Description

Introduction


API

The API functions can be grouped like this:

Write:

Read:

Function Documentation

§ DDI16BitfieldRead()

uint16_t DDI16BitfieldRead ( uint32_t  ui32Base,
uint32_t  ui32Reg,
uint32_t  ui32Mask,
uint32_t  ui32Shift 
)

Read a bit field via the DDI using 16-bit read.

Requires that entire bit field is within the half word boundary.

Parameters
ui32Baseis the base address of the DDI port.
ui32Regis register to access.
ui32Maskis the mask defining which of the 16 bits that should be overwritten.
ui32Shiftdefines the required shift of the data to align with bit 0.
Returns
Returns data aligned to bit 0.

Referenced by DDI16SetValBit(), OSCClockSourceGet(), and OSCHfSourceReady().

185 {
186  uint32_t ui32RegAddr;
187  uint16_t ui16Data;
188 
189  // Check the arguments.
190  ASSERT(DDIBaseValid(ui32Base));
191 
192  // Calculate the register address.
193  ui32RegAddr = ui32Base + ui32Reg + DDI_O_DIR;
194 
195  // Adjust for target bit in high half of the word.
196  if(ui32Shift >= 16)
197  {
198  ui32Shift = ui32Shift - 16;
199  ui32RegAddr += 2;
200  ui32Mask = ui32Mask >> 16;
201  }
202 
203  // Read the register.
204  ui16Data = HWREGH(ui32RegAddr);
205 
206  // Mask data and shift into place.
207  ui16Data &= ui32Mask;
208  ui16Data >>= ui32Shift;
209 
210  // Return data.
211  return(ui16Data);
212 }
#define ASSERT(expr)
Definition: debug.h:71

§ DDI16BitfieldWrite()

void DDI16BitfieldWrite ( uint32_t  ui32Base,
uint32_t  ui32Reg,
uint32_t  ui32Mask,
uint32_t  ui32Shift,
uint16_t  ui32Data 
)

Write a bit field via the DDI using 16-bit maskable write.

Requires that entire bit field is within the half word boundary.

Parameters
ui32Baseis the base address of the DDI port.
ui32Regis register to access.
ui32Maskis the mask defining which of the 16 bits that should be overwritten.
ui32Shiftis the shift value for the bit field.
ui32Datais the data aligned to bit 0.
Returns
None

Referenced by DDI16SetValBit(), OSCClockLossEventDisable(), OSCClockLossEventEnable(), OSCClockSourceSet(), and SetupAfterColdResetWakeupFromShutDownCfg2().

118 {
119  uint32_t ui32RegAddr;
120  uint32_t ui32WrData;
121 
122  // Check the arguments.
123  ASSERT(DDIBaseValid(ui32Base));
124 
125  // 16-bit target is on 32-bit boundary so double offset.
126  ui32RegAddr = ui32Base + (ui32Reg << 1) + DDI_O_MASK16B;
127 
128  // Adjust for target bit in high half of the word.
129  if(ui32Shift >= 16)
130  {
131  ui32Shift = ui32Shift - 16;
132  ui32RegAddr += 4;
133  ui32Mask = ui32Mask >> 16;
134  }
135 
136  // Shift data in to position.
137  ui32WrData = ui32Data << ui32Shift;
138 
139  // Write data.
140  HWREG(ui32RegAddr) = (ui32Mask << 16) | ui32WrData;
141 }
#define ASSERT(expr)
Definition: debug.h:71

§ DDI16BitRead()

uint16_t DDI16BitRead ( uint32_t  ui32Base,
uint32_t  ui32Reg,
uint32_t  ui32Mask 
)

Read a bit via the DDI using 16-bit read.

Parameters
ui32Baseis the base address of the DDI module.
ui32Regis the register to read.
ui32Maskdefines the bit which should be read.
Returns
Returns a zero if bit selected by mask is '0'. Else returns the mask.

Referenced by DDI16SetValBit().

150 {
151  uint32_t ui32RegAddr;
152  uint16_t ui16Data;
153 
154  // Check the arguments.
155  ASSERT(DDIBaseValid(ui32Base));
156 
157  // Calculate the address of the register.
158  ui32RegAddr = ui32Base + ui32Reg + DDI_O_DIR;
159 
160  // Adjust for target bit in high half of the word.
161  if(ui32Mask & 0xFFFF0000)
162  {
163  ui32RegAddr += 2;
164  ui32Mask = ui32Mask >> 16;
165  }
166 
167  // Read a halfword on the DDI interface.
168  ui16Data = HWREGH(ui32RegAddr);
169 
170  // Mask data.
171  ui16Data = ui16Data & ui32Mask;
172 
173  // Return masked data.
174  return(ui16Data);
175 }
#define ASSERT(expr)
Definition: debug.h:71

§ DDI16BitWrite()

void DDI16BitWrite ( uint32_t  ui32Base,
uint32_t  ui32Reg,
uint32_t  ui32Mask,
uint32_t  ui32WrData 
)

Write a single bit using a 16-bit maskable write.

A '1' is written to the bit if ui32WrData is non-zero, else a '0' is written.

Parameters
ui32Baseis the base address of the DDI port.
ui32Regis register to access.
ui32Maskis the mask defining which of the 16 bit that should be overwritten.
ui32WrDatais the value to write. The value must be defined in the lower half of the 32 bits.
Returns
None

Referenced by DDI16SetValBit(), and OSCXHfPowerModeSet().

83 {
84  uint32_t ui32RegAddr;
85  uint32_t ui32Data;
86 
87  // Check the arguments.
88  ASSERT(DDIBaseValid(ui32Base));
89  ASSERT(!((ui32Mask & 0xFFFF0000) ^ (ui32Mask & 0x0000FFFF)));
90  ASSERT(!(ui32WrData & 0xFFFF0000));
91 
92  // DDI 16-bit target is on 32-bit boundary so double offset
93  ui32RegAddr = ui32Base + (ui32Reg << 1) + DDI_O_MASK16B;
94 
95  // Adjust for target bit in high half of the word.
96  if(ui32Mask & 0xFFFF0000)
97  {
98  ui32RegAddr += 4;
99  ui32Mask >>= 16;
100  }
101 
102  // Write mask if data is not zero (to set mask bit), else write '0'.
103  ui32Data = ui32WrData ? ui32Mask : 0x0;
104 
105  // Update the register.
106  HWREG(ui32RegAddr) = (ui32Mask << 16) | ui32Data;
107 }
#define ASSERT(expr)
Definition: debug.h:71

§ DDI16SetValBit()

static void DDI16SetValBit ( uint32_t  ui32Base,
uint32_t  ui32Reg,
bool  bWriteHigh,
uint32_t  ui32Mask,
uint32_t  ui32Val 
)
inlinestatic

Set a value on any 16 bits inside a 32 bit register aligned on a half-word boundary in the DDI slave.

This function allows 16 bit masked access to the DDI slave registers.

Use this function to write any value in the range 0-15 bits aligned on a half-word boundary. For example, for writing the value 0b101 to bits 1-3 set ui32Val = 0x000A and ui32Mask = 0x000E. Bits 0 and 5-15 will not be affected by the operation, as long as the corresponding bits are not set in the ui32Mask.

Parameters
ui32Baseis the base address of the DDI port.
ui32Regis register to access.
bWriteHighdefines which part of the register to write in.
ui32Maskis the mask defining which of the 16 bit that should be overwritten. The mask must be defined in the lower half of the 32 bits.
ui32Valis the value to write. The value must be defined in the lower half of the 32 bits.
Returns
None
307 {
308  uint32_t ui32RegOffset;
309 
310  // Check the arguments.
311  ASSERT(DDIBaseValid(ui32Base));
312  ASSERT(ui32Reg < DDI_SLAVE_REGS);
313  ASSERT(!(ui32Val & 0xFFFF0000));
314  ASSERT(!(ui32Mask & 0xFFFF0000));
315 
316  // Get the correct address of the first register used for setting bits
317  // in the DDI slave.
318  ui32RegOffset = DDI_O_MASK16B + (ui32Reg << 1) + (bWriteHigh ? 4 : 0);
319 
320  // Set the selected bits.
321  HWREG(ui32Base + ui32RegOffset) = (ui32Mask << 16) | ui32Val;
322 }
#define ASSERT(expr)
Definition: debug.h:71
#define DDI_SLAVE_REGS
Definition: ddi.h:95
Here is the call graph for this function:

§ DDI32BitsClear()

static void DDI32BitsClear ( uint32_t  ui32Base,
uint32_t  ui32Reg,
uint32_t  ui32Val 
)
inlinestatic

Clear specific bits in a 32 bit DDI register.

This function will clear bits in a register in the analog domain.

Parameters
ui32Baseis DDI base address.
ui32Regis the base registers to clear the bits in.
ui32Valis the 32 bit one-hot encoded value specifying which bits to clear in the register.
Returns
None
221 {
222  uint32_t ui32RegOffset;
223 
224  // Check the arguments.
225  ASSERT(DDIBaseValid(ui32Base));
226  ASSERT(ui32Reg < DDI_SLAVE_REGS);
227 
228  // Get the correct address of the first register used for setting bits
229  // in the DDI slave.
230  ui32RegOffset = DDI_O_CLR;
231 
232  // Clear the selected bits.
233  HWREG(ui32Base + ui32RegOffset + ui32Reg) = ui32Val;
234 }
#define ASSERT(expr)
Definition: debug.h:71
#define DDI_SLAVE_REGS
Definition: ddi.h:95

§ DDI32BitsSet()

static void DDI32BitsSet ( uint32_t  ui32Base,
uint32_t  ui32Reg,
uint32_t  ui32Val 
)
inlinestatic

Set specific bits in a DDI slave register.

This function will set bits in a register in the analog domain.

Note
This operation is write only for the specified register. This function is used to set bits in specific register in the DDI slave. Only bits in the selected register are affected by the operation.
Parameters
ui32Baseis DDI base address.
ui32Regis the base register to assert the bits in.
ui32Valis the 32 bit one-hot encoded value specifying which bits to set in the register.
Returns
None
189 {
190  uint32_t ui32RegOffset;
191 
192  // Check the arguments.
193  ASSERT(DDIBaseValid(ui32Base));
194  ASSERT(ui32Reg < DDI_SLAVE_REGS);
195 
196  // Get the correct address of the first register used for setting bits
197  // in the DDI slave.
198  ui32RegOffset = DDI_O_SET;
199 
200  // Set the selected bits.
201  HWREG(ui32Base + ui32RegOffset + ui32Reg) = ui32Val;
202 }
#define ASSERT(expr)
Definition: debug.h:71
#define DDI_SLAVE_REGS
Definition: ddi.h:95

§ DDI32RegRead()

static uint32_t DDI32RegRead ( uint32_t  ui32Base,
uint32_t  ui32Reg 
)
inlinestatic

Read the value in a 32 bit register.

This function will read a register in the analog domain and return the value as an uint32_t.

Parameters
ui32Baseis DDI base address.
ui32Regis the 32 bit register to read.
Returns
Returns the 32 bit value of the analog register.
159 {
160  // Check the arguments.
161  ASSERT(DDIBaseValid(ui32Base));
162  ASSERT(ui32Reg < DDI_SLAVE_REGS);
163 
164  // Read the register and return the value.
165  return(HWREG(ui32Base + ui32Reg));
166 }
#define ASSERT(expr)
Definition: debug.h:71
#define DDI_SLAVE_REGS
Definition: ddi.h:95

§ DDI32RegWrite()

void DDI32RegWrite ( uint32_t  ui32Base,
uint32_t  ui32Reg,
uint32_t  ui32Val 
)

Write a 32 bit value to a register in the DDI slave.

This function will write a value to a register in the analog domain.

Note
This operation is write only for the specified register. No conservation of the previous value of the register will be kept (i.e. this is NOT read-modify-write on the register).
Parameters
ui32Baseis DDI base address.
ui32Regis the register to write.
ui32Valis the 32 bit value to write to the register.
Returns
None

Referenced by DDI16SetValBit(), OSC_AdjustXoscHfCapArray(), and SetupAfterColdResetWakeupFromShutDownCfg2().

66 {
67  // Check the arguments.
68  ASSERT(DDIBaseValid(ui32Base));
69  ASSERT(ui32Reg < DDI_SLAVE_REGS);
70 
71  // Write the value to the register.
72  HWREG(ui32Base + ui32Reg) = ui32Val;
73 }
#define ASSERT(expr)
Definition: debug.h:71
#define DDI_SLAVE_REGS
Definition: ddi.h:95

§ DDI8SetValBit()

static void DDI8SetValBit ( uint32_t  ui32Base,
uint32_t  ui32Reg,
uint32_t  ui32Byte,
uint16_t  ui16Mask,
uint16_t  ui16Val 
)
inlinestatic

Set a value on any 8 bits inside a 32 bit register in the DDI slave.

This function allows byte (8 bit access) to the DDI slave registers.

Use this function to write any value in the range 0-7 bits aligned on a byte boundary. For example, for writing the value 0b101 to bits 1-3 set ui16Val = 0x0A and ui16Mask = 0x0E. Bits 0 and 5-7 will not be affected by the operation, as long as the corresponding bits are not set in the ui16Mask.

Parameters
ui32Baseis the base address of the DDI port.
ui32Regis the Least Significant Register in the DDI slave that will be affected by the write operation.
ui32Byteis the byte number to access within the 32 bit register.
ui16Maskis the mask defining which of the 8 bits that should be overwritten. The mask must be defined in the lower half of the 16 bits.
ui16Valis the value to write. The value must be defined in the lower half of the 16 bits.
Returns
None
263 {
264  uint32_t ui32RegOffset;
265 
266  // Check the arguments.
267  ASSERT(DDIBaseValid(ui32Base));
268  ASSERT(ui32Reg < DDI_SLAVE_REGS);
269  ASSERT(!(ui16Val & 0xFF00));
270  ASSERT(!(ui16Mask & 0xFF00));
271 
272  // Get the correct address of the first register used for setting bits
273  // in the DDI slave.
274  ui32RegOffset = DDI_O_MASK8B + (ui32Reg << 1) + (ui32Byte << 1);
275 
276  // Set the selected bits.
277  HWREGH(ui32Base + ui32RegOffset) = (ui16Mask << 8) | ui16Val;
278 }
#define ASSERT(expr)
Definition: debug.h:71
#define DDI_SLAVE_REGS
Definition: ddi.h:95

Macro Definition Documentation

§ DDI_ACK

#define DDI_ACK   0x00000001

§ DDI_PROTECT

#define DDI_PROTECT   0x00000080

§ DDI_SLAVE_REGS

#define DDI_SLAVE_REGS   64

§ DDI_SYNC

#define DDI_SYNC   0x00000000