wm_efuse.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. /**************************************************************************
  2. * File Name : tls_efuse.c
  3. * Author :
  4. * Version :
  5. * Date :
  6. * Description : Use Flash Addr as virtual efuse
  7. *
  8. * Copyright (c) 2014 Winner Microelectronics Co., Ltd.
  9. * All rights reserved.
  10. *
  11. ***************************************************************************/
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include <stdlib.h>
  15. #include "wm_debug.h"
  16. #include "wm_regs.h"
  17. #include "wm_efuse.h"
  18. #include "wm_config.h"
  19. #include "list.h"
  20. #include "wm_internal_flash.h"
  21. #include "wm_crypto_hard.h"
  22. #include "wm_mem.h"
  23. #define USE_OTA_FT_PARAM 0
  24. #include "wm_flash_map.h"
  25. #define FT_MAGICNUM_ADDR (FLASH_BASE_ADDR)
  26. #define MAGICNUM_LEN (4)
  27. #define MAC_ADDR_LEN (6)
  28. #define FT_GAIN_LEN (84)
  29. #define FT_PARAM_EXT_REVERSED_LEN 32
  30. typedef struct FT_PARAM
  31. {
  32. unsigned int magic_no;
  33. unsigned int checksum;
  34. unsigned char wifi_mac_addr[MAC_ADDR_LEN];
  35. unsigned short version_no;
  36. unsigned char bt_mac_addr[MAC_ADDR_LEN];
  37. unsigned short ext_param_len;
  38. unsigned int tx_dcoffset;
  39. unsigned int rx_dcoffset;
  40. unsigned int tx_iq_gain;
  41. unsigned int rx_iq_gain;
  42. unsigned int tx_iq_phase;
  43. unsigned int rx_iq_phase;
  44. unsigned char tx_gain[FT_GAIN_LEN];
  45. }FT_PARAM_ST;
  46. typedef struct FT_PARAM_EXT_1
  47. {
  48. unsigned int rf_freq_err;
  49. unsigned int rf_cal_flag;
  50. FT_ADC_CAL_ST adc_cal_param;
  51. FT_TEMP_CAL_ST temp_cal_param;
  52. }FT_PARAM_ST_EXT_1;
  53. typedef struct FT_PARAM_VER1
  54. {
  55. FT_PARAM_ST ft_param;
  56. unsigned int ext_checksum;
  57. FT_PARAM_ST_EXT_1 ft_ext1;
  58. unsigned char _reversed[FT_PARAM_EXT_REVERSED_LEN];
  59. }FT_PARAM_ST_VER1;
  60. static u8 default_mac[6] = {0x00,0x25,0x08,0x09,0x01,0x0F};
  61. FT_PARAM_ST_VER1 gftParamVer1;
  62. FT_PARAM_ST *gftParam = (FT_PARAM_ST *)&gftParamVer1;
  63. int tls_ft_param_init(void)
  64. {
  65. u32 crcvalue = 0;
  66. psCrcContext_t ctx;
  67. FT_PARAM_ST_VER1 *pft_ver1 = NULL;
  68. FT_PARAM_ST *pft = NULL;
  69. if (gftParam->magic_no == SIGNATURE_WORD)
  70. {
  71. return TRUE;
  72. }
  73. pft = tls_mem_alloc(sizeof(FT_PARAM_ST_VER1));
  74. if (pft == NULL)
  75. {
  76. return FALSE;
  77. }
  78. memset(pft, 0xFF, sizeof(FT_PARAM_ST_VER1));
  79. memset(gftParam, 0xFF, sizeof(FT_PARAM_ST_VER1));
  80. tls_fls_read(FT_MAGICNUM_ADDR, (unsigned char *)pft, sizeof(FT_PARAM_ST_VER1));
  81. if (pft->magic_no == SIGNATURE_WORD)
  82. {
  83. tls_crypto_init();
  84. tls_crypto_crc_init(&ctx, 0xFFFFFFFF, CRYPTO_CRC_TYPE_32, INPUT_REFLECT | OUTPUT_REFLECT);
  85. tls_crypto_crc_update(&ctx, (unsigned char *)pft + 8, sizeof(FT_PARAM_ST) - 8);
  86. tls_crypto_crc_final(&ctx, &crcvalue);
  87. if (pft->checksum != crcvalue)
  88. {
  89. tls_mem_free(pft);
  90. return FALSE;
  91. }
  92. do
  93. {
  94. if (pft->version_no > 0 && pft->version_no < 0xFFFF && pft->ext_param_len >= sizeof(FT_PARAM_ST_EXT_1) &&
  95. pft->ext_param_len <= (sizeof(FT_PARAM_ST_EXT_1) + FT_PARAM_EXT_REVERSED_LEN))
  96. {
  97. pft_ver1 = (FT_PARAM_ST_VER1 *)pft;
  98. tls_crypto_crc_init(&ctx, 0xFFFFFFFF, CRYPTO_CRC_TYPE_32, INPUT_REFLECT | OUTPUT_REFLECT);
  99. tls_crypto_crc_update(&ctx, (unsigned char *)&pft_ver1->ft_ext1, pft->ext_param_len);
  100. tls_crypto_crc_final(&ctx, &crcvalue);
  101. if(pft_ver1->ext_checksum == crcvalue)
  102. {
  103. memcpy((unsigned char *)gftParam, (unsigned char *)pft, sizeof(FT_PARAM_ST_VER1));
  104. break;
  105. }
  106. }
  107. pft->version_no = 0xFFFF;
  108. pft->ext_param_len = 0xFFFF;
  109. memcpy((unsigned char *)gftParam, (unsigned char *)pft, sizeof(FT_PARAM_ST));
  110. }while(0);
  111. }
  112. tls_mem_free(pft);
  113. /*lock parameter*/
  114. tls_flash_unlock();
  115. return TRUE;
  116. }
  117. int tls_ft_param_get(unsigned int opnum, void *data, unsigned int rdlen)
  118. {
  119. switch (opnum)
  120. {
  121. case CMD_TX_ADC_CAL:
  122. if(gftParam->version_no > 0 && gftParam->version_no < 0xFFFF)
  123. {
  124. memcpy(data, (unsigned char *)&gftParamVer1.ft_ext1.adc_cal_param, rdlen);
  125. }
  126. break;
  127. case CMD_WIFI_MAC: /*MAC*/
  128. if ((gftParam->wifi_mac_addr[0]&0x1)
  129. ||(0 == (gftParam->wifi_mac_addr[0]|gftParam->wifi_mac_addr[1]|gftParam->wifi_mac_addr[2]|gftParam->wifi_mac_addr[3]|gftParam->wifi_mac_addr[4]|gftParam->wifi_mac_addr[5])))
  130. {
  131. memcpy(data, default_mac, rdlen);
  132. }
  133. else
  134. {
  135. memcpy(data, gftParam->wifi_mac_addr, rdlen);
  136. }
  137. break;
  138. case CMD_BT_MAC: /*MAC*/
  139. {
  140. u8 invalid_bt_mac[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
  141. u8 invalid_bt_mac1[6] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  142. if ((memcmp(gftParam->bt_mac_addr, invalid_bt_mac, 6) == 0)||(memcmp(gftParam->bt_mac_addr, invalid_bt_mac1, 6) == 0))
  143. {
  144. memcpy(data, default_mac, rdlen);
  145. *((u8*)data+5) +=1; /*defalut plus 1*/
  146. *((u8*)data) |= 0xC0; /*defalut public static type*/
  147. }
  148. else
  149. {
  150. memcpy(data, gftParam->bt_mac_addr, rdlen);
  151. }
  152. }
  153. break;
  154. case CMD_TX_DC: /*tx_dcoffset*/
  155. *(unsigned int *)data = gftParam->tx_dcoffset;
  156. break;
  157. case CMD_RX_DC: /*rx_dcoffset*/
  158. *(unsigned int *)data = gftParam->rx_dcoffset;
  159. break;
  160. case CMD_TX_IQ_GAIN:
  161. *(unsigned int *)data = gftParam->tx_iq_gain;
  162. break;
  163. case CMD_RX_IQ_GAIN:
  164. *(unsigned int *)data = gftParam->rx_iq_gain;
  165. break;
  166. case CMD_TX_IQ_PHASE:
  167. *(unsigned int *)data = gftParam->tx_iq_phase;
  168. break;
  169. case CMD_RX_IQ_PHASE:
  170. *(unsigned int *)data = gftParam->rx_iq_phase;
  171. break;
  172. case CMD_TX_GAIN: /*gain*/
  173. if (rdlen < FT_GAIN_LEN)
  174. {
  175. memcpy(data, gftParam->tx_gain, rdlen);
  176. }
  177. else
  178. {
  179. memcpy(data, gftParam->tx_gain, FT_GAIN_LEN);
  180. }
  181. break;
  182. default:
  183. return -1;
  184. }
  185. //printf("tls_ft_param_get: opnum=%d, val=%x\n", opnum, *(unsigned int *)data);
  186. return 0;
  187. }
  188. int tls_ft_param_set(unsigned int opnum, void *data, unsigned int len)
  189. {
  190. psCrcContext_t ctx;
  191. unsigned int writelen = 0;
  192. if (!data || !len)
  193. {
  194. return -1;
  195. }
  196. switch (opnum)
  197. {
  198. case CMD_WIFI_MAC: /*MAC*/
  199. memcpy(gftParam->wifi_mac_addr, (unsigned char *)data, len);
  200. break;
  201. case CMD_BT_MAC: /*BT MAC*/
  202. memcpy(gftParam->bt_mac_addr, (unsigned char *)data, len);
  203. break;
  204. case CMD_TX_DC: /*tx_dcoffset*/
  205. gftParam->tx_dcoffset = *(unsigned int *)data;
  206. break;
  207. case CMD_RX_DC: /*rx_dcoffset*/
  208. gftParam->rx_dcoffset = *(unsigned int *)data;
  209. break;
  210. case CMD_TX_IQ_GAIN:
  211. gftParam->tx_iq_gain = *(unsigned int *)data;
  212. break;
  213. case CMD_RX_IQ_GAIN:
  214. gftParam->rx_iq_gain = *(unsigned int *) data;
  215. break;
  216. case CMD_TX_IQ_PHASE:
  217. gftParam->tx_iq_phase = *(unsigned int *)data;
  218. break;
  219. case CMD_RX_IQ_PHASE:
  220. gftParam->rx_iq_phase = *(unsigned int *) data;
  221. break;
  222. case CMD_TX_GAIN: /*gain*/
  223. if (len >= FT_GAIN_LEN)
  224. {
  225. writelen = FT_GAIN_LEN;
  226. }
  227. else
  228. {
  229. writelen = len;
  230. }
  231. memcpy(gftParam->tx_gain, data, writelen);
  232. break;
  233. default:
  234. return -1;
  235. }
  236. tls_crypto_init();
  237. tls_crypto_crc_init(&ctx, 0xFFFFFFFF, CRYPTO_CRC_TYPE_32, INPUT_REFLECT | OUTPUT_REFLECT);
  238. gftParam->magic_no = SIGNATURE_WORD;
  239. tls_crypto_crc_update(&ctx, (unsigned char *)gftParam + 8, sizeof(FT_PARAM_ST) -8);
  240. tls_crypto_crc_final(&ctx, &gftParam->checksum);
  241. writelen = sizeof(FT_PARAM_ST);
  242. if(gftParam->version_no > 0 && gftParam->version_no < 0xFFFF)
  243. {
  244. writelen = sizeof(FT_PARAM_ST_VER1);
  245. tls_crypto_crc_init(&ctx, 0xFFFFFFFF, CRYPTO_CRC_TYPE_32, INPUT_REFLECT | OUTPUT_REFLECT);
  246. tls_crypto_crc_update(&ctx, (unsigned char *)&gftParamVer1.ft_ext1, gftParam->ext_param_len);
  247. tls_crypto_crc_final(&ctx, &gftParamVer1.ext_checksum);
  248. }
  249. tls_flash_unlock();
  250. tls_fls_write(FT_MAGICNUM_ADDR, (unsigned char *)gftParam, writelen);
  251. tls_flash_lock();
  252. return 0;
  253. }
  254. /**********************************************************************************************************
  255. * Description: This function is used to get mac addr.
  256. *
  257. * Arguments : mac mac addr,6 byte
  258. *
  259. * Returns : TLS_EFUSE_STATUS_OK get success
  260. * TLS_EFUSE_STATUS_EIO get failed
  261. **********************************************************************************************************/
  262. int tls_get_mac_addr(u8 *mac)
  263. {
  264. return tls_ft_param_get(CMD_WIFI_MAC, mac, 6);
  265. }
  266. /**********************************************************************************************************
  267. * Description: This function is used to set mac addr.
  268. *
  269. * Arguments : mac mac addr,6 byte
  270. *
  271. * Returns : TLS_EFUSE_STATUS_OK get success
  272. * TLS_EFUSE_STATUS_EIO get failed
  273. **********************************************************************************************************/
  274. int tls_set_mac_addr(u8 *mac)
  275. {
  276. return tls_ft_param_set(CMD_WIFI_MAC, mac, 6);
  277. }
  278. /**********************************************************************************************************
  279. * Description: This function is used to get bluetooth mac addr.
  280. *
  281. * Arguments : mac mac addr,6 byte
  282. *
  283. * Returns : TLS_EFUSE_STATUS_OK get success
  284. * TLS_EFUSE_STATUS_EIO get failed
  285. **********************************************************************************************************/
  286. int tls_get_bt_mac_addr(u8 *mac)
  287. {
  288. return tls_ft_param_get(CMD_BT_MAC, mac, 6);
  289. }
  290. /**********************************************************************************************************
  291. * Description: This function is used to set bluetooth mac addr.
  292. *
  293. * Arguments : mac mac addr,6 byte
  294. *
  295. * Returns : TLS_EFUSE_STATUS_OK get success
  296. * TLS_EFUSE_STATUS_EIO get failed
  297. **********************************************************************************************************/
  298. int tls_set_bt_mac_addr(u8 *mac)
  299. {
  300. return tls_ft_param_set(CMD_BT_MAC, mac, 6);
  301. }
  302. /**********************************************************************************************************
  303. * Description: This function is used to get tx lod.
  304. *
  305. * Arguments : *txlo
  306. *
  307. * Returns : 0 get success
  308. * -1 get failed
  309. **********************************************************************************************************/
  310. int tls_get_tx_lo(u8 *txlo)
  311. {
  312. return tls_ft_param_get(CMD_TX_DC, txlo, 4);
  313. }
  314. /**********************************************************************************************************
  315. * Description: This function is used to set tx lo.
  316. *
  317. * Arguments : txlo
  318. *
  319. * Returns : 0 set success
  320. * -1 set failed
  321. **********************************************************************************************************/
  322. int tls_set_tx_lo(u8 *txlo)
  323. {
  324. return tls_ft_param_set(CMD_TX_DC, txlo, 4);
  325. }
  326. /**********************************************************************************************************
  327. * Description: This function is used to get tx iq gain.
  328. *
  329. * Arguments : txGain
  330. *
  331. * Returns : 0 set success
  332. * -1 set failed
  333. **********************************************************************************************************/
  334. int tls_get_tx_iq_gain(u8 *txGain)
  335. {
  336. return tls_ft_param_get(CMD_TX_IQ_GAIN, txGain, 4);
  337. }
  338. /**********************************************************************************************************
  339. * Description: This function is used to set tx iq gain.
  340. *
  341. * Arguments : txGain
  342. *
  343. * Returns : 0 set success
  344. * -1 set failed
  345. **********************************************************************************************************/
  346. int tls_set_tx_iq_gain(u8 *txGain)
  347. {
  348. return tls_ft_param_set(CMD_TX_IQ_GAIN, txGain, 4);
  349. }
  350. /**********************************************************************************************************
  351. * Description: This function is used to get rx iq gain.
  352. *
  353. * Arguments : rxGain
  354. *
  355. * Returns : 0 set success
  356. * -1 set failed
  357. **********************************************************************************************************/
  358. int tls_get_rx_iq_gain(u8 *rxGain)
  359. {
  360. return tls_ft_param_get(CMD_RX_IQ_GAIN, rxGain, 4);
  361. }
  362. /**********************************************************************************************************
  363. * Description: This function is used to set rx iq gain.
  364. *
  365. * Arguments : rxGain
  366. *
  367. * Returns : 0 set success
  368. * -1 set failed
  369. **********************************************************************************************************/
  370. int tls_set_rx_iq_gain(u8 *rxGain)
  371. {
  372. return tls_ft_param_set(CMD_RX_IQ_GAIN, rxGain, 4);
  373. }
  374. /**********************************************************************************************************
  375. * Description: This function is used to get tx iq phase.
  376. *
  377. * Arguments : txPhase
  378. *
  379. * Returns : 0 set success
  380. * -1 set failed
  381. **********************************************************************************************************/
  382. int tls_get_tx_iq_phase(u8 *txPhase)
  383. {
  384. return tls_ft_param_get(CMD_TX_IQ_PHASE, txPhase, 4);
  385. }
  386. /**********************************************************************************************************
  387. * Description: This function is used to set tx iq phase.
  388. *
  389. * Arguments : txPhase
  390. *
  391. * Returns : 0 set success
  392. * -1 set failed
  393. **********************************************************************************************************/
  394. int tls_set_tx_iq_phase(u8 *txPhase)
  395. {
  396. return tls_ft_param_set(CMD_TX_IQ_PHASE, txPhase, 4);
  397. }
  398. /**********************************************************************************************************
  399. * Description: This function is used to get rx iq phase.
  400. *
  401. * Arguments : rxPhase
  402. *
  403. * Returns : 0 set success
  404. * -1 set failed
  405. **********************************************************************************************************/
  406. int tls_get_rx_iq_phase(u8 *rxPhase)
  407. {
  408. return tls_ft_param_get(CMD_RX_IQ_PHASE, rxPhase, 4);
  409. }
  410. /**********************************************************************************************************
  411. * Description: This function is used to set tx iq phase.
  412. *
  413. * Arguments : rxPhase
  414. *
  415. * Returns : 0 set success
  416. * -1 set failed
  417. **********************************************************************************************************/
  418. int tls_set_rx_iq_phase(u8 *rxPhase)
  419. {
  420. return tls_ft_param_set(CMD_RX_IQ_PHASE, rxPhase, 4);
  421. }
  422. int tls_freq_err_op(u8 *freqerr, u8 flag)
  423. {
  424. int ret = 0;
  425. psCrcContext_t ctx;
  426. int value = 0;
  427. if (flag){
  428. tls_flash_unlock();
  429. if(gftParam->version_no > 0 && gftParam->version_no < 0xFFFF)
  430. {
  431. memcpy((char *)&gftParamVer1.ft_ext1.rf_freq_err, (char *)freqerr, FREQERR_LEN);
  432. tls_crypto_crc_init(&ctx, 0xFFFFFFFF, CRYPTO_CRC_TYPE_32, INPUT_REFLECT | OUTPUT_REFLECT);
  433. tls_crypto_crc_update(&ctx, (unsigned char *)&gftParamVer1.ft_ext1, gftParam->ext_param_len);
  434. tls_crypto_crc_final(&ctx, &gftParamVer1.ext_checksum);
  435. ret = tls_fls_write(FT_MAGICNUM_ADDR, (unsigned char *)gftParam, sizeof(FT_PARAM_ST_VER1));
  436. }
  437. else
  438. {
  439. ret = tls_fls_write(FREQERR_ADDR, freqerr, FREQERR_LEN);
  440. }
  441. tls_flash_lock();
  442. }
  443. else
  444. {
  445. if(gftParam->version_no > 0 && gftParam->version_no < 0xFFFF)
  446. {
  447. memcpy((char *)freqerr, (char *)&gftParamVer1.ft_ext1.rf_freq_err, FREQERR_LEN);
  448. }
  449. else
  450. {
  451. ret = tls_fls_read(FREQERR_ADDR, freqerr, FREQERR_LEN);
  452. }
  453. memcpy(&value, freqerr, FREQERR_LEN);
  454. if (value > 200000) /*when freq offset is out of range (-200KHz, 200KHz),do not use it*/
  455. {
  456. value = 200000;
  457. memcpy((char *)freqerr, (char *)&value, FREQERR_LEN);
  458. }
  459. else if (value < -200000)
  460. {
  461. value = -200000;
  462. memcpy((char *)freqerr, (char *)&value, FREQERR_LEN);
  463. }
  464. }
  465. if (ret == 0)
  466. {
  467. return TLS_EFUSE_STATUS_OK;
  468. }
  469. else
  470. {
  471. return TLS_EFUSE_STATUS_EINVALID;
  472. }
  473. }
  474. int tls_rf_cal_finish_op(u8 *calflag, u8 flag)
  475. {
  476. int ret = 0;
  477. psCrcContext_t ctx;
  478. if (flag){
  479. tls_flash_unlock();
  480. if(gftParam->version_no > 0 && gftParam->version_no < 0xFFFF)
  481. {
  482. memcpy((char *)&gftParamVer1.ft_ext1.rf_cal_flag, (char *)calflag, CAL_FLAG_LEN);
  483. tls_crypto_crc_init(&ctx, 0xFFFFFFFF, CRYPTO_CRC_TYPE_32, INPUT_REFLECT | OUTPUT_REFLECT);
  484. tls_crypto_crc_update(&ctx, (unsigned char *)&gftParamVer1.ft_ext1, gftParam->ext_param_len);
  485. tls_crypto_crc_final(&ctx, &gftParamVer1.ext_checksum);
  486. ret = tls_fls_write(FT_MAGICNUM_ADDR, (unsigned char *)gftParam, sizeof(FT_PARAM_ST_VER1));
  487. }
  488. else
  489. {
  490. ret = tls_fls_write(CAL_FLAG_ADDR, calflag, CAL_FLAG_LEN);
  491. }
  492. tls_flash_lock();
  493. }
  494. else
  495. {
  496. if(gftParam->version_no > 0 && gftParam->version_no < 0xFFFF)
  497. {
  498. memcpy((char *)calflag, (char *)&gftParamVer1.ft_ext1.rf_cal_flag, CAL_FLAG_LEN);
  499. }
  500. else
  501. {
  502. ret = tls_fls_read(CAL_FLAG_ADDR, calflag, CAL_FLAG_LEN);
  503. }
  504. }
  505. if (ret == 0)
  506. {
  507. return TLS_EFUSE_STATUS_OK;
  508. }
  509. else
  510. {
  511. return TLS_EFUSE_STATUS_EINVALID;
  512. }
  513. }
  514. /**********************************************************************************************************
  515. * Description: This function is used to get tx gain.
  516. *
  517. * Arguments : txgain tx gain
  518. *
  519. * Returns : 0 get success
  520. * -1 get failed
  521. **********************************************************************************************************/
  522. int tls_get_tx_gain(u8 *txgain)
  523. {
  524. return tls_ft_param_get(CMD_TX_GAIN, txgain, TX_GAIN_LEN);
  525. }
  526. /**********************************************************************************************************
  527. * Description: This function is used to set tx gain.
  528. *
  529. * Arguments : txgain tx gain
  530. *
  531. * Returns : 0 set success
  532. * -1 set failed
  533. **********************************************************************************************************/
  534. int tls_set_tx_gain(u8 *txgain)
  535. {
  536. return tls_ft_param_set(CMD_TX_GAIN, txgain, TX_GAIN_LEN);
  537. }
  538. int tls_get_adc_cal_param(FT_ADC_CAL_ST *adc_cal)
  539. {
  540. return tls_ft_param_get(CMD_TX_ADC_CAL, adc_cal, sizeof(FT_ADC_CAL_ST));
  541. }