1 /* 2 * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef R_DAC_H 8 #define R_DAC_H 9 10 /*********************************************************************************************************************** 11 * Includes 12 **********************************************************************************************************************/ 13 14 #include "bsp_api.h" 15 #include "r_dac_cfg.h" 16 #include "r_dac_api.h" 17 18 /* Common macro for FSP header files. There is also a corresponding FSP_FOOTER macro at the end of this file. */ 19 FSP_HEADER 20 21 /*******************************************************************************************************************//** 22 * @addtogroup DAC 23 * @{ 24 **********************************************************************************************************************/ 25 26 /*********************************************************************************************************************** 27 * Macro definitions 28 **********************************************************************************************************************/ 29 30 /*********************************************************************************************************************** 31 * Typedef definitions 32 **********************************************************************************************************************/ 33 34 /** DAC Reference voltage selection. */ 35 typedef enum e_dac_ref_volt_sel 36 { 37 DAC_VREF_NONE = 0x00, ///< No reference voltage selected 38 DAC_VREF_AVCC0_AVSS0 = 0x01, ///< Select AVCC0/AVSS0 39 DAC_VREF_IVREF_AVSS0 = 0x03, ///< Select Internal reference voltage/AVSS0 40 DAC_VREF_VREFH_VREFL = 0x06 ///< Select VREFH/VREFL 41 } dac_ref_volt_sel_t; 42 43 /** DAC instance control block. */ 44 typedef struct st_dac_instance_ctrl 45 { 46 uint8_t channel; // DAC channel number 47 uint8_t channel_index; // Channel index to access bits 48 uint32_t channel_opened; // DAC Driver ID 49 bool output_amplifier_enabled; // DAC Output amplifier (on selected MCUs) enabled/disabled. 50 bool internal_output_enabled; // Output provided to internal modules (on selected MCUs) enabled/disabled. 51 R_DAC_Type * p_reg; // Base register for this channel 52 } dac_instance_ctrl_t; 53 54 /** DAC extended configuration */ 55 typedef struct st_dac_extended_cfg 56 { 57 bool enable_charge_pump; ///< Enable DAC charge pump available on selected MCUs. 58 bool output_amplifier_enabled; ///< Output amplifier enable available on selected MCUs. 59 bool internal_output_enabled; ///< Internal output enable available on selected MCUs. 60 dac_data_format_t data_format; ///< Data format 61 dac_ref_volt_sel_t ref_volt_sel; ///< Reference voltage selection 62 } dac_extended_cfg_t; 63 64 /********************************************************************************************************************** 65 * Exported global variables 66 **********************************************************************************************************************/ 67 68 /** @cond INC_HEADER_DEFS_SEC */ 69 /** Filled in Interface API structure for this Instance. */ 70 extern const dac_api_t g_dac_on_dac; 71 72 /** @endcond */ 73 74 /*********************************************************************************************************************** 75 * Public APIs 76 **********************************************************************************************************************/ 77 fsp_err_t R_DAC_Open(dac_ctrl_t * p_api_ctrl, dac_cfg_t const * const p_cfg); 78 fsp_err_t R_DAC_Write(dac_ctrl_t * p_api_ctrl, uint16_t value); 79 fsp_err_t R_DAC_Start(dac_ctrl_t * p_api_ctrl); 80 fsp_err_t R_DAC_Stop(dac_ctrl_t * p_api_ctrl); 81 fsp_err_t R_DAC_Close(dac_ctrl_t * p_api_ctrl); 82 83 /*******************************************************************************************************************//** 84 * @} (end defgroup DAC) 85 **********************************************************************************************************************/ 86 87 /* Common macro for FSP header files. There is also a corresponding FSP_HEADER macro at the top of this file. */ 88 FSP_FOOTER 89 90 #endif // R_DAC_H 91