| NANO100_BSP V3.05.000 The Board Support Package for Nano100BN Series

Macros | Functions
DAC Exported Functions
NANO100 Device Driver » DAC Driver » DAC Exported Constants
Collaboration diagram for DAC Exported Functions:

## Macros
#define | DAC_WRITE_DATA(dac, u32Ch, u32Data)
| Write data for conversion. More...
#define | DAC_ENABLE_GROUP_MODE(dac)
| Enable DAC group mode. More...
#define | DAC_DISABLE_GROUP_MODE(dac)
| Disable DAC group mode. More...
#define | DAC_IS_BUSY(dac, u32Ch)
| Get the busy state of DAC. More...
#define | DAC_GET_INT_FLAG(dac, u32Ch)
| Get the interrupt flag of specified channel. More...
#define | DAC_CLR_INT_FLAG(dac, u32Ch)
| This macro clear the interrupt status bit of specified channel. More...
#define | DAC_SET_REF_VOLTAGE(dac, u32Ref)
| Set the DAC reference voltage. This setting affects both DAC channel. More...
#define | DAC_ENABLE_INT(dac, u32Ch)
| This macro enable the interrupt of specified channel. More...
#define | DAC_DISABLE_INT(dac, u32Ch)
| This macro disable the interrupt of specified channel. More...

## Functions
void | DAC_Open (DAC_T *dac, uint32_t u32Ch, uint32_t u32TrgSrc)
| This function make a DAC channel ready to convert. More...
void | DAC_Close (DAC_T *dac, uint32_t u32Ch)
| Disable DAC analog power. More...
int | DAC_SetDelayTime (DAC_T *dac, uint32_t u32Delay)
| Set delay time for DAC to become stable. More...

## Detailed Description

## Macro Definition Documentation

## ◆ DAC_CLR_INT_FLAG

#define DAC_CLR_INT_FLAG | ( |  | dac,
|  |  | u32Ch
| ) |  |

This macro clear the interrupt status bit of specified channel.

Parameters

  [in] | dac | Base address of DAC module.
  [in] | u32Ch | DAC channel number, could be 0 or 1

Returns
  None

Definition at line 116 of file dac.h.

## ◆ DAC_DISABLE_GROUP_MODE

#define DAC_DISABLE_GROUP_MODE | ( |  | dac | ) |

Disable DAC group mode.

Parameters

  [in] | dac | Base address of DAC module.

Returns
  None

Definition at line 83 of file dac.h.

## ◆ DAC_DISABLE_INT

#define DAC_DISABLE_INT | ( |  | dac,
|  |  | u32Ch
| ) |  |

This macro disable the interrupt of specified channel.

Parameters

  [in] | dac | Base address of DAC module.
  [in] | u32Ch | DAC channel number, could be 0 or 1

Returns
  None

Definition at line 157 of file dac.h.

## ◆ DAC_ENABLE_GROUP_MODE

#define DAC_ENABLE_GROUP_MODE | ( |  | dac | ) |

Enable DAC group mode.

Parameters

  [in] | dac | Base address of DAC module.

Returns
  None

Definition at line 75 of file dac.h.

## ◆ DAC_ENABLE_INT

#define DAC_ENABLE_INT | ( |  | dac,
|  |  | u32Ch
| ) |  |

This macro enable the interrupt of specified channel.

Parameters

  [in] | dac | Base address of DAC module.
  [in] | u32Ch | DAC channel number, could be 0 or 1

Returns
  None

Definition at line 143 of file dac.h.

## ◆ DAC_GET_INT_FLAG

#define DAC_GET_INT_FLAG | ( |  | dac,
|  |  | u32Ch
| ) |  |

Get the interrupt flag of specified channel.

Parameters

  [in] | dac | Base address of DAC module.
  [in] | u32Ch | DAC channel number, could be 0 or 1

Returns
  Returns the interrupt flag of selected channel.

Return values

  0 | DAC interrupt flag is not set.
  1 | DAC interrupt flag is set.

Definition at line 107 of file dac.h.

## ◆ DAC_IS_BUSY

#define DAC_IS_BUSY | ( |  | dac,
|  |  | u32Ch
| ) |  |

Get the busy state of DAC.

Parameters

  [in] | dac | Base address of DAC module.
  [in] | u32Ch | DAC channel number, could be 0 or 1

Returns
  If DAC is able to convert or not.

Return values

  0 | DAC is in idle state.
  1 | DAC is in busy state, or DAC is not in ready state.

If this macro returns 1, DAC is not in ready state. Ether DAC is busy or not in ready state.

Definition at line 95 of file dac.h.

## ◆ DAC_SET_REF_VOLTAGE

#define DAC_SET_REF_VOLTAGE | ( |  | dac,
|  |  | u32Ref
| ) |  |

Set the DAC reference voltage. This setting affects both DAC channel.

Parameters

  [in] | dac | Base address of DAC module
  [in] | u32Ref | The reference voltage selection. Valid values are: DAC_REFSEL_POWER DAC_REFSEL_INT_VREF DAC_REFSEL_VREF

Returns
  None

Definition at line 134 of file dac.h.

## ◆ DAC_WRITE_DATA

#define DAC_WRITE_DATA | ( |  | dac,
|  |  | u32Ch,
|  |  | u32Data
| ) |  |

Write data for conversion.

Parameters

  [in] | dac | Base address of DAC module.
  [in] | u32Ch | DAC channel number, could be 0 or 1
  [in] | u32Data | Decides the data for conversion, valid range are between 0~0xFFF.

Returns
  None

Definition at line 60 of file dac.h.

## Function Documentation

## ◆ DAC_Close()

void DAC_Close | ( | DAC_T * | dac,
|  | uint32_t | u32Ch
| ) |  |

Disable DAC analog power.

Parameters

  [in] | dac | Base address of DAC module.
  [in] | u32Ch | DAC channel number, could be 0 or 1

Returns
  None

Disable DAC analog power for saving power consumption.

Definition at line 67 of file dac.c.

## ◆ DAC_Open()

void DAC_Open | ( | DAC_T * | dac,
|  | uint32_t | u32Ch,
|  | uint32_t | u32TrgSrc
| ) |  |

This function make a DAC channel ready to convert.

Parameters

  [in] | dac | Base address of DAC module.
  [in] | u32Ch | DAC channel number, could be 0 or 1
  [in] | u32TrgSrc | Decides the trigger source of specified DAC channel. Valid options are: DAC_WRITE_DAT_TRIGGER DAC_PDMA_TRIGGER DAC_TIMER0_TRIGGER DAC_TIMER1_TRIGGER DAC_TIMER2_TRIGGER DAC_TIMER3_TRIGGER

Returns
  None

Note
  This API also set DAC stable time to 2uc according to current PCLK

Definition at line 40 of file dac.c.

Here is the call graph for this function:

## ◆ DAC_SetDelayTime()

int DAC_SetDelayTime | ( | DAC_T * | dac,
|  | uint32_t | u32Delay
| ) |  |

Set delay time for DAC to become stable.

Parameters

  [in] | dac | Base address of DAC module.
  [in] | u32Delay | Decides the DAC conversion settling time, Valid values are between 1~0xFF.

Returns
  Success or failed

Return values

  0 | Success
  -1 | Failed, the new setting will cause stable time less than 2us. So new setting is not applied.

For example, DAC controller clock speed is 12MHz and DAC conversion settling time is 3 us, u32Delay should be given the value 3 * 12 = 36.

Note
  User needs to write appropriate value to meet DAC conversion settling time base on PCLK (APB clock) speed. Minimum delay is 2 us.
  This setting is shared by both DAC channels.

Definition at line 94 of file dac.c.

Here is the call graph for this function: