/**
******************************************************************************
* @file xl_osc.h
* @author software group
* @brief This file contains all the functions prototypes for the OSC
* firmware library.
******************************************************************************
* @attention
*
* 2019 by Chipways Communications,Inc. All Rights Reserved.
* This software is supplied under the terms of a license
* agreement or non-disclosure agreement with Chipways.
* Passing on and copying of this document,and communication
* of its contents is not permitted without prior written
* authorization.
*
*
© COPYRIGHT 2019 Chipways
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef XL_OSC_H_
#define XL_OSC_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "XL6600.h"
/* Register define ------------------------------------------------------------*/
#define OSC_CR_OSCINIT_MASK 0x1u
#define OSC_CR_OSCINIT_SHIFT 0u
#define OSC_CR_HGO_MASK 0x2u
#define OSC_CR_HGO_SHIFT 1u
#define OSC_CR_RANGE_MASK 0x4u
#define OSC_CR_RANGE_SHIFT 2u
#define OSC_CR_OSCOS_MASK 0x10u
#define OSC_CR_OSCOS_SHIFT 4u
#define OSC_CR_OSCSTEN_MASK 0x20u
#define OSC_CR_OSCSTEN_SHIFT 5u
#define OSC_CR_OSCEN_MASK 0x80u
#define OSC_CR_OSCEN_SHIFT 7u
/* TCR Bit Fields */
#define OSC_TCR_ECLK_MASK 0x7FFFu
#define OSC_TCR_ECLK_SHIFT 0u
#define OSC_TCR_CV_MASK 0x8000u
#define OSC_TCR_CV_SHIFT 15u
/** OSC - Register Layout Typedef */
typedef struct {
__IO uint32_t CR; /*!< OSC ¿ØÖƼĴæÆ÷, offset: 0x0 */
__IO uint32_t TCR; /*!< OSC À©Õ¹Ê±¼ä¿ØÖƼĴæÆ÷, offset: 0x4 */
} OSC_Type;
extern OSC_Type* OSC;
/** @addtogroup XL6600_StdPeriph_Driver
* @{
*/
/** @addtogroup OSC
* @{
*/
/* Exported types ------------------------------------------------------------*/
/**
* @brief OSC³õʼ»¯½á¹¹Ì嶨Òå
*/
typedef struct
{
uint8_t OSC_OutputSelect; /*!< OSC Êä³öÑ¡Ôñ */
uint8_t OSC_RangeSelect; /*!< ƵÂÊ·¶Î§Ñ¡Ôñ */
uint8_t OSC_ModeSelect; /*!< ¸ßÔöÒæÕñµ´Æ÷Ñ¡Ôñ */
}OSC_InitTypeDef;
/** @defgroup OSC_Exported_Constants OSCÄ£¿éʹÓòÎÊý¶¨Òå
* @{
*/
/** @defgroup OSC_OutSelect OSCÊä³öÑ¡Ôñ
* @{
*/
#define OSC_EXTERNAL_COLOCK ((uint8_t)0x00) /*!< Ñ¡ÔñÍⲿʱÖÓÔ´ */
#define OSC_OSCCILLATOR_COLOR ((uint8_t)0x10) /*!< Ñ¡ÔñOSCʱÖÓÔ´ */
/**
* @}
*/
/** @defgroup OSC_RangeSelect OSCƵÂÊ·¶Î§Ñ¡Ôñ
* @{
*/
#define OSC_RANGE_LOW ((uint8_t)0x00) /*!< 32kHz */
#define OSC_RANGE_HIGH ((uint8_t)0x04) /*!< 4 to 24MHz */
/**
* @}
*/
/** @defgroup OSC_WorkMode OSC¹¤×÷ģʽ
* @{
*/
#define OSC_LP_MODE ((uint8_t)0x00) /*!< µÍ¹¦ºÄģʽ */
#define OSC_HG_MODE ((uint8_t)0x02) /*!< ¸ßÔöÒæÄ£Ê½ */
/**
* @}
*/
/** @defgroup OSC_InitResult OSC³õʼ»¯½á¹û
* @{
*/
#define OSC_INITSTATUS_FAILED ((uint8_t)0x00) /*!< OSC ³õʼ»¯Ê§°Ü */
#define OSC_INITSTATUS_SUCESS ((uint8_t)0x01) /*!< OSC ³õʼ»¯³É¹¦ */
/**
* @}
*/
/**
* @}
*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
void OSC_Deinit(void);
void OSC_Init(const OSC_InitTypeDef *OSC_InitStruct);
void OSC_EnableCmd(FunctionalState State);
void OSC_ModuleInStopModeCmd(FunctionalState NewState);
void OSC_SetExtTime(uint32_t ExpTime);
uint8_t OSC_GetInitStatus(void);
uint8_t OSC_GetRange(void);
#ifdef __cplusplus
}
#endif
#endif /*__XL_OSC_H__ */
/**
* @}
*/
/**
* @}
*/