/******************************************************************************* * * * File: hal_system.h * Description hal 通用系统接口头文件 * Version V0.1 * Date 2021-05-21 * Author lzy *******************************************************************************/ #ifndef __HAL_SYSTEM_H__ #define __HAL_SYSTEM_H__ /******************************************************************************* * 1.Included files *******************************************************************************/ #include "tau_common.h" /******************************************************************************* * 2.Global constant and macro definitions using #define *******************************************************************************/ /******************************************************************************* * 3.Global structures, unions and enumerations using typedef *******************************************************************************/ /******************************************************************************* * 4.Global variable extern declarations *******************************************************************************/ /******************************************************************************* * 5.Global function prototypes *******************************************************************************/ /** * @brief system 初始化 * @param none * @retval none */ void hal_system_init(uint32_t sysclk); /** * @brief system 初始化 console * @param baud_rate 波特率 * @retval none */ void hal_system_init_console(uint32_t baud_rate); /** * @brief mcu进入idle模式,等待中断唤醒 * @param disable_systick: 进入idle时是否关闭systick(退出idle 恢复systick) * @retval none */ void hal_system_idle_mode(bool disable_systick); /** * @brief 注册systick回调函数 * @param cb_func:回调函数地址 * @retval 无 */ void hal_system_register_systick_cb(fcb_type cb_func); /** * @brief 启动sys tickt * @param ms: sys tickt 间隔, 范围1-10ms * @retval true/false */ bool hal_system_enable_systick(uint8_t ms); /** * @brief 获取systickt * @param none * @retval 当前systickt值 */ bool hal_system_disable_systick(void); /** * @brief 获取systickt * @param none * @retval 当前systickt值 */ uint32_t hal_system_get_tick(void); /** * @brief 进入deep sleep mode 模式, 等待AP_RSTN 唤醒 * @param polarity true:上升沿唤醒, false:下降沿唤醒 * @retval none */ void hal_system_deep_sleep_mode(bool polarity); /** * @brief 配置共享flash开关(使用过后注意关闭,常开功耗会增加) * @param enable:true:可通过F_SPI访问内部flash , false:不可通过F_SPI访问内部flash * @retval true/false */ bool hal_system_share_flash_mode(bool enable); /** * @brief sleep mode 配置 * @param enable * @retval none */ void hal_system_sleep_mode(bool enable); /** * @brief reset chip * @param none * @retval none */ void hal_system_reset_chip(void); /** * @brief 开关PVD检测 * @param none * @retval none */ void hal_system_set_pvd(bool enable); /** * @brief VCC电源开关, * 使用场景: VCC掉电,13D与13M使用外灌电源时,关闭内部VCC供电,防止电源倒灌 * @param enable: true:打开CP, false:关闭CP * @retval none */ void hal_system_set_vcc(bool enable); /** * @brief 用户字节数组形式从flash读取数据,按页读取,每页1024字节 * @param *usr_cfg_t_addr(数组首地址), usr_cfg_t_size(数组大小可以超过1024,可以按页读也可连续跨页读) flash_page (页0~63) * @retval bool 无 */ bool hal_system_flash_read(uint8_t *usr_cfg_t_addr, uint16_t usr_cfg_t_size, uint8_t flash_page); /** * @brief 用户字节数组形式存入flash(次数有限,不可频繁写入),按页写入,每页1024字节 * @param *usr_cfg_t_addr(数组首地址), usr_cfg_t_size(数组大小可以超过1024,可以按页写也可连续跨页写入), 推荐按页顺序写入方式,第一次必须从0页开始写入,后续才可1~63任意页写入 flash_page (写入页0~63) * @retval bool 校验size是否超出 */ bool hal_system_flash_write(uint8_t *usr_cfg_t_addr, uint16_t usr_cfg_t_size, uint8_t flash_page); /** * @brief 控制flash退出deep sleep power mode * @param 发送0xAB指令 * @retval null */ void hal_system_flash_release_power_down(void); /** * @brief 控制flash进入deep sleep power mode * @param 发送0xB9指令 * @retval null */ void hal_system_flash_power_down(void); #if defined(ISP_568) || defined(ISP_368) /** * @brief 控制DPHY内部校准开关 * @param en: 使能开关 * @retval none */ void hal_system_set_phy_calibration(bool en); #endif /** * @brief 获取上位机设置的debug state * @param none * @retval debug state */ uint32_t hal_system_get_debug_state(void); /** * @brief clear debug state(debug only) * @param none * @retval none */ void hal_system_clear_debug_state(void); #endif //__HAL_SYSTEM_H__