#ifndef __H0D_AF_H__
#define __H0D_AF_H__
#include "sv_common.h"

#define REG_H0D_17_FORCE_DIDO_OUTPUT 0x0D11
// DIDO强制模式下输出使能枚举类型
typedef enum
{
    SV630P_DIDO_FORCE_NONE       = 0, // 无操作
    SV630P_DIDO_FORCE_DI_ENABLE  = 1, // 强制DI使能，强制DO不使能
    SV630P_DIDO_FORCE_DO_ENABLE  = 2, // 强制DO使能，强制DI不使能
    SV630P_DIDO_FORCE_ALL_ENABLE = 3  // 强制DIDO都使能
} DIDO_ForceMode;

#define REG_H0D_18_FORCE_DI_INPUT 0x0D12
#define FORCE_DI_INPUT_VAL_MIN    0x0000
#define FORCE_DI_INPUT_VAL_MAX    0x1FF
#define FORCE_DI_INPUT_VAL_DEF    0x1FF

#define DI1_BIT (1 << 0)
#define DI2_BIT (1 << 1)
#define DI3_BIT (1 << 2)
#define DI4_BIT (1 << 3)
#define DI5_BIT (1 << 4)
#define DI6_BIT (1 << 5)
#define DI7_BIT (1 << 6)
#define DI8_BIT (1 << 7)
#define DI9_BIT (1 << 8)
#define NOT_CONCERN_BIT (0)

int sv630p_h0d_17_read_force_output_mode(sv630p_handle_t *dev, DIDO_ForceMode *mode);

/**
 * @brief Set the Force Output Mode
 * @param dev SV630P device
 * @param mode DIDO_ForceMode
*/
int sv630p_h0d_17_write_force_output_mode(sv630p_handle_t *dev, DIDO_ForceMode mode);

int sv630p_h0d_18_read_force_input_value(sv630p_handle_t *dev, uint16_t *value);

/**
 * @brief Set the Force Input Value
 * @param dev SV630P device
 * @param high_mask Bit mask that needs to be set to high level
 * @param low_mask Bit mask that needs to be set to high level
 * @note Check H17 and H0D.17 H0D.18
*/
int sv630p_h0d_18_write_force_input_bits(sv630p_handle_t *dev, uint16_t high_mask, uint16_t low_mask);

#endif //__H0D_AF_H
