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 bitfield via the DDI using 16-bit read. More...
 

Detailed Description

Introduction


API

The API functions can be grouped like this:

Write:

Read:

Function Documentation

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

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

Requires that bit fields do not space the low/high word boundary.

Note
Both the AUX module and the clock for the AUX SMPH module must be enabled before calling this function.
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. The mask must be defined in the lower half of the 32 bits.
ui32Shiftdefines the required shift of the data to align with bit 0.
Returns
Returns data aligned to bit 0.

Referenced by OSCClockSourceGet(), and OSCHfSourceReady().

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

Note
Both the AUX module and the clock for the AUX SMPH module must be enabled before calling this function.
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. The mask must be defined in the lower half of the 32 bits.
ui32Shift
ui32Data
Returns
None

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

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

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

Note
Both the AUX module and the clock for the AUX SMPH module must be enabled before calling this function.
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.
152 {
153  uint32_t ui32RegAddr;
154  uint16_t ui16Data;
155 
156  // Check the arguments.
157  ASSERT(DDIBaseValid(ui32Base));
158 
159  // Calculate the address of the register.
160  ui32RegAddr = ui32Base + ui32Reg + DDI_O_DIR;
161 
162  // Adjust for target bit in high half of the word.
163  if(ui32Mask & 0xFFFF0000)
164  {
165  ui32RegAddr += 2;
166  ui32Mask = ui32Mask >> 16;
167  }
168 
169  // Read a halfword on the DDI interface.
170  ui16Data = HWREGH(ui32RegAddr);
171 
172  // Mask data.
173  ui16Data = ui16Data & ui32Mask;
174 
175  // Return masked data.
176  return(ui16Data);
177 }
#define ASSERT(expr)
Definition: debug.h:73
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.

Note
Both the AUX module and the clock for the AUX SMPH module must be enabled before calling this function.
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. The mask must be defined in the lower half of the 32 bits.
ui32WrDatais the value to write. The value must be defined in the lower half of the 32 bits.
Returns
None

Referenced by OSCXHfPowerModeSet().

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

Note
Both the AUX module and the clock for the AUX SMPH module must be enabled before calling this function.
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
325 {
326  uint32_t ui32RegOffset;
327 
328  // Check the arguments.
329  ASSERT(DDIBaseValid(ui32Base));
330  ASSERT(ui32Reg < DDI_SLAVE_REGS);
331  ASSERT(!(ui32Val & 0xFFFF0000));
332  ASSERT(!(ui32Mask & 0xFFFF0000));
333 
334  // Get the correct address of the first register used for setting bits
335  // in the DDI slave.
336  ui32RegOffset = DDI_O_MASK16B + (ui32Reg << 1) + (bWriteHigh ? 4 : 0);
337 
338  // Set the selected bits.
339  HWREG(ui32Base + ui32RegOffset) = (ui32Mask << 16) | ui32Val;
340 }
#define ASSERT(expr)
Definition: debug.h:73
#define DDI_SLAVE_REGS
Definition: ddi.h:97
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.

Note
Both the AUX module and the clock for the AUX SMPH module must be enabled before calling this function.
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
233 {
234  uint32_t ui32RegOffset;
235 
236  // Check the arguments.
237  ASSERT(DDIBaseValid(ui32Base));
238  ASSERT(ui32Reg < DDI_SLAVE_REGS);
239 
240  // Get the correct address of the first register used for setting bits
241  // in the DDI slave.
242  ui32RegOffset = DDI_O_CLR;
243 
244  // Clear the selected bits.
245  HWREG(ui32Base + ui32RegOffset + ui32Reg) = ui32Val;
246 }
#define ASSERT(expr)
Definition: debug.h:73
#define DDI_SLAVE_REGS
Definition: ddi.h:97
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.
Both the AUX module and the clock for the AUX SMPH module must be enabled before calling this function.
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
198 {
199  uint32_t ui32RegOffset;
200 
201  // Check the arguments.
202  ASSERT(DDIBaseValid(ui32Base));
203  ASSERT(ui32Reg < DDI_SLAVE_REGS);
204 
205  // Get the correct address of the first register used for setting bits
206  // in the DDI slave.
207  ui32RegOffset = DDI_O_SET;
208 
209  // Set the selected bits.
210  HWREG(ui32Base + ui32RegOffset + ui32Reg) = ui32Val;
211 }
#define ASSERT(expr)
Definition: debug.h:73
#define DDI_SLAVE_REGS
Definition: ddi.h:97
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.

Note
Both the AUX module and the clock for the AUX SMPH module must be enabled before calling this function.
Parameters
ui32Baseis DDI base address.
ui32Regis the 32 bit register to read.
Returns
Returns the 32 bit value of the analog register.
165 {
166  // Check the arguments.
167  ASSERT(DDIBaseValid(ui32Base));
168  ASSERT(ui32Reg < DDI_SLAVE_REGS);
169 
170  // Read the register and return the value.
171  return(HWREG(ui32Base + ui32Reg));
172 }
#define ASSERT(expr)
Definition: debug.h:73
#define DDI_SLAVE_REGS
Definition: ddi.h:97
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).
Both the AUX module and the clock for the AUX SMPH module must be enabled before calling this function.
Parameters
ui32Baseis DDI base address.
ui32Regis the register to write.
ui32Valis the 32 bit value to write to the register.
Returns
None

Referenced by OSC_AdjustXoscHfCapArray(), and SetupAfterColdResetWakeupFromShutDownCfg2().

68 {
69  // Check the arguments.
70  ASSERT(DDIBaseValid(ui32Base));
71  ASSERT(ui32Reg < DDI_SLAVE_REGS);
72 
73  // Write the value to the register.
74  HWREG(ui32Base + ui32Reg) = ui32Val;
75 }
#define ASSERT(expr)
Definition: debug.h:73
#define DDI_SLAVE_REGS
Definition: ddi.h:97
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. Fx. 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.

Note
Both the AUX module and the clock for the AUX SMPH module must be enabled before calling this function.
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
278 {
279  uint32_t ui32RegOffset;
280 
281  // Check the arguments.
282  ASSERT(DDIBaseValid(ui32Base));
283  ASSERT(ui32Reg < DDI_SLAVE_REGS);
284  ASSERT(!(ui16Val & 0xFF00));
285  ASSERT(!(ui16Mask & 0xFF00));
286 
287  // Get the correct address of the first register used for setting bits
288  // in the DDI slave.
289  ui32RegOffset = DDI_O_MASK8B + (ui32Reg << 1) + (ui32Byte << 1);
290 
291  // Set the selected bits.
292  HWREGH(ui32Base + ui32RegOffset) = (ui16Mask << 8) | ui16Val;
293 }
#define ASSERT(expr)
Definition: debug.h:73
#define DDI_SLAVE_REGS
Definition: ddi.h:97

Macro Definition Documentation

#define DDI_ACK   0x00000001
#define DDI_PROTECT   0x00000080
#define DDI_SLAVE_REGS   64
#define DDI_SYNC   0x00000000