/**************************************************************************** Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED. This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT be copied by any method or incorporated into another program without the express written consent of Aerospace C.Power. This Information or any portion thereof remains the property of Aerospace C.Power. The Information contained herein is believed to be accurate and Aerospace C.Power assumes no responsibility or liability for its use in any way and conveys no license or title under any patent or copyright and makes no representation or warranty that this Information is free from patent or copyright infringement. ****************************************************************************/ #include "mac_rf_timer.h" #include "hw_reg_api.h" #include "rfplc_reg_base.h" #include "rf_mac_reg.h" #include "mac_sys_reg.h" #include "mac_rf_isr.h" uint32_t IRAM_ATTR mac_rf_timer_get_timeout_ids() { return RF_MAC_READ_REG(CFG_RF_MAC_COMMON_TIMER_REG_6_ADDR); } void IRAM_ATTR mac_rf_timer_clr_timeout_ids(uint32_t timer_ids) { RF_MAC_WRITE_REG(CFG_RF_MAC_COMMON_TIMER_REG_4_ADDR, timer_ids); } void mac_rf_timer_enable(uint32_t ids) { RF_MAC_WRITE_REG(CFG_RF_MAC_COMMON_TIMER_REG_0_ADDR, ids); RF_MAC_WRITE_REG(CFG_RF_MAC_COMMON_TIMER_REG_8_ADDR, ids); } void mac_rf_timer_enable_all() { /* enable all timer */ mac_rf_timer_enable(RF_MAC_COMMON_TIMER_CLR_CPU1_MASK); } void mac_rf_timer_disable_all() { /* disable all common timer */ mac_rf_timer_enable(0); /* clear all status */ RF_MAC_WRITE_REG(CFG_RF_MAC_COMMON_TIMER_REG_4_ADDR, RF_MAC_COMMON_TIMER_CLR_CPU1_MASK); } void mac_rf_timer_start(uint32_t timer_id) { RF_MAC_WRITE_REG(CFG_RF_MAC_COMMON_TIMER_REG_2_ADDR, (1 << timer_id)); } void mac_rf_timer_stop(uint32_t timer_id) { RF_MAC_WRITE_REG(CFG_RF_MAC_COMMON_TIMER_REG_4_ADDR, (1 << timer_id)); } void mac_rf_timer_set(uint32_t timer_id, uint32_t time_ntb) { IOT_ASSERT(timer_id < (RF_MAC_SW2_INT_MAX - RF_MAC_SW_INT_MAX) && time_ntb < MAC_RF_TIMER_MAX_TIME_NTB); uint32_t addr_base = CFG_RF_MAC_COMMON_TIMER_REG_10_ADDR; RF_MAC_WRITE_REG(addr_base + (timer_id * 4), time_ntb); }