luat_pins.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. #include "luat_base.h"
  2. #include "luat_pins.h"
  3. #include "luat_mcu.h"
  4. #include <stdlib.h>
  5. #include "luat_fs.h"
  6. #include "luat_mem.h"
  7. #include "luat_pm.h"
  8. #include "luat_hmeta.h"
  9. #define LUAT_LOG_TAG "pins"
  10. #include "luat_log.h"
  11. #include "cJSON.h"
  12. uint8_t g_pins_debug;
  13. static inline int luat_isdigit(char c)
  14. {
  15. return (c >= '0' && c <= '9');
  16. }
  17. static int search(char *string, size_t string_len, const char **table, uint8_t len)
  18. {
  19. for(int i = 0; i < len; i++)
  20. {
  21. if (strnstr(string, table[i], string_len))
  22. {
  23. return i;
  24. }
  25. }
  26. return -1;
  27. }
  28. static luat_pin_peripheral_function_description_u luat_pin_function_analyze(char *string, size_t len)
  29. {
  30. luat_pin_peripheral_function_description_u description = {0};
  31. char *old = string;
  32. size_t org_len = len;
  33. size_t offset = 0;
  34. const char *peripheral_names[LUAT_MCU_PERIPHERAL_QTY] = {
  35. "UART","I2C","SPI","PWM","CAN","GPIO","I2S","SDIO","LCD","CAMERA","ONEWIRE","KEYBORAD","ETH","QSPI","USIM"
  36. };
  37. const char *function0_names[4] = {
  38. "RX","SCL","MOSI","PHY_INT"
  39. };
  40. const char *function1_names[4] = {
  41. "TX","SDA","MISO","MDC"
  42. };
  43. const char *function2_names[4] = {
  44. "RTS","CLK","BCLK","MDIO"
  45. };
  46. const char *function3_names[4] = {
  47. "CTS","CS","LRCLK","REF_CLK"
  48. };
  49. const char *function4_names[4] = {
  50. "MCLK","CMD","IO","DAT"
  51. };
  52. const char *function5_names[2] = {
  53. "SCLK","RST"
  54. };
  55. description.code = 0;
  56. for(description.peripheral_type = 0; description.peripheral_type < LUAT_MCU_PERIPHERAL_QTY; description.peripheral_type++)
  57. {
  58. offset = strlen(peripheral_names[description.peripheral_type]);
  59. if (!memcmp(string, peripheral_names[description.peripheral_type], offset))
  60. {
  61. int function_id;
  62. string += offset;
  63. len -= offset;
  64. if (description.peripheral_type != LUAT_MCU_PERIPHERAL_GPIO)
  65. {
  66. description.peripheral_id = 0;
  67. while(luat_isdigit(string[0]))
  68. {
  69. description.peripheral_id = description.peripheral_id * 10 + (string[0] - '0');
  70. string++;
  71. len--;
  72. }
  73. }
  74. switch(description.peripheral_type)
  75. {
  76. case LUAT_MCU_PERIPHERAL_UART:
  77. function_id = search(string, len, function0_names, sizeof(function0_names)/4);
  78. if (function_id >= 0)
  79. {
  80. description.function_id = 0;
  81. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  82. }
  83. function_id = search(string, len, function1_names, sizeof(function1_names)/4);
  84. if (function_id >= 0)
  85. {
  86. description.function_id = 1;
  87. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  88. }
  89. function_id = search(string, len, function2_names, sizeof(function2_names)/4);
  90. if (function_id >= 0)
  91. {
  92. description.function_id = 2;
  93. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  94. }
  95. function_id = search(string, len, function3_names, sizeof(function3_names)/4);
  96. if (function_id >= 0)
  97. {
  98. description.function_id = 3;
  99. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  100. }
  101. break;
  102. case LUAT_MCU_PERIPHERAL_I2C:
  103. function_id = search(string, len, function0_names, sizeof(function0_names)/4);
  104. if (function_id >= 0)
  105. {
  106. description.function_id = 0;
  107. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  108. }
  109. function_id = search(string, len, function1_names, sizeof(function1_names)/4);
  110. if (function_id >= 0)
  111. {
  112. description.function_id = 1;
  113. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  114. }
  115. break;
  116. case LUAT_MCU_PERIPHERAL_SPI:
  117. function_id = search(string, len, function0_names, sizeof(function0_names)/4);
  118. if (function_id >= 0)
  119. {
  120. description.function_id = 0;
  121. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  122. }
  123. function_id = search(string, len, function1_names, sizeof(function1_names)/4);
  124. if (function_id >= 0)
  125. {
  126. description.function_id = 1;
  127. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  128. }
  129. function_id = search(string, len, function2_names, sizeof(function2_names)/4);
  130. if (function_id >= 0)
  131. {
  132. description.function_id = 2;
  133. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  134. }
  135. function_id = search(string, len, function3_names, sizeof(function3_names)/4);
  136. if (function_id >= 0)
  137. {
  138. description.function_id = 3;
  139. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  140. }
  141. break;
  142. case LUAT_MCU_PERIPHERAL_PWM:
  143. if (!string[0])
  144. {
  145. description.function_id = 0;
  146. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  147. }
  148. if (string[0] == 'n')
  149. {
  150. description.function_id = 1;
  151. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  152. }
  153. break;
  154. case LUAT_MCU_PERIPHERAL_CAN:
  155. function_id = search(string, len, function0_names, sizeof(function0_names)/4);
  156. if (function_id >= 0)
  157. {
  158. description.function_id = 0;
  159. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  160. }
  161. function_id = search(string, len, function1_names, sizeof(function1_names)/4);
  162. if (function_id >= 0)
  163. {
  164. description.function_id = 1;
  165. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  166. }
  167. function_id = search(string, len, function2_names, sizeof(function2_names)/4);
  168. if (function_id >= 0)
  169. {
  170. description.function_id = 2;
  171. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  172. }
  173. break;
  174. case LUAT_MCU_PERIPHERAL_GPIO:
  175. if (luat_isdigit(string[0]))
  176. {
  177. function_id = 0;
  178. while(luat_isdigit(string[0]))
  179. {
  180. function_id = function_id * 10 + (string[0] - '0');
  181. string++;
  182. len--;
  183. }
  184. description.code |= (function_id & 0x00ff);
  185. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  186. }
  187. break;
  188. case LUAT_MCU_PERIPHERAL_I2S:
  189. function_id = search(string, len, function0_names, sizeof(function0_names)/4);
  190. if (function_id >= 0)
  191. {
  192. description.function_id = 0;
  193. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  194. }
  195. function_id = search(string, len, function1_names, sizeof(function1_names)/4);
  196. if (function_id >= 0)
  197. {
  198. description.function_id = 1;
  199. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  200. }
  201. function_id = search(string, len, function2_names, sizeof(function2_names)/4);
  202. if (function_id >= 0)
  203. {
  204. description.function_id = 2;
  205. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  206. }
  207. function_id = search(string, len, function3_names, sizeof(function3_names)/4);
  208. if (function_id >= 0)
  209. {
  210. description.function_id = 3;
  211. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  212. }
  213. function_id = search(string, len, function4_names, sizeof(function4_names)/4);
  214. if (function_id >= 0)
  215. {
  216. description.function_id = 4;
  217. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  218. }
  219. break;
  220. case LUAT_MCU_PERIPHERAL_SDIO:
  221. if (strnstr(string, "_DATA", len))
  222. {
  223. if (string[5] >= '0' && string[5] <= '3')
  224. {
  225. function_id = string[5] - '0';
  226. }
  227. break;
  228. }
  229. function_id = search(string, len, function4_names, sizeof(function4_names)/4);
  230. if (function_id >= 0)
  231. {
  232. description.function_id = 4;
  233. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  234. }
  235. function_id = search(string, len, function5_names, sizeof(function5_names)/4);
  236. if (function_id >= 0)
  237. {
  238. description.function_id = 5;
  239. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  240. }
  241. break;
  242. case LUAT_MCU_PERIPHERAL_ONEWIRE:
  243. if (!string[0])
  244. {
  245. description.function_id = 0;
  246. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  247. }
  248. break;
  249. case LUAT_MCU_PERIPHERAL_ETH:
  250. if (strnstr(string, "_RXD", len))
  251. {
  252. if (string[4] == 'V')
  253. {
  254. description.function_id = 4;
  255. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  256. }
  257. else if (string[5] == '0' || string[5] == '1')
  258. {
  259. description.function_id = string[5] - '0' + 5;
  260. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  261. }
  262. }
  263. if (strnstr(string, "_TXD", len))
  264. {
  265. if (string[5] == '0' || string[5] == '1')
  266. {
  267. description.function_id = string[5] - '0' + 7;
  268. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  269. }
  270. }
  271. if (strnstr(string, "_TXEN", len))
  272. {
  273. description.function_id = 9;
  274. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  275. }
  276. function_id = search(string, len, function0_names, sizeof(function0_names)/4);
  277. if (function_id >= 0)
  278. {
  279. description.function_id = 0;
  280. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  281. }
  282. function_id = search(string, len, function1_names, sizeof(function1_names)/4);
  283. if (function_id >= 0)
  284. {
  285. description.function_id = 1;
  286. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  287. }
  288. function_id = search(string, len, function3_names, sizeof(function3_names)/4);
  289. if (function_id >= 0)
  290. {
  291. description.function_id = 3;
  292. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  293. }
  294. function_id = search(string, len, function2_names, sizeof(function2_names)/4);
  295. if (function_id >= 0)
  296. {
  297. description.function_id = 2;
  298. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  299. }
  300. break;
  301. case LUAT_MCU_PERIPHERAL_SIM:
  302. if (description.peripheral_id) description.peripheral_id = 1;
  303. function_id = search(string, len, function2_names, sizeof(function2_names)/4);
  304. if (function_id >= 0)
  305. {
  306. description.function_id = 1;
  307. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  308. }
  309. function_id = search(string, len, function4_names, sizeof(function4_names)/4);
  310. if (function_id >= 0)
  311. {
  312. description.function_id = 0;
  313. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  314. }
  315. function_id = search(string, len, function5_names, sizeof(function5_names)/4);
  316. if (function_id >= 0)
  317. {
  318. description.function_id = 2;
  319. goto LUAT_PIN_FUNCTION_ANALYZE_DONE;
  320. }
  321. break;
  322. default:
  323. break;
  324. }
  325. }
  326. }
  327. LLOGE("%.*s不是可配置的外设功能", len, string);
  328. description.code = 0xffff;
  329. LUAT_PIN_FUNCTION_ANALYZE_DONE:
  330. if (!description.is_no_use)
  331. {
  332. if (g_pins_debug) {
  333. LLOGD("%.*s find %d,%d,%d", org_len, old, description.peripheral_type, description.peripheral_id, description.function_id);
  334. }
  335. }
  336. return description;
  337. }
  338. int luat_pins_setup(uint16_t pin, const char* func_name, size_t name_len, int altfun_id) {
  339. luat_pin_function_description_t pin_description = {0};
  340. luat_pin_peripheral_function_description_u func_description = {0};
  341. luat_pin_iomux_info pin_list[LUAT_PIN_FUNCTION_MAX] = {0};
  342. int result = 0;
  343. // 需要忽略部分特定名称的pin
  344. #ifdef LUAT_MODEL_AIR780EHV
  345. if (pin == 57 || pin == 58) { // air780ehv的57/58不支持配置
  346. LLOGE("pin%d不支持修改", pin);
  347. goto LUAT_PIN_SETUP_DONE;
  348. }
  349. #endif
  350. #ifdef CHIP_EC718
  351. if (name_len < 4) {
  352. return 0;
  353. }
  354. if (memcmp("DBG_", func_name, 4) == 0
  355. || memcmp("LCD_", func_name, 4) == 0
  356. || memcmp("USIM_", func_name, 5) == 0
  357. || memcmp("VBUS", func_name, 4) == 0
  358. || memcmp("USB_", func_name, 4) == 0
  359. || memcmp("CHG_", func_name, 4) == 0
  360. || memcmp("CAM_", func_name, 4) == 0
  361. || memcmp("SPI", func_name, 3) == 0
  362. || memcmp("WAKEUP", func_name, 5) == 0
  363. || memcmp("ADC", func_name, 3) == 0
  364. || memcmp("PWR_KEY", func_name, 7) == 0
  365. || memcmp("I2S", func_name, 3) == 0){
  366. return 1;
  367. }
  368. #endif
  369. #ifdef __BK72XX__
  370. if (pin == 26 || pin == 27){ // air8101的26/27不支持配置,只能作为uart0调试串口
  371. LLOGE("pin%d 是UART0功能, 不支持修改", pin);
  372. goto LUAT_PIN_SETUP_DONE;
  373. }
  374. if (memcmp("DVP_", func_name, 4) == 0
  375. || memcmp("QSPI", func_name, 4) == 0
  376. || memcmp("RGB_", func_name, 4) == 0
  377. || memcmp("SWCLK", func_name, 5) == 0
  378. || memcmp("SWDIO", func_name, 5) == 0){
  379. return 1;
  380. }
  381. #endif
  382. if (func_name != NULL)
  383. {
  384. if (name_len < 2)
  385. {
  386. LLOGE("%.*s外设功能描述不正确", name_len, func_name);
  387. goto LUAT_PIN_SETUP_DONE;
  388. }
  389. func_description = luat_pin_function_analyze(func_name, name_len);
  390. if (func_description.code == 0xffff)
  391. {
  392. goto LUAT_PIN_SETUP_DONE;
  393. }
  394. // GPIO128 及以上的, 不支持配置
  395. if (func_description.peripheral_type == LUAT_MCU_PERIPHERAL_GPIO && (func_description.code & 0x00ff) >= 128) {
  396. result = 1;
  397. goto LUAT_PIN_SETUP_DONE;
  398. }
  399. // UART10 及以上的, 不支持配置
  400. if (func_description.peripheral_type == LUAT_MCU_PERIPHERAL_UART && func_description.peripheral_id >= 10) {
  401. result = 1;
  402. goto LUAT_PIN_SETUP_DONE;
  403. }
  404. }
  405. if (g_pins_debug) {
  406. LLOGD("luat_pins_setup pin %d func %.*s fid %d pid %d", pin, (int)name_len, func_name, func_description.function_id, func_description.peripheral_id);
  407. }
  408. if (luat_pin_get_description_from_num(pin, &pin_description))
  409. {
  410. LLOGE("pin%d不支持修改", pin);
  411. goto LUAT_PIN_SETUP_DONE;
  412. }
  413. if (func_name != NULL)
  414. {
  415. altfun_id = luat_pin_get_altfun_id_from_description(func_description.code, &pin_description);
  416. if (altfun_id == 0xff)
  417. {
  418. LLOGE("%.*s不是pin%d的可配置功能", name_len, func_name, pin);
  419. goto LUAT_PIN_SETUP_DONE;
  420. }
  421. }
  422. else
  423. {
  424. if (altfun_id < LUAT_PIN_ALT_FUNCTION_MAX)
  425. {
  426. func_description.code = pin_description.function_code[altfun_id];
  427. if (func_description.code == 0xffff)
  428. {
  429. LLOGE("没有altfunction%d", altfun_id);
  430. goto LUAT_PIN_SETUP_DONE;
  431. }
  432. }
  433. else
  434. {
  435. LLOGE("没有altfunction%d", altfun_id);
  436. goto LUAT_PIN_SETUP_DONE;
  437. }
  438. }
  439. if (!luat_pin_get_iomux_info(func_description.peripheral_type, (func_description.peripheral_type != LUAT_MCU_PERIPHERAL_GPIO)?(func_description.peripheral_id):(func_description.code & 0x00ff), pin_list))
  440. {
  441. if (func_description.peripheral_type != LUAT_MCU_PERIPHERAL_GPIO)
  442. {
  443. pin_list[func_description.function_id].altfun_id = altfun_id;
  444. pin_list[func_description.function_id].uid = pin_description.uid;
  445. }
  446. else
  447. {
  448. pin_list[0].altfun_id = altfun_id;
  449. pin_list[0].uid = pin_description.uid;
  450. }
  451. result = luat_pin_set_iomux_info(func_description.peripheral_type, (func_description.peripheral_type != LUAT_MCU_PERIPHERAL_GPIO)?(func_description.peripheral_id):(func_description.code & 0x00ff), pin_list);
  452. if (result >= 0)
  453. {
  454. result = 1;
  455. goto LUAT_PIN_SETUP_DONE;
  456. }
  457. else {
  458. LLOGD("luat_pin_set_iomux_info fail! pin %d tp %d id %d", pin, func_description.peripheral_type, func_description.peripheral_id);
  459. }
  460. }
  461. else {
  462. LLOGD("luat_pin_get_iomux_info fail! pin %d tp %d id %d", pin, func_description.peripheral_type, func_description.peripheral_id);
  463. }
  464. if (func_name)
  465. {
  466. LLOGE("%.*s不可配置,请确认硬件手册上该功能可以复用在2个及以上的pin", name_len, func_name);
  467. }
  468. else
  469. {
  470. LLOGE("altfunction%d不可配置,请确认硬件手册上该功能可以复用在2个及以上的pin", altfun_id);
  471. }
  472. LUAT_PIN_SETUP_DONE:
  473. return result;
  474. }
  475. // 加载过程
  476. static int luat_pins_load_from_json(cJSON *root)
  477. {
  478. cJSON *pins = cJSON_GetObjectItem(root, "pins");
  479. cJSON *item = NULL;
  480. cJSON *pin_item = NULL;
  481. cJSON *func_item = NULL;
  482. uint16_t pin = 0;
  483. const char* func = NULL;
  484. if (pins == NULL) {
  485. LLOGE("json without pins item!!!");
  486. return -101;
  487. }
  488. int pins_count = cJSON_GetArraySize(pins);
  489. if (pins_count < 1) {
  490. LLOGE("invaild pins item!!!");
  491. return -102;
  492. }
  493. if (pins_count == 0) {
  494. LLOGD("pins is emtry!!!");
  495. return -103;
  496. }
  497. for (size_t i = 0; i < pins_count; i++)
  498. {
  499. item = cJSON_GetArrayItem(pins, i);
  500. if (item == NULL) {
  501. LLOGW("emtry pins item[%d]??", i);
  502. continue;
  503. }
  504. if (!cJSON_IsArray(item)) {
  505. LLOGW("pins item[%d] is not array", i);
  506. continue;
  507. }
  508. pin_item = cJSON_GetArrayItem(item, 0);
  509. func_item = cJSON_GetArrayItem(item, 1);
  510. if (pin_item == NULL || func_item == NULL) {
  511. LLOGW("pins item[%d] is not vaild!!!", i);
  512. continue;
  513. }
  514. if (!cJSON_IsNumber(pin_item)) {
  515. LLOGW("pins item[%d] pin is not number", i);
  516. continue;
  517. }
  518. if (!cJSON_IsString(func_item) || func_item->valuestring == NULL) {
  519. LLOGW("pins item[%d] func is not string", i);
  520. continue;
  521. }
  522. pin = pin_item->valueint;
  523. func = func_item->valuestring;
  524. if (luat_pins_setup(pin, func, strlen(func), 0) != 1) {
  525. LLOGW("pins %d %s setup failed", pin, func);
  526. continue;
  527. }
  528. }
  529. return 0;
  530. }
  531. static int luat_pins_load_from_bin(const uint8_t *data, size_t len)
  532. {
  533. LLOGE("not support bin file yet");
  534. return -5;
  535. }
  536. int luat_pins_load_from_file(const char* path) {
  537. size_t flen;
  538. int ret = -100;
  539. flen = luat_fs_fsize(path);
  540. if (flen < 1) {
  541. LLOGW("%s not exist!!", path);
  542. return -1;
  543. }
  544. if (flen > 16 * 1024) {
  545. LLOGW("%s too large!!", path);
  546. return -2;
  547. }
  548. uint8_t *data = (uint8_t *)luat_heap_malloc(flen);
  549. if (data == NULL) {
  550. LLOGW("no memory for loading %s", path);
  551. return -3;
  552. }
  553. FILE* fd = luat_fs_fopen(path, "rb");
  554. if (fd == NULL) {
  555. LLOGW("open %s failed", path);
  556. luat_heap_free(data);
  557. return -4;
  558. }
  559. if (luat_fs_fread(data, 1, flen, fd) != flen) {
  560. LLOGW("read %s failed", path);
  561. luat_heap_free(data);
  562. return -4;
  563. }
  564. luat_fs_fclose(fd);
  565. if (memcmp(path + strlen(path) - 4, ".bin", 4) == 0) {
  566. ret = luat_pins_load_from_bin(data, flen);
  567. }
  568. else if (memcmp(path + strlen(path) - 5, ".json", 5) == 0) {
  569. cJSON * root = cJSON_ParseWithLength((const char *)data, flen);
  570. if (root == NULL) {
  571. LLOGE("not valid json %s", path);
  572. }
  573. else {
  574. // 是否为debug模式
  575. if (cJSON_HasObjectItem(root, "pins_debug")) {
  576. cJSON *item = cJSON_GetObjectItem(root, "pins_debug");
  577. g_pins_debug = item->valueint;
  578. if (g_pins_debug) {
  579. LLOGI("pins debug模式开启");
  580. }
  581. }
  582. // 检查io电平配置
  583. if (cJSON_HasObjectItem(root, "iovolt")) {
  584. cJSON *item = cJSON_GetObjectItem(root, "iovolt");
  585. if(item->valueint >= 1800 && item->valueint <= 3300) {
  586. luat_pm_iovolt_ctrl(LUAT_PM_ALL_GPIO, item->valueint);
  587. }
  588. }
  589. ret = luat_pins_load_from_json((cJSON *)root);
  590. cJSON_Delete(root);
  591. }
  592. }
  593. else {
  594. LLOGE("unknown file type %s", path);
  595. }
  596. if (data) {
  597. luat_heap_free(data);
  598. data = NULL;
  599. }
  600. return ret;
  601. }