freertos_f407/User/system/bsp/dacs.h

56 lines
1.7 KiB
C

/**
* @file dacs.h
* @brief Header file for DACs module.
*
* This file contains the declarations and definitions for the DACs module.
* DACs (Digital-to-Analog Converters) are used to convert digital signals into analog voltages.
*
* @author xxx
* @date 2023-12-27 14:44:03
* @copyright Copyright (c) 2024 by xxx, All Rights Reserved.
*/
#ifndef __DACS_H__
#define __DACS_H__
#include "dac.h"
#include "lib.h"
#include "main.h"
/**
* @brief Set the output value for a specific DAC channel.
* @param dac: pointer to the @ref dac_t structure that contains the configuration information for the specified DAC.
* @param value: the output value to be set.
* @retval None
*/
#define DAC_OUT(DACx, DAC_Channel, Data) \
do \
{ \
LL_DAC_ConvertData12RightAligned(DACx, DAC_Channel, Data); \
LL_DAC_TrigSWConversion(DACx, DAC_Channel); \
} while (__LINE__ == -1)
/**
* @brief Enable the specified DAC channel.
* @param dac: pointer to the @ref dac_t structure that contains the configuration information for the specified DAC.
* @retval None
*/
#define DAC_START(DACx, DAC_Channel) LL_DAC_Enable(DACx, DAC_Channel)
/**
* @brief Disable the specified DAC channel.
* @param dac: pointer to the @ref dac_t structure that contains the configuration information for the specified DAC.
* @retval None
*/
#define DAC_STOP(DACx, DAC_Channel) LL_DAC_Disable(DACx, DAC_Channel)
/**
* @brief Structure definition for the DAC driver.
*/
typedef struct DACS
{
DAC_TypeDef *dac;
uint16_t dac_channel;
void (*out)(struct DACS *dac, uint16_t value);
} dac_t;
#endif