mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2025-07-31 20:31:05 +00:00
update
This commit is contained in:
parent
b8c699eb1c
commit
3a865fb51d
40 changed files with 293 additions and 463 deletions
|
|
@ -707,14 +707,14 @@ void fATSP(void *arg) {
|
|||
switch (argv[1][0]) {
|
||||
case 'a': // acquire
|
||||
{
|
||||
pmu_acquire_wakelock(WAKELOCK_OS);
|
||||
acquire_wakelock(WAKELOCK_OS);
|
||||
//at_printf("\r\n[ATSP] wakelock:0x%08x", get_wakelock_status());
|
||||
break;
|
||||
}
|
||||
|
||||
case 'r': // release
|
||||
{
|
||||
pmu_release_wakelock(WAKELOCK_OS);
|
||||
release_wakelock(WAKELOCK_OS);
|
||||
//at_printf("\r\n[ATSP] wakelock:0x%08x", get_wakelock_status());
|
||||
break;
|
||||
}
|
||||
|
|
@ -1110,7 +1110,7 @@ void fATSL(void *arg) {
|
|||
{
|
||||
if (argc == 3) {
|
||||
lock_id = strtoul(argv[2], NULL, 16);
|
||||
pmu_acquire_wakelock(lock_id);
|
||||
acquire_wakelock(lock_id);
|
||||
}
|
||||
AT_DBG_MSG(AT_FLAG_OS, AT_DBG_ALWAYS, "[ATSL] wakelock:0x%08x",
|
||||
pmu_get_wakelock_status());
|
||||
|
|
@ -1121,7 +1121,7 @@ void fATSL(void *arg) {
|
|||
{
|
||||
if (argc == 3) {
|
||||
lock_id = strtoul(argv[2], NULL, 16);
|
||||
pmu_release_wakelock(lock_id);
|
||||
release_wakelock(lock_id);
|
||||
}
|
||||
AT_DBG_MSG(AT_FLAG_OS, AT_DBG_ALWAYS, "[ATSL] wakelock:0x%08x",
|
||||
pmu_get_wakelock_status());
|
||||
|
|
|
|||
|
|
@ -427,7 +427,7 @@ void log_service(void *param)
|
|||
log_service_unlock();
|
||||
#endif
|
||||
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
|
||||
pmu_release_wakelock(WAKELOCK_LOGUART);
|
||||
release_wakelock(WAKELOCK_LOGUART);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,12 @@
|
|||
#endif
|
||||
#include <osdep_service.h>
|
||||
|
||||
#include "sdk_ver.h"
|
||||
#if SDK_VER_NUM < 0x4000
|
||||
#define USE_WIFI_ADAPTER 1 // использовать прямое обращение в тело драйвера WiFi
|
||||
#else
|
||||
#define USE_WIFI_ADAPTER 0 // не использовать прямое обращение в тело драйвера WiFi (ещё не согласована struct adapter)
|
||||
#endif
|
||||
|
||||
int iw_ioctl(const char * ifname, unsigned long request, struct iwreq * pwrq) {
|
||||
memcpy(pwrq->ifr_name, ifname, 5);
|
||||
|
|
@ -32,7 +37,7 @@ int iw_ioctl(const char * ifname, unsigned long request, struct iwreq * pwrq) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef USE_WIFI_ADAPTER
|
||||
#if USE_WIFI_ADAPTER
|
||||
extern Rltk_wlan_t rltk_wlan_info[2]; // in wrapper.h
|
||||
LOCAL _adapter * get_padapter(const char *ifname) {
|
||||
if(ifname[4] == '0') {
|
||||
|
|
@ -46,7 +51,7 @@ LOCAL _adapter * get_padapter(const char *ifname) {
|
|||
|
||||
/* ssid = NULL -> not connected */
|
||||
int wext_get_ssid(const char *ifname, __u8 *ssid) {
|
||||
#ifdef USE_WIFI_ADAPTER
|
||||
#if USE_WIFI_ADAPTER
|
||||
_adapter * pad = get_padapter(ifname);
|
||||
rtw_result_t ret = RTW_ERROR;
|
||||
if(pad != NULL && (pad->mlmepriv.fw_state & 0x41) != 0) {
|
||||
|
|
@ -250,7 +255,7 @@ int wext_get_mac_address(const char *ifname, char * mac)
|
|||
#endif
|
||||
|
||||
int wext_enable_powersave(const char *ifname, __u8 ips_mode, __u8 lps_mode) {
|
||||
#ifdef USE_WIFI_ADAPTER
|
||||
#if USE_WIFI_ADAPTER
|
||||
_adapter * pad = get_padapter(ifname);
|
||||
rtw_result_t ret = RTW_ERROR;
|
||||
if(pad) {
|
||||
|
|
@ -303,7 +308,7 @@ int wext_disable_powersave(const char *ifname) {
|
|||
|
||||
int wext_set_tdma_param(const char *ifname, __u8 slot_period,
|
||||
__u8 rfon_period_len_1, __u8 rfon_period_len_2, __u8 rfon_period_len_3) {
|
||||
#ifdef USE_WIFI_ADAPTER
|
||||
#if USE_WIFI_ADAPTER
|
||||
_adapter * pad = get_padapter(ifname);
|
||||
rtw_result_t ret = RTW_ERROR;
|
||||
if(pad) {
|
||||
|
|
@ -336,7 +341,7 @@ int wext_set_tdma_param(const char *ifname, __u8 slot_period,
|
|||
}
|
||||
|
||||
int wext_set_lps_dtim(const char *ifname, __u8 lps_dtim) {
|
||||
#ifdef USE_WIFI_ADAPTER
|
||||
#if USE_WIFI_ADAPTER
|
||||
_adapter * pad = get_padapter(ifname);
|
||||
rtw_result_t ret = RTW_ERROR;
|
||||
if(pad) {
|
||||
|
|
@ -365,7 +370,7 @@ int wext_set_lps_dtim(const char *ifname, __u8 lps_dtim) {
|
|||
}
|
||||
|
||||
int wext_get_lps_dtim(const char *ifname, __u8 *lps_dtim) {
|
||||
#ifdef USE_WIFI_ADAPTER
|
||||
#if USE_WIFI_ADAPTER
|
||||
_adapter * pad = get_padapter(ifname);
|
||||
rtw_result_t ret = RTW_ERROR;
|
||||
if(pad) {
|
||||
|
|
@ -506,7 +511,7 @@ int wext_get_ap_info(const char *ifname, rtw_bss_info_t * ap_info,
|
|||
#endif
|
||||
|
||||
int wext_set_mode(const char *ifname, int mode) {
|
||||
#ifdef USE_WIFI_ADAPTER
|
||||
#if USE_WIFI_ADAPTER
|
||||
_adapter * pad = get_padapter(ifname);
|
||||
int nwm;
|
||||
if(rtw_pwr_wakeup(pad) && pad->hw_init_completed) {
|
||||
|
|
@ -540,7 +545,7 @@ int wext_set_mode(const char *ifname, int mode) {
|
|||
}
|
||||
|
||||
int wext_get_mode(const char *ifname, int *mode) {
|
||||
#ifdef USE_WIFI_ADAPTER
|
||||
#if USE_WIFI_ADAPTER
|
||||
_adapter * pad = get_padapter(ifname);
|
||||
rtw_result_t ret = RTW_ERROR;
|
||||
if(pad) {
|
||||
|
|
@ -563,7 +568,7 @@ int wext_get_mode(const char *ifname, int *mode) {
|
|||
}
|
||||
|
||||
int wext_set_ap_ssid(const char *ifname, const __u8 *ssid, __u16 ssid_len) {
|
||||
#ifdef USE_WIFI_ADAPTER
|
||||
#if USE_WIFI_ADAPTER
|
||||
struct net_device * pdev = rltk_wlan_info[0].dev;
|
||||
if(ifname[4] != '0')
|
||||
pdev = rltk_wlan_info[1].dev;
|
||||
|
|
@ -593,7 +598,7 @@ int wext_set_country(const char *ifname, rtw_country_code_t country_code) {
|
|||
}
|
||||
|
||||
int wext_get_rssi(const char *ifname, int *rssi) {
|
||||
#ifdef USE_WIFI_ADAPTER
|
||||
#if USE_WIFI_ADAPTER
|
||||
_adapter * pad = get_padapter(ifname);
|
||||
rtw_result_t ret = RTW_ERROR;
|
||||
if(pad) {
|
||||
|
|
@ -671,7 +676,7 @@ int wext_set_channel(const char *ifname, __u8 ch) {
|
|||
}
|
||||
|
||||
int wext_get_channel(const char *ifname, __u8 *ch) {
|
||||
#ifdef USE_WIFI_ADAPTER
|
||||
#if USE_WIFI_ADAPTER
|
||||
_adapter * pad = get_padapter(ifname);
|
||||
rtw_result_t ret = RTW_ERROR;
|
||||
if(pad) {
|
||||
|
|
|
|||
|
|
@ -248,16 +248,16 @@ LOCAL uint8 chk_ap_netif_num(void)
|
|||
|
||||
extern Rltk_wlan_t rltk_wlan_info[2]; // in wrapper.h
|
||||
|
||||
/*LOCAL _adapter * get_padapter(int num) {
|
||||
/*LOCAL _adapter * get_padaptern(int num) {
|
||||
if(rltk_wlan_info[num].enable) {
|
||||
return *(_adapter **)((rltk_wlan_info[0].dev)->priv);
|
||||
}
|
||||
return NULL;
|
||||
};*/
|
||||
#define get_padapter(num) (*(_adapter **)((rltk_wlan_info[num].dev)->priv));
|
||||
#define get_padaptern(num) (*(_adapter **)((rltk_wlan_info[num].dev)->priv));
|
||||
|
||||
LOCAL rtw_result_t _wext_set_lps_dtim(int adapter_num, uint8 lps_dtim ) {
|
||||
_adapter * pad = get_padapter(adapter_num);
|
||||
rtw_result_t _wext_set_lps_dtim(int adapter_num, uint8 lps_dtim ) {
|
||||
_adapter * pad = get_padaptern(adapter_num);
|
||||
rtw_result_t ret = RTW_ERROR;
|
||||
if(pad) {
|
||||
ret = rtw_pm_set_lps_dtim(pad, lps_dtim);
|
||||
|
|
@ -265,8 +265,13 @@ LOCAL rtw_result_t _wext_set_lps_dtim(int adapter_num, uint8 lps_dtim ) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
LOCAL rtw_result_t _wext_enable_powersave(int adapter_num, uint8 ips_mode, uint8 lps_mode) {
|
||||
_adapter * pad = get_padapter(adapter_num);
|
||||
int _wext_get_lps_dtim(int adapter_num) {
|
||||
_adapter * pad = get_padaptern(adapter_num);
|
||||
return rtw_pm_get_lps_dtim(pad);
|
||||
}
|
||||
|
||||
rtw_result_t _wext_enable_powersave(int adapter_num, uint8 ips_mode, uint8 lps_mode) {
|
||||
_adapter * pad = get_padaptern(adapter_num);
|
||||
rtw_result_t ret = RTW_ERROR;
|
||||
if(pad) {
|
||||
ret = rtw_pm_set_ips(pad, ips_mode); // 2 режима 1,2 !
|
||||
|
|
@ -280,7 +285,7 @@ LOCAL rtw_result_t _wext_enable_powersave(int adapter_num, uint8 ips_mode, uint8
|
|||
|
||||
LOCAL int _wext_cmp_ssid(int adapter_num, uint8 *ssid)
|
||||
{
|
||||
_adapter * pad = get_padapter(adapter_num);
|
||||
_adapter * pad = get_padaptern(adapter_num);
|
||||
int ret = 0;
|
||||
if((pad != NULL) && (pad->mlmepriv.fw_state & 0x41) != 0) {
|
||||
int len = pad->mlmepriv.cur_network.network.Ssid.SsidLength;
|
||||
|
|
@ -295,7 +300,7 @@ LOCAL int _wext_cmp_ssid(int adapter_num, uint8 *ssid)
|
|||
#ifdef NOT_USE_CALLS
|
||||
|
||||
LOCAL rtw_result_t _wext_get_mode(int adapter_num, int *mode) {
|
||||
_adapter * pad = get_padapter(adapter_num);
|
||||
_adapter * pad = get_padaptern(adapter_num);
|
||||
rtw_result_t ret = RTW_ERROR;
|
||||
if(pad) {
|
||||
uint16 f = pad->mlmepriv.fw_state;
|
||||
|
|
@ -310,7 +315,7 @@ LOCAL rtw_result_t _wext_get_mode(int adapter_num, int *mode) {
|
|||
|
||||
LOCAL rtw_result_t _wext_get_channel(int adapter_num, uint8 *ch)
|
||||
{
|
||||
_adapter * pad = get_padapter(adapter_num);
|
||||
_adapter * pad = get_padaptern(adapter_num);
|
||||
rtw_result_t ret = RTW_ERROR;
|
||||
if(pad) {
|
||||
if(pad->mlmepriv.fw_state & 1) {
|
||||
|
|
|
|||
|
|
@ -185,4 +185,8 @@ rtw_result_t api_wifi_scan(api_scan_result_handler_t scan_result_cb);
|
|||
void wifi_close_scan(void);
|
||||
|
||||
|
||||
rtw_result_t _wext_set_lps_dtim(int adapter_num, uint8 lps_dtim);
|
||||
int _wext_get_lps_dtim(int adapter_num);
|
||||
rtw_result_t _wext_enable_powersave(int adapter_num, uint8 ips_mode, uint8 lps_mode);
|
||||
|
||||
#endif // _WIFI_API_H_
|
||||
|
|
|
|||
|
|
@ -1977,6 +1977,53 @@ struct hal_ops {
|
|||
uint8_t (*hal_get_tx_buff_rsvd_page_num)(_adapter *, bool);
|
||||
};
|
||||
|
||||
/* 138 */
|
||||
typedef enum _P2P_ROLE // : __int32
|
||||
{
|
||||
P2P_ROLE_DISABLE = 0x0,
|
||||
P2P_ROLE_DEVICE = 0x1,
|
||||
P2P_ROLE_CLIENT = 0x2,
|
||||
P2P_ROLE_GO = 0x3,
|
||||
} P2P_ROLE;
|
||||
|
||||
typedef enum P2P_STATE // : __int32
|
||||
{
|
||||
P2P_STATE_NONE = 0x0,
|
||||
P2P_STATE_IDLE = 0x1,
|
||||
P2P_STATE_LISTEN = 0x2,
|
||||
P2P_STATE_SCAN = 0x3,
|
||||
P2P_STATE_FIND_PHASE_LISTEN = 0x4,
|
||||
P2P_STATE_FIND_PHASE_SEARCH = 0x5,
|
||||
P2P_STATE_TX_PROVISION_DIS_REQ = 0x6,
|
||||
P2P_STATE_RX_PROVISION_DIS_RSP = 0x7,
|
||||
P2P_STATE_RX_PROVISION_DIS_REQ = 0x8,
|
||||
P2P_STATE_GONEGO_ING = 0x9,
|
||||
P2P_STATE_GONEGO_OK = 0xA,
|
||||
P2P_STATE_GONEGO_FAIL = 0xB,
|
||||
P2P_STATE_RECV_INVITE_REQ_MATCH = 0xC,
|
||||
P2P_STATE_PROVISIONING_ING = 0xD,
|
||||
P2P_STATE_PROVISIONING_DONE = 0xE,
|
||||
P2P_STATE_TX_INVITE_REQ = 0xF,
|
||||
P2P_STATE_RX_INVITE_RESP = 0x10,
|
||||
P2P_STATE_RECV_INVITE_REQ_DISMATCH = 0x11,
|
||||
P2P_STATE_RECV_INVITE_REQ_GO = 0x12,
|
||||
P2P_STATE_RECV_INVITE_REQ_JOIN = 0x13,
|
||||
P2P_STATE_FORMATION_COMPLETE = 0x14,
|
||||
P2P_STATE_CONNECTED = 0x15,
|
||||
} P2P_STATE;
|
||||
|
||||
|
||||
struct wifidirect_info
|
||||
{
|
||||
P2P_ROLE role;
|
||||
P2P_STATE p2p_state;
|
||||
uint8_t baction_tx_pending;
|
||||
uint8_t pending_peer[6];
|
||||
struct xmit_frame *pending_action;
|
||||
_timer pre_tx_scan_timer;
|
||||
};
|
||||
|
||||
|
||||
struct _atr_aligned4_ _ADAPTER {
|
||||
uint16_t HardwareType;
|
||||
uint16_t interface_type; //+2
|
||||
|
|
@ -1994,6 +2041,9 @@ struct _atr_aligned4_ _ADAPTER {
|
|||
struct registry_priv registrypriv;
|
||||
struct pwrctrl_priv pwrctrlpriv; // pwrctrlpriv.bInternalAutoSuspend //+5061
|
||||
struct eeprom_priv eeprompriv;
|
||||
|
||||
struct wifidirect_info wdinfo;
|
||||
|
||||
PVOID HalData;
|
||||
uint32_t hal_data_sz;
|
||||
struct hal_ops HalFunc;
|
||||
|
|
@ -2024,14 +2074,22 @@ struct _atr_aligned4_ _ADAPTER {
|
|||
uint8_t bRxRSSIDisplay;
|
||||
_adapter *pbuddy_adapter; //+6056
|
||||
_mutex *hw_init_mutex; //+6060
|
||||
|
||||
_mutex *ph2c_fwcmd_mutex;
|
||||
|
||||
uint8_t isprimary; //+6064
|
||||
uint8_t adapter_type; //+6065
|
||||
uint8_t iface_type; //+6056
|
||||
_mutex *ph2c_fwcmd_mutex; //+6068
|
||||
// _mutex *ph2c_fwcmd_mutex; //+6068
|
||||
_mutex *psetch_mutex; //+6072
|
||||
_mutex *psetbw_mutex; //+6076
|
||||
struct co_data_priv *pcodatapriv; //+6080
|
||||
uint8_t fix_rate; //+6084
|
||||
|
||||
uint8_t ra_mask_user_en;
|
||||
uint32_t ra_mask_define;
|
||||
uint8_t auto_rate_fallback_user_en;
|
||||
|
||||
}; // [6088] (!)
|
||||
typedef struct _ADAPTER *PADAPTER;
|
||||
// if sizeof(struct _ADAPTER) != 6088 #error "Check aligned struct!" !
|
||||
|
|
|
|||
|
|
@ -1287,8 +1287,10 @@ extern void LPS_Enter(PADAPTER padapter);
|
|||
extern void LPS_Leave(PADAPTER padapter);
|
||||
extern void LeaveAllPowerSaveMode(PADAPTER Adapter);
|
||||
extern void rtw_init_pwrctrl_priv(PADAPTER padapter);
|
||||
extern void rtw_free_pwrctrl_priv(PADAPTER adapter);
|
||||
extern int rtw_pwr_wakeup(_adapter *padapter, uint32_t ips_deffer_ms, const char *caller);
|
||||
extern void rtw_free_pwrctrl_priv(PADAPTER adapter);
|
||||
extern int _rtw_pwr_wakeup(_adapter *padapter, uint32_t ips_deffer_ms, const char *caller);
|
||||
#define RTW_PWR_STATE_CHK_INTERVAL 2000
|
||||
#define rtw_pwr_wakeup(adapter) _rtw_pwr_wakeup(adapter, RTW_PWR_STATE_CHK_INTERVAL, __FUNCTION__)
|
||||
extern int rtw_pm_set_lps(_adapter *padapter, int mode);
|
||||
extern int rtw_pm_set_ips(_adapter *padapter, int mode);
|
||||
extern int rtw_pm_set_tdma_param(_adapter *padapter, uint8_t tdma_slot_period, uint8_t tdma_rfon_period_len_1, uint8_t tdma_rfon_period_len_2, uint8_t tdma_rfon_period_len_3);
|
||||
|
|
|
|||
|
|
@ -34,8 +34,13 @@ void sys_recover_ota_signature(void);
|
|||
void sys_log_uart_on(void);
|
||||
void sys_log_uart_off(void);
|
||||
void sys_adc_calibration(u8 write, u16 *offset, u16 *gain);
|
||||
u8 sys_is_sdram_power_on(void);
|
||||
#ifdef CONFIG_SDR_EN
|
||||
void sys_sdram_off(void);
|
||||
u8 sys_is_sdram_power_on(void);
|
||||
#else
|
||||
#define sys_sdram_off()
|
||||
#define sys_is_sdram_power_on() (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief system software reset
|
||||
|
|
|
|||
|
|
@ -203,28 +203,16 @@ void sys_reset(void)
|
|||
(1 << 2)); // SYSRESETREQ
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SDR_EN
|
||||
u8 sys_is_sdram_power_on(void)
|
||||
{
|
||||
#ifdef CONFIG_SDR_EN
|
||||
// u8 ison = 0;
|
||||
|
||||
//#if defined ( __ICCARM__ )
|
||||
return IsSdrPowerOn();
|
||||
//#endif
|
||||
|
||||
// return ison;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void sys_sdram_off(void)
|
||||
{
|
||||
#ifdef CONFIG_SDR_EN
|
||||
//#if defined ( __ICCARM__ )
|
||||
if (IsSdrPowerOn()) {
|
||||
SdrPowerOff();
|
||||
}
|
||||
//#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,298 +0,0 @@
|
|||
/*
|
||||
* SDK ver 3.5.2 !
|
||||
*/
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#include "freertos_pmu.h"
|
||||
|
||||
#include <platform_opts.h>
|
||||
|
||||
#include "platform_autoconf.h"
|
||||
#include "sys_api.h"
|
||||
#include "sleep_ex_api.h"
|
||||
#include "gpio_api.h"
|
||||
#include "us_ticker_api.h"
|
||||
|
||||
#include "task.h"
|
||||
|
||||
#ifndef portNVIC_SYSTICK_CURRENT_VALUE_REG
|
||||
#define portNVIC_SYSTICK_CURRENT_VALUE_REG ( * ( ( volatile uint32_t * ) 0xe000e018 ) )
|
||||
#endif
|
||||
|
||||
uint32_t missing_tick = 0;
|
||||
|
||||
#define FREERTOS_PMU_DISABLE_LOGUART_IN_TICKLESS (0)
|
||||
|
||||
static uint32_t wakelock = DEFAULT_WAKELOCK;
|
||||
static uint32_t wakeup_event = DEFAULT_WAKEUP_EVENT;
|
||||
|
||||
freertos_sleep_callback pre_sleep_callback[32] = {NULL};
|
||||
freertos_sleep_callback post_sleep_callback[32] = {NULL};
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
static u8 last_wakelock_state[32] = {
|
||||
DEFAULT_WAKELOCK & 0x01, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
static u32 last_acquire_wakelock_time[32] = {0};
|
||||
static u32 hold_wakelock_time[32] = {0};
|
||||
static u32 base_sys_time = 0;
|
||||
static u32 sys_sleep_time = 0;
|
||||
#endif
|
||||
|
||||
#if defined(FREERTOS_PMU_TICKLESS_PLL_RESERVED) && (FREERTOS_PMU_TICKLESS_PLL_RESERVED==1)
|
||||
unsigned char reserve_pll = 1;
|
||||
#else
|
||||
unsigned char reserve_pll = 0;
|
||||
#endif
|
||||
|
||||
|
||||
/* ++++++++ FreeRTOS macro implementation ++++++++ */
|
||||
|
||||
/*
|
||||
* It is called in idle task.
|
||||
*
|
||||
* @return true : System is ready to check conditions that if it can enter sleep.
|
||||
* false : System keep awake.
|
||||
**/
|
||||
int freertos_ready_to_sleep() {
|
||||
return wakelock == 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* It is called when freertos is going to sleep.
|
||||
* At this moment, all sleep conditons are satisfied. All freertos' sleep pre-processing are done.
|
||||
*
|
||||
* @param expected_idle_time : The time that FreeRTOS expect to sleep.
|
||||
* If we set this value to 0 then FreeRTOS will do nothing in its sleep function.
|
||||
**/
|
||||
void freertos_pre_sleep_processing(unsigned int *expected_idle_time) {
|
||||
|
||||
#ifdef CONFIG_SOC_PS_MODULE
|
||||
|
||||
uint32_t i;
|
||||
uint32_t stime;
|
||||
uint32_t tick_before_sleep;
|
||||
uint32_t tick_after_sleep;
|
||||
uint32_t tick_passed;
|
||||
uint32_t backup_systick_reg;
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
uint32_t kernel_tick_before_sleep;
|
||||
uint32_t kernel_tick_after_sleep;
|
||||
#endif
|
||||
|
||||
/* To disable freertos sleep function and use our sleep function,
|
||||
* we can set original expected idle time to 0. */
|
||||
stime = *expected_idle_time;
|
||||
*expected_idle_time = 0;
|
||||
|
||||
for (i=0; i<32; i++) {
|
||||
if ( pre_sleep_callback[i] != NULL) {
|
||||
pre_sleep_callback[i]( stime );
|
||||
}
|
||||
}
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
kernel_tick_before_sleep = osKernelSysTick();
|
||||
#endif
|
||||
|
||||
// Store gtimer timestamp before sleep
|
||||
tick_before_sleep = us_ticker_read();
|
||||
|
||||
#if (FREERTOS_PMU_DISABLE_LOGUART_IN_TICKLESS)
|
||||
// config gpio on log uart tx for pull ctrl
|
||||
HAL_GPIO_PIN gpio_log_uart_tx;
|
||||
gpio_log_uart_tx.pin_name = gpio_set(PB_0);
|
||||
gpio_log_uart_tx.pin_mode = DOUT_PUSH_PULL;
|
||||
HAL_GPIO_Init(&gpio_log_uart_tx);
|
||||
GpioFunctionChk(PB_0, ENABLE);
|
||||
|
||||
sys_log_uart_off();
|
||||
HAL_GPIO_WritePin(&gpio_log_uart_tx, 1); // pull up log uart tx to avoid power lekage
|
||||
#endif
|
||||
|
||||
backup_systick_reg = portNVIC_SYSTICK_CURRENT_VALUE_REG;
|
||||
|
||||
#ifdef CONFIG_SDR_EN
|
||||
// sleep
|
||||
#if defined(FREERTOS_PMU_TICKLESS_SUSPEND_SDRAM) && (FREERTOS_PMU_TICKLESS_SUSPEND_SDRAM!=0)
|
||||
sleep_ex_selective(wakeup_event, stime, reserve_pll, IsSdrPowerOn());
|
||||
#else
|
||||
sleep_ex_selective(wakeup_event, stime, reserve_pll, 0);
|
||||
#endif
|
||||
#else
|
||||
sleep_ex_selective(wakeup_event, stime, reserve_pll, 0);
|
||||
#endif // CONFIG_SDR_EN
|
||||
|
||||
portNVIC_SYSTICK_CURRENT_VALUE_REG = backup_systick_reg;
|
||||
|
||||
#if (FREERTOS_PMU_DISABLE_LOGUART_IN_TICKLESS)
|
||||
sys_log_uart_off();
|
||||
sys_log_uart_on();
|
||||
#endif
|
||||
|
||||
// update kernel tick by calculating passed tick from gtimer
|
||||
{
|
||||
// get current gtimer timestamp
|
||||
tick_after_sleep = us_ticker_read();
|
||||
|
||||
// calculated passed time
|
||||
if (tick_after_sleep > tick_before_sleep) {
|
||||
tick_passed = tick_after_sleep - tick_before_sleep;
|
||||
} else {
|
||||
// overflow
|
||||
tick_passed = (0xffffffff - tick_before_sleep) + tick_after_sleep;
|
||||
}
|
||||
|
||||
/* If there is a rapid interrupt (<1ms), it makes tick_passed less than 1ms.
|
||||
* The tick_passed would be rounded and make OS can't step tick.
|
||||
* We collect the rounded tick_passed into missing_tick and step tick properly.
|
||||
* */
|
||||
tick_passed += missing_tick;
|
||||
if (tick_passed > stime * 1000) {
|
||||
missing_tick = tick_passed - stime * 1000;
|
||||
tick_passed = stime * 1000;
|
||||
} else {
|
||||
missing_tick = tick_passed % 1000;
|
||||
}
|
||||
|
||||
// update kernel tick
|
||||
vTaskStepTick( tick_passed/1000 );
|
||||
}
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
kernel_tick_after_sleep = osKernelSysTick();
|
||||
sys_sleep_time += (kernel_tick_after_sleep - kernel_tick_before_sleep);
|
||||
#endif
|
||||
|
||||
for (i=0; i<32; i++) {
|
||||
if ( post_sleep_callback[i] != NULL) {
|
||||
post_sleep_callback[i]( stime );
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
// If PS is not enabled, then use freertos sleep function
|
||||
#endif
|
||||
}
|
||||
|
||||
void freertos_post_sleep_processing(unsigned int *expected_idle_time) {
|
||||
#ifndef configSYSTICK_CLOCK_HZ
|
||||
*expected_idle_time = 1 + ( portNVIC_SYSTICK_CURRENT_VALUE_REG / ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) );
|
||||
#else
|
||||
*expected_idle_time = 1 + ( portNVIC_SYSTICK_CURRENT_VALUE_REG / ( configSYSTICK_CLOCK_HZ / configTICK_RATE_HZ ) );
|
||||
#endif
|
||||
}
|
||||
/* -------- FreeRTOS macro implementation -------- */
|
||||
|
||||
void acquire_wakelock(uint32_t lock_id) {
|
||||
|
||||
wakelock |= lock_id;
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
u32 i;
|
||||
u32 current_timestamp = osKernelSysTick();
|
||||
for (i=0; i<32; i++) {
|
||||
if ( (1<<i & lock_id) && (last_wakelock_state[i] == 0) ) {
|
||||
last_acquire_wakelock_time[i] = current_timestamp;
|
||||
last_wakelock_state[i] = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void release_wakelock(uint32_t lock_id) {
|
||||
wakelock &= ~lock_id;
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
u32 i;
|
||||
u32 current_timestamp = osKernelSysTick();
|
||||
for (i=0; i<32; i++) {
|
||||
if ( (1<<i & lock_id) && (last_wakelock_state[i] == 1) ) {
|
||||
hold_wakelock_time[i] += current_timestamp - last_acquire_wakelock_time[i];
|
||||
last_wakelock_state[i] = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
uint32_t get_wakelock_status() {
|
||||
return wakelock;
|
||||
}
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
void get_wakelock_hold_stats( char *pcWriteBuffer ) {
|
||||
u32 i;
|
||||
u32 current_timestamp = osKernelSysTick();
|
||||
|
||||
*pcWriteBuffer = 0x00;
|
||||
|
||||
// print header
|
||||
sprintf(pcWriteBuffer, "wakelock_id\tholdtime\r\n");
|
||||
pcWriteBuffer += strlen( pcWriteBuffer );
|
||||
|
||||
for (i=0; i<32; i++) {
|
||||
if (last_wakelock_state[i] == 1) {
|
||||
sprintf(pcWriteBuffer, "%x\t\t%d\r\n", i, hold_wakelock_time[i] + (current_timestamp - last_acquire_wakelock_time[i]));
|
||||
} else {
|
||||
if (hold_wakelock_time[i] > 0) {
|
||||
sprintf(pcWriteBuffer, "%x\t\t%d\r\n", i, hold_wakelock_time[i]);
|
||||
}
|
||||
}
|
||||
pcWriteBuffer += strlen( pcWriteBuffer );
|
||||
}
|
||||
sprintf(pcWriteBuffer, "time passed: %d ms, system sleep %d ms\r\n", current_timestamp - base_sys_time, sys_sleep_time);
|
||||
}
|
||||
|
||||
void clean_wakelock_stat() {
|
||||
u32 i;
|
||||
base_sys_time = osKernelSysTick();
|
||||
for (i=0; i<32; i++) {
|
||||
hold_wakelock_time[i] = 0;
|
||||
if (last_wakelock_state[i] == 1) {
|
||||
last_acquire_wakelock_time[i] = base_sys_time;
|
||||
}
|
||||
}
|
||||
sys_sleep_time = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void add_wakeup_event(uint32_t event) {
|
||||
wakeup_event |= event;
|
||||
}
|
||||
|
||||
void del_wakeup_event(uint32_t event) {
|
||||
wakeup_event &= ~event;
|
||||
// To fulfill tickless design, system timer is required to be wakeup event
|
||||
wakeup_event |= SLEEP_WAKEUP_BY_STIMER;
|
||||
}
|
||||
|
||||
void register_sleep_callback_by_module( unsigned char is_pre_sleep, freertos_sleep_callback sleep_cb, uint32_t module ) {
|
||||
u32 i;
|
||||
for (i=0; i<32; i++) {
|
||||
if ( module & BIT(i) ) {
|
||||
if (is_pre_sleep) {
|
||||
pre_sleep_callback[i] = sleep_cb;
|
||||
} else {
|
||||
post_sleep_callback[i] = sleep_cb;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void register_pre_sleep_callback( freertos_sleep_callback pre_sleep_cb ) {
|
||||
register_sleep_callback_by_module(1, pre_sleep_cb, 0x00008000);
|
||||
}
|
||||
|
||||
void register_post_sleep_callback( freertos_sleep_callback post_sleep_cb ) {
|
||||
register_sleep_callback_by_module(0, post_sleep_cb, 0x00008000);
|
||||
}
|
||||
|
||||
void set_pll_reserved(unsigned char reserve) {
|
||||
reserve_pll = reserve;
|
||||
}
|
||||
|
|
@ -41,20 +41,20 @@ typedef enum PMU_DEVICE {
|
|||
|
||||
#ifdef CONFIG_PLATFORM_8711B
|
||||
typedef enum {
|
||||
PMU_OS =0,
|
||||
PMU_OS =0,
|
||||
PMU_WLAN_DEVICE =1,
|
||||
PMU_LOGUART_DEVICE =2,
|
||||
PMU_SDIO_DEVICE =3,
|
||||
|
||||
PMU_UART0_DEVICE =4,
|
||||
PMU_UART1_DEVICE =5,
|
||||
PMU_UART0_DEVICE =4,
|
||||
PMU_UART1_DEVICE =5,
|
||||
PMU_I2C0_DEVICE =6,
|
||||
PMU_I2C1_DEVICE =7,
|
||||
PMU_USOC_DEVICE =8,
|
||||
PMU_DONGLE_DEVICE =9,
|
||||
PMU_RTC_DEVICE =10,
|
||||
PMU_CONSOL_DEVICE =11,
|
||||
PMU_ADC_DEVICE =12,
|
||||
PMU_ADC_DEVICE =12,
|
||||
PMU_DEV_USER_BASE =16,
|
||||
|
||||
PMU_MAX =31
|
||||
|
|
@ -81,7 +81,9 @@ typedef uint32_t (*PSM_HOOK_FUN)( unsigned int, void* param_ptr );
|
|||
*
|
||||
* @param nDeviceId : The bit which is attempt to add into wakelock
|
||||
*/
|
||||
void pmu_acquire_wakelock(uint32_t nDeviceId);
|
||||
//void pmu_acquire_wakelock(uint32_t nDeviceId);
|
||||
void acquire_wakelock(uint32_t flg);
|
||||
#define pmu_acquire_wakelock(nDeviceId) acquire_wakelock(1<<(nDeviceId))
|
||||
|
||||
/** Release wakelock
|
||||
*
|
||||
|
|
@ -89,13 +91,17 @@ void pmu_acquire_wakelock(uint32_t nDeviceId);
|
|||
*
|
||||
* @param nDeviceId : The bit which is attempt to remove from wakelock
|
||||
*/
|
||||
void pmu_release_wakelock(uint32_t nDeviceId);
|
||||
//void pmu_release_wakelock(uint32_t nDeviceId);
|
||||
void release_wakelock(uint32_t flg);
|
||||
#define pmu_release_wakelock(nDeviceId) release_wakelock(1<<(nDeviceId))
|
||||
|
||||
/** Get current wakelock bit map value
|
||||
*
|
||||
* @return : the current wakelock bit map value
|
||||
*/
|
||||
uint32_t pmu_get_wakelock_status(void);
|
||||
//uint32_t pmu_get_wakelock_status(void);
|
||||
uint32_t get_wakelock_status(void);
|
||||
#define pmu_get_wakelock_status get_wakelock_status
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
|
||||
|
|
|
|||
|
|
@ -360,12 +360,15 @@ static void _freertos_msleep_os(int ms)
|
|||
#endif
|
||||
}
|
||||
|
||||
extern void wait_us(int us); // До 2.147483648 секунды!
|
||||
|
||||
static void _freertos_usleep_os(int us)
|
||||
{
|
||||
#if defined(STM32F2XX) || defined(STM32F4XX) || defined(STM32F10X_XL)
|
||||
// FreeRTOS does not provide us level delay. Use busy wait
|
||||
WLAN_BSP_UsLoop(us);
|
||||
#elif defined(CONFIG_PLATFORM_8195A)
|
||||
wait_us(us);
|
||||
//DBG_ERR("%s: Please Implement micro-second delay\n", __FUNCTION__);
|
||||
#elif defined(CONFIG_PLATFORM_8711B)
|
||||
DelayUs(us);
|
||||
|
|
@ -385,7 +388,8 @@ static void _freertos_udelay_os(int us)
|
|||
// FreeRTOS does not provide us level delay. Use busy wait
|
||||
WLAN_BSP_UsLoop(us);
|
||||
#elif defined(CONFIG_PLATFORM_8195A)
|
||||
HalDelayUs(us);
|
||||
// HalDelayUs(us);
|
||||
wait_us(us);
|
||||
#elif defined(CONFIG_PLATFORM_8711B)
|
||||
DelayUs(us);
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ IIR[3:0]:
|
|||
typedef enum {
|
||||
RU_IIR_MODEM_STATUS = 0, //Clear to send or data set ready or ring indicator or data carrier detect.
|
||||
RU_IIR_NO_PENDING = 1,
|
||||
RU_IIR_THR_EMPTY = 2, // TX FIFO level lower than threshold or FIFO empty
|
||||
RU_IIR_RX_RDY = 4, // RX data ready
|
||||
RU_IIR_RX_LINE_STATUS = 6, // Overrun/parity/framing errors or break interrupt
|
||||
RU_IIR_THR_EMPTY = 2, // TX FIFO level lower than threshold or FIFO empty
|
||||
RU_IIR_RX_RDY = 4, // RX data ready
|
||||
RU_IIR_RX_LINE_STATUS = 6, // Overrun/parity/framing errors or break interrupt
|
||||
RU_IIR_BUSY = 7,
|
||||
RU_IIR_CHAR_TIMEOUT = 12 // timeout: Rx data ready but no read
|
||||
RU_IIR_CHAR_TIMEOUT = 12 // timeout: Rx data ready but no read
|
||||
} RUART_INT_ID;
|
||||
#define RUART_IIR_INT_PEND 0x01
|
||||
#define RUART_IIR_INT_ID (0x07<<1) //011(3), 010(2), 110(6), 001(1), 000(0)
|
||||
|
|
@ -57,17 +57,17 @@ typedef enum {
|
|||
#define RUART_FIFO_CTL_REG_OFF 0x08 //[W]
|
||||
// Define FIFO Control Register Bits
|
||||
typedef enum {
|
||||
RU_FCR_FIFO_EN = BIT0, // FIFO Enable.
|
||||
RU_FCR_RST_RX = BIT1, // RCVR FIFO Reset, self clear
|
||||
RU_FCR_RST_TX = BIT2, // XMIT FIFO Reset, self clear
|
||||
RU_FCR_TX_TRIG_EMP = 0, // TX Empty Trigger: FIFO empty
|
||||
RU_FCR_TX_TRIG_2CH = BIT4, // TX Empty Trigger: 2 characters in the FIFO
|
||||
RU_FCR_TX_TRIG_QF = BIT5, // TX Empty Trigger: FIFO 1/4 full
|
||||
RU_FCR_TX_TRIG_HF = (BIT5|BIT4), // TX Empty Trigger: FIFO 1/2 full
|
||||
RU_FCR_TX_TRIG_MASK = (BIT5|BIT4), // TX Empty Trigger Bit Mask
|
||||
RU_FCR_RX_TRIG_1CH = 0, // RCVR Trigger: 1 character in the FIFO
|
||||
RU_FCR_RX_TRIG_QF = BIT6, // RCVR Trigger: FIFO 1/4 full
|
||||
RU_FCR_RX_TRIG_HF = BIT7, // RCVR Trigger: FIFO 1/2 full
|
||||
RU_FCR_FIFO_EN = BIT0, // FIFO Enable.
|
||||
RU_FCR_RST_RX = BIT1, // RCVR FIFO Reset, self clear
|
||||
RU_FCR_RST_TX = BIT2, // XMIT FIFO Reset, self clear
|
||||
RU_FCR_TX_TRIG_EMP = 0, // TX Empty Trigger: FIFO empty
|
||||
RU_FCR_TX_TRIG_2CH = BIT4, // TX Empty Trigger: 2 characters in the FIFO
|
||||
RU_FCR_TX_TRIG_QF = BIT5, // TX Empty Trigger: FIFO 1/4 full
|
||||
RU_FCR_TX_TRIG_HF = (BIT5|BIT4), // TX Empty Trigger: FIFO 1/2 full
|
||||
RU_FCR_TX_TRIG_MASK = (BIT5|BIT4), // TX Empty Trigger Bit Mask
|
||||
RU_FCR_RX_TRIG_1CH = 0, // RCVR Trigger: 1 character in the FIFO
|
||||
RU_FCR_RX_TRIG_QF = BIT6, // RCVR Trigger: FIFO 1/4 full
|
||||
RU_FCR_RX_TRIG_HF = BIT7, // RCVR Trigger: FIFO 1/2 full
|
||||
RU_FCR_RX_TRIG_AF = (BIT7|BIT6), // RCVR Trigger: FIFO 2 less than full
|
||||
RU_FCR_RX_TRIG_MASK = (BIT7|BIT6) // RCVR Trigger bits Mask
|
||||
} RUART_FIFO_CTRL;
|
||||
|
|
@ -92,7 +92,7 @@ typedef enum {
|
|||
#define RUART_LINE_CTL_REG_OFF 0x0C
|
||||
// Define Line Control Register Bits
|
||||
typedef enum {
|
||||
RU_LCR_DLS_5B = 0, // Data Length: 5 bits
|
||||
RU_LCR_DLS_5B = 0, // Data Length: 5 bits
|
||||
RU_LCR_DLS_6B = BIT0, // Data Length: 6 bits
|
||||
RU_LCR_DLS_7B = BIT1, // Data Length: 7 bits
|
||||
RU_LCR_DLS_8B = (BIT1|BIT0), // Data Length: 7 bits
|
||||
|
|
@ -105,7 +105,7 @@ typedef enum {
|
|||
RU_LCR_PARITY_EVEN = (BIT4|BIT3), // Parity Enable: 1, Even Parity: 1
|
||||
|
||||
RU_LCR_BC = BIT6, // Break Control Bit
|
||||
RU_LCR_DLAB = BIT7 // Divisor Latch Access Bit
|
||||
RU_LCR_DLAB = BIT7 // Divisor Latch Access Bit
|
||||
} RUART_LINE_CTRL;
|
||||
//*BIT6 Break Control Bit (BC)
|
||||
//*BIT4 Even Parity Select (EPS)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ HalRuartGetChipVerRtl8195a(VOID)
|
|||
{
|
||||
u8 chip_ver;
|
||||
|
||||
chip_ver = (HAL_READ32(SYSTEM_CTRL_BASE, 0x01F0) >> 4) & 0x0f;
|
||||
chip_ver = (HAL_READ32(SYSTEM_CTRL_BASE, REG_SYS_SYSTEM_CFG0) >> 4) & 0x0f; // 0x400001F0 RTL8710AF = 0x41000220
|
||||
return chip_ver;
|
||||
}
|
||||
|
||||
|
|
@ -369,7 +369,7 @@ HalRuartSetBaudRateRtl8195a(
|
|||
u8 chip_ver;
|
||||
|
||||
// get chip version
|
||||
chip_ver = HalRuartGetChipVerRtl8195a();
|
||||
chip_ver = HalRuartGetChipVerRtl8195a(); // RTL8710AF = 2
|
||||
#endif
|
||||
|
||||
if (pHalRuartAdapter->WordLen == RUART_WLS_8BITS) {
|
||||
|
|
|
|||
|
|
@ -241,11 +241,11 @@ MON_RAM_TEXT_SECTION void RtlConsolTaskRam(void *Data) {
|
|||
}
|
||||
if(flg) DiagPrintf("cmd: %s - nothing!\n", ArgvArray[0]);
|
||||
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
|
||||
pmu_release_wakelock(WAKELOCK_LOGUART);
|
||||
release_wakelock(WAKELOCK_LOGUART);
|
||||
#endif
|
||||
}
|
||||
#if defined(configUSE_WAKELOCK_PMU) && (configUSE_WAKELOCK_PMU == 1)
|
||||
else pmu_acquire_wakelock(WAKELOCK_LOGUART);
|
||||
else acquire_wakelock(WAKELOCK_LOGUART);
|
||||
#endif
|
||||
p->pTmpLogBuf->BufCount = 0;
|
||||
p->pTmpLogBuf->UARTLogBuf[0] = 0;
|
||||
|
|
|
|||
|
|
@ -37,9 +37,12 @@ static uint8_t last_wakelock_state[32] = {
|
|||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
static uint32_t last_acquire_wakelock_time[32] = {0};
|
||||
static uint32_t hold_wakelock_time[32] = {0};
|
||||
static uint32_t base_sys_time = 0;
|
||||
#endif
|
||||
|
||||
static uint32_t sys_sleep_time = 0;
|
||||
|
||||
|
|
@ -164,10 +167,48 @@ int freertos_ready_to_sleep() {
|
|||
return wakelock == 0;
|
||||
}
|
||||
|
||||
|
||||
void acquire_wakelock(uint32_t lock_id) {
|
||||
|
||||
wakelock |= lock_id;
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
u32 i;
|
||||
u32 current_timestamp = osKernelSysTick();
|
||||
for (i=0; i<32; i++) {
|
||||
if ( (1<<i & lock_id) && (last_wakelock_state[i] == 0) ) {
|
||||
last_acquire_wakelock_time[i] = current_timestamp;
|
||||
last_wakelock_state[i] = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void release_wakelock(uint32_t lock_id) {
|
||||
wakelock &= ~lock_id;
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
u32 i;
|
||||
u32 current_timestamp = osKernelSysTick();
|
||||
for (i=0; i<32; i++) {
|
||||
if ( (1<<i & lock_id) && (last_wakelock_state[i] == 1) ) {
|
||||
hold_wakelock_time[i] += current_timestamp - last_acquire_wakelock_time[i];
|
||||
last_wakelock_state[i] = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t get_wakelock_status() {
|
||||
return wakelock;
|
||||
}
|
||||
|
||||
#if 0 // SDK3.5 compatible
|
||||
void pmu_acquire_wakelock(uint32_t lock_id) {
|
||||
|
||||
wakelock |= BIT(lock_id);
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
if (generate_wakelock_stats) {
|
||||
uint32_t i;
|
||||
uint32_t current_timestamp = osKernelSysTick();
|
||||
|
|
@ -178,11 +219,13 @@ void pmu_acquire_wakelock(uint32_t lock_id) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void pmu_release_wakelock(uint32_t lock_id) {
|
||||
wakelock &= ~BIT(lock_id);
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
if (generate_wakelock_stats) {
|
||||
uint32_t i;
|
||||
uint32_t current_timestamp = osKernelSysTick();
|
||||
|
|
@ -193,16 +236,20 @@ void pmu_release_wakelock(uint32_t lock_id) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32_t pmu_get_wakelock_status() {
|
||||
return wakelock;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void pmu_enable_wakelock_stats(unsigned char enable) {
|
||||
generate_wakelock_stats = enable;
|
||||
}
|
||||
|
||||
#if (configGENERATE_RUN_TIME_STATS == 1)
|
||||
void pmu_get_wakelock_hold_stats( char *pcWriteBuffer ) {
|
||||
uint32_t i;
|
||||
uint32_t current_timestamp = osKernelSysTick();
|
||||
|
|
@ -239,6 +286,7 @@ void pmu_clean_wakelock_stat() {
|
|||
}
|
||||
sys_sleep_time = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void pmu_add_wakeup_event(uint32_t event) {
|
||||
wakeup_event |= event;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue