This repository has been archived on 2025-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
controller-hd/User/application/src/mode_dac.c

90 lines
1.8 KiB
C

/**
* @file mode_dac.c
* @author gpj
* @date 2023-11-08 15:48:57
* @brief DAC算法模式控制
* @copyright Copyright (c) 2023 by xxx, All Rights Reserved.
*/
#include <math.h>
#include <stdlib.h>
#include "mode_dac.h"
#include "mode.h"
#include "entity.h"
#include "board.h"
#include "pdctrl.h"
#include "convert.h"
#include "at_hc24.h"
mode_dac_t *mode_dac;
/*******************************************************************************************************************/
/**
* @brief DAC模式初始化
* @return {*}
* @note
*/
void mode_dac_init(mode_dac_params_u *params, void (*params_save_cb)(void))
{
DBG_ASSERT(params != NULL __DBG_LINE);
DBG_ASSERT(params_save_cb != NULL __DBG_LINE);
if (mode_dac == NULL)
{
mode_dac = (mode_dac_t *)osel_mem_alloc(sizeof(mode_dac_t));
}
osel_memset((uint8_t *)mode_dac, 0, sizeof(mode_dac_t));
dac_process_state_set(DAC_PROCESS_ADJUST); // DAC_PROCESS_CONTROL, DAC_PROCESS_TEST, DAC_PROCESS_ADJUST
}
void mode_dac_dinit(void)
{
if (mode_dac != NULL)
{
osel_mem_free(mode_dac);
mode_dac = NULL;
}
}
/**
* @brief 设置过程状态
* @param {mode_dac_process_state_e} state
* @return {*}
* @note
*/
void dac_process_state_set(mode_dac_process_state_e state)
{
if (mode_dac->process_state != state)
{
mode_dac->process_state = state;
}
}
/**
* @brief DAC模式处理
* @return {*}
* @note
*/
void mode_dac_process(void)
{
if (mode_dac == NULL)
{
return;
}
switch (mode_dac->process_state)
{
case DAC_PROCESS_CONTROL:
break;
case DAC_PROCESS_ADJUST:
break;
case DAC_PROCESS_STOP:
pdctrl_out(1000);
break;
case DAC_PROCESS_TEST:
break;
default:
break;
}
}