Files
kunlun/ftm/mp/cli/cli_rf_ic_tool.h

291 lines
8.5 KiB
C
Raw Normal View History

2024-09-28 14:24:04 +08:00
/****************************************************************************
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 "plc_protocol.h"
#include "iot_pkt_api.h"
#ifndef CLI_RF_IC_TOOL_H
#define CLI_RF_IC_TOOL_H
#ifdef __cplusplus
extern "C" {
#endif
/* sending rf tones through hardware */
#define CLI_RF_TX_TONE_MODE_HW 1
/* sending rf tones through software */
#define CLI_RF_TX_TONE_MODE_SW 0
/* pack for the structures in the whole file */
#pragma pack(push) // save the pack status
#pragma pack(1) // 1 byte align
typedef struct _cli_kl_cmd_ack {
/** result code */
uint16_t result;
/** reserved data */
uint8_t reserved[8];
} cli_kl_cmd_ack;
/* set rf option */
typedef struct _cli_rf_option_chn {
uint32_t option;
uint32_t chn;
} cli_rf_option_chn;
/* rf tx tone command message layout */
typedef struct _cli_rf_tx_tone {
/* tx tone control1 - on 0 - stop */
uint8_t on_off;
/* tone0 number */
int8_t tone0_num;
/* option */
uint8_t option;
/* rf center frequency, unit Hz */
uint32_t fchz;
/* tx tone mode, see CLI_RF_TX_TONE_MODE_XXX. */
uint8_t mode;
/* tone1 number */
int8_t tone1_num;
/* attenuation code */
uint8_t att0;
/* attenuation code */
uint8_t att1;
} cli_rf_tx_tone_t;
/* rf spi read */
typedef struct _cli_rf_spi_read {
uint8_t addr;
} cli_rf_spi_read;
/* rf spi write */
typedef struct _cli_rf_spi_write {
uint8_t addr;
uint16_t value;
} cli_rf_spi_write;
/* rf calibration measurement req msg layout */
typedef struct _cli_rf_tx_cal_update {
/* flag to mark if member tx_i_mag and tx_q_mag needs to be updated to RF */
uint8_t tx_iq_mag_update : 1,
/* flag to mark if member tx_i_phase and tx_q_phase needs to be updated
* to RF.
*/
tx_iq_phase_update : 1,
/* flag to mark if member tx_i_dc and tx_q_dc needs to be updated to RF */
tx_iq_dc_update : 1,
/* reserved for further use */
rsvd : 5;
/* tx I MAG balance calibration value, range range: 0~15 */
uint8_t tx_i_mag;
/* tx Q MAG balance calibration value, range range: 0~15 */
uint8_t tx_q_mag;
/* tx I phase calibration value, range range: 0~31 */
uint8_t tx_i_phase;
/* tx Q phase calibration value, range range: 0~31 */
uint8_t tx_q_phase;
/* tx I dc calibration value, range range: -127~127 */
int8_t tx_i_dc;
/* tx Q dc calibration value, range range: -127~127 */
int8_t tx_q_dc;
/* reserved for further use */
int8_t rsvd_bytes[8];
} cli_rf_tx_cal_update_t;
/* rf rx iqm calibration request */
typedef struct _cli_rf_cal_rxiqm_req_t {
/* tone frequency offset relative to center frequency, unit is 1Hz */
int32_t tone_freq;
} cli_rf_rxiqm_cal_req_t;
/* rf rx iqm calibration response */
typedef struct _cli_rf_cal_rxiqm_rsp_t {
/* result code */
uint8_t result;
/* rx I mag calibration value, range: 0~15 */
uint8_t i_mag : 4,
/* rx Q mag calibration value, range: 0~15 */
q_mag : 4;
/* rx I phase calibration value, range: 0~31 */
uint8_t i_phase;
/* rx Q phase calibration value, range: 0~31 */
uint8_t q_phase;
} cli_rf_rxiqm_cal_rsp_t;
/* rf state */
typedef struct _cli_rf_state_cfg_t {
/* whitch state see CLI_RF_POWER_XXX */
uint8_t type;
/* option */
uint8_t option;
/* channel id */
uint8_t ch_id;
} cli_rf_state_cfg_t;
/* RF ada dump */
typedef struct _cli_rf_ada_dump {
uint32_t dump_addr;
uint32_t dump_len;
} cli_rf_ada_dump;
/* RF rx tone power query */
typedef struct _cli_rf_rx_tone_power_query {
uint16_t tone_idx;
uint16_t dc_idx;
uint16_t img_idx;
} cli_rf_rx_tone_power_query_t;
/* RF rx tone power info */
typedef struct _cli_rf_rx_tone_power_info {
uint32_t tone_pwr;
uint32_t dc_pwr;
uint32_t img_pwr;
uint32_t gain;
} cli_rf_rx_tone_power_info_t;
/* rf version and phy tx calibration info */
typedef struct _cli_rf_cal_txiqm {
/* tx I MAG balance calibration value, range range: 0~15 */
uint8_t tx_i_mag : 4,
/* rf version, see RF_VER_XXX */
rf_ver : 4;
/* tx Q MAG balance calibration value, range range: 0~15 */
uint8_t tx_q_mag;
/* tx I phase calibration value, range range: 0~31 */
uint8_t tx_i_phase;
/* tx Q phase calibration value, range range: 0~31 */
uint8_t tx_q_phase;
/* tx I dc calibration value, range range: -127~127 */
int8_t tx_i_dc;
/* tx I dc calibration value, range range: -127~127 */
int8_t tx_q_dc;
} cli_rf_cal_txiqm_t;
/* rf phy rx calibration info */
typedef struct _cli_rf_cal_rxiqm {
/* rx I MAG balance calibration value, range range: 0~15 */
uint8_t rx_i_mag : 4,
/* rx Q MAG balance calibration value, range range: 0~15 */
rx_q_mag : 4;
/* rx I phase calibration value, range range: 0~31 */
uint8_t rx_i_phase;
/* rx Q phase calibration value, range range: 0~31 */
uint8_t rx_q_phase;
} cli_rf_cal_rxiqm_t;
/* rf phy tx fiter calibration info */
typedef struct _cli_rf_cal_txf {
/* flag mark if the value of the corresponding option is valid */
uint8_t valid_mask;
/* tx filter bw calibration value for each option */
uint16_t bw_sel_value[RF_OPTION_MAX];
} cli_rf_cal_txf_t;
typedef struct _cli_plc_fft_dump_req {
/* average number */
uint8_t avg_num;
/* tone index*/
uint16_t tone_idx;
} cli_plc_fft_dump_req_t;
typedef struct _cli_plc_fft_dump_rsp {
/* error number */
uint16_t err_no;
/* fft energy of query tone idx */
uint32_t energy;
/* memory address of fft data */
uint32_t address;
/* fft data length */
uint16_t len;
} cli_plc_fft_dump_rsp_t;
typedef struct _cli_gpio_set {
/* gpio number */
uint32_t gpio;
/* function */
uint32_t func;
/* value, 0 or 1 */
uint32_t val;
} cli_gpio_set_t;
typedef struct _cli_gpio_set_rsp {
/* result */
uint16_t result;
/* gpio value */
uint8_t gpio_value;
} cli_gpio_set_rsp_t;
/* rf rx cmd layout */
typedef struct _cli_rf_rx_cmd {
/* frequency of spectrum shifting, unit:Hz. */
uint32_t f0;
/* rf gain, if it is a negative number, it indicates automatic adjustment of
* gain.
*/
int8_t gain;
/* Indicates how many frequency points can be obtained at most. */
uint8_t num;
/* frequency list, used to obtain information of interested frequency points.
* unit:Hz.
*/
uint32_t freq[0];
} cli_rf_rx_cmd_t;
/* rf rx gain cal_data info */
typedef struct _cli_rf_rx_gain_cali_info_t {
/* rx gain, range: 13~74 */
uint8_t gain;
/* calibration value, range: -128~127, unit: 0.1db */
int8_t cal_data;
} cli_rf_rx_gain_cali_info_t;
/* rf rx gain cal_data read */
typedef struct _cli_rf_rx_gain_cali_read_t {
/* rx gain, range range: 13~74 */
uint8_t gain;
} cli_rf_rx_gain_cali_read_t;
/* rf tx power info */
typedef struct _cli_rf_tx_power_info_t {
/* which position to save power info */
uint8_t idx;
/* power, unit: dbm */
int8_t power;
/* tx rf_att, range: [0x7e, 0x7d, 0x7b, 0x77, 0x6f, 0x5f, 0x3f] */
uint8_t rf_att;
/* if gain, range: 0~31 */
uint16_t if_gain : 5,
/* ldovs, range: 0~511 */
ldovs : 9,
/* rservd */
rsvd : 2;
} cli_rf_tx_power_info;
/* rf tx power info read */
typedef struct _cli_rf_tx_power_read_t {
/* which record to read */
uint8_t idx;
} cli_rf_tx_power_read_t;
void iot_ic_rf_tool_op(int msgid, iot_pkt_t* buffer, uint32_t len);
#pragma pack(pop) // restore the pack status
#ifdef __cplusplus
}
#endif
#endif /* CLI_RF_IC_TOOL_H */