/*
 * @Date: 2025-06-26 09:16:24
 * @Author: mypx
 * @LastEditors: mypx mypx_coder@163.com
 * @LastEditTime: 2025-07-22 16:37:06
 * @FilePath: h00_motor_args.c
 * @Description: 
 * Copyright (c) 2025 by mypx, All Rights Reserved.
 */
#include "h00_motor_args.h"

/**
 * @brief H00.00 Read motor ID
 * @param dev Pointer to servo handle
 * @param value Pointer to store the motor ID
 * @return int 
 */
int sv630p_read_h00_00_motor_id(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_00_MOTOR_ID, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.00 Write motor ID
 * @param dev Pointer to servo handle
 * @param value Motor ID to write
 * @return int 
 */
int sv630p_write_h00_00_motor_id(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->write_single_reg(dev, REG_H00_00_MOTOR_ID, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.02 Read Non-standard Number (32-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_02_non_label(sv630p_handle_t *dev, uint32_t *value)
{
    uint16_t regs[2];
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_02_NON_LABEL, 2, regs) == NMBS_ERROR_NONE)
    {
        *value = (uint32_t)regs[0] | ((uint32_t)regs[1] << 16);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.04 Read Encoder Version (16-bit)
 * @param value Pointer to store the value
 * @return nmbs_error
 */
int sv630p_read_h00_04_enc_version(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, 0x2005, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.05 Read Bus Motor ID (16-bit)
 * @param value Pointer to store the value
 * @return nmbs_error
 */
int sv630p_read_h00_05_bus_motor_id(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_05_BUS_MOTOR_ID, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.06 Read FPGA Non-standard Number (32-bit)
 * @param value Pointer to store the value
 * @return nmbs_error
 */
int sv630p_read_h00_06_fpga_non_label(sv630p_handle_t *dev, uint32_t *value)
{
    uint16_t regs[2];
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_06_FPGA_NON_LABEL, 2, regs) == NMBS_ERROR_NONE)
    {
        *value = (uint32_t)regs[0] | ((uint32_t)regs[1] << 16);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.08 Read Bus Encoder Type (16-bit)
 * @param value Pointer to store the value
 * @return nmbs_error
 */
int sv630p_read_h00_08_bus_enc_type(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_08_BUS_ENC_TYPE, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.08 Write Bus Encoder Type (16-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_08_bus_enc_type(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->write_single_reg(dev, REG_H00_08_BUS_ENC_TYPE, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.09 Read Rated Voltage (16-bit)
 * @param value Pointer to store the value
 * @return nmbs_error
 */
int sv630p_read_h00_09_rated_voltage(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_09_RATED_VOLTAGE, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.09 Write Rated Voltage (16-bit)
 * @param value Value to write
 * @return nmbs_error
 */
int sv630p_write_h00_09_rated_voltage(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (value > REG_H00_09_RATED_VOLTAGE_MAX)
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_09_RATED_VOLTAGE, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.10 Read Rated Power (16-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_10_rated_power(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_10_RATED_POWER, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.10 Write Rated Power (16-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_10_rated_power(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (value < (uint16_t)(REG_H00_10_RATED_POWER_MIN * 100) || value > (uint16_t)(REG_H00_10_RATED_POWER_MAX * 100))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_10_RATED_POWER, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.11 Read Rated Current (16-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_11_rated_current(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_11_RATED_CURRENT, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.11 Write Rated Current (16-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_11_rated_current(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (value < (uint16_t)(REG_H00_11_RATED_CURRENT_MIN * 100) || value > (uint16_t)(REG_H00_11_RATED_CURRENT_MAX * 100))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_11_RATED_CURRENT, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.12 Read Rated Torque (16-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_12_rated_torque(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_12_RATED_TORQUE, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.12 Write Rated Torque (16-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_12_rated_torque(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (value < (uint16_t)(REG_H00_12_RATED_TORQUE_MIN * 100) || value > (uint16_t)(REG_H00_12_RATED_TORQUE_MAX * 100))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_12_RATED_TORQUE, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.13 Read Maximum Torque (16-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_13_max_torque(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_13_MAX_TORQUE, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.13 Write Maximum Torque (16-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_13_max_torque(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (value < (uint16_t)(REG_H00_13_MAX_TORQUE_MIN * 100) || value > (uint16_t)(REG_H00_13_MAX_TORQUE_MAX * 100))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_13_MAX_TORQUE, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.14 Read Rated Speed (16-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_14_rated_speed(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_14_RATED_SPEED, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.14 Write Rated Speed (16-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_14_rated_speed(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (value < REG_H00_14_RATED_SPEED_MIN || value > REG_H00_14_RATED_SPEED_MAX)
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_14_RATED_SPEED, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.15 Read Maximum Speed (16-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int
 */
int sv630p_read_h00_15_max_speed(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_15_MAX_SPEED, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.15 Write Maximum Speed (16-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int
 */
int sv630p_write_h00_15_max_speed(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (value < REG_H00_15_MAX_SPEED_MIN || value > REG_H00_15_MAX_SPEED_MAX)
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_15_MAX_SPEED, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.16 Read Moment of Inertia Jm (16-bit, unit: 0.01kg·cm²)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_16_moment_of_inertia(sv630p_handle_t *dev, uint16_t *value)
{
    uint16_t reg_val;
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_16_MOMENT_OF_INERTIA, 1, &reg_val) == NMBS_ERROR_NONE)
    {
        *value = (uint16_t)((float)reg_val / 100.0f);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.16 Write Moment of Inertia Jm (16-bit, unit: 0.01kg·cm²)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_16_moment_of_inertia(sv630p_handle_t *dev, uint16_t value)
{
    uint16_t reg_value = (uint16_t)(value * 100.0f);
    SV630P_ARGS_CHECK(dev);
    if (reg_value < (uint16_t)(REG_H00_16_MOMENT_OF_INERTIA_MIN * 100) || reg_value > (uint16_t)(REG_H00_16_MOMENT_OF_INERTIA_MAX * 100))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_16_MOMENT_OF_INERTIA, reg_value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.17 Read Number of Pole Pairs (16-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_17_pole_pairs(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_17_POLE_PAIRS, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.17 Write Number of Pole Pairs (16-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_17_pole_pairs(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (value < REG_H00_17_POLE_PAIRS_MIN || value > REG_H00_17_POLE_PAIRS_MAX)
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_17_POLE_PAIRS, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.18 Read Stator Resistance (16-bit, unit: 0.001Ω)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_18_stator_resistance(sv630p_handle_t *dev, uint16_t *value)
{
    uint16_t reg_val;
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_18_STATOR_RESISTANCE, 1, &reg_val) == NMBS_ERROR_NONE)
    {
        *value = (uint16_t)((float)reg_val / 1000.0f);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.18 Write Stator Resistance (16-bit, unit: 0.001Ω)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_18_stator_resistance(sv630p_handle_t *dev, uint16_t value)
{
    uint16_t reg_value = (uint16_t)(value * 1000.0f);
    SV630P_ARGS_CHECK(dev);
    if (reg_value < (uint16_t)(REG_H00_18_STATOR_RESISTANCE_MIN * 1000) || reg_value > (uint16_t)(REG_H00_18_STATOR_RESISTANCE_MAX * 1000))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_18_STATOR_RESISTANCE, reg_value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.19 Read Stator Inductance Lq (16-bit, unit: 0.01mH)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_19_stator_inductance_lq(sv630p_handle_t *dev, uint16_t *value)
{
    uint16_t reg_val;
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_19_STATOR_INDUCTANCE_LQ, 1, &reg_val) == NMBS_ERROR_NONE)
    {
        *value = (uint16_t)((float)reg_val / 100.0f);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.19 Write Stator Inductance Lq (16-bit, unit: 0.01mH)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_19_stator_inductance_lq(sv630p_handle_t *dev, uint16_t value)
{
    uint16_t reg_value = (uint16_t)(value * 100.0f);
    SV630P_ARGS_CHECK(dev);
    if (reg_value < (uint16_t)(REG_H00_19_STATOR_INDUCTANCE_LQ_MIN * 100) || reg_value > (uint16_t)(REG_H00_19_STATOR_INDUCTANCE_LQ_MAX * 100))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_19_STATOR_INDUCTANCE_LQ, reg_value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.20 Read Stator Inductance Ld (16-bit, unit: 0.01mH)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int
 */
int sv630p_read_h00_20_stator_inductance_ld(sv630p_handle_t *dev, uint16_t *value)
{
    uint16_t reg_val;
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_20_STATOR_INDUCTANCE_LD, 1, &reg_val) == NMBS_ERROR_NONE)
    {
        *value = (uint16_t)((float)reg_val / 100.0f);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.20 Write Stator Inductance Ld (16-bit, unit: 0.01mH)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int
 */
int sv630p_write_h00_20_stator_inductance_ld(sv630p_handle_t *dev, uint16_t value)
{
    uint16_t reg_value = (uint16_t)(value * 100.0f);
    SV630P_ARGS_CHECK(dev);
    if (reg_value < (uint16_t)(REG_H00_20_STATOR_INDUCTANCE_LD_MIN * 100) || reg_value > (uint16_t)(REG_H00_20_STATOR_INDUCTANCE_LD_MAX * 100))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_20_STATOR_INDUCTANCE_LD, reg_value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.21 Read Back EMF Coefficient (16-bit, unit: 0.01mV/rpm)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_21_back_emf_coeff(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_21_BACK_EMF_COEFF, 1, value) == NMBS_ERROR_NONE)
    {
        *value = (uint16_t)((float)*value / 100.0f);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.21 Write Back EMF Coefficient (16-bit, unit: 0.01mV/rpm)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_21_back_emf_coeff(sv630p_handle_t *dev, uint16_t value)
{
    uint16_t reg_value = (uint16_t)(value * 100.0f);
    SV630P_ARGS_CHECK(dev);
    if (reg_value < (uint16_t)(REG_H00_21_BACK_EMF_COEFF_MIN * 100) || reg_value > (uint16_t)(REG_H00_21_BACK_EMF_COEFF_MAX * 100))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_21_BACK_EMF_COEFF, reg_value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.22 Read Torque Coefficient Kt (16-bit, unit: 0.01N·m/Arms)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_22_torque_coeff_kt(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_22_TORQUE_COEFF_KT, 1, value) == NMBS_ERROR_NONE)
    {
        *value = (uint16_t)((float)*value / 100.0f);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.22 Write Torque Coefficient Kt (16-bit, unit: 0.01N·m/Arms)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_22_torque_coeff_kt(sv630p_handle_t *dev, uint16_t value)
{
    uint16_t reg_value = (uint16_t)(value * 100.0f);
    SV630P_ARGS_CHECK(dev);
    if (reg_value < (uint16_t)(REG_H00_22_TORQUE_COEFF_KT_MIN * 100) || reg_value > (uint16_t)(REG_H00_22_TORQUE_COEFF_KT_MAX * 100))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_22_TORQUE_COEFF_KT, reg_value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.23 Read Electrical Time Constant Te (16-bit, unit: 0.01ms)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_h00_23_read_electrical_constant(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_23_ELECTRICAL_TIME_CONST, 1, value) == NMBS_ERROR_NONE)
    {
        *value = (uint16_t)((float)*value / 100.0f);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.23 Write Electrical Time Constant Te (16-bit, unit: 0.01ms)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_h00_23_write_electrical_constant(sv630p_handle_t *dev, uint16_t value)
{
    uint16_t reg_value = (uint16_t)(value * 100.0f);
    SV630P_ARGS_CHECK(dev);
    if (reg_value < (uint16_t)(REG_H00_23_ELECTRICAL_TIME_CONST_MIN * 100) || reg_value > (uint16_t)(REG_H00_23_ELECTRICAL_TIME_CONST_MAX * 100))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_23_ELECTRICAL_TIME_CONST, reg_value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.24 Read Mechanical Time Constant Tm (16-bit, unit: 0.01ms)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_h00_24_read_mechanical_constant(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_24_MECHANICAL_TIME_CONST, 1, value) == NMBS_ERROR_NONE)
    {
        *value = (uint16_t)((float)*value / 100.0f);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.24 Write Mechanical Time Constant Tm (16-bit, unit: 0.01ms)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_24_mechanical_constant(sv630p_handle_t *dev, uint16_t value)
{
    uint16_t reg_value = (uint16_t)(value * 100.0f);
    SV630P_ARGS_CHECK(dev);
    if (reg_value < (uint16_t)(REG_H00_24_MECHANICAL_TIME_CONST_MIN * 100) || reg_value > (uint16_t)(REG_H00_24_MECHANICAL_TIME_CONST_MAX * 100))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_24_MECHANICAL_TIME_CONST, reg_value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.27 Read Bus Sine/Cosine Count (16-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_h00_27_read_bus_sincos_count(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_27_BUS_SINCOS_COUNT, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.27 Write Bus Sine/Cosine Count (16-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_h00_27_write_bus_sincos_count(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->write_single_reg(dev, REG_H00_27_BUS_SINCOS_COUNT, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.28 Read Absolute Encoder Position Offset (32-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_h00_28_read_abs_pos_offset(sv630p_handle_t *dev, uint32_t *value)
{
    uint16_t regs[2];
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_28_ABS_POS_OFFSET, 2, regs) == NMBS_ERROR_NONE)
    {
        *value = (uint32_t)regs[0] | ((uint32_t)regs[1] << 16);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.28 Write Absolute Encoder Position Offset (32-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_h00_28_write_abs_pos_offset(sv630p_handle_t *dev, uint32_t value)
{
    uint16_t regs[2];
    SV630P_ARGS_CHECK(dev);
    if (value > REG_H00_28_ABS_POS_OFFSET_MAX)
    {
        return SV630P_PARAM_ERR;
    }
    regs[0] = (uint16_t)value;
    regs[1] = (uint16_t)(value >> 16);
    if (dev->ops->write_multiple_regs(dev, REG_H00_28_ABS_POS_OFFSET, 2, regs) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.30 Read Encoder Select (HEX) (16-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_h00_30_read_encoder_select(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_30_ENCODER_SELECT, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.30 Write Encoder Select (HEX) (16-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_h00_30_write_encoder_select(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->write_single_reg(dev, REG_H00_30_ENCODER_SELECT, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.31 Read Encoder Lines (32-bit)
 * @param dev Pointer to servo handle 
 * @param value Pointer to store the value
 * @return int
 */
int sv630p_h00_31_read_encoder_lines(sv630p_handle_t *dev, uint32_t *value)
{
    uint16_t regs[2];
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_31_ENCODER_LINES, 2, regs) == NMBS_ERROR_NONE)
    {
        *value = (uint32_t)regs[0] | ((uint32_t)regs[1] << 16);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.31 Write Encoder Lines (32-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int
 */
int sv630p_h00_31_write_encoder_lines(sv630p_handle_t *dev, uint32_t value)
{
    uint16_t regs[2];
    SV630P_ARGS_CHECK(dev);
    if (value < REG_H00_31_ENCODER_LINES_MIN || value > REG_H00_31_ENCODER_LINES_MAX)
    {
        return SV630P_PARAM_ERR;
    }
    regs[0] = (uint16_t)value;
    regs[1] = (uint16_t)(value >> 16);
    if (dev->ops->write_multiple_regs(dev, REG_H00_31_ENCODER_LINES, 2, regs) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.35 Read Bus Encoder Stored Motor ID (16-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int
 */
int sv630p_h00_35_read_bus_enc_motor_id(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_35_BUS_ENC_MOTOR_ID, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.35 Write Bus Encoder Stored Motor ID (16-bit)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int
 */
int sv630p_h00_35_write_bus_enc_motor_id(sv630p_handle_t *dev, uint16_t value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->write_single_reg(dev, REG_H00_35_BUS_ENC_MOTOR_ID, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.37 Read Encoder Function Flags (16-bit)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int
 */
int sv630p_h00_37_read_encoder_func_bits(sv630p_handle_t *dev, uint16_t *value)
{
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_37_ENCODER_FUNC_FLAGS, 1, value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.43 Read Maximum Current (16-bit, unit: 0.01A)
 * @param dev Pointer to servo handle
 * @param value Pointer to store the value
 * @return int 
 */
int sv630p_read_h00_43_max_current(sv630p_handle_t *dev, uint16_t *value)
{
    uint16_t reg_val;
    SV630P_ARGS_CHECK(dev);
    if (dev->ops->read_holding_regs(dev, REG_H00_43_MAX_CURRENT, 1, &reg_val) == NMBS_ERROR_NONE)
    {
        *value = (uint16_t)((float)reg_val / 100.0f);
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

/**
 * @brief H00.43 Write Maximum Current (16-bit, unit: 0.01A)
 * @param dev Pointer to servo handle
 * @param value Value to write
 * @return int 
 */
int sv630p_write_h00_43_max_current(sv630p_handle_t *dev, uint16_t value)
{
    uint16_t reg_value = (uint16_t)(value * 100.0f);
    SV630P_ARGS_CHECK(dev);
    if (reg_value < (uint16_t)(REG_H00_43_MAX_CURRENT_MIN * 100) || reg_value > (uint16_t)(REG_H00_43_MAX_CURRENT_MAX * 100))
    {
        return SV630P_PARAM_ERR;
    }
    if (dev->ops->write_single_reg(dev, REG_H00_43_MAX_CURRENT, reg_value) == NMBS_ERROR_NONE)
    {
        return SV630P_OK;
    }
    return SV630P_BUS_ERR;
}

