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

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 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 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 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.

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.

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  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. 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
310 {
311  uint32_t ui32RegOffset;
312 
313  // Check the arguments.
314  ASSERT(DDIBaseValid(ui32Base));
315  ASSERT(ui32Reg < DDI_SLAVE_REGS);
316  ASSERT(!(ui32Val & 0xFFFF0000));
317  ASSERT(!(ui32Mask & 0xFFFF0000));
318 
319  // Get the correct address of the first register used for setting bits
320  // in the DDI slave.
321  ui32RegOffset = DDI_O_MASK16B + (ui32Reg << 1) + (bWriteHigh ? 4 : 0);
322 
323  // Set the selected bits.
324  HWREG(ui32Base + ui32RegOffset) = (ui32Mask << 16) | ui32Val;
325 }
#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.

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
224 {
225  uint32_t ui32RegOffset;
226 
227  // Check the arguments.
228  ASSERT(DDIBaseValid(ui32Base));
229  ASSERT(ui32Reg < DDI_SLAVE_REGS);
230 
231  // Get the correct address of the first register used for setting bits
232  // in the DDI slave.
233  ui32RegOffset = DDI_O_CLR;
234 
235  // Clear the selected bits.
236  HWREG(ui32Base + ui32RegOffset + ui32Reg) = ui32Val;
237 }
#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.
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
192 {
193  uint32_t ui32RegOffset;
194 
195  // Check the arguments.
196  ASSERT(DDIBaseValid(ui32Base));
197  ASSERT(ui32Reg < DDI_SLAVE_REGS);
198 
199  // Get the correct address of the first register used for setting bits
200  // in the DDI slave.
201  ui32RegOffset = DDI_O_SET;
202 
203  // Set the selected bits.
204  HWREG(ui32Base + ui32RegOffset + ui32Reg) = ui32Val;
205 }
#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.

Parameters
ui32Baseis DDI base address.
ui32Regis the 32 bit register to read.
Returns
Returns the 32 bit value of the analog register.
162 {
163  // Check the arguments.
164  ASSERT(DDIBaseValid(ui32Base));
165  ASSERT(ui32Reg < DDI_SLAVE_REGS);
166 
167  // Read the register and return the value.
168  return(HWREG(ui32Base + ui32Reg));
169 }
#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).
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. 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
266 {
267  uint32_t ui32RegOffset;
268 
269  // Check the arguments.
270  ASSERT(DDIBaseValid(ui32Base));
271  ASSERT(ui32Reg < DDI_SLAVE_REGS);
272  ASSERT(!(ui16Val & 0xFF00));
273  ASSERT(!(ui16Mask & 0xFF00));
274 
275  // Get the correct address of the first register used for setting bits
276  // in the DDI slave.
277  ui32RegOffset = DDI_O_MASK8B + (ui32Reg << 1) + (ui32Byte << 1);
278 
279  // Set the selected bits.
280  HWREGH(ui32Base + ui32RegOffset) = (ui16Mask << 8) | ui16Val;
281 }
#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