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

Functions

static void AuxAdiDdiSafeWrite (uint32_t nAddr, uint32_t nData, uint32_t nSize)
 Safely write to AUX ADI/DDI interfaces using a semaphore. More...
 
static uint32_t AuxAdiDdiSafeRead (uint32_t nAddr, uint32_t nSize)
 Safely read from AUX ADI/DDI interfaces using a semaphore. More...
 
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:

AUX access using semaphores (used by both ADI and DDI APIs when necessary):

Function Documentation

static uint32_t AuxAdiDdiSafeRead ( uint32_t  nAddr,
uint32_t  nSize 
)
inlinestatic

Safely read from AUX ADI/DDI interfaces using a semaphore.

Note
Both the AUX module and the clock for the AUX SMPH module must be enabled before calling this function.
Parameters
nAddris the register address.
nSizeis the register access size in bytes.
Returns
Returns the data read.

Referenced by ADI16RegRead(), ADI32RegRead(), ADI8RegRead(), DDI16BitfieldRead(), DDI16BitRead(), and DDI32RegRead().

170 {
171  uint32_t nRet;
172  // Disable interrupts and remember whether to re-enable
173  bool bIrqEnabled = !CPUcpsid();
174  // Acquire semaphore for accessing ADI/DDI in AUX, perform access, release semaphore
175  while (!HWREG(AUX_SMPH_BASE + AUX_SMPH_O_SMPH0));
176  switch (nSize) {
177  case 1: nRet = HWREGB(nAddr); break;
178  case 2: nRet = HWREGH(nAddr); break;
179  case 4: default: nRet = HWREG(nAddr); break;
180  }
181  HWREG(AUX_SMPH_BASE + AUX_SMPH_O_SMPH0) = 1;
182  // Restore interrupt enable
183  if (bIrqEnabled) {
184  CPUcpsie();
185  }
186  return nRet;
187 }
uint32_t CPUcpsid(void)
Disable all external interrupts.
Definition: cpu.c:68
uint32_t CPUcpsie(void)
Enable all external interrupts.
Definition: cpu.c:206

Here is the call graph for this function:

static void AuxAdiDdiSafeWrite ( uint32_t  nAddr,
uint32_t  nData,
uint32_t  nSize 
)
inlinestatic

Safely write to AUX ADI/DDI interfaces using a semaphore.

Note
Both the AUX module and the clock for the AUX SMPH module must be enabled before calling this function.
Parameters
nAddris the register address.
nDatais the data to write to the register.
nSizeis the register access size in bytes.
Returns
None

Referenced by ADI16BitsClear(), ADI16BitsSet(), ADI16RegWrite(), ADI16SetValBit(), ADI32BitsClear(), ADI32BitsSet(), ADI32RegWrite(), ADI4SetValBit(), ADI8BitsClear(), ADI8BitsSet(), ADI8RegWrite(), ADI8SetValBit(), DDI16BitfieldWrite(), DDI16BitWrite(), DDI16SetValBit(), DDI32BitsClear(), DDI32BitsSet(), DDI32RegWrite(), and DDI8SetValBit().

138 {
139  // Disable interrupts and remember whether to re-enable
140  bool bIrqEnabled = !CPUcpsid();
141  // Acquire semaphore for accessing ADI/DDI in AUX, perform access, release semaphore
142  while (!HWREG(AUX_SMPH_BASE + AUX_SMPH_O_SMPH0));
143  switch (nSize) {
144  case 1: HWREGB(nAddr) = (uint8_t)nData; break;
145  case 2: HWREGH(nAddr) = (uint16_t)nData; break;
146  case 4: default: HWREG(nAddr) = nData; break;
147  }
148  HWREG(AUX_SMPH_BASE + AUX_SMPH_O_SMPH0) = 1;
149  // Restore interrupt enable
150  if (bIrqEnabled) {
151  CPUcpsie();
152  }
153 }
uint32_t CPUcpsid(void)
Disable all external interrupts.
Definition: cpu.c:68
uint32_t CPUcpsie(void)
Enable all external interrupts.
Definition: cpu.c:206

Here is the call graph for this function:

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.

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.
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 = AuxAdiDdiSafeRead(ui32RegAddr, 2);
207 
208  // Mask data and shift into place.
209  ui16Data &= ui32Mask;
210  ui16Data >>= ui32Shift;
211 
212  // Return data.
213  return(ui16Data);
214 }
static uint32_t AuxAdiDdiSafeRead(uint32_t nAddr, uint32_t nSize)
Safely read from AUX ADI/DDI interfaces using a semaphore.
Definition: ddi.h:169
#define ASSERT(expr)
Definition: debug.h:73

Here is the call graph for this function:

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.

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.
ui32Shiftis the shift value for the bit field.
ui32Datais the data aligned to bit 0.
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  AuxAdiDdiSafeWrite(ui32RegAddr, (ui32Mask << 16) | ui32WrData, 4);
143 }
#define ASSERT(expr)
Definition: debug.h:73
static void AuxAdiDdiSafeWrite(uint32_t nAddr, uint32_t nData, uint32_t nSize)
Safely write to AUX ADI/DDI interfaces using a semaphore.
Definition: ddi.h:137

Here is the call graph for this function:

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 = AuxAdiDdiSafeRead(ui32RegAddr, 2);
171 
172  // Mask data.
173  ui16Data = ui16Data & ui32Mask;
174 
175  // Return masked data.
176  return(ui16Data);
177 }
static uint32_t AuxAdiDdiSafeRead(uint32_t nAddr, uint32_t nSize)
Safely read from AUX ADI/DDI interfaces using a semaphore.
Definition: ddi.h:169
#define ASSERT(expr)
Definition: debug.h:73

Here is the call graph for this function:

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.
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  AuxAdiDdiSafeWrite(ui32RegAddr, (ui32Mask << 16) | ui32Data, 4);
109 }
#define ASSERT(expr)
Definition: debug.h:73
static void AuxAdiDdiSafeWrite(uint32_t nAddr, uint32_t nData, uint32_t nSize)
Safely write to AUX ADI/DDI interfaces using a semaphore.
Definition: ddi.h:137

Here is the call graph for this function:

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.

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
392 {
393  uint32_t ui32RegOffset;
394 
395  // Check the arguments.
396  ASSERT(DDIBaseValid(ui32Base));
397  ASSERT(ui32Reg < DDI_SLAVE_REGS);
398  ASSERT(!(ui32Val & 0xFFFF0000));
399  ASSERT(!(ui32Mask & 0xFFFF0000));
400 
401  // Get the correct address of the first register used for setting bits
402  // in the DDI slave.
403  ui32RegOffset = DDI_O_MASK16B + (ui32Reg << 1) + (bWriteHigh ? 4 : 0);
404 
405  // Set the selected bits.
406  AuxAdiDdiSafeWrite(ui32Base + ui32RegOffset, (ui32Mask << 16) | ui32Val, 4);
407 }
#define ASSERT(expr)
Definition: debug.h:73
#define DDI_SLAVE_REGS
Definition: ddi.h:97
static void AuxAdiDdiSafeWrite(uint32_t nAddr, uint32_t nData, uint32_t nSize)
Safely write to AUX ADI/DDI interfaces using a semaphore.
Definition: ddi.h:137

Here is the call graph for this function:

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
300 {
301  uint32_t ui32RegOffset;
302 
303  // Check the arguments.
304  ASSERT(DDIBaseValid(ui32Base));
305  ASSERT(ui32Reg < DDI_SLAVE_REGS);
306 
307  // Get the correct address of the first register used for setting bits
308  // in the DDI slave.
309  ui32RegOffset = DDI_O_CLR;
310 
311  // Clear the selected bits.
312  AuxAdiDdiSafeWrite(ui32Base + ui32RegOffset + ui32Reg, ui32Val, 4);
313 }
#define ASSERT(expr)
Definition: debug.h:73
#define DDI_SLAVE_REGS
Definition: ddi.h:97
static void AuxAdiDdiSafeWrite(uint32_t nAddr, uint32_t nData, uint32_t nSize)
Safely write to AUX ADI/DDI interfaces using a semaphore.
Definition: ddi.h:137

Here is the call graph for this function:

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
265 {
266  uint32_t ui32RegOffset;
267 
268  // Check the arguments.
269  ASSERT(DDIBaseValid(ui32Base));
270  ASSERT(ui32Reg < DDI_SLAVE_REGS);
271 
272  // Get the correct address of the first register used for setting bits
273  // in the DDI slave.
274  ui32RegOffset = DDI_O_SET;
275 
276  // Set the selected bits.
277  AuxAdiDdiSafeWrite(ui32Base + ui32RegOffset + ui32Reg, ui32Val, 4);
278 }
#define ASSERT(expr)
Definition: debug.h:73
#define DDI_SLAVE_REGS
Definition: ddi.h:97
static void AuxAdiDdiSafeWrite(uint32_t nAddr, uint32_t nData, uint32_t nSize)
Safely write to AUX ADI/DDI interfaces using a semaphore.
Definition: ddi.h:137

Here is the call graph for this function:

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.
232 {
233  // Check the arguments.
234  ASSERT(DDIBaseValid(ui32Base));
235  ASSERT(ui32Reg < DDI_SLAVE_REGS);
236 
237  // Read the register and return the value.
238  return AuxAdiDdiSafeRead(ui32Base + ui32Reg, 4);
239 }
static uint32_t AuxAdiDdiSafeRead(uint32_t nAddr, uint32_t nSize)
Safely read from AUX ADI/DDI interfaces using a semaphore.
Definition: ddi.h:169
#define ASSERT(expr)
Definition: debug.h:73
#define DDI_SLAVE_REGS
Definition: ddi.h:97

Here is the call graph for this function:

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  AuxAdiDdiSafeWrite(ui32Base + ui32Reg, ui32Val, 4);
75 }
#define ASSERT(expr)
Definition: debug.h:73
#define DDI_SLAVE_REGS
Definition: ddi.h:97
static void AuxAdiDdiSafeWrite(uint32_t nAddr, uint32_t nData, uint32_t nSize)
Safely write to AUX ADI/DDI interfaces using a semaphore.
Definition: ddi.h:137

Here is the call graph for this function:

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.

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
345 {
346  uint32_t ui32RegOffset;
347 
348  // Check the arguments.
349  ASSERT(DDIBaseValid(ui32Base));
350  ASSERT(ui32Reg < DDI_SLAVE_REGS);
351  ASSERT(!(ui16Val & 0xFF00));
352  ASSERT(!(ui16Mask & 0xFF00));
353 
354  // Get the correct address of the first register used for setting bits
355  // in the DDI slave.
356  ui32RegOffset = DDI_O_MASK8B + (ui32Reg << 1) + (ui32Byte << 1);
357 
358  // Set the selected bits.
359  AuxAdiDdiSafeWrite(ui32Base + ui32RegOffset, (ui16Mask << 8) | ui16Val, 2);
360 }
#define ASSERT(expr)
Definition: debug.h:73
#define DDI_SLAVE_REGS
Definition: ddi.h:97
static void AuxAdiDdiSafeWrite(uint32_t nAddr, uint32_t nData, uint32_t nSize)
Safely write to AUX ADI/DDI interfaces using a semaphore.
Definition: ddi.h:137

Here is the call graph for this function:

Macro Definition Documentation

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