示例#1
0
文件: ad5755.c 项目: 363546178/no-OS
/***************************************************************************//**
 * @brief Enables/Disables watchdog timer and sets the timeout period.
 *
 * @param wtdEnable - Watchdog enable option.
 *                    Example: 0 - disables watchdog timer
 *                             1 - enabled watchdog timer
 * @param timeout - Timeout period for the watchdog timer.
 *                  Example: AD5755_WD_5MS
 *                           AD5755_WD_10MS
 *                           AD5755_WD_100MS
 *                           AD5755_WD_200MS
 *
 * @return None.
*******************************************************************************/
 void AD5755_WatchDogSetup(unsigned char wtdEnable, unsigned char timeout)
 {
    unsigned long oldMainCtrlReg = 0;
    unsigned long newMainCtrlReg = 0;

    oldMainCtrlReg = AD5755_GetRegisterValue(AD5755_RD_MAIN_CTRL_REG);
    oldMainCtrlReg &= ~(AD5755_MAIN_EWD | AD5755_MAIN_WD(3));
    newMainCtrlReg = oldMainCtrlReg |
                    (AD5755_MAIN_EWD * wtdEnable) |
                    AD5755_MAIN_WD(timeout);
    AD5755_SetControlRegisters(AD5755_CREG_MAIN,
                               0,
                               newMainCtrlReg);
}
示例#2
0
/***************************************************************************//**
 * @brief Enables/Disables watchdog timer and sets the timeout period.
 *
 * @param dev        - The device structure.
 * @param wtd_enable - Watchdog enable option.
 *                    Example: 0 - disables watchdog timer
 *                             1 - enabled watchdog timer
 * @param timeout    - Timeout period for the watchdog timer.
 *                    Example: AD5755_WD_5MS
 *                             AD5755_WD_10MS
 *                             AD5755_WD_100MS
 *                             AD5755_WD_200MS
 *
 * @return None.
*******************************************************************************/
void ad5755_watch_dog_setup(struct ad5755_dev *dev,
			    uint8_t wtd_enable,
			    uint8_t timeout)
{
	uint32_t old_main_ctrl_reg = 0;
	uint32_t new_main_ctrl_reg = 0;

	old_main_ctrl_reg = ad5755_get_register_value(dev,
			    AD5755_RD_MAIN_CTRL_REG);
	old_main_ctrl_reg &= ~(AD5755_MAIN_EWD | AD5755_MAIN_WD(3));
	new_main_ctrl_reg = old_main_ctrl_reg |
			    (AD5755_MAIN_EWD * wtd_enable) |
			    AD5755_MAIN_WD(timeout);
	ad5755_set_control_registers(dev,
				     AD5755_CREG_MAIN,
				     0,
				     new_main_ctrl_reg);
}