非main函数中获取 命令行参数
This commit is contained in:
178
test_fun.c
178
test_fun.c
@@ -84,7 +84,7 @@ uint8_t iot_getcrc8(uint8_t *buffer, uint32_t len)
|
||||
|
||||
|
||||
|
||||
uint8_t data_table[] = { 0x5a,0x59,0x48,0x50,0x72,0x02,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
||||
uint8_t data_table[] = { 0xea,0x5a,0x59,0x48,0x50,0x72,0x02,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
||||
,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
|
||||
@@ -133,27 +133,171 @@ void fun_test(void) {
|
||||
}
|
||||
|
||||
|
||||
#define IOT_PHY_GAIN_STEP_NUM (85)
|
||||
#define IOT_CAL_DATA_DUMMY_LEN (10)
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
/* adc module calibration data. actual_val = raw_val * k + b */
|
||||
typedef struct _iot_adc_m_cal_data {
|
||||
float k;
|
||||
float b;
|
||||
}iot_adc_m_cal_data_t;
|
||||
|
||||
void print_adc_cal(iot_adc_m_cal_data_t* t) {
|
||||
DBG_LOG("k=%f, b=%f\n", t->k, t->b);
|
||||
}
|
||||
|
||||
/* rf version and phy tx calibration info */
|
||||
typedef struct _iot_cal_data_rf_ver_phy_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;
|
||||
} iot_cal_data_rf_ver_phy_txiqm_t;
|
||||
|
||||
void print_rf_ver(iot_cal_data_rf_ver_phy_txiqm_t* t) {
|
||||
DBG_LOG("tx_i_mag=%u, rf_ver=%u, tx_q_mag=%u, tx_i_phase=%u, tx_q_phase=%u, tx_i_dc=%i, tx_q_dc=%i",
|
||||
t->tx_i_mag, t->rf_ver, t->tx_q_mag, t->tx_i_phase, t->tx_q_phase, t->tx_i_dc, t->tx_q_dc);
|
||||
}
|
||||
|
||||
/* rf phy tx fiter calibration info */
|
||||
typedef struct _iot_cal_data_rf_phy_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[3];
|
||||
} iot_cal_data_rf_phy_txf_t;
|
||||
|
||||
void print_rf_phy(iot_cal_data_rf_phy_txf_t* t) {
|
||||
DBG_LOG("valid_mask=%u, bw_sel_value[0]=%u, bw_sel_value[1]=%u, bw_sel_value[2]=%u, ",
|
||||
t->valid_mask, t->bw_sel_value[0], t->bw_sel_value[1], t->bw_sel_value[2]);
|
||||
}
|
||||
|
||||
typedef struct _iot_cal_data_pt_info {
|
||||
/* the golden mac which used for the pt test */
|
||||
uint8_t golden_mac[6];
|
||||
/* production test time in bcd format */
|
||||
uint8_t year;
|
||||
uint8_t month;
|
||||
uint8_t day;
|
||||
uint8_t hour;
|
||||
uint8_t min;
|
||||
uint32_t golden_fw_ver;
|
||||
uint32_t pt_tool_ver;
|
||||
uint32_t pt_board_ver;
|
||||
} iot_cal_data_pt_info;
|
||||
|
||||
void print_pt_info(iot_cal_data_pt_info* t) {
|
||||
DBG_LOG("year=%u, month=%u, day=%u, hour=%u, min=%u, golden_fw_ver=%u, pt_tool_ver=%u, pt_board_ver=%u",
|
||||
t->year, t->month, t->day, t->hour, t->min, t->golden_fw_ver, t->pt_tool_ver, t->pt_board_ver);
|
||||
DBG_LOG("golden_mac=%u.%u.%u.%u",
|
||||
t->golden_mac[0], t->golden_mac[1], t->golden_mac[2], t->golden_mac[3], t->golden_mac[4], t->golden_mac[5]);
|
||||
}
|
||||
|
||||
/* rf phy rx calibration info */
|
||||
typedef struct _iot_cal_data_rf_phy_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;
|
||||
} iot_cal_data_rf_phy_rxiqm_t;
|
||||
|
||||
void print_rf_phy_rxiqm(iot_cal_data_rf_phy_rxiqm_t* t) {
|
||||
DBG_LOG("rx_i_mag=%u, rx_q_mag=%u, rx_i_phase=%u, rx_q_phase=%u",
|
||||
t->rx_i_mag, t->rx_q_mag, t->rx_i_phase, t->rx_q_phase);
|
||||
}
|
||||
|
||||
/* halphy config setting */
|
||||
typedef struct _iot_cal_data_halphy_real_cfg {
|
||||
/* magic num */
|
||||
uint32_t magic;
|
||||
/* mask */
|
||||
uint32_t mask;
|
||||
/* chip id for check valid */
|
||||
uint32_t chipid_hi;
|
||||
uint32_t chipid_lo;
|
||||
/* ppm cali */
|
||||
int8_t ppm;
|
||||
/* tx dc cali */
|
||||
uint16_t tx_dc[4];
|
||||
/* rx dc cali */
|
||||
uint16_t rx_dc[IOT_PHY_GAIN_STEP_NUM];
|
||||
/* pt fw version record */
|
||||
uint32_t pt_fw_ver;
|
||||
/* hardware version */
|
||||
uint16_t hw_ver_major;
|
||||
uint16_t hw_ver_minor;
|
||||
/* unit: degrees centigrade, actual_temp = raw_temp + cali_temp */
|
||||
float cali_temp;
|
||||
/* adc module calibration data */
|
||||
iot_adc_m_cal_data_t cali_adc_m;
|
||||
/* rf version and phy tx iqm calibration data */
|
||||
iot_cal_data_rf_ver_phy_txiqm_t rf_txiqm;
|
||||
/* rf phy tx filter calibration data */
|
||||
iot_cal_data_rf_phy_txf_t rf_txf;
|
||||
/* the production info */
|
||||
iot_cal_data_pt_info pt_info;
|
||||
/* rf phy rx iqm calibration data */
|
||||
iot_cal_data_rf_phy_rxiqm_t rf_rxiqm;
|
||||
uint8_t reserved[IOT_CAL_DATA_DUMMY_LEN];
|
||||
} iot_halphy_real_cfg_t;
|
||||
|
||||
|
||||
void print_halphy_real_cfg(iot_halphy_real_cfg_t* t) {
|
||||
DBG_LOG("magic=0x%08x, mask=0x%08x, chipid_hi=0x%08x, chipid_lo=0x%08x, ppm=%d, ",
|
||||
t->magic, t->mask, t->chipid_hi, t->chipid_lo, t->ppm);
|
||||
DBG_LOG("tx_dc=%u,%u,%u,%u", t->tx_dc[0], t->tx_dc[1], t->tx_dc[2], t->tx_dc[3]);
|
||||
for (int i = 0;i < IOT_PHY_GAIN_STEP_NUM;i++) {
|
||||
DBG_LOG("rx_dc[%d]=%u,", i, t->rx_dc[i]);
|
||||
}
|
||||
DBG_LOG("pt_fw_ver=%u, hw_ver_major=0x%04x, hw_ver_minor=0x%04x, cali_temp=%f,",
|
||||
t->pt_fw_ver, t->hw_ver_major, t->hw_ver_minor, t->cali_temp);
|
||||
|
||||
print_adc_cal(&t->cali_adc_m);
|
||||
print_rf_ver(&t->rf_txiqm);
|
||||
print_rf_phy(&t->rf_txf);
|
||||
print_pt_info(&t->pt_info);
|
||||
print_rf_phy_rxiqm(&t->rf_rxiqm);
|
||||
}
|
||||
|
||||
|
||||
typedef struct _iot_cal_data_cfg {
|
||||
uint8_t crc;
|
||||
iot_halphy_real_cfg_t halphy_cfg;
|
||||
} iot_cal_data_cfg_t;
|
||||
|
||||
void print_cal_data_cfg(iot_cal_data_cfg_t* t) {
|
||||
DBG_LOG("crc=0x%02x,", t->crc);
|
||||
print_halphy_real_cfg(&t->halphy_cfg);
|
||||
}
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
int thread_fun(void* t) {
|
||||
DBG_INFO("run in test_fun.\n");
|
||||
uint8_t crc8 = 0;
|
||||
int len = 0;
|
||||
// while (crc8 != 0x83) {
|
||||
// crc8 = iot_getcrc8(data_table2+1, len);
|
||||
// len++;
|
||||
// }
|
||||
test_struct a;
|
||||
typeof(a.b) b;
|
||||
crc8 = offsetof(test_struct, c);
|
||||
DBG_LOG("a_addr=%p,a_d_d2_addr=%p", &a, headof(test_struct, d, &a.d));
|
||||
// crc8 = iot_getcrc8(data_table2 + 1, 264);
|
||||
DBG_LOG("crc8=%x,len=%d", crc8, len);
|
||||
|
||||
return 0;
|
||||
int thread_fun1(void* t) {
|
||||
DBG_LOG("run in test_fun.\n");
|
||||
uint8_t crc8 = 0;
|
||||
iot_cal_data_cfg_t data = { 0 };
|
||||
memcpy(&data, data_table2, sizeof(data));
|
||||
crc8 = iot_getcrc8(&data.halphy_cfg, sizeof(data.halphy_cfg));
|
||||
debug_print_context(0);
|
||||
DBG_LOG("calc_crc=0x%02x", crc8);
|
||||
print_cal_data_cfg(&data);
|
||||
debug_print_context(1);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user