155 lines
6.1 KiB
C
155 lines
6.1 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 __PHY_RF_CHN_H__
|
||
|
#define __PHY_RF_CHN_H__
|
||
|
|
||
|
#include "os_types.h"
|
||
|
#include "plc_protocol.h"
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
|
/* define rf chip version is invaild */
|
||
|
#define RF_VER_INVAILD 0
|
||
|
/* define rf chip version is unkonwn */
|
||
|
#define RF_VER_UNKNOWN 7
|
||
|
/* define rf chip version is version 1 */
|
||
|
#define RF_VER_1 1
|
||
|
/* define rf chip version is version 2 */
|
||
|
#define RF_VER_2 2
|
||
|
/* define rf chip version is version 3 */
|
||
|
#define RF_VER_3 3
|
||
|
|
||
|
/* define phy rf freq band */
|
||
|
typedef enum _phy_rf_band {
|
||
|
/* band for smart power grid, freq range:470Mhz~510Mhz */
|
||
|
PHY_RF_BAND_NSG,
|
||
|
/* band for overseas power grid, freq range:863Mhz~876Mhz &
|
||
|
* 902Mhz~928Mhz.
|
||
|
*/
|
||
|
PHY_RF_BAND_OVERSEAS,
|
||
|
PHY_RF_BAND_MAX
|
||
|
} PHY_RF_BAND_T;
|
||
|
|
||
|
typedef enum _phy_rf_option_id_range_t {
|
||
|
/* option1 channel interval 1M */
|
||
|
PHY_RF_OPTION1_1M = RF_OPTION_1,
|
||
|
/* option2 channel interval 500K */
|
||
|
PHY_RF_OPTION2_500K = RF_OPTION_2,
|
||
|
/* option3 channel interval 200K */
|
||
|
PHY_RF_OPTION3_200K = RF_OPTION_3,
|
||
|
PHY_RF_OPTION_MAX = PHY_RF_OPTION3_200K + 1
|
||
|
} phy_rf_option_id_range_t;
|
||
|
|
||
|
/* phy rf band NSG option 1,2,3 channel 1 cneter frequency, uint is Hz */
|
||
|
#define PHY_RF_BAND_NSG_OPT1_CH1_CF 471000000
|
||
|
#define PHY_RF_BAND_NSG_OPT2_CH1_CF 470500000
|
||
|
#define PHY_RF_BAND_NSG_OPT3_CH1_CF 470100000
|
||
|
/* phy rf band NSG option 1,2,3 channel id max */
|
||
|
#define PHY_RF_BAND_NSG_OPT1_CH_ID_MAX 40
|
||
|
#define PHY_RF_BAND_NSG_OPT2_CH_ID_MAX 80
|
||
|
#define PHY_RF_BAND_NSG_OPT3_CH_ID_MAX 201
|
||
|
/* define default options and channels for NSG band */
|
||
|
#define PHY_RF_BAND_NSG_OPTION_DFT RF_OPTION_2
|
||
|
#define PHY_RF_BAND_NSG_CH_DFT RF_CHANNEL_ID_16
|
||
|
|
||
|
/* phy rf band OVERSEAS option 1,2,3 some typical channel cneter frequency,
|
||
|
* uint is Hz.
|
||
|
*/
|
||
|
#define PHY_RF_BAND_OVERSEAS_OPT1_CH1_CF 864000000
|
||
|
#define PHY_RF_BAND_OVERSEAS_OPT1_CH13_CF 903000000
|
||
|
#define PHY_RF_BAND_OVERSEAS_OPT2_CH1_CF 863500000
|
||
|
#define PHY_RF_BAND_OVERSEAS_OPT2_CH26_CF 902500000
|
||
|
#define PHY_RF_BAND_OVERSEAS_OPT3_CH1_CF 863200000
|
||
|
#define PHY_RF_BAND_OVERSEAS_OPT3_CH65_CF 902200000
|
||
|
/* phy rf band OVERSEAS option 1,2,3 channel id max */
|
||
|
#define PHY_RF_BAND_OVERSEAS_OPT1_CH_ID_MAX 38
|
||
|
#define PHY_RF_BAND_OVERSEAS_OPT2_CH_ID_MAX 77
|
||
|
#define PHY_RF_BAND_OVERSEAS_OPT3_CH_ID_MAX 194
|
||
|
/* define default options and channels for OVERSEAS band */
|
||
|
#define PHY_RF_BAND_OVERSEAS_OPTION_DFT RF_OPTION_2
|
||
|
#define PHY_RF_BAND_OVERSEAS_CH_DFT 51
|
||
|
|
||
|
/* define the channel spacing of option 1, 1M, unit hz */
|
||
|
#define OPTION1_CHANNEL_SPACING 1000000
|
||
|
/* define the channel spacing of option 2, 500K, unit hz */
|
||
|
#define OPTION2_CHANNEL_SPACING 500000
|
||
|
/* define the channel spacing of option 3, 200K, unit hz */
|
||
|
#define OPTION3_CHANNEL_SPACING 200000
|
||
|
|
||
|
/* define the minimum value of RF signal gain */
|
||
|
#define PHY_RF_GAIN_MIN 13
|
||
|
|
||
|
/* define the mmaximum value of RF signal gain */
|
||
|
#define PHY_RF_GAIN_MAX 74
|
||
|
|
||
|
/*
|
||
|
* @breif phy_rf_get_channel_freq_by_id() - get channel frequency by channel id.
|
||
|
* @param option - rf optino, PHY_RF_OPTION_xx.
|
||
|
* @param channel_id - rf channel see RF_CHANNEL_ID_xx.
|
||
|
* @return uint32_t - frequency, unit hz.
|
||
|
*/
|
||
|
uint32_t phy_rf_get_channel_freq_by_id(uint32_t option, uint32_t channel_id);
|
||
|
|
||
|
/*
|
||
|
* @breif phy_rf_get_channel_id_max() - get channel id max.
|
||
|
* @param option - rf optino, PHY_RF_OPTION_xx.
|
||
|
* @return uint32_t - channel id max. see OPTIONxx_CAHNNEL_ID_MAX.
|
||
|
*/
|
||
|
uint32_t phy_rf_get_channel_id_max(uint32_t option);
|
||
|
|
||
|
/*
|
||
|
* @breif phy_rf_check_rf_version() - check whether the rf version is valid.
|
||
|
* @param ver - rf version, see RC_VER_XXX.
|
||
|
* @return uint8_t - 1 : valid, 0 : not valid.
|
||
|
*/
|
||
|
uint8_t phy_rf_check_rf_version(uint8_t ver);
|
||
|
|
||
|
/*
|
||
|
* @breif phy_rf_band_info_init() - initialize phy rf band info
|
||
|
* @param band_sel - RF band selection code, see PHY_RF_BAND_T
|
||
|
*/
|
||
|
void phy_rf_band_info_init(PHY_RF_BAND_T band_sel);
|
||
|
|
||
|
/*
|
||
|
* @breif phy_rf_get_band_sel() - get RF phy current band.
|
||
|
* @return PHY_RF_BAND_T - RF band selection code, see PHY_RF_BAND_T
|
||
|
*/
|
||
|
PHY_RF_BAND_T phy_rf_get_band_sel();
|
||
|
|
||
|
/**
|
||
|
* @brief phy_rf_get_power() - get RF phy default tx power.
|
||
|
* @param min - return min tx power
|
||
|
* @param max - return max tx power
|
||
|
* @param def - return default tx power
|
||
|
* @param full - return full tx power
|
||
|
*/
|
||
|
void phy_rf_get_power(int8_t *min, int8_t *max, int8_t *def, int8_t *full);
|
||
|
|
||
|
/*
|
||
|
* @breif phy_rf_get_default_cfg() - get the default working options and channels of
|
||
|
* the current RF phy band
|
||
|
* @param opt - Return default option of current band
|
||
|
* @param ch - Return default option of current band
|
||
|
*/
|
||
|
void phy_rf_get_default_cfg(uint8_t *opt, uint8_t *ch);
|
||
|
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#endif // __PHY_RF_CHN_H__
|