ql_init.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778
  1. /*================================================================
  2. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  3. Quectel Wireless Solution Proprietary and Confidential.
  4. =================================================================*/
  5. /*=================================================================
  6. EDIT HISTORY FOR MODULE
  7. This section contains comments describing changes made to the module.
  8. Notice that changes are listed in reverse chronological order.
  9. WHEN WHO WHAT, WHERE, WHY
  10. ------------ ------- -------------------------------------------------------------------------------
  11. =================================================================*/
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include <stdlib.h>
  15. #include "ql_app_feature_config.h"
  16. #include "ql_api_osi.h"
  17. #include "ql_log.h"
  18. #include "ql_pin_cfg.h"
  19. #include "nw_demo.h"
  20. #include "gpio_demo.h"
  21. #include "gpio_int_demo.h"
  22. #include "datacall_demo.h"
  23. #include "osi_demo.h"
  24. #include "ql_dev_demo.h"
  25. #include "adc_demo.h"
  26. #include "led_cfg_demo.h"
  27. #include "ql_sim_demo.h"
  28. #include "power_demo.h"
  29. #include "ql_api_dev.h"
  30. #include "app_loader.h"
  31. #include "hal_config.h"
  32. #ifdef QL_APP_FEATURE_USB
  33. #include "usb_demo.h"
  34. #endif
  35. #ifdef QL_APP_FEATURE_MMS
  36. #include "mms_demo.h"
  37. #endif
  38. #ifdef QL_APP_FEATURE_UART
  39. #include "uart_demo.h"
  40. #endif
  41. #ifdef QL_APP_FEATURE_RS485
  42. #include "rs485_demo.h"
  43. #endif
  44. #ifdef QL_APP_FEATURE_AUDIO
  45. #include "audio_demo.h"
  46. #endif
  47. #ifdef QL_APP_FEATURE_LCD
  48. #include "lcd_demo.h"
  49. #endif
  50. #ifdef QL_APP_FEATURE_LVGL
  51. #include "lvgl_demo.h"
  52. #endif
  53. #ifdef QL_APP_FEATURE_HTTP
  54. #include "http_demo.h"
  55. #endif
  56. #ifdef QL_APP_FEATURE_FTP
  57. #include "ftp_demo.h"
  58. #endif
  59. #ifdef QL_APP_FEATURE_MQTT
  60. #include "mqtt_demo.h"
  61. #endif
  62. #ifdef QL_APP_FEATURE_SSL
  63. #include "ssl_demo.h"
  64. #endif
  65. #ifdef QL_APP_FEATURE_PING
  66. #include "ping_demo.h"
  67. #endif
  68. #ifdef QL_APP_FEATURE_NTP
  69. #include "ntp_demo.h"
  70. #endif
  71. #ifdef QL_APP_FEATURE_LBS
  72. #include "lbs_demo.h"
  73. #endif
  74. #ifdef QL_APP_FEATURE_QTHSDK
  75. #include "qthsdk_demo.h"
  76. #endif
  77. #ifdef QL_APP_FEATURE_SOCKET
  78. #include "socket_demo.h"
  79. #endif
  80. #include "app_moid8id_hc.h"
  81. #ifdef QL_APP_FEATURE_FILE_ZIP
  82. #include "zip_demo.h"
  83. #endif
  84. #ifdef QL_APP_FEATURE_BT
  85. #ifdef QL_APP_FEATURE_BT_SPP
  86. #include "bt_spp_demo.h"
  87. #endif
  88. #ifdef QL_APP_FEATURE_BT_HFP
  89. #include "bt_hfp_demo.h"
  90. #endif
  91. #ifdef QL_APP_FEATURE_BT_A2DP_AVRCP
  92. #include "bt_a2dp_avrcp_demo.h"
  93. #endif
  94. #ifdef QL_APP_FEATURE_BLE_GATT
  95. #include "ble_gatt_demo.h"
  96. #endif
  97. #endif
  98. #ifdef QL_APP_FEATURE_FILE
  99. #include "ql_fs_demo.h"
  100. #endif
  101. #ifdef QL_APP_FEATURE_SMS
  102. #include "sms_demo.h"
  103. #endif
  104. #ifdef QL_APP_FEATURE_VOICE_CALL
  105. #include "voice_call_demo.h"
  106. #endif
  107. #ifdef QL_APP_FEATURE_GNSS
  108. #include "gnss_demo.h"
  109. #endif
  110. #ifdef QL_APP_FEATURE_HD_GNSS
  111. #include "hd_gnss_demo.h"
  112. #endif
  113. #ifdef QL_APP_FEATURE_SPI
  114. #include "spi_demo.h"
  115. #endif
  116. #ifdef QL_APP_FEATURE_SPI_NOR_FLASH
  117. #include "spi_nor_flash_demo.h"
  118. #endif
  119. #ifdef QL_APP_FEATURE_SPI4_EXT_NOR_SFFS
  120. #include "spi4_ext_nor_sffs_demo.h"
  121. #endif
  122. #ifdef QL_APP_FEATURE_SPI6_EXT_NOR
  123. #include "spi6_ext_nor_flash_demo.h"
  124. #endif
  125. #ifdef QL_APP_FEATURE_SPI_NAND_FLASH
  126. #include "spi_nand_flash_demo.h"
  127. #endif
  128. #ifdef QL_APP_FEATURE_CAMERA
  129. #include "camera_demo.h"
  130. #endif
  131. #ifdef QL_APP_FEATURE_WIFISCAN
  132. #include "wifi_scan_demo.h"
  133. #endif
  134. #ifdef QL_APP_FEATURE_HTTP_FOTA
  135. #include "fota_http_demo.h"
  136. #endif
  137. #ifdef QL_APP_FEATURE_FTP_FOTA
  138. #include "fota_ftp_demo.h"
  139. #endif
  140. #ifdef QL_APP_FEATURE_DECODER
  141. #include "decoder_demo.h"
  142. #endif
  143. #ifdef QL_APP_FEATURE_APP_IMG_AT
  144. #include "app_img_at_demo.h"
  145. #endif
  146. #ifdef QL_APP_FEATURE_VOLTE
  147. #include "volte_demo.h"
  148. #endif
  149. #ifdef QL_APP_FEATURE_VSIM_ADAPT
  150. #include "vsim_adapt_demo.h"
  151. #endif
  152. #ifdef QL_APP_FEATURE_KEYPAD
  153. #include "keypad_demo.h"
  154. #endif
  155. #ifdef QL_APP_FEATURE_RTC
  156. #include "ql_rtc_demo.h"
  157. #endif
  158. #ifdef QL_APP_FEATURE_SECURE_BOOT
  159. #include "ql_api_dev.h"
  160. #endif
  161. #ifdef QL_APP_FEATURE_USB_CHARGE
  162. #include "charge_demo.h"
  163. #endif
  164. #ifdef QL_APP_FEATURE_QCLOUD_IOT
  165. #include "qcloud_demo.h"
  166. #endif
  167. #ifdef QL_APP_FEATURE_VIRT_AT
  168. #include "ql_virt_at_demo.h"
  169. #endif
  170. #ifdef QL_APP_FEATURE_TTS
  171. #include "tts_demo.h"
  172. #endif
  173. #ifdef QL_APP_FEATURE_I2C
  174. #include "I2C_demo.h"
  175. #endif
  176. #ifdef QL_APP_FEATURE_PBK
  177. #include "ql_pbk_demo.h"
  178. #endif
  179. #ifdef QL_APP_FEATURE_SDMMC
  180. #include "ql_sdmmc_demo.h"
  181. #endif
  182. #ifdef QL_APP_FEATURE_ALI_LINKSDK
  183. #include "ali_demo.h"
  184. #endif
  185. #ifdef QL_APP_FEATURE_USBNET
  186. #include "usbnet_demo.h"
  187. #endif
  188. #ifdef QL_APP_FEATURE_FS_NAND_FLASH
  189. #include "fs_nand_flash_demo.h"
  190. #endif
  191. #ifdef QL_APP_FEATURE_FS_NOR_FLASH
  192. #include "fs_nor_flash_demo.h"
  193. #endif
  194. #ifdef QL_APP_FEATURE_SFTP
  195. #include "sftp_demo.h"
  196. #endif
  197. #ifdef QL_APP_FEATURE_MXML
  198. #include "mxml_demo.h"
  199. #endif
  200. #ifdef QL_APP_FEATURE_CLOUDOTA
  201. #include "cloudota_demo.h"
  202. #endif
  203. #ifdef QL_APP_FEATURE_EMBED_NOR_FLASH
  204. #include "embed_nor_flash_demo.h"
  205. #endif
  206. #ifdef QL_APP_FEATURE_EXT_NOR_FLASH
  207. #include "ext_nor_flash_demo.h"
  208. #endif
  209. #ifdef QL_APP_FEATURE_HILINK
  210. #include "hilink.h"
  211. #endif
  212. #ifdef QL_APP_FEATURE_PSM
  213. #include "psm_demo.h"
  214. #endif
  215. #ifdef QL_APP_FEATURE_STK
  216. #include "stk_demo.h"
  217. #endif
  218. #ifdef QL_APP_FEATURE_GPRS_DATA_TRANSFER
  219. #include "gprs_data_transfer_demo.h"
  220. #endif
  221. #ifdef QL_APP_FEATURE_TP
  222. #include "tp_demo.h"
  223. #endif
  224. #ifdef QL_APP_FEATURE_ALIOTSMARTCARD
  225. #include "aliotsmartcard_demo.h"
  226. #endif
  227. #ifdef QL_APP_FEATURE_ALIPAY_IOT_SDK
  228. extern void ql_alipay_iot_sdk_app_init(void);
  229. #endif
  230. #ifdef QL_APP_FEATURE_NTRIP_RTK
  231. #include "ntrip_rtk_demo.h"
  232. #endif
  233. #ifdef QL_APP_FEATURE_ETHERNET
  234. #include "ethernet_demo.h"
  235. #endif
  236. #ifdef QL_APP_FEATURE_WEBSOCKET
  237. #include "websocket_demo.h"
  238. #endif
  239. #ifdef QL_APP_FEATURE_WIFI
  240. #include "wifi_demo.h"
  241. #endif
  242. #define QL_INIT_LOG_LEVEL QL_LOG_LEVEL_INFO
  243. #define QL_INIT_LOG(msg, ...) QL_LOG(QL_INIT_LOG_LEVEL, "ql_INIT", msg, ##__VA_ARGS__)
  244. #define QL_INIT_LOG_PUSH(msg, ...) QL_LOG_PUSH("ql_INIT", msg, ##__VA_ARGS__)
  245. static void prvInvokeGlobalCtors(void)
  246. {
  247. extern void (*__init_array_start[])();
  248. extern void (*__init_array_end[])();
  249. size_t count = __init_array_end - __init_array_start;
  250. for (size_t i = 0; i < count; ++i)
  251. __init_array_start[i]();
  252. }
  253. static void ql_init_demo_thread(void *param)
  254. {
  255. QL_INIT_LOG("init demo thread enter, param 0x%x", param);
  256. /*Caution:If the macro of secure boot and the function are opened, download firmware and restart will enable secure boot.
  257. the secret key cannot be changed forever*/
  258. #ifdef QL_APP_FEATURE_SECURE_BOOT
  259. //ql_dev_enable_secure_boot();
  260. #endif
  261. #if 0
  262. ql_gpio_app_init();
  263. ql_gpioint_app_init();
  264. #endif
  265. #ifdef QL_APP_FEATURE_LEDCFG
  266. ql_ledcfg_app_init();
  267. #endif
  268. /*
  269. 1. 验证usb虚拟U盘功能需要在target.config中打开宏CONFIG_QUEC_PROJECT_FEATURE_USB_MASS_STORAGE
  270. 2. 映射sd卡到PC端需要打开sd卡demo(ql_sdmmc_app_init)去挂载sd卡文件系统
  271. 3. 映射6线flash到PC端需要打开6线flash demo(ql_spi6_ext_nor_flash_demo_init)挂载6线flash文件系统
  272. */
  273. #ifdef QL_APP_FEATURE_USB
  274. //ql_usb_app_init();
  275. #endif
  276. #ifdef QL_APP_FEATURE_AUDIO
  277. //ql_audio_app_init();
  278. #ifdef QL_APP_FEATURE_HEADSET_DET
  279. //ql_headset_det_app_init();
  280. #endif
  281. #endif
  282. #ifdef QL_APP_FEATURE_TTS
  283. /*
  284. *demo1直接调用TTS库和audio播放api进行TTS播放,
  285. *demo2对TTS库和audio的播放api进行封装,封装后的TTS api与我司asr系列的TTS api类似
  286. *注意:由于audio播放器只有一个,因此这两个demo只能运行一个,不能两个demo同时播放
  287. *用户如需将TTS库放到内核,则在target.config中将 CONFIG_QUEC_PROJECT_FEATURE_TTS_IN_KERNEL 置为 y,
  288. 并修改分区,将内核分区增大250k左右,其余的内容不变
  289. */
  290. //ql_tts_demo1_init();
  291. //ql_tts_demo2_init();
  292. #endif
  293. #ifdef QL_APP_FEATURE_LCD
  294. //ql_lcd_app_init();
  295. #endif
  296. #ifdef QL_APP_FEATURE_LVGL
  297. //ql_lvgl_app_init();
  298. #endif
  299. //ql_nw_app_init();
  300. //ql_datacall_app_init();
  301. //ql_osi_demo_init();
  302. #ifdef QL_APP_FEATURE_SDMMC
  303. ql_sdmmc_app_init();
  304. #endif
  305. #ifdef QL_APP_FEATURE_FILE
  306. //ql_fs_demo_init();
  307. #endif
  308. //ql_dev_app_init();
  309. //ql_adc_app_init();
  310. #ifdef QL_APP_FEATURE_UART
  311. //ql_uart_app_init();
  312. //ql_uart_rb_app_init();
  313. #endif
  314. #ifdef QL_APP_FEATURE_RS485
  315. //ql_rs485_app_init();
  316. #endif
  317. #ifdef QL_APP_FEATURE_BT
  318. #ifdef QL_APP_FEATURE_BT_SPP
  319. #endif
  320. #ifdef QL_APP_FEATURE_BLE_GATT
  321. //ql_ble_gatt_server_demo_init();
  322. //ql_ble_gatt_client_demo_init();
  323. #endif
  324. #ifdef QL_APP_FEATURE_BT_HFP
  325. //ql_bt_hfp_demo_init();
  326. #endif
  327. #ifdef QL_APP_FEATURE_BT_A2DP_AVRCP
  328. //ql_bt_a2dp_avrcp_app_init();
  329. #endif
  330. #endif
  331. //ql_sim_app_init();
  332. #ifdef QL_APP_FEATURE_PSM
  333. //ql_psm_app_init();
  334. #endif
  335. #ifdef QL_APP_FEATURE_CLOUDOTA
  336. //ql_cloudota_app_init();
  337. #endif
  338. #ifdef QL_APP_FEATURE_PWK
  339. //ql_pwrkey_app_init();
  340. #endif
  341. #ifdef QL_APP_FEATURE_FTP
  342. //ql_ftp_app_init();
  343. #endif
  344. #ifdef QL_APP_FEATURE_HTTP
  345. //ql_http_app_init();
  346. //ql_http_post_app_init();
  347. //ql_http_put_app_init();
  348. //ql_https_get_app_init();
  349. #endif
  350. #ifdef QL_APP_FEATURE_MQTT
  351. //ql_mqtt_app_init();
  352. #endif
  353. #ifdef QL_APP_FEATURE_SSL
  354. //ql_ssl_app_init();
  355. #endif
  356. #ifdef QL_APP_FEATURE_PING
  357. //ql_ping_app_init();
  358. #endif
  359. #ifdef QL_APP_FEATURE_NTP
  360. //ql_ntp_app_init();
  361. #endif
  362. #ifdef QL_APP_FEATURE_LBS
  363. //ql_lbs_app_init();
  364. #if defined (QL_APP_FEATURE_WIFISCAN)
  365. //ql_lbs_wifi_app_init();
  366. #endif
  367. #endif
  368. #ifdef QL_APP_FEATURE_QTHSDK
  369. //ql_qthsdk_app_init();
  370. #endif
  371. #ifdef QL_APP_FEATURE_SOCKET
  372. ql_socket_app_init();
  373. #endif
  374. #ifdef QL_APP_FEATURE_MMS
  375. //ql_mms_app_init();
  376. #endif
  377. #ifdef QL_APP_FEATURE_SMS
  378. //ql_sms_app_init();
  379. #endif
  380. #ifdef QL_APP_FEATURE_PBK
  381. //ql_pbk_app_init();
  382. #endif
  383. #ifdef QL_APP_FEATURE_STK
  384. // ql_stk_app_init();
  385. #endif
  386. #ifdef QL_APP_FEATURE_VOICE_CALL
  387. //ql_voice_call_app_init();
  388. #endif
  389. #ifdef QL_APP_FEATURE_VOLTE
  390. //ql_volte_app_init();
  391. #endif
  392. #ifdef QL_APP_FEATURE_VSIM_ADAPT
  393. //ql_vsim_adapt_init();
  394. #endif
  395. #ifdef QL_APP_FEATURE_GNSS //内置GNSS
  396. //ql_gnss_app_init();
  397. #endif
  398. #ifdef QL_APP_FEATURE_HD_GNSS //外挂华大GNSS
  399. //ql_hd_gnss_app_init();
  400. #endif
  401. #ifdef QL_APP_FEATURE_FILE_ZIP
  402. //ql_zip_app_init();
  403. #endif
  404. #ifdef QL_APP_FEATURE_SPI
  405. //ql_spi_demo_init();
  406. #endif
  407. #ifdef QL_APP_FEATURE_CAMERA
  408. /*因为camera被i2c用来演示功能,所以打开camera demo时不可同时打开i2c demo*/
  409. /*because camera as a demonstration for i2c, so camera demo can not be opened when the i2c demo open */
  410. //ql_camera_app_init();
  411. #endif
  412. #ifdef QL_APP_FEATURE_SPI_NOR_FLASH
  413. //ql_spi_nor_flash_demo_init();
  414. #endif
  415. #ifdef QL_APP_FEATURE_SPI4_EXT_NOR_SFFS
  416. //ql_spi4_ext_nor_sffs_demo_init();
  417. #endif
  418. #ifdef QL_APP_FEATURE_SPI6_EXT_NOR
  419. //ql_spi6_ext_nor_flash_demo_init();
  420. #endif
  421. #ifdef QL_APP_FEATURE_SPI_NAND_FLASH
  422. //ql_spi_nand_flash_demo_init();
  423. #endif
  424. #if defined (QL_APP_FEATURE_WIFISCAN)
  425. //ql_wifiscan_app_init();
  426. #endif
  427. #ifdef QL_APP_FEATURE_HTTP_FOTA
  428. //ql_fota_http_app_init();
  429. #endif
  430. #ifdef QL_APP_FEATURE_FTP_FOTA
  431. //ql_fota_ftp_app_init();
  432. #endif
  433. #ifdef QL_APP_FEATURE_DECODER
  434. //ql_decoder_app_init();
  435. #endif
  436. #ifdef QL_APP_FEATURE_APP_IMG_AT
  437. //ql_app_img_at_init();
  438. #endif
  439. #ifdef QL_APP_FEATURE_KEYPAD
  440. //ql_keypad_app_init();
  441. #endif
  442. #ifdef QL_APP_FEATURE_RTC
  443. //ql_rtc_app_init();
  444. #endif
  445. #ifdef QL_APP_FEATURE_USB_CHARGE
  446. //ql_charge_app_init();
  447. #endif
  448. #ifdef QL_APP_FEATURE_ALI_LINKSDK
  449. //ql_ali_sdk_mqtt_client_test_init(); /* mqtt_basic_demo.c */
  450. //ql_ali_sdk_bootstrap_test_init(); /* bootstrap_posix_demo.c */
  451. //ql_ali_sdk_cota_test_init(); /* cota_basic_demo.c */
  452. //ql_ali_sdk_das_test_init(); /* das_basic_demo.c */
  453. //ql_ali_sdk_data_model_test_init(); /* data_model_basic_demo.c */
  454. //ql_ali_sdk_devinfo_test_init(); /* devinfo_posix_demo.c */
  455. //ql_ali_sdk_diag_test_init(); /* diag_basic_demo.c */
  456. //ql_ali_sdk_dynreg_test_init(); /* dynreg_basic_demo.c */
  457. //ql_ali_sdk_dynregmq_test_init(); /* dynregmq_basic_demo.c */
  458. //ql_ali_sdk_fota_test_init(); /* fota_basic_demo.c */
  459. //ql_ali_sdk_http_client_test_init(); /* http_basic_demo.c */
  460. //ql_ali_sdk_logpost_test_init(); /* logpost_basic_demo.c */
  461. //ql_ali_sdk_mqtt_broadcast_test_init(); /* mqtt_broadcast_demo.c */
  462. //ql_ali_sdk_rrpc_test_init(); /* mqtt_rrpc_demo.c */
  463. //ql_ali_sdk_ntp_test_init(); /* ntp_posix_demo.c */
  464. //ql_ali_sdk_shadow_test_init(); /* shadow_basic_demo.c */
  465. #endif
  466. #ifdef QL_APP_FEATURE_QCLOUD_IOT
  467. //light_data_template_sample_start();/* light_data_template_sample_start_demo.c */
  468. //mqtt_sample_start(); /* mqtt_sample_start_demo.c */
  469. //data_template_sample_start(); /* data_template_sample_start_demo.c */
  470. //ota_mqtt_sample_start(); /* ota_mqtt_sample_start_demo.c */
  471. //raw_data_sample_start(); /* raw_data_sample_start_demo.c */
  472. //dynreg_dev_sample_start(); /* dynreg_dev_sample_start_demo.c */
  473. //gateway_sample_start(); /* gateway_sample_start_demo.c */
  474. #endif
  475. #ifdef QL_APP_FEATURE_VIRT_AT
  476. //ql_virt_at_app_init();
  477. #endif
  478. #ifdef QL_APP_FEATURE_I2C
  479. /*因为i2c通过camera来演示功能,所以打开i2c demo时不可同时打开camera demo*/
  480. /*because I2C uses the camera as a demonstration, so i2c demo can not be opened when the camera demo open */
  481. //ql_i2c_demo_init();
  482. #endif
  483. #ifdef QL_APP_FEATURE_USBNET
  484. //ql_usbnet_app_init();
  485. #endif
  486. #ifdef QL_APP_FEATURE_FS_NAND_FLASH
  487. //ql_fs_nand_flash_demo_init();
  488. #endif
  489. #ifdef QL_APP_FEATURE_FS_NOR_FLASH
  490. //ql_fs_nor_flash_demo_init();
  491. #endif
  492. #ifdef QL_APP_FEATURE_SFTP
  493. //ql_sftp_app_init();
  494. #endif
  495. #ifdef QL_APP_FEATURE_MXML
  496. //ql_mxml_app_init();
  497. #endif
  498. #ifdef QL_APP_FEATURE_EMBED_NOR_FLASH
  499. //ql_embed_nor_flash_app_init();
  500. #endif
  501. #ifdef QL_APP_FEATURE_EXT_NOR_FLASH
  502. //ql_ext_nor_flash_app_init();
  503. #endif
  504. #ifdef QL_APP_FEATURE_HILINK
  505. //hilink_main();
  506. #endif
  507. #ifdef QL_APP_FEATURE_GPRS_DATA_TRANSFER
  508. //ql_gprs_data_transfer_app_init();
  509. #endif
  510. #ifdef QL_APP_FEATURE_TP
  511. //ql_tp_demo_init();
  512. #endif
  513. #ifdef QL_APP_FEATURE_ALIPAY_IOT_SDK
  514. //ql_alipay_iot_sdk_app_init();
  515. #endif
  516. #ifdef QL_APP_FEATURE_ALIOTSMARTCARD
  517. //ql_aliotsmartcard_app_init();
  518. #endif
  519. #ifdef QL_APP_FEATURE_WEBSOCKET
  520. //ql_websocket_app_init();
  521. #endif
  522. #ifdef QL_APP_FEATURE_NTRIP_RTK
  523. //ql_ntrip_rtk_demo_init();
  524. #endif
  525. #ifdef QL_APP_FEATURE_ETHERNET
  526. //ql_ethernet_demo_init();
  527. #endif
  528. #ifdef QL_APP_FEATURE_WIFI
  529. //ql_wifi_demo_init();
  530. #endif
  531. ql_sdmmc_app_init();
  532. ql_spi_demo_init();
  533. ql_power_app_init();
  534. hc_moid_app_init();
  535. #if 0
  536. ql_fota_ftp_app_init();
  537. QL_INIT_LOG("/////////////////////////////////////////////////////////////////////////////");
  538. QL_INIT_LOG("升级前的SDK...");
  539. QL_INIT_LOG("/////////////////////////////////////////////////////////////////////////////");
  540. #else
  541. QL_INIT_LOG("/////////////////////////////////////////////////////////////////////////////");
  542. QL_INIT_LOG("升级成功后的SDK...");
  543. QL_INIT_LOG("/////////////////////////////////////////////////////////////////////////////");
  544. //ql_socket_app_init();
  545. #ifdef QL_APP_FEATURE_FTP
  546. ql_ftp_app_demo_init();
  547. #endif
  548. #endif
  549. ql_rtos_task_sleep_ms(1000); /*Chaos change: set to 1000 for the camera power on*/
  550. /*To save logs to sdcard/nandflash, you must call this function after initializing sdcard/nandflash file system;*/
  551. /*Logs before this point can be output via USB or debug port, which can be configured in prvTraceInit of app_start*/
  552. //ql_fs_trace_init();
  553. #ifdef QL_APP_FEATURE_APPIMG2
  554. void appimg_jump(void);
  555. appimg_jump();
  556. #endif
  557. ql_rtos_task_delete(NULL);
  558. }
  559. int appimg_enter(void *param)
  560. {
  561. QlOSStatus err = QL_OSI_SUCCESS;
  562. ql_task_t ql_init_task = NULL;
  563. QL_INIT_LOG("init demo enter APP: %s @ %s", QL_APP_VERSION, QL_APP_BUILD_RELEASE_TYPE);
  564. prvInvokeGlobalCtors();
  565. if(0 == strcasecmp(QL_APP_BUILD_RELEASE_TYPE, "release"))
  566. {
  567. ql_dev_cfg_wdt(1);
  568. //open the kernel log
  569. //ql_quec_trace_enable(1);
  570. }
  571. else
  572. {
  573. ql_dev_cfg_wdt(0);
  574. //close the kernel log
  575. //ql_quec_trace_enable(0);
  576. }
  577. err = ql_rtos_task_create(&ql_init_task, 1024*4, APP_PRIORITY_NORMAL, "ql_init", ql_init_demo_thread, NULL, 1);
  578. if(err != QL_OSI_SUCCESS)
  579. {
  580. QL_INIT_LOG("init failed");
  581. }
  582. return err;
  583. }
  584. void appimg_exit(void)
  585. {
  586. QL_INIT_LOG("init demo exit");
  587. }
  588. #ifdef QL_APP_FEATURE_APPIMG2
  589. void appimg_jump(void)
  590. {
  591. #if 0
  592. #ifdef CONFIG_APPIMG_LOAD_FLASH
  593. const unsigned flash_img_address = (const unsigned)CONFIG_APPIMG_FLASH_ADDRESS;
  594. const unsigned flash_img_size = (const unsigned)CONFIG_APPIMG_FLASH_SIZE;
  595. const unsigned flash_ram_address = (const unsigned)CONFIG_APP_FLASHIMG_RAM_ADDRESS;
  596. const unsigned flash_ram_size = (const unsigned)CONFIG_APP_FLASHIMG_RAM_SIZE;
  597. #else
  598. const unsigned flash_ram_address = (const unsigned)CONFIG_APP_FILEIMG_RAM_ADDRESS;
  599. const unsigned flash_ram_size = (const unsigned)CONFIG_APP_FILEIMG_RAM_SIZE;
  600. #endif
  601. #else
  602. #ifdef CONFIG_APPIMG_LOAD_FLASH
  603. const unsigned flash_img_address = (const unsigned)CONFIG_APPIMG2_FLASH_ADDRESS;
  604. const unsigned flash_img_size = (const unsigned)CONFIG_APPIMG2_FLASH_SIZE;
  605. const unsigned flash_ram_address = (const unsigned)CONFIG_APP2_FLASHIMG_RAM_ADDRESS;
  606. const unsigned flash_ram_size = (const unsigned)CONFIG_APP2_FLASHIMG_RAM_SIZE;
  607. #else
  608. const unsigned flash_ram_address = (const unsigned)CONFIG_APP2_FILEIMG_RAM_ADDRESS;
  609. const unsigned flash_ram_size = (const unsigned)CONFIG_APP2_FILEIMG_RAM_SIZE;
  610. #endif
  611. #endif
  612. #ifdef CONFIG_APPIMG_LOAD_FLASH
  613. appImageHandler_t AppImgFlash = {};
  614. if(ql_app_image_from_flash(flash_img_address,flash_img_size,flash_ram_address,flash_ram_size,&AppImgFlash))
  615. {
  616. QL_INIT_LOG("Find app image at 0x%x", flash_img_address);
  617. AppImgFlash.enter(NULL);
  618. }
  619. else
  620. {
  621. QL_INIT_LOG("app jump failed");
  622. }
  623. #endif
  624. #ifdef CONFIG_APPIMG_LOAD_FILE
  625. appImageHandler_t AppImgFile = {};
  626. if(ql_app_image_from_file(CONFIG_APPIMG2_LOAD_FILE_NAME,flash_ram_address,flash_ram_size,&AppImgFile))
  627. {
  628. QL_INIT_LOG("Find file image at " CONFIG_APPIMG2_LOAD_FILE_NAME);
  629. AppImgFile.enter(NULL);
  630. }
  631. else
  632. {
  633. QL_INIT_LOG("app jump failed");
  634. }
  635. #endif
  636. }
  637. #endif