/*!
 * @file        bmp561_iwdt.h
 *
 * @brief       This file contains all the functions prototypes for the IWDT firmware library
 *
 * @version     V1.0.0
 *
 * @date        2025-01-01
 *
 * @attention
 *
 *  Copyright (C) 2025 Geehy Semiconductor
 *
 *  You may not use this file except in compliance with the
 *  GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
 *
 *  The program is only for reference, which is distributed in the hope
 *  that it will be useful and instructional for customers to develop
 *  their software. Unless required by applicable law or agreed to in
 *  writing, the program is distributed on an "AS IS" BASIS, WITHOUT
 *  ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
 *  and limitations under the License.
 */

/* Define to prevent recursive inclusion */
#ifndef __BMP561_IWDT_H
#define __BMP561_IWDT_H

/* Includes */
#include "bmp561.h"

#ifdef __cplusplus
  extern "C" {
#endif

/** @addtogroup Peripherals_Library Standard Peripheral Library
  @{
*/

/** @addtogroup IWDT_Driver IWDT Driver
  @{
*/

/** @addtogroup IWDT_Enumerations Enumerations
  @{
*/

/**
 * @brief    IWDT prescaler
 */

typedef enum
{
    IWDT_PS_0  = ((uint8_t)0x00),    /*!< IWDT counter clock = Fsys/2^0 */
    IWDT_PS_1  = ((uint8_t)0x01),    /*!< IWDT counter clock = Fsys/2^1 */
    IWDT_PS_2  = ((uint8_t)0x02),    /*!< IWDT counter clock = Fsys/2^2 */
    IWDT_PS_3  = ((uint8_t)0x03),    /*!< IWDT counter clock = Fsys/2^3 */
    IWDT_PS_4  = ((uint8_t)0x04),    /*!< IWDT counter clock = Fsys/2^4 */
    IWDT_PS_5  = ((uint8_t)0x05),    /*!< IWDT counter clock = Fsys/2^5 */
    IWDT_PS_6  = ((uint8_t)0x06),    /*!< IWDT counter clock = Fsys/2^6 */
    IWDT_PS_7  = ((uint8_t)0x07),    /*!< IWDT counter clock = Fsys/2^7 */
    IWDT_PS_8  = ((uint8_t)0x08),    /*!< IWDT counter clock = Fsys/2^8 */
    IWDT_PS_9  = ((uint8_t)0x09),    /*!< IWDT counter clock = Fsys/2^9 */
    IWDT_PS_10 = ((uint8_t)0x0A),    /*!< IWDT counter clock = Fsys/2^10 */
    IWDT_PS_11 = ((uint8_t)0x0B),    /*!< IWDT counter clock = Fsys/2^11 */
    IWDT_PS_12 = ((uint8_t)0x0C),    /*!< IWDT counter clock = Fsys/2^12 */
    IWDT_PS_13 = ((uint8_t)0x0D),    /*!< IWDT counter clock = Fsys/2^13 */
    IWDT_PS_14 = ((uint8_t)0x0E),    /*!< IWDT counter clock = Fsys/2^14 */
    IWDT_PS_15 = ((uint8_t)0x0F)     /*!< IWDT counter clock = Fsys/2^15 */
} IWDT_PS_T;

/**
 * @brief    IWDT function
 */

typedef enum
{
    IWDT_FUNC_FEEDDOG = ((uint8_t)0xAA),    /*!< Feed dog */
    IWDT_FUNC_UNLOCK  = ((uint8_t)0x55),    /*!< Unlock PS and RV registers */
    IWDT_FUNC_ENABLE  = ((uint8_t)0xCC)     /*!< Enable IWDT */
} IWDT_FUNC_T;

/**
 * @brief    IWDT flag
 */

typedef enum
{
    IWDT_FLAG_TU = ((uint8_t)0x01),    /*!< Reload value update on going */
    IWDT_FLAG_PU = ((uint8_t)0x02),    /*!< Prescaler value update on going */
    IWDT_FLAG_RU = ((uint8_t)0x04)     /*!< EEPROM single bit error */
} IWDT_FLAG_T;

/**@} end of group IWDT_Enumerations */

/** @addtogroup IWDT_Functions Functions
  @{
*/

/* IWDT configuration */
void IWDT_Reset(void);
void IWDT_ConfigPrescaler(IWDT_PS_T prescaler);
void IWDT_ConfigFunction(IWDT_FUNC_T type);
void IWDT_ConfigReload(uint16_t reload);
uint8_t IWDT_ReadFlag(IWDT_FLAG_T flag);

/**@} end of group IWDT_Functions */
/**@} end of group IWDT_Driver */
/**@} end of group Peripherals_Library */

#ifdef __cplusplus
}
#endif

#endif /* __BMP561_IWDT_H */
