168 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			168 lines
		
	
	
		
			6.2 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| 
								 | 
							
								/****************************************************************************
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								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.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								****************************************************************************/
							 | 
						||
| 
								 | 
							
								#ifndef MAC_TX_POWER_H
							 | 
						||
| 
								 | 
							
								#define MAC_TX_POWER_H
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "os_types.h"
							 | 
						||
| 
								 | 
							
								#include "os_timer_api.h"
							 | 
						||
| 
								 | 
							
								#include "phy_txrx_pwr.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								extern "C" {
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* MAC LAYER WRITE 5S*/
							 | 
						||
| 
								 | 
							
								#define OVER_STRESS_HANDLE_MAC_TIME   (5 * 1000)   //5s
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define OVER_STRESS_HANDLE_TIME       (OVER_STRESS_HANDLE_MAC_TIME)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/******************* AUTO POWER CONTROL REASON ****************************/
							 | 
						||
| 
								 | 
							
								#define HIGH_PWR_REQ_BY_STA_LVL                  0
							 | 
						||
| 
								 | 
							
								#define HIGH_PWR_REQ_BY_NETWORK_SIZE             1
							 | 
						||
| 
								 | 
							
								#define HIGH_PWR_REQ_BY_NOISE_FLOOR              2
							 | 
						||
| 
								 | 
							
								#define HIGH_PWR_REQ_BY_NETWORK_STATUS           3
							 | 
						||
| 
								 | 
							
								#define HIGH_PWR_REQ_BY_CVG                      4
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/******************** AUTO POWER CONTROL PARAM *****************************/
							 | 
						||
| 
								 | 
							
								#define HIGH_PWR_LVL_THRE                        2    /* sta level */
							 | 
						||
| 
								 | 
							
								#define HIGH_PWR_NETWORK_SCALE_THRE              8    /* 8 sta in network */
							 | 
						||
| 
								 | 
							
								#define HIGH_PWR_BCN_PERIOD_THRE                 4000 /* bcn period 4000 ms */
							 | 
						||
| 
								 | 
							
								#define HIGH_PWR_NF_THRE                         80   /* noise floor */
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* define the target power for STA devices to automatically increase power,
							 | 
						||
| 
								 | 
							
								 * which represents the decrease in decibels of the target power relative
							 | 
						||
| 
								 | 
							
								 * to full power(137dBuV).
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define STA_TX_POWER_REDUCE_DB_DEFAULT          2
							 | 
						||
| 
								 | 
							
								#define STA_TX_POWER_REDUCE_DB_BAND_01          6
							 | 
						||
| 
								 | 
							
								#define STA_TX_POWER_REDUCE_DB_BAND_OTHER       8
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/* define the target power for new type cco devices to automatically increase
							 | 
						||
| 
								 | 
							
								 * power, which represents the decrease in decibels of the target power relative
							 | 
						||
| 
								 | 
							
								 * to full power(137dBuV).
							 | 
						||
| 
								 | 
							
								 */
							 | 
						||
| 
								 | 
							
								#define CCO_TX_POWER_REDUCE_DB_NEW_TYPE         7
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#define MAC_TX_POWER_CE_DEFAULT                 77
							 | 
						||
| 
								 | 
							
								#define MAC_TX_POWER_CE_MIN                     75
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_over_stress_isr_handle       mac over stress isr handle
							 | 
						||
| 
								 | 
							
								 *@param param                            [NULL]
							 | 
						||
| 
								 | 
							
								 *@param db_offset                        [threshold for power]
							 | 
						||
| 
								 | 
							
								 *@exception                              [none.]
							 | 
						||
| 
								 | 
							
								 *@return                                 [none.]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								void mac_over_stress_isr_handle(void *param, uint8_t db_offset);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_over_stress_dsr_handle       mac over stress dsr handle
							 | 
						||
| 
								 | 
							
								 *@param timer_id                         [none]
							 | 
						||
| 
								 | 
							
								 *@exception                              [none.]
							 | 
						||
| 
								 | 
							
								 *@return                                 [none.]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								void mac_over_stress_dsr_handle();
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_over_stress_timer_handle     mac over stress timer handle
							 | 
						||
| 
								 | 
							
								 *@param timer_id                         [timer id]
							 | 
						||
| 
								 | 
							
								 *@param arg                              [arg]
							 | 
						||
| 
								 | 
							
								 *@exception                              [none.]
							 | 
						||
| 
								 | 
							
								 *@return                                 [none.]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								void mac_over_stress_timer_handle(timer_id_t timer_id, void * arg);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief phy_get_def_tx_power  get global default tx power,
							 | 
						||
| 
								 | 
							
								 *@brief    usually it's also the max regular value
							 | 
						||
| 
								 | 
							
								 *@proto    protocol ID
							 | 
						||
| 
								 | 
							
								 *@proto_band_id   protocol band id for this kind of protocol
							 | 
						||
| 
								 | 
							
								 *@ret_tx_power returned tx power
							 | 
						||
| 
								 | 
							
								 *
							 | 
						||
| 
								 | 
							
								 *@return                   [0]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								uint32_t mac_get_def_tx_power(uint32_t proto, uint32_t proto_band_id,
							 | 
						||
| 
								 | 
							
								        uint32_t *ret_tx_power);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_high_power_req               auto power control
							 | 
						||
| 
								 | 
							
								 *@param reason                           control reason
							 | 
						||
| 
								 | 
							
								 *@param flag                             raise/reduce power
							 | 
						||
| 
								 | 
							
								 *@param vdev                             cur vdev
							 | 
						||
| 
								 | 
							
								 *@exception                              [none.]
							 | 
						||
| 
								 | 
							
								 *@return                                 [none.]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								void mac_high_power_req(void *vdev, uint8_t reason, uint8_t flag);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_set_tx_power_cap             set tx power cap
							 | 
						||
| 
								 | 
							
								 *@param vdev_ptr                         cur vdev
							 | 
						||
| 
								 | 
							
								 *@hplc_power                             point to hplc power, unit dbuv
							 | 
						||
| 
								 | 
							
								 *@rf_power                               point to rf power, unit dbm
							 | 
						||
| 
								 | 
							
								 *@is_force                               force set hplc and rf power cap or not
							 | 
						||
| 
								 | 
							
								 *@exception                              [none.]
							 | 
						||
| 
								 | 
							
								 *@return                                 [none.]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								void mac_set_tx_power_cap(void *vdev_ptr, uint8_t *hplc_power,
							 | 
						||
| 
								 | 
							
								    int8_t *rf_power, uint8_t is_force);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_fix_power_init               init
							 | 
						||
| 
								 | 
							
								 *@param vdev_ptr                         cur vdev
							 | 
						||
| 
								 | 
							
								 *@exception                              [none.]
							 | 
						||
| 
								 | 
							
								 *@return                                 [none.]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								void mac_fix_power_init(void *vdev_ptr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_check_power_by_level        update power by sta level
							 | 
						||
| 
								 | 
							
								 *@param vdev_ptr                         cur vdev
							 | 
						||
| 
								 | 
							
								 *@param sta_level                        sta level
							 | 
						||
| 
								 | 
							
								 *@exception                              [none.]
							 | 
						||
| 
								 | 
							
								 *@return                                 [none.]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								void mac_check_power_by_level(void *vdev_ptr, uint8_t sta_level);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_high_power_req_ena           disable/enable auto power control
							 | 
						||
| 
								 | 
							
								 *@param vdev_ptr                         cur vdev
							 | 
						||
| 
								 | 
							
								 *@param ena                              enable/disable
							 | 
						||
| 
								 | 
							
								 *@exception                              [none.]
							 | 
						||
| 
								 | 
							
								 *@return                                 [none.]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								void mac_high_power_req_ena(void *vdev_ptr, uint8_t ena);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_cert_war_tx_pwr              rise power if box4 or box5
							 | 
						||
| 
								 | 
							
								 *@param mac_addr                         [timer id]
							 | 
						||
| 
								 | 
							
								 *@exception                              [none.]
							 | 
						||
| 
								 | 
							
								 *@return                                 [1: pwr rised; other: pwr not changed]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								uint32_t mac_cert_war_tx_pwr(uint8_t *mac_addr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								/**
							 | 
						||
| 
								 | 
							
								 *@brief mac_fix_power_apply              mac power apply.
							 | 
						||
| 
								 | 
							
								 *@param vdev_ptr                         cur vdev
							 | 
						||
| 
								 | 
							
								 *@exception                              [none.]
							 | 
						||
| 
								 | 
							
								 *@return                                 [none.]
							 | 
						||
| 
								 | 
							
								*/
							 | 
						||
| 
								 | 
							
								void mac_fix_power_apply(void *vdev_ptr);
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#ifdef __cplusplus
							 | 
						||
| 
								 | 
							
								}
							 | 
						||
| 
								 | 
							
								#endif
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#endif
							 |