Regulátor pro remosku s STM8
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remostat/TinySPL_S103/stm8s_wwdg.h

190 lines
5.2 KiB

8 years ago
/**
********************************************************************************
* @file stm8s_wwdg.h
* @author MCD Application Team
* @version V2.2.0
* @date 30-September-2014
* @brief This file contains all functions prototype and macros for the WWDG peripheral.
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
*
* Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.st.com/software_license_agreement_liberty_v2
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM8S_WWDG_H
#define __STM8S_WWDG_H
/* Includes ------------------------------------------------------------------*/
#include "stm8s.h"
/** @addtogroup STM8S_StdPeriph_Driver
* @{
*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup WWDG_Private_Macros
* @{
*/
/**
* @brief Macro used by the assert function in order to check the
* values of the window register.
*/
#define IS_WWDG_WINDOWLIMITVALUE_OK(WindowLimitValue) ((WindowLimitValue) <= 0x7F)
/**
* @brief Macro used by the assert function in order to check the different
* values of the counter register.
*/
#define IS_WWDG_COUNTERVALUE_OK(CounterValue) ((CounterValue) <= 0x7F)
/**
* @}
*/
/* Exported types ------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/** @addtogroup WWDG_Exported_Functions
* @{
*/
#if 0
void WWDG_Init(uint8_t Counter, uint8_t WindowValue);
void WWDG_SetCounter(uint8_t Counter);
uint8_t WWDG_GetCounter(void);
void WWDG_SWReset(void);
void WWDG_SetWindowValue(uint8_t WindowValue);
#endif
/** @addtogroup STM8S_StdPeriph_Driver
* @{
*/
/* Private define ------------------------------------------------------------*/
#define _WWDG_BIT_MASK ((uint8_t)0x7F)
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/** @addtogroup WWDG_Public_Functions
* @{
*/
/**
* @brief Initializes the WWDG peripheral.
* This function set Window Register = WindowValue, Counter Register
* according to Counter and \b ENABLE \b WWDG
* @param Counter : WWDG counter value
* @param WindowValue : specifies the WWDG Window Register, range is 0x00 to 0x7F.
* @retval None
*/
inline void WWDG_Init(uint8_t Counter, uint8_t WindowValue)
{
/* Check the parameters */
assert_param(IS_WWDG_WINDOWLIMITVALUE_OK(WindowValue));
WWDG->WR = WWDG_WR_RESET_VALUE;
WWDG->CR = (uint8_t) ((uint8_t) (WWDG_CR_WDGA | WWDG_CR_T6) | (uint8_t) Counter);
WWDG->WR = (uint8_t) ((uint8_t) (~WWDG_CR_WDGA) & (uint8_t) (WWDG_CR_T6 | WindowValue));
}
/**
* @brief Refreshes the WWDG peripheral.
* @param Counter : WWDG Counter Value
* This parameter must be a number between 0x40 and 0x7F.
* @retval None
*/
inline void WWDG_SetCounter(uint8_t Counter)
{
/* Check the parameters */
assert_param(IS_WWDG_COUNTERVALUE_OK(Counter));
/* Write to T[6:0] bits to configure the counter value, no need to do
a read-modify-write; writing a 0 to WDGA bit does nothing */
WWDG->CR = (uint8_t) (Counter & (uint8_t) _WWDG_BIT_MASK);
}
/**
* @brief Gets the WWDG Counter Value.
* This value could be used to check if WWDG is in the window, where
* refresh is allowed.
* @param None
* @retval WWDG Counter Value
*/
inline uint8_t WWDG_GetCounter(void)
{
return (WWDG->CR);
}
/**
* @brief Generates immediate WWDG RESET.
* @param None
* @retval None
*/
inline void WWDG_SWReset(void)
{
WWDG->CR = WWDG_CR_WDGA; /* Activate WWDG, with clearing T6 */
}
/**
* @brief Sets the WWDG window value.
* @param WindowValue: specifies the window value to be compared to the
* downcounter.
* This parameter value must be lower than 0x80.
* @retval None
*/
inline void WWDG_SetWindowValue(uint8_t WindowValue)
{
/* Check the parameters */
assert_param(IS_WWDG_WINDOWLIMITVALUE_OK(WindowValue));
WWDG->WR = (uint8_t) ((uint8_t) (~WWDG_CR_WDGA) & (uint8_t) (WWDG_CR_T6 | WindowValue));
}
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
* @}
*/
#endif /* __STM8S_WWDG_H */
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/