mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-22 17:12:55 +08:00
173 lines
3.5 KiB
C
173 lines
3.5 KiB
C
/********************************** (C) COPYRIGHT *******************************
|
||
* File Name : CH57x_SYS.h
|
||
* Author : WCH
|
||
* Version : V1.2
|
||
* Date : 2021/11/17
|
||
* Description
|
||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||
* SPDX-License-Identifier: Apache-2.0
|
||
*******************************************************************************/
|
||
|
||
#ifndef __CH58x_SYS_H__
|
||
#define __CH58x_SYS_H__
|
||
|
||
#ifdef __cplusplus
|
||
extern "C" {
|
||
#endif
|
||
|
||
/**
|
||
* @brief rtc interrupt event define
|
||
*/
|
||
typedef enum
|
||
{
|
||
RST_STATUS_SW = 0, // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||
RST_STATUS_RPOR, // <20>ϵ縴λ
|
||
RST_STATUS_WTR, // <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1>λ
|
||
RST_STATUS_MR, // <20>ⲿ<EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>λ
|
||
RST_STATUS_LRM0, // <20><><EFBFBD>Ѹ<EFBFBD>λ-<2D><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||
RST_STATUS_GPWSM, // <20>µ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD>Ѹ<EFBFBD>λ
|
||
RST_STATUS_LRM1, // <09><><EFBFBD>Ѹ<EFBFBD>λ-<2D><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD>
|
||
RST_STATUS_LRM2, // <09><><EFBFBD>Ѹ<EFBFBD>λ-<2D>ֶ<EFBFBD><D6B6><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||
|
||
} SYS_ResetStaTypeDef;
|
||
|
||
/**
|
||
* @brief rtc interrupt event define
|
||
*/
|
||
typedef enum
|
||
{
|
||
INFO_ROM_READ = 0, // FlashROM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ƿ<EFBFBD><C7B7>ɶ<EFBFBD>
|
||
INFO_RESET_EN = 2, // RST#<23>ⲿ<EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>λ<EFBFBD><CEBB><EFBFBD>빦<EFBFBD><EBB9A6><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||
INFO_BOOT_EN, // ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BootLoader <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||
INFO_DEBUG_EN, // ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Խӿ<D4BD><D3BF>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||
INFO_LOADER, // <20><>ǰϵͳ<CFB5>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>Bootloader <20><>
|
||
STA_SAFEACC_ACT, // <20><>ǰϵͳ<CFB5>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ڰ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RWA<57><41><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɷ<F2B2BBBF><C9B7><EFBFBD>
|
||
|
||
} SYS_InfoStaTypeDef;
|
||
|
||
/**
|
||
* @brief <20><>ȡоƬID<49>࣬һ<E0A3AC><D2BB>Ϊ<EFBFBD>̶<EFBFBD>ֵ
|
||
*/
|
||
#define SYS_GetChipID() R8_CHIP_ID
|
||
|
||
/**
|
||
* @brief <20><>ȡ<EFBFBD><C8A1>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD>ID<49><44>һ<EFBFBD><D2BB>Ϊ<EFBFBD>̶<EFBFBD>ֵ
|
||
*/
|
||
#define SYS_GetAccessID() R8_SAFE_ACCESS_ID
|
||
|
||
/**
|
||
* @brief <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
|
||
*
|
||
* @param sc - ϵͳʱ<CDB3><CAB1>Դѡ<D4B4><D1A1> refer to SYS_CLKTypeDef
|
||
*/
|
||
void SetSysClock(SYS_CLKTypeDef sc);
|
||
|
||
/**
|
||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰϵͳʱ<CDB3><CAB1>
|
||
*
|
||
* @return Hz
|
||
*/
|
||
uint32_t GetSysClock(void);
|
||
|
||
/**
|
||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰϵͳ<CFB5><CDB3>Ϣ״̬
|
||
*
|
||
* @param i - refer to SYS_InfoStaTypeDef
|
||
*
|
||
* @return <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
uint8_t SYS_GetInfoSta(SYS_InfoStaTypeDef i);
|
||
|
||
/**
|
||
* @brief <20><>ȡϵͳ<CFB5>ϴθ<CFB4>λ״̬
|
||
*
|
||
* @return refer to SYS_ResetStaTypeDef
|
||
*/
|
||
#define SYS_GetLastResetSta() (R8_RESET_STATUS & RB_RESET_FLAG)
|
||
|
||
/**
|
||
* @brief ִ<><D6B4>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
|
||
*/
|
||
void SYS_ResetExecute(void);
|
||
|
||
/**
|
||
* @brief <20><><EFBFBD>ø<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>λ<EFBFBD><CEBB> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB> <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD>Ѹ<EFBFBD>λ<EFBFBD><CEBB>Ӱ<EFBFBD><D3B0>
|
||
*
|
||
* @param i - refer to SYS_InfoStaTypeDef
|
||
*/
|
||
#define SYS_ResetKeepBuf(d) (R8_GLOB_RESET_KEEP = d)
|
||
|
||
/**
|
||
* @brief <20>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϣ<D0B6><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ж<EFBFBD>ֵ
|
||
*
|
||
* @param pirqv - <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ֵ
|
||
*/
|
||
void SYS_DisableAllIrq(uint32_t *pirqv);
|
||
|
||
/**
|
||
* @brief <20>ָ<EFBFBD>֮ǰ<D6AE>رյ<D8B1><D5B5>ж<EFBFBD>ֵ
|
||
*
|
||
* @param irq_status - <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ֵ
|
||
*/
|
||
void SYS_RecoverIrq(uint32_t irq_status);
|
||
|
||
/**
|
||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰϵͳ(SYSTICK)<29><><EFBFBD><EFBFBD>ֵ
|
||
*
|
||
* @return <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ֵ
|
||
*/
|
||
uint32_t SYS_GetSysTickCnt(void);
|
||
|
||
/**
|
||
* @brief <20><><EFBFBD>ؿ<EFBFBD><D8BF>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*
|
||
* @param c - <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
||
*/
|
||
#define WWDG_SetCounter(c) (R8_WDOG_COUNT = c)
|
||
|
||
/**
|
||
* @brief <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʹ<EFBFBD><CAB9>
|
||
*
|
||
* @param s - <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ж<EFBFBD>
|
||
*/
|
||
void WWDG_ITCfg(FunctionalState s);
|
||
|
||
/**
|
||
* @brief <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
||
*
|
||
* @param s - <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>λ
|
||
*/
|
||
void WWDG_ResetCfg(FunctionalState s);
|
||
|
||
/**
|
||
* @brief <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||
*
|
||
* @return <20><><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||
*/
|
||
#define WWDG_GetFlowFlag() (R8_RST_WDOG_CTRL & RB_WDOG_INT_FLAG)
|
||
|
||
/**
|
||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ź<EFBFBD><C5B9>жϱ<D0B6>־<EFBFBD><D6BE><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC>ؼ<EFBFBD><D8BC><EFBFBD>ֵҲ<D6B5><D2B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
void WWDG_ClearFlag(void);
|
||
|
||
/**
|
||
* @brief uS <20><>ʱ
|
||
*
|
||
* @param t - ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
void mDelayuS(uint16_t t);
|
||
|
||
/**
|
||
* @brief mS <20><>ʱ
|
||
*
|
||
* @param t - ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||
*/
|
||
void mDelaymS(uint16_t t);
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|
||
|
||
#endif // __CH58x_SYS_H__
|