Compare commits

...

258 Commits
master ... lwip

Author SHA1 Message Date
Jeremy db3784b928 optmize lwip demo and add iperf for hc32 2023-05-15 15:00:13 +08:00
Jeremy 39c8ee354b Merge branch 'xuos_prepare_for_master' into prepare_for_master 2023-05-15 10:57:50 +08:00
xuedongliang 48decbe80f fix compile bug for test apps from Mo_jiayang
it is OK
2023-05-10 10:12:52 +08:00
xuedongliang 9109db0d94 add ota project function code from Wang_guozhu
it is OK
2023-05-10 10:12:16 +08:00
xuedongliang e0bc75c405 feat add S7 protocol in control framework and add plc app demo from liu_weichao
it is OK
2023-05-09 11:11:12 +08:00
wgzAIIT d6ff73acab Merge pull request 'merge code' (#11) from xidatong-arm32 into prepare_for_master 2023-05-08 16:23:04 +08:00
wgzAIIT 2532ae43d4 move version rollback function for OTA to tool dir 2023-05-08 16:19:49 +08:00
wgzAIIT b825fd7f84 Merge pull request 'merge code' (#10) from xidatong-arm32 into prepare_for_master 2023-05-08 15:57:56 +08:00
jqy1988 813ca3dd20 add delta dvp test readme 2023-05-08 15:28:02 +08:00
jqy1988 d471bc04db add mitsubishi fx2n test readme 2023-05-08 15:24:52 +08:00
jqy1988 2df93dc327 1.add br ppc2100 ethernet test app 2.add br ppc2100 test readme 2023-05-08 15:15:41 +08:00
wgzAIIT 078f4babf1 mover version rollback function for OTA to tool dir 2023-05-08 14:48:38 +08:00
wgzAIIT 33abc16c67 revert "Add version rollback function for OTA" 2023-05-08 13:59:41 +08:00
wgzAIIT 4b40ae19dc 1、Adapt ota-related interfaces to the XiZi_IIoT/tool/bootloader directory
2、Add flash config by menuconfig
2023-05-06 13:28:16 +08:00
Wien.b b37885b839 Merge branch 'control_framework' of https://gitlink.org.cn/IACU/xiuos into control_framework 2023-05-05 19:21:33 -07:00
Wien.b 042a51dc36 add Omron CP1H test program 2023-05-05 19:20:53 -07:00
jqy1988 fb27201603 1.add ge cpe100 test app 2.add ge plc readme 2023-05-05 14:59:52 +08:00
huang 0ecb29c887 Add version rollback function for OTA 2023-05-04 13:38:16 +08:00
Wien.b af665f9f29 modify siemens app readme 2023-04-27 02:54:02 -07:00
Wien.b 7b33905b3e add siemens s7-1512 app readme 2023-04-27 02:34:22 -07:00
Wien.b 2ec0e796fe add omron readme 2023-04-26 01:17:30 -07:00
Liu_Weichao e231a29f5a 1、delete useless code in s7.c;2、fix hc32f4a0 compile error when using libs7.a。 2023-04-26 11:20:31 +08:00
Liu_Weichao 4f72b78b96 Merge branch 'control_framework' of https://gitlink.org.cn/IACU/xiuos into control_framework 2023-04-26 11:02:48 +08:00
Liu_Weichao 8ae4bce9a5 Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into control_framework 2023-04-26 10:50:45 +08:00
jqy1988 20d9a52bdb add inovance am401 communication test readme file 2023-04-26 10:14:43 +08:00
jqy1988 b38e5c1c5c add inovance am401 ethernet test app 2023-04-25 15:18:19 +08:00
wgzAIIT 54d6c01868 Merge pull request 'merge code' (#9) from xidatong-arm32 into prepare_for_master 2023-04-24 19:22:42 +08:00
wgzAIIT 84f78b6435 Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into xidatong-arm32 2023-04-24 19:10:07 +08:00
xuedongliang a894bc8940 feat add lorawan_radio_driver submodule and fix compile error from Liu_weichao
it is OK
2023-04-24 15:49:56 +08:00
wgzAIIT 3d16b694dd Use the serial port iap method to burn the initial firmware under the bootloader 2023-04-24 10:24:56 +08:00
wgzAIIT cfadebc3e8 Optimize OTA information structure and flash_write function 2023-04-23 16:33:22 +08:00
wgzAIIT 6074b2b147 Add function comments for flash related functions 2023-04-21 10:15:15 +08:00
Jeremy 692e010e0d fix compile bug 2023-04-20 18:02:50 +08:00
wgzAIIT 8bc7546828 support ota function for xidatong-arm32 2023-04-20 15:34:19 +08:00
Wien.b c63301a870 Modify S7 Protocol 2023-04-19 02:31:45 -07:00
Wien.b 94c6631a24 Add S7 protocol and a S7 App demo 2023-04-18 19:52:24 -07:00
Liu_Weichao dc5537a64f feat add lorawan submodule README.md and fix Kconfig compile error 2023-04-18 18:14:10 +08:00
Liu_Weichao 2b3f3de22e feat add control device struct in control framework 2023-04-18 17:05:11 +08:00
wgzAIIT a9deff5cd0 move UartConfig function to common.c 2023-04-18 15:38:52 +08:00
wgzAIIT bbb8dd75f8 Add four macro definitions:
#define XIUOS_FLAH_ADDRESS  0x60100000
#define BAKUP_FLAH_ADDRESS  0x60300000
#define DOWN_FLAH_ADDRESS   0x60500000
#define FLAG_FLAH_ADDRESS   0x60700000
2023-04-17 18:36:47 +08:00
wgzAIIT 198fabf970 fix xidatong-arm32 NorFlash init bug 2023-04-17 15:08:10 +08:00
Jeremy 5677cd0768 Merge remote-tracking branch 'xuos/prepare_for_master' into prepare_for_master 2023-04-17 14:12:07 +08:00
Liu_Weichao 0c45a736d3 feat add bootloader in XiZi_IIoT/tool DIR 2023-04-14 14:07:48 +08:00
Liu_Weichao 3d9160fa44 fix compile error in pthread_arm.h 2023-04-14 14:06:18 +08:00
Liu_Weichao 6b41cdbcfe Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into lorawan_develop 2023-04-14 14:05:31 +08:00
Wien.b ba7e1a0d3b new paragraph named xdh_60t4_e.c xsdh_60a32_e.c 2023-04-13 19:57:03 -07:00
Wien.b 0a58099c51 new paragraph named xdh_60t4_e.c xsdh_60a32_e.c omron_cp1l.c 2023-04-13 19:55:40 -07:00
xuedongliang f0240eb702 1、fix compile bug;2、delete unused defconfig on nuttx;3、optimize w5500 socket test cmd for edu-riscv64 board from Wangguozhu
it is OK
2023-04-13 12:05:47 +08:00
xuedongliang 2db9716cc0 fix LwIP error on HC32F4A0
it is OK
2023-04-13 12:04:52 +08:00
xuedongliang 640c5e6f59 fix LCD error from Mo_Jiayang
it is OK
2023-04-13 12:03:10 +08:00
xuedongliang e6390ecf73 add tinyttf engine for xidatong-arm32 from huchao
it is OK
2023-04-13 12:01:01 +08:00
xuedongliang 84f453d4ac fix issue from soft-spi's Kconfig and complete cmsis-nn runtime for XiZi from Wuzheng
it is OK
2023-04-13 12:00:30 +08:00
xuedongliang f33c50b97e feat fix modbus-uart bugs for control_framework and add plc demo C files from Liu_weichao
it is Ok
2023-04-13 11:59:53 +08:00
xuedongliang cc8f577ba4 repair the compiler error of the configuration with Seperating compiler or musl lib from Wangweigen
it is OK
2023-04-13 11:59:20 +08:00
wgzAIIT 85105cb65d Upgrading binary packages by iap on xidatong-arm32 2023-04-13 09:57:08 +08:00
wgzAIIT d615793063 1、Modifying Flash Partitions:
Bootloader:0x60000000-0x6007FFFF 512K
   APP:0x60100000-0x601FFFFF 1024K
   Backup:0x60300000-0x603FFFFF 1024K
   Download:0x60500000-0x605FFFFF 1024K
   OTAFlag:0x60700000-0x6071FFFF 128K
2、add four flash function:flash_erase,flash_write,flash_read and flash_copy
2023-04-12 08:29:57 +08:00
wgzAIIT 3819716568 Update flash-mcuboot-app.ld 2023-04-11 11:19:25 +08:00
Wang_Weigen 60e1c1bf8f add part of bsp for sabre lite board 2023-04-07 16:23:09 +08:00
wgzAIIT 669ef1eb2b 1、feat add link-bootloader.lds[start from 0x60000000] and link-application.lds[start from 0x60040000];
2、support BSP_USING_OTA MCUBOOT_BOOTLOADER and MCUBOOT_APPLICATION in xidatong-arm32/Kconfig;
3、support compile XiZi-xidatong-arm32-boot.bin when enable MCUBOOT_BOOTLOADER and XiZi-xidatong-arm32-app.bin when enable MCUBOOT_APPLICATION;
4、add QSPIFlash function for xidatong-arm32。
2023-04-04 15:47:34 +08:00
Liu_Weichao 95b049e636 feat support lorawan_devicenode submodule 2023-03-31 14:14:54 +08:00
Jeremy a3377c21b6 fix #260 pbuf assert 2023-03-30 10:26:11 +08:00
Jeremy 8a589d0eaa fix:test_lcd_edu.c draw line mem overread 2023-03-27 10:44:55 +08:00
Liu_Weichao 58057e0b5e feat add lorawan_devicenode submodule 2023-03-22 16:50:34 +08:00
Liu_Weichao 08388f1b11 1、updata lora_radio_driver submodules;2、fix radio define error in connect_lora_spi.c;3、fix ticks calculation bug in timer_settime。 2023-03-21 15:16:12 +08:00
wgzAIIT 0a3ba23753 add flash-mcuboot-app.ld file copy from flash-ocram.ld 2023-03-20 18:09:14 +08:00
Liu_Weichao 0a71b8b62a fix timer set_time over-value error 2023-03-20 17:21:43 +08:00
huchao cf1d5a234b add tinyttf 2023-03-20 07:55:30 +00:00
Liu_Weichao 83d383feab feat support event function for XiZi transform_layer 2023-03-20 14:49:40 +08:00
Liu_Weichao 47cea831ba modify lora_radio_driver path and compile OK 2023-03-17 10:05:59 +08:00
Liu_Weichao a4eec2646d feat add lora_radio_driver submodule 2023-03-16 11:21:47 +08:00
Liu_Weichao 4db0c44434 delete useless printf in connect_touch.c 2023-03-16 10:17:21 +08:00
Liu_Weichao 1776223332 feat add spi type in transform_layer 2023-03-14 17:08:21 +08:00
Liu_Weichao 79edaf3d17 feat add flags for soft timer to choose ONCE or PERIODIC 2023-03-14 17:07:30 +08:00
Liu_Weichao 5e499bf975 add soft timer posix support in XiZi 2023-03-10 17:11:53 +08:00
Liu_Weichao d797a999ae Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into control_framework 2023-03-02 09:32:31 +08:00
wgzAIIT a16223f850 fix compile bug 2023-03-01 10:17:01 +08:00
wgzAIIT abba2ce735 delete defconfig on nuttx 2023-03-01 09:24:03 +08:00
Wang_Weigen 419b53594f repair the compiler error of gd32vf103 2023-02-28 18:06:28 +08:00
Wang_Weigen 179c894840 Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into develop 2023-02-28 17:20:51 +08:00
Wang_Weigen 5ae31a37f3 repair the compiler error of the configuration with Seperating compiler or musl lib 2023-02-28 17:20:39 +08:00
wuzheng 195e0085db fix complie error for incompatibilities between kernels 2023-02-28 10:44:32 +08:00
wuzheng 4b0783ab07 Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into prepare_for_master 2023-02-27 17:21:37 +08:00
wuzheng 27ad06f4c1 readme update in cmsis-nn demo 2023-02-27 17:18:35 +08:00
wgzAIIT 0996e47b88 optimize w5500 socket test cmd for edu-riscv64 board 2023-02-27 16:59:08 +08:00
wuzheng d7e72942b5 cmsis runtime complement for XiZi 2023-02-27 14:19:04 +08:00
xuedongliang 779444f998 add timer and flash and can drivers with test examples for hc32f4a0 in XiZi_IIoT from Wu_zheng
it is OK
2023-02-27 12:13:39 +08:00
xuedongliang 35dc835d12 optimize w5500 socket test cmd for edu-riscv64 board from Wang_guozhu
it is OK
2023-02-27 12:13:03 +08:00
wuzheng 918b3663b8 fix kconfig issue for tfcard drivered by soft-spi 2023-02-24 19:52:11 +08:00
wuzheng eed171df2a path_kernel.mk update 2023-02-24 16:00:46 +08:00
wuzheng 9b3c321150 add makefiles to adapt nnom and cmsis-nn for xizi 2023-02-24 15:47:49 +08:00
wgzAIIT a286b2292f Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into develop 2023-02-24 14:14:59 +08:00
wgzAIIT 1655d28d63 optimize w5500 socket test cmd for edu-riscv64 board 2023-02-24 13:51:36 +08:00
xuedongliang 5dc639a133 add ADC and DAC driver for hc32f4a0 on XiZi_IIOT from Zhao_yun
it is OK
2023-02-24 10:49:36 +08:00
xuedongliang bebc65607e add rtc and watchdog driver for hc32f4a0 on XiZi_IIOT from Wu_zhen
it is OK
2023-02-24 10:48:53 +08:00
jqy1988 7fee9d9e9f 1.modify melsec Melsec3eqlGenerateCommand function 2.modify ModbusUartGetDataBySerial function 3.add delta,ge,mitsubishi plc test app 2023-02-22 16:13:50 +08:00
wuzheng 10c39d930c add cpp support for hc32f4a0 2023-02-22 15:15:40 +08:00
wuzheng 73fbeea117 add can and flash driver for hc32f4a0 in XiZi_IIoT 2023-02-22 09:38:41 +08:00
Liu_Weichao e0c9761f75 Merge branch 'control_framework' of https://git.trustie.net/IACU/xiuos into control_framework 2023-02-20 10:42:08 +08:00
wuzheng 002325c1d8 add flash and timer driver for hc32f4a0 2023-02-17 16:21:06 +08:00
zhaoyun1215 1b73886dbc add adc and dac drivers for hc32f4a0 in XiZi Kernel 2023-02-14 18:04:49 -08:00
Wien.b 572cbd201a new a demo named omron_cp1l.c 2023-02-10 02:36:57 -08:00
Wien.b 0ebfda21f7 new a demo named schneider_m241.c 2023-02-09 22:32:21 -08:00
zhaoyun1215 3a5d63762b add adc and dac drivers for hc32f4a0 in XiZi Kernel 2023-02-09 00:43:15 -08:00
zhaoyun1215 3950a6ec28 add adc and dac drivers for hc32f4a0 in XiZi Kernel 2023-02-09 00:41:24 -08:00
wuzheng ba51d8ba8e fix bugs for gpio interrupt in hc32f4a0 for XiZi_IIOT 2023-02-09 10:59:17 +08:00
wuzheng c88ce9d708 fix bugs in hc32f4a0 GPIO driver 2023-02-08 09:20:58 +08:00
wuzheng bfe1e72378 Format rtc and watchdog driver for hc32 2023-02-07 16:48:52 +08:00
wuzheng e6fa8a2603 code simplified and delete some unused 2023-02-06 16:34:46 +08:00
wgzAIIT 732320f5c9 support sabre-lite borad on xiuos appframework and Nuttx 2023-02-03 13:32:52 +08:00
wuzheng 3a6b5d7f4f fix file log error 2023-02-03 09:50:21 +08:00
wuzheng 8632d37d14 fix the file time log error 2023-02-03 09:48:11 +08:00
wuzheng bcb5e48d6a adapt watchdog driver for hc32f4a0 2023-02-03 09:45:20 +08:00
wuzheng d2e6719a0e adapt rtc driver for hc32f4a0 2023-02-02 18:01:24 +08:00
Wien.b f55da28789 new two plc in xinje 2023-01-31 23:50:23 -08:00
wuzheng b2de31844a KPU's kconfig bug fix 2023-02-01 14:19:26 +08:00
Wien.b a590d902f5 create a new folder called xinje 2023-01-18 18:48:36 -08:00
wgzAIIT 60dbe78045 Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into develop 2023-01-18 16:24:34 +08:00
xuedongliang ff78fcc100 1、add menuconfig and compilation function for XiZi_AIoT; 2、add isr function and machine start for imxrt6q-sabrelite from Wang_Weigen
it is OK
2023-01-18 15:08:00 +08:00
xuedongliang aea6a4f63e fixed nsh can’t use bug support hc32f4a0 i2c driver from Wang_linyu
it is OK
2023-01-18 15:07:00 +08:00
xuedongliang d1da6ae35b 1、feat add modbus tcp protocol for control framework; 2、fix spi6 io define error on hc32f4a0 board from Liu_Weichao
it is OK
2023-01-18 15:06:08 +08:00
xuedongliang df2a1043df add lora e22、ch376 usb fuction、lora e220 and wifi esp8285 for edu-riscv64 on Nuttx from Wang_Guozhu
it is OK
2023-01-18 15:05:28 +08:00
xuedongliang d144306f76 Add Feature from Wu_Zheng
add kpu driver for edu-riscv64.
adapt kpu framework for XiZi_IIOT.
unified dvp driver for edu-riscv64.
add ethernet(W5500) example for edu-riscv64
adapt qs-fs/fx sensor framework in XiZi for edu-riscv6
2023-01-18 15:04:51 +08:00
Liu_Weichao 55654af275 fix serial receive data bug in control framework on xidatong-arm32 board 2023-01-13 15:35:34 +08:00
Liu_Weichao fb11970cab fix serial ioctl error in control framework 2023-01-13 10:29:20 +08:00
Wang_Weigen 806492e271 1、modify the 'link.lds' file accroding to sdk;2、add irq enable and disable function 2023-01-11 14:32:41 +08:00
Liu_Weichao 8001b07341 fix Calculte error 2023-01-10 17:49:20 +08:00
Liu_Weichao c621db2ca7 add imxrt1052 board mdelay function 2023-01-10 17:21:10 +08:00
Liu_Weichao f8b845ca62 optimize control framework using socket, support LwIP and W5500(need to add init/socket apis) 2023-01-06 17:25:11 +08:00
Liu_Weichao 9ad282c39e feat support LwIP in hc32f4a0 board 2023-01-06 10:17:24 +08:00
wgzAIIT a4e37b962f add spi_sdcard driver for edu-riscv64 on Nuttx 2023-01-04 18:20:19 +08:00
Liu_Weichao e4742a480c feat add modbus uart protocol for control framework, compile OK 2023-01-04 17:14:01 +08:00
Wang_Weigen 6b091797ae 1、add 'menuconfig' function for XiZi_AIoT with imx6q-sabrelite board;2、add compilation function for AIoT system with imx6q-sabrelite board;3、add newlib base files;4、add startup files and irq function for imx6q-sabrelite 2023-01-03 10:14:05 +08:00
wgzAIIT e37d8ed7d1 Merge pull request 'fix kconfig bug for edu-riscv64' (#3) from develop into prepare_for_master 2022-12-30 10:35:39 +08:00
wgzAIIT 1a0880c3f2 fix kconfig bug for edu-riscv64 2022-12-30 10:31:43 +08:00
Liu_Weichao 6010fe5654 feat add melsec tcp protocol for control framework, compile OK 2022-12-29 16:35:23 +08:00
wgzAIIT a7bdd89097 Merge pull request 'add e22 test demo on edu-riscv64' (#2) from develop into prepare_for_master 2022-12-28 14:52:42 +08:00
wgzAIIT 32bf012d9a add e22 test demo on edu-riscv64 2022-12-28 14:44:16 +08:00
wagweigen ce60710fe6 add exception.c and irq entry function 2022-12-23 16:28:39 +08:00
WuZheng 9f6419e5f6 fix dvp-read problem caused by driver adaptation 2022-12-23 09:09:54 +08:00
wlyu 4edf73254e support i2c and fixed no shell bug 2022-12-21 18:36:30 +08:00
Liu_Weichao b933e0decb fix spi6 io define error on hc32f4a0 board 2022-12-21 12:07:47 +08:00
WuZheng 0b5c6b0f9f fix bugs that e220 initialize death 2022-12-20 15:15:35 +08:00
wgzAIIT 6b4097b941 Merge pull request 'merge code' (#1) from develop into prepare_for_master 2022-12-20 11:07:48 +08:00
wgzAIIT d57552e223 add e22、ch376 usb fuction、lora e220 and wifi esp8285 for edu-riscv64 on nuttx 2022-12-20 11:04:19 +08:00
Wang_Weigen 4f7f98b0e9 add armv7-a start file 2022-12-19 16:33:25 +08:00
WuZheng 27cc89bcef update readme.md for know framwork 2022-12-19 14:24:35 +08:00
WuZheng 38c4419ef9 add KPU driver and resource in XiZi for edu-riscv64 2022-12-19 14:13:54 +08:00
Liu_Weichao bc014769f5 1、fix modbus_tcp socket bug;2、fix ch438 init error on xidatong-arm32 board 2022-12-16 10:58:26 +08:00
WuZheng 4e1bc3bf04 add readme for yolo framework 2022-12-15 16:17:31 +08:00
WuZheng 5761bd0916 primarily unify dvp APIs with rt 2022-12-15 15:51:46 +08:00
WuZheng 186790f5ec fix bugs camera buff unstable 2022-12-15 10:36:56 +08:00
WuZheng 1864f39dd2 fix bugs in multi-blocks read meeting '0xFE' CRCs 2022-12-14 17:35:10 +08:00
Liu_Weichao 59fa5451ca feat add modbus tcp write function and fix modbus tcp bug 2022-12-13 17:25:37 +08:00
WuZheng 5a64507a84 Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into prepare_for_master 2022-12-13 17:04:42 +08:00
Liu_Weichao 56a014fe98 feat add modbus tcp protocol for control framework 2022-12-13 11:19:11 +08:00
Liu_Weichao 9b334f90e0 Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into control_framework 2022-12-13 11:17:38 +08:00
wuzheng 6a89a12c49 temporarily adapt kpu for XiZi 2022-12-12 16:24:54 +08:00
wuzheng 04dc796f95 fix problems in client recv 2022-12-12 16:22:36 +08:00
xuedongliang a3094c1dd6 repaire the k210 start failed problem caused by float sub operation at boot.S from Wang_weigen
it is OK
2022-12-09 14:22:19 +08:00
wuzheng 2df54e7f41 fix some bugs for sd read 2022-12-09 13:57:01 +08:00
Liu_Weichao 6ef80903ce Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into control_framework 2022-12-09 13:55:45 +08:00
Wang_Weigen 4f85bc91e5 modify compiler with double float 2022-12-09 13:39:18 +08:00
xuedongliang 5622be48ac add i2c and gpio driver for hc32f4a0 board from Liu_Weichao
it is OK
2022-12-09 11:34:57 +08:00
xuedongliang 669b7f427e Optimize k210 serial port driver for nuttx from Wang_guozhu
it is OK
2022-12-09 11:33:52 +08:00
xuedongliang b20f041722 add tablestorage for RT-Thread_Fusion_XiUOS from yu
it is OK
2022-12-09 11:33:17 +08:00
xuedongliang e802403362 support hc32 irq and spi and spi flash from Wang_linyu
it is OK
2022-12-09 11:32:21 +08:00
Wang_Weigen 19b16f7729 repaire the k210 start failed problem caused by float sub operation at boot.S 2022-12-09 11:24:41 +08:00
Liu_Weichao 465241e569 feat add ethernet driver for hc32f4a0 board, compile OK and PHY Loop-Back test OK 2022-12-05 17:46:56 +08:00
Liu_Weichao dc8244cc5d feat add gpio for hc32f4a0 board 2022-12-05 11:23:56 +08:00
Liu_Weichao d0902ca37f feat add i2c driver for hc32f4a0 board 2022-12-05 11:01:47 +08:00
wuzheng 6fa996d132 add ethernet test fro edu-riscv64 2022-12-02 11:04:46 +08:00
wuzheng a782b53423 adapt qs-fs and qs-fx for edu-riscv64 2022-12-01 09:37:43 +08:00
yu 5a3954b726 add tablestorage for RT-Thread_Fusion_XiUOS 2022-11-30 15:27:07 +08:00
Liu_Weichao 0b49dd1a3c feat add melsec protocol for control framework 2022-11-29 17:11:51 +08:00
wlyu 9b83bc586e support hc32 irq and spi and spi flash 2022-11-29 14:16:37 +08:00
wgzAIIT 2757649473 add loransh/defconfig for edu-riscv64 on nuttx 2022-11-29 11:13:08 +08:00
wuzheng 100fe8c2d0 add w5500 test example 2022-11-29 09:30:48 +08:00
wgzAIIT 4fd39c0dd7 Optimize k210 serial port driver for nuttx 2022-11-28 17:39:30 +08:00
wuzheng d8ac0998b2 fix configure network problem and configure fpio for w5500 2022-11-28 09:38:35 +08:00
wgzAIIT f1029b81c3 fix compile error for makefile 2022-11-25 13:31:38 +08:00
wgzAIIT 1f97dd3d77 Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into develop 2022-11-25 11:01:37 +08:00
xuedongliang e5bf0cee41 Add camera driver and examples for edu-riscv64 from Wu_zheng
it is OK
2022-11-25 10:25:38 +08:00
xuedongliang d845bd61b6 feat support control_framework from Liu_Weichao
it is perfect
2022-11-25 10:25:09 +08:00
wuzheng 334d5f1eee Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into prepare_for_master 2022-11-25 09:50:44 +08:00
wgzAIIT 0125fdf0ef Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into develop 2022-11-25 09:32:07 +08:00
wuzheng 22e35a70aa adapt wifi framework and fix 'strncat' problem 2022-11-25 09:29:37 +08:00
Liu_Weichao 8583ea25b6 feat add control_framework, support fins protocol OK 2022-11-24 17:20:40 +08:00
Liu_Weichao ba31c9e0f8 feat add control_framework, socket connect OK and delete useless printf 2022-11-24 16:07:41 +08:00
Liu_Weichao f4b21208e8 Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into control_framework 2022-11-24 16:06:20 +08:00
xuedongliang 2a01ff712d add w5500 support to xidatong-riscv64 and edu-riscv64 from Tu_Yuyang
it is OK
2022-11-24 14:27:29 +08:00
Liu_Weichao bc47ae644f feat add control_framework, read json file OK 2022-11-24 10:46:54 +08:00
wgzAIIT 31189c2939 add edu-riscv64 board on nuttx 2022-11-23 18:15:53 +08:00
TXuian 1061ce4dff Merge remote-tracking branch 'upstream/prepare_for_master' into prepare_for_master 2022-11-22 08:03:14 -08:00
wuzheng c1976c8d92 fix errors of naming function 2022-11-22 15:57:33 +08:00
TXuian 0d93a91829 add support to edu. 2022-11-21 19:38:18 -08:00
TXuian 7145cd6920 update w5500 functions. 2022-11-21 19:07:50 -08:00
Liu_Weichao 2a8a11849d feat add control_framework, support fins protocol, add control_io.c and function descriptions 2022-11-22 11:05:57 +08:00
wuzheng 49df162734 add softspi in xidatong-riscv64 2022-11-22 10:20:15 +08:00
Liu_Weichao 5560fc5318 feat add control_framework, support fins protocol, compile OK 2022-11-21 17:20:44 +08:00
wuzheng 987fd6c798 fit touch postion for lvgl 2022-11-21 16:46:46 +08:00
wuzheng ebc61431bd fit touch position for lcd 2022-11-21 15:59:25 +08:00
wuzheng 7c252bda56 fix touch address error 2022-11-21 14:29:17 +08:00
wuzheng e31199a104 Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into prepare_for_master 2022-11-21 11:30:48 +08:00
wuzheng 68cdcbdcce improve dvp driver by add one effective mode 2022-11-21 11:12:35 +08:00
wuzheng 06ed03337a add camera driver and examples for edu-riscv64 2022-11-18 20:20:34 +08:00
Liu_Weichao 72e09d82e7 Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into control_framework 2022-11-18 09:52:41 +08:00
xuedongliang 164614a75a add touch for edu-riscv64 board from Wang_weigen
it is OK
2022-11-16 15:23:34 +08:00
xuedongliang 75259c4006 1、support musl libc on nuttx and add test case on xidatong-arm32 2、register lcd device on xidatong-riscv64 on nuttx
it is OK
2022-11-16 15:23:05 +08:00
xuedongliang 992b8f62ab soft-SPI driver for edu-riscv64,which mainly for SDcard. edu-riscv64 examples including filesystem/RS485/gpio/loraE220/RTC from Wu_zheng
it is OK
2022-11-16 15:22:09 +08:00
xuedongliang afc27bce65 1、support SDIO driver and mount FAT-FS; 2、support SPI driver; 3、support SPI-LoRa driver; 4、fix heap memory error : start from _bss_end and conflict with stack segment
it is OK
2022-11-16 15:21:08 +08:00
Wang_Weigen 96baeb9482 add new files for armv7-a 2022-11-16 10:58:56 +08:00
TXuian 2a07e463f6 add w5500 support 2022-11-15 17:40:51 -08:00
TXuian 629e8893e3 add w5500 support. 2022-11-15 07:45:21 -08:00
wuzheng f22fbc3c94 example for edu-riscv64:watchdog,lcd and timer 2022-11-15 15:47:48 +08:00
Wang_Weigen 14f0e442ad fix compile error 2022-11-15 14:09:03 +08:00
Liu_Weichao 32c8701391 Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into control_framework 2022-11-14 16:09:47 +08:00
Liu_Weichao 452699ac02 feat add third_party_driver/usb for hc32f4a0 board, support Mount file-system 2022-11-14 16:05:26 +08:00
wgzAIIT 77bae67322 Merge pull request 'merge code' (#20) from develop into prepare_for_master 2022-11-14 15:22:39 +08:00
wgzAIIT 02cbcf2b23 fix touch problem 2022-11-14 15:20:03 +08:00
wgzAIIT 2bfd6c9aaa Merge pull request 'merge code' (#18) from develop into prepare_for_master 2022-11-14 09:56:41 +08:00
wgzAIIT 8bb59ddf3a Resolve kconfig warnning 2022-11-14 09:53:33 +08:00
wuzheng 8c929ba701 rs485 test example 2022-11-11 20:29:35 +08:00
wuzheng e7175c2745 add edu-riscv64 RTC test example 2022-11-11 17:39:03 +08:00
wuzheng e746639f8a add edu-riscv64 lora example and fix name problem 2022-11-11 15:32:38 +08:00
Wang_Weigen d89e018d33 add touch for edu-riscv64 board 2022-11-11 11:13:56 +08:00
wgzAIIT c7c7e700ca Merge pull request 'merge code' (#16) from develop into prepare_for_master 2022-11-10 14:45:25 +08:00
wgzAIIT 5d6aa56f29 support can and add test case for xidatong-riscv64 on nuttx 2022-11-10 14:37:54 +08:00
wuzheng 00b39cdd55 gpio test sample for edu-riscv64 2022-11-10 10:20:20 +08:00
wuzheng b8cf052d49 test framework 2022-11-09 20:45:44 +08:00
wuzheng d3836f1a6f softspi driver and its app test 2022-11-09 19:23:12 +08:00
wgzAIIT 33984d8872 Merge pull request 'merge code' (#15) from develop into prepare_for_master 2022-11-09 18:37:30 +08:00
wgzAIIT 2bc1de068c change ch376_demo.c 2022-11-09 18:07:48 +08:00
wgzAIIT 4f15f1e70b add usbnsh/defconfig and sdnsh/defconfig 2022-11-09 16:48:18 +08:00
wgzAIIT d6495c03d2 Merge pull request 'merge code' (#14) from develop into prepare_for_master 2022-11-09 08:55:59 +08:00
Liu_Weichao 696c9f6fe0 fix MountUsb function error 2022-11-08 17:02:39 +08:00
Liu_Weichao 9a818b1ef4 feat add third_party_driver/usb for hc32f4a0 board, compile OK 2022-11-08 14:15:23 +08:00
wgzAIIT b5e08c5d43 support musl libc on nuttx and add test case 2022-11-08 13:57:46 +08:00
Liu_Weichao 636f803b7b modify usb init position into board.c from init.c 2022-11-08 11:27:06 +08:00
wgzAIIT 51ebd8f604 register lcd device on xidatong-riscv64 on nuttx 2022-11-07 16:45:00 +08:00
Liu_Weichao 5f4922866e modify hc32f4a0 console usart as usart3 2022-11-03 09:31:34 +08:00
Liu_Weichao d0e42a9b51 feat add third_party_driver/spi/lora for hc32f4a0 board, send and receive function OK 2022-11-02 17:23:07 +08:00
Liu_Weichao 107913cb61 Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into hc32f4a0_driver 2022-11-02 17:22:06 +08:00
wgzAIIT 7361d1c65f Merge pull request 'merge code' (#10) from develop into prepare_for_master 2022-11-02 15:09:58 +08:00
wgzAIIT 9965ce4c43 register lcd device on riscv64 on nuttx 2022-11-02 14:43:58 +08:00
wgzAIIT a39bc41597 Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into prepare_for_master 2022-11-02 09:34:43 +08:00
wgzAIIT 3352d4be6b add hc32 dir 2022-11-02 09:33:03 +08:00
wgzAIIT 485555b3a2 Merge branch 'prepare_for_master' of https://gitlink.org.cn/wgzAIIT/xiuos into prepare_for_master 2022-11-02 09:18:23 +08:00
wgzAIIT 0bb057c642 register_driver lcd device on riscv64 on nuttx 2022-11-02 09:18:04 +08:00
Liu_Weichao 0504cf0e48 feat add third_party_driver/spi/lora for hc32f4a0 board, init function OK 2022-11-01 17:40:53 +08:00
Liu_Weichao 234f4fc2ed Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into hc32f4a0_driver 2022-11-01 17:39:40 +08:00
Liu_Weichao 2d7d5d121d feat add third_party_driver/spi for hc32f4a0 board, write and read function OK 2022-10-31 15:11:39 +08:00
Liu_Weichao 7a8766a74d Merge branch 'prepare_for_master' of https://gitlink.org.cn/xuos/xiuos into hc32f4a0_driver 2022-10-31 15:09:35 +08:00
Liu_Weichao e26c93a666 fix heap memory error : start from _bss_end and conflict with stack segment 2022-10-19 14:27:44 +08:00
Liu_Weichao 9802c89fd6 feat add third_party_driver/sdio for hc32f4a0 board 2022-10-18 17:27:30 +08:00
Liu_Weichao 700a07bc84 feat add third_party_driver/spi for hc32f4a0 board, compile OK 2022-10-18 15:03:44 +08:00
Liu_Weichao 37bdc4a33f fix spi CS init param error on aiit-riscv64\K210-emulator\kd233 board 2022-10-17 16:57:18 +08:00
Liu_Weichao c612502cdc Merge branch 'prepare_for_master' of https://git.trustie.net/xuos/xiuos into control_framework 2022-10-17 14:25:50 +08:00
Liu_Weichao 012fc146cc fix hifive1-emulator compile error : enable work_queen 2022-10-08 14:52:16 +08:00
974 changed files with 662337 additions and 8029 deletions

7
.gitmodules vendored
View File

@ -22,3 +22,10 @@
[submodule "Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/kendryte-sdk/kendryte-sdk-source"]
path = Ubiquitous/RT-Thread_Fusion_XiUOS/aiit_board/xidatong-riscv64/kendryte-sdk/kendryte-sdk-source
url = https://code.gitlink.org.cn/chunyexixiaoyu/kendryte-sdk-source.git
[submodule "APP_Framework/lib/lorawan/lora_radio_driver"]
path = APP_Framework/lib/lorawan/lora_radio_driver
url = https://gitlink.org.cn/IACU/lora_radio_driver.git
[submodule "APP_Framework/lib/lorawan/lorawan_devicenode"]
path = APP_Framework/lib/lorawan/lorawan_devicenode
url = https://gitlink.org.cn/IACU/lorawan_devicenode.git
branch = master

View File

@ -2,7 +2,6 @@
# APP_Framework/Applications/Make.defs
############################################################################
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/app_test
CONFIGURED_APPS += $(APPDIR)/../../../APP_Framework/Applications/general_functions/list
include $(wildcard $(APPDIR)/../../../APP_Framework/Applications/*/Make.defs)

View File

@ -2,7 +2,7 @@ include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += framework_init.c
CSRCS +=
include $(APPDIR)/Application.mk
endif
@ -10,9 +10,10 @@ endif
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
SRC_DIR := general_functions app_test
SRC_FILES := main.c framework_init.c
SRC_FILES := main.c
ifeq ($(CONFIG_LIB_LV),y)
SRC_DIR += lv_app
SRC_DIR += tinyttf_app
endif
ifeq ($(CONFIG_APPLICATION_OTA),y)

View File

@ -26,6 +26,179 @@ menu "test app"
endif
endif
menuconfig USER_TEST_FS
bool "Config test fs with sd or usb"
default n
if USER_TEST_FS
if ADD_XIZI_FETURES
config FPATH
string "Set test file path"
default "/test_file"
endif
endif
menuconfig USER_TEST_GPIO
select BSP_USING_GPIO
select RESOURCES_PIN
select BSP_USING_LED
select BSP_USING_KEY
bool "Config test gpio with led and key"
default n
if USER_TEST_GPIO
if ADD_XIZI_FETURES
config GPIO_DEV_DRIVER
string "Set gpio dev path"
default "/dev/pin_dev"
endif
endif
menuconfig USER_TEST_LORA
select BSP_USING_UART
select BSP_USING_GPIO
select RESOURCES_PIN
select BSP_USING_UART2
select BSP_USING_LORA
bool "Config test uart(loraE220)"
default n
if USER_TEST_LORA
if ADD_XIZI_FETURES
config LORA_UART_DEV_DRIVER
string "Set uart dev path"
default "/dev/uart2_dev2"
config LORA_PIN_DEV_DRIVER
string "Set pin dev path"
default "/dev/pin_dev"
endif
endif
menuconfig USER_TEST_RS485
select BSP_USING_UART
select BSP_USING_GPIO
select RESOURCES_PIN
select BSP_USING_UART1
bool "Config test uart(RS485)"
default n
if USER_TEST_RS485
if ADD_XIZI_FETURES
config RS485_UART_DEV_DRIVER
string "Set uart dev path"
default "/dev/uart1_dev1"
config RS485_PIN_DEV_DRIVER
string "Set pin dev path"
default "/dev/pin_dev"
endif
endif
menuconfig USER_TEST_RTC
select BSP_USING_RTC
bool "Config test rtc"
default n
if USER_TEST_RTC
if ADD_XIZI_FETURES
config RTC_DEV_DRIVER
string "Set rtc dev path"
default "/dev/rtc_dev"
endif
endif
menuconfig USER_TEST_HWTIMER
select BSP_USING_HWTIMER
select BSP_USING_GPIO
select RESOURCES_PIN
select BSP_USING_LED
bool "Config test hwtimer"
default n
if USER_TEST_HWTIMER
if ADD_XIZI_FETURES
config HWTIMER_TIMER_DEV_DRIVER
string "Set pin dev path"
default "/dev/timer0_dev0"
config HWTIMER_PIN_DEV_DRIVER
string "Set pin dev path"
default "/dev/pin_dev"
endif
endif
menuconfig USER_TEST_WDT
select BSP_USING_WDT0
bool "Config test watchdog"
default n
if USER_TEST_WDT
if ADD_XIZI_FETURES
config WDT0_DEV_DRIVER
string "Set wdt dev path"
default "/dev/wdt0_dev0"
endif
endif
menuconfig USER_TEST_LCD_EDU
select BSP_USING_LCD
bool "Config test lcd in PrivOpen"
default n
if USER_TEST_LCD_EDU
if ADD_XIZI_FETURES
config EDU_LCD_DEV_DRIVER
string "Set lcd dev path"
default "/dev/lcd_dev"
endif
endif
menuconfig USER_TEST_TOUCH
select BSP_USING_TOUCH
bool "Config test touch"
default n
if USER_TEST_TOUCH
if ADD_XIZI_FETURES
config TOUCH_DEV_DRIVER
string "Set touch dev path"
default "/dev/touch_dev"
config TOUCH_LCD_DEV_DRIVER
string "Set lcd dev path"
default "/dev/lcd_dev"
endif
endif
menuconfig USER_TEST_I2C
select BSP_USING_I2C
bool "Config test i2c"
default n
if USER_TEST_I2C
if ADD_XIZI_FETURES
config I2C_DEV_DRIVER
string "Set i2c dev path"
default "/dev/i2c1_dev0"
endif
endif
menuconfig USER_TEST_CAN
select BSP_USING_CAN
bool "Config test can"
default n
if USER_TEST_CAN
if ADD_XIZI_FETURES
config CAN_DEV_DRIVER
string "Set can dev path"
default "/dev/can2_dev1"
endif
endif
menuconfig USER_TEST_CAMERA
select BSP_USING_CAMERA
select BSP_USING_LCD
bool "Config test camera with lcd"
default n
if USER_TEST_CAMERA
if ADD_XIZI_FETURES
config CAMERA_DEV_DRIVER
string "Set camera dev path"
default "/dev/camera_dev"
config CAMERA_LCD_DEV_DRIVER
string "Set lcd dev path"
default "/dev/lcd_dev"
endif
endif
config USER_TEST_SEMC
bool "Config test semc sdram"
default n
@ -33,5 +206,39 @@ menu "test app"
config USER_TEST_LCD
bool "Config test lcd device"
default n
menuconfig USER_TEST_ETHERNET
bool "Config test ethernet only for edu-riscv64"
default n
if USER_TEST_ETHERNET
if ADD_XIZI_FETURES
choice
prompt "set ethernet role as client or server"
default ETHERNET_AS_SERVER
config ETHERNET_AS_SERVER
bool "test as server"
config ETHERNET_AS_CLIENT
bool "test as client"
endchoice
endif
endif
menuconfig USER_TEST_FLASH
bool "Config test w25q128 device"
default n
if USER_TEST_FLASH
if ADD_XIZI_FETURES
config FLASH_DEV_DRIVER
string "Set flash dev path"
default "/dev/qspi_W25Q128"
endif
endif
menuconfig USER_TEST_TIMER
bool "Config test soft timer"
default n
endif
endmenu

View File

@ -10,6 +10,14 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
CSRCS += test_lcd.c
endif
ifeq ($(CONFIG_BSP_USING_TOUCH),y)
CSRCS += test_touch.c
endif
ifeq ($(CONFIG_MUSL_LIBC),y)
CSRCS += test_musl.c
endif
include $(APPDIR)/Application.mk
endif
@ -25,6 +33,10 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
SRC_FILES += test_dac.c
endif
ifeq ($(CONFIG_USER_TEST_FS),y)
SRC_FILES += test_fs.c
endif
ifeq ($(CONFIG_USER_TEST_SEMC),y)
SRC_FILES += test_extsram.c
endif
@ -33,5 +45,61 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
SRC_FILES +=
endif
ifeq ($(CONFIG_USER_TEST_I2C),y)
SRC_FILES += test_i2c.c
endif
ifeq ($(CONFIG_USER_TEST_GPIO),y)
SRC_FILES += test_gpio.c
endif
ifeq ($(CONFIG_USER_TEST_LORA),y)
SRC_FILES += test_loraE220.c
endif
ifeq ($(CONFIG_USER_TEST_RTC),y)
SRC_FILES += test_rtc.c
endif
ifeq ($(CONFIG_USER_TEST_RS485),y)
SRC_FILES += test_rs485.c
endif
ifeq ($(CONFIG_USER_TEST_HWTIMER),y)
SRC_FILES += test_hwtimer.c
endif
ifeq ($(CONFIG_USER_TEST_LCD_EDU),y)
SRC_FILES += test_lcd_edu.c
endif
ifeq ($(CONFIG_USER_TEST_WDT),y)
SRC_FILES += test_wdt.c
endif
ifeq ($(CONFIG_USER_TEST_TOUCH),y)
SRC_FILES += test_touch.c
endif
ifeq ($(CONFIG_USER_TEST_CAMERA),y)
SRC_FILES += test_camera.c
endif
ifeq ($(CONFIG_USER_TEST_ETHERNET),y)
SRC_FILES += test_ethernet.c
endif
ifeq ($(CONFIG_USER_TEST_FLASH),y)
SRC_FILES += test_flash.c
endif
ifeq ($(CONFIG_USER_TEST_CAN),y)
SRC_FILES += test_can.c
endif
ifeq ($(CONFIG_USER_TEST_TIMER),y)
SRC_FILES += test_timer.c
endif
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
void TestAdc(void)
{
@ -57,3 +58,4 @@ void TestAdc(void)
return;
}
PRIV_SHELL_CMD_FUNCTION(TestAdc, a adc test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,120 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_camera.c
* @brief: a application of camera function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/7
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
static uint16_t image_buff[384000];
void TestCamera(int argc, char *argv[])
{
int frame_counter = 10000;
if (argc > 1)
{
frame_counter = atoi(argv[1]);
}
printf("This test will refresh %d frames\n", frame_counter);
int camera_fd = PrivOpen(CAMERA_DEV_DRIVER, O_RDWR);
if (camera_fd < 0)
{
printf("open camera fd error:%d\n", camera_fd);
return;
}
int lcd_fd = PrivOpen(CAMERA_LCD_DEV_DRIVER, O_RDWR);
if (lcd_fd < 0)
{
printf("open lcd fd error:%d\n", lcd_fd);
return;
}
//configure the camera's output address
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = CAMERA_TYPE;
struct CameraCfg camera_cfg ={
.gain_manu_enable = 0,
.gain = 0xFF,
.window_w = 800,
.window_h = 600,
.output_w = IMAGE_WIDTH,
.output_h = IMAGE_HEIGHT,
.window_xoffset = 0,
.window_yoffset = 0
};
ioctl_cfg.args = &camera_cfg;
if (0 != PrivIoctl(camera_fd, OPE_CFG, &ioctl_cfg))
{
printf("camera pin fd error %d\n", camera_fd);
PrivClose(camera_fd);
return;
}
ioctl_cfg.args = (void *)image_buff;
if (0 != PrivRead(camera_fd, image_buff, NULL_PARAMETER))
{
printf("camera pin fd error %d\n", camera_fd);
PrivClose(camera_fd);
return;
}
printf("address buff is %x\n", image_buff);
LcdWriteParam graph_param;
graph_param.type = LCD_DOT_TYPE;
//clear the LCD
uint16_t back_color[LCD_SIZE];
memset(back_color,0,sizeof(back_color));
for (int i = 0; i < LCD_SIZE; i++)
{
graph_param.pixel_info.pixel_color = &back_color;
graph_param.pixel_info.x_startpos = 0;
graph_param.pixel_info.y_startpos = i;
graph_param.pixel_info.x_endpos = LCD_SIZE -1;
graph_param.pixel_info.y_endpos = i;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
}
//refresh the LCD using photo of camera
while (frame_counter--)
{
for (int i = 0; i < IMAGE_HEIGHT; i++)
{
graph_param.pixel_info.pixel_color = image_buff + i * IMAGE_WIDTH;
graph_param.pixel_info.x_startpos = 0;
graph_param.pixel_info.y_startpos = i + (LCD_SIZE - IMAGE_HEIGHT) / 2;
graph_param.pixel_info.x_endpos = IMAGE_WIDTH - 1;
graph_param.pixel_info.y_endpos = i + (LCD_SIZE - IMAGE_HEIGHT) / 2;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
}
}
// close test
PrivClose(lcd_fd);
PrivClose(camera_fd);
printf("The camera test is finished successfully\n");
}
PRIV_SHELL_CMD_FUNCTION(TestCamera, a camera test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,87 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_can.c
* @brief: a application of can function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2023/2/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
void TestCAN(void)
{
// config CAN pin(SCL:34.SDA:35) in menuconfig
int can_fd = PrivOpen(CAN_DEV_DRIVER, O_RDWR);
if (can_fd < 0)
{
printf("open can_fd fd error:%d\n", can_fd);
return;
}
printf("CAN open successful!\n");
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = CAN_TYPE;
struct CanDriverConfigure can_config;
can_config.brp = 8U;
can_config.tbs1 = 1U + 8U;
can_config.tbs2 = 4U;
can_config.tsjw = 4U;
can_config.mode = 0U;
ioctl_cfg.args = (void *)&can_config;
if (0 != PrivIoctl(can_fd, OPE_INT, &ioctl_cfg))
{
printf("init can fd error %d\n", can_fd);
PrivClose(can_fd);
return;
}
printf("CAN configure successful!\n");
uint8_t data_buff[64u] = {1,2,3,4,4,3,2,1};
struct CanSendConfigure frame_send;
frame_send.ide=0;
frame_send.stdid = 0x55;
frame_send.rtr=0;
frame_send.data_lenth=8;
frame_send.data = data_buff;
struct CanSendConfigure frame_recv;
uint8_t recv_buff[65U] = {0};
frame_recv.data = recv_buff;
// CAN write
while (1)
{
PrivTaskDelay(500);
PrivWrite(can_fd, &frame_send, NONE);
PrivTaskDelay(500);
PrivRead(can_fd, &frame_recv, NONE);
// if any data has received,Then printf message
if(frame_recv.data_lenth > 0){
printf("ID %08x:%s\n",frame_recv.exdid,frame_recv.data);
}
}
PrivClose(can_fd);
return;
}
PRIV_SHELL_CMD_FUNCTION(TestCAN, a can test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -17,10 +17,10 @@
* @author: AIIT XUOS Lab
* @date: 2022/1/11
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
void TestDac(void)
{
@ -57,3 +57,4 @@ void TestDac(void)
return;
}
PRIV_SHELL_CMD_FUNCTION(TestDac, a dac test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,194 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_ethernet.c
* @brief: a application of ethernet function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#include <socket.h>
#define BUFF_SIZE 128
#define RECV_SIZE 16
#define TCP_PORT 12345
const static uint32_t sn = 0;
#ifdef ETHERNET_AS_SERVER
static int32_t wiz_server_op(uint8_t sn, uint8_t *buf, uint32_t buf_size,
uint16_t port, enum TCP_OPTION opt) {
int32_t ret = 0;
uint16_t size = 0, sentsize = 0;
switch (getSn_SR(sn)) {
case SOCK_ESTABLISHED:
if (getSn_IR(sn) & Sn_IR_CON) {
printf("%d:Connected\r\n", sn);
setSn_IR(sn, Sn_IR_CON);
}
if (opt == SEND_DATA) {
uint32_t sent_size = 0;
memset(buf,0,buf_size);
strcpy(buf,"The message has been recved");
ret = wiz_sock_send(sn, buf, buf_size);
if (ret < 0) {
wiz_sock_close(sn);
return ret;
}
} else if (opt == RECV_DATA) {
uint32_t size = 0;
if ((size = getSn_RX_RSR(sn)) > 0) {
if (size > buf_size) size = buf_size;
memset(buf,0,buf_size);
ret = wiz_sock_recv(sn, buf, size);
printf("Recv message: %s\n",buf);
return ret;
}
}
break;
case SOCK_CLOSE_WAIT:
printf("%d:CloseWait\r\n", sn);
if ((ret = wiz_sock_disconnect(sn)) != SOCK_OK) return ret;
printf("%d:Closed\r\n", sn);
break;
case SOCK_INIT:
printf("%d:Listen, port [%d]\r\n", sn, port);
if ((ret = wiz_sock_listen(sn)) != SOCK_OK) return ret;
break;
case SOCK_CLOSED:
printf("%d:LBTStart\r\n", sn);
if ((ret = wiz_socket(sn, Sn_MR_TCP, port, 0x00)) != sn) return ret;
printf("%d:Opened\r\n", sn);
break;
default:
break;
}
return 0;
}
void TestSocketAsServer(int argc, char *argv[])
{
x_err_t ret;
uint8_t buf[BUFF_SIZE] = {0};
while (1) {
ret = wiz_server_op(0, buf, BUFF_SIZE, TCP_PORT, RECV_DATA);
if (ret > 0) {
wiz_server_op(0, buf, BUFF_SIZE, TCP_PORT, SEND_DATA);
};
}
return ;
}
PRIV_SHELL_CMD_FUNCTION(TestSocketAsServer, a w5500 server test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#elif defined ETHERNET_AS_CLIENT
static uint32_t wiz_client_op(uint8_t sn, uint8_t *buf, uint32_t buf_size,
uint8_t dst_ip[4], uint16_t dst_port,
enum TCP_OPTION opt) {
// assert(buf_size <= g_wiznet_buf_size);
int32_t ret;
switch (getSn_SR(sn)) {
case SOCK_CLOSE_WAIT:
wiz_sock_disconnect(sn);
break;
case SOCK_CLOSED:
wiz_socket(sn, Sn_MR_TCP, 5000, 0x00);
break;
case SOCK_INIT:
KPrintf("[SOCKET CLIENT] sock init.\n");
wiz_sock_connect(sn, dst_ip, dst_port);
break;
case SOCK_ESTABLISHED:
if (getSn_IR(sn) & Sn_IR_CON) {
printf("[SOCKET CLIENT] %d:Connected\r\n", sn);
setSn_IR(sn, Sn_IR_CON);
}
if (opt == SEND_DATA) {
uint32_t sent_size = 0;
ret = wiz_sock_send(sn, buf, buf_size);
if (ret < 0) {
wiz_sock_close(sn);
return ret;
}
} else if (opt == RECV_DATA) {
uint32_t size = 0;
if ((size = getSn_RX_RSR(sn)) > 0) {
if (size > buf_size) size = buf_size;
ret = wiz_sock_recv(sn, buf, size);
if (ret <= 0) return ret;
}
}
break;
default:
break;
}
}
void TestSocketAsClient(int argc, char *argv[])
{
x_err_t ret;
uint8_t buf[BUFF_SIZE] = {0};
uint32_t tmp_ip[4];
uint32_t port;
const uint8_t client_sock = 2;
if(argc<3){
printf("Please enter command like TestSocketAsClient ip:port msg\n");
}
sscanf(argv[1],"%d.%d.%d.%d:%d",tmp_ip,tmp_ip+1,tmp_ip+2,tmp_ip+3,&port);
printf("Client to %d.%d.%d.%d:%d\n",tmp_ip[0],tmp_ip[1],tmp_ip[2],tmp_ip[3],port);
uint8_t destination_ip[4]={0};
for(int i=0;i<4;i++){
destination_ip[i]=tmp_ip[i];
}
while(1){
ret = wiz_client_op(client_sock, argv[2], strlen(argv[2]), destination_ip, port,SEND_DATA);
printf("sizeof:%d\n",strlen(argv[2]));
PrivTaskDelay(1000);
if (ret > 0) {
ret=wiz_client_op(client_sock, buf, BUFF_SIZE, destination_ip, port, RECV_DATA);
printf("read ret is %d\n",ret);
if(ret>0){
printf("client recv msg successfully!\n");
printf("%s\n",buf);
}
};
PrivTaskDelay(1000);
}
return ;
}
PRIV_SHELL_CMD_FUNCTION(TestSocketAsClient, a w5500 client-ip-port-msg test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif
#endif

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_flash.c
* @brief: a application of flash function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
void TestFlash(void)
{
int fd = open(FLASH_DEV_DRIVER,O_RDWR);
if(fd<0){
printf("fs fd open error:%d\n",fd);
return;
}
struct BusBlockWriteParam flash_writer;
uint8_t read_buff[8] = {1,2,3,4,5,6,7,8};
flash_writer.pos = 0x000000L;
flash_writer.size = 8;
flash_writer.buffer = read_buff;
struct BusBlockReadParam flash_reader;
flash_reader.pos = 0x000000L;
flash_reader.size = 8;
flash_reader.buffer = read_buff;
PrivRead(fd,&flash_reader,NONE);
printf("Read data is:");
for(int i=0;i<flash_writer.size;i++){
printf("%02x ",read_buff[i]);
read_buff[i]++;
}
printf("\n");
PrivWrite(fd,&flash_writer,NONE);
return;
}
PRIV_SHELL_CMD_FUNCTION(TestFlash, a flash test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,83 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_fs.c
* @brief: a application of file_system function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/11/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#define MAX_READ_LENGTH 1000
// sd card here is loaded as "/"
void TestFs(void)
{
//open the file in sdcard
int fd = open(FPATH,O_RDWR|O_CREAT);
if(fd<0){
printf("fs fd open error:%d\n",fd);
return;
}
char filewords[MAX_READ_LENGTH];
memset(filewords,0,MAX_READ_LENGTH);
const char *input_words = "these words are going to write in fs\n";
//read and write then close file
int err_flag = read(fd,filewords,MAX_READ_LENGTH);
if(err_flag<0){
printf("read failed,error:%d\n",err_flag);
return;
}
printf("read data is \n%s\n",filewords);
err_flag = write(fd,input_words,strlen(input_words));
if(err_flag<0){
printf("write failed,error:%d\n",err_flag);
return;
}
err_flag = close(fd);
if(err_flag<0){
printf("close failed,error %d\n",err_flag);
return ;
}
//re-open the file and re-read the file
fd = open(FPATH,O_RDWR);
if(fd<0){
printf("fs fd open error:%d\n",fd);
return;
}
err_flag = read(fd,filewords,MAX_READ_LENGTH);
if(err_flag<0){
printf("read failed,error:%d\n",err_flag);
return;
}
printf("read data is \n%s\n",filewords);
err_flag = close(fd);
if(err_flag<0){
printf("close failed,error:%d\n",err_flag);
return;
}
return;
}
PRIV_SHELL_CMD_FUNCTION(TestFs, a sd or usb filesystem test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,98 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_gpio.c
* @brief: a application of GPIO function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#ifdef BOARD_EDU_RISCV64_EVB
#define BSP_LED_PIN 29
#define BSP_KEY_PIN 31
#elif defined BOARD_HC32F4A0_EVB
#define BSP_LED_PIN 134
#define BSP_KEY_PIN 176
#endif
#define NULL_PARAMETER 0
void TestGpio(void)
{
int pin_fd = PrivOpen(GPIO_DEV_DRIVER, O_RDWR);
if(pin_fd < 0) {
printf("open pin fd error:%d\n",pin_fd);
return;
}
//config led pin in board
struct PinParam parameter;
parameter.cmd = GPIO_CONFIG_MODE;
parameter.pin = BSP_LED_PIN;
parameter.mode = GPIO_CFG_OUTPUT;
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
ioctl_cfg.args = (void *)&parameter;
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
printf("ioctl pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
//config key pin in board
parameter.pin = BSP_KEY_PIN;
parameter.mode = GPIO_CFG_INPUT;
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
printf("ioctl pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
struct PinStat pin_led;
struct PinStat pin_key;
pin_led.pin = BSP_LED_PIN;
pin_key.pin = BSP_KEY_PIN;
//recycle read pin and write pin until key break
while(1){
if(0 > PrivRead(pin_fd, &pin_key, NULL_PARAMETER)) {
printf("read pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
//led on if key pressed,or led off
if(pin_key.val){
pin_led.val = GPIO_HIGH;
}else{
pin_led.val = GPIO_LOW;
}
if(0 > PrivWrite(pin_fd, &pin_led, NULL_PARAMETER)) {
printf("write pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
}
}
PRIV_SHELL_CMD_FUNCTION(TestGpio, a gpio test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,97 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_hwtimer.c
* @brief: a application of hwtimer function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#define BSP_LED_PIN 134
#define NULL_PARAMETER 0
static uint16_t pin_fd=0;
static struct PinStat pin_led;
void ledflip(void *parameter)
{
pin_led.pin = BSP_LED_PIN;
pin_led.val = !pin_led.val;
PrivWrite(pin_fd,&pin_led,NULL_PARAMETER);
}
void TestHwTimer(void)
{
x_ticks_t period = 100000;
pin_fd = PrivOpen(HWTIMER_PIN_DEV_DRIVER, O_RDWR);
if(pin_fd<0){
printf("open pin fd error:%d\n",pin_fd);
return;
}
int timer_fd = PrivOpen(HWTIMER_TIMER_DEV_DRIVER, O_RDWR);
if(timer_fd<0){
printf("open timer fd error:%d\n",timer_fd);
return;
}
//config led pin in board
struct PinParam parameter;
parameter.cmd = GPIO_CONFIG_MODE;
parameter.pin = BSP_LED_PIN;
parameter.mode = GPIO_CFG_OUTPUT;
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
ioctl_cfg.args = (void *)&parameter;
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
printf("ioctl pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
ioctl_cfg.ioctl_driver_type = TIME_TYPE;
ioctl_cfg.args = (void *)&ledflip;
if (0 != PrivIoctl(timer_fd, OPE_INT, &ioctl_cfg)) {
printf("timer pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
ioctl_cfg.args = (void *)&period;
if (0 != PrivIoctl(timer_fd, OPE_CFG, &ioctl_cfg)) {
printf("timer pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
while(1){
}
// int32 timer_handle = KCreateTimer("LED on and off by 1s",&ledflip,&pin_fd,period,TIMER_TRIGGER_PERIODIC);
// KTimerStartRun(timer_handle);
PrivClose(pin_fd);
PrivClose(timer_fd);
}
PRIV_SHELL_CMD_FUNCTION(TestHwTimer, a timer test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_i2c.c
* @brief: a application of i2c function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#define I2C_SLAVE_ADDRESS 0x0012U
void TestI2C(void)
{
// config IIC pin(SCL:34.SDA:35) in menuconfig
int iic_fd = PrivOpen(I2C_DEV_DRIVER, O_RDWR);
if (iic_fd < 0)
{
printf("open iic_fd fd error:%d\n", iic_fd);
return;
}
printf("IIC open successful!\n");
// init iic
uint16 iic_address = I2C_SLAVE_ADDRESS;
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = I2C_TYPE;
ioctl_cfg.args = (void *)&iic_address;
if (0 != PrivIoctl(iic_fd, OPE_INT, &ioctl_cfg))
{
printf("ioctl iic fd error %d\n", iic_fd);
PrivClose(iic_fd);
return;
}
printf("IIC configure successful!\n");
// I2C read and write
char tmp_buff[100];
while (1)
{
PrivTaskDelay(1000);
PrivWrite(iic_fd, "Hello World!\n", sizeof("Hello World!\n"));
printf("msg send:%s\n", "Hello World!\n");
PrivTaskDelay(1000);
memset(tmp_buff, 0, sizeof(tmp_buff));
PrivRead(iic_fd, tmp_buff, sizeof(tmp_buff));
printf("msg recv:%s\n", tmp_buff);
}
PrivClose(iic_fd);
return;
}
PRIV_SHELL_CMD_FUNCTION(TestI2C, a iic test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -1,26 +1,22 @@
/****************************************************************************
* apps/examples/fb/fb_main.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/****************************************************************************
* Included Files
****************************************************************************/
/**
* @file: test_lcd.c
* @brief: a application of dac function
* @version: 2.0
* @author: AIIT XUOS Lab
* @date: 2022/1/11
*/
#include <transform.h>
@ -29,40 +25,39 @@
#ifdef CONFIG_K210_LCD
void LcdDemo(void)
{
int x1 = 50, y1 = 50, x2 = LCD_XSIZE_TFT - 50, y2 = LCD_YSIZE_TFT - 50;
int lcd_fd = PrivOpen("/dev/lcd_dev",O_RDWR);
LcdWriteParam disp_info;
Main_Image_Start_Address(LCD_START_ADDR);
Main_Image_Width(LCD_XSIZE_TFT);
Main_Window_Start_XY(0, 0);
Canvas_Image_Start_address(LCD_START_ADDR);
Canvas_image_width(LCD_XSIZE_TFT);
Active_Window_XY(0, 0);
Active_Window_WH(LCD_XSIZE_TFT, LCD_YSIZE_TFT);
up_mdelay(10);
Canvas_Image_Start_address(LCD_START_ADDR);
disp_info.type = 0;
disp_info.string_info.x_pos = 80;
disp_info.string_info.y_pos = 80;
disp_info.string_info.width = 250;
disp_info.string_info.height = 24;
disp_info.string_info.font_size = 24;
disp_info.string_info.addr = "wecome test lcd";
disp_info.string_info.font_color = GREEN;
disp_info.string_info.back_color = BLUE;
PrivWrite(lcd_fd, &disp_info, sizeof(LcdWriteParam));
PrivTaskDelay(2000);
for(int i = 0; i < 3; i++)
{
x1 = 50;
y1 = 50;
x2 = LCD_XSIZE_TFT - 50;
y2 = LCD_YSIZE_TFT - 50;
syslog(LOG_NOTICE, "Disp_demo %d (%d,%d - %d,%d)\n", i, x1, y1, x2, y2);
LT768_DrawSquare_Fill(x1, y1, x2, y2, Red);
up_mdelay(2000);
x1 += 20;
y1 += 20;
x2 -= 20;
y2 -= 20;
LT768_DrawSquare_Fill(x1, y1, x2, y2, Green);
up_mdelay(2000);
x1 += 20;
y1 += 20;
x2 -= 20;
y2 -= 20;
LT768_DrawSquare_Fill(x1, y1, x2, y2, Blue);
up_mdelay(2000);
}
disp_info.type = 1;
lv_color_t redcolor = {
.ch = {
.red = 0b11111,
.green = 0,
.blue = 0
}
};
disp_info.pixel_info.x_startpos = 0;
disp_info.pixel_info.x_endpos = 50;
disp_info.pixel_info.y_startpos = 0;
disp_info.pixel_info.y_endpos = 50;
disp_info.pixel_info.pixel_color = &redcolor;
PrivWrite(lcd_fd, &disp_info, sizeof(LcdWriteParam));
PrivTaskDelay(2000);
disp_info.type = SHOW_TRIANGLE;
PrivWrite(lcd_fd, &disp_info, sizeof(LcdWriteParam));
}
#else

View File

@ -0,0 +1,89 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_lcd.c
* @brief: a application of lcd function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#define GRAPHIC_CTRL_RECT_UPDATE 0x00
#define LCD_STRING_TYPE 0
#define LCD_DOT_TYPE 1
#define LCD_FONT_RECT_WIDTH 150
#define LCD_FONT_RECT_HEIGHT 50
#define NULL_PARAMETER 0
void TestLcd(void)
{
int lcd_fd = PrivOpen(EDU_LCD_DEV_DRIVER, O_RDWR);
if (lcd_fd < 0)
{
printf("open lcd fd error:%d\n", lcd_fd);
return;
}
LcdWriteParam graph_param;
// black
uint16* color_select = malloc(sizeof(uint16) * 321 * 321);
memset(color_select, 0x00, sizeof(uint16) * 321 * 321);
graph_param.type = LCD_DOT_TYPE;
graph_param.pixel_info.x_startpos = 0;
graph_param.pixel_info.y_startpos = 0;
graph_param.pixel_info.x_endpos = 320;
graph_param.pixel_info.y_endpos = 320;
graph_param.pixel_info.pixel_color = color_select;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
free(color_select);
// draw text
graph_param.type = LCD_STRING_TYPE;
graph_param.string_info.x_pos = 0;
graph_param.string_info.y_pos = 0;
graph_param.string_info.width = 250;
graph_param.string_info.height = 24;
graph_param.string_info.font_size = 24;
graph_param.string_info.back_color = 0xFFFF;
graph_param.string_info.font_color = 0x0000;
graph_param.string_info.addr = "hello_world!";
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
// draw line
color_select = malloc(sizeof(uint16) * 1 * 320);
for (int i = 0; i < 320; i++)
{
color_select[i] = 0xF800;
}
for (int i = 1; i <= 5; i++)
{
graph_param.type = LCD_DOT_TYPE;
graph_param.pixel_info.x_startpos = 0;
graph_param.pixel_info.y_startpos = i * 50;
graph_param.pixel_info.x_endpos = 319;
graph_param.pixel_info.y_endpos = i * 50;
graph_param.pixel_info.pixel_color = color_select;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
}
free(color_select);
PrivClose(lcd_fd);
}
PRIV_SHELL_CMD_FUNCTION(TestLcd, a lcd test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,168 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_loraE220.c
* @brief: a application of loraE220 function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#define NULL_PARAMETER 0
#define E220_CFG_LENGTH
#define GPIOSET(fd, buf, bit) \
{ \
buf.val = bit; \
if (0 > PrivWrite(fd, &buf, NULL_PARAMETER)) \
{ \
printf("write pin fd error %d\n", fd); \
PrivClose(fd); \
return; \
} \
}
#define BSP_E220_M0_PIN 32
#define BSP_E220_M1_PIN 33
void TestLora(int argc, char *argv[])
{
char uart_recvbuff[100];
memset(uart_recvbuff, 0, sizeof(uart_recvbuff));
int pin_fd = PrivOpen(LORA_PIN_DEV_DRIVER, O_RDWR);
if (pin_fd < 0)
{
printf("open pin fd error:%d\n", pin_fd);
return;
}
int uart_fd = PrivOpen(LORA_UART_DEV_DRIVER, O_RDWR);
if (uart_fd < 0)
{
printf("open pin fd error:%d\n", uart_fd);
return;
}
printf("uart and pin fopen success\n");
struct PinStat pin_m0;
struct PinStat pin_m1;
pin_m0.pin = BSP_E220_M0_PIN;
pin_m1.pin = BSP_E220_M1_PIN;
// config led pin in board
struct PrivIoctlCfg ioctl_cfg;
struct PinParam pin_param;
pin_param.cmd = GPIO_CONFIG_MODE;
pin_param.mode = GPIO_CFG_OUTPUT;
pin_param.pin = BSP_E220_M0_PIN;
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
ioctl_cfg.args = &pin_param;
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg))
{
printf("ioctl pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
pin_param.pin = BSP_E220_M1_PIN;
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg))
{
printf("ioctl pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
printf("pin configure success\n");
struct SerialDataCfg uart_cfg;
// loraE220 support only 9600bps with 8N1 during initializing
uart_cfg.serial_baud_rate = BAUD_RATE_9600;
uart_cfg.serial_data_bits = DATA_BITS_8;
uart_cfg.serial_stop_bits = STOP_BITS_1;
uart_cfg.serial_parity_mode = PARITY_NONE;
uart_cfg.serial_bit_order = BIT_ORDER_LSB;
uart_cfg.serial_invert_mode = NRZ_NORMAL;
uart_cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
uart_cfg.serial_timeout = 1000;
uart_cfg.is_ext_uart = 0;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = (void *)&uart_cfg;
if (0 != PrivIoctl(uart_fd, OPE_INT, &ioctl_cfg))
{
printf("ioctl uart fd error %d\n", uart_fd);
PrivClose(uart_fd);
return;
}
printf("uart configure success\n");
GPIOSET(pin_fd, pin_m0, GPIO_HIGH);
GPIOSET(pin_fd, pin_m1, GPIO_HIGH);
printf("lora configure into sleep(configure) mode\n");
// send configure data, and receive the same length of data
// configure loraE220 as address 1949 CH17 36.8kps
char sendbuff[] = {0xC0, 0x00, 0x05, 0x19, 0x49, 0xE6, 0x00, 0x17};
PrivTaskDelay(2000);
printf("Sending lora configure information(SIZE:%d)\n", sizeof(sendbuff));
PrivWrite(uart_fd, sendbuff, sizeof(sendbuff));
printf("lora configure information send\n");
PrivTaskDelay(2000);
PrivRead(uart_fd, uart_recvbuff, sizeof(sendbuff));
printf("%x %x %x %x", uart_recvbuff[0], uart_recvbuff[1], uart_recvbuff[2], uart_recvbuff[3]);
printf("lora configure success\n");
// error when all bytes are 0xff
if (0xFF == (uart_recvbuff[0] & uart_recvbuff[1] & uart_recvbuff[2]))
{
printf("from lora receive error:%d\n", 0xff);
return;
}
uart_cfg.serial_baud_rate = BAUD_RATE_115200;
if (0 != PrivIoctl(uart_fd, OPE_INT, &ioctl_cfg))
{
printf("ioctl uart fd error %d\n", uart_fd);
PrivClose(uart_fd);
return;
}
// into transparent transmission mode
GPIOSET(pin_fd, pin_m0, GPIO_LOW);
GPIOSET(pin_fd, pin_m1, GPIO_LOW);
// receive and send "Hello World"
while (1)
{
PrivTaskDelay(500);
PrivWrite(uart_fd, "Hello_World!", sizeof("Hello_World!"));
printf("Data Send:\n%s\n", "Hello_World!");
PrivTaskDelay(500);
memset(uart_recvbuff, 0, sizeof(uart_recvbuff));
PrivRead(uart_fd, uart_recvbuff, sizeof(uart_recvbuff));
printf("Receive Data is :\n%s\n", uart_recvbuff);
}
PrivClose(pin_fd);
PrivClose(uart_fd);
}
PRIV_SHELL_CMD_FUNCTION(TestLora, a lora test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,103 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_musl.c
* @brief: a application of musl test function
* @version: 2.0
* @author: AIIT XUOS Lab
* @date: 2022/11/8
*/
#include <transform.h>
#ifdef ADD_NUTTX_FETURES
#if defined(CONFIG_MUSL_LIBC) && defined(CONFIG_FS_AUTOMOUNTER)
static void file_read_and_write(void)
{
FILE *p;
char s[] = "good luck to you!";
char buffer[20];
if((p = fopen("/mnt/sdcard/test.txt","w+")) == NULL)
{
printf("Can not open file!\n");
}
fwrite(s, sizeof(s) + 1, 1, p);
fseek(p, SEEK_SET, 0);
fread(buffer, sizeof(buffer) + 1, 1, p);
printf("read string is: %s\n", buffer);
fclose(p);
}
static void file_operations(void)
{
int ret;
FILE *fp;
char filename1[] = "/mnt/sdcard/file1.txt";
char filename2[] = "/mnt/sdcard/file2.txt";
fp = fopen(filename1, "w");
fprintf(fp, "%s", "this is runoob.com");
fclose(fp);
ret = remove(filename1);
if(ret == 0)
{
printf("remove file1 success!\n");
}
else
{
printf("error,can not remove file1!\n");
}
ret = remove(filename2);
if(ret == 0)
{
printf("remove file2 success!\n");
}
else
{
printf("error,can not remove file2!\n");
}
}
static void malloc_and_free(void)
{
int *p;
int len;
for(int i = 0; i < 100; i++)
{
len = 1024*(i+1);
p = malloc(len);
if(p)
{
printf("malloc %d bytes success!\n",len);
free(p);
}
}
}
void Testmusl(void)
{
printf("--------start test file read and write!--------\n");
file_read_and_write();
printf("----------start test file operationsn!---------\n");
file_operations();
printf("---------start test malloc and free!-----------\n");
malloc_and_free();
}
#endif
#endif

View File

@ -0,0 +1,107 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_rs485.c
* @brief: a application of rs485 function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#define BSP_485_DIR_PIN 24
void Test485(void)
{
int pin_fd = PrivOpen(RS485_PIN_DEV_DRIVER, O_RDWR);
if (pin_fd < 0)
{
printf("open pin fd error:%d\n", pin_fd);
return;
}
int uart_fd = PrivOpen(RS485_UART_DEV_DRIVER, O_RDWR);
if (uart_fd < 0)
{
printf("open pin fd error:%d\n", uart_fd);
return;
}
printf("uart and pin fopen success\n");
//config led pin in board
struct PinParam pin_parameter;
memset(&pin_parameter, 0, sizeof(struct PinParam));
pin_parameter.cmd = GPIO_CONFIG_MODE;
pin_parameter.pin = BSP_485_DIR_PIN;
pin_parameter.mode = GPIO_CFG_OUTPUT;
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = PIN_TYPE;
ioctl_cfg.args = (void *)&pin_parameter;
if (0 != PrivIoctl(pin_fd, OPE_CFG, &ioctl_cfg)) {
printf("ioctl pin fd error %d\n", pin_fd);
PrivClose(pin_fd);
return;
}
struct SerialDataCfg uart_cfg;
memset(&uart_cfg, 0, sizeof(struct SerialDataCfg));
uart_cfg.serial_baud_rate = BAUD_RATE_115200;
uart_cfg.serial_data_bits = DATA_BITS_8;
uart_cfg.serial_stop_bits = STOP_BITS_1;
uart_cfg.serial_parity_mode = PARITY_NONE;
uart_cfg.serial_bit_order = BIT_ORDER_LSB;
uart_cfg.serial_invert_mode = NRZ_NORMAL;
uart_cfg.serial_buffer_size = SERIAL_RB_BUFSZ;
uart_cfg.serial_timeout = 1000;
uart_cfg.is_ext_uart = 0;
ioctl_cfg.ioctl_driver_type = SERIAL_TYPE;
ioctl_cfg.args = (void *)&uart_cfg;
if (0 != PrivIoctl(uart_fd, OPE_INT, &ioctl_cfg))
{
printf("ioctl uart fd error %d\n", uart_fd);
PrivClose(uart_fd);
return;
}
struct PinStat pin_dir;
pin_dir.pin = BSP_485_DIR_PIN;
while (1)
{
pin_dir.val = GPIO_HIGH;
PrivWrite(pin_fd,&pin_dir,0);
PrivWrite(uart_fd,"Hello world!\n",sizeof("Hello world!\n"));
PrivTaskDelay(100);
pin_dir.val = GPIO_LOW;
PrivWrite(pin_fd,&pin_dir,0);
char recv_buff[100];
memset(recv_buff,0,sizeof(recv_buff));
PrivRead(uart_fd,recv_buff,20);
printf("%s",recv_buff);
PrivTaskDelay(100);
}
PrivClose(pin_fd);
PrivClose(uart_fd);
return;
}
PRIV_SHELL_CMD_FUNCTION(Test485, a RS485 test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,62 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_rtc.c
* @brief: a application of rtc function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
void TestRTC(int argc,char *argv[])
{
int rtc_fd = PrivOpen(RTC_DEV_DRIVER, O_RDWR);
if(rtc_fd<0){
printf("open rtc fd error:%d\n",rtc_fd);
return;
}
if(argc>1){
int times = atoi(argv[1]);
printf("Time will be printf %d times\n",times);
struct RtcDrvConfigureParam rtc_para;
time_t my_time=0;
rtc_para.rtc_operation_cmd = OPER_RTC_SET_TIME;
rtc_para.time = &my_time;
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = RTC_TYPE;
ioctl_cfg.args = (void *)&rtc_para;
PrivIoctl(rtc_fd,0,&ioctl_cfg);
rtc_para.rtc_operation_cmd = OPER_RTC_GET_TIME;
for(size_t i=0;i<times;i++){
PrivIoctl(rtc_fd,0,&ioctl_cfg);
printf("The time now is %d\n",*(rtc_para.time));
PrivTaskDelay(5000);
}
}
PrivClose(rtc_fd);
return;
}
PRIV_SHELL_CMD_FUNCTION(TestRTC, a rtc test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_timer.c
* @brief: a application of soft timer function
* @version: 3.0
* @author: AIIT XUOS Lab
* @date: 2023/03/09
*/
#include <transform.h>
void TimerFunction(union sigval sig_val)
{
static int cnt = 0;
printf("%s cnt %d\n", __func__, cnt++);
}
void TestTimer(void)
{
int ret = 0;
int timer_flags;
timer_t timer_id;
struct sigevent evp;
memset(&evp, 0, sizeof(struct sigevent));
timer_flags = TIMER_TRIGGER_PERIODIC;
evp.sigev_notify = SIGEV_THREAD;
evp.sigev_notify_function = TimerFunction;
evp.sigev_notify_attributes = &timer_flags;
ret = timer_create(CLOCK_REALTIME, &evp, &timer_id);
if (ret < 0) {
printf("%s create timer failed ret %d\n", __func__, ret);
return;
}
struct itimerspec value;
//active time interval
value.it_interval.tv_sec = 2;
value.it_interval.tv_nsec = 0;
//first timer set time
value.it_value.tv_sec = 2;
value.it_value.tv_nsec = 0;
ret = timer_settime(timer_id, 1, &value, NULL);
if (ret < 0) {
printf("%s set timer time failed ret %d\n", __func__, ret);
return;
}
printf("%s success\n", __func__);
}
PRIV_SHELL_CMD_FUNCTION(TestTimer, soft timer test, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,113 @@
/****************************************************************************
* apps/examples/fb/fb_main.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <transform.h>
#ifdef ADD_NUTTX_FETURES
#ifdef CONFIG_BSP_USING_TOUCH
void TestTouch(void)
{
int fd;
TouchDataParam point = {0, 0, 0};
fd = PrivOpen("/dev/touch_dev", O_RDWR);
while(1)
{
PrivRead(fd,&point,1);
printf("Now touch point:(%d,%d)\n",point.x,point.y);
}
}
#endif
#include <stdio.h>
#include <string.h>
#include <transform.h>
#define NULL_PARAMETER 0
#define LCD_DOT_TYPE 1
#define LCD_SIZE 320
#elif defined ADD_XIZI_FETURES
void TestTouch(void)
{
int touch_fd = PrivOpen(TOUCH_DEV_DRIVER, O_RDWR);
if (touch_fd < 0)
{
printf("open touch fd error:%d\n", touch_fd);
return;
}
int lcd_fd = PrivOpen(TOUCH_LCD_DEV_DRIVER, O_RDWR);
if (lcd_fd < 0)
{
printf("open lcd fd error:%d\n", lcd_fd);
return;
}
// draw text
struct TouchDataStandard touch_pixel;
memset(&touch_pixel,0,sizeof(touch_pixel));
LcdWriteParam graph_param;
graph_param.type = LCD_DOT_TYPE;
uint16_t back_color[LCD_SIZE];
memset(back_color,0x00,sizeof(back_color));
for (int i = 0; i < LCD_SIZE; i++)
{
graph_param.pixel_info.pixel_color = &back_color;
graph_param.pixel_info.x_startpos = 0;
graph_param.pixel_info.y_startpos = i;
graph_param.pixel_info.x_endpos = LCD_SIZE -1;
graph_param.pixel_info.y_endpos = i;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
}
uint16 color_select[LCD_SIZE];
memset(color_select,0xff,sizeof(color_select));
graph_param.pixel_info.pixel_color = &color_select;
while(1){
if(0 > PrivRead(touch_fd, &touch_pixel, NULL_PARAMETER)){
printf("read touch error\n");
return;
}
printf("touch pixel position x:%d,y:%d\n",touch_pixel.x,touch_pixel.y);
graph_param.pixel_info.x_startpos = touch_pixel.x-10>0?touch_pixel.x-10:0;
graph_param.pixel_info.y_startpos = touch_pixel.y;
graph_param.pixel_info.x_endpos = touch_pixel.x+10;
graph_param.pixel_info.y_endpos = touch_pixel.y;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
graph_param.pixel_info.x_startpos = touch_pixel.x;
graph_param.pixel_info.y_startpos = touch_pixel.y-10>0?touch_pixel.y-10:0;
graph_param.pixel_info.x_endpos = touch_pixel.x;
graph_param.pixel_info.y_endpos = touch_pixel.y+10;
PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER);
}
PrivClose(lcd_fd);
PrivClose(touch_fd);
}
PRIV_SHELL_CMD_FUNCTION(TestTouch, a touch test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,66 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: test_wdt.c
* @brief: a application of wdt function
* @version: 1.1
* @author: AIIT XUOS Lab
* @date: 2022/12/17
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#ifdef ADD_XIZI_FETURES
void TestWDT(int argc, char *agrv[])
{
int wdt_fd = PrivOpen(WDT0_DEV_DRIVER, O_RDWR);
if (wdt_fd < 0)
{
printf("open wdt_fd fd error:%d\n", wdt_fd);
return;
}
printf("hw watchdog open!\n");
// init watchdog
int wdt_time = 1000;
struct PrivIoctlCfg ioctl_cfg;
ioctl_cfg.ioctl_driver_type = WDT_TYPE;
ioctl_cfg.args = (void *)&wdt_time;
if (0 != PrivIoctl(wdt_fd, OPER_WDT_SET_TIMEOUT, &ioctl_cfg))
{
printf("ioctl wdt fd error %d\n", wdt_fd);
PrivClose(wdt_fd);
return;
}
int test_counter = 100;
// wdt feed or not according to argc,if argc!=1 then dog won't be feed
while (test_counter--)
{
if (1 == argc)
{
printf("dog is feed\n");
PrivIoctl(wdt_fd, OPER_WDT_KEEPALIVE, &ioctl_cfg); // feed dog
}
PrivTaskDelay(100);
}
PrivClose(wdt_fd);
return;
}
PRIV_SHELL_CMD_FUNCTION(TestWDT, a wdt test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif

View File

@ -0,0 +1,133 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file 4g_app.c
* @brief support get data from and send data to 4g server
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.12.12
*/
#include <stdio.h>
#include <string.h>
#include <transform.h>
#include <adapter.h>
static uint8_t adapter_4g_status = 0;
static pthread_t recv_4g_heart_task;
struct Adapter *adapter_4g;
static const uint8_t server_addr[] = "xxx.xxx.xxx.xxx";
static const uint8_t server_port[] = "xxx";
#define ADAPTER_4G_HEART "HEART"
int Adapter4GConnectFunction(struct Adapter *adapter, uint8_t reconnect)
{
int ret = 0;
int baud_rate = BAUD_RATE_115200;
if (1 != reconnect) {
ret = AdapterDeviceOpen(adapter);
if (ret < 0) {
goto out;
}
ret = AdapterDeviceControl(adapter, OPE_INT, &baud_rate);
if (ret < 0) {
goto out;
}
}
ret = AdapterDeviceConnect(adapter, CLIENT, server_addr, server_port, IPV4);
if (ret < 0) {
goto out;
}
out:
if (ret < 0) {
AdapterDeviceClose(adapter);
}
return ret;
}
void Adapter4gSend(uint8_t *send_data, size_t length)
{
if (adapter_4g_status) {
AdapterDeviceSend(adapter_4g, send_data, length);
}
}
static void *Receive4gHeartTask(void* parameter)
{
char recv_msg[16] = {0};
ssize_t recv_length = 0;
uint8_t net_status_cnt = 0;
while (1) {
SetTaskStatus(0x01);
if (net_status_cnt > 5) {
adapter_4g_status = 0;
while (Adapter4GConnectFunction(adapter_4g, 1) < 0) {
PrivTaskDelay(10000);
}
net_status_cnt = 0;
}
adapter_4g_status = 1;
recv_length = AdapterDeviceRecv(adapter_4g, recv_msg, 6);
if (recv_length > 0) {
//if (0 == strcmp(recv_msg, ADAPTER_4G_HEART)) {
net_status_cnt = 0;
//}
} else {
printf("4G recv heart error re-recv cnt %d\n", net_status_cnt);
net_status_cnt++;
}
memset(recv_msg, 0, sizeof(recv_msg));
}
}
int Adapter4GActive(void)
{
int ret = 0;
adapter_4g = AdapterDeviceFindByName(ADAPTER_4G_NAME);
#ifdef ADAPTER_EC200T
adapter_4g->socket.socket_id = 0;
ret = Adapter4GConnectFunction(adapter_4g, 0);
if (ret < 0) {
printf("Adapter4GConnect failed %d\n", ret);
}
adapter_4g_status = 1;
pthread_attr_t attr;
attr.schedparam.sched_priority = 22;
attr.stacksize = 2048;
PrivTaskCreate(&recv_4g_heart_task, &attr, &Receive4gHeartTask, NULL);
PrivTaskStartup(&recv_4g_heart_task);
#endif
return ret;
}

View File

@ -0,0 +1,3 @@
SRC_FILES := 4g_app.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -1,6 +1,3 @@
ifeq ($(CONFIG_SOCKET_DEMO),y)
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
@ -10,6 +7,10 @@ endif
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
ifeq ($(CONFIG_CONNECTION_ADAPTER_4G),y)
SRC_DIR += 4g_app
endif
ifeq ($(CONFIG_RESOURCES_LWIP),y)
SRC_DIR += socket_demo
endif
@ -17,4 +18,3 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
include $(KERNEL_ROOT)/compiler.mk
endif
endif

View File

@ -21,7 +21,7 @@
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#include "sys_arch.h"
#include <sys_arch.h>
#include <lwip/sockets.h>
#include "lwip/sys.h"
#endif
@ -33,9 +33,17 @@
#include "stdio.h"
#endif
#define TCP_DEMO_BUF_SIZE 65535
#define TCP_DEMO_BUF_SIZE 65535
#define TCP_DEMO_SEND_TIMES 20
#define LWIP_TCP_DEMO_TASK_STACK_SIZE 4096
#define LWIP_TCP_DEMO_TASK_PRIO 20
char tcp_socket_ip[] = {192, 168, 250, 252};
static pthread_t tcp_client_task;
static pthread_t tcp_server_task;
static char tcp_demo_ipaddr[] = {192, 168, 131, 77};
static char tcp_demo_netmask[] = {255, 255, 254, 0};
static char tcp_demo_gwaddr[] = {192, 168, 131, 1};
#ifdef ADD_NUTTX_FETURES
#define lw_print printf
@ -46,8 +54,8 @@ char tcp_socket_ip[] = {192, 168, 250, 252};
#define LWIP_TARGET_PORT 4840
#endif
uint16_t tcp_socket_port = LWIP_TARGET_PORT;
char tcp_ip_str[128] = {0};
static uint16_t tcp_socket_port = 8888;
static char tcp_ip_str[128] = {0};
/******************************************************************************/
void TcpSocketConfigParam(char *ip_str)
@ -55,35 +63,23 @@ void TcpSocketConfigParam(char *ip_str)
int ip1, ip2, ip3, ip4, port = 0;
if(ip_str == NULL)
{
return;
}
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port))
{
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port)) {
printf("config ip %s port %d\n", ip_str, port);
strcpy(tcp_ip_str, ip_str);
tcp_socket_ip[0] = ip1;
tcp_socket_ip[1] = ip2;
tcp_socket_ip[2] = ip3;
tcp_socket_ip[3] = ip4;
if(port)
tcp_socket_port = port;
return;
}
if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4))
{
if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4)) {
printf("config ip %s\n", ip_str);
tcp_socket_ip[0] = ip1;
tcp_socket_ip[1] = ip2;
tcp_socket_ip[2] = ip3;
tcp_socket_ip[3] = ip4;
strcpy(tcp_ip_str, ip_str);
}
}
static void TcpSocketRecvTask(void *arg)
static void *TcpSocketRecvTask(void *arg)
{
int fd = -1, clientfd;
int recv_len;
@ -91,18 +87,15 @@ static void TcpSocketRecvTask(void *arg)
struct sockaddr_in tcp_addr;
socklen_t addr_len;
while(1)
{
while(1) {
recv_buf = (char *)malloc(TCP_DEMO_BUF_SIZE);
if (recv_buf == NULL)
{
if (recv_buf == NULL) {
lw_error("No memory\n");
continue;
}
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
{
if (fd < 0) {
lw_error("Socket error\n");
free(recv_buf);
continue;
@ -113,8 +106,7 @@ static void TcpSocketRecvTask(void *arg)
tcp_addr.sin_port = htons(tcp_socket_port);
memset(&(tcp_addr.sin_zero), 0, sizeof(tcp_addr.sin_zero));
if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1)
{
if (bind(fd, (struct sockaddr *)&tcp_addr, sizeof(struct sockaddr)) == -1) {
lw_error("Unable to bind\n");
close(fd);
free(recv_buf);
@ -125,8 +117,7 @@ static void TcpSocketRecvTask(void *arg)
lw_notice("\nLocal Port:%d\n", tcp_socket_port);
// setup socket fd as listening mode
if (listen(fd, 5) != 0 )
{
if (listen(fd, 5) != 0 ) {
lw_error("Unable to listen\n");
close(fd);
free(recv_buf);
@ -137,13 +128,11 @@ static void TcpSocketRecvTask(void *arg)
clientfd = accept(fd, (struct sockaddr *)&tcp_addr, (socklen_t*)&addr_len);
lw_notice("client %s connected\n", inet_ntoa(tcp_addr.sin_addr));
while(1)
{
while(1) {
memset(recv_buf, 0, TCP_DEMO_BUF_SIZE);
recv_len = recvfrom(clientfd, recv_buf, TCP_DEMO_BUF_SIZE, 0,
(struct sockaddr *)&tcp_addr, &addr_len);
if(recv_len > 0)
{
if(recv_len > 0) {
lw_notice("Receive from : %s\n", inet_ntoa(tcp_addr.sin_addr));
lw_notice("Receive data : %d - %s\n\n", recv_len, recv_buf);
}
@ -157,26 +146,33 @@ static void TcpSocketRecvTask(void *arg)
void TcpSocketRecvTest(int argc, char *argv[])
{
if(argc >= 2)
{
if(argc >= 2) {
lw_print("lw: [%s] target ip %s\n", __func__, argv[1]);
TcpSocketConfigParam(argv[1]);
}
#ifdef ADD_XIZI_FETURES
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
sys_thread_new("TcpSocketRecvTask", TcpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
lwip_config_tcp(0, tcp_demo_ipaddr, tcp_demo_netmask, tcp_demo_gwaddr);
pthread_attr_t attr;
attr.schedparam.sched_priority = LWIP_TCP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
#endif
#ifdef ADD_NUTTX_FETURES
TcpSocketRecvTask(NULL);
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
attr.priority = LWIP_TCP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
#endif
PrivTaskCreate(&tcp_server_task, &attr, &TcpSocketRecvTask, NULL);
PrivTaskStartup(&tcp_server_task);
}
PRIV_SHELL_CMD_FUNCTION(TcpSocketRecvTest, a tcp receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
static void TcpSocketSendTask(void *arg)
static void *TcpSocketSendTask(void *arg)
{
int cnt = LWIP_DEMO_TIMES;
int cnt = TCP_DEMO_SEND_TIMES;
int fd = -1;
int ret;
char send_msg[128];
@ -186,10 +182,9 @@ static void TcpSocketSendTask(void *arg)
memset(send_msg, 0, sizeof(send_msg));
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
{
if (fd < 0) {
lw_print("Socket error\n");
return;
return NULL;
}
struct sockaddr_in tcp_sock;
@ -200,17 +195,15 @@ static void TcpSocketSendTask(void *arg)
memset(&(tcp_sock.sin_zero), 0, sizeof(tcp_sock.sin_zero));
ret = connect(fd, (struct sockaddr *)&tcp_sock, sizeof(struct sockaddr));
if (ret)
{
lw_print("Unable to connect %s = %d\n", tcp_ip_str, ret);
if (ret < 0) {
lw_print("Unable to connect %s:%d = %d\n", tcp_ip_str, tcp_socket_port, ret);
close(fd);
return;
return NULL;
}
lw_print("TCP connect %s:%d success, start to send.\n", tcp_ip_str, tcp_socket_port);
while (cnt --)
{
while (cnt --) {
lw_print("Lwip client is running.\n");
snprintf(send_msg, sizeof(send_msg), "TCP test package times %d\r\n", cnt);
send(fd, send_msg, strlen(send_msg), 0);
@ -219,24 +212,31 @@ static void TcpSocketSendTask(void *arg)
}
close(fd);
return;
return NULL;
}
void TcpSocketSendTest(int argc, char *argv[])
{
if(argc >= 2)
{
if(argc >= 2) {
lw_print("lw: [%s] target ip %s\n", __func__, argv[1]);
TcpSocketConfigParam(argv[1]);
}
#ifdef ADD_XIZI_FETURES
lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip);
sys_thread_new("Tcp Socket Send", TcpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
lwip_config_tcp(0, tcp_demo_ipaddr, tcp_demo_netmask, tcp_demo_gwaddr);
pthread_attr_t attr;
attr.schedparam.sched_priority = LWIP_TCP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
#endif
#ifdef ADD_NUTTX_FETURES
TcpSocketSendTask(NULL);
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
attr.priority = LWIP_TCP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_TCP_DEMO_TASK_STACK_SIZE;
#endif
PrivTaskCreate(&tcp_client_task, &attr, &TcpSocketSendTask, NULL);
PrivTaskStartup(&tcp_client_task);
}
PRIV_SHELL_CMD_FUNCTION(TcpSocketSendTest, a tcp send sample, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -20,7 +20,7 @@
#include <transform.h>
#ifdef ADD_XIZI_FETURES
#include "sys_arch.h"
#include <sys_arch.h>
#include "lwip/sockets.h"
#endif
@ -38,11 +38,20 @@
#define lw_print printf
#endif
#define UDP_BUF_SIZE 65536
#define UDP_DEMO_BUF_SIZE 65535
#define UDP_DEMO_SEND_TIMES 20
#define LWIP_UDP_DEMO_TASK_STACK_SIZE 4096
#define LWIP_UDP_DEMO_TASK_PRIO 20
char udp_socket_ip[] = {192, 168, 250, 252};
char udp_ip_str[128] = {0};
uint16_t udp_socket_port = LWIP_LOCAL_PORT;
static pthread_t udp_client_task;
static pthread_t udp_server_task;
static char udp_demo_ipaddr[] = {192, 168, 131, 77};
static char udp_demo_netmask[] = {255, 255, 254, 0};
static char udp_demo_gwaddr[] = {192, 168, 131, 1};
static char udp_ip_str[128] = {0};
static uint16_t udp_socket_port = 8888;
/*****************************************************************************/
void UdpSocketConfigParam(char *ip_str)
@ -50,53 +59,38 @@ void UdpSocketConfigParam(char *ip_str)
int ip1, ip2, ip3, ip4, port = 0;
if(ip_str == NULL)
{
return;
}
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port))
{
if(sscanf(ip_str, "%d.%d.%d.%d:%d", &ip1, &ip2, &ip3, &ip4, &port)) {
printf("config ip %s port %d\n", ip_str, port);
strcpy(udp_ip_str, ip_str);
udp_socket_ip[0] = ip1;
udp_socket_ip[1] = ip2;
udp_socket_ip[2] = ip3;
udp_socket_ip[3] = ip4;
if(port)
udp_socket_port = port;
return;
}
if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4))
{
if(sscanf(ip_str, "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4)) {
printf("config ip %s\n", ip_str);
udp_socket_ip[0] = ip1;
udp_socket_ip[1] = ip2;
udp_socket_ip[2] = ip3;
udp_socket_ip[3] = ip4;
strcpy(udp_ip_str, ip_str);
}
}
static void UdpSocketRecvTask(void *arg)
static void *UdpSocketRecvTask(void *arg)
{
int fd = -1;
char *recv_buf;
struct sockaddr_in udp_addr, server_addr;
int recv_len;
while(1)
{
recv_buf = (char *)malloc(UDP_BUF_SIZE);
if(recv_buf == NULL)
{
while(1) {
recv_buf = (char *)PrivMalloc(UDP_DEMO_BUF_SIZE);
if(recv_buf == NULL) {
lw_error("No memory\n");
continue;
}
fd = socket(AF_INET, SOCK_DGRAM, 0);
if(fd < 0)
{
if(fd < 0) {
lw_error("Socket error\n");
free(recv_buf);
continue;
@ -107,8 +101,7 @@ static void UdpSocketRecvTask(void *arg)
udp_addr.sin_port = htons(udp_socket_port);
memset(&(udp_addr.sin_zero), 0, sizeof(udp_addr.sin_zero));
if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1)
{
if(bind(fd, (struct sockaddr *)&udp_addr, sizeof(struct sockaddr)) == -1) {
lw_error("Unable to bind\n");
close(fd);
free(recv_buf);
@ -118,12 +111,10 @@ static void UdpSocketRecvTask(void *arg)
lw_notice("UDP bind success, start to receive.\n");
lw_notice("\n\nLocal Port:%d\n\n", udp_socket_port);
while(1)
{
memset(recv_buf, 0, UDP_BUF_SIZE);
recv_len = recv(fd, recv_buf, UDP_BUF_SIZE, 0);
if(recv_len > 0)
{
while(1) {
memset(recv_buf, 0, UDP_DEMO_BUF_SIZE);
recv_len = recv(fd, recv_buf, UDP_DEMO_BUF_SIZE, 0);
if(recv_len > 0) {
lw_notice("Receive from : %s\n", inet_ntoa(server_addr.sin_addr));
lw_notice("Receive data : %s\n\n", recv_buf);
}
@ -137,36 +128,41 @@ static void UdpSocketRecvTask(void *arg)
void UdpSocketRecvTest(int argc, char *argv[])
{
if(argc >= 2)
{
if(argc >= 2) {
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
UdpSocketConfigParam(argv[1]);
}
#ifdef ADD_XIZI_FETURES
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL,
LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO);
lwip_config_tcp(0, udp_demo_ipaddr, udp_demo_netmask, udp_demo_gwaddr);
pthread_attr_t attr;
attr.schedparam.sched_priority = LWIP_UDP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE;
#endif
#ifdef ADD_NUTTX_FETURES
UdpSocketRecvTask(NULL);
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
attr.priority = LWIP_UDP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE;
#endif
PrivTaskCreate(&udp_server_task, &attr, &UdpSocketRecvTask, NULL);
PrivTaskStartup(&udp_server_task);
}
PRIV_SHELL_CMD_FUNCTION(UdpSocketRecvTest, a udp receive sample, PRIV_SHELL_CMD_MAIN_ATTR);
static void UdpSocketSendTask(void *arg)
static void *UdpSocketSendTask(void *arg)
{
int cnt = LWIP_DEMO_TIMES;
int cnt = UDP_DEMO_SEND_TIMES;
char send_str[128];
int fd = -1;
memset(send_str, 0, sizeof(send_str));
fd = socket(AF_INET, SOCK_DGRAM, 0);
if(fd < 0)
{
if(fd < 0) {
lw_error("Socket error\n");
return;
return NULL;
}
struct sockaddr_in udp_sock;
@ -175,19 +171,17 @@ static void UdpSocketSendTask(void *arg)
udp_sock.sin_addr.s_addr = inet_addr(udp_ip_str);
memset(&(udp_sock.sin_zero), 0, sizeof(udp_sock.sin_zero));
if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr)))
{
lw_error("Unable to connect\n");
if(connect(fd, (struct sockaddr *)&udp_sock, sizeof(struct sockaddr)) < 0) {
lw_error("Unable to connect %s:%d\n", udp_ip_str, udp_socket_port);
close(fd);
return;
return NULL;
}
lw_print("UDP connect %s:%d success, start to send.\n",
udp_ip_str,
udp_socket_port);
while(cnt --)
{
while(cnt --) {
snprintf(send_str, sizeof(send_str), "UDP test package times %d\r\n", cnt);
send(fd, send_str, strlen(send_str), 0);
lw_notice("Send UDP msg: %s ", send_str);
@ -195,25 +189,31 @@ static void UdpSocketSendTask(void *arg)
}
close(fd);
return;
return NULL;
}
void UdpSocketSendTest(int argc, char *argv[])
{
if(argc >= 2)
{
if(argc >= 2) {
lw_notice("lw: [%s] target ip %s\n", __func__, argv[1]);
UdpSocketConfigParam(argv[1]);
}
#ifdef ADD_XIZI_FETURES
lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip);
sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE,
LWIP_DEMO_TASK_PRIO);
lwip_config_tcp(0, udp_demo_ipaddr, udp_demo_netmask, udp_demo_gwaddr);
pthread_attr_t attr;
attr.schedparam.sched_priority = LWIP_UDP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE;
#endif
#ifdef ADD_NUTTX_FETURES
UdpSocketSendTask(NULL);
pthread_attr_t attr = PTHREAD_ATTR_INITIALIZER;
attr.priority = LWIP_UDP_DEMO_TASK_PRIO;
attr.stacksize = LWIP_UDP_DEMO_TASK_STACK_SIZE;
#endif
PrivTaskCreate(&udp_client_task, &attr, &UdpSocketSendTask, NULL);
PrivTaskStartup(&udp_client_task);
}
PRIV_SHELL_CMD_FUNCTION(UdpSocketSendTest, a udp send sample, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -1,3 +1,3 @@
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens
SRC_DIR := advantech beckhoff br delta mitsubishi omron schneider siemens ge xinje inovance
include $(KERNEL_ROOT)/compiler.mk

View File

@ -1,3 +1,3 @@
SRC_FILES := br_x20cp0410.c br_x20cp1381.c br_x20cp1586.c
SRC_FILES := br_x20cp0410.c br_x20cp1381.c br_x20cp1586.c br_ppc2100.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,23 @@
# 贝加莱 PPC2100通信测试
[TOC]
## 通信接线及参数设置
* 网口
* 通过ETH1 RJ45 网口连接
* 网口参数IP192.168.250.26 Port502
* 测试的协议:Modbus TCP
## 存储区
- 贝加莱PLC与其他PLC不同没有明确类似MD等这样的存储区的概念Modbus地址取决于库函数中结构体变量索引。
## 通信测试
- 共测试BOOLINT16INT32FLOAT,DOUBLE 共五种类型数据。
- 测试BOOL型变量用功能码01测其他类型变量用功能码03。
-

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file br_ppc2100.c
* @brief PLC BR PPC2100 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.5.8
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlBrTest_PPC2100(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlBrTest_PPC2100, Delta ppc2100 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,93 @@
{
"device_id": 1,
"device_name": "BR_PPC2100",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.26",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.254.0",
"port": 502
},
"protocol_type": 2,
"read_period": 2000,
"read_item_list": [
{
"value_name": "motorrun",
"value_type": 1,
"function_code": 2,
"start_address": 0,
"quantity": 1
},
{
"value_name": "motorstop",
"value_type": 1,
"function_code": 2,
"start_address": 1,
"quantity": 1
},
{
"value_name": "valueopen",
"value_type": 1,
"function_code": 1,
"start_address": 100,
"quantity": 1
},
{
"value_name": "valueclose",
"value_type": 1,
"function_code": 1,
"start_address": 101,
"quantity": 1
},
{
"value_name": "step",
"value_type": 3,
"function_code": 4,
"start_address": 100,
"quantity": 1
},
{
"value_name": "temperature",
"value_type": 9,
"function_code": 4,
"start_address": 101,
"quantity": 2
},
{
"value_name": "status",
"value_type": 4,
"function_code": 4,
"start_address": 103,
"quantity": 2
},
{
"value_name": "mode",
"value_type": 3,
"function_code": 3,
"start_address": 200,
"quantity": 1
},
{
"value_name": "setTemperature",
"value_type": 9,
"function_code": 3,
"start_address": 201,
"quantity": 2
},
{
"value_name": "setConuter",
"value_type": 4,
"function_code": 3,
"start_address": 203,
"quantity": 2
},
{
"value_name": "LrealTest",
"value_type": 8,
"function_code": 3,
"start_address": 205,
"quantity": 4
}
]
}

View File

@ -1,3 +1,3 @@
SRC_FILES := delta_as228t.c
SRC_FILES := delta_as228t.c delta_as332t.c delta_dvp.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,22 @@
# 台达 DVP通信测试
[TOC]
## 通信接线及参数设置
* 网口
* 通过自带 RJ45 网口连接
* 网口参数IP192.168.250.27 Port502
* 测试的协议:Modbus TCP
## 存储区
- 含MDXY。台达PLC中 各存储区地址和Modbus地址有明确的对应表详见台达DVP协议解析测试文档。
## 通信测试
- 共测试BOOLINT16INT32FLOAT 共四种类型数据。
- 测试D区M区和Y区。

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file delta_dvp.c
* @brief PLC DELTA DVP app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlDeltadvpTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlDeltadvpTest, Delta dvp Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,80 @@
{
"device_id": 1,
"device_name": "DELTA_DVP",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.27",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.254.0",
"port": 502
},
"protocol_type": 2,
"read_period": 2000,
"read_item_list": [
{
"value_name": "M20",
"value_type": 1,
"function_code": 1,
"start_address": 2068,
"quantity": 1
},
{
"value_name": "M100",
"value_type": 1,
"function_code": 1,
"start_address":2148,
"quantity": 1
},
{
"value_name": "Y10",
"value_type": 1,
"function_code": 1,
"start_address": 1288,
"quantity": 1
},
{
"value_name": "D200",
"value_type": 3,
"function_code": 3,
"start_address":4296,
"quantity": 1
},
{
"value_name": "D201",
"value_type": 3,
"function_code": 3,
"start_address": 4297,
"quantity": 1
},
{
"value_name": "D220",
"value_type": 4,
"function_code": 3,
"start_address": 4316,
"quantity": 2
},
{
"value_name": "D222",
"value_type": 4,
"function_code": 3,
"start_address": 4318,
"quantity": 2
},
{
"value_name": "D300",
"value_type": 9,
"function_code": 3,
"start_address": 4396,
"quantity": 2
},
{
"value_name": "D302",
"value_type": 9,
"function_code": 3,
"start_address": 4398,
"quantity": 2
}
]
}

View File

@ -0,0 +1,3 @@
SRC_FILES := ge_versamax001.c ge_cpe100.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,57 @@
---
typora-copy-images-to: upload
---
# 艾默生原GE 通信测试
[TOC]
## 小型VersaMAX CPU001测试
### 通信接线及参数设置
* 串口
* COM2为15孔D型 RS485。波特率19200数据位8位停止位1位校验偶校验。接线按下图典型双线接法。
![ge_versamax_serial](./img/ge_versamax_serial.png)
### 存储区
- 存储区 IQAIR区。其他内存区如MAQ不能直接访问要通过程序转换访问。
### 通信测试
- 共测试BOOLINT16FLOAT共三种类型数据。
- 测试R区及Q区数据。
- R区数据测试用功能码03以字为单位读取。配方中start_address字段为PLC地址直接减1。
- Q区数据测试用功能码01以位为单位读取。配方中start_address字段为PLC地址直接减1。
## 中型PLC CPE100通信测试
### 通信接线及参数设置
- 网口
- 网口RJ45参数 IP192.168.250.28 端口号502
### 存储区
- 存储区 IQAIR区。其他内存区如MAQ不能直接访问要通过程序转换访问。
### 通信测试
- 共测试BOOLINT16INT32FLOATDOUBLE共五种类型数据。
- 测试R区及Q区数据。
- R区数据测试用功能码03以字为单位读取。配方中start_address字段为PLC地址直接减1。
- Q区数据测试用功能码01以位为单位读取。配方中start_address字段为PLC地址直接减1。

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file ge_cpe100.c
* @brief PLC GE Versamax app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlGecpe100Test(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlGecpe100Test, ge cpe100 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file ge_versamax001.c
* @brief PLC GE Versamax app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlGeversamaxTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_rtu_protocol = ControlProtocolFind();
if (NULL == modbus_rtu_protocol) {
printf("%s get modbus rtu protocol %p failed\n", __func__, modbus_rtu_protocol);
return;
}
printf("%s get modbus rtu protocol %p successfull\n", __func__, modbus_rtu_protocol);
if (CONTROL_REGISTERED == modbus_rtu_protocol->protocol_status) {
ControlProtocolOpen(modbus_rtu_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_rtu_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus rtu data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_rtu_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlGeversamaxTest, ge versamax001 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

View File

@ -0,0 +1,73 @@
{
"device_id": 1,
"device_name": "GE_CPE100_TCP",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.28",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.254.0",
"port": 502
},
"protocol_type": 2,
"read_period": 2000,
"read_item_list": [
{
"value_name": "Q001",
"value_type": 1,
"function_code": 1,
"start_address": 0,
"quantity": 1
},
{
"value_name": "Q010",
"value_type": 1,
"function_code": 1,
"start_address":9,
"quantity": 1
},
{
"value_name": "Q066",
"value_type": 1,
"function_code": 1,
"start_address": 65,
"quantity": 1
},
{
"value_name": "Q100",
"value_type": 1,
"function_code": 1,
"start_address":99,
"quantity": 1
},
{
"value_name": "R11",
"value_type": 3,
"function_code": 3,
"start_address": 10,
"quantity": 1
},
{
"value_name": "R12",
"value_type": 9,
"function_code": 3,
"start_address": 11,
"quantity": 2
},
{
"value_name": "R14",
"value_type": 8,
"function_code": 3,
"start_address": 13,
"quantity": 4
},
{
"value_name": "R18",
"value_type": 4,
"function_code": 3,
"start_address": 17,
"quantity": 2
}
]
}

View File

@ -0,0 +1,58 @@
{
"device_id": 1,
"device_name": "GE_VersaMAX_RTU",
"communication_type": 1,
"serial_config": {
"station": 1,
"baud_rate": 19200,
"data_bits": 8,
"stop_bits": 1,
"check_mode": 2
},
"protocol_type": 3,
"read_period": 2000,
"read_item_list": [
{
"value_name": "Q001",
"value_type": 1,
"function_code": 1,
"start_address": 0,
"quantity": 1
},
{
"value_name": "Q010",
"value_type": 1,
"function_code": 1,
"start_address": 9,
"quantity": 1
},
{
"value_name": "Q066",
"value_type": 1,
"function_code": 1,
"start_address": 65,
"quantity": 1
},
{
"value_name": "Q100",
"value_type": 1,
"function_code": 1,
"start_address": 99,
"quantity": 1
},
{
"value_name": "R11",
"value_type": 3,
"function_code": 3,
"start_address": 10,
"quantity": 1
},
{
"value_name": "R12",
"value_type": 9,
"function_code": 3,
"start_address": 11,
"quantity": 2
}
]
}

View File

@ -0,0 +1,3 @@
SRC_FILES := inovance_am401_cpu1608tn_ethernet.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,26 @@
# INOVANCE AM4011608TN通信测试
[TOC]
## 通信接线及参数设置
* 网口
* CN3 EtherNET,Mosbus TCP协议IP192.168.250.50Port502
* 串口
* CN1 RS485AM401只支持一路串口AM600可支持两路串口。AM401接线pin1:485-pin2:485+。波特率9600数据位8位停止位1位校验偶校验
## 存储区
- 存储区 IQM区。
## 通信测试
1共测试BOOLINT16INT32FLOAT共四种类型数据。
2测试M区及Q区数据。
3M区数据测试用功能码03以字为单位读取。如读MX0.3,则读取MW0然后按位拆解。如读MW100则配方文件中起始地址则直接写100即可。如读MDx则配方文件中起始地址应为2*x这是汇川的地址编码规则决定如MD200则对应400。
4Q区数据测试用功能码01以位为单位读取。如读QX.Y则配方文件中起始地址为X*8+Y如读QWQD等则需按位进行读取后然后组合得到。

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file inovance_am401_cpu1608tn_ethernet.c
* @brief PLC inovance am401 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.4.25
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlInovanceam401EthernetTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlInovanceam401EthernetTest, inovance am401 ethernet Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,80 @@
{
"device_id": 1,
"device_name": "INOVANCE_AM401_TCP",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.50",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.254.0",
"port": 502
},
"protocol_type": 2,
"read_period": 2000,
"read_item_list": [
{
"value_name": "q00",
"value_type": 1,
"function_code": 1,
"start_address": 0,
"quantity": 1
},
{
"value_name": "q01",
"value_type": 1,
"function_code": 1,
"start_address":1,
"quantity": 1
},
{
"value_name": "q10",
"value_type": 1,
"function_code": 1,
"start_address": 8,
"quantity": 1
},
{
"value_name": "mw100",
"value_type": 3,
"function_code": 3,
"start_address": 100,
"quantity": 1
},
{
"value_name": "mw101",
"value_type": 3,
"function_code": 3,
"start_address": 101,
"quantity": 1
},
{
"value_name": "md200",
"value_type": 4,
"function_code": 3,
"start_address": 400,
"quantity": 2
},
{
"value_name": "md201",
"value_type": 4,
"function_code": 3,
"start_address": 402,
"quantity": 2
},
{
"value_name": "md300",
"value_type": 9,
"function_code": 3,
"start_address": 600,
"quantity": 2
},
{
"value_name": "md301",
"value_type": 9,
"function_code": 3,
"start_address": 602,
"quantity": 2
}
]
}

View File

@ -1,3 +1,3 @@
SRC_FILES := mitsubishi_fx3u.c mitsubishi_fx5u.c
SRC_FILES := mitsubishi_fx3u.c mitsubishi_fx5u.c mitsubishi_fx2n.c mitsubishi_q02u.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,24 @@
# 三菱 FX2N通信测试
[TOC]
## 通信接线及参数设置
* 串口
* FX2N自带8针圆口422用于程序的下载。全系列不支持网口且需购买串口拓展模块FX2N-485-BD用于通信测试。
* 接线RDA和SDA短接引出ARDB与SDB短接引出B。
* 串口模块支持MC-1C协议通信速率9600数据位7bit停止位1bit校验偶校验
## 存储区
- 存储区 IQMD区。
## 通信测试
- 共测试BOOLINT16FLOAT共三种类型数据。
- 测试M区及D区数据。

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file mitsubishi_fx2n.c
* @brief PLC MITSUBISHI FX2N app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlFx2nTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType melsec_1c_protocol = ControlProtocolFind();
if (NULL == melsec_1c_protocol) {
printf("%s get melsec 1c protocol %p failed\n", __func__, melsec_1c_protocol);
return;
}
printf("%s get melsec 1c protocol %p successfull\n", __func__, melsec_1c_protocol);
if (CONTROL_REGISTERED == melsec_1c_protocol->protocol_status) {
ControlProtocolOpen(melsec_1c_protocol);
for (;;) {
read_data_length = ControlProtocolRead(melsec_1c_protocol, read_data, sizeof(read_data));
printf("%s read [%d] melsec 1c data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(melsec_1c_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlFx2nTest, Mitsubishi FX2N Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -18,6 +18,47 @@
* @date 2022.9.27
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlFx3uTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType melsec_1e_protocol = ControlProtocolFind();
if (NULL == melsec_1e_protocol) {
printf("%s get melsec 1e protocol %p failed\n", __func__, melsec_1e_protocol);
return;
}
printf("%s get melsec 1e protocol %p successfull\n", __func__, melsec_1e_protocol);
if (CONTROL_REGISTERED == melsec_1e_protocol->protocol_status) {
ControlProtocolOpen(melsec_1e_protocol);
for (;;) {
read_data_length = ControlProtocolRead(melsec_1e_protocol, read_data, sizeof(read_data));
printf("%s read [%d] melsec 1e data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlFx3uTest, Mitsubishi fx3u Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,64 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file mitsubishi_q02u.c
* @brief PLC MITSUBISHI Q02U app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
*/
#include <control.h>
extern int Adapter4GActive(void);
void ControlQ02uTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType melsec_3e_protocol = ControlProtocolFind();
if (NULL == melsec_3e_protocol) {
printf("%s get melsec 3e protocol %p failed\n", __func__, melsec_3e_protocol);
return;
}
printf("%s get melsec 3e protocol %p successfull\n", __func__, melsec_3e_protocol);
if (CONTROL_REGISTERED == melsec_3e_protocol->protocol_status) {
ControlProtocolOpen(melsec_3e_protocol);
for (;;) {
read_data_length = ControlProtocolRead(melsec_3e_protocol, read_data, sizeof(read_data));
printf("%s read [%d] melsec 3c data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(melsec_3c_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlQ02uTest, Mitsubishi Q02U Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,331 @@
{
"device_id": 769,
"device_name": "S01",
"communication_type": 1,
"serial_config": {
"station": 1,
"baud_rate": 9600,
"data_bits": 7,
"stop_bits": 1,
"check_mode": 3
},
"protocol_type": 9,
"read_period": 1000,
"read_item_list": [
{
"value_name": "启动",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "0",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "停止",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "1",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "使能",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "2",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "回零",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "3",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "急停",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "4",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "正限位",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "5",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "负限位",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "6",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "自动运行中",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "20",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "故障",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "21",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "待机",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "22",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "手动模式",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "23",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "自动模式",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "24",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "运行方向",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "25",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "复位",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "26",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "备用1",
"value_type": 1,
"device_code": "M",
"head_device_number_string": "27",
"device_points_count": 1,
"command_type": 0,
"monitoring_timer": 100
},
{
"value_name": "产量",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "0",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型1",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "1",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型2",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "2",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型3",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "3",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型4",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "4",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型5",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "5",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型6",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "50",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型7",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "51",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型8",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "52",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "整型9",
"value_type": 3,
"device_code": "D",
"head_device_number_string": "53",
"device_points_count": 1,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "速度",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "200",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "加速度",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "202",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "减速度",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "204",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "起始位置",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "206",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "终点位置",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "208",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "张力值",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "300",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "浮点型1",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "302",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "浮点型2",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "304",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "浮点型3",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "306",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
},
{
"value_name": "浮点型4",
"value_type": 9,
"device_code": "D",
"head_device_number_string": "308",
"device_points_count": 2,
"command_type": 1,
"monitoring_timer": 100
}
]
}

View File

@ -1,3 +1,3 @@
SRC_FILES := omron_cj2m.c omron_nj501.c omron_nx102.c
SRC_FILES := omron_cj2m.c omron_nj501.c omron_nx102.c omron_cp1h.c omron_cp1l.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,70 @@
# OMRON_CP1L通信测试
[TOC]
## 通信接线及参数设置
* 本体无接口增加CP1W-CIF41网络板卡
* FINS协议PLC IP192.168.250.31Port9600
## 存储区
- 存储区 WD区。
## JSON配方设计
* 共测试BOOLINT16共2种类型数据,以下为JSON文件解释。
- ```json
{
"device_id": 1, //设备ID默认是1此参数无效
"device_name": "CP1L", //设备名称,自定义
"communication_type": 0, //通讯协议类型 0是以太网1是串口
"socket_config": { //以太网配置
"plc_ip": "192.168.250.31", //PLC的IP地址
"local_ip": "192.168.250.233", //矽达通IP地址设定
"gateway": "192.168.250.1", //矽达通的网关地址设定
"netmask": "255.255.255.0", //矽达通子网掩码设定
"port": 9600 //端口号设定
},
"protocol_type": 5, //通讯协议5代表FINS协议
"read_period": 100, //交互周期ms
"read_item_list": [
{
"value_name": "停止", //变量名称,自定义
"value_type": 1, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"area_char": "W", //变量功能块
"data_type": 0, //数据传输类型BOOL = 0,WORD = 1
"start_address": 100, //起始地址
"bit_address": 1, //BOOL地址偏移位采集变量地址是W100.1
"data_length": 1 //BOOL长度默认是1代表读取1个BOOL长度
},
{
"value_name": "转速", //变量名称,自定义
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"area_char": "D", //变量功能块
"data_type": 1, //数据传输类型BOOL = 0,WORD = 1
"start_address": 101, //起始地址
"bit_address": 0, //以WORD采集方式时此参数无效采集变量地址是D101
"data_length": 1 //WORD长度默认是1代表读取1个WORD长度2个字节
}
]
}
```
## 通信测试
(1) 新增1个通信demo命名为omron_cp1l.c
(2) 复制样例代码程序到omron_cp1l.c文件中
(3) void **ControlOmronCP1LTest**(void) 更改函数名;
(4) PRIV_SHELL_CMD_FUNCTION(**ControlOmronCP1LTest**, **Omron Plc Cp1l Demo**, PRIV_SHELL_CMD_MAIN_ATTR);更改测试指令;
(5) 剪裁配置完成后,用过烧写器下载至矽达通中,重启后完成测试。

View File

@ -18,6 +18,32 @@
* @date 2022.9.27
*/
#include <control.h>
void ControlOmronTest(void)
{
int i = 0;
uint16_t read_data_length = 0;
uint8_t read_data[1024] = {0};
ControlProtocolType fins_protocol = ControlProtocolFind();
if (NULL == fins_protocol) {
printf("%s get fins protocol %p failed\n", __func__, fins_protocol);
return;
}
printf("%s get fins protocol %p successfull\n", __func__, fins_protocol);
if (CONTROL_REGISTERED == fins_protocol->protocol_status) {
ControlProtocolOpen(fins_protocol);
for (;;) {
read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data));
printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length);
i++;
PrivTaskDelay(100000);
}
//ControlProtocolClose(fins_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlOmronTest, Omron Plc FINS Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file omron_cp1h.c
* @brief PLC OMRON CP1H app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.4.1
*/
#include <control.h>
void ControlOmronCP1HTest(void)
{
int i = 0;
uint16_t read_data_length = 0;
uint8_t read_data[1024] = {0};
ControlProtocolType fins_protocol = ControlProtocolFind();
if (NULL == fins_protocol) {
printf("%s get fins protocol %p failed\n", __func__, fins_protocol);
return;
}
printf("%s get fins protocol %p successfull\n", __func__, fins_protocol);
if (CONTROL_REGISTERED == fins_protocol->protocol_status) {
ControlProtocolOpen(fins_protocol);
for (;;) {
read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data));
printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length);
i++;
PrivTaskDelay(100000);
}
//ControlProtocolClose(fins_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlOmronCP1HTest, Omron Plc Cp1h Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file omron_.cp1l.c
* @brief PLC OMRON CP1L app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.2.10
*/
#include <control.h>
void ControlOmronCP1LTest(void)
{
int i = 0;
uint16_t read_data_length = 0;
uint8_t read_data[1024] = {0};
ControlProtocolType fins_protocol = ControlProtocolFind();
if (NULL == fins_protocol) {
printf("%s get fins protocol %p failed\n", __func__, fins_protocol);
return;
}
printf("%s get fins protocol %p successfull\n", __func__, fins_protocol);
if (CONTROL_REGISTERED == fins_protocol->protocol_status) {
ControlProtocolOpen(fins_protocol);
for (;;) {
read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data));
printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length);
i++;
PrivTaskDelay(100000);
}
//ControlProtocolClose(fins_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlOmronCP1LTest, Omron Plc Cp1l Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -18,6 +18,34 @@
* @date 2022.9.27
*/
#include <control.h>
void ControlOmronNX102Test(void)
{
int i = 0;
uint16_t read_data_length = 0;
uint8_t read_data[1024] = {0};
ControlProtocolType fins_protocol = ControlProtocolFind();
if (NULL == fins_protocol) {
printf("%s get fins protocol %p failed\n", __func__, fins_protocol);
return;
}
printf("%s get fins protocol %p successfull\n", __func__, fins_protocol);
if (CONTROL_REGISTERED == fins_protocol->protocol_status) {
ControlProtocolOpen(fins_protocol);
for (;;) {
read_data_length = ControlProtocolRead(fins_protocol, read_data, sizeof(read_data));
printf("%s read [%d] fins data %d using receipe file\n", __func__, i, read_data_length);
i++;
PrivTaskDelay(10000);
}
// ControlProtocolClose(fins_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlOmronNX102Test, Omron Plc FINS Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,70 @@
{
"device_id": 1,
"device_name": "CP1H",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.46",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 9600
},
"protocol_type": 5,
"read_period": 100,
"read_item_list": [
{
"value_name": "启动",
"value_type": 1,
"area_char": "W",
"data_type": 0,
"start_address": 10,
"bit_address": 0,
"data_length": 1
},
{
"value_name": "停止",
"value_type": 1,
"area_char": "W",
"data_type": 0,
"start_address": 10,
"bit_address": 1,
"data_length": 1
},
{
"value_name": "暂停",
"value_type": 1,
"area_char": "W",
"data_type": 0,
"start_address": 10,
"bit_address": 2,
"data_length": 1
},
{
"value_name": "整型1",
"value_type": 3,
"area_char": "D",
"data_type": 1,
"start_address": 100,
"bit_address": 0,
"data_length": 1
},
{
"value_name": "整型2",
"value_type": 3,
"area_char": "D",
"data_type": 1,
"start_address": 101,
"bit_address": 0,
"data_length": 1
},
{
"value_name": "浮点",
"value_type": 9,
"area_char": "D",
"data_type": 1,
"start_address": 110,
"bit_address": 0,
"data_length": 2
}
]
}

View File

@ -0,0 +1,52 @@
{
"device_id": 1,
"device_name": "CP1L",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.31",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 9600
},
"protocol_type": 5,
"read_period": 100,
"read_item_list": [
{
"value_name": "启动",
"value_type": 1,
"area_char": "W",
"data_type": 0,
"start_address": 100,
"bit_address": 0,
"data_length": 1
},
{
"value_name": "停止",
"value_type": 1,
"area_char": "W",
"data_type": 0,
"start_address": 100,
"bit_address": 1,
"data_length": 1
},
{
"value_name": "转速",
"value_type": 3,
"area_char": "D",
"data_type": 1,
"start_address": 101,
"bit_address": 0,
"data_length": 1
},
{
"value_name": "产量",
"value_type": 3,
"area_char": "D",
"data_type": 1,
"start_address": 102,
"bit_address": 0,
"data_length": 1
}
]
}

View File

@ -0,0 +1,30 @@
{
"device_id": 1,
"device_name": "m241",
"communication_type": 1,
"serial_config": {
"station": 1,
"baud_rate": 9600,
"data_bits": 8,
"stop_bits": 1,
"check_mode": 3
},
"protocol_type": 3,
"read_period": 100,
"read_item_list": [
{
"value_name": "MW0",
"value_type": 3,
"function_code": 3,
"start_address": 0,
"quantity": 1
},
{
"value_name": "MW1",
"value_type": 3,
"function_code": 3,
"start_address": 1,
"quantity": 1
}
]
}

View File

@ -15,9 +15,47 @@
* @brief PLC SCHNEIDER M241 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
* @date 2023.2.1
*/
#include <control.h>
void ControlM241Test(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
#ifdef CONNECTION_ADAPTER_4G
Adapter4GActive();
#endif
ControlProtocolType modbus_rtu_protocol = ControlProtocolFind();
if (NULL == modbus_rtu_protocol) {
printf("%s get modbus rtu protocol %p failed\n", __func__, modbus_rtu_protocol);
return;
}
printf("%s get modbus rtu protocol %p successfull\n", __func__, modbus_rtu_protocol);
if (CONTROL_REGISTERED == modbus_rtu_protocol->protocol_status) {
ControlProtocolOpen(modbus_rtu_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_rtu_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus rtu data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_rtu_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlM241Test, Schneider M241 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,79 @@
# SIEMENS - S7-1512通信测试
[TOC]
## 通信接线及参数设置
* 本体以太网口
* S7协议PLC IP192.168.250.2Port102
## 存储区
- 存储区 QDB区。
## JSON配方设计
* 共测试BOOLINT16共2种类型数据,以下为JSON文件解释。
- ```json
{
"device_id": 1, //设备ID默认是1此参数无效
"device_name": "S7-1512", //设备名称,自定义
"communication_type": 0, //通讯协议类型 0是以太网1是串口
"socket_config": { //以太网配置
"plc_ip": "192.168.250.2", //PLC的IP地址
"local_ip": "192.168.250.233", //矽达通IP地址设定
"gateway": "192.168.250.1", //矽达通的网关地址设定
"netmask": "255.255.255.0", //矽达通子网掩码设定
"port": 102 //端口号设定
},
"protocol_type": 1, //通讯协议5代表FINS协议
"read_period": 100, //交互周期ms
"read_item_list": [
{
"value_name": "布尔1", //变量名称,自定义
"value_type": 1, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"area": "Q", //变量功能块
"wordlen": "Bit", //变量字长类型,有Bit Byte Word DWord Real Counter Timer
"db_number": 1, //如为DB区填写对应的DB块编号,如不是DB区无效
"start": 1, //BOOL地址偏移位采集变量地址是Q0.1
"amount": 1 //BOOL长度默认是1代表读取1个BOOL长度
},
{
"value_name": "整型", //变量名称,自定义
"value_type": 3, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"area": "DB", //变量功能块
"wordlen": "Word", //变量字长类型,有Bit Byte Word DWord Real Counter Timer
"db_number": 18, //如为DB区即DB18块
"start": 2, //Word地址偏移位采集变量地址是DB18.DBW2
"amount": 1 //Word长度默认是1代表读取1个WORD长度2个字节
},
{
"value_name": "浮点数", //变量名称,自定义
"value_type": 9, //变量类型BOOL = 1,INT8 = 2,INT16,INT32,UINT8,UINT16,UINT32,DOUBLE,FLOAT = 9
"area": "DB", //变量功能块
"wordlen": "Real", //变量字长类型,有Bit Byte Word DWord Real Counter Timer
"db_number": 18, //如为DB区即DB18块
"start": 18, //Real地址偏移位采集变量地址是DB18.DBD18
"amount": 1 //Real长度默认是1代表读取1个Real长度4个字节
}
]
}
```
## 通信测试
(1) 新增1个通信demo命名为simens_s7_1500.c
(2) 复制样例代码程序到simens_s7_1500.c文件中
(3) void **ControlS71500Test**(void)更改函数名;
(4) PRIV_SHELL_CMD_FUNCTION(**ControlS71500Test, Siemens Plc S7_1512 Demo**, PRIV_SHELL_CMD_MAIN_ATTR);更改测试指令;
(5) 剪裁配置完成后,用过烧写器下载至矽达通中,重启后完成测试。

View File

@ -15,9 +15,6 @@
* @brief PLC SIEMENS S7-1200 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
* @date 2023.3.27
*/

View File

@ -15,9 +15,31 @@
* @brief PLC SIEMENS S7-1500 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
* @date 2023.3.27
*/
#include <control.h>
void ControlS71500Test(void)
{
int i = 0;
uint16_t read_data_length = 0;
uint8_t read_data[1024] = {0};
ControlProtocolType s7_protocol = ControlProtocolFind();
if (NULL == s7_protocol) {
printf("%s get s7 protocol %p failed\n", __func__, s7_protocol);
return;
}
printf("%s get s7 protocol %p successfull\n", __func__, s7_protocol);
if (CONTROL_REGISTERED == s7_protocol->protocol_status) {
ControlProtocolOpen(s7_protocol);
for (;;) {
read_data_length = ControlProtocolRead(s7_protocol, read_data, sizeof(read_data));
printf("%s read [%d] s7 data %d using receipe file\n", __func__, i, read_data_length);
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
}
}
PRIV_SHELL_CMD_FUNCTION(ControlS71500Test, Siemens Plc S7_1512 Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -11,13 +11,10 @@
*/
/**
* @file siemens_s7_200_smart.c
* @brief PLC SIEMENS S7-200 SMART app
* @file siemens_s7_200 smart.c
* @brief PLC SIEMENS S7-200 smart app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
* @date 2023.3.27
*/

View File

@ -15,9 +15,6 @@
* @brief PLC SIEMENS S7-300 app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2022.9.27
* @date 2023.3.27
*/

View File

@ -0,0 +1,70 @@
{
"device_id": 1,
"device_name": "S7-1512",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.2",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.252",
"netmask": "255.255.255.0",
"port": 102
},
"protocol_type": 1,
"read_period": 100,
"read_item_list": [
{
"value_name": "布尔1",
"value_type": 1,
"area": "Q",
"wordlen": "Bit",
"db_number": 1,
"start": 1,
"amount": 1
},
{
"value_name": "布尔2",
"value_type": 1,
"area": "Q",
"wordlen": "Bit",
"db_number": 1,
"start": 2,
"amount": 1
},
{
"value_name": "布尔3",
"value_type": 1,
"area": "Q",
"wordlen": "Bit",
"db_number": 1,
"start": 3,
"amount": 1
},
{
"value_name": "布尔4",
"value_type": 1,
"area": "Q",
"wordlen": "Bit",
"db_number": 1,
"start": 4,
"amount": 1
},
{
"value_name": "整型",
"value_type": 3,
"area": "DB",
"wordlen": "Word",
"db_number": 18,
"start": 2,
"amount": 1
},
{
"value_name": "浮点数",
"value_type": 9,
"area": "DB",
"wordlen": "Real",
"db_number": 18,
"start": 18,
"amount": 1
}
]
}

View File

@ -0,0 +1,3 @@
SRC_FILES := xdh_60t4_e.c xsdh_60a32_e.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,184 @@
{
"device_id": 1,
"device_name": "OP01",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.32",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 502
},
"protocol_type": 2,
"read_period": 100,
"read_item_list": [
{
"value_name": "M19",
"value_type": 1,
"function_code": 5,
"start_address": 19,
"quantity": 1
},
{
"value_name": "M20",
"value_type": 1,
"function_code": 5,
"start_address":20,
"quantity": 1
},
{
"value_name": "D500",
"value_type": 4,
"function_code": 6,
"start_address": 500,
"quantity": 1
},
{
"value_name": "D501",
"value_type": 4,
"function_code": 6,
"start_address": 501,
"quantity": 1
},
{
"value_name": "D502",
"value_type": 4,
"function_code": 6,
"start_address": 502,
"quantity": 1
},
{
"value_name": "D503",
"value_type": 4,
"function_code": 6,
"start_address": 503,
"quantity": 1
},
{
"value_name": "D504",
"value_type": 4,
"function_code": 6,
"start_address": 504,
"quantity": 1
},
{
"value_name": "M22",
"value_type": 1,
"function_code": 5,
"start_address": 22,
"quantity": 1
},
{
"value_name": "D505",
"value_type": 4,
"function_code": 6,
"start_address": 505,
"quantity": 1
},
{
"value_name": "D506",
"value_type": 4,
"function_code": 6,
"start_address": 506,
"quantity": 1
},
{
"value_name": "D507",
"value_type": 4,
"function_code": 6,
"start_address": 507,
"quantity": 1
},
{
"value_name": "D508",
"value_type": 4,
"function_code": 6,
"start_address": 508,
"quantity": 1
},
{
"value_name": "D509",
"value_type": 4,
"function_code": 6,
"start_address": 509,
"quantity": 1
},
{
"value_name": "D510",
"value_type": 4,
"function_code": 6,
"start_address": 510,
"quantity": 1
},
{
"value_name": "D511",
"value_type": 4,
"function_code": 6,
"start_address": 511,
"quantity": 1
},
{
"value_name": "M23",
"value_type": 1,
"function_code": 5,
"start_address": 23,
"quantity": 1
},
{
"value_name": "M24",
"value_type": 1,
"function_code": 5,
"start_address":24,
"quantity": 1
},
{
"value_name": "M25",
"value_type": 1,
"function_code": 5,
"start_address": 25,
"quantity": 1
},
{
"value_name": "M26",
"value_type": 1,
"function_code": 5,
"start_address": 26,
"quantity": 1
},
{
"value_name": "M29",
"value_type": 1,
"function_code": 5,
"start_address": 29,
"quantity": 1
},
{
"value_name": "D513",
"value_type": 4,
"function_code": 3,
"start_address": 513,
"quantity": 1
},
{
"value_name": "D515",
"value_type": 4,
"function_code": 3,
"start_address": 515,
"quantity": 1
},
{
"value_name": "M27",
"value_type": 1,
"function_code": 1,
"start_address":27,
"quantity": 1
},
{
"value_name": "M28",
"value_type": 1,
"function_code": 1,
"start_address":28,
"quantity": 1
}
]
}

View File

@ -0,0 +1,93 @@
{
"device_id": 255,
"device_name": "GJ2",
"communication_type": 0,
"socket_config": {
"plc_ip": "192.168.250.45",
"local_ip": "192.168.250.233",
"gateway": "192.168.250.1",
"netmask": "255.255.255.0",
"port": 502
},
"protocol_type": 2,
"read_period": 100,
"read_item_list": [
{
"value_name": "QX40.0",
"value_type": 1,
"function_code": 1,
"start_address":0,
"quantity": 1
},
{
"value_name": "QX40.1",
"value_type": 1,
"function_code": 1,
"start_address": 1,
"quantity": 1
},
{
"value_name": "QX40.2",
"value_type": 1,
"function_code": 1,
"start_address": 2,
"quantity": 1
},
{
"value_name": "QX40.3",
"value_type": 1,
"function_code": 1,
"start_address":3,
"quantity": 1
},
{
"value_name": "QX40.4",
"value_type": 1,
"function_code": 1,
"start_address": 4,
"quantity": 1
},
{
"value_name": "QW0",
"value_type": 3,
"function_code": 3,
"start_address": 0,
"quantity": 2
},
{
"value_name": "QW1",
"value_type": 3,
"function_code": 3,
"start_address": 1,
"quantity": 2
},
{
"value_name": "QW2",
"value_type": 3,
"function_code": 3,
"start_address": 2,
"quantity": 2
},
{
"value_name": "QW3",
"value_type": 3,
"function_code": 3,
"start_address": 3,
"quantity": 2
},
{
"value_name": "QW10",
"value_type": 3,
"function_code": 4,
"start_address": 0,
"quantity": 2
},
{
"value_name": "QW11",
"value_type": 3,
"function_code": 4,
"start_address": 1,
"quantity": 2
}
]
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file xdh-60t4-e.c
* @brief PLC XINJE XDH-60T4-E app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.4.5
*/
#include <control.h>
void ControlXDHTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlXDHTest, Xinje Plc XDH_60T4_E Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) 2022 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file xsdh-60a32-e.c
* @brief PLC XINJE XSDH-60A32-E app
* @version 3.0
* @author AIIT XUOS Lab
* @date 2023.3.28
*/
#include <control.h>
void ControlXSDHTest(void)
{
int i, j = 0;
int read_data_length = 0;
uint8_t read_data[128] = {0};
ControlProtocolType modbus_tcp_protocol = ControlProtocolFind();
if (NULL == modbus_tcp_protocol) {
printf("%s get modbus tcp protocol %p failed\n", __func__, modbus_tcp_protocol);
return;
}
printf("%s get modbus tcp protocol %p successfull\n", __func__, modbus_tcp_protocol);
if (CONTROL_REGISTERED == modbus_tcp_protocol->protocol_status) {
ControlProtocolOpen(modbus_tcp_protocol);
for (;;) {
read_data_length = ControlProtocolRead(modbus_tcp_protocol, read_data, sizeof(read_data));
printf("%s read [%d] modbus tcp data %d using receipe file\n", __func__, i, read_data_length);
if (read_data_length) {
for (j = 0; j < read_data_length; j ++) {
printf("j %d data 0x%x\n", j, read_data[j]);
}
}
i++;
memset(read_data, 0, sizeof(read_data));
PrivTaskDelay(10000);
}
//ControlProtocolClose(modbus_tcp_protocol);
}
}
PRIV_SHELL_CMD_FUNCTION(ControlXSDHTest, Xinje Plc XSDH_60A32_E Demo, PRIV_SHELL_CMD_MAIN_ATTR);

View File

@ -1,3 +1,3 @@
SRC_DIR := list
SRC_DIR := list circular_area
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,11 @@
include $(KERNEL_ROOT)/.config
ifeq ($(CONFIG_ADD_NUTTX_FETURES),y)
include $(APPDIR)/Make.defs
CSRCS += circular_area_app.c
include $(APPDIR)/Application.mk
endif
ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
SRC_FILES := circular_area_app.c
include $(KERNEL_ROOT)/compiler.mk
endif

View File

@ -0,0 +1,11 @@
import os
from building import *
Import('RTT_ROOT')
Import('rtconfig')
cwd = GetCurrentDir()
DEPENDS = [""]
SOURCES = ['circular_area_app.c']
path = [cwd]
objs = DefineGroup('circular_area', src = SOURCES, depend = DEPENDS,CPPPATH = path)
Return("objs")

View File

@ -0,0 +1,281 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: circular_area_app.c
* @brief: circular area file for applications
* @version: 3.0
* @author: AIIT XUOS Lab
* @date: 2022/11/21
*
*/
#include "circular_area_app.h"
/**
* This function will return whether the circular_area is full or not
*
* @param circular_area CircularAreaApp descriptor
*/
int CircularAreaAppIsFull(CircularAreaAppType circular_area)
{
CA_PARAM_CHECK(circular_area);
if((circular_area->readidx == circular_area->writeidx) && (circular_area->b_status)) {
printf("the circular area is full\n");
return 1;
} else {
return 0;
}
}
/**
* This function will return whether the circular_area is empty or not
*
* @param circular_area CircularAreaApp descriptor
*/
int CircularAreaAppIsEmpty(CircularAreaAppType circular_area)
{
CA_PARAM_CHECK(circular_area);
if((circular_area->readidx == circular_area->writeidx) && (!circular_area->b_status)) {
//printf("the circular area is empty\n");
return 1;
} else {
return 0;
}
}
/**
* This function will reset the circular_area and set the descriptor to default
*
* @param circular_area CircularAreaApp descriptor
*/
void CircularAreaAppReset(CircularAreaAppType circular_area)
{
circular_area->writeidx = 0;
circular_area->readidx = 0;
circular_area->b_status = 0;
}
/**
* This function will release the circular_area descriptor and free the memory
*
* @param circular_area CircularAreaApp descriptor
*/
void CircularAreaAppRelease(CircularAreaAppType circular_area)
{
circular_area->readidx = 0;
circular_area->writeidx = 0;
circular_area->p_head = NULL;
circular_area->p_tail = NULL;
circular_area->b_status = 0;
circular_area->area_length = 0;
PrivFree(circular_area->data_buffer);
PrivFree(circular_area);
}
/**
* This function will get the circual_area max length
*
* @param circular_area CircularAreaApp descriptor
*/
uint32_t CircularAreaAppGetMaxLength(CircularAreaAppType circular_area)
{
CA_PARAM_CHECK(circular_area);
return circular_area->area_length;
}
/**
* This function will get the data length of the circular_area
*
* @param circular_area CircularAreaApp descriptor
*/
uint32_t CircularAreaAppGetDataLength(CircularAreaAppType circular_area)
{
CA_PARAM_CHECK(circular_area);
if(CircularAreaAppIsFull(circular_area)) {
return circular_area->area_length;
} else {
return (circular_area->writeidx - circular_area->readidx + circular_area->area_length) % circular_area->area_length;
}
}
/**
* This function will return whether it is need to divide the read data into two parts or not
*
* @param circular_area CircularAreaApp descriptor
* @param data_length output data length
*/
static uint32_t CircularAreaAppDivideRdData(CircularAreaAppType circular_area, uint32_t data_length)
{
CA_PARAM_CHECK(circular_area);
if(circular_area->readidx + data_length <= circular_area->area_length) {
return 0;
} else {
return 1;
}
}
/**
* This function will return whether it is need to divide the write data into two parts or not
*
* @param circular_area CircularAreaApp descriptor
* @param data_length input data length
*/
static uint32_t CircularAreaAppDivideWrData(CircularAreaAppType circular_area, uint32_t data_length)
{
CA_PARAM_CHECK(circular_area);
if(circular_area->writeidx + data_length <= circular_area->area_length) {
return 0;
} else {
return 1;
}
}
/**
* This function will read data from the circular_area
*
* @param circular_area CircularAreaApp descriptor
* @param output_buffer output data buffer poniter
* @param data_length output data length
*/
int CircularAreaAppRead(CircularAreaAppType circular_area, uint8_t *output_buffer, uint32_t data_length)
{
CA_PARAM_CHECK(circular_area);
CA_PARAM_CHECK(output_buffer);
CA_CHECK(data_length > 0);
if(CircularAreaAppIsEmpty(circular_area)) {
return -1;
}
int read_length = (data_length > CircularAreaAppGetDataLength(circular_area)) ? CircularAreaAppGetDataLength(circular_area) : data_length;
// if (data_length > CircularAreaAppGetDataLength(circular_area)) {
// return -1;
// }
if(CircularAreaAppDivideRdData(circular_area, read_length)) {
uint32_t read_len_up = circular_area->area_length - circular_area->readidx;
uint32_t read_len_down = read_length - read_len_up;
memcpy(output_buffer, &circular_area->data_buffer[circular_area->readidx], read_len_up);
memcpy(output_buffer + read_len_up, circular_area->p_head, read_len_down);
circular_area->readidx = read_len_down;
} else {
memcpy(output_buffer, &circular_area->data_buffer[circular_area->readidx], read_length);
circular_area->readidx = (circular_area->readidx + read_length) % circular_area->area_length;
}
circular_area->b_status = 0;
return read_length;
}
/**
* This function will write data to the circular_area
*
* @param circular_area CircularAreaApp descriptor
* @param input_buffer input data buffer poniter
* @param data_length input data length
* @param b_force whether to force to write data disregard the length limit
*/
int CircularAreaAppWrite(CircularAreaAppType circular_area, uint8_t *input_buffer, uint32_t data_length, int b_force)
{
CA_PARAM_CHECK(circular_area);
CA_PARAM_CHECK(input_buffer);
CA_CHECK(data_length > 0);
if(CircularAreaAppIsFull(circular_area) && (!b_force)) {
return -1;
}
uint32_t write_data_length = circular_area->area_length - CircularAreaAppGetDataLength(circular_area);
//data_length = (data_length > write_data_length) ? write_data_length : data_length;
if (data_length > write_data_length) {
return -1;
}
if(CircularAreaAppDivideWrData(circular_area, data_length)) {
uint32_t write_len_up = circular_area->area_length - circular_area->writeidx;
uint32_t write_len_down = data_length - write_len_up;
memcpy(&circular_area->data_buffer[circular_area->writeidx], input_buffer, write_len_up);
memcpy(circular_area->p_head, input_buffer + write_len_up, write_len_down);
circular_area->writeidx = write_len_down;
} else {
memcpy(&circular_area->data_buffer[circular_area->writeidx], input_buffer, data_length);
circular_area->writeidx = (circular_area->writeidx + data_length) % circular_area->area_length;
}
circular_area->b_status = 1;
if(b_force) {
circular_area->readidx = circular_area->writeidx;
}
return 0;
}
static struct CircularAreaAppOps CircularAreaAppOperations =
{
CircularAreaAppRead,
CircularAreaAppWrite,
CircularAreaAppRelease,
CircularAreaAppReset,
};
/**
* This function will initialize the circular_area
*
* @param circular_area_length circular_area length
*/
CircularAreaAppType CircularAreaAppInit(uint32_t circular_area_length)
{
CA_CHECK(circular_area_length > 0);
circular_area_length = CA_ALIGN_DOWN(circular_area_length, 8);
CircularAreaAppType circular_area = PrivMalloc(sizeof(struct CircularAreaApp));
if(NULL == circular_area) {
printf("CircularAreaAppInit malloc struct circular_area failed\n");
PrivFree(circular_area);
return NULL;
}
CircularAreaAppReset(circular_area);
circular_area->data_buffer = PrivMalloc(circular_area_length);
if(NULL == circular_area->data_buffer) {
printf("CircularAreaAppInit malloc circular_area data_buffer failed\n");
PrivFree(circular_area->data_buffer);
return NULL;
}
circular_area->p_head = circular_area->data_buffer;
circular_area->p_tail = circular_area->data_buffer + circular_area_length;
circular_area->area_length = circular_area_length;
printf("CircularAreaAppInit done p_head %8p p_tail %8p length %u\n",
circular_area->p_head, circular_area->p_tail, circular_area->area_length);
circular_area->CircularAreaAppOperations = &CircularAreaAppOperations;
return circular_area;
}

View File

@ -0,0 +1,109 @@
/*
* Copyright (c) 2020 AIIT XUOS Lab
* XiUOS is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
/**
* @file: circular_area_app.h
* @brief: function declaration and structure defintion of circular area for applications
* @version: 3.0
* @author: AIIT XUOS Lab
* @date: 2022/11/21
*
*/
#ifndef CIRCULAR_AREA_APP_H
#define CIRCULAR_AREA_APP_H
#include <string.h>
#include <transform.h>
#ifdef __cplusplus
extern "C" {
#endif
#define CA_CHECK(TRUE_CONDITION) \
do \
{ \
if(!(TRUE_CONDITION)) { \
printf("%s CHECK condition is false at line[%d] of [%s] func.\n", #TRUE_CONDITION, __LINE__, __func__);\
while(1); \
} \
}while (0)
#define CA_PARAM_CHECK(param) \
do \
{ \
if(param == NULL) { \
printf("PARAM CHECK FAILED ...%s %d %s is NULL.\n", __func__, __LINE__, #param); \
while(1); \
} \
}while (0)
#define CA_ALIGN_DOWN(size, align) ((size)/(align)*(align))
typedef struct CircularAreaApp *CircularAreaAppType;
struct CircularAreaAppOps
{
int (*read) (CircularAreaAppType circular_area, uint8_t *output_buffer, uint32_t data_length);
int (*write) (CircularAreaAppType circular_area, uint8_t *input_buffer, uint32_t data_length, int b_force);
void (*release) (CircularAreaAppType circular_area);
void (*reset) (CircularAreaAppType circular_area);
};
struct CircularAreaApp
{
uint8_t *data_buffer;
uint32_t readidx;
uint32_t writeidx;
uint8_t *p_head;
uint8_t *p_tail;
uint32_t area_length;
int b_status;
struct CircularAreaAppOps *CircularAreaAppOperations;
};
/*This function will return whether the circular_area is full or not*/
int CircularAreaAppIsFull(CircularAreaAppType circular_area);
/*This function will return whether the circular_area is empty or not*/
int CircularAreaAppIsEmpty(CircularAreaAppType circular_area);
/*This function will reset the circular_area and set the descriptor to default*/
void CircularAreaAppReset(CircularAreaAppType circular_area);
/*This function will release the circular_area descriptor and free the memory*/
void CircularAreaAppRelease(CircularAreaAppType circular_area);
/*This function will read data from the circular_area*/
int CircularAreaAppRead(CircularAreaAppType circular_area, uint8_t *output_buffer, uint32_t data_length);
/*This function will write data to the circular_area*/
int CircularAreaAppWrite(CircularAreaAppType circular_area, uint8_t *input_buffer, uint32_t data_length, int b_force);
/*This function will get the circual_area max length*/
uint32_t CircularAreaAppGetMaxLength(CircularAreaAppType circular_area);
/*This function will get the data length of the circular_area*/
uint32_t CircularAreaAppGetDataLength(CircularAreaAppType circular_area);
/*This function will initialize the circular_area*/
CircularAreaAppType CircularAreaAppInit(uint32_t circular_area_length);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,3 +1,15 @@
SRC_DIR := mnist
SRC_DIR :=
ifeq ($(CONFIG_APP_MNIST),y)
SRC_DIR += mnist
endif
ifeq ($(CONFIG_USING_NNOM_DEMOAPP),y)
SRC_DIR += nnom_demo
endif
ifeq ($(CONFIG_USING_CMSIS_5_DEMOAPP),y)
SRC_DIR += cmsis_5_demo
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,11 @@
SRC_DIR :=
ifeq ($(CONFIG_USING_CMSIS_5_NN_DEMOAPP),y)
SRC_DIR += cmsisnn-cifar10
endif
ifeq ($(CONFIG_USING_CMSIS_5_NN_DEMOAPP_VEG_CLASSIFY),y)
SRC_DIR += cmsisnn_vegetable_classify
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,3 @@
SRC_FILES := demo/cmsisnn_demo.c demo/tjpgd.c model/m4/nn.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,3 @@
# ISSUE
Code in Lib `tjpgd` might be redefined in RT-thread(which has not been tested). if occurs, please try to temporarily delete `tjpgd.c` in dir and `tjpgd.h` in ../model/m4/.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
/*----------------------------------------------------------------------------/
/ TJpgDec - Tiny JPEG Decompressor include file (C)ChaN, 2019
/----------------------------------------------------------------------------*/
#ifndef DEF_TJPGDEC
#define DEF_TJPGDEC
/*---------------------------------------------------------------------------*/
/* System Configurations */
#define JD_SZBUF 512 /* Size of stream input buffer */
#define JD_FORMAT 1 /* Output pixel format 0:RGB888 (3 BYTE/pix), 1:RGB565 (1 WORD/pix) */
#define JD_USE_SCALE 1 /* Use descaling feature for output */
#define JD_TBLCLIP 1 /* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */
#define JD_SCALE 2 /* 0:1/1 1:1/2 2:1/4 3:1/8 */
/*---------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32) /* Main development platform */
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef short int16_t;
typedef unsigned long uint32_t;
typedef long int32_t;
#else
#include "stdint.h"
#endif
/* Error code */
typedef enum
{
JDR_OK = 0, /* 0: Succeeded */
JDR_INTR, /* 1: Interrupted by output function */
JDR_INP, /* 2: Device error or wrong termination of input stream */
JDR_MEM1, /* 3: Insufficient memory pool for the image */
JDR_MEM2, /* 4: Insufficient stream input buffer */
JDR_PAR, /* 5: Parameter error */
JDR_FMT1, /* 6: Data format error (may be damaged data) */
JDR_FMT2, /* 7: Right format but not supported */
JDR_FMT3 /* 8: Not supported JPEG standard */
} JRESULT;
/* Rectangular structure */
typedef struct
{
uint16_t left, right, top, bottom;
} JRECT;
/* Decompressor object structure */
typedef struct JDEC JDEC;
struct JDEC
{
uint16_t dctr; /* Number of bytes available in the input buffer */
uint8_t *dptr; /* Current data read ptr */
uint8_t *inbuf; /* Bit stream input buffer */
uint8_t dmsk; /* Current bit in the current read byte */
uint8_t scale; /* Output scaling ratio */
uint8_t msx, msy; /* MCU size in unit of block (width, height) */
uint8_t qtid[3]; /* Quantization table ID of each component */
int16_t dcv[3]; /* Previous DC element of each component */
uint16_t nrst; /* Restart inverval */
uint16_t width, height; /* Size of the input image (pixel) */
uint8_t *huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */
uint16_t *huffcode[2][2]; /* Huffman code word tables [id][dcac] */
uint8_t *huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */
int32_t *qttbl[4]; /* Dequantizer tables [id] */
void *workbuf; /* Working buffer for IDCT and RGB output */
uint8_t *mcubuf; /* Working buffer for the MCU */
void *pool; /* Pointer to available memory pool */
uint16_t sz_pool; /* Size of momory pool (bytes available) */
uint16_t (*infunc)(JDEC *, uint8_t *, uint16_t); /* Pointer to jpeg stream input function */
void *device; /* Pointer to I/O device identifiler for the session */
};
/* TJpgDec API functions */
JRESULT jd_prepare (JDEC *, uint16_t(*)(JDEC *, uint8_t *, uint16_t), void *, uint16_t, void *);
JRESULT jd_decomp (JDEC *, uint16_t(*)(JDEC *, void *, JRECT *), uint8_t);
#ifdef __cplusplus
}
#endif
#endif /* _TJPGDEC */

View File

@ -0,0 +1,3 @@
SRC_FILES := cmsisnn_vegetable_classify.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -1,7 +1,9 @@
SRC_FILES :=
ifeq ($(CONFIG_APP_MNIST),y)
SRC_FILES := \
main.cpp \
mnistmain.c
CPPPATHS += -I.
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,5 @@
ifeq ($(CONFIG_USING_NNOM_DEMOAPP),y)
SRC_DIR := mnist_nnom
endif
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,3 @@
SRC_FILES := main.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -71,7 +71,9 @@ void mnist_nnom(int argc, char **argv)
printf("Predicted label: %d\n", predic_label);
printf("Probability: %d%%\n", (int)(prob * 100));
}
#ifdef ADD_XIZI_FETURES
PRIV_SHELL_CMD_FUNCTION(mnist_nnom, a mnist_nnom test sample, PRIV_SHELL_CMD_MAIN_ATTR);
#endif
#ifdef __RT_THREAD_H__
MSH_CMD_EXPORT(mnist_nnom, nnom mnist demo and image number should be followed);
#endif

View File

@ -30,10 +30,10 @@ void HumiHs300x(void)
int32_t humidity;
struct SensorQuantity *humi = SensorQuantityFind(SENSOR_QUANTITY_HS300X_HUMIDITY, SENSOR_QUANTITY_HUMI);
SensorQuantityOpen(humi);
for (i = 0; i < 100; i ++) {
for (i = 0; i < 10; i ++) {
humidity = SensorQuantityReadValue(humi);
printf("Humidity : %d.%d %%RH\n", humidity/10, humidity%10);
PrivTaskDelay(5000);
PrivTaskDelay(500);
}
SensorQuantityClose(humi);
}

View File

@ -30,14 +30,14 @@ void TempHs300x(void)
int32_t temperature;
struct SensorQuantity *temp = SensorQuantityFind(SENSOR_QUANTITY_HS300X_TEMPERATURE, SENSOR_QUANTITY_TEMP);
SensorQuantityOpen(temp);
for (i = 0; i < 100; i ++) {
for (i = 0; i < 10; i ++) {
temperature = SensorQuantityReadValue(temp);
if (temperature > 0)
printf("Temperature : %d.%d ℃\n", temperature/10, temperature%10);
else
printf("Temperature : %d.%d ℃\n", temperature/10, -temperature%10);
PrivTaskDelay(5000);
PrivTaskDelay(500);
}
SensorQuantityClose(temp);

View File

@ -29,7 +29,14 @@ void WindDirectionQsFx(void)
struct SensorQuantity *wind_direction = SensorQuantityFind(SENSOR_QUANTITY_QS_FX_WINDDIRECTION, SENSOR_QUANTITY_WINDDIRECTION);
SensorQuantityOpen(wind_direction);
PrivTaskDelay(2000);
uint16_t result = SensorQuantityReadValue(wind_direction);
printf("wind direction : %d degree\n", result);
int result = 0;
for(int i=0;i<2000;i++)
{
result = 0;
PrivTaskDelay(1000);
result = SensorQuantityReadValue(wind_direction);
if(result > 0)
printf("wind direction : %d degree\n", result);
}
SensorQuantityClose(wind_direction);
}

View File

@ -29,7 +29,14 @@ void WindSpeedQsFs(void)
struct SensorQuantity *wind_speed = SensorQuantityFind(SENSOR_QUANTITY_QS_FS_WINDSPEED, SENSOR_QUANTITY_WINDSPEED);
SensorQuantityOpen(wind_speed);
PrivTaskDelay(2000);
uint16_t result = SensorQuantityReadValue(wind_speed);
printf("wind speed : %d.%d m/s\n", result/10, result%10);
int result = 0;
for(int i=0;i<2000;i++)
{
result = 0;
PrivTaskDelay(1000);
result = SensorQuantityReadValue(wind_speed);
if(result > 0)
printf("wind speed : %d.%d m/s\n", result/10, result%10);
}
SensorQuantityClose(wind_speed);
}

View File

@ -0,0 +1,3 @@
SRC_FILES := ttf_demo.c lv_example_tiny_ttf_1.c lv_example_tiny_ttf_2.c
include $(KERNEL_ROOT)/compiler.mk

View File

@ -0,0 +1,12 @@
## Tiny TTF font engine
用于在触摸屏上渲染矢量字体若要使用该引擎需开启LVGL。
### Usage
在`lv_conf.h`中开启`LV_USE_TINY_TTF`,可以使用`lv_tiny_ttf_create_data(data, data_size, line_height)`创建字体创建字体后像LVGL正常字体一样使用。
默认情况下TTF或者OTF文件必须作为数组嵌入到程序见`ubuntu_font`如果要从sd卡中读取文件需开启`LV_TINY_TTF_FILE_SUPPORT`和`LV_USE_FS_POSIX`。
> 注意从sd卡中读取字库文件会比较慢请谨慎使用
默认情况下字体使用4KB缓存来加速渲染可以使用`lv_tiny_ttf_create_data_ex(data, data_size, line_height, cache_size)`或者`lv_tiny_ttf_create_file_ex(path, line_height, cache_size)`更改此大小
### API
见 xiuos/APP_Framework/lib/lvgl/src/extra/libs/tiny_ttf/lv_tiny_ttf.h

View File

@ -0,0 +1,39 @@
/**
* @file lv_example_tiny_ttf.h
*
*/
#ifndef LV_EXAMPLE_TINY_TTF_H
#define LV_EXAMPLE_TINY_TTF_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* GLOBAL PROTOTYPES
**********************/
void lv_example_tiny_ttf_1(void);
void lv_example_tiny_ttf_2(void);
/**********************
* MACROS
**********************/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_EXAMPLE_TINY_TTF_H*/

View File

@ -0,0 +1,25 @@
#include <../../lib/lvgl/examples/lv_examples.h>
#if LV_USE_TINY_TTF && LV_BUILD_EXAMPLES
#include "ubuntu_font_ch.h"
/**
* Load a font with Tiny_TTF
*/
void lv_example_tiny_ttf_1(void)
{
/*Create style with the new font*/
static lv_style_t style;
lv_style_init(&style);
lv_font_t * font = lv_tiny_ttf_create_data(ubuntu_font, sizeof(ubuntu_font), 35);
lv_style_set_text_font(&style, font);
lv_style_set_text_align(&style, LV_TEXT_ALIGN_CENTER);
/*Create a label with the new style*/
lv_obj_t * label = lv_label_create(lv_scr_act());
lv_obj_add_style(label, &style, 0);
lv_label_set_text(label, "你好世界\nI'm a font\ncreated\nwith Tiny TTF");
lv_obj_center(label);
}
#endif

Some files were not shown because too many files have changed in this diff Show More