IDAC - Current DAC
Description
Current Digital-to-Analog Converter (IDAC) Peripheral API.
IDAC can source or sink a configurable constant current, which can be output on, or sinked from pin or ADC. Current is configurable with several ranges of various step sizes. IDAC can be used with PRS and can operate down to EM3.
The following steps are necessary for basic operation:
Clock enable:
Initialize peripheral with default settings and modify selected fields, such as output select:
Set output:
Data Structures |
|
| struct | IDAC_Init_TypeDef |
|
IDAC initialization structure, common for both channels.
|
|
Functions |
|
| void | IDAC_Init (IDAC_TypeDef *idac, const IDAC_Init_TypeDef *init) |
|
Initialize IDAC.
|
|
| void | IDAC_Enable (IDAC_TypeDef *idac, bool enable) |
|
Enable/disable IDAC.
|
|
| void | IDAC_Reset (IDAC_TypeDef *idac) |
|
Reset IDAC to the same state that it was in after a hardware reset.
|
|
| void | IDAC_MinimalOutputTransitionMode (IDAC_TypeDef *idac, bool enable) |
|
Enable/disable Minimal Output Transition mode.
|
|
| void | IDAC_RangeSet (IDAC_TypeDef *idac, const IDAC_Range_TypeDef range) |
|
Set the current range of the IDAC output.
|
|
| void | IDAC_StepSet (IDAC_TypeDef *idac, const uint32_t step) |
|
Set the current step of the IDAC output.
|
|
| void | IDAC_OutEnable (IDAC_TypeDef *idac, bool enable) |
|
Enable/disable the IDAC OUT pin.
|
|
| void | IDAC_IntClear (IDAC_TypeDef *idac, uint32_t flags) |
|
Clear one or more pending IDAC interrupts.
|
|
| void | IDAC_IntDisable (IDAC_TypeDef *idac, uint32_t flags) |
|
Disable one or more IDAC interrupts.
|
|
| void | IDAC_IntEnable (IDAC_TypeDef *idac, uint32_t flags) |
|
Enable one or more IDAC interrupts.
|
|
| uint32_t | IDAC_IntGet (IDAC_TypeDef *idac) |
|
Get pending IDAC interrupt flags.
|
|
| uint32_t | IDAC_IntGetEnabled (IDAC_TypeDef *idac) |
|
Get enabled and pending IDAC interrupt flags.
|
|
| void | IDAC_IntSet (IDAC_TypeDef *idac, uint32_t flags) |
|
Set one or more pending IDAC interrupts from SW.
|
|
Macros |
|
| #define | IDAC_INIT_DEFAULT |
|
Default configuration for IDAC initialization structure.
|
|
Enumerations |
|
| enum |
IDAC_OutMode_TypeDef
{
idacOutputAPORT1XCH0 = IDAC_CTRL_APORTOUTSEL_APORT1XCH0, idacOutputAPORT1YCH1 = IDAC_CTRL_APORTOUTSEL_APORT1YCH1, idacOutputAPORT1XCH2 = IDAC_CTRL_APORTOUTSEL_APORT1XCH2, idacOutputAPORT1YCH3 = IDAC_CTRL_APORTOUTSEL_APORT1YCH3, idacOutputAPORT1XCH4 = IDAC_CTRL_APORTOUTSEL_APORT1XCH4, idacOutputAPORT1YCH5 = IDAC_CTRL_APORTOUTSEL_APORT1YCH5, idacOutputAPORT1XCH6 = IDAC_CTRL_APORTOUTSEL_APORT1XCH6, idacOutputAPORT1YCH7 = IDAC_CTRL_APORTOUTSEL_APORT1YCH7, idacOutputAPORT1XCH8 = IDAC_CTRL_APORTOUTSEL_APORT1XCH8, idacOutputAPORT1YCH9 = IDAC_CTRL_APORTOUTSEL_APORT1YCH9, idacOutputAPORT1XCH10 = IDAC_CTRL_APORTOUTSEL_APORT1XCH10, idacOutputAPORT1YCH11 = IDAC_CTRL_APORTOUTSEL_APORT1YCH11, idacOutputAPORT1XCH12 = IDAC_CTRL_APORTOUTSEL_APORT1XCH12, idacOutputAPORT1YCH13 = IDAC_CTRL_APORTOUTSEL_APORT1YCH13, idacOutputAPORT1XCH14 = IDAC_CTRL_APORTOUTSEL_APORT1XCH14, idacOutputAPORT1YCH15 = IDAC_CTRL_APORTOUTSEL_APORT1YCH15, idacOutputAPORT1XCH16 = IDAC_CTRL_APORTOUTSEL_APORT1XCH16, idacOutputAPORT1YCH17 = IDAC_CTRL_APORTOUTSEL_APORT1YCH17, idacOutputAPORT1XCH18 = IDAC_CTRL_APORTOUTSEL_APORT1XCH18, idacOutputAPORT1YCH19 = IDAC_CTRL_APORTOUTSEL_APORT1YCH19, idacOutputAPORT1XCH20 = IDAC_CTRL_APORTOUTSEL_APORT1XCH20, idacOutputAPORT1YCH21 = IDAC_CTRL_APORTOUTSEL_APORT1YCH21, idacOutputAPORT1XCH22 = IDAC_CTRL_APORTOUTSEL_APORT1XCH22, idacOutputAPORT1YCH23 = IDAC_CTRL_APORTOUTSEL_APORT1YCH23, idacOutputAPORT1XCH24 = IDAC_CTRL_APORTOUTSEL_APORT1XCH24, idacOutputAPORT1YCH25 = IDAC_CTRL_APORTOUTSEL_APORT1YCH25, idacOutputAPORT1XCH26 = IDAC_CTRL_APORTOUTSEL_APORT1XCH26, idacOutputAPORT1YCH27 = IDAC_CTRL_APORTOUTSEL_APORT1YCH27, idacOutputAPORT1XCH28 = IDAC_CTRL_APORTOUTSEL_APORT1XCH28, idacOutputAPORT1YCH29 = IDAC_CTRL_APORTOUTSEL_APORT1YCH29, idacOutputAPORT1XCH30 = IDAC_CTRL_APORTOUTSEL_APORT1XCH30, idacOutputAPORT1YCH31 = IDAC_CTRL_APORTOUTSEL_APORT1YCH31 } |
|
Output mode.
|
|
| enum |
IDAC_PRSSEL_TypeDef
{
idacPRSSELCh0 = IDAC_CTRL_PRSSEL_PRSCH0, idacPRSSELCh1 = IDAC_CTRL_PRSSEL_PRSCH1, idacPRSSELCh2 = IDAC_CTRL_PRSSEL_PRSCH2, idacPRSSELCh3 = IDAC_CTRL_PRSSEL_PRSCH3, idacPRSSELCh4 = IDAC_CTRL_PRSSEL_PRSCH4, idacPRSSELCh5 = IDAC_CTRL_PRSSEL_PRSCH5, idacPRSSELCh6 = IDAC_CTRL_PRSSEL_PRSCH6, idacPRSSELCh7 = IDAC_CTRL_PRSSEL_PRSCH7, idacPRSSELCh8 = IDAC_CTRL_PRSSEL_PRSCH8, idacPRSSELCh9 = IDAC_CTRL_PRSSEL_PRSCH9, idacPRSSELCh10 = IDAC_CTRL_PRSSEL_PRSCH10, idacPRSSELCh11 = IDAC_CTRL_PRSSEL_PRSCH11 } |
|
Selects which Peripheral Reflex System (PRS) signal to use when PRS is set to control IDAC output.
|
|
| enum |
IDAC_Range_TypeDef
{
idacCurrentRange0 = IDAC_CURPROG_RANGESEL_RANGE0, idacCurrentRange1 = IDAC_CURPROG_RANGESEL_RANGE1, idacCurrentRange2 = IDAC_CURPROG_RANGESEL_RANGE2, idacCurrentRange3 = IDAC_CURPROG_RANGESEL_RANGE3 } |
|
Selects which current range to use.
|
|
Function Documentation
◆ IDAC_Init()
| void IDAC_Init | ( | IDAC_TypeDef * |
idac,
|
| const IDAC_Init_TypeDef * |
init
|
||
| ) |
Initialize IDAC.
Initializes IDAC according to the initialization structure parameter and sets the default calibration value stored in the DEVINFO structure.
- Note
- This function will disable IDAC prior to configuration.
- Parameters
-
[in] idacA pointer to the IDAC peripheral register block. [in] initA pointer to the IDAC initialization structure.
◆ IDAC_Enable()
| void IDAC_Enable | ( | IDAC_TypeDef * |
idac,
|
| bool |
enable
|
||
| ) |
Enable/disable IDAC.
- Parameters
-
[in] idacA pointer to the IDAC peripheral register block. [in] enableTrue to enable IDAC, false to disable.
◆ IDAC_Reset()
| void IDAC_Reset | ( | IDAC_TypeDef * |
idac
|
) |
Reset IDAC to the same state that it was in after a hardware reset.
- Parameters
-
[in] idacA pointer to the IDAC peripheral register block.
◆ IDAC_MinimalOutputTransitionMode()
| void IDAC_MinimalOutputTransitionMode | ( | IDAC_TypeDef * |
idac,
|
| bool |
enable
|
||
| ) |
Enable/disable Minimal Output Transition mode.
- Parameters
-
[in] idacA pointer to the IDAC peripheral register block. [in] enableTrue to enable Minimal Output Transition mode, false to disable.
◆ IDAC_RangeSet()
| void IDAC_RangeSet | ( | IDAC_TypeDef * |
idac,
|
| const IDAC_Range_TypeDef |
range
|
||
| ) |
Set the current range of the IDAC output.
This function sets the current range of the IDAC output. The function also updates the IDAC calibration register (IDAC_CAL) with the default calibration value from DEVINFO (factory calibration) corresponding to the specified range.
- Parameters
-
[in] idacA pointer to the IDAC peripheral register block. [in] rangeThe current range value.
◆ IDAC_StepSet()
| void IDAC_StepSet | ( | IDAC_TypeDef * |
idac,
|
| const uint32_t |
step
|
||
| ) |
Set the current step of the IDAC output.
- Parameters
-
[in] idacA pointer to the IDAC peripheral register block. [in] stepA step value for the IDAC output. A valid range is 0-31.
◆ IDAC_OutEnable()
| void IDAC_OutEnable | ( | IDAC_TypeDef * |
idac,
|
| bool |
enable
|
||
| ) |
Enable/disable the IDAC OUT pin.
- Parameters
-
[in] idacA pointer to the IDAC peripheral register block. [in] enableTrue to enable the IDAC OUT pin, false to disable.
◆ IDAC_IntClear()
|
inline |
Clear one or more pending IDAC interrupts.
- Parameters
-
[in] idacPointer to IDAC peripheral register block. [in] flagsPending IDAC interrupt source(s) to clear. Use one or more valid interrupt flags for the IDAC module (IDAC_IF_nnn) OR'ed together.
◆ IDAC_IntDisable()
|
inline |
Disable one or more IDAC interrupts.
- Parameters
-
[in] idacPointer to IDAC peripheral register block. [in] flagsIDAC interrupt source(s) to disable. Use one or more valid interrupt flags for the IDAC module (IDAC_IF_nnn) OR'ed together.
◆ IDAC_IntEnable()
|
inline |
Enable one or more IDAC interrupts.
- Note
- Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. To ignore a pending interrupt, consider using IDAC_IntClear() prior to enabling the interrupt.
- Parameters
-
[in] idacPointer to IDAC peripheral register block. [in] flagsIDAC interrupt source(s) to enable. Use one or more valid interrupt flags for IDAC module (IDAC_IF_nnn) OR'ed together.
◆ IDAC_IntGet()
|
inline |
Get pending IDAC interrupt flags.
- Note
- Event bits are not cleared by the use of this function.
- Parameters
-
[in] idacPointer to IDAC peripheral register block.
- Returns
- IDAC interrupt source(s) pending. Returns one or more valid interrupt flags for IDAC module (IDAC_IF_nnn) OR'ed together.
◆ IDAC_IntGetEnabled()
|
inline |
Get enabled and pending IDAC interrupt flags.
Useful for handling more interrupt sources in the same interrupt handler.
- Parameters
-
[in] idacPointer to IDAC peripheral register block.
- Note
- Interrupt flags are not cleared by the use of this function.
- Returns
-
Pending and enabled IDAC interrupt sources. Return value is the bitwise AND combination of
- the OR combination of enabled interrupt sources in IDACx_IEN_nnn register (IDACx_IEN_nnn) and
- the OR combination of valid interrupt flags of IDAC module (IDACx_IF_nnn).
◆ IDAC_IntSet()
|
inline |
Set one or more pending IDAC interrupts from SW.
- Parameters
-
[in] idacPointer to IDAC peripheral register block. [in] flagsIDAC interrupt source(s) to set to pending. Use one or more valid interrupt flags for IDAC module (IDAC_IF_nnn) OR'ed together.
Macro Definition Documentation
◆ IDAC_INIT_DEFAULT
| #define IDAC_INIT_DEFAULT |
Default configuration for IDAC initialization structure.
Enumeration Type Documentation
◆ IDAC_OutMode_TypeDef
| enum IDAC_OutMode_TypeDef |
Output mode.
◆ IDAC_PRSSEL_TypeDef
| enum IDAC_PRSSEL_TypeDef |
Selects which Peripheral Reflex System (PRS) signal to use when PRS is set to control IDAC output.
◆ IDAC_Range_TypeDef
| enum IDAC_Range_TypeDef |