94 lines
3.0 KiB
C
Executable File
94 lines
3.0 KiB
C
Executable File
/****************************************************************************
|
|
|
|
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 "iot_config.h"
|
|
#include "os_types.h"
|
|
#include "os_task.h"
|
|
#include "hw_reg_api.h"
|
|
#include "os_timer_api.h"
|
|
#include "phy_isr.h"
|
|
#include "phy_overstress.h"
|
|
#include "phy_bb.h"
|
|
#include "phy_reg.h"
|
|
#include "hw_phy_api.h"
|
|
#include "ahb.h"
|
|
#include "iot_io_api.h"
|
|
#include "phy_txrx_pwr.h"
|
|
|
|
/* driver includes */
|
|
#include "iot_system.h"
|
|
#include "iot_irq.h"
|
|
#include "iot_gpio_api.h"
|
|
#include "iot_board_api.h"
|
|
#include "pin_rf.h"
|
|
#include "phy_temperature.h"
|
|
|
|
extern iot_plc_over_stress_cb_t mac_ovr_stress_isr_cb;
|
|
|
|
#define PHY_OVERSTRESS_TIMER_PERIOD_S (3)
|
|
|
|
void phy_overstress_timer_handler()
|
|
{
|
|
#if HW_PLATFORM >= HW_PLATFORM_FPGA
|
|
|
|
static uint8_t cnt = 0;
|
|
cnt++;
|
|
if (cnt < PHY_OVERSTRESS_TIMER_PERIOD_S) {
|
|
return;
|
|
}
|
|
cnt = 0;
|
|
uint8_t over_stress_gpio = 0;
|
|
uint32_t reg_int = 0;
|
|
phy_overstress_ctxt_t *ovs_ctxt;
|
|
|
|
ovs_ctxt = &g_phy_ctxt.indep.ovs_ctxt;
|
|
if(ovs_ctxt->ovr_stress) {
|
|
/* after continous down cycles no ovs happen then handle power up */
|
|
if (ovs_ctxt->no_ovs_cnt > OVERSTRESS_DOWN_CYCLES) {
|
|
|
|
/* update flag if increase pwr */
|
|
ovs_ctxt->ovr_stress = 0;
|
|
|
|
/* mac callback send event overstress recover
|
|
* NOTE: Function phy_overstress_power_up is called by timer_handler
|
|
* not a real isr, so thers is a little performance loss.
|
|
*/
|
|
if (mac_ovr_stress_isr_cb != NULL) {
|
|
mac_ovr_stress_isr_cb(NULL, 0);
|
|
}
|
|
ovs_ctxt->no_ovs_cnt = 0;
|
|
} else {
|
|
ovs_ctxt->no_ovs_cnt++;
|
|
}
|
|
|
|
/* enable PA interrupt */
|
|
if(iot_chip_check_lic()) {/* internal PA */
|
|
/* disable irq */
|
|
os_disable_irq();
|
|
reg_int = PHY_READ_REG(CFG_BB_INT_EN_1_ADDR);
|
|
reg_int |=PHY_LIC_OVR_STRESS;
|
|
PHY_WRITE_REG(CFG_BB_INT_EN_1_ADDR, reg_int);
|
|
/* enable irq */
|
|
os_enable_irq();
|
|
} else {/* external PA */
|
|
over_stress_gpio = iot_board_get_gpio(GPIO_GEODE_OVT);
|
|
iot_gpio_interrupt_enable(over_stress_gpio, 1);
|
|
}
|
|
}
|
|
phy_temperature_adc_scan();
|
|
#endif
|
|
}
|
|
|