From 012fc146cc2eb012c9b79b9a82261eca7fe1c0b5 Mon Sep 17 00:00:00 2001 From: Liu_Weichao Date: Sat, 8 Oct 2022 14:52:16 +0800 Subject: [PATCH 01/14] fix hifive1-emulator compile error : enable work_queen --- Ubiquitous/XiZi_IIoT/board/hifive1-emulator/.defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ubiquitous/XiZi_IIoT/board/hifive1-emulator/.defconfig b/Ubiquitous/XiZi_IIoT/board/hifive1-emulator/.defconfig index 9511edeb5..8280d8f01 100644 --- a/Ubiquitous/XiZi_IIoT/board/hifive1-emulator/.defconfig +++ b/Ubiquitous/XiZi_IIoT/board/hifive1-emulator/.defconfig @@ -140,7 +140,7 @@ CONFIG_SHELL_HELP_SHOW_PERMISSION=y # CONFIG_SHELL_HELP_LIST_VAR is not set # CONFIG_SHELL_HELP_LIST_KEY is not set #CONFIG_KERNEL_QUEUEMANAGE=y -# CONFIG_KERNEL_WORKQUEUE is not set +CONFIG_KERNEL_WORKQUEUE=y CONFIG_WORKQUEUE_KTASK_STACKSIZE=256 CONFIG_WORKQUEUE_KTASK_PRIORITY=2 CONFIG_QUEUE_MAX=2 From 06ed03337aead354bc522eed0e5b7ba1eaa72d9d Mon Sep 17 00:00:00 2001 From: wuzheng Date: Fri, 18 Nov 2022 20:20:34 +0800 Subject: [PATCH 02/14] add camera driver and examples for edu-riscv64 --- APP_Framework/Applications/app_test/Kconfig | 30 + APP_Framework/Applications/app_test/Makefile | 10 +- .../Applications/app_test/test_camera.c | 108 + .../Applications/app_test/test_hwtimer.c | 19 +- .../Applications/app_test/test_touch.c | 30 + .../transform_layer/xizi/transform.c | 1 + .../transform_layer/xizi/transform.h | 21 + APP_Framework/lib/lvgl/lvgl.mk | 5 +- .../XiZi_IIoT/board/edu-riscv64/board.c | 9 +- .../edu-riscv64/third_party_driver/Kconfig | 9 + .../edu-riscv64/third_party_driver/Makefile | 4 + .../third_party_driver/dvp/Kconfig | 46 + .../third_party_driver/dvp/Makefile | 4 + .../third_party_driver/dvp/connect_dvp.c | 242 + .../edu-riscv64/third_party_driver/dvp/dvp.c | 288 + .../third_party_driver/dvp/ov2640.c | 457 ++ .../third_party_driver/gpio/drv_io_config.c | 38 +- .../third_party_driver/include/connect_dvp.h | 15 + .../include/drv_io_config.h | 37 +- .../third_party_driver/include/ov2640.h | 38 + .../third_party_driver/lcd/connect_lcd.c | 13 +- .../third_party_driver/spi/Kconfig | 23 - .../third_party_driver/touch/Kconfig | 4 +- .../third_party_driver/touch/connect_touch.c | 376 +- .../touch/gsl2038firmware.h | 5009 +++++++++++++++++ Ubiquitous/XiZi_IIoT/resources/Kconfig | 6 + Ubiquitous/XiZi_IIoT/resources/Makefile | 4 + .../XiZi_IIoT/resources/camera/Makefile | 5 + .../XiZi_IIoT/resources/camera/bus_camera.c | 123 + .../XiZi_IIoT/resources/camera/dev_camera.c | 200 + .../XiZi_IIoT/resources/camera/drv_camera.c | 68 + Ubiquitous/XiZi_IIoT/resources/include/bus.h | 3 + .../XiZi_IIoT/resources/include/bus_camera.h | 69 + .../XiZi_IIoT/resources/include/dev_camera.h | 69 + .../XiZi_IIoT/resources/include/device.h | 5 + .../XiZi_IIoT/tool/shell/letter-shell/cmd.c | 1 + 36 files changed, 7038 insertions(+), 351 deletions(-) create mode 100644 APP_Framework/Applications/app_test/test_camera.c create mode 100644 APP_Framework/Applications/app_test/test_touch.c create mode 100644 Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/Kconfig create mode 100644 Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/Makefile create mode 100644 Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c create mode 100644 Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/dvp.c create mode 100644 Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/ov2640.c create mode 100644 Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_dvp.h create mode 100644 Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/ov2640.h create mode 100644 Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/gsl2038firmware.h create mode 100644 Ubiquitous/XiZi_IIoT/resources/camera/Makefile create mode 100644 Ubiquitous/XiZi_IIoT/resources/camera/bus_camera.c create mode 100644 Ubiquitous/XiZi_IIoT/resources/camera/dev_camera.c create mode 100644 Ubiquitous/XiZi_IIoT/resources/camera/drv_camera.c create mode 100644 Ubiquitous/XiZi_IIoT/resources/include/bus_camera.h create mode 100644 Ubiquitous/XiZi_IIoT/resources/include/dev_camera.h diff --git a/APP_Framework/Applications/app_test/Kconfig b/APP_Framework/Applications/app_test/Kconfig index e1e9b084e..3b9af83c3 100644 --- a/APP_Framework/Applications/app_test/Kconfig +++ b/APP_Framework/Applications/app_test/Kconfig @@ -105,6 +105,8 @@ menu "test app" 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 @@ -139,6 +141,18 @@ menu "test app" 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" + endif + endif + menuconfig USER_TEST_I2C select BSP_USING_I2C bool "Config test i2c" @@ -151,6 +165,22 @@ menu "test app" 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 diff --git a/APP_Framework/Applications/app_test/Makefile b/APP_Framework/Applications/app_test/Makefile index 28e2f25e5..abf585f31 100644 --- a/APP_Framework/Applications/app_test/Makefile +++ b/APP_Framework/Applications/app_test/Makefile @@ -67,7 +67,15 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y) ifeq ($(CONFIG_USER_TEST_WDT),y) SRC_FILES += test_wdt.c - endif + 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 include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Applications/app_test/test_camera.c b/APP_Framework/Applications/app_test/test_camera.c new file mode 100644 index 000000000..f414dd2ee --- /dev/null +++ b/APP_Framework/Applications/app_test/test_camera.c @@ -0,0 +1,108 @@ +#include +#include +#include + +#define NULL_PARAMETER 0 + +#define DVP_INIT 0x00U +#define REG_SCCB_READ 0x12U +#define REG_SCCB_WRITE 0x13U +#define OUTPUT_CONFIG 0x20U +#define LCD_STRING_TYPE 0 +#define LCD_DOT_TYPE 1 +#define LCD_SIZE 320 + +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); \ No newline at end of file diff --git a/APP_Framework/Applications/app_test/test_hwtimer.c b/APP_Framework/Applications/app_test/test_hwtimer.c index 985d7fac7..d8bd76543 100644 --- a/APP_Framework/Applications/app_test/test_hwtimer.c +++ b/APP_Framework/Applications/app_test/test_hwtimer.c @@ -6,28 +6,23 @@ #define NULL_PARAMETER 0 static uint16_t pinval=0; +static uint16_t pin_fd=0; void ledflip(void *parameter) { - int tmp_fd = *(int*)parameter; struct PinStat pin_led; pin_led.pin = BSP_LED_PIN; pin_led.val = !pinval; pinval = !pinval; - PrivWrite(tmp_fd,&pin_led,NULL_PARAMETER); - printf("Timer has callback once\n"); + PrivWrite(pin_fd,&pin_led,NULL_PARAMETER); + // printf("Timer has callback once:%d\n",pinval); } -void TestHwTimer(int argc, char *argv[]) +void TestHwTimer(void) { x_ticks_t period = 100;//uint:10ms - - if(argc>1){ - period = (x_ticks_t)atoi(argv[1]); - } - - int pin_fd = PrivOpen(HWTIMER_PIN_DEV_DRIVER, O_RDWR); + pin_fd = PrivOpen(HWTIMER_PIN_DEV_DRIVER, O_RDWR); if(pin_fd<0){ printf("open pin fd error:%d\n",pin_fd); return; @@ -52,10 +47,6 @@ void TestHwTimer(int argc, char *argv[]) int32 timer_handle = KCreateTimer("LED on and off by 1s",&ledflip,&pin_fd,period,TIMER_TRIGGER_PERIODIC); KTimerStartRun(timer_handle); - PrivTaskDelay(10000); - KTimerQuitRun(timer_handle); - - KDeleteTimer(timer_handle); } diff --git a/APP_Framework/Applications/app_test/test_touch.c b/APP_Framework/Applications/app_test/test_touch.c new file mode 100644 index 000000000..96dc147af --- /dev/null +++ b/APP_Framework/Applications/app_test/test_touch.c @@ -0,0 +1,30 @@ +#include +#include +#include + +#define NULL_PARAMETER 0 + +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; + } + + // draw text + struct TouchDataStandard touch_pixel; + memset(&touch_pixel,0,sizeof(touch_pixel)); + + 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); + } + PrivClose(touch_fd); +} + +PRIV_SHELL_CMD_FUNCTION(TestTouch, a touch test sample, PRIV_SHELL_CMD_MAIN_ATTR); \ No newline at end of file diff --git a/APP_Framework/Framework/transform_layer/xizi/transform.c b/APP_Framework/Framework/transform_layer/xizi/transform.c index 5f56c6f25..f2d53d155 100644 --- a/APP_Framework/Framework/transform_layer/xizi/transform.c +++ b/APP_Framework/Framework/transform_layer/xizi/transform.c @@ -173,6 +173,7 @@ int PrivIoctl(int fd, int cmd, void *args) case ADC_TYPE: case DAC_TYPE: case WDT_TYPE: + case CAMERA_TYPE: ret = ioctl(fd, cmd, ioctl_cfg->args); break; default: diff --git a/APP_Framework/Framework/transform_layer/xizi/transform.h b/APP_Framework/Framework/transform_layer/xizi/transform.h index 0a0780798..bda868988 100644 --- a/APP_Framework/Framework/transform_layer/xizi/transform.h +++ b/APP_Framework/Framework/transform_layer/xizi/transform.h @@ -150,9 +150,18 @@ enum IoctlDriverType DAC_TYPE, WDT_TYPE, RTC_TYPE, + CAMERA_TYPE, DEFAULT_TYPE, }; + +struct DvpRegConfigureInfo +{ + uint8_t device_addr; + uint16_t reg_addr; + uint8_t reg_value; +} ; + struct PrivIoctlCfg { enum IoctlDriverType ioctl_driver_type; @@ -180,6 +189,18 @@ typedef struct void* pixel_color; }LcdPixelParam; +struct CameraCfg +{ + uint16_t window_w; + uint16_t window_h; + uint16_t window_xoffset; + uint16_t window_yoffset; + uint16_t output_w; + uint16_t output_h; + uint8_t gain; + uint8_t gain_manu_enable; +}; + typedef struct { char type; // 0:write string;1:write dot diff --git a/APP_Framework/lib/lvgl/lvgl.mk b/APP_Framework/lib/lvgl/lvgl.mk index 73466ddbb..2dd1245c3 100644 --- a/APP_Framework/lib/lvgl/lvgl.mk +++ b/APP_Framework/lib/lvgl/lvgl.mk @@ -1,5 +1,4 @@ -# include $(LVGL_DIR)/$(LVGL_DIR_NAME)/examples/examples.mk -include $(LVGL_DIR)/$(LVGL_DIR_NAME)/porting/porting.mk +include $(LVGL_DIR)/$(LVGL_DIR_NAME)/examples/examples.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/extra/extra.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/core/lv_core.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw/lv_draw.mk @@ -7,4 +6,4 @@ include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/font/lv_font.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/gpu/lv_gpu.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/hal/lv_hal.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/misc/lv_misc.mk -include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/widgets/lv_widgets.mk +include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/widgets/lv_widgets.mk \ No newline at end of file diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/board.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/board.c index 0107071e8..d8ab4edac 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/board.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/board.c @@ -48,6 +48,7 @@ Modification: #include "connect_rtc.h" #include "connect_hwtimer.h" #include "connect_wdt.h" +#include "connect_dvp.h" // #if defined(FS_VFS) // #include @@ -210,6 +211,9 @@ struct InitSequenceDesc _board_init[] = #endif #ifdef BSP_USING_WDT {"hw_wdt", HwWdtInit }, +#endif +#ifdef BSP_USING_CAMERA + {"hw_camera", HwDvpInit }, #endif { " NONE ",NONE }, }; @@ -222,6 +226,7 @@ void InitBoardHardware(void) SysctlPllSetFreq(SYSCTL_PLL0, 800000000UL); SysctlPllSetFreq(SYSCTL_PLL1, 400000000UL); + SysctlPllSetFreq(SYSCTL_PLL2, 45158400UL); #ifdef BSP_USING_GPIO /* Init FPIOA */ FpioaInit(); @@ -235,7 +240,9 @@ void InitBoardHardware(void) #ifdef BSP_USING_UART HwUartInit(); #endif - +// #ifdef BSP_USING_CAMERA +// HwDvpInit(); +// #endif /* initialize memory system */ InitBoardMemory(MEMORY_START_ADDRESS, MEMORY_END_ADDRESS); diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/Kconfig b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/Kconfig index 11ecca978..9ea181f9c 100755 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/Kconfig +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/Kconfig @@ -112,3 +112,12 @@ menuconfig BSP_USING_WDT if BSP_USING_WDT source "$BSP_DIR/third_party_driver/watchdog/Kconfig" endif + +menuconfig BSP_USING_CAMERA + bool "Using camera device" + default y + select RESOURCES_CAMERA + if BSP_USING_CAMERA + source "$BSP_DIR/third_party_driver/dvp/Kconfig" + endif + diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/Makefile b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/Makefile index b8f466166..22fb77503 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/Makefile +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/Makefile @@ -56,5 +56,9 @@ ifeq ($(CONFIG_BSP_USING_WDT),y) SRC_DIR += watchdog endif +ifeq ($(CONFIG_BSP_USING_CAMERA),y) + SRC_DIR += dvp +endif + include $(KERNEL_ROOT)/compiler.mk diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/Kconfig b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/Kconfig new file mode 100644 index 000000000..f7f10a646 --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/Kconfig @@ -0,0 +1,46 @@ +if BSP_USING_CAMERA + config DVP_XCLK_RATE + int "Camera interface clk rate" + default 24000000 + config IMAGE_WIDTH + int "Camera photo width" + default 320 + config IMAGE_HEIGHT + int "Camera photo height" + default 240 + config DVP_BURST_ENABLE + bool "brust mode enable" + default y + config DVP_AUTO_ENABLE + bool "auto recv image mode enable" + default n + config DVP_AI_OUTPUT + bool "ai output enable" + default n + config DVP_INTERRUPT_ENABLE + bool "interrupt enable" + default y + + config CAMERA_BUS_NAME + string "camera bus name" + default "camera" + config CAMERA_DRV_NAME + string "camera driver name" + default "camera_drv" + config CAMERA_DEVICE_NAME + string "camera device name" + default "camera_dev" + + choice + prompt "set camera framesize and fps" + default SVGA_25FPS_MODE + + config UXGA_15FPS_MODE + bool "using uxga in 15fps" + + config SVGA_25FPS_MODE + bool "using svag in 25fps" + endchoice + + +endif diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/Makefile b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/Makefile new file mode 100644 index 000000000..38326d7ab --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/Makefile @@ -0,0 +1,4 @@ +SRC_FILES := connect_dvp.c dvp.c ov2640.c + + +include $(KERNEL_ROOT)/compiler.mk \ No newline at end of file diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c new file mode 100644 index 000000000..fb3c02219 --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c @@ -0,0 +1,242 @@ +#include +#include +#include +#include "sysctl.h" +#include "bsp.h" +#include "plic.h" +#include + +#define REG_SCCB_READ 0x12U +#define REG_SCCB_WRITE 0x13U +#define SCCB_REG_LENGTH 0x08U + +// irq interrupt function +static int on_irq_dvp(int irq, void *arg) +{ + if (dvp_get_interrupt(DVP_STS_FRAME_FINISH)) + { + dvp_clear_interrupt(DVP_STS_FRAME_FINISH); + } + else + { + dvp_start_convert(); + dvp_clear_interrupt(DVP_STS_FRAME_START); + } + return 0; +} + +struct DvpRegConfigureInfo +{ + uint8_t device_addr; + uint16_t reg_addr; + uint8_t reg_value; +}; + +static struct CameraCfg sensor_config = { + .output_h = IMAGE_HEIGHT,//will be resize from window below in ov2640 + .output_w = IMAGE_WIDTH, + .window_h = 600, //register configure in ov2640.h + .window_w = 800, //to make window as large as cmos selected size + .window_xoffset = 0, + .window_yoffset = 0, + .gain_manu_enable = 0, + .gain = 0x00 + }; + +static uint32 dvpDrvInit(void) +{ + x_err_t ret = EOK; + dvp_init(SCCB_REG_LENGTH); + dvp_set_xclk_rate(DVP_XCLK_RATE); + dvp_set_image_format(DVP_CFG_RGB_FORMAT); + dvp_set_image_size(IMAGE_WIDTH, IMAGE_HEIGHT); + dvp_set_output_enable(DVP_OUTPUT_DISPLAY, 0); + dvp_set_output_enable(DVP_OUTPUT_AI, 0); + ov2640_init(); + sensorConfigure(&sensor_config); + + sysctl_set_spi0_dvp_data(1); +#ifdef DVP_BURST_ENABLE + dvp_enable_burst(); +#endif +#ifdef DVP_AUTO_ENABLE + dvp_disable_auto(); +#endif +#ifdef DVP_AI_OUTPUT + dvp_set_output_enable(DVP_OUTPUT_AI, 1); + dvp_set_ai_addr((uint32_t)DVP_AI_RED_ADRESS, (uint32_t)DVP_AI_GREEN_ADRESS, (uint32_t)DVP_AI_BLUE_ADRESS); +#endif +#ifdef DVP_INTERRUPT_ENABLE + dvp_config_interrupt(DVP_CFG_START_INT_ENABLE | DVP_CFG_FINISH_INT_ENABLE, 0); + isrManager.done->registerIrq(IRQN_DVP_INTERRUPT, (IsrHandlerType)on_irq_dvp, NULL); + isrManager.done->enableIrq(IRQN_DVP_INTERRUPT); + dvp_clear_interrupt(DVP_STS_FRAME_START | DVP_STS_FRAME_FINISH); + dvp_config_interrupt(DVP_CFG_START_INT_ENABLE | DVP_CFG_FINISH_INT_ENABLE, 1); + KPrintf("camera interrupt has open!\n"); +#endif + return ret; +} + +static uint32 readDvpReg(void *drv, struct DvpRegConfigureInfo *reg_info) +{ + x_err_t ret = EOK; + reg_info->reg_value = dvp_sccb_receive_data(reg_info->device_addr, reg_info->reg_addr); + return ret; +} + +static uint32 writeDvpReg(void *drv, struct DvpRegConfigureInfo *reg_info) +{ + x_err_t ret = EOK; + dvp_sccb_send_data(reg_info->device_addr, reg_info->reg_addr, reg_info->reg_value); + return ret; +} + +static uint32 dvpOpen(void *dev) +{ + x_err_t ret = EOK; + dvpDrvInit(); + return ret; +} + +static uint32 dvpClose(void *dev) +{ + x_err_t ret = EOK; + dvp_config_interrupt(DVP_CFG_START_INT_ENABLE | DVP_CFG_FINISH_INT_ENABLE, 0); + dvp_set_output_enable(DVP_OUTPUT_AI, 0); + dvp_set_output_enable(DVP_OUTPUT_DISPLAY, 0); + return ret; +} + +static uint32 dvpRead(void *dev, struct BusBlockReadParam *read_param) +{ + x_err_t ret = EOK; + + // change the output buff address by read + dvp_set_output_enable(DVP_OUTPUT_DISPLAY, 0); + dvp_set_display_addr((uintptr_t)read_param->buffer); + dvp_set_output_enable(DVP_OUTPUT_DISPLAY, 1); + + return ret; +} + +static uint32 dvpDrvConfigure(void *drv, struct BusConfigureInfo *args) +{ + + x_err_t ret = EOK; + int cmd_type = args->configure_cmd; + struct CameraCfg* tmp_cfg; + switch (cmd_type) + { + case OPE_INT: + break; + case OPE_CFG: + tmp_cfg = (struct CameraCfg *)args->private_data; + sensorConfigure(tmp_cfg); + dvp_set_image_size(tmp_cfg->output_w, tmp_cfg->output_h); + break; + case REG_SCCB_READ: + readDvpReg(drv, (struct DvpRegConfigureInfo *)args->private_data); + break; + case REG_SCCB_WRITE: + writeDvpReg(drv, (struct DvpRegConfigureInfo *)args->private_data); + break; + default: + break; + } + return ret; +} + +/*manage the camera device operations*/ +static const struct CameraDevDone camera_dev_done = + { + .dev_open = dvpOpen, + .dev_close = dvpClose, + .dev_write = NONE, + .dev_read = dvpRead, +}; + +/*Init camera bus*/ +static int BoardCameraBusInit(struct CameraBus *camera_bus, struct CameraDriver *camera_driver) +{ + x_err_t ret = EOK; + + /*Init the camera bus */ + camera_bus->private_data = (void *)&camera_dev_done; + ret = CameraBusInit(camera_bus, CAMERA_BUS_NAME); + if (EOK != ret) + { + KPrintf("board_camera_init CameraBusInit error %d\n", ret); + return ERROR; + } + + /*Init the camera driver*/ + camera_driver->private_data = (void *)&camera_dev_done; + ret = CameraDriverInit(camera_driver, CAMERA_DRV_NAME); + if (EOK != ret) + { + KPrintf("board_camera_init CameraDriverInit error %d\n", ret); + return ERROR; + } + + /*Attach the camera driver to the camera bus*/ + ret = CameraDriverAttachToBus(CAMERA_DRV_NAME, CAMERA_BUS_NAME); + if (EOK != ret) + { + KPrintf("board_camera_init CameraDriverAttachToBus error %d\n", ret); + return ERROR; + } + + return ret; +} + +/*Attach the camera device to the camera bus*/ +static int BoardCameraDevBend(void) +{ + x_err_t ret = EOK; + static struct CameraHardwareDevice camera_device; + memset(&camera_device, 0, sizeof(struct CameraHardwareDevice)); + + camera_device.camera_dev_done = &camera_dev_done; + + ret = CameraDeviceRegister(&camera_device, NONE, CAMERA_DEVICE_NAME); + if (EOK != ret) + { + KPrintf("board_camera_init CameraDeviceInit device %s error %d\n", CAMERA_DEVICE_NAME, ret); + return ERROR; + } + + ret = CameraDeviceAttachToBus(CAMERA_DEVICE_NAME, CAMERA_BUS_NAME); + if (EOK != ret) + { + KPrintf("board_camera_init CameraDeviceAttachToBus device %s error %d\n", CAMERA_DEVICE_NAME, ret); + return ERROR; + } + + return ret; +} + +int HwDvpInit(void) +{ + x_err_t ret = EOK; + static struct CameraBus camera_bus; + memset(&camera_bus, 0, sizeof(struct CameraBus)); + + static struct CameraDriver camera_driver; + memset(&camera_driver, 0, sizeof(struct CameraDriver)); + + camera_driver.configure = dvpDrvConfigure; + ret = BoardCameraBusInit(&camera_bus, &camera_driver); + if (EOK != ret) + { + KPrintf("board_camera_Init error ret %u\n", ret); + return ERROR; + } + + ret = BoardCameraDevBend(); + if (EOK != ret) + { + KPrintf("board_camera_Init error ret %u\n", ret); + return ERROR; + } + return ret; +} \ No newline at end of file diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/dvp.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/dvp.c new file mode 100644 index 000000000..50cc8ff6c --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/dvp.c @@ -0,0 +1,288 @@ +/* Copyright 2018 Canaan Inc. + * + * Licensed 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. + */ +#include +#include +#include "dvp.h" +#include "utils.h" +#include "fpioa.h" +#include "sysctl.h" +#include +#include + +volatile dvp_t* const dvp = (volatile dvp_t*)DVP_BASE_ADDR; +static uint8_t g_sccb_reg_len = 8; + + +static void dvp_sccb_clk_init(void) +{ + uint32_t tmp; + + tmp = dvp->sccb_cfg & (~(DVP_SCCB_SCL_LCNT_MASK | DVP_SCCB_SCL_HCNT_MASK)); + tmp |= DVP_SCCB_SCL_LCNT(255) | DVP_SCCB_SCL_HCNT(255); + + dvp->sccb_cfg = tmp; +} + +uint32_t dvp_sccb_set_clk_rate(uint32_t clk_rate) +{ + uint32_t tmp; + uint32_t v_sccb_freq = SysctlClockGetFreq(SYSCTL_CLOCK_APB1); + uint16_t v_period_clk_cnt = round(v_sccb_freq / clk_rate / 2.0); + if(v_period_clk_cnt > 255) + { + return 0; + } + tmp = dvp->sccb_cfg & (~(DVP_SCCB_SCL_LCNT_MASK | DVP_SCCB_SCL_HCNT_MASK)); + tmp |= DVP_SCCB_SCL_LCNT(v_period_clk_cnt) | DVP_SCCB_SCL_HCNT(v_period_clk_cnt); + dvp->sccb_cfg = tmp; + return SysctlClockGetFreq(SYSCTL_CLOCK_DVP) / (v_period_clk_cnt * 2); +} + +static void dvp_sccb_start_transfer(void) +{ + while (dvp->sts & DVP_STS_SCCB_EN) + ; + dvp->sts = DVP_STS_SCCB_EN | DVP_STS_SCCB_EN_WE; + while (dvp->sts & DVP_STS_SCCB_EN) + ; +} + +void dvp_sccb_send_data(uint8_t dev_addr, uint16_t reg_addr, uint8_t reg_data) +{ + uint32_t tmp; + + tmp = dvp->sccb_cfg & (~DVP_SCCB_BYTE_NUM_MASK); + + (g_sccb_reg_len == 8) ? (tmp |= DVP_SCCB_BYTE_NUM_3) : (tmp |= DVP_SCCB_BYTE_NUM_4); + + dvp->sccb_cfg = tmp; + + if (g_sccb_reg_len == 8) + { + dvp->sccb_ctl = DVP_SCCB_WRITE_DATA_ENABLE | DVP_SCCB_DEVICE_ADDRESS(dev_addr) | DVP_SCCB_REG_ADDRESS(reg_addr) | DVP_SCCB_WDATA_BYTE0(reg_data); + } + else + { + dvp->sccb_ctl = DVP_SCCB_WRITE_DATA_ENABLE | DVP_SCCB_DEVICE_ADDRESS(dev_addr) | DVP_SCCB_REG_ADDRESS(reg_addr >> 8) | DVP_SCCB_WDATA_BYTE0(reg_addr & 0xff) | DVP_SCCB_WDATA_BYTE1(reg_data); + } + dvp_sccb_start_transfer(); +} + +uint8_t dvp_sccb_receive_data(uint8_t dev_addr, uint16_t reg_addr) +{ + uint32_t tmp; + + tmp = dvp->sccb_cfg & (~DVP_SCCB_BYTE_NUM_MASK); + + if (g_sccb_reg_len == 8) + tmp |= DVP_SCCB_BYTE_NUM_2; + else + tmp |= DVP_SCCB_BYTE_NUM_3; + + dvp->sccb_cfg = tmp; + + if (g_sccb_reg_len == 8) + { + dvp->sccb_ctl = DVP_SCCB_WRITE_DATA_ENABLE | DVP_SCCB_DEVICE_ADDRESS(dev_addr) | DVP_SCCB_REG_ADDRESS(reg_addr); + } + else + { + dvp->sccb_ctl = DVP_SCCB_WRITE_DATA_ENABLE | DVP_SCCB_DEVICE_ADDRESS(dev_addr) | DVP_SCCB_REG_ADDRESS(reg_addr >> 8) | DVP_SCCB_WDATA_BYTE0(reg_addr & 0xff); + } + dvp_sccb_start_transfer(); + + dvp->sccb_ctl = DVP_SCCB_DEVICE_ADDRESS(dev_addr); + + dvp_sccb_start_transfer(); + + return (uint8_t) DVP_SCCB_RDATA_BYTE(dvp->sccb_cfg); +} + +static void dvp_reset(void) +{ + /* First power down */ + dvp->cmos_cfg |= DVP_CMOS_POWER_DOWN; + msleep(200); + dvp->cmos_cfg &= ~DVP_CMOS_POWER_DOWN; + msleep(200); + + /* Second reset */ + dvp->cmos_cfg &= ~DVP_CMOS_RESET; + msleep(200); + dvp->cmos_cfg |= DVP_CMOS_RESET; + msleep(200); +} + +void dvp_init(uint8_t reg_len) +{ + g_sccb_reg_len = reg_len; + sysctl_clock_enable(SYSCTL_CLOCK_DVP); + sysctl_reset(SYSCTL_RESET_DVP); + dvp->cmos_cfg &= (~DVP_CMOS_CLK_DIV_MASK); + dvp->cmos_cfg |= DVP_CMOS_CLK_DIV(3) | DVP_CMOS_CLK_ENABLE; + dvp_sccb_clk_init(); + dvp_reset(); +} + +uint32_t dvp_set_xclk_rate(uint32_t xclk_rate) +{ + uint32_t v_apb1_clk = SysctlClockGetFreq(SYSCTL_CLOCK_APB1); + uint32_t v_period; + if(v_apb1_clk > xclk_rate * 2) + v_period = round(v_apb1_clk / (xclk_rate * 2.0)) - 1; + else + v_period = 0; + if(v_period > 255) + v_period = 255; + dvp->cmos_cfg &= (~DVP_CMOS_CLK_DIV_MASK); + dvp->cmos_cfg |= DVP_CMOS_CLK_DIV(v_period) | DVP_CMOS_CLK_ENABLE; + dvp_reset(); + return v_apb1_clk / ((v_period + 1) * 2); +} + +void dvp_set_image_format(uint32_t format) +{ + uint32_t tmp; + + tmp = dvp->dvp_cfg & (~DVP_CFG_FORMAT_MASK); + dvp->dvp_cfg = tmp | format; +} + +void dvp_enable_burst(void) +{ + dvp->dvp_cfg |= DVP_CFG_BURST_SIZE_4BEATS; + + dvp->axi &= (~DVP_AXI_GM_MLEN_MASK); + dvp->axi |= DVP_AXI_GM_MLEN_4BYTE; +} + +void dvp_disable_burst(void) +{ + dvp->dvp_cfg &= (~DVP_CFG_BURST_SIZE_4BEATS); + + dvp->axi &= (~DVP_AXI_GM_MLEN_MASK); + dvp->axi |= DVP_AXI_GM_MLEN_1BYTE; +} + +void dvp_set_image_size(uint32_t width, uint32_t height) +{ + uint32_t tmp; + + tmp = dvp->dvp_cfg & (~(DVP_CFG_HREF_BURST_NUM_MASK | DVP_CFG_LINE_NUM_MASK)); + + tmp |= DVP_CFG_LINE_NUM(height); + + if (dvp->dvp_cfg & DVP_CFG_BURST_SIZE_4BEATS) + tmp |= DVP_CFG_HREF_BURST_NUM(width / 8 / 4); + else + tmp |= DVP_CFG_HREF_BURST_NUM(width / 8 / 1); + + dvp->dvp_cfg = tmp; +} + +void dvp_set_ai_addr(uint32_t r_addr, uint32_t g_addr, uint32_t b_addr) +{ + dvp->r_addr = r_addr; + dvp->g_addr = g_addr; + dvp->b_addr = b_addr; +} + +void dvp_set_display_addr(uint32_t addr) +{ + dvp->rgb_addr = addr; +} + +void dvp_start_frame(void) +{ + while (!(dvp->sts & DVP_STS_FRAME_START)) + ; + dvp->sts = (DVP_STS_FRAME_START | DVP_STS_FRAME_START_WE); +} + +void dvp_start_convert(void) +{ + dvp->sts = DVP_STS_DVP_EN | DVP_STS_DVP_EN_WE; +} + +void dvp_finish_convert(void) +{ + while (!(dvp->sts & DVP_STS_FRAME_FINISH)) + ; + dvp->sts = DVP_STS_FRAME_FINISH | DVP_STS_FRAME_FINISH_WE; +} + +void dvp_get_image(void) +{ + while (!(dvp->sts & DVP_STS_FRAME_START)) + ; + dvp->sts = DVP_STS_FRAME_START | DVP_STS_FRAME_START_WE; + while (!(dvp->sts & DVP_STS_FRAME_START)) + ; + dvp->sts = DVP_STS_FRAME_FINISH | DVP_STS_FRAME_FINISH_WE | DVP_STS_FRAME_START | DVP_STS_FRAME_START_WE | DVP_STS_DVP_EN | DVP_STS_DVP_EN_WE; + while (!(dvp->sts & DVP_STS_FRAME_FINISH)) + ; +} + +void dvp_config_interrupt(uint32_t interrupt, uint8_t enable) +{ + if (enable) + dvp->dvp_cfg |= interrupt; + else + dvp->dvp_cfg &= (~interrupt); +} + +int dvp_get_interrupt(uint32_t interrupt) +{ + if (dvp->sts & interrupt) + return 1; + return 0; +} + +void dvp_clear_interrupt(uint32_t interrupt) +{ + interrupt |= (interrupt << 1); + dvp->sts |= interrupt; +} + +void dvp_enable_auto(void) +{ + dvp->dvp_cfg |= DVP_CFG_AUTO_ENABLE; +} + +void dvp_disable_auto(void) +{ + dvp->dvp_cfg &= (~DVP_CFG_AUTO_ENABLE); +} + +void dvp_set_output_enable(dvp_output_mode_t index, int enable) +{ + configASSERT(index < 2); + + if (index == 0) + { + if (enable) + dvp->dvp_cfg |= DVP_CFG_AI_OUTPUT_ENABLE; + else + dvp->dvp_cfg &= ~DVP_CFG_AI_OUTPUT_ENABLE; + } + else + { + if (enable) + dvp->dvp_cfg |= DVP_CFG_DISPLAY_OUTPUT_ENABLE; + else + dvp->dvp_cfg &= ~DVP_CFG_DISPLAY_OUTPUT_ENABLE; + } +} + diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/ov2640.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/ov2640.c new file mode 100644 index 000000000..867642bda --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/ov2640.c @@ -0,0 +1,457 @@ +/* Copyright 2018 Canaan Inc. + * + * Licensed 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. + */ +#include +#include "ov2640.h" +#include "dvp.h" +#include "plic.h" +#include "board.h" + +#if defined SVGA_25FPS_MODE +const uint8_t ov2640_config[][2]= +{ + {0xff, 0x01}, + {0x12, 0x80}, + {0xff, 0x00}, + {0x2c, 0xff}, + {0x2e, 0xdf}, + {0xff, 0x01}, + {0x3c, 0x32}, + {0x11, 0x00}, + {0x09, 0x02}, + {0x04, 0x58}, + {0x13, 0xe5}, + {0x14, 0x48}, + {0x2c, 0x0c}, + {0x33, 0x78}, + {0x3a, 0x33}, + {0x3b, 0xfb}, + {0x3e, 0x00}, + {0x43, 0x11}, + {0x16, 0x10}, + {0x39, 0x92}, + {0x35, 0xda}, + {0x22, 0x1a}, + {0x37, 0xc3}, + {0x23, 0x00}, + {0x34, 0xc0}, + {0x36, 0x1a}, + {0x06, 0x88}, + {0x07, 0xc0}, + {0x0d, 0x87}, + {0x0e, 0x41}, + {0x4c, 0x00}, + {0x48, 0x00}, + {0x5b, 0x00}, + {0x42, 0x03}, + {0x4a, 0x81}, + {0x21, 0x99}, + {0x24, 0x40}, + {0x25, 0x38}, + {0x26, 0x82}, + {0x5c, 0x00}, + {0x63, 0x00}, + {0x46, 0x22}, + {0x0c, 0x3c}, + {0x61, 0x70}, + {0x62, 0x80}, + {0x7c, 0x05}, + {0x20, 0x80}, + {0x28, 0x30}, + {0x6c, 0x00}, + {0x6d, 0x80}, + {0x6e, 0x00}, + {0x70, 0x02}, + {0x71, 0x94}, + {0x73, 0xc1}, + {0x3d, 0x34}, + {0x5a, 0x57}, + {0x12, 0x40}, + {0x17, 0x11}, + {0x18, 0x43}, + {0x19, 0x00}, + {0x1a, 0x97}, + {0x32, 0x09}, + {0x37, 0xc0}, + {0x4f, 0xca}, + {0x50, 0xa8}, + {0x5a, 0x23}, + {0x6d, 0x00}, + {0x3d, 0x38}, + {0xff, 0x00}, + {0xe5, 0x7f}, + {0xf9, 0xc0}, + {0x41, 0x24}, + {0xe0, 0x14}, + {0x76, 0xff}, + {0x33, 0xa0}, + {0x42, 0x20}, + {0x43, 0x18}, + {0x4c, 0x00}, + {0x87, 0xd5}, + {0x88, 0x3f}, + {0xd7, 0x03}, + {0xd9, 0x10}, + {0xd3, 0x82}, + {0xc8, 0x08}, + {0xc9, 0x80}, + {0x7c, 0x00}, + {0x7d, 0x00}, + {0x7c, 0x03}, + {0x7d, 0x48}, + {0x7d, 0x48}, + {0x7c, 0x08}, + {0x7d, 0x20}, + {0x7d, 0x10}, + {0x7d, 0x0e}, + {0x90, 0x00}, + {0x91, 0x0e}, + {0x91, 0x1a}, + {0x91, 0x31}, + {0x91, 0x5a}, + {0x91, 0x69}, + {0x91, 0x75}, + {0x91, 0x7e}, + {0x91, 0x88}, + {0x91, 0x8f}, + {0x91, 0x96}, + {0x91, 0xa3}, + {0x91, 0xaf}, + {0x91, 0xc4}, + {0x91, 0xd7}, + {0x91, 0xe8}, + {0x91, 0x20}, + {0x92, 0x00}, + {0x93, 0x06}, + {0x93, 0xe3}, + {0x93, 0x05}, + {0x93, 0x05}, + {0x93, 0x00}, + {0x93, 0x04}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x96, 0x00}, + {0x97, 0x08}, + {0x97, 0x19}, + {0x97, 0x02}, + {0x97, 0x0c}, + {0x97, 0x24}, + {0x97, 0x30}, + {0x97, 0x28}, + {0x97, 0x26}, + {0x97, 0x02}, + {0x97, 0x98}, + {0x97, 0x80}, + {0x97, 0x00}, + {0x97, 0x00}, + {0xc3, 0xed}, + {0xa4, 0x00}, + {0xa8, 0x00}, + {0xc5, 0x11}, + {0xc6, 0x51}, + {0xbf, 0x80}, + {0xc7, 0x10}, + {0xb6, 0x66}, + {0xb8, 0xa5}, + {0xb7, 0x64}, + {0xb9, 0x7c}, + {0xb3, 0xaf}, + {0xb4, 0x97}, + {0xb5, 0xff}, + {0xb0, 0xc5}, + {0xb1, 0x94}, + {0xb2, 0x0f}, + {0xc4, 0x5c}, + {0xc0, 0x64}, + {0xc1, 0x4b}, + {0x8c, 0x00}, + {0x86, 0x3d}, + {0x50, 0x00}, + {0x51, 0xc8}, + {0x52, 0x96}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x00}, + {0x5a, 0xc8}, + {0x5b, 0x96}, + {0x5c, 0x00}, + {0xd3, 0x02}, + {0xc3, 0xed}, + {0x7f, 0x00}, + {0xda, 0x08}, + {0xe5, 0x1f}, + {0xe1, 0x67}, + {0xe0, 0x00}, + {0xdd, 0x7f}, + {0x05, 0x00}, + {0xff, 0x00}, + {0xe0, 0x04}, + {0x5a, 0x50}, + {0x5b, 0x3c}, + {0x5c, 0x00}, + {0xe0, 0x00}, + {0x00, 0x00} +}; +#elif defined UXGA_15FPS_MODE +const uint8_t ov2640_config[][2]= +{ + {0xFF, 0x00}, + {0x2C, 0xFF}, + {0x2E, 0xDF}, + {0xFF, 0x01}, + {0x3C, 0x32}, + {0x11, 0x00}, + {0x09, 0x02}, + {0x04, 0xA8}, + {0x13, 0xE5}, + {0x14, 0x48}, + {0x2C, 0x0C}, + {0x33, 0x78}, + {0x3A, 0x33}, + {0x3B, 0xFB}, + {0x3E, 0x00}, + {0x43, 0x11}, + {0x16, 0x10}, + {0x39, 0x92}, + {0x35, 0xDA}, + {0x22, 0x1A}, + {0x37, 0xC3}, + {0x23, 0x00}, + {0x34, 0xC0}, + {0x36, 0x1A}, + {0x06, 0x88}, + {0x07, 0xC0}, + {0x0D, 0x87}, + {0x0E, 0x41}, + {0x4C, 0x00}, + {0x48, 0x00}, + {0x5B, 0x00}, + {0x42, 0x03}, + {0x4A, 0x81}, + {0x21, 0x99}, + {0x24, 0x40}, + {0x25, 0x38}, + {0x26, 0x82}, + {0x5C, 0x00}, + {0x63, 0x00}, + {0x46, 0x00}, + {0x0C, 0x3C}, + {0x61, 0x70}, + {0x62, 0x80}, + {0x7C, 0x05}, + {0x20, 0x80}, + {0x28, 0x30}, + {0x6C, 0x00}, + {0x6D, 0x80}, + {0x6E, 0x00}, + {0x70, 0x02}, + {0x71, 0x94}, + {0x73, 0xC1}, + {0x3D, 0x34}, + {0x5A, 0x57}, + {0x12, 0x00}, + {0x17, 0x11}, + {0x18, 0x75}, + {0x19, 0x01}, + {0x1A, 0x97}, + {0x32, 0x36}, + {0x03, 0x0F}, + {0x37, 0x40}, + {0x4F, 0xCA}, + {0x50, 0xA8}, + {0x5A, 0x23}, + {0x6D, 0x00}, + {0x6D, 0x38}, + {0xFF, 0x00}, + {0xE5, 0x7F}, + {0xF9, 0xC0}, + {0x41, 0x24}, + {0xE0, 0x14}, + {0x76, 0xFF}, + {0x33, 0xA0}, + {0x42, 0x20}, + {0x43, 0x18}, + {0x4C, 0x00}, + {0x87, 0xD5}, + {0x88, 0x3F}, + {0xD7, 0x03}, + {0xD9, 0x10}, + {0xD3, 0x82}, + {0xC8, 0x08}, + {0xC9, 0x80}, + {0x7C, 0x00}, + {0x7D, 0x00}, + {0x7C, 0x03}, + {0x7D, 0x48}, + {0x7D, 0x48}, + {0x7C, 0x08}, + {0x7D, 0x20}, + {0x7D, 0x10}, + {0x7D, 0x0E}, + {0x90, 0x00}, + {0x91, 0x0E}, + {0x91, 0x1A}, + {0x91, 0x31}, + {0x91, 0x5A}, + {0x91, 0x69}, + {0x91, 0x75}, + {0x91, 0x7E}, + {0x91, 0x88}, + {0x91, 0x8F}, + {0x91, 0x96}, + {0x91, 0xA3}, + {0x91, 0xAF}, + {0x91, 0xC4}, + {0x91, 0xD7}, + {0x91, 0xE8}, + {0x91, 0x20}, + {0x92, 0x00}, + {0x93, 0x06}, + {0x93, 0xE3}, + {0x93, 0x05}, + {0x93, 0x05}, + {0x93, 0x00}, + {0x93, 0x04}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x96, 0x00}, + {0x97, 0x08}, + {0x97, 0x19}, + {0x97, 0x02}, + {0x97, 0x0C}, + {0x97, 0x24}, + {0x97, 0x30}, + {0x97, 0x28}, + {0x97, 0x26}, + {0x97, 0x02}, + {0x97, 0x98}, + {0x97, 0x80}, + {0x97, 0x00}, + {0x97, 0x00}, + {0xC3, 0xEF}, + {0xA4, 0x00}, + {0xA8, 0x00}, + {0xC5, 0x11}, + {0xC6, 0x51}, + {0xBF, 0x80}, + {0xC7, 0x10}, + {0xB6, 0x66}, + {0xB8, 0xA5}, + {0xB7, 0x64}, + {0xB9, 0x7C}, + {0xB3, 0xAF}, + {0xB4, 0x97}, + {0xB5, 0xFF}, + {0xB0, 0xC5}, + {0xB1, 0x94}, + {0xB2, 0x0F}, + {0xC4, 0x5C}, + {0xC0, 0xC8}, + {0xC1, 0x96}, + {0x8C, 0x00}, + {0x86, 0x3D}, + {0x50, 0x00}, + {0x51, 0x90}, + {0x52, 0x2C}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x88}, + {0x5A, 0x90}, + {0x5B, 0x2C}, + {0x5C, 0x05}, + {0xD3, 0x02}, + {0xC3, 0xED}, + {0x7F, 0x00}, + {0xDA, 0x08}, + {0xE5, 0x1F}, + {0xE1, 0x67}, + {0xE0, 0x00}, + {0xDD, 0x7F}, + {0x00, 0x00} +}; +#else +const uint8_t ov2640_config[][2]= +{ + {0x00,x00} +} +#endif + + + +int ov2640_init(void) +{ + uint16_t v_manuf_id; + uint16_t v_device_id; + ov2640_read_id(&v_manuf_id, &v_device_id); + printf("manuf_id:0x%04x,device_id:0x%04x\n", v_manuf_id, v_device_id); + uint16_t index = 0; + for (index = 0; ov2640_config[index][0]; index++) + dvp_sccb_send_data(OV2640_ADDR, ov2640_config[index][0], ov2640_config[index][1]); + return 0; +} + +int ov2640_read_id(uint16_t *manuf_id, uint16_t *device_id) +{ + dvp_sccb_send_data(OV2640_ADDR, 0xFF, 0x01); + *manuf_id = (dvp_sccb_receive_data(OV2640_ADDR, 0x1C) << 8) | dvp_sccb_receive_data(OV2640_ADDR, 0x1D); + *device_id = (dvp_sccb_receive_data(OV2640_ADDR, 0x0A) << 8) | dvp_sccb_receive_data(OV2640_ADDR, 0x0B); + return 0; +} + +int sensorConfigure(struct CameraCfg *cfg_info) +{ + uint8_t reg_tmp; + + //set reg mode to sensor + dvp_sccb_send_data(OV2640_ADDR, 0xFF, 0x00); + + //configure the window size and position + dvp_sccb_send_data(OV2640_ADDR, 0x51, cfg_info->window_w>>2); + dvp_sccb_send_data(OV2640_ADDR, 0x52, cfg_info->window_h>>2); + dvp_sccb_send_data(OV2640_ADDR, 0x53, (uint8_t)(cfg_info->window_xoffset&0xFF)); + dvp_sccb_send_data(OV2640_ADDR, 0x54, (uint8_t)(cfg_info->window_yoffset&0xFF)); + dvp_sccb_send_data(OV2640_ADDR, 0x55, (((cfg_info->window_h/4)&0x100)>>1)+ + ((cfg_info->window_yoffset&0x700)>>4)+ + (((cfg_info->window_w/4)&0x100)>>5)+ + ((cfg_info->window_xoffset&0x700)>>8)); + dvp_sccb_send_data(OV2640_ADDR, 0x57, ((cfg_info->window_w/4)&0x200)>>2); + dvp_sccb_send_data(OV2640_ADDR, 0x5A, cfg_info->output_w>>2); + dvp_sccb_send_data(OV2640_ADDR, 0x5B, cfg_info->output_h>>2); + + //set reg mode to dsp + dvp_sccb_send_data(OV2640_ADDR, 0xFF, 0x01); + + //configure dsp gain + if(cfg_info->gain_manu_enable){ + reg_tmp = dvp_sccb_receive_data(OV2640_ADDR, 0x13); + dvp_sccb_send_data(OV2640_ADDR, 0x13, reg_tmp&0xFB); + dvp_sccb_send_data(OV2640_ADDR, 0x00, cfg_info->gain); + }else{ + reg_tmp = dvp_sccb_receive_data(OV2640_ADDR, 0x13); + dvp_sccb_send_data(OV2640_ADDR, 0x13, reg_tmp|0x04); + } + + + return 1; +} diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/gpio/drv_io_config.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/gpio/drv_io_config.c index fa2b4617f..2905d5de7 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/gpio/drv_io_config.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/gpio/drv_io_config.c @@ -72,30 +72,16 @@ static struct io_config IOCONFIG(BSP_UART2_RXD_PIN, FUNC_UART2_RX), #endif #ifdef BSP_USING_UART3 - IOCONFIG(BSP_UART3_TXD_PIN, FUNC_UART3_RX), - IOCONFIG(BSP_UART3_RXD_PIN, FUNC_UART3_TX), + IOCONFIG(BSP_UART3_TXD_PIN, FUNC_UART3_TX), + IOCONFIG(BSP_UART3_RXD_PIN, FUNC_UART3_RX), #endif #ifdef BSP_USING_I2C IOCONFIG(BSP_I2C_SDA, FUNC_GPIO3), IOCONFIG(BSP_I2C_SCL, FUNC_GPIO4), #endif #ifdef BSP_USING_TOUCH - IOCONFIG(BSP_TOUCH_TP_INT, HS_GPIO(FPIOA_TOUCH_TP_INT)), -#endif - -#ifdef BSP_USING_CH438 - IOCONFIG(BSP_CH438_ALE_PIN, HS_GPIO(FPIOA_CH438_ALE)), - IOCONFIG(BSP_CH438_NWR_PIN, HS_GPIO(FPIOA_CH438_NWR)), - IOCONFIG(BSP_CH438_NRD_PIN, HS_GPIO(FPIOA_CH438_NRD)), - IOCONFIG(BSP_CH438_INT_PIN, HS_GPIO(FPIOA_CH438_INT)), - IOCONFIG(BSP_CH438_D0_PIN, HS_GPIO(FPIOA_CH438_D0)), - IOCONFIG(BSP_CH438_D1_PIN, HS_GPIO(FPIOA_CH438_D1)), - IOCONFIG(BSP_CH438_D2_PIN, HS_GPIO(FPIOA_CH438_D2)), - IOCONFIG(BSP_CH438_D3_PIN, HS_GPIO(FPIOA_CH438_D3)), - IOCONFIG(BSP_CH438_D4_PIN, HS_GPIO(FPIOA_CH438_D4)), - IOCONFIG(BSP_CH438_D5_PIN, HS_GPIO(FPIOA_CH438_D5)), - IOCONFIG(BSP_CH438_D6_PIN, HS_GPIO(FPIOA_CH438_D6)), - IOCONFIG(BSP_CH438_D7_PIN, HS_GPIO(FPIOA_CH438_D7)), + // IOCONFIG(BSP_TOUCH_TP_INT, HS_GPIO(FPIOA_TOUCH_TP_INT)), + IOCONFIG(BSP_TOUCH_TP_INT, HS_GPIO(FUNC_GPIOHS30)), #endif #ifdef BSP_USING_SOFT_SPI @@ -105,6 +91,17 @@ static struct io_config IOCONFIG(BSP_SOFT_SPI_NCS_PIN, HS_GPIO(FPIOA_SOFT_SPI_NCS)), #endif +#ifdef BSP_USING_CAMERA + IOCONFIG(BSP_DVP_RST_PIN,FUNC_CMOS_RST), + IOCONFIG(BSP_DVP_PWDN_PIN, FUNC_CMOS_PWDN), + IOCONFIG(BSP_DVP_XCLK_PIN,FUNC_CMOS_XCLK), + IOCONFIG(BSP_DVP_PCLK_PIN,FUNC_CMOS_PCLK), + IOCONFIG(BSP_DVP_HSYNC_PIN,FUNC_CMOS_HREF), + IOCONFIG(BSP_DVP_VSYNC_PIN,FUNC_CMOS_VSYNC), + IOCONFIG(BSP_DVP_SCL_PIN,FUNC_SCCB_SCLK), + IOCONFIG(BSP_DVP_SDA_PIN,FUNC_SCCB_SDA), +#endif + #ifdef BSP_USING_LORA IOCONFIG(BSP_E220_M0_PIN, HS_GPIO(FUNC_GPIOHS10)), IOCONFIG(BSP_E220_M1_PIN, HS_GPIO(FUNC_GPIOHS11)), @@ -158,6 +155,11 @@ int IoConfigInit(void) sysctl_set_power_mode(SYSCTL_POWER_BANK3, SYSCTL_POWER_V33); #endif +#ifdef BSP_USING_CAMERA + sysctl_set_power_mode(SYSCTL_POWER_BANK7,SYSCTL_POWER_V18); + // sysctl_set_power_mode(SYSCTL_POWER_BANK7,SYSCTL_POWER_V18); +#endif + for(i = 0; i < count; i++) { ret = FpioaSetFunction(io_config[i].io_num, io_config[i].func); diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_dvp.h b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_dvp.h new file mode 100644 index 000000000..b8550cd5f --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_dvp.h @@ -0,0 +1,15 @@ +#ifndef CONNECT_DVP_H +#define CONNECT_DVP_H +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int HwDvpInit(void); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/drv_io_config.h b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/drv_io_config.h index f48e34c0d..9126a444e 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/drv_io_config.h +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/drv_io_config.h @@ -50,33 +50,6 @@ enum HS_GPIO_CONFIG GPIO_ALLOC_START /* index of gpio driver start */ }; -#ifdef BSP_USING_CH438 -#define FPIOA_CH438_ALE 12 -#define FPIOA_CH438_NWR 13 -#define FPIOA_CH438_NRD 14 -#define FPIOA_CH438_D0 15 -#define FPIOA_CH438_D1 16 -#define FPIOA_CH438_D2 17 -#define FPIOA_CH438_D3 18 -#define FPIOA_CH438_D4 19 -#define FPIOA_CH438_D5 20 -#define FPIOA_CH438_D6 21 -#define FPIOA_CH438_D7 22 -#define FPIOA_CH438_INT 23 - -#define BSP_CH438_ALE_PIN 24 -#define BSP_CH438_NWR_PIN 25 -#define BSP_CH438_NRD_PIN 26 -#define BSP_CH438_D0_PIN 27 -#define BSP_CH438_D1_PIN 28 -#define BSP_CH438_D2_PIN 29 -#define BSP_CH438_D3_PIN 30 -#define BSP_CH438_D4_PIN 31 -#define BSP_CH438_D5_PIN 32 -#define BSP_CH438_D6_PIN 33 -#define BSP_CH438_D7_PIN 34 -#define BSP_CH438_INT_PIN 35 -#endif #ifdef BSP_USING_SOFT_SPI #define FPIOA_SOFT_SPI_SCK 26 @@ -88,7 +61,17 @@ enum HS_GPIO_CONFIG #define BSP_SOFT_SPI_MIOS_PIN 25 #define BSP_SOFT_SPI_MSOI_PIN 27 #define BSP_SOFT_SPI_NCS_PIN 28 +#endif +#ifdef BSP_USING_CAMERA +#define BSP_DVP_RST_PIN 40 +#define BSP_DVP_PWDN_PIN 41 +#define BSP_DVP_XCLK_PIN 42 +#define BSP_DVP_PCLK_PIN 43 +#define BSP_DVP_HSYNC_PIN 44 +#define BSP_DVP_VSYNC_PIN 45 +#define BSP_DVP_SCL_PIN 46 +#define BSP_DVP_SDA_PIN 47 #endif #ifdef BSP_USING_LED diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/ov2640.h b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/ov2640.h new file mode 100644 index 000000000..b56c427a5 --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/ov2640.h @@ -0,0 +1,38 @@ +/* Copyright 2018 Canaan Inc. + * + * Licensed 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. + */ +#ifndef _OV2640_H +#define _OV2640_H + +#include + +#define OV2640_ADDR 0x60 + +struct CameraCfg +{ + uint16_t window_w; + uint16_t window_h; + uint16_t window_xoffset; + uint16_t window_yoffset; + uint16_t output_w; + uint16_t output_h; + uint8_t gain; + uint8_t gain_manu_enable; +}; + +int ov2640_init(void); +int ov2640_read_id(uint16_t *manuf_id, uint16_t *device_id); +int sensorConfigure(struct CameraCfg* cfg_info); + +#endif /* _OV2640_H */ diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/lcd/connect_lcd.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/lcd/connect_lcd.c index 8595bca05..dd43ac2d0 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/lcd/connect_lcd.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/lcd/connect_lcd.c @@ -342,7 +342,7 @@ static void DrvLcdRectUpdate(uint16_t x1, uint16_t y1, uint16_t width, uint16_t } } -x_err_t DrvLcdInit(Lcd8080DeviceType dev) +static x_err_t DrvLcdInit(Lcd8080DeviceType dev) { x_err_t ret = EOK; aiit_lcd = (Lcd8080DeviceType)dev; @@ -366,6 +366,8 @@ x_err_t DrvLcdInit(Lcd8080DeviceType dev) data = 0x55; DrvLcdDataByte(&data, 1); + DrvLcdCmd(INVERSION_DISPALY_ON); + /* set direction */ DrvLcdSetDirection(DIR_YX_RLUD); @@ -476,7 +478,6 @@ static uint32 LcdWrite(void *dev, struct BusBlockWriteParam *write_param) } else if(1 == show->type) //output dot { - // DrvLcdSetPixel(show->pixel_info.x_pos, show->pixel_info.y_pos, show->pixel_info.pixel_color); DrvLcdSetPixelDot(show->pixel_info.x_startpos,show->pixel_info.y_startpos, show->pixel_info.x_endpos, show->pixel_info.y_endpos,show->pixel_info.pixel_color); return EOK; } @@ -549,7 +550,7 @@ static int BoardLcdDevBend(struct LcdHardwareDevice *lcd_device, void *param, co return ret; } - +static int flag = 1; int HwLcdInit(void) { x_err_t ret = EOK; @@ -613,7 +614,11 @@ int HwLcdInit(void) KPrintf("LCD driver inited ...\r\n"); - DrvLcdInit(lcd_dev); + if(flag){ + DrvLcdInit(lcd_dev); + flag = 0; + } + return ret; } diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/spi/Kconfig b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/spi/Kconfig index de61c1ef5..d1ebdeb3c 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/spi/Kconfig +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/spi/Kconfig @@ -100,26 +100,3 @@ if BSP_USING_SPI1 endif endif -config BSP_USING_TP -bool "Using LCD touch " -default n - -if BSP_USING_TP - config BSP_TP_SCK_PIN - int "TP SCK pin number" - default 42 - config BSP_TP_NCS_PIN - int "TP NCS pin number" - default 43 - config BSP_TP_MISO_PIN - int "TP MISO pin number" - default 44 - config BSP_TP_IRQ_PIN - int "TP IRQ pin number" - default 45 - config BSP_TP_MOSI_PIN - int "TP MOSI pin number" - default 46 - -endif - diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/Kconfig b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/Kconfig index e669ed7e6..c2b9193a0 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/Kconfig +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/Kconfig @@ -10,8 +10,8 @@ if BSP_USING_TOUCH default "touch_dev" config BSP_TOUCH_TP_INT int "touch int pin" - default 36 + default 30 config FPIOA_TOUCH_TP_INT int "fpioa touch int pin" - default 12 + default 30 endif diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c index c97b68dc8..2f95c371e 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c @@ -24,21 +24,33 @@ #include #include #include +#include "gsl2038firmware.h" + + +struct Finger { + uint8_t fingerID; + uint32_t x; + uint32_t y; +}; +struct Touch_event { + uint8_t NBfingers; + struct Finger fingers[5]; +}; -// #define LCD_HEIGHT BSP_LCD_X_MAX -// #define LCD_WIDTH BSP_LCD_Y_MAX #define DEFAULT_NUM 0x0D - +#define TOUCH_ADDRESS 0x44 volatile bool SemReleaseFlag = 0; static struct Bus* i2c_bus = NONE; static struct Bus* pin_bus = NONE; int touch_sem = 0; -POINT Pre_Touch_Point; + +#define DATA_REG 0x80 +#define STATUS_REG 0xE0 /* HERE WE IMPLEMENT I2C READING AND WRITING FROM SENSOR */ /* write sensor register data */ -static x_err_t WriteReg(struct HardwareDev* dev, uint8 len, uint8* buf) +static x_err_t WriteReg(struct HardwareDev* dev, char* buf, int len) { struct BusBlockWriteParam write_param; write_param.pos = 0; @@ -62,150 +74,10 @@ static x_err_t ReadRegs(struct HardwareDev* dev, uint8 len, uint8* buf) return BusDevReadData(dev, &read_param); } -/** - * i2c_transfer - execute a single I2C message - * @msgs: One or more messages to execute before STOP is issued to - * terminate the operation; each message begins with a START. - */ -int I2C_Transfer(struct i2c_msg* msg) -{ - int16 ret = 0; - - if (msg->flags & I2C_M_RD) //根据flag判断是读数据还是写数据 - { - ret = ReadRegs(i2c_bus->owner_haldev, msg->len, msg->buf); //IIC读取数据 - } - else - { - ret = WriteReg(i2c_bus->owner_haldev, msg->len, msg->buf); //IIC写入数据 - } //正常完成的传输结构个数 - - return ret; -} - -static int32_t GtpI2cWrite(uint8_t* buf, int32_t len) -{ - struct i2c_msg msg; - int32_t ret = -1; - int32_t retries = 0; - - msg.flags = !I2C_M_RD; - msg.len = len; - msg.buf = buf; - //msg.scl_rate = 300 * 1000; // for Rockchip, etc - while (retries < 5) - { - ret = I2C_Transfer(&msg); - if (ret == 1) { break; } - retries++; - } - if (retries >= 5) - { - KPrintf("I2C Write: 0x%04X, %d bytes failed, errcode: %d! Process reset.", (((uint16_t)(buf[0] << 8)) | buf[1]), len - 2, ret); - ret = -1; - } - return ret; -} -static int32_t GtpI2cRead(uint8_t* buf, int32_t len) -{ - struct i2c_msg msgs[2]; - int32_t ret = -1; - int32_t retries = 0; - - // write reading addr. - msgs[0].flags = !I2C_M_RD; - msgs[0].len = GTP_ADDR_LENGTH; - msgs[0].buf = buf; - - // read data at addr sended. - msgs[1].flags = I2C_M_RD; - msgs[1].len = len - GTP_ADDR_LENGTH; - msgs[1].buf = &buf[GTP_ADDR_LENGTH]; - - while (retries < 5) - { - ret = I2C_Transfer(&msgs[0]); - ret += I2C_Transfer(&msgs[1]); - if (ret == 2)break; - retries++; - } - if (retries >= 5) - { - KPrintf("I2C Read: 0x%04X, %d bytes %d times failed, errcode: %d! Process reset.\n", (((uint16_t)(buf[0] << 8)) | buf[1]), len - 2, retries, ret); - ret = -1; - } - return ret; -} - -/* HERE WE IMPLEMENT TOUCH INIT */ -int32_t GtpReadVersion(void) -{ - int32_t ret = -1; - uint8_t buf[8] = { GTP_REG_VERSION >> 8, GTP_REG_VERSION & 0xff }; - - ret = GtpI2cRead(buf, sizeof(buf)); - if (ret < 0) - { - KPrintf("GTP read version failed.\n"); - return ret; - } - - if (buf[5] == 0x00) - { - KPrintf("IC1 Version: %c%c%c_%02x%02x\n", buf[2], buf[3], buf[4], buf[7], buf[6]); - } - else - { - KPrintf("IC2 Version: %c%c%c%c_%02x%02x\n", buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]); - } - return ret; -} - -static int32_t GtpGetInfo(void) -{ - uint8_t end_cmd[3] = { GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF, 0 }; - uint8_t opr_buf[6] = { 0 }; - int32_t ret = 0; - - uint16_t abs_x_max = GTP_MAX_WIDTH; - uint16_t abs_y_max = GTP_MAX_HEIGHT; - uint8_t int_trigger_type = GTP_INT_TRIGGER; - - opr_buf[0] = (uint8_t)((GTP_REG_CONFIG_DATA + 1) >> 8); - opr_buf[1] = (uint8_t)((GTP_REG_CONFIG_DATA + 1) & 0xFF); - - if (GtpI2cRead(opr_buf, 6) < 0) - { - return -1; - } - - abs_x_max = (opr_buf[3] << 8) + opr_buf[2]; - abs_y_max = (opr_buf[5] << 8) + opr_buf[4]; - - opr_buf[0] = (uint8_t)((GTP_REG_CONFIG_DATA + 6) >> 8); - opr_buf[1] = (uint8_t)((GTP_REG_CONFIG_DATA + 6) & 0xFF); - - if (GtpI2cRead(opr_buf, 3) < 0) - { - return 0; - } - - int_trigger_type = opr_buf[2] & 0x03; - KPrintf("X_MAX = %d, Y_MAX = %d, TRIGGER = 0x%02x\n", - abs_x_max, abs_y_max, int_trigger_type); - - if (GtpI2cWrite(end_cmd, 3) < 0) - { - KPrintf("I2C write end_cmd error!\n"); - ret = 0; - } - return 0; ; -} - // not used in polling mode -static void GT9xx_PEN_IRQHandler(void* arg) +static void touch_pin_irqhandler(void* arg) { - KPrintf("int hdr working.\n"); + // KPrintf("int hdr working.\n"); if (!SemReleaseFlag) { KSemaphoreAbandon(touch_sem); @@ -213,20 +85,20 @@ static void GT9xx_PEN_IRQHandler(void* arg) } } -int32_t GT9xx_INT_INIT() { +int32_t touch_irq_init() +{ int32_t ret = -ERROR; - - pin_bus = PinBusInitGet(); - struct PinParam pin_param; struct BusConfigureInfo pin_configure_info; + pin_bus = PinBusInitGet(); + pin_configure_info.configure_cmd = OPE_CFG; pin_configure_info.private_data = (void*)&pin_param; pin_param.cmd = GPIO_CONFIG_MODE; pin_param.pin = BSP_TOUCH_TP_INT; - pin_param.mode = GPIO_CFG_INPUT_PULLUP; + pin_param.mode = GPIO_CFG_INPUT; ret = BusDrvConfigure(pin_bus->owner_driver, &pin_configure_info); if (ret != EOK) { KPrintf("config pin_param %d input failed!\n", pin_param.pin); @@ -235,8 +107,8 @@ int32_t GT9xx_INT_INIT() { pin_param.cmd = GPIO_IRQ_REGISTER; pin_param.pin = BSP_TOUCH_TP_INT; - pin_param.irq_set.irq_mode = GPIO_IRQ_EDGE_FALLING; - pin_param.irq_set.hdr = GT9xx_PEN_IRQHandler; + pin_param.irq_set.irq_mode = GPIO_IRQ_EDGE_BOTH; + pin_param.irq_set.hdr = touch_pin_irqhandler; pin_param.irq_set.args = NONE; ret = BusDrvConfigure(pin_bus->owner_driver, &pin_configure_info); if (ret != EOK) { @@ -264,7 +136,7 @@ int32_t GT9xx_INT_INIT() { return EOK; } -int32_t I2C_Touch_Init() { +int32_t I2cTouchInit() { // using static bus information int32_t ret = -1; /* find I2C device and get I2C handle */ @@ -294,116 +166,68 @@ int32_t I2C_Touch_Init() { // memset(&i2c_configure_info, 0, sizeof(struct BusConfigureInfo)); i2c_configure_info.configure_cmd = OPE_INT; - uint16 i2c_address = GTP_ADDRESS >> 1; + uint16 i2c_address = TOUCH_ADDRESS; i2c_configure_info.private_data = (void*)&i2c_address; BusDrvConfigure(i2c_bus->owner_driver, &i2c_configure_info); // 3. init interruption - return GT9xx_INT_INIT(); + return touch_irq_init(); } - -/* HERE WE IMPLEMENT GET COORDINATE FUNCTION */ -/** - * @brief 触屏处理函数,轮询或者在触摸中断调用 - * @param 无 - * @retval 无 - */ -bool GetTouchEvent(POINT* touch_point, touch_event_t* touch_event) +void loadfw(struct HardwareDev *dev) { + uint8_t addr; + uint8_t Wrbuf[5]; + size_t source_len = sizeof(GSL2038_FW) / sizeof(struct fw_data); + + for (size_t source_line = 0; source_line < source_len; source_line++) { + // addr = GSL2038_FW[source_line].offset; + memset(Wrbuf, 0 , 5); + Wrbuf[0] = GSL2038_FW[source_line].offset; + Wrbuf[1] = (char)(GSL2038_FW[source_line].val & 0x000000ff); + Wrbuf[2] = (char)((GSL2038_FW[source_line].val & 0x0000ff00) >> 8); + Wrbuf[3] = (char)((GSL2038_FW[source_line].val & 0x00ff0000) >> 16); + Wrbuf[4] = (char)((GSL2038_FW[source_line].val & 0xff000000) >> 24); - uint8_t end_cmd[3] = { GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF, 0 }; - uint8_t point_data[2 + 1 + 8 * GTP_MAX_TOUCH + 1] = { GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF }; - uint8_t touch_num = 0; - uint8_t finger = 0; - static uint16_t pre_touch = 0; - - uint8_t* coor_data = NULL; - int32_t input_x = 0; - int32_t input_y = 0; - int32_t input_w = 0; - - int32_t ret = -1; - - ret = GtpI2cRead(point_data, 12);//10字节寄存器加2字节地址 - if (ret < 0) - { - KPrintf("I2C transfer error. errno:%d\n ", ret); - return 0; + WriteReg(dev, Wrbuf,5); } +} - finger = point_data[GTP_ADDR_LENGTH];//状态寄存器数据 +void reset() +{ + uint8_t REG[6] = {STATUS_REG, 0xE4, 0xbc, 0xbd, 0xbe, 0xbf}; + uint8_t DATA[6] = {0x88, 0x04, 0x00, 0x00, 0x00, 0x00}; + char reg_data[2]; - if (finger == 0x00) //没有数据,退出 + int i; + for (i = 0; i < sizeof(REG); ++i) { - ret = 0; - goto exit_work_func; + // WriteReg(i2c_bus->owner_haldev, ®[i],1); + // WriteReg(i2c_bus->owner_haldev, &DATA[i],1); + reg_data[0] = REG[i]; + reg_data[1] = DATA[i]; + WriteReg(i2c_bus->owner_haldev, reg_data,2); + MdelayKTask(10); } +} - if ((finger & 0x80) == 0)//判断buffer status位 - { - ret = 0; - goto exit_work_func;//坐标未就绪,数据无效 - } +void startchip() +{ + char reg_data[] = {0xE0, 0x00}; - touch_num = finger & 0x0f;//坐标点数 - if (touch_num > GTP_MAX_TOUCH) - { - ret = 0; - goto exit_work_func;//大于最大支持点数,错误退出 - } - - if (touch_num) - { - coor_data = &point_data[0 * 8 + 3]; - input_x = coor_data[1] | (coor_data[2] << 8); //x坐标 - input_y = coor_data[3] | (coor_data[4] << 8); //y坐标 - input_w = coor_data[5] | (coor_data[6] << 8); //size - touch_point->X = input_x; - touch_point->Y = input_y; - *touch_event = kTouch_Down; - Pre_Touch_Point = *touch_point; - - } - else if (pre_touch) //touch_ num=0 且pre_touch!=0 - { - *touch_point = Pre_Touch_Point; - *touch_event = kTouch_Up; - Pre_Touch_Point.X = -1; - Pre_Touch_Point.Y = -1; - } - pre_touch = touch_num; - -exit_work_func: - { - ret = GtpI2cWrite(end_cmd, 3); - if (ret < 0) - { - KPrintf("I2C write end_cmd error!\n"); - ret = 0; - } - } - return ret; + WriteReg(i2c_bus->owner_haldev, reg_data,2); // Registre } static uint32 TouchOpen(void* dev) { - int32_t ret = -1; + int32_t ret = 0; - I2C_Touch_Init(); - ret = GtpReadVersion(); - if (ret < 0) - { - KPrintf("gtp read version error\n"); - return ret; - } + I2cTouchInit(); - ret = GtpGetInfo(); - if (ret < 0) - { - KPrintf("gtp read info error\n"); - return ret; - } + reset(); + loadfw(i2c_bus->owner_haldev); + reset(); + startchip(); touch_sem = KSemaphoreCreate(0); if (touch_sem < 0) { @@ -415,8 +239,32 @@ static uint32 TouchOpen(void* dev) } static uint32 TouchClose(void* dev) -{ +{ + int32_t ret = -ERROR; + struct PinParam pin_param; + struct BusConfigureInfo pin_configure_info; + + pin_configure_info.configure_cmd = OPE_CFG; + pin_configure_info.private_data = (void*)&pin_param; + + pin_param.cmd = GPIO_IRQ_DISABLE; + pin_param.pin = BSP_TOUCH_TP_INT; + ret = BusDrvConfigure(pin_bus->owner_driver, &pin_configure_info); + if (ret != EOK) { + KPrintf("disable pin_param %d irq failed!\n", pin_param.pin); + return -ERROR; + } + + pin_param.cmd = GPIO_IRQ_FREE; + pin_param.pin = BSP_TOUCH_TP_INT; + ret = BusDrvConfigure(pin_bus->owner_driver, &pin_configure_info); + if (ret != EOK) { + KPrintf("register pin_param %d irq failed!\n", pin_param.pin); + return -ERROR; + } + KSemaphoreDelete(touch_sem); + return 0; } @@ -424,23 +272,35 @@ static uint32 TouchRead(void* dev, struct BusBlockReadParam* read_param) { uint32 ret = -1; x_err_t result; - POINT touch_point; - touch_point.X = -1; - touch_point.Y = -1; - touch_event_t touch_event; + uint8_t TOUCHRECDATA[24] = {0}; + struct Touch_event ts_event; + char status_reg = 0x80; struct TouchDataStandard* data = (struct TouchDataStandard*)read_param->buffer; read_param->read_length = 0; - result = KSemaphoreObtain(touch_sem, 100); - if (GetTouchEvent(&touch_point, &touch_event)) - { - data->x = touch_point.X; - data->y = touch_point.Y; + result = KSemaphoreObtain(touch_sem, 1000); + // if (EOK == result) + // { + memset(TOUCHRECDATA, 0, 24); + memset(&ts_event, 0, sizeof(struct Touch_event)); - read_param->read_length = read_param->size; - ret = EOK; - } - SemReleaseFlag = 0; + WriteReg(i2c_bus->owner_haldev, &status_reg, 1); + ReadRegs(i2c_bus->owner_haldev, 24, TOUCHRECDATA); + ts_event.NBfingers = TOUCHRECDATA[0]; + + for (int i = 0; i < ts_event.NBfingers; i++) + { + ts_event.fingers[i].x = ((((uint32_t)TOUCHRECDATA[(i * 4) + 5]) << 8) | (uint32_t)TOUCHRECDATA[(i * 4) + 4]) & 0x00000FFF; // 12 bits of X coord + ts_event.fingers[i].y = ((((uint32_t)TOUCHRECDATA[(i * 4) + 7]) << 8) | (uint32_t)TOUCHRECDATA[(i * 4) + 6]) & 0x00000FFF; + ts_event.fingers[i].fingerID = (uint32_t)TOUCHRECDATA[(i * 4) + 7] >> 4; // finger that did the touch + printf("fingers[%d] x %d y %d id %d\n",i,ts_event.fingers[i].x,ts_event.fingers[i].y,ts_event.fingers[i].fingerID); + } + + data->x = ts_event.fingers[ts_event.NBfingers - 1].x; + data->y = ts_event.fingers[ts_event.NBfingers - 1].y; + + SemReleaseFlag = 0; + // } return ret; } diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/gsl2038firmware.h b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/gsl2038firmware.h new file mode 100644 index 000000000..d21c2e295 --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/gsl2038firmware.h @@ -0,0 +1,5009 @@ +/**************************************************************************/ +/*! + @file gsl2038firmware.h + + @thanks to wireless-tag-com for the source code this firmware : https://github.com/wireless-tag-com/8ms-esp32 +*/ + +#ifndef _GSL2038_H_ +#define _GSL2038_H_ + +struct fw_data +{ + uint8_t offset; + uint32_t val; +}; + + +const struct fw_data GSL2038_FW[] = { +//GSL_2038 +{0xf0,0x2}, +{0x00,0x00000000}, +{0x04,0x00000000}, +{0x08,0x00000000}, +{0x0c,0x00000000}, +{0x10,0x00000000}, +{0x14,0x00000000}, +{0x18,0x00000000}, +{0x1c,0x00000000}, +{0x20,0x00000000}, +{0x24,0x00000000}, +{0x28,0x00000000}, +{0x2c,0x00000000}, +{0x30,0x00000000}, +{0x34,0x00000000}, +{0x38,0x00000000}, +{0x3c,0x00000000}, +{0x40,0x00000000}, +{0x44,0x00000000}, +{0x48,0x00000000}, +{0x4c,0x00000000}, +{0x50,0x000f000f}, +{0x54,0x00000000}, +{0x58,0x00000000}, +{0x5c,0x00000000}, +{0x60,0x00000000}, +{0x64,0xf801000a}, +{0x68,0x04066414}, +{0x6c,0x1001020c}, +{0x70,0x00000fff}, +{0x74,0x00000000}, +{0x78,0x00000000}, +{0x7c,0x0c020c02}, +{0xf0,0x3}, +{0x00,0xb5cbfdad}, +{0x04,0x00000000}, +{0x08,0x00400000}, +{0x0c,0x00800000}, +{0x10,0x40020000}, +{0x14,0x00000000}, +{0x18,0xff380801}, +{0x1c,0x00000000}, +{0x20,0x00000000}, +{0x24,0x00005100}, +{0x28,0x00008e00}, +{0x2c,0x00000000}, +{0x30,0x0001005d}, +{0x34,0x007d00c6}, +{0x38,0x00e60140}, +{0x3c,0x00000000}, +{0x40,0x00010001}, +{0x44,0x0035010a}, +{0x48,0x01400140}, +{0x4c,0x00000000}, +{0x50,0x00000000}, +{0x54,0x00000000}, +{0x58,0x00000080}, +{0x5c,0x00000000}, +{0x60,0x00000000}, +{0x64,0x1a0ac00a}, +{0x68,0x00000002}, +{0x6c,0x0000000f}, +{0x70,0x00000000}, +{0x74,0x00000000}, +{0x78,0xffffffec}, +{0x7c,0x00000000}, +{0xf0,0x4}, +{0x00,0x00000000}, +{0x04,0x0000b306}, +{0x08,0x00000064}, +{0x0c,0x00000fff}, +{0x10,0xfe0cff06}, +{0x14,0x00020008}, +{0x18,0x0000008c}, +{0x1c,0x03030800}, +{0x20,0x000800c0}, +{0x24,0x00000000}, +{0x28,0x80808080}, +{0x2c,0x00000000}, +{0x30,0x00010000}, +{0x34,0x00000000}, +{0x38,0x00000000}, +{0x3c,0x00000000}, +{0x40,0x00007fff}, +{0x44,0x0040002d}, +{0x48,0x00007fff}, +{0x4c,0x0040002d}, +{0x50,0x0c182430}, +{0x54,0x0c182430}, +{0x58,0x0c182430}, +{0x5c,0x0c182430}, +{0x60,0x0005000c}, +{0x64,0x00190037}, +{0x68,0x00020004}, +{0x6c,0x0008000c}, +{0x70,0x0005000c}, +{0x74,0x00190037}, +{0x78,0x0005000c}, +{0x7c,0x00190044}, +{0xf0,0x5}, +{0x00,0x0000000a}, +{0x04,0x00000001}, +{0x08,0x0000012c}, +{0x0c,0x00000000}, +{0x10,0x0000000a}, +{0x14,0x00000000}, +{0x18,0x00000fff}, +{0x1c,0x10000000}, +{0x20,0x13520042}, +{0x24,0x00000000}, +{0x28,0x00000000}, +{0x2c,0x00000400}, +{0x30,0x00000200}, +{0x34,0x1234c878}, +{0x38,0x00000001}, +{0x3c,0x00000000}, +{0x40,0x00000000}, +{0x44,0x1f808014}, +{0x48,0x03000200}, +{0x4c,0x012c044c}, +{0x50,0x00000000}, +{0x54,0x10000050}, +{0x58,0x00010002}, +{0x5c,0x00000000}, +{0x60,0x80808080}, +{0x64,0x00000000}, +{0x68,0x00000080}, +{0x6c,0x00000080}, +{0x70,0x00000011}, +{0x74,0x00000220}, +{0x78,0x00000002}, +{0x7c,0x0000000c}, +{0xf0,0x6}, +{0x00,0x0000000b}, +{0x04,0x00000000}, +{0x08,0x00000002}, +{0x0c,0x07030203}, +{0x10,0x00000032}, +{0x14,0x01080008}, +{0x18,0x00000000}, +{0x1c,0x00000001}, +{0x20,0x00002904}, +{0x24,0x00000140}, +{0x28,0x00000140}, +{0x2c,0xf801000a}, +{0x30,0xf8010008}, +{0x34,0x0000001f}, +{0x38,0x00000003}, +{0x3c,0x00000fff}, +{0x40,0x80000000}, +{0x44,0x00190019}, +{0x48,0x00000fff}, +{0x4c,0x05030203}, +{0x50,0x00000000}, +{0x54,0x000002a4}, +{0x58,0x00000000}, +{0x5c,0x00000000}, +{0x60,0x20100804}, +{0x64,0x00000000}, +{0x68,0x00000000}, +{0x6c,0x00000000}, +{0x70,0x00000000}, +{0x74,0x000000fa}, +{0x78,0x000a003c}, +{0x7c,0x00000000}, +{0xf0,0x7}, +{0x00,0x27292819}, +{0x04,0x03090208}, +{0x08,0x050b040a}, +{0x0c,0x07110610}, +{0x10,0x09130812}, +{0x14,0x00123456}, +{0x18,0x00000000}, +{0x1c,0x000a0078}, +{0x20,0x00001081}, +{0x24,0xff080010}, +{0x28,0xff080120}, +{0x2c,0xff080140}, +{0x30,0xff080160}, +{0x34,0x000002bc}, +{0x38,0x0000017d}, +{0x3c,0x00000142}, +{0x40,0x00000000}, +{0x44,0x00000000}, +{0x48,0x00000001}, +{0x4c,0x320f0f03}, +{0x50,0x00000000}, +{0x54,0x00000002}, +{0x58,0x00040000}, +{0x5c,0x00090005}, +{0x60,0x000e000a}, +{0x64,0x0013000f}, +{0x68,0x00001000}, +{0x6c,0x0004003c}, +{0x70,0x00040000}, +{0x74,0x00040000}, +{0x78,0x00012345}, +{0x7c,0x00012345}, +{0xf0,0x8}, +{0x00,0x02090c13}, +{0x04,0x10170601}, +{0x08,0x0a0e15ff}, +{0x0c,0xffffffff}, +{0x10,0xffffffff}, +{0x14,0xffffffff}, +{0x18,0xffffffff}, +{0x1c,0xffffffff}, +{0x20,0x03081116}, +{0x24,0x0d120b04}, +{0x28,0x070f14ff}, +{0x2c,0xffffffff}, +{0x30,0xffffffff}, +{0x34,0xffffffff}, +{0x38,0xffffffff}, +{0x3c,0xffffffff}, +{0x40,0x00000000}, +{0x44,0x00000000}, +{0x48,0x00000000}, +{0x4c,0x00000000}, +{0x50,0x00000000}, +{0x54,0x00000000}, +{0x58,0x00050004}, +{0x5c,0x00000000}, +{0x60,0x00000000}, +{0x64,0x00000000}, +{0x68,0x00000000}, +{0x6c,0x00000000}, +{0x70,0x00000073}, +{0x74,0x000a0019}, +{0x78,0x10000001}, +{0x7c,0x0000000c}, +{0xf0,0x9}, +{0x00,0xff080078}, +{0x04,0x00ff0011}, +{0x08,0xff08007c}, +{0x0c,0xffc00000}, +{0x10,0xfffffff0}, +{0x14,0x00000000}, +{0x18,0xfffffff0}, +{0x1c,0x00000000}, +{0x20,0xfffffff0}, +{0x24,0x00000000}, +{0x28,0xfffffff0}, +{0x2c,0x00000000}, +{0x30,0xfffffff0}, +{0x34,0x00000000}, +{0x38,0xfffffff0}, +{0x3c,0x00000000}, +{0x40,0xfffffff0}, +{0x44,0x00000000}, +{0x48,0xfffffff0}, +{0x4c,0x00000000}, +{0x50,0xfffffff0}, +{0x54,0x00000000}, +{0x58,0xfffffff0}, +{0x5c,0x00000000}, +{0x60,0xfffffff0}, +{0x64,0x00000000}, +{0x68,0xfffffff0}, +{0x6c,0x00000000}, +{0x70,0xfffffff0}, +{0x74,0x00000000}, +{0x78,0xfffffff0}, +{0x7c,0x00000000}, +{0xf0,0x1a}, +{0x00,0x00000000}, +{0x04,0x00000000}, +{0x08,0x00000000}, +{0x0c,0x00000000}, +{0x10,0x00000000}, +{0x14,0x00000000}, +{0x18,0x00000000}, +{0x1c,0x00000000}, +{0x20,0x00020000}, +{0x24,0x00000000}, +{0x28,0x00000000}, +{0x2c,0x00000000}, +{0x30,0x00020000}, +{0x34,0x00000000}, +{0x38,0x00000000}, +{0x3c,0x00000000}, +{0x40,0x00020000}, +{0x44,0x00000000}, +{0x48,0x00000000}, +{0x4c,0x00000000}, +{0x50,0x00020000}, +{0x54,0x00000000}, +{0x58,0x00000000}, +{0x5c,0x00000000}, +{0x60,0x00020000}, +{0x64,0x00000000}, +{0x68,0x00000000}, +{0x6c,0x00000000}, +{0x70,0x00020000}, +{0x74,0x00000000}, +{0x78,0x00000000}, +{0x7c,0x00000000}, +{0xf0,0x1b}, +{0x00,0x00020000}, +{0x04,0x00000000}, +{0x08,0x00000000}, +{0x0c,0x00000000}, +{0x10,0x00020000}, +{0x14,0x00000000}, +{0x18,0x00000000}, +{0x1c,0x00000000}, +{0x20,0x00020000}, +{0x24,0x00000000}, +{0x28,0x00000000}, +{0x2c,0x00000000}, +{0x30,0x00020000}, +{0x34,0x00000000}, +{0x38,0x00000000}, +{0x3c,0x00000000}, +{0x40,0x00020000}, +{0x44,0x00000000}, +{0x48,0x00000000}, +{0x4c,0x00000000}, +{0x50,0x00020000}, +{0x54,0x00000000}, +{0x58,0x00000000}, +{0x5c,0x00000000}, +{0x60,0x00020000}, +{0x64,0x00000000}, +{0x68,0x00000000}, +{0x6c,0x00000000}, +{0x70,0x00020000}, +{0x74,0x00000000}, +{0x78,0x00000000}, +{0x7c,0x00000000}, +{0xf0,0x1c}, +{0x00,0x00009249}, +{0x04,0x02412492}, +{0x08,0x0481b6db}, +{0x0c,0x06c24924}, +{0x10,0x0902db6d}, +{0x14,0x0b436db6}, +{0x18,0x0d93ffff}, +{0x1c,0x00000000}, +{0x20,0x0000003f}, +{0x24,0x0000003f}, +{0x28,0x0000003f}, +{0x2c,0x0000003f}, +{0x30,0x0000003f}, +{0x34,0x0000003f}, +{0x38,0x0000003f}, +{0x3c,0x00000000}, +{0x40,0x7e7e7e7e}, +{0x44,0x7d7d7e7e}, +{0x48,0x7d7d7d7d}, +{0x4c,0x7b7b7b7b}, +{0x50,0x77777b7b}, +{0x54,0x77777777}, +{0x58,0x6f6f6f6f}, +{0x5c,0x5f5f6f6f}, +{0x60,0x5f5f5f5f}, +{0x64,0x3f3f3f3f}, +{0x68,0x00003f3f}, +{0x6c,0x00000000}, +{0x70,0x00000000}, +{0x74,0x00000000}, +{0x78,0x00000000}, +{0x7c,0x5a5a5a5a}, +{0xf0,0x1d}, +{0x00,0x00013c4d}, +{0x04,0x024223ab}, +{0x08,0x048298f2}, +{0x0c,0x06c0d716}, +{0x10,0x0901c499}, +{0x14,0x0b436b64}, +{0x18,0x0d93ffff}, +{0x1c,0x00000000}, +{0x20,0x0000002d}, +{0x24,0x0000003f}, +{0x28,0x0000003f}, +{0x2c,0x0000003f}, +{0x30,0x00000000}, +{0x34,0x00000000}, +{0x38,0x00000000}, +{0x3c,0x00000000}, +{0x40,0x5f7e7e6f}, +{0x44,0x6f7b7d7b}, +{0x48,0x777d7e5f}, +{0x4c,0x777b5f7d}, +{0x50,0x7d5f6f7e}, +{0x54,0x7e6f7b77}, +{0x58,0x7d7d7b7e}, +{0x5c,0x77777b77}, +{0x60,0x5f5f6f6f}, +{0x64,0x3f3f3f3f}, +{0x68,0x00003f3f}, +{0x6c,0x00000000}, +{0x70,0x00000000}, +{0x74,0x00000000}, +{0x78,0x00000000}, +{0x7c,0x5a5a5a5a}, + +/* +{0xf0,0xe0}, +{0x00,0x00000000}, +{0x04,0x00000000}, +{0x08,0x00000000}, +{0x0c,0x00000000}, +{0x10,0x00000000}, +{0x14,0x00000000}, +{0x18,0x00000000}, +{0x1c,0x00000000}, +{0x20,0x00000000}, +{0x24,0x00000000}, +{0x28,0x00000000}, +{0x2c,0x00000000}, +{0x30,0x00000000}, +{0x34,0x00000000}, +{0x38,0x00000000}, +{0x3c,0x00000000}, +{0x40,0x00780226}, +{0x44,0x00780078}, +{0x48,0x01b80078}, +{0x4c,0x007801b8}, +{0x50,0x00780078}, +{0x54,0x014a0078}, +{0x58,0x014a014a}, +{0x5c,0x0050014a}, +{0x60,0x00640000}, +{0x64,0x00640064}, +{0x68,0x0000003c}, +{0x6c,0x005a0000}, +{0x70,0x00000000}, +{0x74,0x00000000}, +{0x78,0x00000000}, +{0x7c,0x00000000}, +*/ +{0xf0,0x1e}, +{0x00,0x5a5a0f00}, +{0x04,0x00003a24}, +{0x08,0x00003a94}, +{0x0c,0x00003c88}, +{0x10,0x00003e2c}, +{0x14,0x00003e60}, +{0x18,0x00004014}, +{0x1c,0x00004198}, +{0x20,0x00004384}, +{0x24,0x00004614}, +{0x28,0x00004754}, +{0x2c,0x00004810}, +{0x30,0x00004894}, +{0x34,0x0000498c}, +{0x38,0x00004c5c}, +{0x3c,0x00004d00}, +{0x40,0x00004eb4}, +{0x44,0x00005060}, +{0x48,0x00000000}, +{0x4c,0x00000000}, +{0x50,0x00000000}, +{0x54,0x00000000}, +{0x58,0x00000000}, +{0x5c,0x00000000}, +{0x60,0x00000000}, +{0x64,0x00000000}, +{0x68,0x00000000}, +{0x6c,0x00000000}, +{0x70,0x00000000}, +{0x74,0x00000000}, +{0x78,0x00000000}, +{0x7c,0x00000000}, +{0xf0,0x1f}, +{0x00,0x00000000}, +{0x04,0x00000000}, +{0x08,0x00000000}, +{0x0c,0x00000000}, +{0x10,0x00000000}, +{0x14,0x00000000}, +{0x18,0x00000000}, +{0x1c,0x00000000}, +{0x20,0x00000000}, +{0x24,0x00000000}, +{0x28,0x00000000}, +{0x2c,0x00000000}, +{0x30,0x00000000}, +{0x34,0x00000000}, +{0x38,0x00000000}, +{0x3c,0x00000000}, +{0x40,0x00000000}, +{0x44,0x00000000}, +{0x48,0x00000000}, +{0x4c,0x00000000}, +{0x50,0x00000000}, +{0x54,0x00000000}, +{0x58,0x00000000}, +{0x5c,0x00002d70}, +{0x60,0x00003068}, +{0x64,0x000036e0}, +{0x68,0x00000000}, +{0x6c,0x0000374c}, +{0x70,0x00000000}, +{0x74,0x0000396c}, +{0x78,0x00005204}, +{0x7c,0x5a5a0ffc}, +{0xf0,0x0}, +{0x00,0x01000000}, +{0x04,0x01000000}, +{0x08,0x01000000}, +{0x0c,0x233fc0c0}, +{0x10,0xa2146004}, +{0x14,0xa4102000}, +{0x18,0xe4244000}, +{0x1c,0x233fc0c0}, +{0x20,0xa2146010}, +{0x24,0x2500003f}, +{0x28,0xa414a3ff}, +{0x2c,0xe4244000}, +{0x30,0x01000000}, +{0x34,0x821020e0}, +{0x38,0x81880001}, +{0x3c,0x01000000}, +{0x40,0x01000000}, +{0x44,0xa410200f}, +{0x48,0xe4a00040}, +{0x4c,0x01000000}, +{0x50,0xa0100000}, +{0x54,0xa2100000}, +{0x58,0xa4100000}, +{0x5c,0xa6100000}, +{0x60,0xa8100000}, +{0x64,0xaa100000}, +{0x68,0xac100000}, +{0x6c,0xae100000}, +{0x70,0x90100000}, +{0x74,0x92100000}, +{0x78,0x94100000}, +{0x7c,0x96100000}, +{0xf0,0x1}, +{0x00,0x98100000}, +{0x04,0x9a100000}, +{0x08,0x9c100000}, +{0x0c,0x9e100000}, +{0x10,0x84100000}, +{0x14,0x01000000}, +{0x18,0x01000000}, +{0x1c,0x82100000}, +{0x20,0x81900001}, +{0x24,0x82100000}, +{0x28,0x81980001}, +{0x2c,0x81800000}, +{0x30,0x01000000}, +{0x34,0x01000000}, +{0x38,0x01000000}, +{0x3c,0xbc102cfc}, +{0x40,0x9c102cf8}, +{0x44,0x01000000}, +{0x48,0x01000000}, +{0x4c,0x27001040}, +{0x50,0xa614e00f}, +{0x54,0xe6a00040}, +{0x58,0x01000000}, +{0x5c,0x400006ca}, +{0x60,0x01000000}, +{0x64,0x01000000}, +{0x68,0x10bfffff}, +{0x6c,0x01000000}, +{0x70,0x03169684}, +{0x74,0x82106053}, +{0x78,0x03296948}, +{0x7c,0x82106133}, +{0xf0,0x20}, +{0x00,0x83580000}, +{0x04,0x82086ff0}, +{0x08,0x83306004}, +{0x0c,0x80a06005}, +{0x10,0x02800027}, +{0x14,0x01000000}, +{0x18,0x80a06006}, +{0x1c,0x0280003c}, +{0x20,0x01000000}, +{0x24,0x80a06015}, +{0x28,0x02800054}, +{0x2c,0x01000000}, +{0x30,0x80a0602a}, +{0x34,0x02800090}, +{0x38,0x01000000}, +{0x3c,0x80a06018}, +{0x40,0x02800085}, +{0x44,0x01000000}, +{0x48,0x073fc180}, +{0x4c,0x8610e03c}, +{0x50,0x05169680}, +{0x54,0x84004002}, +{0x58,0xc420c000}, +{0x5c,0x073fc000}, +{0x60,0x8610e020}, +{0x64,0x84102001}, +{0x68,0xc420c000}, +{0x6c,0x0500000c}, +{0x70,0x01000000}, +{0x74,0x01000000}, +{0x78,0x8480bfff}, +{0x7c,0x12bffffe}, +{0xf0,0x21}, +{0x00,0x01000000}, +{0x04,0x01000000}, +{0x08,0x073fc000}, +{0x0c,0x8610e020}, +{0x10,0x84102000}, +{0x14,0xc420c000}, +{0x18,0x01000000}, +{0x1c,0x01000000}, +{0x20,0x81c44000}, +{0x24,0x81cc8000}, +{0x28,0x01000000}, +{0x2c,0xa7500000}, +{0x30,0xa92ce002}, +{0x34,0xa734e001}, +{0x38,0xa614c014}, +{0x3c,0xa60ce007}, +{0x40,0x81900000}, +{0x44,0x01000000}, +{0x48,0x01000000}, +{0x4c,0x81e00000}, +{0x50,0xe03ba000}, +{0x54,0xe43ba008}, +{0x58,0xe83ba010}, +{0x5c,0xec3ba018}, +{0x60,0xf03ba020}, +{0x64,0xf43ba028}, +{0x68,0xf83ba030}, +{0x6c,0xfc3ba038}, +{0x70,0x81e80000}, +{0x74,0x8194c000}, +{0x78,0x01000000}, +{0x7c,0x01000000}, +{0xf0,0x22}, +{0x00,0x81c44000}, +{0x04,0x81cc8000}, +{0x08,0x01000000}, +{0x0c,0xa7500000}, +{0x10,0xa934e002}, +{0x14,0xa72ce001}, +{0x18,0xa614c014}, +{0x1c,0xa60ce007}, +{0x20,0x81900000}, +{0x24,0x01000000}, +{0x28,0x01000000}, +{0x2c,0x81e80000}, +{0x30,0x81e80000}, +{0x34,0xe01ba000}, +{0x38,0xe41ba008}, +{0x3c,0xe81ba010}, +{0x40,0xec1ba018}, +{0x44,0xf01ba020}, +{0x48,0xf41ba028}, +{0x4c,0xf81ba030}, +{0x50,0xfc1ba038}, +{0x54,0x81e00000}, +{0x58,0x81e00000}, +{0x5c,0x8194c000}, +{0x60,0x01000000}, +{0x64,0x01000000}, +{0x68,0x81c44000}, +{0x6c,0x81cc8000}, +{0x70,0x01000000}, +{0x74,0x01000000}, +{0x78,0x82102010}, +{0x7c,0x273fc0c0}, +{0xf0,0x23}, +{0x00,0xa614e010}, +{0x04,0xc224c000}, +{0x08,0x01000000}, +{0x0c,0x033fc0c0}, +{0x10,0x82106004}, +{0x14,0xa6102000}, +{0x18,0xe6204000}, +{0x1c,0x01000000}, +{0x20,0x01000000}, +{0x24,0x01000000}, +{0x28,0xa6102020}, +{0x2c,0x83480000}, +{0x30,0x82104013}, +{0x34,0x81884000}, +{0x38,0x01000000}, +{0x3c,0x40000656}, +{0x40,0x01000000}, +{0x44,0x01000000}, +{0x48,0x01000000}, +{0x4c,0xa7500000}, +{0x50,0xa934e002}, +{0x54,0xa72ce001}, +{0x58,0xa614c014}, +{0x5c,0xa60ce007}, +{0x60,0x81900000}, +{0x64,0x01000000}, +{0x68,0x81e80000}, +{0x6c,0xe01ba000}, +{0x70,0xe41ba008}, +{0x74,0xe81ba010}, +{0x78,0xec1ba018}, +{0x7c,0xf01ba020}, +{0xf0,0x24}, +{0x00,0xf41ba028}, +{0x04,0xf81ba030}, +{0x08,0xfc1ba038}, +{0x0c,0x81e00000}, +{0x10,0x8194c000}, +{0x14,0x01000000}, +{0x18,0xa6102020}, +{0x1c,0x83480000}, +{0x20,0x82284013}, +{0x24,0x81884000}, +{0x28,0x01000000}, +{0x2c,0x033fc0c0}, +{0x30,0x82106004}, +{0x34,0xa6103fff}, +{0x38,0xe6204000}, +{0x3c,0x01000000}, +{0x40,0x01000000}, +{0x44,0x01000000}, +{0x48,0x81c44000}, +{0x4c,0x81cc8000}, +{0x50,0x01000000}, +{0x54,0x82102080}, +{0x58,0x273fc0c0}, +{0x5c,0xa614e010}, +{0x60,0xc224c000}, +{0x64,0x01000000}, +{0x68,0x81c44000}, +{0x6c,0x81cc8000}, +{0x70,0x01000000}, +{0x74,0x81c48000}, +{0x78,0x81cca004}, +{0x7c,0x01000000}, +{0xf0,0x25}, +{0x00,0x1b3fc140}, +{0x04,0x82136048}, +{0x08,0xc2104000}, +{0x0c,0x82006003}, +{0x10,0x82086003}, +{0x14,0x83286002}, +{0x18,0x9a136080}, +{0x1c,0x81c3e008}, +{0x20,0xd000400d}, +{0x24,0x9de3bf98}, +{0x28,0x9e100018}, +{0x2c,0xb4102000}, +{0x30,0xb2102000}, +{0x34,0x832ea002}, +{0x38,0xf00063a4}, +{0x3c,0xb6102000}, +{0x40,0xb806400f}, +{0x44,0xbb2ee002}, +{0x48,0xc2070000}, +{0x4c,0xb606e001}, +{0x50,0xc226001d}, +{0x54,0x80a6e002}, +{0x58,0x04bffffb}, +{0x5c,0xb8072004}, +{0x60,0xb406a001}, +{0x64,0x80a6a003}, +{0x68,0x04bffff3}, +{0x6c,0xb2066018}, +{0x70,0x81c7e008}, +{0x74,0x81e80000}, +{0x78,0x82020008}, +{0x7c,0x82004008}, +{0xf0,0x26}, +{0x00,0x9b326002}, +{0x04,0x82004001}, +{0x08,0x8200400d}, +{0x0c,0x83286002}, +{0x10,0x920a6003}, +{0x14,0x932a6003}, +{0x18,0xd00065b0}, +{0x1c,0x91320009}, +{0x20,0x81c3e008}, +{0x24,0x900a20ff}, +{0x28,0x9a020008}, +{0x2c,0x9a034008}, +{0x30,0x83326002}, +{0x34,0x9a03400d}, +{0x38,0x9a034001}, +{0x3c,0x920a6003}, +{0x40,0x932a6003}, +{0x44,0x9b2b6002}, +{0x48,0x821020ff}, +{0x4c,0xd80365b0}, +{0x50,0x83284009}, +{0x54,0x822b0001}, +{0x58,0x952a8009}, +{0x5c,0x8210400a}, +{0x60,0x81c3e008}, +{0x64,0xc22365b0}, +{0x68,0x9a020008}, +{0x6c,0x9a034008}, +{0x70,0x97326002}, +{0x74,0x9a03400d}, +{0x78,0x9a03400b}, +{0x7c,0x920a6003}, +{0xf0,0x27}, +{0x00,0x9b2b6002}, +{0x04,0x932a6003}, +{0x08,0x821020ff}, +{0x0c,0xd80365b0}, +{0x10,0x83284009}, +{0x14,0x822b0001}, +{0x18,0x952a8009}, +{0x1c,0x8210400a}, +{0x20,0xc22365b0}, +{0x24,0x912a2002}, +{0x28,0xda0223a4}, +{0x2c,0x972ae002}, +{0x30,0x81c3e008}, +{0x34,0xc223400b}, +{0x38,0x82102005}, +{0x3c,0x1b3fc200}, +{0x40,0x82204008}, +{0x44,0x9a136008}, +{0x48,0x83286002}, +{0x4c,0xd0034000}, +{0x50,0x91320001}, +{0x54,0x81c3e008}, +{0x58,0x900a200f}, +{0x5c,0xc200247c}, +{0x60,0x905a0001}, +{0x64,0x921a6001}, +{0x68,0x92024008}, +{0x6c,0x92024009}, +{0x70,0x81c3e008}, +{0x74,0xd0128009}, +{0x78,0x9de3bf98}, +{0x7c,0xc200247c}, +{0xf0,0x28}, +{0x00,0x83306001}, +{0x04,0x80a60001}, +{0x08,0x1a800006}, +{0x0c,0x90100018}, +{0x10,0x7fffffea}, +{0x14,0x01000000}, +{0x18,0x10800006}, +{0x1c,0xb0020008}, +{0x20,0x7fffffe6}, +{0x24,0x90260001}, +{0x28,0x90020008}, +{0x2c,0xb0022001}, +{0x30,0x81c7e008}, +{0x34,0x81e80000}, +{0x38,0x9de3bf90}, +{0x3c,0x03008060}, +{0x40,0xe8002348}, +{0x44,0x82106040}, +{0x48,0xc227bff0}, +{0x4c,0x03080402}, +{0x50,0x82106004}, +{0x54,0xc227bff4}, +{0x58,0xa2102000}, +{0x5c,0xc20023d4}, +{0x60,0x80a44001}, +{0x64,0x1a80002f}, +{0x68,0xa4102000}, +{0x6c,0xc200247c}, +{0x70,0x80a48001}, +{0x74,0x3a800027}, +{0x78,0xa2046001}, +{0x7c,0x7fffffdf}, +{0xf0,0x29}, +{0x00,0x90100012}, +{0x04,0xa6100008}, +{0x08,0x90100011}, +{0x0c,0x7fffff9b}, +{0x10,0x92100013}, +{0x14,0x80a62000}, +{0x18,0x12800004}, +{0x1c,0xa0100008}, +{0x20,0x10800013}, +{0x24,0xa0102000}, +{0x28,0x80a62008}, +{0x2c,0x1880000e}, +{0x30,0x80a62007}, +{0x34,0x7fffff73}, +{0x38,0x01000000}, +{0x3c,0x94100008}, +{0x40,0x90100011}, +{0x44,0x7fffffc6}, +{0x48,0x92100012}, +{0x4c,0x80a20014}, +{0x50,0x04800004}, +{0x54,0x8206001e}, +{0x58,0xc2087fef}, +{0x5c,0xa02c0001}, +{0x60,0x80a62007}, +{0x64,0x18800006}, +{0x68,0x92100013}, +{0x6c,0x8206001e}, +{0x70,0xc2087ff0}, +{0x74,0xa0140001}, +{0x78,0x92100013}, +{0x7c,0x94100010}, +{0xf0,0x2a}, +{0x00,0x7fffff9a}, +{0x04,0x90100011}, +{0x08,0x10bfffd9}, +{0x0c,0xa404a001}, +{0x10,0xc20023d4}, +{0x14,0x80a44001}, +{0x18,0x0abfffd5}, +{0x1c,0xa4102000}, +{0x20,0x81c7e008}, +{0x24,0x81e80000}, +{0x28,0x98102000}, +{0x2c,0x9610201e}, +{0x30,0x80a22000}, +{0x34,0x12800003}, +{0x38,0x8210000c}, +{0x3c,0x8222c00c}, +{0x40,0x83286002}, +{0x44,0xda006480}, +{0x48,0x80a37ff0}, +{0x4c,0x02800006}, +{0x50,0x98032002}, +{0x54,0xc2006484}, +{0x58,0x80a3201f}, +{0x5c,0x04bffff5}, +{0x60,0xc2234000}, +{0x64,0x81c3e008}, +{0x68,0x01000000}, +{0x6c,0x9de3bf98}, +{0x70,0xfa002508}, +{0x74,0x033fc000}, +{0x78,0xba0f4001}, +{0x7c,0x373fc180}, +{0xf0,0x2b}, +{0x00,0x03202020}, +{0x04,0x82106080}, +{0x08,0xb816e038}, +{0x0c,0xc2270000}, +{0x10,0x03168000}, +{0x14,0x80a74001}, +{0x18,0xc026c000}, +{0x1c,0x1280000b}, +{0x20,0x98102000}, +{0x24,0x0300003f}, +{0x28,0xfa002548}, +{0x2c,0x821063ff}, +{0x30,0xba0f4001}, +{0x34,0xf8002508}, +{0x38,0x033fffc0}, +{0x3c,0xb80f0001}, +{0x40,0xba17401c}, +{0x44,0xfa202548}, +{0x48,0x80a62000}, +{0x4c,0x1680000a}, +{0x50,0x82380018}, +{0x54,0x3b3fc040}, +{0x58,0xc2002548}, +{0x5c,0x8208401d}, +{0x60,0x3b168040}, +{0x64,0x80a0401d}, +{0x68,0x22800002}, +{0x6c,0x98102001}, +{0x70,0x82380018}, +{0x74,0x8330601f}, +{0x78,0xb410400c}, +{0x7c,0xf200254c}, +{0xf0,0x2c}, +{0x00,0xd6002548}, +{0x04,0xb8102500}, +{0x08,0x82073a50}, +{0x0c,0x80a32000}, +{0x10,0x02800009}, +{0x14,0xb61f250c}, +{0x18,0x80a060f0}, +{0x1c,0xba402000}, +{0x20,0x80a0001b}, +{0x24,0x82603fff}, +{0x28,0x80974001}, +{0x2c,0x3280000a}, +{0x30,0xb8072004}, +{0x34,0x80a6a000}, +{0x38,0x02800005}, +{0x3c,0x82073960}, +{0x40,0x80a0603f}, +{0x44,0x28800004}, +{0x48,0xb8072004}, +{0x4c,0xc0270000}, +{0x50,0xb8072004}, +{0x54,0x80a7286f}, +{0x58,0x08bfffed}, +{0x5c,0x82073a50}, +{0x60,0x80a62000}, +{0x64,0x06800005}, +{0x68,0x0300003f}, +{0x6c,0x821063ff}, +{0x70,0x820e4001}, +{0x74,0xc220254c}, +{0x78,0xc2002548}, +{0x7c,0xf6002334}, +{0xf0,0x2d}, +{0x00,0xfa0023c8}, +{0x04,0xb606e001}, +{0x08,0x9e087dff}, +{0x0c,0xbb376012}, +{0x10,0xc200254c}, +{0x14,0xba0f6200}, +{0x18,0xb936e001}, +{0x1c,0x1b3fc200}, +{0x20,0x9e13c01d}, +{0x24,0xb806c01c}, +{0x28,0x82087ffd}, +{0x2c,0xfa002344}, +{0x30,0xc220254c}, +{0x34,0xf820258c}, +{0x38,0xb4136030}, +{0x3c,0xfa268000}, +{0x40,0xb2136038}, +{0x44,0xfa264000}, +{0x48,0xb132e018}, +{0x4c,0xfa20257c}, +{0x50,0x80a6205a}, +{0x54,0xf6202554}, +{0x58,0xf6202588}, +{0x5c,0xde202548}, +{0x60,0x12800009}, +{0x64,0xfa202570}, +{0x68,0x0300003f}, +{0x6c,0x821063ff}, +{0x70,0x3b3fffc0}, +{0x74,0x820bc001}, +{0x78,0xba0ac01d}, +{0x7c,0x8210401d}, +{0xf0,0x2e}, +{0x00,0xc2202548}, +{0x04,0x80a32001}, +{0x08,0x1280000e}, +{0x0c,0x01000000}, +{0x10,0xc2002548}, +{0x14,0x83306011}, +{0x18,0x80886001}, +{0x1c,0x02800006}, +{0x20,0x82102059}, +{0x24,0xba136074}, +{0x28,0xc2002330}, +{0x2c,0xc2274000}, +{0x30,0x82102059}, +{0x34,0xc2202500}, +{0x38,0x7ffffedb}, +{0x3c,0x91e825b0}, +{0x40,0x01000000}, +{0x44,0x81c7e008}, +{0x48,0x81e80000}, +{0x4c,0x033fc200}, +{0x50,0x961060a0}, +{0x54,0x98102000}, +{0x58,0x9b2b2002}, +{0x5c,0x98032001}, +{0x60,0xc2036e80}, +{0x64,0x80a32006}, +{0x68,0x04bffffc}, +{0x6c,0xc223400b}, +{0x70,0x81c3e008}, +{0x74,0x01000000}, +{0x78,0x9de3bf98}, +{0x7c,0x3b3fc200}, +{0xf0,0x2f}, +{0x00,0x03000017}, +{0x04,0xb410001d}, +{0x08,0x9e106324}, +{0x0c,0xb817612c}, +{0x10,0xb6102000}, +{0x14,0xb0176140}, +{0x18,0xb2176160}, +{0x1c,0x80a70018}, +{0x20,0x12800004}, +{0x24,0x80a70019}, +{0x28,0x10800004}, +{0x2c,0xb816a14c}, +{0x30,0x22800002}, +{0x34,0xb816a16c}, +{0x38,0xc203c000}, +{0x3c,0x80a00001}, +{0x40,0x832ee002}, +{0x44,0xc2006ec0}, +{0x48,0xba403fff}, +{0x4c,0x8208401d}, +{0x50,0xc2270000}, +{0x54,0xb606e001}, +{0x58,0x80a6e00a}, +{0x5c,0x08bffff0}, +{0x60,0xb8072004}, +{0x64,0x81c7e008}, +{0x68,0x81e80000}, +{0x6c,0x9de3bf98}, +{0x70,0x3b3fc200}, +{0x74,0x030001c0}, +{0x78,0xb8176094}, +{0x7c,0x82106011}, +{0xf0,0x30}, +{0x00,0xc2270000}, +{0x04,0xb4176090}, +{0x08,0x03000100}, +{0x0c,0xc2268000}, +{0x10,0xb2176068}, +{0x14,0x030000c0}, +{0x18,0xc2264000}, +{0x1c,0x03004009}, +{0x20,0xb0176064}, +{0x24,0x82106182}, +{0x28,0xc2260000}, +{0x2c,0x0300065f}, +{0x30,0x9e17604c}, +{0x34,0x821063ff}, +{0x38,0xc223c000}, +{0x3c,0x033fc1c0}, +{0x40,0xb8102002}, +{0x44,0xf8204000}, +{0x48,0x96176024}, +{0x4c,0x9a176060}, +{0x50,0x03000811}, +{0x54,0xba176058}, +{0x58,0xc2274000}, +{0x5c,0x373fc140}, +{0x60,0x9816e040}, +{0x64,0x82102015}, +{0x68,0xc2230000}, +{0x6c,0x821020ff}, +{0x70,0xc222c000}, +{0x74,0xb616e020}, +{0x78,0xc0234000}, +{0x7c,0xc026c000}, +{0xf0,0x31}, +{0x00,0x81c7e008}, +{0x04,0x81e80000}, +{0x08,0x832a2008}, +{0x0c,0x1b000040}, +{0x10,0x82004008}, +{0x14,0x9a136101}, +{0x18,0x9a234001}, +{0x1c,0x033fc200}, +{0x20,0x81c3e008}, +{0x24,0xda204000}, +{0x28,0x9de3bf98}, +{0x2c,0x4000022b}, +{0x30,0x01000000}, +{0x34,0x9a102000}, +{0x38,0xc2002300}, +{0x3c,0x80a34001}, +{0x40,0x1a80000d}, +{0x44,0x03000019}, +{0x48,0x9610632c}, +{0x4c,0x98106328}, +{0x50,0x832b6003}, +{0x54,0xc020400b}, +{0x58,0xc020400c}, +{0x5c,0x9a036001}, +{0x60,0xc2002300}, +{0x64,0x80a34001}, +{0x68,0x0abffffb}, +{0x6c,0x832b6003}, +{0x70,0x9a102000}, +{0x74,0xc2002304}, +{0x78,0x80a34001}, +{0x7c,0x1a80000a}, +{0xf0,0x32}, +{0x00,0x03000019}, +{0x04,0x981063c0}, +{0x08,0x832b6002}, +{0x0c,0xc020400c}, +{0x10,0x9a036001}, +{0x14,0xc2002304}, +{0x18,0x80a34001}, +{0x1c,0x0abffffc}, +{0x20,0x832b6002}, +{0x24,0x40000460}, +{0x28,0x90102000}, +{0x2c,0x7fffffd7}, +{0x30,0x90102000}, +{0x34,0x193fc200}, +{0x38,0xa2132074}, +{0x3c,0xea0021fc}, +{0x40,0xc2002298}, +{0x44,0x98132070}, +{0x48,0xc2230000}, +{0x4c,0x033fc000}, +{0x50,0xd8002338}, +{0x54,0x82106030}, +{0x58,0xd8204000}, +{0x5c,0xc200232c}, +{0x60,0xc2244000}, +{0x64,0x1b3fc140}, +{0x68,0x0300003f}, +{0x6c,0x17000019}, +{0x70,0xa0136058}, +{0x74,0x821063ff}, +{0x78,0xc2240000}, +{0x7c,0x9e136080}, +{0xf0,0x33}, +{0x00,0x9212e0e8}, +{0x04,0xd223c000}, +{0x08,0x9412e148}, +{0x0c,0xa613608c}, +{0x10,0xa412e208}, +{0x14,0xa813605c}, +{0x18,0x90136084}, +{0x1c,0xd4220000}, +{0x20,0x9a136088}, +{0x24,0x9612e1a8}, +{0x28,0xd6234000}, +{0x2c,0x033fc0c0}, +{0x30,0xe424c000}, +{0x34,0x82106004}, +{0x38,0xc0204000}, +{0x3c,0xc0250000}, +{0x40,0x80a56000}, +{0x44,0xc2002374}, +{0x48,0xd800247c}, +{0x4c,0xd40023d4}, +{0x50,0xec0023f8}, +{0x54,0x02800006}, +{0x58,0xee002340}, +{0x5c,0x82584015}, +{0x60,0x82006800}, +{0x64,0x10800003}, +{0x68,0xab30600c}, +{0x6c,0xaa100001}, +{0x70,0x1b3fc140}, +{0x74,0x96136040}, +{0x78,0xe602c000}, +{0x7c,0x99332001}, +{0xf0,0x34}, +{0x00,0x825b000a}, +{0x04,0xa60cf800}, +{0x08,0xa614c001}, +{0x0c,0xe622c000}, +{0x10,0x82136004}, +{0x14,0xe6004000}, +{0x18,0xa60cffe0}, +{0x1c,0xa614c00c}, +{0x20,0xe6204000}, +{0x24,0x293fc200}, +{0x28,0x82152080}, +{0x2c,0xe6004000}, +{0x30,0xa60cffe0}, +{0x34,0xa614c00c}, +{0x38,0xe6204000}, +{0x3c,0x9215207c}, +{0x40,0xe6024000}, +{0x44,0x033ff000}, +{0x48,0xa62cc001}, +{0x4c,0x82102114}, +{0x50,0x96152054}, +{0x54,0xc222c000}, +{0x58,0x98152008}, +{0x5c,0xec230000}, +{0x60,0x253fc1c0}, +{0x64,0xe6224000}, +{0x68,0x9014a064}, +{0x6c,0x0300007f}, +{0x70,0xee220000}, +{0x74,0x94136010}, +{0x78,0x821063ff}, +{0x7c,0xc2228000}, +{0xf0,0x35}, +{0x00,0xa2136030}, +{0x04,0x1f07ffc0}, +{0x08,0xde244000}, +{0x0c,0xa015200c}, +{0x10,0xec240000}, +{0x14,0x82102003}, +{0x18,0x9a136014}, +{0x1c,0xc2248000}, +{0x20,0x80a56000}, +{0x24,0x0280000f}, +{0x28,0xde234000}, +{0x2c,0x952d6010}, +{0x30,0x82056001}, +{0x34,0x9b2d6004}, +{0x38,0x83286010}, +{0x3c,0x9a02800d}, +{0x40,0x98152084}, +{0x44,0xda230000}, +{0x48,0x82004015}, +{0x4c,0x96152088}, +{0x50,0x9215208c}, +{0x54,0x82006002}, +{0x58,0xd422c000}, +{0x5c,0xc2224000}, +{0x60,0xc2002174}, +{0x64,0x80a06000}, +{0x68,0x02800008}, +{0x6c,0x21000017}, +{0x70,0x173fc080}, +{0x74,0xc2082174}, +{0x78,0xda082177}, +{0x7c,0x9812e008}, +{0xf0,0x36}, +{0x00,0xc2230000}, +{0x04,0xda22c000}, +{0x08,0x8214231c}, +{0x0c,0xc0204000}, +{0x10,0x9a142318}, +{0x14,0xc0234000}, +{0x18,0x98142328}, +{0x1c,0xc0230000}, +{0x20,0x9614232c}, +{0x24,0xc022c000}, +{0x28,0x94142330}, +{0x2c,0xc0228000}, +{0x30,0x92142344}, +{0x34,0x90142334}, +{0x38,0xc0224000}, +{0x3c,0xc0222004}, +{0x40,0xc0220000}, +{0x44,0x7ffffe8a}, +{0x48,0x90103fff}, +{0x4c,0xc2002fe8}, +{0x50,0x80a06000}, +{0x54,0x12800010}, +{0x58,0x03000017}, +{0x5c,0xc20822b4}, +{0x60,0x80a06000}, +{0x64,0x0280000c}, +{0x68,0x03000017}, +{0x6c,0xc2102548}, +{0x70,0x80886001}, +{0x74,0x12800008}, +{0x78,0x03000017}, +{0x7c,0x9a142324}, +{0xf0,0x37}, +{0x00,0x82102001}, +{0x04,0x98142320}, +{0x08,0xc2234000}, +{0x0c,0x10800004}, +{0x10,0xc0230000}, +{0x14,0x82106324}, +{0x18,0xc0204000}, +{0x1c,0x7fffff14}, +{0x20,0x01000000}, +{0x24,0x7ffffe61}, +{0x28,0x90102001}, +{0x2c,0x7ffffee8}, +{0x30,0x01000000}, +{0x34,0x7ffffef1}, +{0x38,0x01000000}, +{0x3c,0xc2002fd8}, +{0x40,0x80a06000}, +{0x44,0x02800005}, +{0x48,0x1b3fc0c0}, +{0x4c,0x9fc04000}, +{0x50,0x01000000}, +{0x54,0x1b3fc0c0}, +{0x58,0x82103fff}, +{0x5c,0x9a136004}, +{0x60,0xc2234000}, +{0x64,0x03000017}, +{0x68,0x82106348}, +{0x6c,0xc0204000}, +{0x70,0x7fffff26}, +{0x74,0x90102001}, +{0x78,0xc02026f8}, +{0x7c,0x81c7e008}, +{0xf0,0x38}, +{0x00,0x81e80000}, +{0x04,0x9de3bf98}, +{0x08,0x40000010}, +{0x0c,0x01000000}, +{0x10,0x40000007}, +{0x14,0x01000000}, +{0x18,0x7fffff24}, +{0x1c,0x01000000}, +{0x20,0x40000015}, +{0x24,0x01000000}, +{0x28,0x30bffffe}, +{0x2c,0x82102001}, +{0x30,0x81904000}, +{0x34,0x01000000}, +{0x38,0x01000000}, +{0x3c,0x01000000}, +{0x40,0x81c3e008}, +{0x44,0x01000000}, +{0x48,0x03000008}, +{0x4c,0x82106342}, +{0x50,0xa3804000}, +{0x54,0x03000004}, +{0x58,0x82106000}, +{0x5c,0x81984000}, +{0x60,0x01000000}, +{0x64,0x01000000}, +{0x68,0x01000000}, +{0x6c,0x81c3e008}, +{0x70,0x01000000}, +{0x74,0x01000000}, +{0x78,0x01000000}, +{0x7c,0x01000000}, +{0xf0,0x39}, +{0x00,0xa7800000}, +{0x04,0x01000000}, +{0x08,0x01000000}, +{0x0c,0x01000000}, +{0x10,0x81c3e008}, +{0x14,0x01000000}, +{0x18,0x80a22000}, +{0x1c,0x02800006}, +{0x20,0x01000000}, +{0x24,0x01000000}, +{0x28,0x90823fff}, +{0x2c,0x12bffffe}, +{0x30,0x01000000}, +{0x34,0x81c3e008}, +{0x38,0x01000000}, +{0x3c,0x01000000}, +{0x40,0x05001040}, +{0x44,0x8410a00f}, +{0x48,0xc4a00040}, +{0x4c,0x01000000}, +{0x50,0x81c3e008}, +{0x54,0x01000000}, +{0x58,0x9de3bf98}, +{0x5c,0x82102000}, +{0x60,0x80a04019}, +{0x64,0x16800015}, +{0x68,0x9e100019}, +{0x6c,0xb6006001}, +{0x70,0x80a6c00f}, +{0x74,0x1680000f}, +{0x78,0xba10001b}, +{0x7c,0xb3286002}, +{0xf0,0x3a}, +{0x00,0xb52f6002}, +{0x04,0xf8060019}, +{0x08,0xc206001a}, +{0x0c,0x80a70001}, +{0x10,0x04800004}, +{0x14,0xba076001}, +{0x18,0xc2260019}, +{0x1c,0xf826001a}, +{0x20,0x80a7400f}, +{0x24,0x06bffff8}, +{0x28,0xb52f6002}, +{0x2c,0x80a6c00f}, +{0x30,0x06bfffef}, +{0x34,0x8210001b}, +{0x38,0x81c7e008}, +{0x3c,0x81e80000}, +{0x40,0x81c3e008}, +{0x44,0x01000000}, +{0x48,0x9de3bf98}, +{0x4c,0xf8060000}, +{0x50,0x96100018}, +{0x54,0x9a100019}, +{0x58,0x80a72000}, +{0x5c,0x12800006}, +{0x60,0x9810001a}, +{0x64,0xc2064000}, +{0x68,0x80a06000}, +{0x6c,0x0280002b}, +{0x70,0xb010001a}, +{0x74,0xb006ffff}, +{0x78,0x80a3001c}, +{0x7c,0x16800012}, +{0xf0,0x3b}, +{0x00,0xba102000}, +{0x04,0x10800024}, +{0x08,0xde034000}, +{0x0c,0x8207000d}, +{0x10,0xc2006004}, +{0x14,0xba23001b}, +{0x18,0x82204019}, +{0x1c,0x8258401d}, +{0x20,0xba26801b}, +{0x24,0x9b38601f}, +{0x28,0x81836000}, +{0x2c,0x01000000}, +{0x30,0x01000000}, +{0x34,0x01000000}, +{0x38,0x8278401d}, +{0x3c,0x10800016}, +{0x40,0x9e004019}, +{0x44,0x80a74018}, +{0x48,0x16800013}, +{0x4c,0xb92f6002}, +{0x50,0x8207000b}, +{0x54,0xf4006004}, +{0x58,0xf602c01c}, +{0x5c,0xb207000d}, +{0x60,0x80a6801b}, +{0x64,0x0680000c}, +{0x68,0xba076001}, +{0x6c,0x80a3001b}, +{0x70,0x26bffff5}, +{0x74,0xde066004}, +{0x78,0x80a3001a}, +{0x7c,0x36bffff2}, +{0xf0,0x3c}, +{0x00,0xde066004}, +{0x04,0x80a6801b}, +{0x08,0x12bfffe1}, +{0x0c,0xf203401c}, +{0x10,0x9e100019}, +{0x14,0xb010000f}, +{0x18,0x81c7e008}, +{0x1c,0x81e80000}, +{0x20,0x9de3bf98}, +{0x24,0xfa002300}, +{0x28,0x832f6002}, +{0x2c,0x82006007}, +{0x30,0x82087ff8}, +{0x34,0x9810000e}, +{0x38,0x9c238001}, +{0x3c,0x9e102000}, +{0x40,0x80a3c01d}, +{0x44,0xb003a060}, +{0x48,0x1a80001e}, +{0x4c,0xb8102000}, +{0x50,0x832f2002}, +{0x54,0xc0260001}, +{0x58,0xb8072001}, +{0x5c,0xc2002300}, +{0x60,0x80a70001}, +{0x64,0x2abffffc}, +{0x68,0x832f2002}, +{0x6c,0xb8102000}, +{0x70,0x80a70001}, +{0x74,0x1a800014}, +{0x78,0x03000019}, +{0x7c,0x9a106328}, +{0xf0,0x3d}, +{0x00,0x832f2003}, +{0x04,0xb600400d}, +{0x08,0xb32f2002}, +{0x0c,0xb4102001}, +{0x10,0xfa06c000}, +{0x14,0xc2060019}, +{0x18,0x8200401d}, +{0x1c,0xc2260019}, +{0x20,0xb486bfff}, +{0x24,0x1cbffffb}, +{0x28,0xb606e004}, +{0x2c,0xb8072001}, +{0x30,0xc2002300}, +{0x34,0x80a70001}, +{0x38,0x0abffff3}, +{0x3c,0x832f2003}, +{0x40,0xb8102000}, +{0x44,0xfa002300}, +{0x48,0x80a7001d}, +{0x4c,0x3a80000d}, +{0x50,0xc210228c}, +{0x54,0xf610228e}, +{0x58,0x832f2002}, +{0x5c,0xc2060001}, +{0x60,0x80a0401b}, +{0x64,0x04800003}, +{0x68,0xb8072001}, +{0x6c,0x9e03e001}, +{0x70,0x80a7001d}, +{0x74,0x0abffffa}, +{0x78,0x832f2002}, +{0x7c,0xc210228c}, +{0xf0,0x3e}, +{0x00,0x80a3c001}, +{0x04,0x04800006}, +{0x08,0x9c10000c}, +{0x0c,0xc200254c}, +{0x10,0x3b000200}, +{0x14,0x8210401d}, +{0x18,0xc220254c}, +{0x1c,0x81c7e008}, +{0x20,0x81e80000}, +{0x24,0x81c3e008}, +{0x28,0x01000000}, +{0x2c,0x9c03bf88}, +{0x30,0x96102000}, +{0x34,0x8203a060}, +{0x38,0x98102003}, +{0x3c,0xc0204000}, +{0x40,0x98833fff}, +{0x44,0x1cbffffe}, +{0x48,0x82006004}, +{0x4c,0x98102000}, +{0x50,0xda002514}, +{0x54,0x80a3000d}, +{0x58,0x1a800008}, +{0x5c,0x832b2002}, +{0x60,0xc2106730}, +{0x64,0x80a0400b}, +{0x68,0x04bffffb}, +{0x6c,0x98032001}, +{0x70,0x10bffff9}, +{0x74,0x96100001}, +{0x78,0xda1022cc}, +{0x7c,0xc20026e0}, +{0xf0,0x3f}, +{0x00,0x80a0400d}, +{0x04,0x04800006}, +{0x08,0x03000017}, +{0x0c,0xda0822c7}, +{0x10,0x82106348}, +{0x14,0x10800008}, +{0x18,0xda204000}, +{0x1c,0x9a106348}, +{0x20,0xc2034000}, +{0x24,0x80a06000}, +{0x28,0x04800003}, +{0x2c,0x82007fff}, +{0x30,0xc2234000}, +{0x34,0x1b000017}, +{0x38,0x82136348}, +{0x3c,0xc2004000}, +{0x40,0x80a06000}, +{0x44,0x0480002f}, +{0x48,0x8213631c}, +{0x4c,0xc2004000}, +{0x50,0x80a06002}, +{0x54,0x2280002c}, +{0x58,0xc2002514}, +{0x5c,0xc20022d4}, +{0x60,0x80886010}, +{0x64,0x02800015}, +{0x68,0x03000017}, +{0x6c,0x82136328}, +{0x70,0xda004000}, +{0x74,0xc2002514}, +{0x78,0x80a0400d}, +{0x7c,0x0280000e}, +{0xf0,0x40}, +{0x00,0x03000018}, +{0x04,0x96106058}, +{0x08,0x98102000}, +{0x0c,0x9b2b2002}, +{0x10,0x98032001}, +{0x14,0xc2036720}, +{0x18,0x80a32003}, +{0x1c,0x04bffffc}, +{0x20,0xc223400b}, +{0x24,0x03000017}, +{0x28,0xda002514}, +{0x2c,0x82106328}, +{0x30,0xda204000}, +{0x34,0x03000017}, +{0x38,0x82106328}, +{0x3c,0xc2004000}, +{0x40,0x80a06000}, +{0x44,0x0480001b}, +{0x48,0x03000018}, +{0x4c,0x96106058}, +{0x50,0x98102000}, +{0x54,0x9b2b2002}, +{0x58,0x98032001}, +{0x5c,0xc203400b}, +{0x60,0x80a32003}, +{0x64,0x04bffffc}, +{0x68,0xc2236720}, +{0x6c,0x03000017}, +{0x70,0x82106328}, +{0x74,0xc2004000}, +{0x78,0x1080000e}, +{0x7c,0xc2202514}, +{0xf0,0x41}, +{0x00,0xc2002514}, +{0x04,0x9a136328}, +{0x08,0xc2234000}, +{0x0c,0x03000018}, +{0x10,0x96106058}, +{0x14,0x98102000}, +{0x18,0x9b2b2002}, +{0x1c,0x98032001}, +{0x20,0xc2036720}, +{0x24,0x80a32003}, +{0x28,0x04bffffc}, +{0x2c,0xc223400b}, +{0x30,0x03000017}, +{0x34,0xda002514}, +{0x38,0x82106328}, +{0x3c,0xda204000}, +{0x40,0x81c3e008}, +{0x44,0x9c23bf88}, +{0x48,0x98102000}, +{0x4c,0x80a3000a}, +{0x50,0x16800008}, +{0x54,0x01000000}, +{0x58,0x9b2b2002}, +{0x5c,0x98032001}, +{0x60,0xc202400d}, +{0x64,0x80a3000a}, +{0x68,0x06bffffc}, +{0x6c,0xc222000d}, +{0x70,0x81c3e008}, +{0x74,0x01000000}, +{0x78,0x9de3bf98}, +{0x7c,0x7ffffde3}, +{0xf0,0x42}, +{0x00,0x90102000}, +{0x04,0x1b000017}, +{0x08,0x98136324}, +{0x0c,0xc2030000}, +{0x10,0x80a00001}, +{0x14,0x82603fff}, +{0x18,0x92004001}, +{0x1c,0x92024001}, +{0x20,0x9a13638c}, +{0x24,0x932a6005}, +{0x28,0x9202400d}, +{0x2c,0xc2230000}, +{0x30,0x94102018}, +{0x34,0x7fffffe5}, +{0x38,0x901025b0}, +{0x3c,0x7ffffc5a}, +{0x40,0x901025b0}, +{0x44,0x7ffffd8d}, +{0x48,0xb0102001}, +{0x4c,0x7ffffdcf}, +{0x50,0x81e80000}, +{0x54,0x01000000}, +{0x58,0x03000018}, +{0x5c,0x96106054}, +{0x60,0x9810604c}, +{0x64,0x82106050}, +{0x68,0x9a103fe0}, +{0x6c,0xda204000}, +{0x70,0xc0230000}, +{0x74,0x81c3e008}, +{0x78,0xc022c000}, +{0x7c,0xda002548}, +{0xf0,0x43}, +{0x00,0x83336010}, +{0x04,0x80886001}, +{0x08,0x0280000b}, +{0x0c,0x90102001}, +{0x10,0xc2002558}, +{0x14,0x9b336011}, +{0x18,0x80a06000}, +{0x1c,0x12800005}, +{0x20,0x90102000}, +{0x24,0x808b6001}, +{0x28,0x12800003}, +{0x2c,0x01000000}, +{0x30,0x90102001}, +{0x34,0x81c3e008}, +{0x38,0x01000000}, +{0x3c,0x94102000}, +{0x40,0xc2002514}, +{0x44,0x80a28001}, +{0x48,0x96102000}, +{0x4c,0x1a800010}, +{0x50,0x9b2ae002}, +{0x54,0xc2036720}, +{0x58,0x992aa002}, +{0x5c,0x80a06000}, +{0x60,0x02800008}, +{0x64,0x9602e001}, +{0x68,0xc2232720}, +{0x6c,0xc2036730}, +{0x70,0xc2232730}, +{0x74,0xc20367e0}, +{0x78,0x9402a001}, +{0x7c,0xc22327e0}, +{0xf0,0x44}, +{0x00,0xc2002514}, +{0x04,0x10bffff2}, +{0x08,0x80a2c001}, +{0x0c,0x81c3e008}, +{0x10,0xd4202514}, +{0x14,0x9de3bf98}, +{0x18,0xb0102000}, +{0x1c,0xf6002514}, +{0x20,0x80a6001b}, +{0x24,0x1a800012}, +{0x28,0xbb2e2002}, +{0x2c,0xc2076720}, +{0x30,0x80a06000}, +{0x34,0x02bffffb}, +{0x38,0xb0062001}, +{0x3c,0xf8176732}, +{0x40,0xc200271c}, +{0x44,0x80a70001}, +{0x48,0x34800002}, +{0x4c,0xf820271c}, +{0x50,0xfa176730}, +{0x54,0xc2002718}, +{0x58,0x80a74001}, +{0x5c,0x34bffff1}, +{0x60,0xfa202718}, +{0x64,0x10bffff0}, +{0x68,0x80a6001b}, +{0x6c,0x3b333333}, +{0x70,0xc2002500}, +{0x74,0xba1760cd}, +{0x78,0x8050401d}, +{0x7c,0xbb400000}, +{0xf0,0x45}, +{0x00,0xbb376003}, +{0x04,0xb92f6002}, +{0x08,0xb807001d}, +{0x0c,0xb807001c}, +{0x10,0x80a0401c}, +{0x14,0x1280000d}, +{0x18,0xb0102000}, +{0x1c,0xc200271c}, +{0x20,0x80a06000}, +{0x24,0x04800003}, +{0x28,0x82007fff}, +{0x2c,0xc220271c}, +{0x30,0xc2002718}, +{0x34,0x80a06000}, +{0x38,0x04800003}, +{0x3c,0x82007fff}, +{0x40,0xc2202718}, +{0x44,0xb0102000}, +{0x48,0xc2002514}, +{0x4c,0x80a60001}, +{0x50,0x1a80003e}, +{0x54,0x01000000}, +{0x58,0xb4102000}, +{0x5c,0xc20022d4}, +{0x60,0x80886010}, +{0x64,0x02800006}, +{0x68,0xfa002300}, +{0x6c,0xf616a720}, +{0x70,0xb60eefff}, +{0x74,0x10800005}, +{0x78,0x9810001d}, +{0x7c,0xc206a720}, +{0xf0,0x46}, +{0x00,0xb6086fff}, +{0x04,0x99376001}, +{0x08,0x9e102000}, +{0x0c,0xc206a720}, +{0x10,0x80a06000}, +{0x14,0x22800025}, +{0x18,0x9e03e001}, +{0x1c,0x80a3e000}, +{0x20,0x32800005}, +{0x24,0xda16a730}, +{0x28,0xda16a732}, +{0x2c,0x10800003}, +{0x30,0xf200271c}, +{0x34,0xf2002718}, +{0x38,0xb92be003}, +{0x3c,0xfa572244}, +{0x40,0x80a6c01d}, +{0x44,0x26800008}, +{0x48,0xfa572246}, +{0x4c,0x832b2006}, +{0x50,0x8220401d}, +{0x54,0x80a6c001}, +{0x58,0x24800014}, +{0x5c,0x9e03e001}, +{0x60,0xfa572246}, +{0x64,0xba5e401d}, +{0x68,0x833f601f}, +{0x6c,0x83306018}, +{0x70,0xba074001}, +{0x74,0xbb3f6008}, +{0x78,0xc2572242}, +{0x7c,0x80a74001}, +{0xf0,0x47}, +{0x00,0x34800002}, +{0x04,0xba100001}, +{0x08,0xc2572240}, +{0x0c,0x80a74001}, +{0x10,0x26800002}, +{0x14,0xba100001}, +{0x18,0x80a3401d}, +{0x1c,0x26800002}, +{0x20,0xc026a720}, +{0x24,0x9e03e001}, +{0x28,0x80a3e001}, +{0x2c,0x24bfffd9}, +{0x30,0xc206a720}, +{0x34,0xb0062001}, +{0x38,0xc2002514}, +{0x3c,0x80a60001}, +{0x40,0x0abfffc7}, +{0x44,0xb406a004}, +{0x48,0x7fffff7d}, +{0x4c,0x81e80000}, +{0x50,0x01000000}, +{0x54,0x81c3e008}, +{0x58,0x01000000}, +{0x5c,0x9de3bf78}, +{0x60,0xc20022d4}, +{0x64,0x80886010}, +{0x68,0x96100018}, +{0x6c,0xa0102000}, +{0x70,0x9a102000}, +{0x74,0x94102000}, +{0x78,0x02800004}, +{0x7c,0xc2002300}, +{0xf0,0x48}, +{0x00,0x10800003}, +{0x04,0x98100001}, +{0x08,0x99306001}, +{0x0c,0x80a2e05f}, +{0x10,0x14800006}, +{0x14,0xb12b2006}, +{0x18,0x82102060}, +{0x1c,0x9420400b}, +{0x20,0x9a102000}, +{0x24,0xa0103fff}, +{0x28,0x82063fa0}, +{0x2c,0x80a2c001}, +{0x30,0x04800006}, +{0x34,0x80a66000}, +{0x38,0x8222c018}, +{0x3c,0x94006060}, +{0x40,0x9a102001}, +{0x44,0xa0102001}, +{0x48,0x32800002}, +{0x4c,0x9a036002}, +{0x50,0x80a2a000}, +{0x54,0x16800004}, +{0x58,0x80a2a03f}, +{0x5c,0x10800004}, +{0x60,0x94102000}, +{0x64,0x34800002}, +{0x68,0x9410203f}, +{0x6c,0x912b6002}, +{0x70,0x92102000}, +{0x74,0x9607bff8}, +{0x78,0x9a020009}, +{0x7c,0x8203400d}, +{0xf0,0x49}, +{0x00,0xd8506260}, +{0x04,0xc20b6250}, +{0x08,0xc222fff0}, +{0x0c,0xd822ffe0}, +{0x10,0x92026001}, +{0x14,0x80a26003}, +{0x18,0x04bffff8}, +{0x1c,0x9602e004}, +{0x20,0x9007bfe8}, +{0x24,0x9207bfd8}, +{0x28,0x7ffffe28}, +{0x2c,0x96102004}, +{0x30,0xc20022d4}, +{0x34,0x80886020}, +{0x38,0x22800002}, +{0x3c,0xa0200010}, +{0x40,0xb05c0008}, +{0x44,0x81c7e008}, +{0x48,0x81e80000}, +{0x4c,0x90020009}, +{0x50,0x932a600a}, +{0x54,0x833a601f}, +{0x58,0x81806000}, +{0x5c,0x01000000}, +{0x60,0x01000000}, +{0x64,0x01000000}, +{0x68,0x907a4008}, +{0x6c,0x033fffaa}, +{0x70,0x9b2a2008}, +{0x74,0x82106300}, +{0x78,0x9a034001}, +{0x7c,0x030c0300}, +{0xf0,0x4a}, +{0x00,0x82106301}, +{0x04,0x805b4001}, +{0x08,0x83400000}, +{0x0c,0x83386006}, +{0x10,0x9b3b601f}, +{0x14,0x80a2a001}, +{0x18,0x12800008}, +{0x1c,0x9020400d}, +{0x20,0x90020008}, +{0x24,0x80a22100}, +{0x28,0x04800005}, +{0x2c,0x80a22000}, +{0x30,0x82102200}, +{0x34,0x90204008}, +{0x38,0x80a22000}, +{0x3c,0x16800004}, +{0x40,0x80a22100}, +{0x44,0x10800004}, +{0x48,0x90102000}, +{0x4c,0x34800002}, +{0x50,0x90102100}, +{0x54,0x81c3e008}, +{0x58,0x01000000}, +{0x5c,0x9de3bf98}, +{0x60,0x03000019}, +{0x64,0x9a100018}, +{0x68,0x9e100019}, +{0x6c,0x9610632c}, +{0x70,0xb4102000}, +{0x74,0x98106328}, +{0x78,0xc24ea400}, +{0x7c,0xb12ea003}, +{0xf0,0x4b}, +{0x00,0xb9286002}, +{0x04,0x80a06000}, +{0x08,0x06800010}, +{0x0c,0xb2004001}, +{0x10,0xc24ea420}, +{0x14,0xbb286002}, +{0x18,0x82004001}, +{0x1c,0xf603401d}, +{0x20,0xc213c001}, +{0x24,0xf803401c}, +{0x28,0xfa13c019}, +{0x2c,0x8220401b}, +{0x30,0xba27401c}, +{0x34,0xb406a001}, +{0x38,0xc226000b}, +{0x3c,0x80a6a014}, +{0x40,0x08bfffee}, +{0x44,0xfa26000c}, +{0x48,0xb4102000}, +{0x4c,0xc2002304}, +{0x50,0x80a68001}, +{0x54,0x1a800010}, +{0x58,0x03000019}, +{0x5c,0xb81063c0}, +{0x60,0xc24ea380}, +{0x64,0xbb286002}, +{0x68,0x82004001}, +{0x6c,0xfa03401d}, +{0x70,0xc213c001}, +{0x74,0x8220401d}, +{0x78,0xbb2ea002}, +{0x7c,0xc227401c}, +{0xf0,0x4c}, +{0x00,0xb406a001}, +{0x04,0xc2002304}, +{0x08,0x80a68001}, +{0x0c,0x2abffff6}, +{0x10,0xc24ea380}, +{0x14,0x81c7e008}, +{0x18,0x81e80000}, +{0x1c,0x9de3bf98}, +{0x20,0xc2002508}, +{0x24,0x808860ff}, +{0x28,0x02800015}, +{0x2c,0x1b3fc180}, +{0x30,0x82102001}, +{0x34,0x9a13603c}, +{0x38,0xc2234000}, +{0x3c,0xc2002508}, +{0x40,0x820860ff}, +{0x44,0x80a04018}, +{0x48,0x1280000b}, +{0x4c,0x033fc180}, +{0x50,0x7ffffd9b}, +{0x54,0x01000000}, +{0x58,0xda002508}, +{0x5c,0x033fc040}, +{0x60,0x9a0b60ff}, +{0x64,0x8210600c}, +{0x68,0xc0204000}, +{0x6c,0x10bffff7}, +{0x70,0x80a34018}, +{0x74,0x8210603c}, +{0x78,0xc0204000}, +{0x7c,0x81c7e008}, +{0xf0,0x4d}, +{0x00,0x81e80000}, +{0x04,0x9a102000}, +{0x08,0x832b6002}, +{0x0c,0x9a036001}, +{0x10,0x80a3602f}, +{0x14,0x08bffffd}, +{0x18,0xc0220001}, +{0x1c,0x81c3e008}, +{0x20,0x01000000}, +{0x24,0x9de3bf98}, +{0x28,0x3b000019}, +{0x2c,0x98100019}, +{0x30,0x03000017}, +{0x34,0x9a106324}, +{0x38,0x94176028}, +{0x3c,0xb2102000}, +{0x40,0x9e176268}, +{0x44,0x96176088}, +{0x48,0xb92e6003}, +{0x4c,0x81800000}, +{0x50,0xc206001c}, +{0x54,0x01000000}, +{0x58,0x01000000}, +{0x5c,0x8270400c}, +{0x60,0xc226001c}, +{0x64,0x82070018}, +{0x68,0x81800000}, +{0x6c,0xf6006004}, +{0x70,0x01000000}, +{0x74,0x01000000}, +{0x78,0xb676c00c}, +{0x7c,0xf6206004}, +{0xf0,0x4e}, +{0x00,0xfa034000}, +{0x04,0x8207401d}, +{0x08,0x8200401d}, +{0x0c,0xfa06001c}, +{0x10,0x83286003}, +{0x14,0x82004019}, +{0x18,0xbb2f6010}, +{0x1c,0x83286002}, +{0x20,0xba07401b}, +{0x24,0xfa20400f}, +{0x28,0xc2034000}, +{0x2c,0x80a06000}, +{0x30,0x1280000c}, +{0x34,0xb52e6002}, +{0x38,0xc206800f}, +{0x3c,0xc226800b}, +{0x40,0xfa034000}, +{0x44,0x8207401d}, +{0x48,0x8200401d}, +{0x4c,0x83286003}, +{0x50,0x82004019}, +{0x54,0x83286002}, +{0x58,0xc200400f}, +{0x5c,0xc226800a}, +{0x60,0xb2066001}, +{0x64,0x80a66017}, +{0x68,0x08bfffd9}, +{0x6c,0xb92e6003}, +{0x70,0x81c7e008}, +{0x74,0x81e80000}, +{0x78,0x81c3e008}, +{0x7c,0x01000000}, +{0xf0,0x4f}, +{0x00,0x9de3bf98}, +{0x04,0xf8060000}, +{0x08,0xfa064000}, +{0x0c,0x83372010}, +{0x10,0xb5376010}, +{0x14,0x82086fff}, +{0x18,0xb40eafff}, +{0x1c,0xb620401a}, +{0x20,0x03000007}, +{0x24,0x821063ff}, +{0x28,0xb40f4001}, +{0x2c,0x820f0001}, +{0x30,0xb820401a}, +{0x34,0xc2002328}, +{0x38,0xb65ec001}, +{0x3c,0xc2002324}, +{0x40,0xb05f0001}, +{0x44,0x833e201f}, +{0x48,0x83306016}, +{0x4c,0xb4060001}, +{0x50,0xc20022d4}, +{0x54,0xbb3ee01f}, +{0x58,0xbb376015}, +{0x5c,0x80886010}, +{0x60,0xc2002300}, +{0x64,0xb806c01d}, +{0x68,0xbb286006}, +{0x6c,0x0280000a}, +{0x70,0x83286005}, +{0x74,0x833ee01f}, +{0x78,0x81806000}, +{0x7c,0x01000000}, +{0xf0,0x50}, +{0x00,0x01000000}, +{0x04,0x01000000}, +{0x08,0xb67ec01d}, +{0x0c,0x10800009}, +{0x10,0xb13ea00a}, +{0x14,0x9b3e201f}, +{0x18,0x81836000}, +{0x1c,0x01000000}, +{0x20,0x01000000}, +{0x24,0x01000000}, +{0x28,0xb07e0001}, +{0x2c,0xb73f200b}, +{0x30,0x825ec01b}, +{0x34,0xb05e0018}, +{0x38,0x81c7e008}, +{0x3c,0x91e84018}, +{0x40,0x9de3bf98}, +{0x44,0x03000017}, +{0x48,0x82106324}, +{0x4c,0xfa004000}, +{0x50,0x03000019}, +{0x54,0xb2106028}, +{0x58,0x80a76000}, +{0x5c,0x02800004}, +{0x60,0x9e100019}, +{0x64,0xb21062c8}, +{0x68,0x9e100019}, +{0x6c,0xf4060000}, +{0x70,0x03000018}, +{0x74,0x82106368}, +{0x78,0xbb2ea002}, +{0x7c,0xfa074001}, +{0xf0,0x51}, +{0x00,0xb806801a}, +{0x04,0xc213c01c}, +{0x08,0xb6a74001}, +{0x0c,0x02800016}, +{0x10,0x8206801a}, +{0x14,0x80a6e000}, +{0x18,0x04800009}, +{0x1c,0x82102001}, +{0x20,0xf0062004}, +{0x24,0x83284018}, +{0x28,0x80a6c001}, +{0x2c,0x3480000d}, +{0x30,0xb73ec018}, +{0x34,0x1080000b}, +{0x38,0xb6102001}, +{0x3c,0x1680000a}, +{0x40,0x8206801a}, +{0x44,0xf0062008}, +{0x48,0x82103fff}, +{0x4c,0x83284018}, +{0x50,0x80a6c001}, +{0x54,0x36800003}, +{0x58,0xb6103fff}, +{0x5c,0xb73ec018}, +{0x60,0x8206801a}, +{0x64,0xc213c001}, +{0x68,0xb606c001}, +{0x6c,0x808ea001}, +{0x70,0x0280000d}, +{0x74,0xbb3ea01f}, +{0x78,0xbb37601f}, +{0x7c,0xba06801d}, +{0xf0,0x52}, +{0x00,0xbb3f6001}, +{0x04,0xbb2f6002}, +{0x08,0x033fffc0}, +{0x0c,0xf806401d}, +{0x10,0xb80f0001}, +{0x14,0x0300003f}, +{0x18,0x821063ff}, +{0x1c,0x1080000b}, +{0x20,0x820ec001}, +{0x24,0xbb37601f}, +{0x28,0xba06801d}, +{0x2c,0xbb3f6001}, +{0x30,0xbb2f6002}, +{0x34,0x0300003f}, +{0x38,0x821063ff}, +{0x3c,0xf806401d}, +{0x40,0xb80f0001}, +{0x44,0x832ee010}, +{0x48,0xb8170001}, +{0x4c,0xf826401d}, +{0x50,0x81c7e008}, +{0x54,0x81e80000}, +{0x58,0x9de3bf68}, +{0x5c,0x7ffffa49}, +{0x60,0xb0102001}, +{0x64,0xa4100008}, +{0x68,0xa2102000}, +{0x6c,0xa0102003}, +{0x70,0x11000016}, +{0x74,0x921223e8}, +{0x78,0x90122388}, +{0x7c,0x90044008}, +{0xf0,0x53}, +{0x00,0x92044009}, +{0x04,0x7ffffdd1}, +{0x08,0x94102018}, +{0x0c,0xa0843fff}, +{0x10,0x1cbffff8}, +{0x14,0xa2046060}, +{0x18,0x11000017}, +{0x1c,0x90122108}, +{0x20,0x92100012}, +{0x24,0x7ffffdc9}, +{0x28,0x94102018}, +{0x2c,0x8207bfe0}, +{0x30,0xa0102004}, +{0x34,0xc0204000}, +{0x38,0xa0843fff}, +{0x3c,0x1cbffffe}, +{0x40,0x82006004}, +{0x44,0xa0102000}, +{0x48,0x03000016}, +{0x4c,0x9a040010}, +{0x50,0x82106388}, +{0x54,0x9a034001}, +{0x58,0xa207bff8}, +{0x5c,0x9807bfc8}, +{0x60,0x96102004}, +{0x64,0xc2134000}, +{0x68,0xc2230000}, +{0x6c,0x9a036060}, +{0x70,0x9682ffff}, +{0x74,0x1cbffffc}, +{0x78,0x98032004}, +{0x7c,0x92102005}, +{0xf0,0x54}, +{0x00,0x7ffffcb6}, +{0x04,0x9007bfc8}, +{0x08,0x03000016}, +{0x0c,0x9a040010}, +{0x10,0x82106388}, +{0x14,0x94034001}, +{0x18,0xd207bfd0}, +{0x1c,0x98100011}, +{0x20,0x96102004}, +{0x24,0xc2128000}, +{0x28,0x82224001}, +{0x2c,0x9b38601f}, +{0x30,0x8218400d}, +{0x34,0x8220400d}, +{0x38,0xda033fe8}, +{0x3c,0x9a034001}, +{0x40,0xda233fe8}, +{0x44,0x9402a060}, +{0x48,0x9682ffff}, +{0x4c,0x1cbffff6}, +{0x50,0x98032004}, +{0x54,0xa0042001}, +{0x58,0x80a42023}, +{0x5c,0x04bfffdc}, +{0x60,0x03000016}, +{0x64,0x03001fff}, +{0x68,0x821063ff}, +{0x6c,0x9a047fe8}, +{0x70,0xa0102000}, +{0x74,0xd8034000}, +{0x78,0x80a30001}, +{0x7c,0x16800004}, +{0xf0,0x55}, +{0x00,0x9a036004}, +{0x04,0x8210000c}, +{0x08,0xb0100010}, +{0x0c,0xa0042001}, +{0x10,0x80a42004}, +{0x14,0x24bffff9}, +{0x18,0xd8034000}, +{0x1c,0x81c7e008}, +{0x20,0x81e80000}, +{0x24,0x9de3bf98}, +{0x28,0x833e201f}, +{0x2c,0xd0002320}, +{0x30,0x82204018}, +{0x34,0x80a22000}, +{0x38,0x02800015}, +{0x3c,0x9b30601f}, +{0x40,0x033fc000}, +{0x44,0xa0106020}, +{0x48,0xc200231c}, +{0x4c,0x80a00001}, +{0x50,0x82402000}, +{0x54,0x8088400d}, +{0x58,0xc2002318}, +{0x5c,0x02800009}, +{0x60,0xb01e0001}, +{0x64,0x80a00001}, +{0x68,0x82603fff}, +{0x6c,0x7ffffc6b}, +{0x70,0xc2240000}, +{0x74,0xc2002318}, +{0x78,0x10800005}, +{0x7c,0xc2240000}, +{0xf0,0x56}, +{0x00,0x033fc000}, +{0x04,0x82106020}, +{0x08,0xf0204000}, +{0x0c,0x81c7e008}, +{0x10,0x81e80000}, +{0x14,0x9de3bf98}, +{0x18,0x7ffffc69}, +{0x1c,0x01000000}, +{0x20,0x033fc040}, +{0x24,0xe2002500}, +{0x28,0x8210600c}, +{0x2c,0x80a46058}, +{0x30,0x08800013}, +{0x34,0xc0204000}, +{0x38,0xc0202584}, +{0x3c,0xa0102000}, +{0x40,0x832c2002}, +{0x44,0xc2006f04}, +{0x48,0x80a06000}, +{0x4c,0x02800074}, +{0x50,0xa0042001}, +{0x54,0x9fc04000}, +{0x58,0x01000000}, +{0x5c,0xc2002584}, +{0x60,0x80a06000}, +{0x64,0x1280006e}, +{0x68,0x80a4203b}, +{0x6c,0x24bffff6}, +{0x70,0x832c2002}, +{0x74,0x1080006b}, +{0x78,0xc2002500}, +{0x7c,0x80a46000}, +{0xf0,0x57}, +{0x00,0x1280000f}, +{0x04,0x80a46014}, +{0x08,0xc2002ff4}, +{0x0c,0x9fc04000}, +{0x10,0x01000000}, +{0x14,0x7ffffa76}, +{0x18,0x90102000}, +{0x1c,0xc24822e5}, +{0x20,0x80a06000}, +{0x24,0x3280005f}, +{0x28,0xc2002500}, +{0x2c,0x7ffffa5f}, +{0x30,0x90102001}, +{0x34,0x1080005b}, +{0x38,0xc2002500}, +{0x3c,0x1880000a}, +{0x40,0x80a46015}, +{0x44,0x808c6001}, +{0x48,0x32800056}, +{0x4c,0xc2002500}, +{0x50,0x90047ffe}, +{0x54,0x7ffffa19}, +{0x58,0x91322001}, +{0x5c,0x10800051}, +{0x60,0xc2002500}, +{0x64,0x18800011}, +{0x68,0x80a46018}, +{0x6c,0x033fc180}, +{0x70,0xda0025b0}, +{0x74,0x82106038}, +{0x78,0xda204000}, +{0x7c,0x033fc200}, +{0xf0,0x58}, +{0x00,0xda00232c}, +{0x04,0x82106074}, +{0x08,0xda204000}, +{0x0c,0x7ffffa47}, +{0x10,0x90102000}, +{0x14,0xc2002ff4}, +{0x18,0x9fc04000}, +{0x1c,0x01000000}, +{0x20,0x10800040}, +{0x24,0xc2002500}, +{0x28,0x1880000b}, +{0x2c,0x80a46058}, +{0x30,0x11000018}, +{0x34,0x7ffffe94}, +{0x38,0x90122368}, +{0x3c,0x1b000017}, +{0x40,0x033fc200}, +{0x44,0x9a1363ff}, +{0x48,0x82106070}, +{0x4c,0x10800034}, +{0x50,0xda204000}, +{0x54,0x38800033}, +{0x58,0xc2002500}, +{0x5c,0xc2002fe8}, +{0x60,0x80a06000}, +{0x64,0x02800004}, +{0x68,0x01000000}, +{0x6c,0x9fc04000}, +{0x70,0x01000000}, +{0x74,0x7ffff983}, +{0x78,0xa0102000}, +{0x7c,0x15000018}, +{0xf0,0x59}, +{0x00,0x9612a368}, +{0x04,0x82040010}, +{0x08,0x992c2002}, +{0x0c,0xda120001}, +{0x10,0xc203000b}, +{0x14,0x8200400d}, +{0x18,0xa0042001}, +{0x1c,0x80a4202f}, +{0x20,0x04bffff9}, +{0x24,0xc223000b}, +{0x28,0x80a46058}, +{0x2c,0x3280001d}, +{0x30,0xc2002500}, +{0x34,0x9012a368}, +{0x38,0x7ffffe7b}, +{0x3c,0x92102040}, +{0x40,0x1b000017}, +{0x44,0xa0136324}, +{0x48,0xc2040000}, +{0x4c,0x90004001}, +{0x50,0x90020001}, +{0x54,0x033fc200}, +{0x58,0x82106070}, +{0x5c,0x9a13638c}, +{0x60,0xd8002298}, +{0x64,0x912a2005}, +{0x68,0xd8204000}, +{0x6c,0x9002000d}, +{0x70,0x921025b0}, +{0x74,0x7ffffcf5}, +{0x78,0x94102018}, +{0x7c,0xc2040000}, +{0xf0,0x5a}, +{0x00,0x80a06001}, +{0x04,0x32800007}, +{0x08,0xc2002500}, +{0x0c,0xa2103fff}, +{0x10,0xc0240000}, +{0x14,0x7ffffa99}, +{0x18,0xe2202500}, +{0x1c,0xc2002500}, +{0x20,0x80a44001}, +{0x24,0x1280000f}, +{0x28,0x80a47fff}, +{0x2c,0x12800004}, +{0x30,0x031fffff}, +{0x34,0x10800007}, +{0x38,0xa2102000}, +{0x3c,0x821063f0}, +{0x40,0x80a44001}, +{0x44,0x38800003}, +{0x48,0x23040000}, +{0x4c,0xa2046001}, +{0x50,0x033fc180}, +{0x54,0x82106034}, +{0x58,0xe2204000}, +{0x5c,0xe2202500}, +{0x60,0x81c7e008}, +{0x64,0x81e80000}, +{0x68,0x81c3e008}, +{0x6c,0x01000000}, +{0x70,0x9de3bf98}, +{0x74,0x94100018}, +{0x78,0xb0063fff}, +{0x7c,0x9802a001}, +{0xf0,0x5b}, +{0x00,0x9210001a}, +{0x04,0x80a6000c}, +{0x08,0x1480001d}, +{0x0c,0x9e102000}, +{0x10,0x03000019}, +{0x14,0x96106328}, +{0x18,0xb72be002}, +{0x1c,0x80a62000}, +{0x20,0x06800013}, +{0x24,0xc026401b}, +{0x28,0xc2002300}, +{0x2c,0x80a60001}, +{0x30,0x3a800010}, +{0x34,0xb0062001}, +{0x38,0x832e2003}, +{0x3c,0xb800400b}, +{0x40,0xb4102001}, +{0x44,0xc2070000}, +{0x48,0xba380001}, +{0x4c,0xbb3f601f}, +{0x50,0x8208401d}, +{0x54,0xfa06401b}, +{0x58,0xba074001}, +{0x5c,0xfa26401b}, +{0x60,0xb486bfff}, +{0x64,0x1cbffff8}, +{0x68,0xb8072004}, +{0x6c,0xb0062001}, +{0x70,0x80a6000c}, +{0x74,0x04bfffe9}, +{0x78,0x9e03e001}, +{0x7c,0xf6066004}, +{0xf0,0x5c}, +{0x00,0xf8064000}, +{0x04,0x80a6c01c}, +{0x08,0x24800096}, +{0x0c,0xb0102000}, +{0x10,0xf2066008}, +{0x14,0x80a6c019}, +{0x18,0x26800092}, +{0x1c,0xb0102000}, +{0x20,0x03000017}, +{0x24,0x8210632c}, +{0x28,0xc2004000}, +{0x2c,0x80a06000}, +{0x30,0x02800004}, +{0x34,0xde1023b6}, +{0x38,0xc20822b6}, +{0x3c,0x9e03c001}, +{0x40,0xba5bc009}, +{0x44,0x833f601f}, +{0x48,0x83306019}, +{0x4c,0xba074001}, +{0x50,0x9f3f6007}, +{0x54,0xd8002470}, +{0x58,0xba5bc00c}, +{0x5c,0x833f601f}, +{0x60,0x83306018}, +{0x64,0xba074001}, +{0x68,0xbb3f6008}, +{0x6c,0x80a6c01d}, +{0x70,0x0680007c}, +{0x74,0xb0102000}, +{0x78,0x80a2a000}, +{0x7c,0x32800008}, +{0xf0,0x5d}, +{0x00,0xc2002300}, +{0x04,0x8226c019}, +{0x08,0x80a64001}, +{0x0c,0x16800011}, +{0x10,0xb4100019}, +{0x14,0x1080000f}, +{0x18,0xb4100001}, +{0x1c,0x82007fff}, +{0x20,0x80a28001}, +{0x24,0x12800008}, +{0x28,0x80a70019}, +{0x2c,0xb426c01c}, +{0x30,0x80a6801c}, +{0x34,0x16800008}, +{0x38,0x80a70019}, +{0x3c,0x10800006}, +{0x40,0xb410001c}, +{0x44,0x06800003}, +{0x48,0xb4100019}, +{0x4c,0xb410001c}, +{0x50,0x80a70019}, +{0x54,0xb406801b}, +{0x58,0x14800003}, +{0x5c,0x9626c019}, +{0x60,0x9626c01c}, +{0x64,0xba5bc00c}, +{0x68,0x833f601f}, +{0x6c,0x83306019}, +{0x70,0xba074001}, +{0x74,0xb0102003}, +{0x78,0x80a62003}, +{0x7c,0x12800004}, +{0xf0,0x5e}, +{0x00,0x80a62002}, +{0x04,0x10800004}, +{0x08,0x9a10000f}, +{0x0c,0x22800002}, +{0x10,0x9b3f6007}, +{0x14,0x8333601f}, +{0x18,0x82034001}, +{0x1c,0x80a6800d}, +{0x20,0x04800005}, +{0x24,0x83386001}, +{0x28,0x80a2c001}, +{0x2c,0x34800006}, +{0x30,0xc2002300}, +{0x34,0xb0863fff}, +{0x38,0x1cbffff1}, +{0x3c,0x80a62003}, +{0x40,0xc2002300}, +{0x44,0x82007fff}, +{0x48,0x80a28001}, +{0x4c,0x12800042}, +{0x50,0x80a62001}, +{0x54,0xb8102000}, +{0x58,0xf2002304}, +{0x5c,0x80a70019}, +{0x60,0x1a80000e}, +{0x64,0xb6102000}, +{0x68,0x03000019}, +{0x6c,0x981063c0}, +{0x70,0xbb2f2002}, +{0x74,0xc207400c}, +{0x78,0x80a06000}, +{0x7c,0x04800004}, +{0xf0,0x5f}, +{0x00,0xb8072001}, +{0x04,0xc207400c}, +{0x08,0xb606c001}, +{0x0c,0x80a70019}, +{0x10,0x0abffff9}, +{0x14,0xbb2f2002}, +{0x18,0xc20021d8}, +{0x1c,0x825ec001}, +{0x20,0xbb38601f}, +{0x24,0xbb376019}, +{0x28,0x8200401d}, +{0x2c,0x83386007}, +{0x30,0x9e03c001}, +{0x34,0xb8102003}, +{0x38,0x80a72003}, +{0x3c,0x12800004}, +{0x40,0x80a72002}, +{0x44,0x1080000a}, +{0x48,0x9a10000f}, +{0x4c,0x32800009}, +{0x50,0x8333601f}, +{0x54,0xfa002470}, +{0x58,0xba5bc01d}, +{0x5c,0x833f601f}, +{0x60,0x83306019}, +{0x64,0xba074001}, +{0x68,0x9b3f6007}, +{0x6c,0x8333601f}, +{0x70,0x82034001}, +{0x74,0x80a6800d}, +{0x78,0x04800005}, +{0x7c,0x83386001}, +{0xf0,0x60}, +{0x00,0x80a2c001}, +{0x04,0x14800006}, +{0x08,0x80a62001}, +{0x0c,0xb8873fff}, +{0x10,0x1cbfffeb}, +{0x14,0x80a72003}, +{0x18,0x80a62001}, +{0x1c,0x14800003}, +{0x20,0xba102001}, +{0x24,0xba102000}, +{0x28,0x80a72001}, +{0x2c,0x04800003}, +{0x30,0x82102001}, +{0x34,0x82102000}, +{0x38,0x808f4001}, +{0x3c,0x02800006}, +{0x40,0x80a62001}, +{0x44,0x03000048}, +{0x48,0x82106345}, +{0x4c,0x10800004}, +{0x50,0xc22026f8}, +{0x54,0x14800003}, +{0x58,0x01000000}, +{0x5c,0xb0102000}, +{0x60,0x81c7e008}, +{0x64,0x81e80000}, +{0x68,0x9de3bf88}, +{0x6c,0x821026a0}, +{0x70,0xc2202580}, +{0x74,0xc02026f8}, +{0x78,0x90102000}, +{0x7c,0x96102000}, +{0xf0,0x61}, +{0x00,0x832ae002}, +{0x04,0x9602e001}, +{0x08,0xc02067e0}, +{0x0c,0xc0206720}, +{0x10,0x80a2e003}, +{0x14,0x04bffffb}, +{0x18,0xc0206730}, +{0x1c,0x03000018}, +{0x20,0xc0202514}, +{0x24,0x9a1062a8}, +{0x28,0xa0102000}, +{0x2c,0x832c2002}, +{0x30,0xa0042001}, +{0x34,0x80a42019}, +{0x38,0x04bffffd}, +{0x3c,0xc020400d}, +{0x40,0xa0102000}, +{0x44,0xc2002300}, +{0x48,0x80a40001}, +{0x4c,0x1a800018}, +{0x50,0x03000018}, +{0x54,0x921062ac}, +{0x58,0x82006400}, +{0x5c,0x9e106328}, +{0x60,0x832c2003}, +{0x64,0x9800400f}, +{0x68,0x952c2002}, +{0x6c,0x96102001}, +{0x70,0xc2030000}, +{0x74,0x9a380001}, +{0x78,0x9b3b601f}, +{0x7c,0x8208400d}, +{0xf0,0x62}, +{0x00,0xda028009}, +{0x04,0x9a034001}, +{0x08,0xda228009}, +{0x0c,0x9682ffff}, +{0x10,0x1cbffff8}, +{0x14,0x98032004}, +{0x18,0xa0042001}, +{0x1c,0xc2002300}, +{0x20,0x80a40001}, +{0x24,0x0abffff0}, +{0x28,0x832c2003}, +{0x2c,0xa0102001}, +{0x30,0xd8002300}, +{0x34,0x80a4000c}, +{0x38,0x1a80000f}, +{0x3c,0x03000018}, +{0x40,0x941062ac}, +{0x44,0x961062a8}, +{0x48,0x832c2002}, +{0x4c,0xda00400a}, +{0x50,0xc200400b}, +{0x54,0x8200400d}, +{0x58,0x80a04008}, +{0x5c,0x04800003}, +{0x60,0xa0042001}, +{0x64,0x90100001}, +{0x68,0x80a4000c}, +{0x6c,0x0abffff8}, +{0x70,0x832c2002}, +{0x74,0x1b000017}, +{0x78,0x82136324}, +{0x7c,0xc2004000}, +{0xf0,0x63}, +{0x00,0x80a06001}, +{0x04,0x1280001f}, +{0x08,0x82136388}, +{0x0c,0x03000018}, +{0x10,0x921062ac}, +{0x14,0x98102000}, +{0x18,0x96102001}, +{0x1c,0x941062a8}, +{0x20,0x832ae002}, +{0x24,0xda004009}, +{0x28,0xc200400a}, +{0x2c,0x8200400d}, +{0x30,0x80a0400c}, +{0x34,0x04800003}, +{0x38,0x9602e001}, +{0x3c,0x98100001}, +{0x40,0x80a2e015}, +{0x44,0x04bffff8}, +{0x48,0x832ae002}, +{0x4c,0xc20022b0}, +{0x50,0x80a30001}, +{0x54,0x03000017}, +{0x58,0x8210637c}, +{0x5c,0x088000f6}, +{0x60,0xd8204000}, +{0x64,0xda002514}, +{0x68,0x03004d40}, +{0x6c,0x9a036001}, +{0x70,0x821060e3}, +{0x74,0xc2202720}, +{0x78,0x108000ef}, +{0x7c,0xda202514}, +{0xf0,0x64}, +{0x00,0xc2004000}, +{0x04,0x80a06001}, +{0x08,0x1280000e}, +{0x0c,0xa0102000}, +{0x10,0xc21022ce}, +{0x14,0x80a20001}, +{0x18,0x04800004}, +{0x1c,0x9a13632c}, +{0x20,0x10800006}, +{0x24,0x8210203c}, +{0x28,0xc2034000}, +{0x2c,0x80a06000}, +{0x30,0x04800003}, +{0x34,0x82007fff}, +{0x38,0xc2234000}, +{0x3c,0xa0102000}, +{0x40,0xc2002300}, +{0x44,0x80a40001}, +{0x48,0x1a8000b4}, +{0x4c,0xa4043fff}, +{0x50,0x92042002}, +{0x54,0x80a48009}, +{0x58,0x9a102001}, +{0x5c,0x94102001}, +{0x60,0x16800018}, +{0x64,0x98100012}, +{0x68,0x03000019}, +{0x6c,0x9e10632c}, +{0x70,0x90106328}, +{0x74,0x80a32000}, +{0x78,0x2680000f}, +{0x7c,0x98032001}, +{0xf0,0x65}, +{0x00,0xc2002300}, +{0x04,0x80a30001}, +{0x08,0x1a80000a}, +{0x0c,0x972b2003}, +{0x10,0xc202c008}, +{0x14,0x80a06000}, +{0x18,0x34800002}, +{0x1c,0x9a034001}, +{0x20,0xc202c00f}, +{0x24,0x80a06000}, +{0x28,0x34800002}, +{0x2c,0x94028001}, +{0x30,0x98032001}, +{0x34,0x80a30009}, +{0x38,0x06bffff0}, +{0x3c,0x80a32000}, +{0x40,0x9a03400a}, +{0x44,0x832aa008}, +{0x48,0x9938601f}, +{0x4c,0x81832000}, +{0x50,0x01000000}, +{0x54,0x01000000}, +{0x58,0x01000000}, +{0x5c,0x8278400d}, +{0x60,0x94007f80}, +{0x64,0x833aa01f}, +{0x68,0x941a8001}, +{0x6c,0x94228001}, +{0x70,0x82102080}, +{0x74,0x9420400a}, +{0x78,0x8238000a}, +{0x7c,0x8338601f}, +{0xf0,0x66}, +{0x00,0x940a8001}, +{0x04,0xda082479}, +{0x08,0x9a5a800d}, +{0x0c,0x833b601f}, +{0x10,0x83306019}, +{0x14,0x9a034001}, +{0x18,0x9b3b6007}, +{0x1c,0xc2102548}, +{0x20,0x80886001}, +{0x24,0x0280000a}, +{0x28,0x9403400d}, +{0x2c,0xc2002558}, +{0x30,0x80a06000}, +{0x34,0x32800007}, +{0x38,0x9402a080}, +{0x3c,0x90100010}, +{0x40,0x9207bfe8}, +{0x44,0x10800005}, +{0x48,0xd410218c}, +{0x4c,0x9402a080}, +{0x50,0x90100010}, +{0x54,0x9207bfe8}, +{0x58,0xc2002fdc}, +{0x5c,0x9fc04000}, +{0x60,0x01000000}, +{0x64,0xa2922000}, +{0x68,0x22bfffb6}, +{0x6c,0xa0042001}, +{0x70,0xda07bfec}, +{0x74,0xc207bfe8}, +{0x78,0x8200400d}, +{0x7c,0xda07bff0}, +{0xf0,0x67}, +{0x00,0xa600400d}, +{0x04,0x96102000}, +{0x08,0x9b2ae002}, +{0x0c,0x9602e001}, +{0x10,0xc2036840}, +{0x14,0x80a2e003}, +{0x18,0x04bffffc}, +{0x1c,0xc2236850}, +{0x20,0x1b000019}, +{0x24,0x992c2003}, +{0x28,0x92136328}, +{0x2c,0xc2030009}, +{0x30,0xc2202840}, +{0x34,0x9a13632c}, +{0x38,0xc203000d}, +{0x3c,0x94042001}, +{0x40,0x96100012}, +{0x44,0xc2202844}, +{0x48,0xc0202848}, +{0x4c,0x80a4800a}, +{0x50,0x14800017}, +{0x54,0xc020284c}, +{0x58,0x90100009}, +{0x5c,0x9210000d}, +{0x60,0x80a2e000}, +{0x64,0x2680000f}, +{0x68,0x9602e001}, +{0x6c,0xc2002300}, +{0x70,0x80a2c001}, +{0x74,0x1a80000a}, +{0x78,0x992ae003}, +{0x7c,0xda030008}, +{0xf0,0x68}, +{0x00,0xc2002848}, +{0x04,0x8200400d}, +{0x08,0xc2202848}, +{0x0c,0xda030009}, +{0x10,0xc200284c}, +{0x14,0x8200400d}, +{0x18,0xc220284c}, +{0x1c,0x9602e001}, +{0x20,0x80a2c00a}, +{0x24,0x04bffff0}, +{0x28,0x80a2e000}, +{0x2c,0xd0002514}, +{0x30,0x80a22004}, +{0x34,0x1280000b}, +{0x38,0x80a46001}, +{0x3c,0xc2002fe4}, +{0x40,0x80a06000}, +{0x44,0x02800007}, +{0x48,0x80a46001}, +{0x4c,0x9fc04000}, +{0x50,0x90100013}, +{0x54,0x80a23fff}, +{0x58,0x0280002e}, +{0x5c,0x80a46001}, +{0x60,0x12800007}, +{0x64,0x80a46002}, +{0x68,0x03000008}, +{0x6c,0x82040001}, +{0x70,0x9b2a2002}, +{0x74,0x10800009}, +{0x78,0xc2236720}, +{0x7c,0x12800006}, +{0xf0,0x69}, +{0x00,0x9b2a2002}, +{0x04,0x03000010}, +{0x08,0x82040001}, +{0x0c,0x10800003}, +{0x10,0xc2236720}, +{0x14,0xe0236720}, +{0x18,0xda002300}, +{0x1c,0x83336001}, +{0x20,0x80a40001}, +{0x24,0x1a800005}, +{0x28,0x03000018}, +{0x2c,0x821062b0}, +{0x30,0x10800005}, +{0x34,0xda004000}, +{0x38,0x9b2b6002}, +{0x3c,0x821062a4}, +{0x40,0xda034001}, +{0x44,0x0300003f}, +{0x48,0x821063ff}, +{0x4c,0x820b4001}, +{0x50,0x9b2ce010}, +{0x54,0x992a2002}, +{0x58,0x9a134001}, +{0x5c,0xc2032730}, +{0x60,0x8210400d}, +{0x64,0xc2232730}, +{0x68,0xe02327e0}, +{0x6c,0xc2002514}, +{0x70,0x82006001}, +{0x74,0x80a06004}, +{0x78,0x12800006}, +{0x7c,0xc2202514}, +{0xf0,0x6a}, +{0x00,0xc2002fe4}, +{0x04,0x80a06000}, +{0x08,0x22800005}, +{0x0c,0xc2002514}, +{0x10,0x10bfff4c}, +{0x14,0xa0042001}, +{0x18,0xc2002514}, +{0x1c,0x80a06000}, +{0x20,0x3280000c}, +{0x24,0xc2002520}, +{0x28,0x96102000}, +{0x2c,0x832ae002}, +{0x30,0x9602e001}, +{0x34,0xc0206850}, +{0x38,0x80a2e003}, +{0x3c,0x04bffffc}, +{0x40,0xc0206840}, +{0x44,0xc20026a0}, +{0x48,0x10800007}, +{0x4c,0x82087bff}, +{0x50,0x80a06000}, +{0x54,0x22800006}, +{0x58,0x96102000}, +{0x5c,0xc20026a0}, +{0x60,0x82106400}, +{0x64,0xc22026a0}, +{0x68,0x96102000}, +{0x6c,0xd4002350}, +{0x70,0x992ae002}, +{0x74,0xda032850}, +{0x78,0x9a5b400a}, +{0x7c,0x833b601f}, +{0xf0,0x6b}, +{0x00,0x83306019}, +{0x04,0x9a034001}, +{0x08,0xc2032840}, +{0x0c,0x9b3b6007}, +{0x10,0x80a0400d}, +{0x14,0x16800005}, +{0x18,0x9602e001}, +{0x1c,0xc20026a0}, +{0x20,0x82106400}, +{0x24,0xc22026a0}, +{0x28,0x80a2e003}, +{0x2c,0x04bffff2}, +{0x30,0x992ae002}, +{0x34,0x1b000017}, +{0x38,0x82136388}, +{0x3c,0xc2004000}, +{0x40,0x80a06001}, +{0x44,0x12800045}, +{0x48,0x82136324}, +{0x4c,0xc2004000}, +{0x50,0x80a06001}, +{0x54,0x02800041}, +{0x58,0x9e102000}, +{0x5c,0xda002514}, +{0x60,0xc02026e0}, +{0x64,0x80a3c00d}, +{0x68,0xa4102000}, +{0x6c,0xa0102000}, +{0x70,0x1a80000a}, +{0x74,0x92102000}, +{0x78,0x98102001}, +{0x7c,0x832a6002}, +{0xf0,0x6c}, +{0x00,0xc20067e0}, +{0x04,0x832b0001}, +{0x08,0x92026001}, +{0x0c,0x80a2400d}, +{0x10,0x0abffffb}, +{0x14,0xa4148001}, +{0x18,0x92102000}, +{0x1c,0xe2002514}, +{0x20,0x80a24011}, +{0x24,0x1a800026}, +{0x28,0x03000019}, +{0x2c,0xa810632c}, +{0x30,0xa6106328}, +{0x34,0x832a6002}, +{0x38,0xc20067e0}, +{0x3c,0x94007ffd}, +{0x40,0x90102001}, +{0x44,0x8238000a}, +{0x48,0x9930601f}, +{0x4c,0x833c800a}, +{0x50,0x80886001}, +{0x54,0x32800014}, +{0x58,0x90823fff}, +{0x5c,0xc2002300}, +{0x60,0x80a28001}, +{0x64,0x82402000}, +{0x68,0x8088400c}, +{0x6c,0x0280000d}, +{0x70,0x9b2aa003}, +{0x74,0xd8034013}, +{0x78,0xd6034014}, +{0x7c,0x8238000c}, +{0xf0,0x6d}, +{0x00,0x9a38000b}, +{0x04,0x8338601f}, +{0x08,0x980b0001}, +{0x0c,0x9b3b601f}, +{0x10,0x9804000c}, +{0x14,0x960ac00d}, +{0x18,0xa003000b}, +{0x1c,0x9e03e001}, +{0x20,0x90823fff}, +{0x24,0x1cbfffe8}, +{0x28,0x9402a006}, +{0x2c,0x92026001}, +{0x30,0x80a24011}, +{0x34,0x0abfffe1}, +{0x38,0x832a6002}, +{0x3c,0x9b3c201f}, +{0x40,0x81836000}, +{0x44,0x01000000}, +{0x48,0x01000000}, +{0x4c,0x01000000}, +{0x50,0x827c000f}, +{0x54,0xc22026e0}, +{0x58,0x81c7e008}, +{0x5c,0x81e80000}, +{0x60,0x031fffff}, +{0x64,0x981063ff}, +{0x68,0x9a102000}, +{0x6c,0x832b6002}, +{0x70,0xc2106730}, +{0x74,0x80a0400c}, +{0x78,0x36800005}, +{0x7c,0x9a036001}, +{0xf0,0x6e}, +{0x00,0x98100001}, +{0x04,0x9610000d}, +{0x08,0x9a036001}, +{0x0c,0x80a36003}, +{0x10,0x04bffff8}, +{0x14,0x832b6002}, +{0x18,0x80a30008}, +{0x1c,0x1680000a}, +{0x20,0x90103fff}, +{0x24,0x832ae002}, +{0x28,0xc02067e0}, +{0x2c,0xc0206720}, +{0x30,0xc0206730}, +{0x34,0xc2002514}, +{0x38,0x82007fff}, +{0x3c,0xc2202514}, +{0x40,0x9010000b}, +{0x44,0x81c3e008}, +{0x48,0x01000000}, +{0x4c,0x9de3bf50}, +{0x50,0xc20022d4}, +{0x54,0x80886010}, +{0x58,0xa0102000}, +{0x5c,0xa2102000}, +{0x60,0x02800009}, +{0x64,0x972e2002}, +{0x68,0xc202e720}, +{0x6c,0xda002324}, +{0x70,0x82086fff}, +{0x74,0x8258400d}, +{0x78,0x8330600a}, +{0x7c,0x1080000e}, +{0xf0,0x6f}, +{0x00,0xc227bff0}, +{0x04,0xc212e720}, +{0x08,0xda002328}, +{0x0c,0x82086fff}, +{0x10,0x8258400d}, +{0x14,0x8330600b}, +{0x18,0xc227bff0}, +{0x1c,0xc202e720}, +{0x20,0x82086fff}, +{0x24,0xa3306005}, +{0x28,0xa0100011}, +{0x2c,0x9b2c6005}, +{0x30,0xa220400d}, +{0x34,0xa407bff8}, +{0x38,0x96102000}, +{0x3c,0x98100012}, +{0x40,0x8202c00b}, +{0x44,0xda5061c0}, +{0x48,0xc25061b0}, +{0x4c,0xc2233fd8}, +{0x50,0xda233fb8}, +{0x54,0x9602e001}, +{0x58,0x80a2e007}, +{0x5c,0x04bffff9}, +{0x60,0x98032004}, +{0x64,0x96102008}, +{0x68,0x9007bfd0}, +{0x6c,0x9207bfb0}, +{0x70,0x7ffff956}, +{0x74,0xd407bff0}, +{0x78,0xd6502456}, +{0x7c,0x80a2e000}, +{0xf0,0x70}, +{0x00,0x02800032}, +{0x04,0x82380008}, +{0x08,0xc2002328}, +{0x0c,0x8220400b}, +{0x10,0x80a20001}, +{0x14,0x28800016}, +{0x18,0xd6502454}, +{0x1c,0xd84c2440}, +{0x20,0xc24c2441}, +{0x24,0x8220400c}, +{0x28,0x82584011}, +{0x2c,0x9b38601f}, +{0x30,0x9b33601b}, +{0x34,0x8200400d}, +{0x38,0x83386005}, +{0x3c,0x9a030001}, +{0x40,0x8222000b}, +{0x44,0x8258400b}, +{0x48,0x9a22c00d}, +{0x4c,0x9938601f}, +{0x50,0x81832000}, +{0x54,0x01000000}, +{0x58,0x01000000}, +{0x5c,0x01000000}, +{0x60,0x8278400d}, +{0x64,0x9002c001}, +{0x68,0xd6502454}, +{0x6c,0x80a2000b}, +{0x70,0x16800016}, +{0x74,0x82380008}, +{0x78,0xd84c245c}, +{0x7c,0xc24c245d}, +{0xf0,0x71}, +{0x00,0x8220400c}, +{0x04,0x82584011}, +{0x08,0x9b38601f}, +{0x0c,0x9b33601b}, +{0x10,0x8200400d}, +{0x14,0x83386005}, +{0x18,0x9a030001}, +{0x1c,0x8222c008}, +{0x20,0x8258400b}, +{0x24,0x9a22c00d}, +{0x28,0x9938601f}, +{0x2c,0x81832000}, +{0x30,0x01000000}, +{0x34,0x01000000}, +{0x38,0x01000000}, +{0x3c,0x8278400d}, +{0x40,0x9022c001}, +{0x44,0x82380008}, +{0x48,0x8338601f}, +{0x4c,0x900a0001}, +{0x50,0xc2002328}, +{0x54,0x82007fff}, +{0x58,0x80a20001}, +{0x5c,0x38800002}, +{0x60,0x90100001}, +{0x64,0xd024bff8}, +{0x68,0xc20022d4}, +{0x6c,0x80886010}, +{0x70,0x972e2002}, +{0x74,0x0280000f}, +{0x78,0xc207bff0}, +{0x7c,0x9b28600a}, +{0xf0,0x72}, +{0x00,0x81800000}, +{0x04,0xc2002324}, +{0x08,0x01000000}, +{0x0c,0x01000000}, +{0x10,0x82734001}, +{0x14,0x9a100001}, +{0x18,0xc202e720}, +{0x1c,0x9a0b6fff}, +{0x20,0x82087000}, +{0x24,0x8210400d}, +{0x28,0x1080000f}, +{0x2c,0xc222e720}, +{0x30,0x8328600b}, +{0x34,0x81800000}, +{0x38,0xd8002328}, +{0x3c,0x01000000}, +{0x40,0x01000000}, +{0x44,0x9870400c}, +{0x48,0x820b2fff}, +{0x4c,0xd802e720}, +{0x50,0x1b03ffc0}, +{0x54,0x9a2b000d}, +{0x58,0x83286010}, +{0x5c,0x9a134001}, +{0x60,0xda22e720}, +{0x64,0x81c7e008}, +{0x68,0x81e80000}, +{0x6c,0x03169696}, +{0x70,0xda002180}, +{0x74,0x8210625a}, +{0x78,0x80a34001}, +{0x7c,0x94102000}, +{0xf0,0x73}, +{0x00,0x12800006}, +{0x04,0x96102000}, +{0x08,0x033fc180}, +{0x0c,0x82106030}, +{0x10,0x10800022}, +{0x14,0xda204000}, +{0x18,0xc202c000}, +{0x1c,0x9602e004}, +{0x20,0x80a2e4ff}, +{0x24,0x08bffffd}, +{0x28,0x94028001}, +{0x2c,0x96102d00}, +{0x30,0xd2002ff8}, +{0x34,0x03000019}, +{0x38,0x80a2c009}, +{0x3c,0x1a80000b}, +{0x40,0x901063ff}, +{0x44,0xd802c000}, +{0x48,0x9602e004}, +{0x4c,0x80a2c009}, +{0x50,0x9a402000}, +{0x54,0x80a2000b}, +{0x58,0x82603fff}, +{0x5c,0x808b4001}, +{0x60,0x12bffff9}, +{0x64,0x9402800c}, +{0x68,0xc2002200}, +{0x6c,0x94228001}, +{0x70,0x03169696}, +{0x74,0x8210625a}, +{0x78,0x80a28001}, +{0x7c,0x033fc180}, +{0xf0,0x74}, +{0x00,0x82106030}, +{0x04,0x02800005}, +{0x08,0xd4204000}, +{0x0c,0x0300000a}, +{0x10,0x81c062a4}, +{0x14,0x90102001}, +{0x18,0x01000000}, +{0x1c,0x81c3e008}, +{0x20,0x01000000}, +{0x24,0x1500003f}, +{0x28,0xd8002508}, +{0x2c,0x8212a300}, +{0x30,0x808b3f00}, +{0x34,0x02800016}, +{0x38,0x9a0b0001}, +{0x3c,0xc200254c}, +{0x40,0x8210400d}, +{0x44,0xc220254c}, +{0x48,0x1b3fc000}, +{0x4c,0xc2002500}, +{0x50,0x960b000d}, +{0x54,0x80a06058}, +{0x58,0xc0202508}, +{0x5c,0x0880000c}, +{0x60,0x033fffc0}, +{0x64,0x9a0b0001}, +{0x68,0x03168000}, +{0x6c,0x80a2c001}, +{0x70,0x12800007}, +{0x74,0x9412a3ff}, +{0x78,0xc2002548}, +{0x7c,0x8208400a}, +{0xf0,0x75}, +{0x00,0x8210400d}, +{0x04,0xc2202548}, +{0x08,0xc02026e4}, +{0x0c,0x81c3e008}, +{0x10,0x01000000}, +{0x14,0x9de3bf88}, +{0x18,0x7ffff5fa}, +{0x1c,0xae102001}, +{0x20,0xaa100008}, +{0x24,0xc027bfe8}, +{0x28,0xc027bfec}, +{0x2c,0x7ffff9b4}, +{0x30,0xc027bff0}, +{0x34,0x80a22000}, +{0x38,0x0280000d}, +{0x3c,0xba102000}, +{0x40,0x03000017}, +{0x44,0x82106324}, +{0x48,0xc2004000}, +{0x4c,0x80a06000}, +{0x50,0x12800005}, +{0x54,0x82102040}, +{0x58,0xc227bfec}, +{0x5c,0x10800007}, +{0x60,0xc227bfe8}, +{0x64,0x10800005}, +{0x68,0xc227bff0}, +{0x6c,0x82102008}, +{0x70,0xc227bfe8}, +{0x74,0xba102001}, +{0x78,0xa4102000}, +{0x7c,0xa8102000}, +{0xf0,0x76}, +{0x00,0xa6102000}, +{0x04,0x23000018}, +{0x08,0xa12ca002}, +{0x0c,0x8214604c}, +{0x10,0xc2040001}, +{0x14,0x80a06000}, +{0x18,0x12800006}, +{0x1c,0xac07bff8}, +{0x20,0x90146068}, +{0x24,0x7ffffad8}, +{0x28,0x90050008}, +{0x2c,0xac07bff8}, +{0x30,0x82040016}, +{0x34,0xc2007ff0}, +{0x38,0x80a06000}, +{0x3c,0x22800014}, +{0x40,0xa404a001}, +{0x44,0x90100011}, +{0x48,0x96102000}, +{0x4c,0x94146068}, +{0x50,0x98100013}, +{0x54,0x8202c00b}, +{0x58,0xda154001}, +{0x5c,0xc203000a}, +{0x60,0x8200400d}, +{0x64,0xc223000a}, +{0x68,0x9602e001}, +{0x6c,0x80a2e02f}, +{0x70,0x04bffff9}, +{0x74,0x98032004}, +{0x78,0x9a12204c}, +{0x7c,0xc204000d}, +{0xf0,0x77}, +{0x00,0x82006001}, +{0x04,0xc224000d}, +{0x08,0xa404a001}, +{0x0c,0xa604e0c0}, +{0x10,0x80a4a002}, +{0x14,0x04bfffdc}, +{0x18,0xa80520c0}, +{0x1c,0xa4102000}, +{0x20,0xa2102000}, +{0x24,0xa12ca002}, +{0x28,0x82040016}, +{0x2c,0xda007ff0}, +{0x30,0x80a36000}, +{0x34,0x2280002f}, +{0x38,0xa404a001}, +{0x3c,0x11000018}, +{0x40,0x9812204c}, +{0x44,0xc204000c}, +{0x48,0x80a0400d}, +{0x4c,0x24800029}, +{0x50,0xa404a001}, +{0x54,0x82122068}, +{0x58,0xa610000c}, +{0x5c,0x98044001}, +{0x60,0x96102000}, +{0x64,0x94122368}, +{0x68,0xc2030000}, +{0x6c,0x9b2ae002}, +{0x70,0x9338601f}, +{0x74,0x81826000}, +{0x78,0xd2040013}, +{0x7c,0x01000000}, +{0xf0,0x78}, +{0x00,0x01000000}, +{0x04,0x82784009}, +{0x08,0x9602e001}, +{0x0c,0xc223400a}, +{0x10,0x80a2e02f}, +{0x14,0x04bffff5}, +{0x18,0x98032004}, +{0x1c,0x03000017}, +{0x20,0x82106324}, +{0x24,0xda004000}, +{0x28,0x8203400d}, +{0x2c,0x8200400d}, +{0x30,0x13000019}, +{0x34,0x83286005}, +{0x38,0x92126268}, +{0x3c,0x92004009}, +{0x40,0x7ffffa47}, +{0x44,0x90122368}, +{0x48,0xc20026e4}, +{0x4c,0x82006001}, +{0x50,0xc22026e4}, +{0x54,0xc0240013}, +{0x58,0x80a76000}, +{0x5c,0x02800004}, +{0x60,0xae102000}, +{0x64,0x7ffff93d}, +{0x68,0x01000000}, +{0x6c,0xa404a001}, +{0x70,0x80a4a002}, +{0x74,0x04bfffcc}, +{0x78,0xa20460c0}, +{0x7c,0xee202584}, +{0xf0,0x79}, +{0x00,0x81c7e008}, +{0x04,0x81e80000}, +{0x08,0x9de3bf98}, +{0x0c,0x03000017}, +{0x10,0x82106324}, +{0x14,0xc2004000}, +{0x18,0x80a06001}, +{0x1c,0x02800062}, +{0x20,0x01000000}, +{0x24,0xc2502198}, +{0x28,0x80a06000}, +{0x2c,0x0280005e}, +{0x30,0x01000000}, +{0x34,0xc2102548}, +{0x38,0x80886001}, +{0x3c,0x1280005a}, +{0x40,0x94102000}, +{0x44,0xc2002300}, +{0x48,0x80a28001}, +{0x4c,0x1a80003c}, +{0x50,0x96102000}, +{0x54,0x03000019}, +{0x58,0x90106328}, +{0x5c,0x98102000}, +{0x60,0x832ae003}, +{0x64,0xb0004008}, +{0x68,0xb2102000}, +{0x6c,0xb52b2010}, +{0x70,0xfa502198}, +{0x74,0xc2060000}, +{0x78,0x80a0401d}, +{0x7c,0x36800026}, +{0xf0,0x7a}, +{0x00,0xb2066001}, +{0x04,0xb6102000}, +{0x08,0x9a030019}, +{0x0c,0x92102001}, +{0x10,0x9e16a100}, +{0x14,0xbb2ee002}, +{0x18,0xf8076524}, +{0x1c,0x80a72000}, +{0x20,0x22800012}, +{0x24,0xc2076524}, +{0x28,0xc20f6525}, +{0x2c,0x80a0400d}, +{0x30,0x3280000e}, +{0x34,0xc2076524}, +{0x38,0x82072100}, +{0x3c,0xc2276524}, +{0x40,0xfa0f6526}, +{0x44,0xc208219a}, +{0x48,0x80a74001}, +{0x4c,0x0880000c}, +{0x50,0x832a401b}, +{0x54,0xc200254c}, +{0x58,0x3b000200}, +{0x5c,0x8210401d}, +{0x60,0x10800031}, +{0x64,0xc220254c}, +{0x68,0x80a06000}, +{0x6c,0x32800006}, +{0x70,0xb606e001}, +{0x74,0x832a401b}, +{0x78,0xde276524}, +{0x7c,0x10800005}, +{0xf0,0x7b}, +{0x00,0x94128001}, +{0x04,0x80a6e003}, +{0x08,0x04bfffe4}, +{0x0c,0xbb2ee002}, +{0x10,0xb2066001}, +{0x14,0x03000040}, +{0x18,0xb4068001}, +{0x1c,0x80a66001}, +{0x20,0x04bfffd4}, +{0x24,0xb0062004}, +{0x28,0x9602e001}, +{0x2c,0xc2002300}, +{0x30,0x80a2c001}, +{0x34,0x0abfffcb}, +{0x38,0x98032002}, +{0x3c,0xb2102000}, +{0x40,0xb6102000}, +{0x44,0xb92ee002}, +{0x48,0xc2072524}, +{0x4c,0xb4006001}, +{0x50,0xbb3a801b}, +{0x54,0x80a06000}, +{0x58,0x02800013}, +{0x5c,0xb12e6002}, +{0x60,0x808f6001}, +{0x64,0x3280000a}, +{0x68,0xc2072524}, +{0x6c,0xf4272524}, +{0x70,0xfa0f2527}, +{0x74,0xc208219b}, +{0x78,0x80a74001}, +{0x7c,0x28800004}, +{0xf0,0x7c}, +{0x00,0xc2072524}, +{0x04,0x10800004}, +{0x08,0xc0272524}, +{0x0c,0xb2066001}, +{0x10,0xc2262524}, +{0x14,0xb606e001}, +{0x18,0x80a6e003}, +{0x1c,0x04bfffeb}, +{0x20,0xb92ee002}, +{0x24,0x81c7e008}, +{0x28,0x81e80000}, +{0x2c,0x9de3bf98}, +{0x30,0x7ffff7c4}, +{0x34,0x01000000}, +{0x38,0x1b000017}, +{0x3c,0x82102001}, +{0x40,0x9a136388}, +{0x44,0xc2234000}, +{0x48,0xc2002fe0}, +{0x4c,0x9fc04000}, +{0x50,0x01000000}, +{0x54,0x01000000}, +{0x58,0x81c7e008}, +{0x5c,0x81e80000}, +{0x60,0x9de3bf98}, +{0x64,0x03000017}, +{0x68,0x82106324}, +{0x6c,0xc2004000}, +{0x70,0x80a06001}, +{0x74,0x02800066}, +{0x78,0x9a102000}, +{0x7c,0xf8002514}, +{0xf0,0x7d}, +{0x00,0xc02026e0}, +{0x04,0x80a3401c}, +{0x08,0xb0102000}, +{0x0c,0x1a80000f}, +{0x10,0xb2102000}, +{0x14,0xc2002300}, +{0x18,0xbb306001}, +{0x1c,0xb6102001}, +{0x20,0x832e6002}, +{0x24,0xc20067e0}, +{0x28,0x80a0401d}, +{0x2c,0x0a800003}, +{0x30,0xb2066001}, +{0x34,0x8220401d}, +{0x38,0x832ec001}, +{0x3c,0x80a6401c}, +{0x40,0x0abffff8}, +{0x44,0xb0160001}, +{0x48,0x3b000017}, +{0x4c,0xb4176380}, +{0x50,0xc2002300}, +{0x54,0xb93e2001}, +{0x58,0xba176384}, +{0x5c,0xb816001c}, +{0x60,0xb6060018}, +{0x64,0x83306001}, +{0x68,0xb2102000}, +{0x6c,0xc0274000}, +{0x70,0xb017001b}, +{0x74,0x80a64001}, +{0x78,0x1a80002e}, +{0x7c,0xc0268000}, +{0xf0,0x7e}, +{0x00,0x94100001}, +{0x04,0x03000019}, +{0x08,0x98106328}, +{0x0c,0x9610632c}, +{0x10,0x82007800}, +{0x14,0x9e106384}, +{0x18,0x92106380}, +{0x1c,0x833e0019}, +{0x20,0x80886001}, +{0x24,0x1280001f}, +{0x28,0xbb2e6003}, +{0x2c,0xf607400c}, +{0x30,0x8238001b}, +{0x34,0xf407400b}, +{0x38,0x8338601f}, +{0x3c,0xb60ec001}, +{0x40,0xb838001a}, +{0x44,0xfa03c000}, +{0x48,0xc2002300}, +{0x4c,0xb93f201f}, +{0x50,0xba07401b}, +{0x54,0xb40e801c}, +{0x58,0x83306001}, +{0x5c,0xba07401a}, +{0x60,0x82004019}, +{0x64,0xfa23c000}, +{0x68,0x83286003}, +{0x6c,0xf600400b}, +{0x70,0xf800400c}, +{0x74,0x8238001c}, +{0x78,0x8338601f}, +{0x7c,0xba38001b}, +{0xf0,0x7f}, +{0x00,0xb80f0001}, +{0x04,0xc2024000}, +{0x08,0xbb3f601f}, +{0x0c,0x8200401c}, +{0x10,0xb60ec01d}, +{0x14,0x8200401b}, +{0x18,0x9a036001}, +{0x1c,0xc2224000}, +{0x20,0xb2066001}, +{0x24,0x80a6400a}, +{0x28,0x0abfffd8}, +{0x2c,0x03000019}, +{0x30,0x37000017}, +{0x34,0x8216e380}, +{0x38,0xb616e384}, +{0x3c,0xf806c000}, +{0x40,0xc2004000}, +{0x44,0x82070001}, +{0x48,0x9938601f}, +{0x4c,0x81832000}, +{0x50,0x01000000}, +{0x54,0x01000000}, +{0x58,0x01000000}, +{0x5c,0x8278400d}, +{0x60,0xbb30601f}, +{0x64,0x8200401d}, +{0x68,0x993f201f}, +{0x6c,0x81832000}, +{0x70,0x01000000}, +{0x74,0x01000000}, +{0x78,0x01000000}, +{0x7c,0xb87f000d}, +{0xf0,0x80}, +{0x00,0x83386001}, +{0x04,0xf826c000}, +{0x08,0xc22026e0}, +{0x0c,0x81c7e008}, +{0x10,0x81e80000}, +{0x14,0x9de3bf98}, +{0x18,0x03000017}, +{0x1c,0x82106324}, +{0x20,0xc2004000}, +{0x24,0x80a06001}, +{0x28,0x0280005a}, +{0x2c,0x01000000}, +{0x30,0xc2002514}, +{0x34,0x80a06000}, +{0x38,0x12800056}, +{0x3c,0x01000000}, +{0x40,0xde002200}, +{0x44,0x80a3e000}, +{0x48,0x1280000a}, +{0x4c,0x03000019}, +{0x50,0xc2002548}, +{0x54,0x82087ffb}, +{0x58,0xc2202548}, +{0x5c,0x033fc180}, +{0x60,0x8210602c}, +{0x64,0xc0204000}, +{0x68,0x1080004a}, +{0x6c,0xc02026e8}, +{0x70,0xc0202504}, +{0x74,0x9a106328}, +{0x78,0xb4102000}, +{0x7c,0x10800011}, +{0xf0,0x81}, +{0x00,0xf0102214}, +{0x04,0xba00400d}, +{0x08,0xf2102216}, +{0x0c,0xb6102001}, +{0x10,0xc2074000}, +{0x14,0xba076004}, +{0x18,0x80a04019}, +{0x1c,0x04800005}, +{0x20,0xb8204019}, +{0x24,0xc2002504}, +{0x28,0x8200401c}, +{0x2c,0xc2202504}, +{0x30,0xb686ffff}, +{0x34,0x3cbffff8}, +{0x38,0xc2074000}, +{0x3c,0xb406a001}, +{0x40,0x80a62000}, +{0x44,0x32800003}, +{0x48,0x80a68018}, +{0x4c,0x80a6800f}, +{0x50,0x38800007}, +{0x54,0xfa10221a}, +{0x58,0xc2002300}, +{0x5c,0x80a68001}, +{0x60,0x08bfffe9}, +{0x64,0x832ea003}, +{0x68,0xfa10221a}, +{0x6c,0xc2002504}, +{0x70,0x80a0401d}, +{0x74,0x34800009}, +{0x78,0xc2002548}, +{0x7c,0xc2102218}, +{0xf0,0x82}, +{0x00,0x80a06000}, +{0x04,0x2280000a}, +{0x08,0xc2002548}, +{0x0c,0x80a06000}, +{0x10,0x12800007}, +{0x14,0xc2002548}, +{0x18,0x80886008}, +{0x1c,0x22800008}, +{0x20,0xc20026e8}, +{0x24,0x10800008}, +{0x28,0xc02026e8}, +{0x2c,0x80886008}, +{0x30,0x22800005}, +{0x34,0xc02026e8}, +{0x38,0xc20026e8}, +{0x3c,0x82006001}, +{0x40,0xc22026e8}, +{0x44,0xfa0026e8}, +{0x48,0xc2002290}, +{0x4c,0x80a74001}, +{0x50,0x0880000b}, +{0x54,0xfa002548}, +{0x58,0x83376003}, +{0x5c,0x82086001}, +{0x60,0x82186001}, +{0x64,0x83286002}, +{0x68,0xba0f7ffb}, +{0x6c,0xba174001}, +{0x70,0xfa202548}, +{0x74,0xc02026e8}, +{0x78,0xfa002548}, +{0x7c,0xbb376002}, +{0xf0,0x83}, +{0x00,0x033fc180}, +{0x04,0xba0f6001}, +{0x08,0x8210602c}, +{0x0c,0xfa204000}, +{0x10,0x81c7e008}, +{0x14,0x81e80000}, +{0x18,0x9de3bf60}, +{0x1c,0xc25022ba}, +{0x20,0x80a06000}, +{0x24,0x02800076}, +{0x28,0x03000017}, +{0x2c,0x82106324}, +{0x30,0xc2004000}, +{0x34,0x80a06001}, +{0x38,0x02800071}, +{0x3c,0x01000000}, +{0x40,0xc2002514}, +{0x44,0x80a06001}, +{0x48,0x1880006d}, +{0x4c,0xa0102000}, +{0x50,0xa4102000}, +{0x54,0xa32c2002}, +{0x58,0x9a07bff8}, +{0x5c,0x8204400d}, +{0x60,0xc0207fc8}, +{0x64,0x92102000}, +{0x68,0x8207bfe0}, +{0x6c,0x98102005}, +{0x70,0xc0204000}, +{0x74,0x98833fff}, +{0x78,0x1cbffffe}, +{0x7c,0x82006004}, +{0xf0,0x84}, +{0x00,0x03000019}, +{0x04,0x9e106268}, +{0x08,0x82007c00}, +{0x0c,0x90106368}, +{0x10,0x96037fe8}, +{0x14,0x98102000}, +{0x18,0x8204800c}, +{0x1c,0x82186001}, +{0x20,0x9b286002}, +{0x24,0x94004001}, +{0x28,0xc2046ea0}, +{0x2c,0x8338400c}, +{0x30,0x80886001}, +{0x34,0x02800008}, +{0x38,0x98032001}, +{0x3c,0xda034008}, +{0x40,0xc212800f}, +{0x44,0x8220400d}, +{0x48,0xc222c000}, +{0x4c,0x92026001}, +{0x50,0x9602e004}, +{0x54,0x80a32005}, +{0x58,0x04bffff1}, +{0x5c,0x8204800c}, +{0x60,0x7ffff69e}, +{0x64,0x9007bfe0}, +{0x68,0xc25022ba}, +{0x6c,0xd25022b8}, +{0x70,0x96007fff}, +{0x74,0x98100009}, +{0x78,0x80a2400b}, +{0x7c,0x1480000b}, +{0xf0,0x85}, +{0x00,0x94102000}, +{0x04,0x832a6002}, +{0x08,0x8200401e}, +{0x0c,0x9a007fe0}, +{0x10,0xc2034000}, +{0x14,0x98032001}, +{0x18,0x94028001}, +{0x1c,0x80a3000b}, +{0x20,0x04bffffc}, +{0x24,0x9a036004}, +{0x28,0x8222c009}, +{0x2c,0x82006001}, +{0x30,0x9b3aa01f}, +{0x34,0x81836000}, +{0x38,0x01000000}, +{0x3c,0x01000000}, +{0x40,0x01000000}, +{0x44,0x947a8001}, +{0x48,0xc25021ac}, +{0x4c,0x80a28001}, +{0x50,0x26800002}, +{0x54,0x94100001}, +{0x58,0x9e07bff8}, +{0x5c,0x8204400f}, +{0x60,0xa0042001}, +{0x64,0xd4207fc8}, +{0x68,0x80a42006}, +{0x6c,0x04bfffba}, +{0x70,0xa404a006}, +{0x74,0xa0102000}, +{0x78,0xc2002300}, +{0x7c,0x80a40001}, +{0xf0,0x86}, +{0x00,0x1a80001f}, +{0x04,0x03000019}, +{0x08,0x92106328}, +{0x0c,0x030aaaaa}, +{0x10,0x901062ab}, +{0x14,0x94042400}, +{0x18,0x972c2003}, +{0x1c,0x98102001}, +{0x20,0xda0a8000}, +{0x24,0x9b2b6018}, +{0x28,0x833b6018}, +{0x2c,0x9b3b601f}, +{0x30,0x80584008}, +{0x34,0x83400000}, +{0x38,0x8220400d}, +{0x3c,0x83286018}, +{0x40,0x83386016}, +{0x44,0x8200400f}, +{0x48,0xda007fc8}, +{0x4c,0xc202c009}, +{0x50,0x8220400d}, +{0x54,0xc222c009}, +{0x58,0x9602e004}, +{0x5c,0x98833fff}, +{0x60,0x1cbffff0}, +{0x64,0x9402a020}, +{0x68,0xa0042001}, +{0x6c,0xc2002300}, +{0x70,0x80a40001}, +{0x74,0x0abfffe9}, +{0x78,0x94042400}, +{0x7c,0x81c7e008}, +{0xf0,0x87}, +{0x00,0x81e80000}, +{0x04,0x9de3bf98}, +{0x08,0x1b000017}, +{0x0c,0x82102002}, +{0x10,0x9a136388}, +{0x14,0xc2234000}, +{0x18,0xc2002fe0}, +{0x1c,0x9fc04000}, +{0x20,0x01000000}, +{0x24,0x01000000}, +{0x28,0x81c7e008}, +{0x2c,0x81e80000}, +{0x30,0x9de3bf28}, +{0x34,0xb12e2002}, +{0x38,0xc2062720}, +{0x3c,0xa2086fff}, +{0x40,0x7ffff6d9}, +{0x44,0x90100011}, +{0x48,0x9a047ffe}, +{0x4c,0xa0046002}, +{0x50,0x80a34010}, +{0x54,0x14800025}, +{0x58,0x832b6003}, +{0x5c,0x90006004}, +{0x60,0x9407bff8}, +{0x64,0x25000019}, +{0x68,0xc022bfe8}, +{0x6c,0x80a36000}, +{0x70,0x06800019}, +{0x74,0xc022bfb8}, +{0x78,0xc2002300}, +{0x7c,0x80a34001}, +{0xf0,0x88}, +{0x00,0x3a800016}, +{0x04,0x9a036001}, +{0x08,0x9e14a328}, +{0x0c,0x832b6003}, +{0x10,0x9600400f}, +{0x14,0x92102000}, +{0x18,0xd802c000}, +{0x1c,0x80a32000}, +{0x20,0x04800009}, +{0x24,0x9602e004}, +{0x28,0xc202bfe8}, +{0x2c,0x8200400c}, +{0x30,0x80a26001}, +{0x34,0x12800004}, +{0x38,0xc222bfe8}, +{0x3c,0xc202000f}, +{0x40,0xc222bfb8}, +{0x44,0x92026001}, +{0x48,0x80a26001}, +{0x4c,0x24bffff4}, +{0x50,0xd802c000}, +{0x54,0x9a036001}, +{0x58,0x90022008}, +{0x5c,0x80a34010}, +{0x60,0x04bfffe2}, +{0x64,0x9402a004}, +{0x68,0x9a102020}, +{0x6c,0xa8102000}, +{0x70,0xa6102040}, +{0x74,0x80a36020}, +{0x78,0x0480000b}, +{0x7c,0x82102020}, +{0xf0,0x89}, +{0x00,0x82102060}, +{0x04,0x8220400d}, +{0x08,0x9a037fe0}, +{0x0c,0xc227bfcc}, +{0x10,0xda27bfd8}, +{0x14,0xc027bfc8}, +{0x18,0xe627bfd0}, +{0x1c,0x10800009}, +{0x20,0xe627bfd4}, +{0x24,0x8220400d}, +{0x28,0x9a036020}, +{0x2c,0xc227bfc8}, +{0x30,0xda27bfd4}, +{0x34,0xe627bfcc}, +{0x38,0xe627bfd0}, +{0x3c,0xc027bfd8}, +{0x40,0x90102000}, +{0x44,0xa4102000}, +{0x48,0xac102000}, +{0x4c,0xaa102000}, +{0x50,0x92102000}, +{0x54,0xae07bff8}, +{0x58,0xa12a6002}, +{0x5c,0x82040017}, +{0x60,0xd6007fd0}, +{0x64,0xd8007fe8}, +{0x68,0x985b000b}, +{0x6c,0x833b201f}, +{0x70,0x8330601a}, +{0x74,0x98030001}, +{0x78,0x9b2a6007}, +{0x7c,0x8223400b}, +{0xf0,0x8a}, +{0x00,0x993b2006}, +{0x04,0x9a03400b}, +{0x08,0x82006080}, +{0x0c,0x825b0001}, +{0x10,0x9a5b000d}, +{0x14,0x9730601f}, +{0x18,0x9533601f}, +{0x1c,0x8200400b}, +{0x20,0x9a03400a}, +{0x24,0x83386001}, +{0x28,0x9b3b6001}, +{0x2c,0x80a26002}, +{0x30,0x9405800c}, +{0x34,0x9e05400c}, +{0x38,0x14800004}, +{0x3c,0x96026001}, +{0x40,0x10800003}, +{0x44,0x90020001}, +{0x48,0x9002000d}, +{0x4c,0x82040017}, +{0x50,0xd8007fd0}, +{0x54,0xda007fb8}, +{0x58,0x9a5b400c}, +{0x5c,0x833b601f}, +{0x60,0x8330601a}, +{0x64,0x9a034001}, +{0x68,0x9b3b6006}, +{0x6c,0x9210000b}, +{0x70,0xa404800d}, +{0x74,0x80a2e004}, +{0x78,0xac10000a}, +{0x7c,0x04bfffd7}, +{0xf0,0x8b}, +{0x00,0xaa10000f}, +{0x04,0x9b3a201f}, +{0x08,0x81836000}, +{0x0c,0x01000000}, +{0x10,0x01000000}, +{0x14,0x01000000}, +{0x18,0x827a000a}, +{0x1c,0xa8052001}, +{0x20,0x80a52002}, +{0x24,0x04bfffb4}, +{0x28,0x9a007f80}, +{0x2c,0xa12c6006}, +{0x30,0xa0034010}, +{0x34,0xa32ca00a}, +{0x38,0x833c601f}, +{0x3c,0x81806000}, +{0x40,0x01000000}, +{0x44,0x01000000}, +{0x48,0x01000000}, +{0x4c,0xa27c400f}, +{0x50,0x90100010}, +{0x54,0x7ffff782}, +{0x58,0x92102000}, +{0x5c,0xc2062720}, +{0x60,0x1b000010}, +{0x64,0xa2044008}, +{0x68,0x8088400d}, +{0x6c,0x912c2010}, +{0x70,0x02800005}, +{0x74,0x820c6fff}, +{0x78,0x82020001}, +{0x7c,0x10800003}, +{0xf0,0x8c}, +{0x00,0x8200400d}, +{0x04,0x82020001}, +{0x08,0xc2262720}, +{0x0c,0x81c7e008}, +{0x10,0x81e80000}, +{0x14,0x9de3bf98}, +{0x18,0x7ffff801}, +{0x1c,0x9010205a}, +{0x20,0xc2002548}, +{0x24,0x9a087fbf}, +{0x28,0xc2002514}, +{0x2c,0x80a06000}, +{0x30,0x02800004}, +{0x34,0xda202548}, +{0x38,0x82136040}, +{0x3c,0xc2202548}, +{0x40,0xc20022d4}, +{0x44,0x80886200}, +{0x48,0x22800007}, +{0x4c,0xc2002514}, +{0x50,0xc20026a0}, +{0x54,0x80886400}, +{0x58,0x22800002}, +{0x5c,0xc0202514}, +{0x60,0xc2002514}, +{0x64,0xb0102000}, +{0x68,0x80a60001}, +{0x6c,0xc2202520}, +{0x70,0xa0102000}, +{0x74,0x1a800019}, +{0x78,0xa32e2002}, +{0x7c,0xc2046720}, +{0xf0,0x8d}, +{0x00,0x8330600d}, +{0x04,0x80886001}, +{0x08,0x12800010}, +{0x0c,0x90100018}, +{0x10,0x7fffff48}, +{0x14,0x01000000}, +{0x18,0xc2002fec}, +{0x1c,0x80a06000}, +{0x20,0x02800004}, +{0x24,0x90100018}, +{0x28,0x9fc04000}, +{0x2c,0x01000000}, +{0x30,0xc2046720}, +{0x34,0x80a06000}, +{0x38,0x02800004}, +{0x3c,0x9b2c2002}, +{0x40,0xa0042001}, +{0x44,0xc2236720}, +{0x48,0xb0062001}, +{0x4c,0xc2002514}, +{0x50,0x10bfffe9}, +{0x54,0x80a60001}, +{0x58,0x03000017}, +{0x5c,0x8210631c}, +{0x60,0xc2004000}, +{0x64,0x80a06002}, +{0x68,0x12800016}, +{0x6c,0xe0202514}, +{0x70,0x80a42001}, +{0x74,0x08800015}, +{0x78,0xb0102000}, +{0x7c,0x80a60010}, +{0xf0,0x8e}, +{0x00,0x1a80000e}, +{0x04,0x96100010}, +{0x08,0x992e2002}, +{0x0c,0xda132730}, +{0x10,0xc2102730}, +{0x14,0x80a34001}, +{0x18,0x08800005}, +{0x1c,0xb0062001}, +{0x20,0xda302730}, +{0x24,0xc2032720}, +{0x28,0xc2202720}, +{0x2c,0x80a6000b}, +{0x30,0x0abffff7}, +{0x34,0x992e2002}, +{0x38,0x82102001}, +{0x3c,0xc2202514}, +{0x40,0x7ffff6b5}, +{0x44,0x81e80000}, +{0x48,0x01000000}, +{0x4c,0x81c7e008}, +{0x50,0x81e80000}, +{0x54,0xc2102548}, +{0x58,0x80886001}, +{0x5c,0xc020255c}, +{0x60,0x02800007}, +{0x64,0x92102000}, +{0x68,0xc20023c8}, +{0x6c,0x8330600d}, +{0x70,0x80886001}, +{0x74,0x02800025}, +{0x78,0x01000000}, +{0x7c,0xd0002304}, +{0xf0,0x8f}, +{0x00,0x80a24008}, +{0x04,0x1a800010}, +{0x08,0x96102000}, +{0x0c,0x03000019}, +{0x10,0x941063c0}, +{0x14,0x992ae002}, +{0x18,0xc203000a}, +{0x1c,0xc203000a}, +{0x20,0x80a04009}, +{0x24,0x24800005}, +{0x28,0x9602e001}, +{0x2c,0xd203000a}, +{0x30,0x9a10000b}, +{0x34,0x9602e001}, +{0x38,0x80a2c008}, +{0x3c,0x0abffff7}, +{0x40,0x992ae002}, +{0x44,0x9b2b6008}, +{0x48,0xc2002288}, +{0x4c,0x80a24001}, +{0x50,0x0680000e}, +{0x54,0x9a036020}, +{0x58,0x98102001}, +{0x5c,0xc2002704}, +{0x60,0x80a06000}, +{0x64,0x12800009}, +{0x68,0xd820255c}, +{0x6c,0xc2002514}, +{0x70,0x80a06000}, +{0x74,0x12800005}, +{0x78,0x0303ffc4}, +{0x7c,0x82034001}, +{0xf0,0x90}, +{0x00,0xc2202720}, +{0x04,0xd8202514}, +{0x08,0x81c3e008}, +{0x0c,0x01000000}, +{0x10,0x9de3bf98}, +{0x14,0x7ffff66a}, +{0x18,0x01000000}, +{0x1c,0xc208254d}, +{0x20,0x80a06000}, +{0x24,0x02800019}, +{0x28,0x033fc180}, +{0x2c,0xc0204000}, +{0x30,0xb0102002}, +{0x34,0x7ffff89c}, +{0x38,0x90102001}, +{0x3c,0x11000099}, +{0x40,0x7ffff516}, +{0x44,0x9012233c}, +{0x48,0xb0863fff}, +{0x4c,0x1cbffffa}, +{0x50,0x01000000}, +{0x54,0xc210254c}, +{0x58,0x80886001}, +{0x5c,0x32800002}, +{0x60,0xc020250c}, +{0x64,0x7ffff342}, +{0x68,0x90102015}, +{0x6c,0xda102548}, +{0x70,0x82102001}, +{0x74,0x808b6001}, +{0x78,0x12800004}, +{0x7c,0xc2202584}, +{0xf0,0x91}, +{0x00,0x7ffff402}, +{0x04,0x91e82001}, +{0x08,0x01000000}, +{0x0c,0x81c7e008}, +{0x10,0x81e80000}, +{0x14,0x9de3bf88}, +{0x18,0x03000017}, +{0x1c,0x82106324}, +{0x20,0xc2004000}, +{0x24,0x80a06001}, +{0x28,0x02800037}, +{0x2c,0x01000000}, +{0x30,0xc208254e}, +{0x34,0x80a00001}, +{0x38,0xda102548}, +{0x3c,0x82602000}, +{0x40,0x9a0b6001}, +{0x44,0x80a0000d}, +{0x48,0x82087ffe}, +{0x4c,0x9a403fff}, +{0x50,0x82006003}, +{0x54,0x8208400d}, +{0x58,0xda086314}, +{0x5c,0xc20026e4}, +{0x60,0x80a0400d}, +{0x64,0x06800028}, +{0x68,0x80a36000}, +{0x6c,0x02800026}, +{0x70,0x01000000}, +{0x74,0xda00254c}, +{0x78,0x83336018}, +{0x7c,0x80886001}, +{0xf0,0x92}, +{0x00,0x12800007}, +{0x04,0x03004000}, +{0x08,0xc20026f4}, +{0x0c,0x80a06000}, +{0x10,0x22800008}, +{0x14,0xc200255c}, +{0x18,0x03004000}, +{0x1c,0x822b4001}, +{0x20,0xc220254c}, +{0x24,0xc027bfec}, +{0x28,0x10800009}, +{0x2c,0xc027bff0}, +{0x30,0x80a06000}, +{0x34,0x12800014}, +{0x38,0x01000000}, +{0x3c,0xc208221c}, +{0x40,0xc227bfec}, +{0x44,0xc208221d}, +{0x48,0xc227bff0}, +{0x4c,0xa0102000}, +{0x50,0xc2002304}, +{0x54,0x80a40001}, +{0x58,0x1a80000b}, +{0x5c,0x01000000}, +{0x60,0xc24c2380}, +{0x64,0xc227bfe8}, +{0x68,0x7ffff7b6}, +{0x6c,0x9007bfe8}, +{0x70,0xa0042001}, +{0x74,0xc2002304}, +{0x78,0x80a40001}, +{0x7c,0x2abffffa}, +{0xf0,0x93}, +{0x00,0xc24c2380}, +{0x04,0x81c7e008}, +{0x08,0x81e80000}, +{0x0c,0x9de3bf78}, +{0x10,0x03000017}, +{0x14,0x82106324}, +{0x18,0xc2004000}, +{0x1c,0x80a06000}, +{0x20,0x12800093}, +{0x24,0xc208254e}, +{0x28,0x80a00001}, +{0x2c,0x82602000}, +{0x30,0xa0087ffe}, +{0x34,0xd8002548}, +{0x38,0x83332010}, +{0x3c,0x80886001}, +{0x40,0x0280000c}, +{0x44,0xa0042003}, +{0x48,0x83332011}, +{0x4c,0x80886001}, +{0x50,0x02800030}, +{0x54,0xa0102000}, +{0x58,0xc2002558}, +{0x5c,0x80a06001}, +{0x60,0x28800081}, +{0x64,0xc02026e4}, +{0x68,0x1080002b}, +{0x6c,0xc20c2314}, +{0x70,0x033fc200}, +{0x74,0x82106030}, +{0x78,0xda004000}, +{0x7c,0xc2002570}, +{0xf0,0x94}, +{0x00,0x80a34001}, +{0x04,0x32800078}, +{0x08,0xc02026e4}, +{0x0c,0x808b2040}, +{0x10,0x3280000f}, +{0x14,0x21000019}, +{0x18,0xc2002200}, +{0x1c,0x80a06000}, +{0x20,0x3280000b}, +{0x24,0x21000019}, +{0x28,0xc200255c}, +{0x2c,0x80a06001}, +{0x30,0x22800007}, +{0x34,0x21000019}, +{0x38,0xc20026f8}, +{0x3c,0x80a06000}, +{0x40,0x22800015}, +{0x44,0xc20c2314}, +{0x48,0x21000019}, +{0x4c,0x92142268}, +{0x50,0x94102018}, +{0x54,0x7ffff59d}, +{0x58,0x90142088}, +{0x5c,0x92142268}, +{0x60,0x90142028}, +{0x64,0x7ffff599}, +{0x68,0x94102018}, +{0x6c,0xda082191}, +{0x70,0x832b6002}, +{0x74,0x8200400d}, +{0x78,0x82004001}, +{0x7c,0x82200001}, +{0xf0,0x95}, +{0x00,0xc22026e4}, +{0x04,0xc02026ec}, +{0x08,0x10800073}, +{0x0c,0xc02026f0}, +{0x10,0xc20c2314}, +{0x14,0x80a06000}, +{0x18,0x22800053}, +{0x1c,0xc02026e4}, +{0x20,0xc20c234c}, +{0x24,0xc227bfec}, +{0x28,0xc20c230c}, +{0x2c,0xc227bff0}, +{0x30,0xda0c2314}, +{0x34,0xc20026e4}, +{0x38,0x80a0400d}, +{0x3c,0x06800066}, +{0x40,0x1b0000c0}, +{0x44,0xc2002548}, +{0x48,0x8208400d}, +{0x4c,0x80a0400d}, +{0x50,0x3280000f}, +{0x54,0xda082191}, +{0x58,0xda082169}, +{0x5c,0xc2002710}, +{0x60,0x80a0400d}, +{0x64,0x2680000a}, +{0x68,0xda082191}, +{0x6c,0xc200270c}, +{0x70,0x82006001}, +{0x74,0xda082168}, +{0x78,0x80a0400d}, +{0x7c,0x06800039}, +{0xf0,0x96}, +{0x00,0xc220270c}, +{0x04,0xc020270c}, +{0x08,0xda082191}, +{0x0c,0xc20026ec}, +{0x10,0x80a0400d}, +{0x14,0x2680000d}, +{0x18,0xd8002548}, +{0x1c,0x21000019}, +{0x20,0x92142088}, +{0x24,0x94102018}, +{0x28,0x7ffff568}, +{0x2c,0x90142268}, +{0x30,0x92142028}, +{0x34,0x90142088}, +{0x38,0x7ffff564}, +{0x3c,0x94102018}, +{0x40,0xc02026ec}, +{0x44,0xd8002548}, +{0x48,0x030000c0}, +{0x4c,0x820b0001}, +{0x50,0x1b000040}, +{0x54,0x80a0400d}, +{0x58,0x32800010}, +{0x5c,0xc2082191}, +{0x60,0xc210218e}, +{0x64,0xda002660}, +{0x68,0x80a34001}, +{0x6c,0x14800005}, +{0x70,0x03000080}, +{0x74,0x82036001}, +{0x78,0x10800005}, +{0x7c,0xc2202660}, +{0xf0,0x97}, +{0x00,0x82130001}, +{0x04,0xc2202548}, +{0x08,0xc0202660}, +{0x0c,0xc027bfec}, +{0x10,0xc027bff0}, +{0x14,0xc2082191}, +{0x18,0xda0026f0}, +{0x1c,0x80a34001}, +{0x20,0x0680000f}, +{0x24,0x82036001}, +{0x28,0xa0102000}, +{0x2c,0xe027bfe8}, +{0x30,0x7ffff724}, +{0x34,0x9007bfe8}, +{0x38,0xa0042001}, +{0x3c,0x80a4202f}, +{0x40,0x24bffffc}, +{0x44,0xe027bfe8}, +{0x48,0xc20026ec}, +{0x4c,0x82006001}, +{0x50,0xc22026ec}, +{0x54,0x10800020}, +{0x58,0xc02026e4}, +{0x5c,0xc22026f0}, +{0x60,0xc02026e4}, +{0x64,0x1080001c}, +{0x68,0xc02026ec}, +{0x6c,0xc2002548}, +{0x70,0x80886040}, +{0x74,0x12800018}, +{0x78,0x01000000}, +{0x7c,0xc2002200}, +{0xf0,0x98}, +{0x00,0x80a06000}, +{0x04,0x12800014}, +{0x08,0x01000000}, +{0x0c,0xc200255c}, +{0x10,0x80a06001}, +{0x14,0x02800010}, +{0x18,0x01000000}, +{0x1c,0xc20026f8}, +{0x20,0x80a06000}, +{0x24,0x1280000c}, +{0x28,0x82102004}, +{0x2c,0xc227bfe0}, +{0x30,0xc227bfdc}, +{0x34,0xa0102000}, +{0x38,0xe027bfd8}, +{0x3c,0x7ffff701}, +{0x40,0x9007bfd8}, +{0x44,0xa0042001}, +{0x48,0x80a4202f}, +{0x4c,0x24bffffc}, +{0x50,0xe027bfd8}, +{0x54,0x81c7e008}, +{0x58,0x81e80000}, +{0x5c,0x03000017}, +{0x60,0x82106324}, +{0x64,0xc2004000}, +{0x68,0x80a06001}, +{0x6c,0x02800023}, +{0x70,0x01000000}, +{0x74,0xc2102548}, +{0x78,0x80886001}, +{0x7c,0x0280001f}, +{0xf0,0x99}, +{0x00,0x96102000}, +{0x04,0xd4002300}, +{0x08,0x80a2c00a}, +{0x0c,0x1a80001b}, +{0x10,0x992ae003}, +{0x14,0xc2002470}, +{0x18,0xda1023b6}, +{0x1c,0x9a5b4001}, +{0x20,0x833b601f}, +{0x24,0x83306019}, +{0x28,0x9a034001}, +{0x2c,0x03000019}, +{0x30,0x9b3b6007}, +{0x34,0x9a20000d}, +{0x38,0x9010632c}, +{0x3c,0x92106328}, +{0x40,0xc2030009}, +{0x44,0x80a0400d}, +{0x48,0x06800006}, +{0x4c,0x9602e001}, +{0x50,0xc2030008}, +{0x54,0x80a0400d}, +{0x58,0x16800006}, +{0x5c,0x80a2c00a}, +{0x60,0xc2002548}, +{0x64,0x82106040}, +{0x68,0xc2202548}, +{0x6c,0x80a2c00a}, +{0x70,0x0abffff4}, +{0x74,0x992ae003}, +{0x78,0x81c3e008}, +{0x7c,0x01000000}, +{0xf0,0x9a}, +{0x00,0x9de3bf98}, +{0x04,0x03000017}, +{0x08,0x82106324}, +{0x0c,0xc2004000}, +{0x10,0x80a06001}, +{0x14,0x02800066}, +{0x18,0xc0202580}, +{0x1c,0xd8002548}, +{0x20,0x83332010}, +{0x24,0x80886001}, +{0x28,0x02800061}, +{0x2c,0x01000000}, +{0x30,0xc2002204}, +{0x34,0x80a06000}, +{0x38,0x0280005d}, +{0x3c,0x83332011}, +{0x40,0x80886001}, +{0x44,0x32800005}, +{0x48,0xc2002514}, +{0x4c,0xc2002208}, +{0x50,0xc2202558}, +{0x54,0xc2002514}, +{0x58,0x80a06000}, +{0x5c,0x02800006}, +{0x60,0x1b000080}, +{0x64,0xc2002558}, +{0x68,0x80a06000}, +{0x6c,0x12800013}, +{0x70,0x80a0603b}, +{0x74,0x82136040}, +{0x78,0x820b0001}, +{0x7c,0x80a0400d}, +{0xf0,0x9b}, +{0x00,0x32800006}, +{0x04,0xc2002558}, +{0x08,0xc200255c}, +{0x0c,0x80a06000}, +{0x10,0x02800015}, +{0x14,0xc2002558}, +{0x18,0x80a06000}, +{0x1c,0x12800007}, +{0x20,0x80a0603b}, +{0x24,0x033fc200}, +{0x28,0xda00232c}, +{0x2c,0x82106074}, +{0x30,0x1080000a}, +{0x34,0xda204000}, +{0x38,0x08800004}, +{0x3c,0x80a06031}, +{0x40,0x10800005}, +{0x44,0xc2002208}, +{0x48,0x38800005}, +{0x4c,0xc2002558}, +{0x50,0x82102032}, +{0x54,0xc2202558}, +{0x58,0xc2002558}, +{0x5c,0x10800006}, +{0x60,0x82006001}, +{0x64,0x80a06000}, +{0x68,0x2280000a}, +{0x6c,0x033fc0c0}, +{0x70,0x82007fff}, +{0x74,0xc2202558}, +{0x78,0xc2002558}, +{0x7c,0x80a06000}, +{0xf0,0x9c}, +{0x00,0x02800004}, +{0x04,0x033fc0c0}, +{0x08,0x7ffff2a0}, +{0x0c,0x91e82001}, +{0x10,0x82106004}, +{0x14,0xc0204000}, +{0x18,0x7ffff29c}, +{0x1c,0x90102000}, +{0x20,0x01000000}, +{0x24,0x033fc1c0}, +{0x28,0x9a102001}, +{0x2c,0x821060d4}, +{0x30,0xda204000}, +{0x34,0x01000000}, +{0x38,0x193fc040}, +{0x3c,0x8213200c}, +{0x40,0xc0204000}, +{0x44,0x01000000}, +{0x48,0x032c8590}, +{0x4c,0xda002204}, +{0x50,0x821062c9}, +{0x54,0x80534001}, +{0x58,0x9b400000}, +{0x5c,0x9b336004}, +{0x60,0x8203400d}, +{0x64,0x8200400d}, +{0x68,0x83286003}, +{0x6c,0x8200400d}, +{0x70,0x83306004}, +{0x74,0x9a132004}, +{0x78,0xc2234000}, +{0x7c,0x01000000}, +{0xf0,0x9d}, +{0x00,0x82102003}, +{0x04,0x98132008}, +{0x08,0xc2230000}, +{0x0c,0x01000000}, +{0x10,0x01000000}, +{0x14,0x01000000}, +{0x18,0x033fc1c0}, +{0x1c,0x9a102081}, +{0x20,0x821060dc}, +{0x24,0xda204000}, +{0x28,0x01000000}, +{0x2c,0x81c7e008}, +{0x30,0x81e80000}, +{0x34,0x9de3bf98}, +{0x38,0x7ffff41d}, +{0x3c,0x01000000}, +{0x40,0xda002548}, +{0x44,0x808b6040}, +{0x48,0x3280000b}, +{0x4c,0xc2002280}, +{0x50,0xc2002704}, +{0x54,0x80a06000}, +{0x58,0x04800003}, +{0x5c,0x82007fff}, +{0x60,0xc2202704}, +{0x64,0x808b6040}, +{0x68,0x02800005}, +{0x6c,0x8333600e}, +{0x70,0xc2002280}, +{0x74,0xc2202704}, +{0x78,0x8333600e}, +{0x7c,0x80886001}, +{0xf0,0x9e}, +{0x00,0x12800056}, +{0x04,0x98102000}, +{0x08,0xc2002514}, +{0x0c,0x80a30001}, +{0x10,0x1a80000b}, +{0x14,0x033fc180}, +{0x18,0x96106004}, +{0x1c,0x832b2002}, +{0x20,0xda006720}, +{0x24,0xda20400b}, +{0x28,0x98032001}, +{0x2c,0xc2002514}, +{0x30,0x80a30001}, +{0x34,0x0abffffb}, +{0x38,0x832b2002}, +{0x3c,0xda00254c}, +{0x40,0x808b6001}, +{0x44,0x32800008}, +{0x48,0xc208254e}, +{0x4c,0xc2002514}, +{0x50,0x9a136001}, +{0x54,0x82106100}, +{0x58,0xda20254c}, +{0x5c,0xc2202514}, +{0x60,0xc208254e}, +{0x64,0x80a06000}, +{0x68,0x3280000b}, +{0x6c,0xd80023c8}, +{0x70,0xc20023c8}, +{0x74,0x83306016}, +{0x78,0x80886001}, +{0x7c,0x22800006}, +{0xf0,0x9f}, +{0x00,0xd80023c8}, +{0x04,0xc2002514}, +{0x08,0x82106200}, +{0x0c,0xc2202514}, +{0x10,0xd80023c8}, +{0x14,0x8333200c}, +{0x18,0x80886001}, +{0x1c,0x1280000f}, +{0x20,0xc2082517}, +{0x24,0x80a06000}, +{0x28,0x32800007}, +{0x2c,0xda002500}, +{0x30,0xc2002560}, +{0x34,0x80a06000}, +{0x38,0x22800008}, +{0x3c,0xc2082517}, +{0x40,0xda002500}, +{0x44,0xc2002514}, +{0x48,0x9b2b6010}, +{0x4c,0x8210400d}, +{0x50,0xc2202514}, +{0x54,0xc2082517}, +{0x58,0x80a06000}, +{0x5c,0x22800010}, +{0x60,0xc2002574}, +{0x64,0xc2002548}, +{0x68,0x80886800}, +{0x6c,0x02800005}, +{0x70,0x80a32000}, +{0x74,0xc2002514}, +{0x78,0x82106400}, +{0x7c,0xc2202514}, +{0xf0,0xa0}, +{0x00,0x36800007}, +{0x04,0xc2002574}, +{0x08,0xc2002514}, +{0x0c,0x1b000004}, +{0x10,0x8210400d}, +{0x14,0xc2202514}, +{0x18,0xc2002574}, +{0x1c,0x80a06000}, +{0x20,0x2280000c}, +{0x24,0xda002514}, +{0x28,0x82007fff}, +{0x2c,0xda082517}, +{0x30,0x80a36000}, +{0x34,0x02800006}, +{0x38,0xc2202574}, +{0x3c,0xc2002514}, +{0x40,0x1b000008}, +{0x44,0x8210400d}, +{0x48,0xc2202514}, +{0x4c,0xda002514}, +{0x50,0x033fc180}, +{0x54,0xda204000}, +{0x58,0x81c7e008}, +{0x5c,0x81e80000}, +{0x60,0x9de3bf98}, +{0x64,0xda002714}, +{0x68,0x80a36000}, +{0x6c,0x36800015}, +{0x70,0xc2002548}, +{0x74,0x193fc180}, +{0x78,0xda002208}, +{0x7c,0xd208216b}, +{0xf0,0xa1}, +{0x00,0x82102860}, +{0x04,0x96132004}, +{0x08,0xc222c000}, +{0x0c,0xc2002710}, +{0x10,0x94132008}, +{0x14,0xc2228000}, +{0x18,0x0316c020}, +{0x1c,0x82106002}, +{0x20,0xc2230000}, +{0x24,0x9a036001}, +{0x28,0x82102001}, +{0x2c,0xda202558}, +{0x30,0xd2202560}, +{0x34,0xc2202714}, +{0x38,0x10800014}, +{0x3c,0xc0202710}, +{0x40,0x8330600e}, +{0x44,0x80886001}, +{0x48,0x22800011}, +{0x4c,0xd8002548}, +{0x50,0xc2002560}, +{0x54,0x80a06000}, +{0x58,0x2280000d}, +{0x5c,0xd8002548}, +{0x60,0x80a36001}, +{0x64,0x2480000a}, +{0x68,0xd8002548}, +{0x6c,0x832b6010}, +{0x70,0x1b168020}, +{0x74,0x8210400d}, +{0x78,0x1b3fc180}, +{0x7c,0xc2234000}, +{0xf0,0xa2}, +{0x00,0xc2002208}, +{0x04,0xc2202558}, +{0x08,0xd8002548}, +{0x0c,0x8333200e}, +{0x10,0x80886001}, +{0x14,0x22800007}, +{0x18,0xc2102516}, +{0x1c,0xc2002714}, +{0x20,0x80a06000}, +{0x24,0x22800029}, +{0x28,0xda002548}, +{0x2c,0xc2102516}, +{0x30,0x80a06000}, +{0x34,0x02800006}, +{0x38,0x9b332002}, +{0x3c,0x808b2004}, +{0x40,0x02800009}, +{0x44,0x8333200e}, +{0x48,0x9b332002}, +{0x4c,0x83332003}, +{0x50,0x9a0b6001}, +{0x54,0x82086001}, +{0x58,0x80a34001}, +{0x5c,0x0280000b}, +{0x60,0x8333200e}, +{0x64,0x80886001}, +{0x68,0x32800009}, +{0x6c,0xc2002560}, +{0x70,0xc200231c}, +{0x74,0x80a06000}, +{0x78,0x22800008}, +{0x7c,0x82102014}, +{0xf0,0xa3}, +{0x00,0x10800006}, +{0x04,0x82102005}, +{0x08,0xc2002560}, +{0x0c,0x80a06000}, +{0x10,0x02800007}, +{0x14,0x82007fff}, +{0x18,0xc2202560}, +{0x1c,0x7ffff642}, +{0x20,0x90102001}, +{0x24,0x10800009}, +{0x28,0xda002548}, +{0x2c,0x7ffff63e}, +{0x30,0x90102000}, +{0x34,0x033fc180}, +{0x38,0xc0204000}, +{0x3c,0xc0202714}, +{0x40,0xc0202710}, +{0x44,0xda002548}, +{0x48,0x8203400d}, +{0x4c,0x82086008}, +{0x50,0x9a0b7ff7}, +{0x54,0x9a134001}, +{0x58,0x03000010}, +{0x5c,0x822b4001}, +{0x60,0x9b306010}, +{0x64,0x808b6001}, +{0x68,0x12800004}, +{0x6c,0xc2202548}, +{0x70,0x7ffff1a6}, +{0x74,0x91e82001}, +{0x78,0x01000000}, +{0x7c,0x81c7e008}, +{0xf0,0xa4}, +{0x00,0x81e80000}, +{0x04,0x00000000}, +{0x08,0x00000000}, +{0x0c,0x00000000}, +{0x10,0x00000000}, +{0x14,0x00000000}, +{0x18,0x00000000}, +{0x1c,0x00000000}, +{0x20,0x00000000}, +{0x24,0x00000000}, +{0x28,0x00000000}, +{0x2c,0x00000000}, +{0x30,0x00000000}, +{0x34,0x00000000}, +{0x38,0x00000000}, +{0x3c,0x00000000}, +{0x40,0x00000000}, +{0x44,0x00000000}, +{0x48,0x00000000}, +{0x4c,0x00000000}, +{0x50,0x00000000}, +{0x54,0x00000000}, +{0x58,0x00000000}, +{0x5c,0x00000000}, +{0x60,0x00000000}, +{0x64,0x00000000}, +{0x68,0x00000000}, +{0x6c,0x00000000}, +{0x70,0x00000000}, +{0x74,0x00000000}, +{0x78,0x00000000}, +{0x7c,0x00000000}, +{0xf0,0xa5}, +{0x00,0x00002133}, +{0x04,0xa5010503}, +{0x08,0xa5000044}, +{0x0c,0x00000000}, +{0x10,0x67616f79}, +{0x14,0x49444449}, +{0x18,0xc9c799e7}, +{0x1c,0xbca78a4f}, +{0x20,0xc40fc64d}, +{0x24,0x99e09a11}, +{0x28,0xcc479d60}, +{0x2c,0x99e1bc47}, +{0x30,0xa8980000}, +{0x34,0x00000000}, +{0x38,0x00000000}, +{0x3c,0x00000000}, +{0x40,0x00000000}, +{0x44,0x00000000}, +{0x48,0x00000000}, +{0x4c,0x00000000}, +{0x50,0x00000000}, +{0x54,0x00000000}, +{0x58,0x00000000}, +{0x5c,0x00000000}, +{0x60,0x00000000}, +{0x64,0x00000000}, +{0x68,0x53657020}, +{0x6c,0x31342032}, +{0x70,0x30313700}, +{0x74,0x00000000}, +{0x78,0x31343a35}, +{0x7c,0x343a3134}, +}; + + +#endif diff --git a/Ubiquitous/XiZi_IIoT/resources/Kconfig b/Ubiquitous/XiZi_IIoT/resources/Kconfig index e41b96df9..c8119869a 100644 --- a/Ubiquitous/XiZi_IIoT/resources/Kconfig +++ b/Ubiquitous/XiZi_IIoT/resources/Kconfig @@ -163,3 +163,9 @@ if BSP_USING_DAC bool "Using DAC bus drivers" default n endif + +if BSP_USING_CAMERA + config RESOURCES_CAMERA + bool "Using Camera bus drivers" + default n +endif diff --git a/Ubiquitous/XiZi_IIoT/resources/Makefile b/Ubiquitous/XiZi_IIoT/resources/Makefile index 3c10a79f9..833c982f2 100644 --- a/Ubiquitous/XiZi_IIoT/resources/Makefile +++ b/Ubiquitous/XiZi_IIoT/resources/Makefile @@ -65,4 +65,8 @@ ifeq ($(CONFIG_RESOURCES_DAC),y) SRC_DIR += dac endif +ifeq ($(CONFIG_RESOURCES_CAMERA),y) + SRC_DIR += camera +endif + include $(KERNEL_ROOT)/compiler.mk diff --git a/Ubiquitous/XiZi_IIoT/resources/camera/Makefile b/Ubiquitous/XiZi_IIoT/resources/camera/Makefile new file mode 100644 index 000000000..747de5b1b --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/resources/camera/Makefile @@ -0,0 +1,5 @@ +SRC_FILES += dev_camera.c drv_camera.c bus_camera.c + + + +include $(KERNEL_ROOT)/compiler.mk diff --git a/Ubiquitous/XiZi_IIoT/resources/camera/bus_camera.c b/Ubiquitous/XiZi_IIoT/resources/camera/bus_camera.c new file mode 100644 index 000000000..6bb77fe0d --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/resources/camera/bus_camera.c @@ -0,0 +1,123 @@ +/* +* 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 bus_camera.c +* @brief register camera bus function using bus driver framework +* @version 1.0 +* @author AIIT XUOS Lab +* @date 2021-04-24 +*/ + +#include +#include + +/*Register the CAMERA BUS*/ +int CameraBusInit(struct CameraBus *camera_bus, const char *bus_name) +{ + NULL_PARAM_CHECK(camera_bus); + NULL_PARAM_CHECK(bus_name); + + x_err_t ret = EOK; + + if (BUS_INSTALL != camera_bus->bus.bus_state) { + strncpy(camera_bus->bus.bus_name, bus_name, NAME_NUM_MAX); + + camera_bus->bus.bus_type = TYPE_CAMERA_BUS; + camera_bus->bus.bus_state = BUS_INSTALL; + camera_bus->bus.private_data = camera_bus->private_data; + + ret = BusRegister(&camera_bus->bus); + if (EOK != ret) { + KPrintf("CameraBusInit BusRegister error %u\n", ret); + return ret; + } + } else { + KPrintf("CameraBusInit BusRegister bus has been register state%u\n", camera_bus->bus.bus_state); + } + + return ret; +} + +/*Register the CAMERA Driver*/ +int CameraDriverInit(struct CameraDriver *camera_driver, const char *driver_name) +{ + NULL_PARAM_CHECK(camera_driver); + NULL_PARAM_CHECK(driver_name); + + x_err_t ret = EOK; + + if (DRV_INSTALL != camera_driver->driver.driver_state) { + camera_driver->driver.driver_type = TYPE_CAMERA_DRV; + camera_driver->driver.driver_state = DRV_INSTALL; + + strncpy(camera_driver->driver.drv_name, driver_name, NAME_NUM_MAX); + + camera_driver->driver.private_data = camera_driver->private_data; + + camera_driver->driver.configure = camera_driver->configure; + + ret = CameraDriverRegister(&camera_driver->driver); + if (EOK != ret) { + KPrintf("CameraDriverInit DriverRegister error %u\n", ret); + return ret; + } + } else { + KPrintf("CameraDriverInit DriverRegister driver has been register state%u\n", camera_driver->driver.driver_state); + } + + return ret; +} + +/*Release the CAMERA device*/ +int CameraReleaseBus(struct CameraBus *camera_bus) +{ + NULL_PARAM_CHECK(camera_bus); + + return BusRelease(&camera_bus->bus); +} + +/*Register the CAMERA Driver to the CAMERA BUS*/ +int CameraDriverAttachToBus(const char *drv_name, const char *bus_name) +{ + NULL_PARAM_CHECK(drv_name); + NULL_PARAM_CHECK(bus_name); + + x_err_t ret = EOK; + + struct Bus *bus; + struct Driver *driver; + + bus = BusFind(bus_name); + if (NONE == bus) { + KPrintf("CameraDriverAttachToBus find camera bus error!name %s\n", bus_name); + return ERROR; + } + + if (TYPE_CAMERA_BUS == bus->bus_type) { + driver = CameraDriverFind(drv_name, TYPE_CAMERA_DRV); + if (NONE == driver) { + KPrintf("CameraDriverAttachToBus find camera driver error!name %s\n", drv_name); + return ERROR; + } + + if (TYPE_CAMERA_DRV == driver->driver_type) { + ret = DriverRegisterToBus(bus, driver); + if (EOK != ret) { + KPrintf("CameraDriverAttachToBus DriverRegisterToBus error %u\n", ret); + return ERROR; + } + } + } + + return ret; +} diff --git a/Ubiquitous/XiZi_IIoT/resources/camera/dev_camera.c b/Ubiquitous/XiZi_IIoT/resources/camera/dev_camera.c new file mode 100644 index 000000000..3ada2191c --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/resources/camera/dev_camera.c @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2006-2018, RT-Thread Development Team + * + * SPDX-License-Identifier: Apache-2.0 + * + * Change Logs: + * Date Author Notes + * 2006-03-13 bernard first version + * 2012-05-15 lgnq modified according bernard's implementation. + * 2012-05-28 bernard code cleanup + * 2012-11-23 bernard fix compiler warning. + * 2013-02-20 bernard use RT_CAMERA_RB_BUFSZ to define + * the size of ring buffer. + * 2014-07-10 bernard rewrite camera framework + * 2014-12-31 bernard use open_flag for poll_tx stream mode. + * 2015-05-19 Quintin fix DMA tx mod tx_dma->activated flag !=RT_FALSE BUG + * in open function. + * 2015-11-10 bernard fix the poll rx issue when there is no data. + * 2016-05-10 armink add fifo mode to DMA rx when camera->config.bufsz != 0. + * 2017-01-19 aubr.cool prevent change camera rx bufsz when camera is opened. + * 2017-11-07 JasonJia fix data bits error issue when using tcsetattr. + * 2017-11-15 JasonJia fix poll rx issue when data is full. + * add TCFLSH and FIONREAD support. + * 2018-12-08 Ernest Chen add DMA choice + * 2020-09-14 WillianChan add a line feed to the carriage return character + * when using interrupt tx + */ + +/** +* @file dev_camera.c +* @brief register camera dev function using bus driver framework +* @version 1.0 +* @author AIIT XUOS Lab +* @date 2021-04-24 +*/ + +/************************************************* +File name: dev_camera.c +Description: support camera dev INT and DMA configure、transfer data +Others: take RT-Thread v4.0.2/components/driver/camera/camera.c for references + https://github.com/RT-Thread/rt-thread/tree/v4.0.2 +History: +1. Date: 2021-04-24 +Author: AIIT XUOS Lab +Modification: +1. support camera dev register, configure, write and read +2. add bus driver framework support, include INT and DMA mode +*************************************************/ + +#include +#include + +static DoubleLinklistType cameradev_linklist; + +static uint32 CameraDevOpen(void *dev) +{ + NULL_PARAM_CHECK(dev); + + x_err_t ret = EOK; + struct CameraHardwareDevice *camera_dev = (struct CameraHardwareDevice *)dev; + + ret = camera_dev->camera_dev_done->dev_open(dev); + + return EOK; +} + +static uint32 CameraDevClose(void *dev) +{ + NULL_PARAM_CHECK(dev); + + x_err_t ret = EOK; + struct CameraHardwareDevice *camera_dev = (struct CameraHardwareDevice *)dev; + + ret = camera_dev->camera_dev_done->dev_close(dev); + return EOK; +} + +static uint32 CameraDevWrite(void *dev, struct BusBlockWriteParam *write_param) +{ + NULL_PARAM_CHECK(dev); + NULL_PARAM_CHECK(write_param); + + x_err_t ret = EOK; + + struct CameraHardwareDevice *camera_dev = (struct CameraHardwareDevice *)dev; + ret = camera_dev->camera_dev_done->dev_write(dev,write_param); + + return ret; +} + +static uint32 CameraDevRead(void *dev, struct BusBlockReadParam *read_param) +{ + NULL_PARAM_CHECK(dev); + NULL_PARAM_CHECK(read_param); + + x_err_t ret = EOK; + + struct CameraHardwareDevice *camera_dev = (struct CameraHardwareDevice *)dev; + ret = camera_dev->camera_dev_done->dev_read(dev,read_param); + + return EOK; +} + + +static const struct HalDevDone dev_done = +{ + .open = CameraDevOpen, + .close = CameraDevClose, + .write = CameraDevWrite, + .read = CameraDevRead, +}; + +/*Create the camera device linklist*/ +static void CameraDeviceLinkInit() +{ + InitDoubleLinkList(&cameradev_linklist); +} + +HardwareDevType CameraDeviceFind(const char *dev_name, enum DevType dev_type) +{ + NULL_PARAM_CHECK(dev_name); + + struct HardwareDev *device = NONE; + + DoubleLinklistType *node = NONE; + DoubleLinklistType *head = &cameradev_linklist; + + for (node = head->node_next; node != head; node = node->node_next) { + device = SYS_DOUBLE_LINKLIST_ENTRY(node, struct HardwareDev, dev_link); + if ((!strcmp(device->dev_name, dev_name)) && (dev_type == device->dev_type)) { + return device; + } + } + + KPrintf("CameraDeviceFind cannot find the %s device.return NULL\n", dev_name); + return NONE; +} + +int CameraDeviceRegister(struct CameraHardwareDevice *camera_device, void *camera_param, const char *device_name) +{ + NULL_PARAM_CHECK(camera_device); + NULL_PARAM_CHECK(device_name); + + x_err_t ret = EOK; + static x_bool dev_link_flag = RET_FALSE; + + if (!dev_link_flag) { + CameraDeviceLinkInit(); + dev_link_flag = RET_TRUE; + } + + if (DEV_INSTALL != camera_device->haldev.dev_state) { + strncpy(camera_device->haldev.dev_name, device_name, NAME_NUM_MAX); + camera_device->haldev.dev_type = TYPE_CAMERA_DEV; + camera_device->haldev.dev_state = DEV_INSTALL; + camera_device->haldev.dev_done = (struct HalDevDone *)&dev_done; + + + DoubleLinkListInsertNodeAfter(&cameradev_linklist, &(camera_device->haldev.dev_link)); + } else { + KPrintf("CameraDeviceRegister device has been register state%u\n", camera_device->haldev.dev_state); + } + + return ret; +} + +int CameraDeviceAttachToBus(const char *dev_name, const char *bus_name) +{ + NULL_PARAM_CHECK(dev_name); + NULL_PARAM_CHECK(bus_name); + + x_err_t ret = EOK; + + struct Bus *bus; + struct HardwareDev *device; + + bus = BusFind(bus_name); + if (NONE == bus) { + KPrintf("CameraDeviceAttachToBus find camera bus error!name %s\n", bus_name); + return ERROR; + } + + if (TYPE_CAMERA_BUS == bus->bus_type) { + device = CameraDeviceFind(dev_name, TYPE_CAMERA_DEV); + if (NONE == device) { + KPrintf("CameraDeviceAttachToBus find camera device error!name %s\n", dev_name); + return ERROR; + } + + if (TYPE_CAMERA_DEV == device->dev_type) { + ret = DeviceRegisterToBus(bus, device); + if (EOK != ret) { + KPrintf("CameraDeviceAttachToBus DeviceRegisterToBus error %u\n", ret); + return ERROR; + } + } + } + + return EOK; +} diff --git a/Ubiquitous/XiZi_IIoT/resources/camera/drv_camera.c b/Ubiquitous/XiZi_IIoT/resources/camera/drv_camera.c new file mode 100644 index 000000000..258c373a4 --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/resources/camera/drv_camera.c @@ -0,0 +1,68 @@ +/* +* 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 drv_camera.c +* @brief register camera drv function using bus driver framework +* @version 1.0 +* @author AIIT XUOS Lab +* @date 2021-04-24 +*/ + +#include +#include + +static DoubleLinklistType camera_drv_linklist; + +/*Create the driver linklist*/ +static void CameraDrvLinkInit() +{ + InitDoubleLinkList(&camera_drv_linklist); +} + +DriverType CameraDriverFind(const char *drv_name, enum DriverType_e drv_type) +{ + NULL_PARAM_CHECK(drv_name); + + struct Driver *driver = NONE; + + DoubleLinklistType *node = NONE; + DoubleLinklistType *head = &camera_drv_linklist; + + for (node = head->node_next; node != head; node = node->node_next) { + driver = SYS_DOUBLE_LINKLIST_ENTRY(node, struct Driver, driver_link); + + if ((!strcmp(driver->drv_name, drv_name)) && (drv_type == driver->driver_type)) { + return driver; + } + } + + KPrintf("CameraDriverFind cannot find the %s driver.return NULL\n", drv_name); + return NONE; +} + +int CameraDriverRegister(struct Driver *driver) +{ + NULL_PARAM_CHECK(driver); + + x_err_t ret = EOK; + static x_bool driver_link_flag = RET_FALSE; + + if (!driver_link_flag) { + CameraDrvLinkInit(); + driver_link_flag = RET_TRUE; + } + + DoubleLinkListInsertNodeAfter(&camera_drv_linklist, &(driver->driver_link)); + + return ret; +} diff --git a/Ubiquitous/XiZi_IIoT/resources/include/bus.h b/Ubiquitous/XiZi_IIoT/resources/include/bus.h index b9d0f4ad7..c0f65c4a7 100644 --- a/Ubiquitous/XiZi_IIoT/resources/include/bus.h +++ b/Ubiquitous/XiZi_IIoT/resources/include/bus.h @@ -54,6 +54,7 @@ enum BusType_e TYPE_SERIAL_BUS, TYPE_ADC_BUS, TYPE_DAC_BUS, + TYPE_CAMERA_BUS, TYPE_BUS_END, }; @@ -80,6 +81,7 @@ enum DevType TYPE_SERIAL_DEV, TYPE_ADC_DEV, TYPE_DAC_DEV, + TYPE_CAMERA_DEV, TYPE_DEV_END, }; @@ -106,6 +108,7 @@ enum DriverType_e TYPE_SERIAL_DRV, TYPE_ADC_DRV, TYPE_DAC_DRV, + TYPE_CAMERA_DRV, TYPE_DRV_END, }; diff --git a/Ubiquitous/XiZi_IIoT/resources/include/bus_camera.h b/Ubiquitous/XiZi_IIoT/resources/include/bus_camera.h new file mode 100644 index 000000000..8ea27c57b --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/resources/include/bus_camera.h @@ -0,0 +1,69 @@ +/* +* 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 bus_camera.h +* @brief define camera bus and drv function using bus driver framework +* @version 1.0 +* @author AIIT XUOS Lab +* @date 2021-11-16 +*/ + +#ifndef BUS_CAMERA_H +#define BUS_CAMERA_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +struct CameraDriver +{ + struct Driver driver; + + uint32 (*configure) (void *drv, struct BusConfigureInfo *configure_info); + + void *private_data; +}; + +struct CameraBus +{ + struct Bus bus; + + void *private_data; +}; + +/*Register the CAMERA bus*/ +int CameraBusInit(struct CameraBus *camera_bus, const char *bus_name); + +/*Register the CAMERA driver*/ +int CameraDriverInit(struct CameraDriver *camera_driver, const char *driver_name); + +/*Release the CAMERA device*/ +int CameraReleaseBus(struct CameraBus *camera_bus); + +/*Register the CAMERA driver to the CAMERA bus*/ +int CameraDriverAttachToBus(const char *drv_name, const char *bus_name); + +/*Register the driver, manage with the double linklist*/ +int CameraDriverRegister(struct Driver *driver); + +/*Find the register driver*/ +DriverType CameraDriverFind(const char *drv_name, enum DriverType_e drv_type); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/Ubiquitous/XiZi_IIoT/resources/include/dev_camera.h b/Ubiquitous/XiZi_IIoT/resources/include/dev_camera.h new file mode 100644 index 000000000..f7ad095be --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/resources/include/dev_camera.h @@ -0,0 +1,69 @@ +/* +* 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 dev_camera.h +* @brief define camera dev function using bus driver framework +* @version 1.0 +* @author AIIT XUOS Lab +* @date 2021-04-24 +*/ + +#ifndef DEV_CAMERA_H +#define DEV_CAMERA_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +struct CameraDataStandard +{ + uint16 addr; + uint16 flags; + uint16 len; + uint16 retries; + uint8 *buf; + + struct CameraDataStandard *next; +}; + +struct CameraDevDone +{ + uint32 (*dev_open) (void *camera_device); + uint32 (*dev_close) (void *camera_device); + uint32 (*dev_write) (void *camera_device, struct BusBlockWriteParam *msg); + uint32 (*dev_read) (void *camera_device, struct BusBlockReadParam *msg); +}; + +struct CameraHardwareDevice +{ + struct HardwareDev haldev; + const struct CameraDevDone *camera_dev_done; +}; + +/*Register the CAMERA device*/ +int CameraDeviceRegister(struct CameraHardwareDevice *camera_device, void *camera_param, const char *device_name); + +/*Register the CAMERA device to the CAMERA bus*/ +int CameraDeviceAttachToBus(const char *dev_name, const char *bus_name); + +/*Find the register CAMERA device*/ +HardwareDevType CameraDeviceFind(const char *dev_name, enum DevType dev_type); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/Ubiquitous/XiZi_IIoT/resources/include/device.h b/Ubiquitous/XiZi_IIoT/resources/include/device.h index 5c2d49a30..9ffd644ff 100644 --- a/Ubiquitous/XiZi_IIoT/resources/include/device.h +++ b/Ubiquitous/XiZi_IIoT/resources/include/device.h @@ -104,4 +104,9 @@ HardwareDevType ObtainConsole(void); #include #endif +#ifdef RESOURCES_CAMERA +#include +#include +#endif + #endif diff --git a/Ubiquitous/XiZi_IIoT/tool/shell/letter-shell/cmd.c b/Ubiquitous/XiZi_IIoT/tool/shell/letter-shell/cmd.c index f3a4b60f0..82fd4eb6f 100644 --- a/Ubiquitous/XiZi_IIoT/tool/shell/letter-shell/cmd.c +++ b/Ubiquitous/XiZi_IIoT/tool/shell/letter-shell/cmd.c @@ -384,6 +384,7 @@ static char *const bus_type_str[] = "SERIAL_BUS", "ADC_BUS", "DAC_BUS", + "CAMERA_BUS", "Unknown" }; From 68cdcbdcce049cd26e3ff21d0ade02d0a8e3314b Mon Sep 17 00:00:00 2001 From: wuzheng Date: Mon, 21 Nov 2022 11:12:35 +0800 Subject: [PATCH 03/14] improve dvp driver by add one effective mode --- .../edu-riscv64/third_party_driver/dvp/connect_dvp.c | 1 + .../edu-riscv64/third_party_driver/dvp/ov2640.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c index fb3c02219..c78b242a6 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c @@ -138,6 +138,7 @@ static uint32 dvpDrvConfigure(void *drv, struct BusConfigureInfo *args) readDvpReg(drv, (struct DvpRegConfigureInfo *)args->private_data); break; case REG_SCCB_WRITE: + //for ov2640,write reg 0x04 to Horizontal mirror or Vertical flip writeDvpReg(drv, (struct DvpRegConfigureInfo *)args->private_data); break; default: diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/ov2640.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/ov2640.c index 867642bda..ba5dfea9b 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/ov2640.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/ov2640.c @@ -30,7 +30,7 @@ const uint8_t ov2640_config[][2]= {0x3c, 0x32}, {0x11, 0x00}, {0x09, 0x02}, - {0x04, 0x58}, + {0x04, 0x28}, {0x13, 0xe5}, {0x14, 0x48}, {0x2c, 0x0c}, @@ -218,7 +218,7 @@ const uint8_t ov2640_config[][2]= {0x3C, 0x32}, {0x11, 0x00}, {0x09, 0x02}, - {0x04, 0xA8}, + {0x04, 0x28}, {0x13, 0xE5}, {0x14, 0x48}, {0x2C, 0x0C}, @@ -387,7 +387,13 @@ const uint8_t ov2640_config[][2]= {0xE5, 0x1F}, {0xE1, 0x67}, {0xE0, 0x00}, - {0xDD, 0x7F}, + {0xDD, 0x7F}, + {0x05, 0x00}, + {0xe0, 0x04}, + {0x5a, 0x50}, + {0x5b, 0x3c}, + {0x5c, 0x00}, + {0xe0, 0x00}, {0x00, 0x00} }; #else From 7c252bda56da8a130449358a6906b088b08fdc57 Mon Sep 17 00:00:00 2001 From: wuzheng Date: Mon, 21 Nov 2022 14:29:17 +0800 Subject: [PATCH 04/14] fix touch address error --- APP_Framework/Framework/transform_layer/xizi/transform.h | 6 ++++++ .../edu-riscv64/third_party_driver/touch/connect_touch.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/APP_Framework/Framework/transform_layer/xizi/transform.h b/APP_Framework/Framework/transform_layer/xizi/transform.h index bda868988..7514d9297 100644 --- a/APP_Framework/Framework/transform_layer/xizi/transform.h +++ b/APP_Framework/Framework/transform_layer/xizi/transform.h @@ -215,6 +215,12 @@ typedef struct uint16_t press; }TouchDataParam; +struct TouchDataStandard +{ + uint16 x; + uint16 y; +}; + struct RtcDrvConfigureParam { int rtc_operation_cmd; diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c index 2f95c371e..24563c51d 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c @@ -38,7 +38,7 @@ struct Touch_event { }; #define DEFAULT_NUM 0x0D -#define TOUCH_ADDRESS 0x44 +#define TOUCH_ADDRESS 0x40 volatile bool SemReleaseFlag = 0; static struct Bus* i2c_bus = NONE; From ebc61431bd826f8b7147791828f0cee1f93f5582 Mon Sep 17 00:00:00 2001 From: wuzheng Date: Mon, 21 Nov 2022 15:59:25 +0800 Subject: [PATCH 05/14] fit touch position for lcd --- .../edu-riscv64/third_party_driver/include/connect_touch.h | 4 ++++ .../edu-riscv64/third_party_driver/touch/connect_touch.c | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h index 30ed6008d..0bf7ee7ae 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h @@ -64,6 +64,10 @@ typedef enum _touch_event #define GTP_REG_CONFIG_DATA 0x8047 #define GTP_REG_VERSION 0x8140 +#define LCD_SIZE 320 +#define TOUCH_WIDTH 1024 +#define TOUCH_HEIGHT 664 + #define CFG_GROUP_LEN(p_cfg_grp) (sizeof(p_cfg_grp) / sizeof(p_cfg_grp[0])) int HwTouchInit(void); diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c index 24563c51d..aed2bd8c3 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c @@ -278,7 +278,7 @@ static uint32 TouchRead(void* dev, struct BusBlockReadParam* read_param) struct TouchDataStandard* data = (struct TouchDataStandard*)read_param->buffer; read_param->read_length = 0; - result = KSemaphoreObtain(touch_sem, 1000); + result = KSemaphoreObtain(touch_sem, 10); // if (EOK == result) // { memset(TOUCHRECDATA, 0, 24); @@ -292,8 +292,10 @@ static uint32 TouchRead(void* dev, struct BusBlockReadParam* read_param) { ts_event.fingers[i].x = ((((uint32_t)TOUCHRECDATA[(i * 4) + 5]) << 8) | (uint32_t)TOUCHRECDATA[(i * 4) + 4]) & 0x00000FFF; // 12 bits of X coord ts_event.fingers[i].y = ((((uint32_t)TOUCHRECDATA[(i * 4) + 7]) << 8) | (uint32_t)TOUCHRECDATA[(i * 4) + 6]) & 0x00000FFF; + ts_event.fingers[i].x = 320 - ts_event.fingers[i].x *LCD_SIZE/TOUCH_WIDTH; + ts_event.fingers[i].y = ts_event.fingers[i].y *LCD_SIZE/TOUCH_HEIGHT; ts_event.fingers[i].fingerID = (uint32_t)TOUCHRECDATA[(i * 4) + 7] >> 4; // finger that did the touch - printf("fingers[%d] x %d y %d id %d\n",i,ts_event.fingers[i].x,ts_event.fingers[i].y,ts_event.fingers[i].fingerID); + // printf("fingers[%d] x %d y %d id %d\n",i,ts_event.fingers[i].x,ts_event.fingers[i].y,ts_event.fingers[i].fingerID); } data->x = ts_event.fingers[ts_event.NBfingers - 1].x; From 987fd6c7980eccd783a46213bbc69ddaa488e6a3 Mon Sep 17 00:00:00 2001 From: wuzheng Date: Mon, 21 Nov 2022 16:46:46 +0800 Subject: [PATCH 06/14] fit touch postion for lvgl --- .../lvgl/examples/porting/lv_port_indev_template.c | 2 +- APP_Framework/lib/lvgl/lvgl.mk | 1 + .../lib/lvgl/porting/lv_port_indev_template.c | 2 +- .../third_party_driver/include/connect_touch.h | 4 ++-- .../third_party_driver/touch/connect_touch.c | 11 ++++++----- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/APP_Framework/lib/lvgl/examples/porting/lv_port_indev_template.c b/APP_Framework/lib/lvgl/examples/porting/lv_port_indev_template.c index 053ba4d22..b2cae0498 100644 --- a/APP_Framework/lib/lvgl/examples/porting/lv_port_indev_template.c +++ b/APP_Framework/lib/lvgl/examples/porting/lv_port_indev_template.c @@ -268,7 +268,7 @@ static bool touchpad_is_pressed(void) ret = PrivRead(touch_fd, &touch_data, 1); if(ret && touch_data.x >= 0 && touch_data.x < MY_INDEV_X && touch_data.y >= 0 && touch_data.y < MY_INDEV_Y) { - // printf("touch x %d touch y %d\n",touch_data.x,touch_data.y); + printf("touch x %d touch y %d\n",touch_data.x,touch_data.y); return true; } diff --git a/APP_Framework/lib/lvgl/lvgl.mk b/APP_Framework/lib/lvgl/lvgl.mk index 2dd1245c3..d7ae3ff22 100644 --- a/APP_Framework/lib/lvgl/lvgl.mk +++ b/APP_Framework/lib/lvgl/lvgl.mk @@ -1,5 +1,6 @@ include $(LVGL_DIR)/$(LVGL_DIR_NAME)/examples/examples.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/extra/extra.mk + include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/core/lv_core.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/draw/lv_draw.mk include $(LVGL_DIR)/$(LVGL_DIR_NAME)/src/font/lv_font.mk diff --git a/APP_Framework/lib/lvgl/porting/lv_port_indev_template.c b/APP_Framework/lib/lvgl/porting/lv_port_indev_template.c index 72652530f..0a3321fed 100644 --- a/APP_Framework/lib/lvgl/porting/lv_port_indev_template.c +++ b/APP_Framework/lib/lvgl/porting/lv_port_indev_template.c @@ -292,7 +292,7 @@ static bool touchpad_is_pressed(struct TouchDataStandard* touch_data_ptr) press_failed_cnt = 0; return true; } - + printf("lv_touch:%d,%d\n",touch_data_ptr->x,touch_data_ptr->y); press_failed_cnt++; if (press_failed_cnt >= PRESS_FAILED_LIMIT) { PrivClose(touch_fd); diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h index 0bf7ee7ae..fcfc71358 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h @@ -65,8 +65,8 @@ typedef enum _touch_event #define GTP_REG_VERSION 0x8140 #define LCD_SIZE 320 -#define TOUCH_WIDTH 1024 -#define TOUCH_HEIGHT 664 +#define TOUCH_WIDTH 1080 +#define TOUCH_HEIGHT 720 #define CFG_GROUP_LEN(p_cfg_grp) (sizeof(p_cfg_grp) / sizeof(p_cfg_grp[0])) diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c index aed2bd8c3..d05d9372b 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c @@ -77,7 +77,7 @@ static x_err_t ReadRegs(struct HardwareDev* dev, uint8 len, uint8* buf) // not used in polling mode static void touch_pin_irqhandler(void* arg) { - // KPrintf("int hdr working.\n"); + KPrintf("int hdr working.\n"); if (!SemReleaseFlag) { KSemaphoreAbandon(touch_sem); @@ -277,7 +277,7 @@ static uint32 TouchRead(void* dev, struct BusBlockReadParam* read_param) char status_reg = 0x80; struct TouchDataStandard* data = (struct TouchDataStandard*)read_param->buffer; - read_param->read_length = 0; + result = KSemaphoreObtain(touch_sem, 10); // if (EOK == result) // { @@ -292,15 +292,16 @@ static uint32 TouchRead(void* dev, struct BusBlockReadParam* read_param) { ts_event.fingers[i].x = ((((uint32_t)TOUCHRECDATA[(i * 4) + 5]) << 8) | (uint32_t)TOUCHRECDATA[(i * 4) + 4]) & 0x00000FFF; // 12 bits of X coord ts_event.fingers[i].y = ((((uint32_t)TOUCHRECDATA[(i * 4) + 7]) << 8) | (uint32_t)TOUCHRECDATA[(i * 4) + 6]) & 0x00000FFF; - ts_event.fingers[i].x = 320 - ts_event.fingers[i].x *LCD_SIZE/TOUCH_WIDTH; - ts_event.fingers[i].y = ts_event.fingers[i].y *LCD_SIZE/TOUCH_HEIGHT; + uint32_t pos_y = 308 - ts_event.fingers[i].x *LCD_SIZE/TOUCH_WIDTH; + ts_event.fingers[i].x = ts_event.fingers[i].y *LCD_SIZE/TOUCH_HEIGHT; + ts_event.fingers[i].y = pos_y; ts_event.fingers[i].fingerID = (uint32_t)TOUCHRECDATA[(i * 4) + 7] >> 4; // finger that did the touch // printf("fingers[%d] x %d y %d id %d\n",i,ts_event.fingers[i].x,ts_event.fingers[i].y,ts_event.fingers[i].fingerID); } data->x = ts_event.fingers[ts_event.NBfingers - 1].x; data->y = ts_event.fingers[ts_event.NBfingers - 1].y; - + read_param->read_length = ts_event.NBfingers; SemReleaseFlag = 0; // } From 5560fc5318983968739b58c710381d092758c869 Mon Sep 17 00:00:00 2001 From: Liu_Weichao Date: Mon, 21 Nov 2022 17:20:44 +0800 Subject: [PATCH 07/14] feat add control_framework, support fins protocol, compile OK --- APP_Framework/Applications/Makefile | 4 +- .../Applications/general_functions/Makefile | 2 +- .../general_functions/circular_area/Makefile | 11 + .../circular_area/SConscript | 11 + .../circular_area/circular_area_app.c | 281 +++++++++++++ .../circular_area/circular_area_app.h | 100 +++++ APP_Framework/Framework/Makefile | 1 + APP_Framework/Framework/connection/adapter.c | 5 +- APP_Framework/Framework/control/Kconfig | 24 +- APP_Framework/Framework/control/Makefile | 10 +- .../Framework/control/ipc_protocol/Kconfig | 6 + .../Framework/control/ipc_protocol/Makefile | 8 +- .../plc/interoperability/socket/plc_socket.c | 365 ----------------- .../Framework/control/plc_protocol/Kconfig | 13 + .../Framework/control/plc_protocol/Makefile | 17 +- .../control/plc_protocol/fins/Makefile | 2 +- .../control/plc_protocol/fins/fins.c | 368 ++++++++++++++++++ .../plc_protocol/fins/test_recipe_fins.json | 331 ++++++++++++++++ .../control/plc_protocol/include/fins.h | 86 ++++ .../include/melsec.h} | 10 +- .../include/opcua.h} | 15 +- .../control/plc_protocol/include/s7.h | 19 + .../Framework/control/shared/Makefile | 6 +- .../Framework/control/shared/config.json | 38 -- .../Framework/control/shared/control.c | 229 ++++++++++- .../Framework/control/shared/control.h | 96 ++++- .../Framework/control/shared/control_def.c | 364 +++++++++++++++++ .../Framework/control/shared/control_def.h | 161 ++++++++ .../framework_init.c | 9 + .../xidatong-arm32/third_party_driver/Kconfig | 2 + Ubiquitous/XiZi_IIoT/path_kernel.mk | 3 + 31 files changed, 2152 insertions(+), 445 deletions(-) create mode 100644 APP_Framework/Applications/general_functions/circular_area/Makefile create mode 100644 APP_Framework/Applications/general_functions/circular_area/SConscript create mode 100644 APP_Framework/Applications/general_functions/circular_area/circular_area_app.c create mode 100644 APP_Framework/Applications/general_functions/circular_area/circular_area_app.h delete mode 100755 APP_Framework/Framework/control/plc/interoperability/socket/plc_socket.c create mode 100644 APP_Framework/Framework/control/plc_protocol/fins/fins.c create mode 100644 APP_Framework/Framework/control/plc_protocol/fins/test_recipe_fins.json create mode 100644 APP_Framework/Framework/control/plc_protocol/include/fins.h rename APP_Framework/Framework/control/{shared/control_file.c => plc_protocol/include/melsec.h} (85%) mode change 100755 => 100644 rename APP_Framework/Framework/control/{shared/control_file.h => plc_protocol/include/opcua.h} (78%) mode change 100755 => 100644 create mode 100644 APP_Framework/Framework/control/plc_protocol/include/s7.h delete mode 100755 APP_Framework/Framework/control/shared/config.json create mode 100644 APP_Framework/Framework/control/shared/control_def.c create mode 100644 APP_Framework/Framework/control/shared/control_def.h rename APP_Framework/{Applications => Framework}/framework_init.c (96%) diff --git a/APP_Framework/Applications/Makefile b/APP_Framework/Applications/Makefile index 8c92833cd..118c80ac5 100644 --- a/APP_Framework/Applications/Makefile +++ b/APP_Framework/Applications/Makefile @@ -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,7 +10,7 @@ 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 endif diff --git a/APP_Framework/Applications/general_functions/Makefile b/APP_Framework/Applications/general_functions/Makefile index 57265e81c..564fc2a05 100644 --- a/APP_Framework/Applications/general_functions/Makefile +++ b/APP_Framework/Applications/general_functions/Makefile @@ -1,3 +1,3 @@ -SRC_DIR := list +SRC_DIR := list circular_area include $(KERNEL_ROOT)/compiler.mk \ No newline at end of file diff --git a/APP_Framework/Applications/general_functions/circular_area/Makefile b/APP_Framework/Applications/general_functions/circular_area/Makefile new file mode 100644 index 000000000..30616891b --- /dev/null +++ b/APP_Framework/Applications/general_functions/circular_area/Makefile @@ -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 \ No newline at end of file diff --git a/APP_Framework/Applications/general_functions/circular_area/SConscript b/APP_Framework/Applications/general_functions/circular_area/SConscript new file mode 100644 index 000000000..0268174f0 --- /dev/null +++ b/APP_Framework/Applications/general_functions/circular_area/SConscript @@ -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") \ No newline at end of file diff --git a/APP_Framework/Applications/general_functions/circular_area/circular_area_app.c b/APP_Framework/Applications/general_functions/circular_area/circular_area_app.c new file mode 100644 index 000000000..25e81c39c --- /dev/null +++ b/APP_Framework/Applications/general_functions/circular_area/circular_area_app.c @@ -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); + CHECK(data_length > 0); + + if(CircularAreaAppIsEmpty(circular_area)) { + return -1; + } + + uint32_t 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); + 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) +{ + 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; +} diff --git a/APP_Framework/Applications/general_functions/circular_area/circular_area_app.h b/APP_Framework/Applications/general_functions/circular_area/circular_area_app.h new file mode 100644 index 000000000..7533248d3 --- /dev/null +++ b/APP_Framework/Applications/general_functions/circular_area/circular_area_app.h @@ -0,0 +1,100 @@ +/* +* 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 +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CA_PARAM_CHECK(param) \ + do \ + { \ + if(param == NULL) { \ + KPrintf("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 diff --git a/APP_Framework/Framework/Makefile b/APP_Framework/Framework/Makefile index d9e3e101e..10b9168ba 100644 --- a/APP_Framework/Framework/Makefile +++ b/APP_Framework/Framework/Makefile @@ -1,3 +1,4 @@ +SRC_FILES := framework_init.c SRC_DIR := transform_layer ifeq ($(CONFIG_SUPPORT_SENSOR_FRAMEWORK),y) diff --git a/APP_Framework/Framework/connection/adapter.c b/APP_Framework/Framework/connection/adapter.c index eb1356c14..3ac510f84 100644 --- a/APP_Framework/Framework/connection/adapter.c +++ b/APP_Framework/Framework/connection/adapter.c @@ -21,11 +21,8 @@ #include static DoublelistType adapter_list; -#ifdef ADD_XIZI_FETURES -static int adapter_list_lock; -#else static pthread_mutex_t adapter_list_lock; -#endif + /** * @description: Init adapter framework * @return 0 diff --git a/APP_Framework/Framework/control/Kconfig b/APP_Framework/Framework/control/Kconfig index 8c7e89ac4..e9e0a1753 100755 --- a/APP_Framework/Framework/control/Kconfig +++ b/APP_Framework/Framework/control/Kconfig @@ -2,8 +2,28 @@ menuconfig SUPPORT_CONTROL_FRAMEWORK bool "support control framework" default n select TRANSFORM_LAYER_ATTRIUBUTE + select BSP_USING_LWIP + select BSP_USING_SDIO + select MOUNT_SDCARD_FS + select LIB_USING_CJSON if SUPPORT_CONTROL_FRAMEWORK - source "$APP_DIR/Framework/control/ipc_protocol/Kconfig" - source "$APP_DIR/Framework/control/plc_protocol/Kconfig" + config CONTROL_RECIPE_FILE + string "control framework recipe file name" + default "test_recipe.json" + + menuconfig CONTROL_IPC_PROTOCOL + bool "Using ipc protocol" + default n + if CONTROL_IPC_PROTOCOL + source "$APP_DIR/Framework/control/ipc_protocol/Kconfig" + endif + + menuconfig CONTROL_PLC_PROTOCOL + bool "Using plc protocol" + default n + if CONTROL_PLC_PROTOCOL + source "$APP_DIR/Framework/control/plc_protocol/Kconfig" + endif + endif diff --git a/APP_Framework/Framework/control/Makefile b/APP_Framework/Framework/control/Makefile index b2fb7da93..3db840df4 100755 --- a/APP_Framework/Framework/control/Makefile +++ b/APP_Framework/Framework/control/Makefile @@ -1,3 +1,11 @@ -SRC_DIR := ipc_protocol plc_protocol shared +SRC_DIR := shared + +ifeq ($(CONFIG_CONTROL_IPC_PROTOCOL), y) + SRC_DIR += ipc_protocol +endif + +ifeq ($(CONFIG_CONTROL_PLC_PROTOCOL), y) + SRC_DIR += plc_protocol +endif include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/control/ipc_protocol/Kconfig b/APP_Framework/Framework/control/ipc_protocol/Kconfig index 139597f9c..bc72c4672 100755 --- a/APP_Framework/Framework/control/ipc_protocol/Kconfig +++ b/APP_Framework/Framework/control/ipc_protocol/Kconfig @@ -1,2 +1,8 @@ +config CONTROL_PROTOCOL_MODBUS_TCP + bool "Using modbus_tcp control protocol" + default n +config CONTROL_PROTOCOL_MODBUS_UART + bool "Using modbus_uart control protocol" + default n diff --git a/APP_Framework/Framework/control/ipc_protocol/Makefile b/APP_Framework/Framework/control/ipc_protocol/Makefile index 4c33eaf37..a22240e9a 100755 --- a/APP_Framework/Framework/control/ipc_protocol/Makefile +++ b/APP_Framework/Framework/control/ipc_protocol/Makefile @@ -1,4 +1,10 @@ -SRC_DIR := modbus_tcp modbus_uart +ifeq ($(CONFIG_CONTROL_PROTOCOL_MODBUS_TCP), y) + SRC_DIR := modbus_tcp +endif + +ifeq ($(CONFIG_CONTROL_PROTOCOL_MODBUS_UART), y) + SRC_DIR := modbus_uart +endif include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/control/plc/interoperability/socket/plc_socket.c b/APP_Framework/Framework/control/plc/interoperability/socket/plc_socket.c deleted file mode 100755 index 5c0dc8867..000000000 --- a/APP_Framework/Framework/control/plc/interoperability/socket/plc_socket.c +++ /dev/null @@ -1,365 +0,0 @@ -/* - * 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 plc_socket.c - * @brief Demo for PLC socket communication function - * @version 1.0 - * @author AIIT XUOS Lab - * @date 2022.03.16 - */ - -#include "transform.h" -#include "plc_socket.h" -#include "sys_arch.h" -#include "lwip/sockets.h" -#include "control_file.h" - -// max support plc socket test commands number -#define PLC_SOCK_CMD_NUM CTL_CMD_NUM -#define PLC_SOCK_TIMEOUT 50000 - -// for saving PLC command index -int plc_cmd_index = 0; - -// only for test -#define SUPPORT_PLC_SIEMENS - -//siemens test -PlcBinCmdType TestPlcCmd[PLC_SOCK_CMD_NUM] = {0}; - -//Test information -//SIEMENS ip: 192.168.250.9 port: 102 -//S7-200 ip: 192.168.250.8 port: 102 -//S7-1200 ip: 192.168.250.6 port: 102 -//OML ip: 192.168.250.3 port: 9600 - -PlcSocketParamType plc_socket_demo_data = { -#ifdef SUPPORT_PLC_SIEMENS - .ip = {192, 168, 250, 6}, - .port = 102, - .device_type = PLC_DEV_TYPE_SIEMENS, - .socket_type = SOCK_STREAM, - .cmd_num = 3, -#else - .ip = {192, 168, 250, 3}, - .port = 9600, - .device_type = PLC_DEV_TYPE_OML, - .socket_type = SOCK_DGRAM, - .cmd_num = 1, -#endif - .recv_len = PLC_RECV_BUF_LEN, - .recv_buf = NULL, -}; - -#define OML_HEADER_LEN 78 -#define CHECK_OML_HEADER(_s) ((0xC0 == *(_s)) && (0x00 == *(_s + 1)) && (0x02 == *(_s + 2)) && (0x00 == *(_s + 3))) - -/******************************************************************************/ - -static void plc_print_array(char *title, int size, uint8_t *cmd) -{ - lw_notice("%s : %d - ", title, size); - for(int i = 0; i < size; i++) - { - lw_notice(" %#x", cmd[i]); - } - lw_notice("\n"); -} - -static void *PlcSocketStart(void *arg) -{ - int fd = -1; - int timeout, recv_len; - struct sockaddr_in sock_addr; - socklen_t addr_len = sizeof(struct sockaddr_in); - PlcSocketParamType *param = (PlcSocketParamType *)&plc_socket_demo_data; - - plc_print("start %d.%d.%d.%d:%d dev %d sock %d\n", - param->ip[0], - param->ip[1], - param->ip[2], - param->ip[3], - param->port, - param->device_type, - param->socket_type); - - param->recv_len = PLC_RECV_BUF_LEN; - - //malloc memory - param->recv_buf = (char *)malloc(param->recv_len); - if (param->recv_buf == NULL) - { - plc_error("No memory\n"); - return NULL; - } - - fd = socket(AF_INET, param->socket_type, 0); - if (fd < 0) - { - plc_error("Socket error %d\n", param->socket_type); - free(param->recv_buf); - return NULL; - } - - plc_print("start %d.%d.%d.%d:%d\n", param->ip[0], param->ip[1], param->ip[2], param->ip[3], param->port); - - sock_addr.sin_family = AF_INET; - sock_addr.sin_port = htons(param->port); - sock_addr.sin_addr.s_addr = PP_HTONL(LWIP_MAKEU32(param->ip[0], param->ip[1], param->ip[2], param->ip[3])); - memset(&(sock_addr.sin_zero), 0, sizeof(sock_addr.sin_zero)); - - if (connect(fd, (struct sockaddr *)&sock_addr, sizeof(struct sockaddr)) < 0) - { - plc_error("Unable to connect\n"); - closesocket(fd); - free(param->recv_buf); - return NULL; - } - - lw_notice("client %s connected\n", inet_ntoa(sock_addr.sin_addr)); - - for(int i = 0; i < param->cmd_num; i ++) - { - PlcBinCmdType *cmd = &TestPlcCmd[i]; - sendto(fd, cmd->cmd, cmd->cmd_len, 0, (struct sockaddr*)&sock_addr, addr_len); - plc_print_array("Send cmd", cmd->cmd_len, cmd->cmd); - - MdelayKTask(cmd->delay_ms); - timeout = PLC_SOCK_TIMEOUT; - memset(param->recv_buf, 0, param->recv_len); - while(timeout --) - { - recv_len = recvfrom(fd, param->recv_buf, param->recv_len, 0, (struct sockaddr *)&sock_addr, &addr_len); - if(recv_len > 0) - { - if(param->device_type == PLC_DEV_TYPE_OML) - { - if((recv_len == OML_HEADER_LEN) && (CHECK_OML_HEADER(param->recv_buf))) - { - lw_notice("This is Oml package!!!\n"); - } - } - lw_notice("Receive from : %s\n", inet_ntoa(sock_addr.sin_addr)); - plc_print_array("Receive data", recv_len, param->recv_buf); - break; - } - } - } - - closesocket(fd); - free(param->recv_buf); - return NULL; -} - -void PlcGetParamCmd(char *cmd) -{ - const char s[2] = ","; - char *token; - uint16_t cmd_index = 0; - char bin_cmd[PLC_BIN_CMD_LEN] = {0}; - token = strtok(cmd, s); - while(token != NULL) - { - sscanf(token, "%x", &bin_cmd[cmd_index]); - plc_print("%d - %s %d\n", cmd_index, token, bin_cmd[cmd_index]); - token = strtok(NULL, s); - cmd_index ++; - } - TestPlcCmd[plc_cmd_index].cmd_len = cmd_index; - memcpy(TestPlcCmd[plc_cmd_index].cmd, bin_cmd, cmd_index); - plc_print("get %d cmd len %d\n", plc_cmd_index, TestPlcCmd[plc_cmd_index].cmd_len); - plc_cmd_index ++; - plc_socket_demo_data.cmd_num = plc_cmd_index; -} - -void PlcShowUsage(void) -{ - plc_notice("------------------------------------\n"); - plc_notice("PlcSocket [ip].[ip].[ip].[ip]:[port]\n"); - plc_notice("PlcSocket support other param:\n"); - plc_notice("plc=[] 0: OML 1:SIEMENS\n"); - plc_notice("tcp=[] 0: udp 1:tcp\n"); - plc_notice("ip=[ip.ip.ip.ip]\n"); - plc_notice("port=port\n"); - plc_notice("file: use %s\n", PLC_SOCK_FILE_NAME); - plc_notice("------------------------------------\n"); -} - -#if defined(MOUNT_SDCARD) && defined(LIB_USING_CJSON) -void PlcGetParamFromFile(char *file_name) -{ - PlcSocketParamType *param = &plc_socket_demo_data; - - char *file_buf = malloc(CTL_FILE_LEN); - if(file_buf == NULL) - { - plc_error("No enough buffer %d\n", CTL_FILE_LEN); - return; - } - memset(file_buf, 0, CTL_FILE_LEN); - - if(CtlFileReadWithFilename(file_name, CTL_FILE_LEN, file_buf) != EOK) - { - plc_error("Can't open file %s\n", file_name); - //try again default file - if(strcmp(file_name, PLC_SOCK_FILE_NAME) != 0) - { - if(CtlFileReadWithFilename(PLC_SOCK_FILE_NAME, CTL_FILE_LEN, file_buf) != EOK) - { - plc_error("Can't open file %s\n", file_name); - return; - } - } - else - { - return; - } - } - CtlParseJsonData(file_buf); - - memcpy(param->ip, ctl_file_param.ip, 4); - param->port = ctl_file_param.port; - param->cmd_num = ctl_file_param.cmd_num; - param->socket_type = ctl_file_param.tcp ? SOCK_STREAM : SOCK_DGRAM; - - for(int i = 0; i < param->cmd_num; i++) - { - TestPlcCmd[i].cmd_len = ctl_file_param.cmd_len[i]; - memcpy(TestPlcCmd[i].cmd, ctl_file_param.cmd[i], TestPlcCmd[i].cmd_len); - } - - plc_print("ip: %d.%d.%d.%d\n", param->ip[0], param->ip[1], param->ip[2], param->ip[3]); - plc_print("port: %d", param->port); - plc_print("tcp: %d", param->socket_type); - plc_print("cmd number: %d\n", param->cmd_num); - - for(int i = 0; i < param->cmd_num; i++) - { - plc_print_array("cmd", TestPlcCmd[i].cmd_len, TestPlcCmd[i].cmd); - } - free(file_buf); -} - -#endif - -void PlcCheckParam(int argc, char *argv[]) -{ - int i; - PlcSocketParamType *param = &plc_socket_demo_data; - plc_cmd_index = 0; - - for(i = 0; i < argc; i++) - { - char *str = argv[i]; - int is_tcp = 0; - char cmd_str[PLC_BIN_CMD_LEN] = {0}; - - plc_print("check %d %s\n", i, str); - -#if defined(MOUNT_SDCARD) && defined(LIB_USING_CJSON) - if(strncmp(str, "file", 4) == 0) - { - char file_name[CTL_FILE_NAME_LEN] = {0}; - if(sscanf(str, "file=%s", file_name) == EOF) - { - strcpy(file_name, PLC_SOCK_FILE_NAME); - } - plc_notice("get %s parameter file %s\n", str, file_name); - PlcGetParamFromFile(file_name); - return; - } -#endif - if(sscanf(str, "ip=%d.%d.%d.%d", - ¶m->ip[0], - ¶m->ip[1], - ¶m->ip[2], - ¶m->ip[3]) == 4) - { - plc_print("find ip %d %d %d %d\n", param->ip[0], param->ip[1], param->ip[2], param->ip[3]); - continue; - } - - if(sscanf(str, "port=%d", ¶m->port) == 1) - { - plc_print("find port %d\n", param->port); - continue; - } - - if(sscanf(str, "tcp=%d", &is_tcp) == 1) - { - plc_print("find tcp %d\n", is_tcp); - param->socket_type = is_tcp ? SOCK_STREAM:SOCK_DGRAM; - continue; - } - - if(sscanf(str, "plc=%d", ¶m->device_type) == 1) - { - plc_print("find device %d\n", param->device_type); - continue; - } - - if(sscanf(str, "cmd=%s", cmd_str) == 1) - { - plc_print("find cmd %s\n", cmd_str); - PlcGetParamCmd(cmd_str); - continue; - } - } - - if(argc >= 2) - { - if(sscanf(argv[1], "%d.%d.%d.%d:%d", - ¶m->ip[0], - ¶m->ip[1], - ¶m->ip[2], - ¶m->ip[3], - ¶m->port) != EOF) - { - return; - } - - if(sscanf(argv[1], "%d.%d.%d.%d", - ¶m->ip[0], - ¶m->ip[1], - ¶m->ip[2], - ¶m->ip[3]) != EOF) - { - return; - } - } - else - { - PlcShowUsage(); - } -} - -void PlcSocketTask(int argc, char *argv[]) -{ - int result = 0; - pthread_t th_id; - uint8_t enet_port = 0; ///< test enet port 0 - - pthread_attr_t attr; - attr.schedparam.sched_priority = LWIP_DEMO_TASK_PRIO; - attr.stacksize = LWIP_TASK_STACK_SIZE; - PlcSocketParamType *param = &plc_socket_demo_data; - - PlcCheckParam(argc, argv); - - lwip_config_net(enet_port, lwip_ipaddr, lwip_netmask, param->ip); - PrivTaskCreate(&th_id, &attr, PlcSocketStart, param); -} - -SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(3), - PlcSocket, PlcSocketTask, Test PLC Socket); - diff --git a/APP_Framework/Framework/control/plc_protocol/Kconfig b/APP_Framework/Framework/control/plc_protocol/Kconfig index 139597f9c..9839fe26e 100755 --- a/APP_Framework/Framework/control/plc_protocol/Kconfig +++ b/APP_Framework/Framework/control/plc_protocol/Kconfig @@ -1,2 +1,15 @@ +config CONTROL_PROTOCOL_FINS + bool "Using fins control protocol" + default n +config CONTROL_PROTOCOL_MELSEC + bool "Using melsec control protocol" + default n +config CONTROL_PROTOCOL_OPCUA + bool "Using opcua control protocol" + default n + +config CONTROL_PROTOCOL_S7 + bool "Using s7 control protocol" + default n diff --git a/APP_Framework/Framework/control/plc_protocol/Makefile b/APP_Framework/Framework/control/plc_protocol/Makefile index ff2e46798..66e467295 100755 --- a/APP_Framework/Framework/control/plc_protocol/Makefile +++ b/APP_Framework/Framework/control/plc_protocol/Makefile @@ -1,4 +1,17 @@ -SRC_DIR := fins melsec opcua s7 +ifeq ($(CONFIG_CONTROL_PROTOCOL_FINS), y) + SRC_DIR := fins +endif + +ifeq ($(CONFIG_CONTROL_PROTOCOL_MELSEC), y) + SRC_DIR := melsec +endif + +ifeq ($(CONFIG_CONTROL_PROTOCOL_OPCUA), y) + SRC_DIR := opcua +endif + +ifeq ($(CONFIG_CONTROL_PROTOCOL_S7), y) + SRC_DIR := s7 +endif include $(KERNEL_ROOT)/compiler.mk - diff --git a/APP_Framework/Framework/control/plc_protocol/fins/Makefile b/APP_Framework/Framework/control/plc_protocol/fins/Makefile index 608656f03..020d8567a 100755 --- a/APP_Framework/Framework/control/plc_protocol/fins/Makefile +++ b/APP_Framework/Framework/control/plc_protocol/fins/Makefile @@ -1,4 +1,4 @@ -SRC_FILES := +SRC_FILES := fins.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/control/plc_protocol/fins/fins.c b/APP_Framework/Framework/control/plc_protocol/fins/fins.c new file mode 100644 index 000000000..0cbfeec88 --- /dev/null +++ b/APP_Framework/Framework/control/plc_protocol/fins/fins.c @@ -0,0 +1,368 @@ +/* +* 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 fins.c + * @brief plc protocol fins + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2022-10-08 + */ + +#include + +#define FINS_COMMAND_LENGTH 34 + +static struct CircularAreaApp *circular_area; + +static uint8_t handshake_require_command[] = {0x46, 0x49, 0x4E, 0x53, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +static uint8_t handshake_respond_buff[24] = {0}; +static uint8_t recv_buff[1024] = {0}; + +static uint8_t FinsAreaCode(char area_char, FinsDataType type) +{ + uint8_t area_code = 0; + if (area_char == 'C') + area_code = (type == FINS_DATA_TYPE_BIT ? 0x30 : 0xB0); + if (area_char == 'W') + area_code = (type == FINS_DATA_TYPE_BIT ? 0x31 : 0xB1); + if (area_char == 'H') + area_code = (type == FINS_DATA_TYPE_BIT ? 0x32 : 0xB2); + if (area_char == 'D') + area_code = (type == FINS_DATA_TYPE_BIT ? 0x02 : 0x82); + return area_code; +} + +static uint16_t FinsCommandGenerate(uint8_t *p_command, uint16_t plc_ip_4, uint16_t pc_ip_4, FinsCommandCode command_code, char area_char, + FinsDataType data_type, uint16_t start_address, uint8_t bit_address, uint16_t data_length) +{ + uint8_t index = 0; + p_command[index++] = (uint8_t)(FINS_HEADER_HEAD >> (3 * 8)); + p_command[index++] = (uint8_t)(FINS_HEADER_HEAD >> (2 * 8)); + p_command[index++] = (uint8_t)(FINS_HEADER_HEAD >> (1 * 8)); + p_command[index++] = (uint8_t)FINS_HEADER_HEAD; + p_command[index++] = (uint8_t)FINS_HEADER_READ_COMMAND_LENGTH >> (3 * 8); + p_command[index++] = (uint32_t)FINS_HEADER_READ_COMMAND_LENGTH >> (2 * 8); + p_command[index++] = (uint32_t)FINS_HEADER_READ_COMMAND_LENGTH >> (1 * 8); + p_command[index++] = (uint32_t)FINS_HEADER_READ_COMMAND_LENGTH; + p_command[index++] = (uint32_t)FINS_HEADER_COMMAND >> (3 * 8); + p_command[index++] = (uint32_t)FINS_HEADER_COMMAND >> (2 * 8); + p_command[index++] = (uint32_t)FINS_HEADER_COMMAND >> (1 * 8); + p_command[index++] = (uint32_t)FINS_HEADER_COMMAND; + p_command[index++] = (uint32_t)FINS_HEADER_ERROR_CODE >> (3 * 8); + p_command[index++] = (uint32_t)FINS_HEADER_ERROR_CODE >> (2 * 8); + p_command[index++] = (uint32_t)FINS_HEADER_ERROR_CODE >> (1 * 8); + p_command[index++] = (uint32_t)FINS_HEADER_ERROR_CODE; + p_command[index++] = FINS_ICF; + p_command[index++] = FINS_RSV; + p_command[index++] = FINS_GCT; + + p_command[index++] = FINS_DNA; + p_command[index++] = plc_ip_4; + p_command[index++] = FINS_DA2; + + p_command[index++] = FINS_SNA; + p_command[index++] = pc_ip_4; + p_command[index++] = FINS_SA2; + + p_command[index++] = FINS_SID; + + p_command[index++] = command_code >> 8; + p_command[index++] = command_code; + p_command[index++] = FinsAreaCode(area_char, data_type); + p_command[index++] = start_address >> 8; + p_command[index++] = start_address; + p_command[index++] = bit_address; + p_command[index++] = data_length >> 8; + p_command[index++] = data_length; + + return index; +} + +static int FinsTransformRecvBuffToData(FinsReadItem *p_read_item, uint8_t *recv_buff) +{ + FinsDataInfo *p_fins_data_info = &(p_read_item->data_info); + uint8_t error_code = recv_buff[3]; + if (error_code) { + printf("Data abnormal, abnormal error code is %08x!", error_code); + return -1; + } + recv_buff += 30; + + FinsCommandCode command_code = p_fins_data_info->command_code; + if (FINS_COMMAND_CODE_READ == command_code) { + + uint16_t data_length = p_read_item->data_length; + ControlPrintList("DATA", recv_buff, data_length * (FINS_DATA_TYPE_BIT == p_read_item->data_type ? 1 : 2)); + printf("Receive data is "); + + if (FINS_DATA_TYPE_BIT == p_read_item->data_type) { + memcpy(p_fins_data_info->base_data_info.p_data, recv_buff, data_length); + + printf("%02x", p_fins_data_info->base_data_info.p_data[0]); + } else { + uint8_t *p_data = p_fins_data_info->base_data_info.p_data; + + for (uint16_t i = 0; i < data_length; i ++) { + p_data[2 * i] = recv_buff[2 * (data_length - i - 1)]; + p_data[2 * i + 1] = recv_buff[2 * (data_length - i - 1) + 1]; + printf("%03x%03x", p_data[2 * i], p_data[2 * i + 1]); + } + } + + printf("\nRead fins plc data success!\n"); + } else if (FINS_COMMAND_CODE_WRITE == command_code) { + /*to do*/ + printf("Write fins plc cmd success!\n"); + } + + return 0; +} + +static int FinsHandshake(int32_t socket, uint16_t local_ip_4) +{ + handshake_require_command[18] = (uint8_t)(local_ip_4 >> 8); + handshake_require_command[19] = (uint8_t)local_ip_4; + uint8_t try_count = 0; + + while (try_count < 10) { + ControlPrintList("SEND", (uint8_t *)handshake_require_command, sizeof(handshake_require_command)); + int32_t write_error = socket_write(socket, handshake_require_command, sizeof(handshake_require_command)); + if (write_error < 0) { + printf("Write socket error, errno is %d!", errno); + } else { + int32_t recv_length = socket_read(socket, (uint8_t *)handshake_respond_buff, sizeof(handshake_respond_buff)); + if (recv_length < 0) { + printf("Read socket error, errno is %d!", errno); + } else { + ControlPrintList("RECV", (uint8_t *)handshake_respond_buff, recv_length); + + /*check fins handshake respond*/ + uint8_t error_code = handshake_respond_buff[15]; + if (error_code == 0 || error_code == 0x21) { + return 0; + } else { + printf("Fins handshake failed, errno is %05x!", handshake_respond_buff[15]); + return -1; + } + } + } + if ((errno == EINTR) || (errno == EAGAIN) || (errno == EWOULDBLOCK)) { + printf("Send plc command failed, errno is %d!", errno); + continue; + } else { + break; + } + } + return -2; +} + +static int FinsGetData(int32_t socket, FinsReadItem *p_read_item, struct ControlRecipe *p_recipe) +{ + uint8_t try_count = 0; + int32_t write_error = 0; + + FinsDataInfo *p_fins_data_info = &(p_read_item->data_info); + BasicPlcDataInfo *p_base_data_info = &(p_fins_data_info->base_data_info); + + memset(recv_buff, 0, sizeof(recv_buff)); + + while (try_count < 10) { + ControlPrintList("SEND", p_base_data_info->p_command, p_base_data_info->command_length); + try_count++; + + write_error = socket_write(socket, p_base_data_info->p_command, p_base_data_info->command_length); + if (write_error < 0) { + printf("Write socket error, errno is %d!", errno); + } else { + PrivTaskDelay(20); + + int32_t recv_length = socket_read(socket, recv_buff, sizeof(recv_buff)); + if (recv_length < 0) { + printf("Read socket error, errno is %d!", errno); + } else { + ControlPrintList("RECV", recv_buff, recv_length); + return FinsTransformRecvBuffToData(p_read_item, recv_buff); + } + } + + if ((errno == EINTR) || (errno == EAGAIN) || (errno == EWOULDBLOCK)) { + printf("Send plc command failed, errno is %d!", errno); + continue; + } else { + return -1; + } + } + return -2; +} + +static int FinsInitialDataInfo(FinsReadItem *p_read_item, uint16_t plc_ip_4, uint16_t local_ip_4, FinsCommandCode command_code, + char area_char, FinsDataType data_type, uint16_t start_address, uint8_t bit_address, uint16_t data_length, uint8_t *p_data) +{ + p_read_item->area_char = area_char; + p_read_item->data_type = data_type; + p_read_item->data_info.command_code = command_code; + p_read_item->start_address = start_address; + p_read_item->bit_address = bit_address; + p_read_item->data_length = data_length; + + BasicPlcDataInfo *p_base_data_info = &(p_read_item->data_info.base_data_info); + switch (command_code) + { + case FINS_COMMAND_CODE_READ: + data_length *= (data_type == FINS_DATA_TYPE_BIT ? 1 : 2); + p_base_data_info->command_length = FINS_COMMAND_LENGTH; + p_base_data_info->p_command = (p_data == NULL ? PrivMalloc(FINS_COMMAND_LENGTH + data_length) : PrivMalloc(FINS_COMMAND_LENGTH)); + p_base_data_info->data_size = data_length; + p_base_data_info->p_data = (p_data == NULL ? p_base_data_info->p_command + FINS_COMMAND_LENGTH : p_data); + break; + case FINS_COMMAND_CODE_WRITE: + //To Do + break; + default: + return -1; + } + uint16_t command_length = FinsCommandGenerate(p_base_data_info->p_command, plc_ip_4, local_ip_4, command_code, area_char, + data_type, start_address, bit_address, data_length); + + return 0; +} + +void *ReceivePlcDataTask(void *parameter) +{ + int i = 0; + uint8_t try_count = 0; + uint16_t data_length = 0; + uint8_t *fins_data; + uint16_t read_item_size = sizeof(FinsReadItem); + + struct ControlProtocol *control_protocol = (struct ControlProtocol *)parameter; + circular_area = (struct CircularAreaApp *)control_protocol->args; + FinsReadItem *fins_read_item = (FinsReadItem *)control_protocol->recipe->read_item; + fins_data = control_protocol->recipe->protocol_data->data; + data_length = control_protocol->recipe->protocol_data->data_length; + + BasicSocketPlc plc_socket; + memset(&plc_socket, 0, sizeof(BasicSocketPlc)); + memcpy(plc_socket.ip, control_protocol->recipe->socket_config.plc_ip, 4); + plc_socket.port = control_protocol->recipe->socket_config.port; + plc_socket.socket = -1; + plc_socket.secondary_connect_flag = 0; + + while (1) { + for (i = 0; i < control_protocol->recipe->read_item_count; i ++) { + /*only connect socket when close socket or init*/ + while (ControlConnectSocket(&plc_socket) < 0) { + PrivTaskDelay(1000); + } + + /*need to handshake after connect socket using FINS protocol*/ + if (0 == plc_socket.secondary_connect_flag) { + if (FinsHandshake(plc_socket.socket, control_protocol->recipe->socket_config.local_ip[3]) < 0) { + plc_socket.secondary_connect_flag = 0; + ControlDisconnectSocket(&plc_socket); + continue; + } + } + + plc_socket.secondary_connect_flag = 1; + + FinsGetData(plc_socket.socket, (FinsReadItem *)fins_read_item + i, control_protocol->recipe); + } + + /*read all variable item data, put them into circular_area*/ + if (i == control_protocol->recipe->read_item_count) { + CircularAreaAppWrite(circular_area, fins_data, data_length, 0); + } + + /*read data every single 200ms*/ + PrivTaskDelay(200); + } +} + +int FinsOpen(struct ControlProtocol *control_protocol) +{ + ControlProtocolOpenDef(control_protocol); + + return 0; +} + +int FinsClose(struct ControlProtocol *control_protocol) +{ + ControlProtocolCloseDef(); +} + +int FinsRead(struct ControlProtocol *control_protocol, void *buf, size_t len) +{ + return CircularAreaAppRead(circular_area, buf, len); +} + +static struct ControlDone fins_protocol_done = +{ + ._open = FinsOpen, + ._close = FinsClose, + ._read = FinsRead, + ._write = NULL, + ._ioctl = NULL, +}; + +int FinsProtocolFormatCmd(struct ControlRecipe *p_recipe, ProtocolFormatInfo *protocol_format_info) +{ + int ret = 0; + static uint8_t last_data_length = 0; + + p_recipe->read_item = PrivMalloc(sizeof(FinsReadItem) * p_recipe->read_item_count); + FinsReadItem *fins_read_item = (FinsReadItem *)(p_recipe->read_item) + protocol_format_info->read_item_index; + + fins_read_item->value_type = cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "value_type")->valueint; + strncpy(fins_read_item->value_name, cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "value_name")->valuestring, 20); + + ret = FinsInitialDataInfo(fins_read_item, + p_recipe->socket_config.plc_ip[3], + p_recipe->socket_config.local_ip[3], + FINS_COMMAND_CODE_READ, + cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "area_char")->valuestring[0], + cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "data_type")->valueint, + cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "start_address")->valueint, + cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "bit_address")->valueint, + cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "data_length")->valueint, + p_recipe->protocol_data->data + last_data_length); + + ControlPrintList("CMD", fins_read_item->data_info.base_data_info.p_command, fins_read_item->data_info.base_data_info.command_length); + last_data_length = GetValueTypeMemorySize(fins_read_item->value_type); + + return ret; +} + +int FinsProtocolInit(struct ControlRecipe *p_recipe) +{ + struct ControlProtocol *p_control_protocol = CONTAINER_OF(p_recipe, struct ControlProtocol, recipe); + if (NULL == p_control_protocol) { + printf("%s get control protocol failed\n", __func__); + return -1; + } + + FinsReadItem *fins_read_item = PrivMalloc(sizeof(FinsReadItem) * p_recipe->read_item_count); + if (NULL == fins_read_item) { + PrivFree(fins_read_item); + return -1; + } + p_recipe->read_item = (void *)fins_read_item; + + p_recipe->ControlProtocolFormatCmd = FinsProtocolFormatCmd; + + p_control_protocol->done = &fins_protocol_done; + + return 0; +} + + diff --git a/APP_Framework/Framework/control/plc_protocol/fins/test_recipe_fins.json b/APP_Framework/Framework/control/plc_protocol/fins/test_recipe_fins.json new file mode 100644 index 000000000..301f67713 --- /dev/null +++ b/APP_Framework/Framework/control/plc_protocol/fins/test_recipe_fins.json @@ -0,0 +1,331 @@ +{ + "device_id": 769, + "device_name": "S01", + "communication_type": 0, + "socket_config": { + "plc_ip": "192.168.250.22", + "local_ip": "192.168.250.233", + "gateway": "192.168.250.1", + "netmask": "255.255.254.0", + "port": 9600 + }, + "protocol_type": 6, + "read_period": 100, + "read_item_list": [ + { + "value_name": "", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 0, + "bit_address": 0, + "data_length": 1 + }, + { + "value_name": "ֹͣ", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 0, + "bit_address": 1, + "data_length": 1 + }, + { + "value_name": "ʹ", + "value_type": 1, + "area_char": "H", + "data_type": 0, + "start_address": 0, + "bit_address": 2, + "data_length": 1 + }, + { + "value_name": "", + "value_type": 1, + "area_char": "D", + "data_type": 0, + "start_address": 0, + "bit_address": 3, + "data_length": 1 + }, + { + "value_name": "ͣ", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 0, + "bit_address": 4, + "data_length": 1 + }, + { + "value_name": "λ", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 10, + "bit_address": 11, + "data_length": 1 + }, + { + "value_name": "λ", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 10, + "bit_address": 12, + "data_length": 1 + }, + { + "value_name": "Զ", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 200, + "bit_address": 5, + "data_length": 1 + }, + { + "value_name": "", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 200, + "bit_address": 6, + "data_length": 1 + }, + { + "value_name": "", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 200, + "bit_address": 7, + "data_length": 1 + }, + { + "value_name": "ֶģʽ", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 300, + "bit_address": 0, + "data_length": 1 + }, + { + "value_name": "Զģʽ", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 300, + "bit_address": 1, + "data_length": 1 + }, + { + "value_name": "з", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 300, + "bit_address": 2, + "data_length": 1 + }, + { + "value_name": "λ", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 400, + "bit_address": 3, + "data_length": 1 + }, + { + "value_name": "1", + "value_type": 1, + "area_char": "W", + "data_type": 0, + "start_address": 400, + "bit_address": 4, + "data_length": 1 + }, + { + "value_name": "", + "value_type": 3, + "area_char": "D", + "data_type": 1, + "start_address": 10, + "bit_address": 0, + "data_length": 1 + }, + { + "value_name": "1", + "value_type": 3, + "area_char": "D", + "data_type": 1, + "start_address": 11, + "bit_address": 0, + "data_length": 1 + }, + { + "value_name": "2", + "value_type": 3, + "area_char": "D", + "data_type": 1, + "start_address": 20, + "bit_address": 0, + "data_length": 1 + }, + { + "value_name": "3", + "value_type": 3, + "area_char": "D", + "data_type": 1, + "start_address": 100, + "bit_address": 0, + "data_length": 1 + }, + { + "value_name": "4", + "value_type": 3, + "area_char": "W", + "data_type": 1, + "start_address": 100, + "bit_address": 0, + "data_length": 1 + }, + { + "value_name": "5", + "value_type": 3, + "area_char": "W", + "data_type": 1, + "start_address": 101, + "bit_address": 0, + "data_length": 1 + }, + { + "value_name": "6", + "value_type": 3, + "area_char": "W", + "data_type": 1, + "start_address": 110, + "bit_address": 0, + "data_length": 1 + }, + { + "value_name": "7", + "value_type": 3, + "area_char": "H", + "data_type": 1, + "start_address": 10, + "bit_address": 0, + "data_length": 1 + }, + { + "value_name": "8", + "value_type": 3, + "area_char": "H", + "data_type": 1, + "start_address": 20, + "bit_address": 0, + "data_length": 1 + }, + { + "value_name": "9", + "value_type": 3, + "area_char": "H", + "data_type": 1, + "start_address": 21, + "bit_address": 0, + "data_length": 1 + }, + { + "value_name": "ٶ", + "value_type": 9, + "area_char": "D", + "data_type": 1, + "start_address": 2000, + "bit_address": 0, + "data_length": 2 + }, + { + "value_name": "ٶ", + "value_type": 9, + "area_char": "D", + "data_type": 1, + "start_address": 2002, + "bit_address": 0, + "data_length": 2 + }, + { + "value_name": "ٶ", + "value_type": 9, + "area_char": "D", + "data_type": 1, + "start_address": 2004, + "bit_address": 0, + "data_length": 2 + }, + { + "value_name": "ʼλ", + "value_type": 9, + "area_char": "D", + "data_type": 1, + "start_address": 300, + "bit_address": 0, + "data_length": 2 + }, + { + "value_name": "յλ", + "value_type": 9, + "area_char": "D", + "data_type": 1, + "start_address": 302, + "bit_address": 0, + "data_length": 2 + }, + { + "value_name": "ֵ", + "value_type": 9, + "area_char": "W", + "data_type": 1, + "start_address": 80, + "bit_address": 0, + "data_length": 2 + }, + { + "value_name": "1", + "value_type": 8, + "area_char": "H", + "data_type": 1, + "start_address": 100, + "bit_address": 0, + "data_length": 4 + }, + { + "value_name": "2", + "value_type": 8, + "area_char": "H", + "data_type": 1, + "start_address": 104, + "bit_address": 0, + "data_length": 4 + }, + { + "value_name": "3", + "value_type": 8, + "area_char": "H", + "data_type": 1, + "start_address": 108, + "bit_address": 0, + "data_length": 4 + }, + { + "value_name": "4", + "value_type": 8, + "area_char": "H", + "data_type": 1, + "start_address": 112, + "bit_address": 0, + "data_length": 4 + } + ] +} \ No newline at end of file diff --git a/APP_Framework/Framework/control/plc_protocol/include/fins.h b/APP_Framework/Framework/control/plc_protocol/include/fins.h new file mode 100644 index 000000000..549776752 --- /dev/null +++ b/APP_Framework/Framework/control/plc_protocol/include/fins.h @@ -0,0 +1,86 @@ +/* +* 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 fins.h + * @brief plc protocol fins + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2022-10-08 + */ + +#ifndef FINS_H +#define FINS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define FINS_HEADER_HEAD 0x46494E53 +#define FINS_HEADER_READ_COMMAND_LENGTH 0x0000001A +#define FINS_HEADER_COMMAND 0x00000002 +#define FINS_HEADER_ERROR_CODE 0x00000000 +#define FINS_ICF 0x80 +#define FINS_RSV 0x00 +#define FINS_REPLY_ICF 0xC0 +#define FINS_GCT 0x02 +#define FINS_DNA 0x00 +#define FINS_DA2 0x00 +#define FINS_SNA 0x00 +#define FINS_SA2 0x00 +#define FINS_SID 0x00 + +typedef enum +{ + FINS_COMMAND_CODE_READ = 0x0101, + FINS_COMMAND_CODE_WRITE = 0x0102 +}FinsCommandCode; + +typedef enum +{ + FINS_DATA_TYPE_BIT, + FINS_DATA_TYPE_WORD +}FinsDataType; + +typedef struct +{ + BasicPlcDataInfo base_data_info; + FinsCommandCode command_code; +}FinsDataInfo; + +typedef struct +{ + int32_t socket; + uint16_t plc_ip_4; +}FinsHandshakeParameter; + +typedef struct +{ + FinsDataInfo data_info; + + UniformValueType value_type; + char value_name[20]; + + char area_char; + FinsDataType data_type; + uint16_t start_address; + uint8_t bit_address; + uint16_t data_length; +}FinsReadItem; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/APP_Framework/Framework/control/shared/control_file.c b/APP_Framework/Framework/control/plc_protocol/include/melsec.h old mode 100755 new mode 100644 similarity index 85% rename from APP_Framework/Framework/control/shared/control_file.c rename to APP_Framework/Framework/control/plc_protocol/include/melsec.h index 198c166ef..2586fdd4e --- a/APP_Framework/Framework/control/shared/control_file.c +++ b/APP_Framework/Framework/control/plc_protocol/include/melsec.h @@ -11,11 +11,9 @@ */ /** - * @file control_file.c - * @brief control relative file operation + * @file melsec.h + * @brief plc protocol melsec * @version 3.0 * @author AIIT XUOS Lab - * @date 2022-09-37 - */ - - + * @date 2022-10-08 + */ \ No newline at end of file diff --git a/APP_Framework/Framework/control/shared/control_file.h b/APP_Framework/Framework/control/plc_protocol/include/opcua.h old mode 100755 new mode 100644 similarity index 78% rename from APP_Framework/Framework/control/shared/control_file.h rename to APP_Framework/Framework/control/plc_protocol/include/opcua.h index 5058c4def..898d0022d --- a/APP_Framework/Framework/control/shared/control_file.h +++ b/APP_Framework/Framework/control/plc_protocol/include/opcua.h @@ -11,16 +11,9 @@ */ /** - * @file control_file.h - * @brief control file function relative API + * @file opcua.h + * @brief control protocol opcua * @version 3.0 * @author AIIT XUOS Lab - * @date 2022-09-27 - */ - -#ifndef CONTROL_FILE_H -#define CONTROL_FILE_H - - -#endif - + * @date 2022-10-08 + */ \ No newline at end of file diff --git a/APP_Framework/Framework/control/plc_protocol/include/s7.h b/APP_Framework/Framework/control/plc_protocol/include/s7.h new file mode 100644 index 000000000..f89f1f122 --- /dev/null +++ b/APP_Framework/Framework/control/plc_protocol/include/s7.h @@ -0,0 +1,19 @@ +/* +* 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 s7.h + * @brief plc protocol s7 + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2022-10-08 + */ \ No newline at end of file diff --git a/APP_Framework/Framework/control/shared/Makefile b/APP_Framework/Framework/control/shared/Makefile index 633191b89..e26f03b9b 100755 --- a/APP_Framework/Framework/control/shared/Makefile +++ b/APP_Framework/Framework/control/shared/Makefile @@ -1,8 +1,4 @@ -SRC_FILES := control.c - -ifeq ($(CONFIG_MOUNT_SDCARD),y) - SRC_FILES += control_file.c -endif +SRC_FILES := control.c control_def.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/control/shared/config.json b/APP_Framework/Framework/control/shared/config.json deleted file mode 100755 index 05b79a6a3..000000000 --- a/APP_Framework/Framework/control/shared/config.json +++ /dev/null @@ -1,38 +0,0 @@ -{ -"siemens plc": -{ - "device type": "PLC", - "control type": "HSC", - "info": - { - "plc ability" : 1, - "plc device id": 1, - "soft version" : 1, - "hardware version": 1, - "date": "2022-1-28", - "vendor": "siemens", - "model":"S300" - }, - - "serial config": - { - "serial type":"485", - "station id" : "station1", - "serial port" : 1 - }, - - "network config": - { - "ip addr" : "192.168.250.5", - "ip port" : 4840 - }, - - "interface": - { - "inhybridnet":"OPCUA", - "transport":"TCP", - "ip address": "192.168.250.5", - "attribute" : "1" - } -} -} diff --git a/APP_Framework/Framework/control/shared/control.c b/APP_Framework/Framework/control/shared/control.c index 8c880f693..6ebd1394a 100755 --- a/APP_Framework/Framework/control/shared/control.c +++ b/APP_Framework/Framework/control/shared/control.c @@ -12,16 +12,239 @@ /** * @file control.c - * @brief control framework code + * @brief code for control framework app * @version 3.0 * @author AIIT XUOS Lab * @date 2022-09-27 */ #include +#include -void control_init(void) +ControlProtocolType control_protocol; + +/** + * @description: Control Framework Find certain Protocol + * @param + * @return Control Protocol pointer + */ +ControlProtocolType ControlProtocolFind(void) { - //to do + return control_protocol; } +/** + * @description: Control Framework Protocol Init + * @param control_protocol - control protocol pointer + * @return success: 0 error : -1 + */ +static int ControlProtocolInit(ControlProtocolType control_protocol) +{ + CONTROL_PARAM_CHECK(control_protocol); + int ret = -1; + + control_protocol->protocol_status = CONTROL_INIT; + + ret = PrivMutexCreate(&control_protocol->lock, 0); + if(ret < 0) { + printf("ControlProtocolInit mutex create failed.\n"); + goto _out; + } + + ret = PrivSemaphoreCreate(&control_protocol->sem, 0, 0); + if (ret < 0) { + printf("ControlProtocolInit create sem error\n"); + goto _out; + } + +_out: + return ret; +} + +/** + * @description: Analyze Recipe + * @param control_protocol - Control Protocol pointer + * @param recipe_name - recipe name + * @return success: 0 error : -1 + */ +static int ControlAnalyzeRecipe(ControlProtocolType control_protocol, const char *recipe_name) +{ + int recipe_file_fd = -1; + struct stat recipe_file_status; + uint16_t recipe_file_length = 0; + char *recipe_file_buf; + + //Step1 : read recipe file data from SD card or other store device + recipe_file_fd = PrivOpen(recipe_name, O_RDONLY); + if (recipe_file_fd < 0) { + printf("Open recipe file %s failed\n", recipe_name); + PrivClose(recipe_file_fd); + return -1; + } + + if (0 != fstat(recipe_file_fd, &recipe_file_status)) { + printf("Get recipe file information failed!\n"); + PrivClose(recipe_file_fd); + return -1; + } else { + recipe_file_length = recipe_file_status.st_size; + } + + recipe_file_buf = PrivMalloc(recipe_file_length); + if (NULL == recipe_file_buf) { + printf("Get recipe file memory failed!\n"); + PrivFree(recipe_file_buf); + PrivClose(recipe_file_fd); + return -1; + } + + if (PrivRead(recipe_file_fd, recipe_file_buf, recipe_file_length) < 0) { + printf("Read recipe file failed!\n"); + PrivFree(recipe_file_buf); + PrivClose(recipe_file_fd); + return -1; + } + + PrivClose(recipe_file_fd); + + //Step2 : CJSON analyze +#ifdef LIB_USING_CJSON + cJSON *recipe_file_json = cJSON_Parse(recipe_file_buf); + PrivFree(recipe_file_buf); + if (NULL == recipe_file_json) { + printf("Parse recipe_file_buf failed!\n"); + return -1; + } + + control_protocol->recipe = (struct ControlRecipe *)PrivMalloc(sizeof(struct ControlRecipe)); + memset(control_protocol->recipe, 0, sizeof(struct ControlRecipe)); + + /*Get basic information from recipe file*/ + if (RecipeBasicInformation(control_protocol->recipe, control_protocol->protocol_type, recipe_file_json) < 0) { + return -1; + } + + /*Get the variable need to read from recipe file*/ + RecipeReadVariableItem(control_protocol->recipe, control_protocol->protocol_type, recipe_file_json); + + cJSON_Delete(recipe_file_json); + printf("Read and parse recipe file done!\n"); +#endif + + return 0; +} + +/*Control Framework Protocol Open*/ +int ControlProtocolOpen(struct ControlProtocol *control_protocol) +{ + CONTROL_PARAM_CHECK(control_protocol); + CONTROL_PARAM_CHECK(control_protocol->done); + int ret = -1; + + if (control_protocol->done->_open) { + ret = control_protocol->done->_open(control_protocol); + } + + return ret; +} + +/*Control Framework Protocol Close*/ +int ControlProtocolClose(struct ControlProtocol *control_protocol) +{ + CONTROL_PARAM_CHECK(control_protocol); + CONTROL_PARAM_CHECK(control_protocol->done); + int ret = -1; + + if (control_protocol->done->_close) { + ret = control_protocol->done->_close(control_protocol); + } + + return ret; +} + +/*Control Framework Protocol Read Date*/ +int ControlProtocolRead(struct ControlProtocol *control_protocol, void *buf, size_t len) +{ + CONTROL_PARAM_CHECK(control_protocol); + CONTROL_PARAM_CHECK(control_protocol->done); + int ret = -1; + + if (control_protocol->done->_read) { + ret = control_protocol->done->_read(control_protocol, buf, len); + } + + return ret; +} + +/*Control Framework Protocol Write Cmd*/ +int ControlProtocolWrite(struct ControlProtocol *control_protocol, const void *buf, size_t len) +{ + CONTROL_PARAM_CHECK(control_protocol); + CONTROL_PARAM_CHECK(control_protocol->done); + int ret = -1; + + if (control_protocol->done->_write) { + ret = control_protocol->done->_write(control_protocol, buf, len); + } + + return ret; +} + +/*Control Framework Protocol Ioctl*/ +int ControlProtocolIoctl(struct ControlProtocol *control_protocol, int cmd, void *args) +{ + CONTROL_PARAM_CHECK(control_protocol); + CONTROL_PARAM_CHECK(control_protocol->done); + int ret = -1; + + if (control_protocol->done->_ioctl) { + ret = control_protocol->done->_ioctl(control_protocol, cmd, args); + } + + return ret; +} + +/** + * @description: Control Framework Init + * @return success: 0 error : -1 + */ +int ControlFrameworkInit(void) +{ + int ret = 0; + + control_protocol = (struct ControlProtocol *)PrivMalloc(sizeof(struct ControlProtocol)); + if (NULL == control_protocol) { + printf("%s malloc control protocol failed!\n", __func__); + PrivFree(control_protocol); + ret = -1; + goto _out; + } + + //Control Protocol Struct Init + ret = ControlProtocolInit(control_protocol); + if (ret < 0) { + printf("%s failed!\n", __func__); + PrivFree(control_protocol); + goto _out; + } + + //Read Recipe File, Get Control Protocol Configure Param + ret = ControlAnalyzeRecipe(control_protocol, CONTROL_RECIPE_FILE); + if (ret < 0) { + printf("%s failed!\n", __func__); + PrivFree(control_protocol); + goto _out; + } + + control_protocol->protocol_status = CONTROL_REGISTERED; + + ret = ControlPeripheralInit(control_protocol->recipe); + if (ret < 0) { + printf("%s failed!\n", __func__); + PrivFree(control_protocol); + goto _out; + } + +_out: + return ret; +} diff --git a/APP_Framework/Framework/control/shared/control.h b/APP_Framework/Framework/control/shared/control.h index bbf5772b4..4f7fb966f 100644 --- a/APP_Framework/Framework/control/shared/control.h +++ b/APP_Framework/Framework/control/shared/control.h @@ -12,13 +12,103 @@ /** * @file control.h - * @brief control framework code + * @brief DEFINE code for control framework app * @version 3.0 * @author AIIT XUOS Lab * @date 2022-09-27 */ -#include -#include +#ifndef CONTROL_H +#define CONTROL_H +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct ControlProtocol; +typedef struct ControlProtocol *ControlProtocolType; +typedef struct ControlData *ControlDataType; + +struct ControlDone +{ + int (*_open)(struct ControlProtocol *control_protocol); + int (*_close)(struct ControlProtocol *control_protocol); + int (*_read)(struct ControlProtocol *control_protocol, void *buf, size_t len); + int (*_write)(struct ControlProtocol *control_protocol, const void *buf, size_t len); + int (*_ioctl)(struct ControlProtocol *control_protocol, int cmd, void *args); +}; + +typedef enum +{ + PROTOCOL_S7 = 1, + PROTOCOL_MODBUS_TCP, + PROTOCOL_MODBUS_UART, + PROTOCOL_OPC_UA, + PROTOCOL_FINS, + PROTOCOL_MELSEC_1E, + PROTOCOL_MELSEC_3E_Q_L, + PROTOCOL_MELSEC_3E_IQ_R, + PROTOCOL_MELSEC_1C, + PROTOCOL_MELSEC_3C, + PROTOCOL_END +}ProtocolType; + +typedef enum +{ + CONTROL_INIT, + CONTROL_REGISTERED, + CONTROL_UNREGISTERED, +}ProtocolStatus; + +struct ControlProtocol +{ + char *name; + ProtocolType protocol_type; + ProtocolStatus protocol_status; + + struct ControlRecipe *recipe; + struct ControlDone *done; + + void *args; + + sem_t sem; + pthread_mutex_t lock; + //struct DoublelistNode link; +}; + +/*Control Framework Protocol Init*/ +int ControlFrameworkInit(void); + +/*Control Framework Find certain Protocol*/ +ControlProtocolType ControlProtocolFind(void); + +// /*Control Framework Protocol Register*/ +// int ControlProtocolRegister(struct ControlProtocol *control_protocol); + +// /*Control Framework Protocol Unregister*/ +// int ControlProtocolUnregister(struct ControlProtocol *control_protocol); + +/*Control Framework Protocol Open*/ +int ControlProtocolOpen(struct ControlProtocol *control_protocol); + +/*Control Framework Protocol Close*/ +int ControlProtocolClose(struct ControlProtocol *control_protocol); + +/*Control Framework Protocol Read*/ +int ControlProtocolRead(struct ControlProtocol *control_protocol, void *buf, size_t len); + +/*Control Framework Protocol Write*/ +int ControlProtocolWrite(struct ControlProtocol *control_protocol, const void *buf, size_t len); + +/*Control Framework Protocol Ioctl*/ +int ControlProtocolIoctl(struct ControlProtocol *control_protocol, int cmd, void *args); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/APP_Framework/Framework/control/shared/control_def.c b/APP_Framework/Framework/control/shared/control_def.c new file mode 100644 index 000000000..1e77cef62 --- /dev/null +++ b/APP_Framework/Framework/control/shared/control_def.c @@ -0,0 +1,364 @@ +/* +* 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 control_def.c + * @brief code for control framework + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2022-10-9 + */ + +#include + +/*using cirtular area to receive data*/ +#define PLC_DATA_LENGTH 1024 +struct CircularAreaApp *g_circular_area; +static pthread_t recv_plc_data_task; + +/*extern function*/ +extern void *ReceivePlcDataTask(void *parameter); + +#ifdef CONTROL_PROTOCOL_FINS +extern int FinsProtocolInit(struct ControlRecipe *p_recipe); +#endif + +/* +CONTROL FRAMEWORK READ DATA FORMAT: +| HEAD |device_id|read data length|read item count| data | +|2 Bytes| 2 Bytes | 2 Bytes | 2 Bytes |read data length Bytes| +*/ +#define CONTROL_DATA_HEAD_LENGTH 8 +#define CONTROL_DATA_HEAD_1 0xAA +#define CONTROL_DATA_HEAD_2 0xBB + +typedef int (*ControlProtocolInitFunc)(struct ControlRecipe *p_recipe); + +struct ControlProtocolInitParam +{ + int protocol_type; + const ControlProtocolInitFunc fn; +}; + +static struct ControlProtocolInitParam protocol_init[] = +{ +#ifdef CONTROL_PROTOCOL_FINS + { PROTOCOL_FINS, FinsProtocolInit }, +#endif + + { PROTOCOL_END, NULL }, +}; + +static int ControlProtocolInitDesc(struct ControlRecipe *p_recipe, struct ControlProtocolInitParam sub_protocol_desc[]) +{ + int i = 0; + int ret = 0; + for( i = 0; sub_protocol_desc[i].fn != NULL; i++ ) { + if (p_recipe->protocol_type == sub_protocol_desc[i].protocol_type) { + ret = sub_protocol_desc[i].fn(p_recipe); + printf("control protocol initialize %d %s\n", sub_protocol_desc[i].protocol_type, ret == 0 ? "success" : "failed"); + break; + } + } + return ret; +} + +static void FormatDataHeader(struct ControlRecipe *p_recipe) +{ + uint16_t plc_read_data_length = CONTROL_DATA_HEAD_LENGTH + p_recipe->total_data_length;//Head length is CONTROL_DATA_HEAD_LENGTH + uint8_t *data = p_recipe->protocol_data->data; + + data[0] = CONTROL_DATA_HEAD_1; + data[1] = CONTROL_DATA_HEAD_2; + data[2] = (p_recipe->device_id) >> 8; + data[3] = p_recipe->device_id; + data[4] = (plc_read_data_length) >> 8; + data[5] = plc_read_data_length; + data[6] = (p_recipe->read_item_count) >> 8; + data[7] = p_recipe->read_item_count; +} + +static uint16_t GetRecipeTotalDataLength(cJSON* read_item_list_json) +{ + uint16_t read_item_count = cJSON_GetArraySize(read_item_list_json); + uint16_t total_data_length = 0; + for (uint16_t read_item_index = 0; read_item_index < read_item_count; read_item_index++) { + cJSON* read_item_json = cJSON_GetArrayItem(read_item_list_json, read_item_index); + UniformValueType value_type = cJSON_GetObjectItem(read_item_json, "value_type")->valueint; + total_data_length += GetValueTypeMemorySize(value_type); + } + return total_data_length; +} + +static void ControlBasicSerialConfig(struct ControlRecipe *p_recipe, cJSON *p_recipe_file_json) +{ + cJSON *p_serial_config_json = cJSON_GetObjectItem(p_recipe_file_json, "serial_config"); + p_recipe->serial_config.baud_rate = cJSON_GetObjectItem(p_serial_config_json, "baud_rate")->valueint; + p_recipe->serial_config.data_bits = cJSON_GetObjectItem(p_serial_config_json, "data_bits")->valueint; + p_recipe->serial_config.stop_bits = cJSON_GetObjectItem(p_serial_config_json, "stop_bits")->valueint; + p_recipe->serial_config.check_mode = cJSON_GetObjectItem(p_serial_config_json, "check_mode")->valueint; + printf("Serial_config: baud_rate: %d, data_bits: %d, stop_bits: %d, check_mode is %d\n", + p_recipe->serial_config.baud_rate, p_recipe->serial_config.data_bits, p_recipe->serial_config.stop_bits, p_recipe->serial_config.check_mode); +} + +static void ControlBasicSocketConfig(struct ControlRecipe *p_recipe, cJSON *p_recipe_file_json) +{ + cJSON *p_socket_address_json = cJSON_GetObjectItem(p_recipe_file_json, "socket_config"); + char *plc_ip_string = cJSON_GetObjectItem(p_socket_address_json, "plc_ip")->valuestring; + sscanf(plc_ip_string, "%d.%d.%d.%d", + p_recipe->socket_config.plc_ip, + p_recipe->socket_config.plc_ip + 1, + p_recipe->socket_config.plc_ip + 2, + p_recipe->socket_config.plc_ip + 3); + + char *local_ip_string = cJSON_GetObjectItem(p_socket_address_json, "local_ip")->valuestring; + sscanf(local_ip_string, "%d.%d.%d.%d", + p_recipe->socket_config.local_ip, + p_recipe->socket_config.local_ip + 1, + p_recipe->socket_config.local_ip + 2, + p_recipe->socket_config.local_ip + 3); + + char *gateway_ip_string = cJSON_GetObjectItem(p_socket_address_json, "gateway")->valuestring; + sscanf(gateway_ip_string, "%d.%d.%d.%d", + p_recipe->socket_config.gateway, + p_recipe->socket_config.gateway + 1, + p_recipe->socket_config.gateway + 2, + p_recipe->socket_config.gateway + 3); + + char *netmask_string = cJSON_GetObjectItem(p_socket_address_json, "netmask")->valuestring; + sscanf(netmask_string, "%d.%d.%d.%d", + p_recipe->socket_config.netmask, + p_recipe->socket_config.netmask + 1, + p_recipe->socket_config.netmask + 2, + p_recipe->socket_config.netmask + 3); + + p_recipe->socket_config.port = cJSON_GetObjectItem(p_socket_address_json, "port")->valueint; + printf("Socket_config: local ip is %s, plc ip is %s, gateway is %s, port is %d.\n", + local_ip_string, plc_ip_string, gateway_ip_string, p_recipe->socket_config.port); +} + +void ControlPrintList(char name[5], uint8_t *number_list, uint16_t length) +{ + printf("\n******************%5s****************\n", name); + for (int32_t i = 0;i < length;i ++) { + printf("%03x ", number_list[i]); + } + printf("\n**************************************\n"); +} + +int ControlConnectSocket(BasicSocketPlc *p_plc) +{ + if (p_plc->socket >= 0) + return 0; + + struct sockaddr_in plc_addr_in; + plc_addr_in.sin_family = AF_INET; + plc_addr_in.sin_port = htons(p_plc->port); + + char ip_string[20] = {0}; + sprintf(ip_string, "%u.%u.%u.%u", p_plc->ip[0], p_plc->ip[1], p_plc->ip[2], p_plc->ip[3]); + plc_addr_in.sin_addr.s_addr = inet_addr(ip_string); + memset(&(plc_addr_in.sin_zero), 0, sizeof(plc_addr_in.sin_zero)); + + int plc_socket = socket(AF_INET, SOCK_STREAM, 0); + int flag = 1; + + struct timeval timeout; + timeout.tv_sec = 10; + timeout.tv_usec = 0; + if (setsockopt(plc_socket, IPPROTO_TCP, TCP_NODELAY, (void*)&flag, sizeof(flag)) < 0) { + printf("Error setting TCP_NODELAY function!\n"); + return -1; + } + if (setsockopt(plc_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, (socklen_t)sizeof(struct timeval)) < 0) { + printf("Error setting SO_SNDTIMEO function!\n"); + return -2; + } + if (setsockopt(plc_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, (socklen_t)sizeof(struct timeval)) < 0) { + printf("Error setting SO_RCVTIMEO function!\n"); + return -3; + } + + if (plc_socket < 0) { + printf("Get socket error!\n"); + return -4; + } + + if (connect(plc_socket, (struct sockaddr*)&plc_addr_in, sizeof(struct sockaddr)) == -1) { + printf("Connect plc socket failed!\n"); + closesocket(plc_socket); + return -5; + } else { + p_plc->socket = plc_socket; + printf("Connect plc socket success!\n"); + return 0; + } +} + +int ControlDisconnectSocket(BasicSocketPlc *p_plc) +{ + if (p_plc->socket < 0) + return -1; + + int error = closesocket(p_plc->socket); + if (0 == error) + p_plc->socket = -1; + + return error; +} + +int ControlProtocolOpenDef(struct ControlProtocol *control_protocol) +{ + g_circular_area = CircularAreaAppInit(PLC_DATA_LENGTH); + if (NULL == g_circular_area) { + printf("%s CircularAreaInit error\n", __func__); + return -1; + } + + control_protocol->args = (void *)g_circular_area; + + pthread_attr_t attr; + attr.schedparam.sched_priority = 19; + attr.stacksize = 2048; + + PrivTaskCreate(&recv_plc_data_task, &attr, &ReceivePlcDataTask, control_protocol); + PrivTaskStartup(&recv_plc_data_task); +} + +int ControlProtocolCloseDef(void) +{ + CircularAreaAppRelease(g_circular_area); + + PrivTaskDelete(recv_plc_data_task, 0); + + return 0; +} + +uint8_t GetValueTypeMemorySize(UniformValueType uniform_value_type) +{ + switch (uniform_value_type) + { + case UNIFORM_BOOL: + case UNIFORM_INT8: + case UNIFORM_UINT8: + return 1; + break; + case UNIFORM_INT16: + case UNIFORM_UINT16: + return 2; + break; + case UNIFORM_INT32: + case UNIFORM_UINT32: + case UNIFORM_FLOAT: + return 4; + break; + case UNIFORM_DOUBLE: + return 8; + break; + default: + break; + } + + return 0; +} + +int ControlPeripheralInit(struct ControlRecipe *p_recipe) +{ + switch (p_recipe->communication_type) + { + case 0://Socket Init + lwip_config_tcp(0, p_recipe->socket_config.local_ip, p_recipe->socket_config.netmask, p_recipe->socket_config.gateway); + break; + case 1://Serial Init + // Uart485Init(p_recipe->serial_config.baud_rate, p_recipe->serial_config.data_bits, + // p_recipe->serial_config.stop_bits, p_recipe->serial_config.check_mode); + break; + default: + break; + } + + return 0; +} + +int RecipeBasicInformation(struct ControlRecipe *p_recipe, int protocol_type, cJSON *p_recipe_file_json) +{ + if (protocol_type != (ProtocolType)(cJSON_GetObjectItem(p_recipe_file_json, "protocol_type")->valueint)) { + printf("protocol type not match!\n"); + return -1; + } + p_recipe->protocol_type = protocol_type; + + p_recipe->device_id = cJSON_GetObjectItem(p_recipe_file_json, "device_id")->valueint; + strncpy(p_recipe->device_name, cJSON_GetObjectItem(p_recipe_file_json, "device_name")->valuestring, 20); + p_recipe->read_period = cJSON_GetObjectItem(p_recipe_file_json, "read_period")->valueint; + p_recipe->communication_type = cJSON_GetObjectItem(p_recipe_file_json, "communication_type")->valueint; + + printf("\n**************** RECIPE BASIC INFORMATION ******************\n"); + printf("\nprotocol_type: %d, communication_type: %d, device_id: %d, device_name: %s, read_period is %d\n", + p_recipe->protocol_type, p_recipe->communication_type, p_recipe->device_id, p_recipe->device_name, p_recipe->read_period); + + switch (p_recipe->communication_type) + { + case 0://Socket Config + ControlBasicSocketConfig(p_recipe, p_recipe_file_json); + break; + case 1://Serial Config + ControlBasicSerialConfig(p_recipe, p_recipe_file_json); + break; + default: + break; + } + + printf("\n************************************************************\n"); +} + +void RecipeReadVariableItem(struct ControlRecipe *p_recipe, int protocol_type, cJSON *p_recipe_file_json) +{ + int ret = 0; + + ProtocolFormatInfo protocol_format_info; + memset(&protocol_format_info, 0, sizeof(ProtocolFormatInfo)); + + cJSON *read_item_list_json = cJSON_GetObjectItem(p_recipe_file_json, "read_item_list"); + if (cJSON_IsArray(read_item_list_json)) { + /*Get Recipe Variable Item Count and total length*/ + p_recipe->read_item_count = cJSON_GetArraySize(read_item_list_json); + p_recipe->total_data_length = GetRecipeTotalDataLength(read_item_list_json); + + /*Malloc Read Data Pointer, Reference "CONTROL FRAMEWORK READ DATA FORMAT"*/ + p_recipe->protocol_data = PrivMalloc(sizeof(struct ProtocolData)); + p_recipe->protocol_data->data = PrivMalloc(CONTROL_DATA_HEAD_LENGTH + p_recipe->total_data_length); + p_recipe->protocol_data->data_length = CONTROL_DATA_HEAD_LENGTH + p_recipe->total_data_length; + memset(p_recipe->protocol_data->data, 0, p_recipe->protocol_data->data_length); + + /*Init The Control Protocol*/ + ControlProtocolInitDesc(p_recipe, protocol_init); + + /*Format Data Header, Reference "CONTROL FRAMEWORK READ DATA FORMAT"*/ + FormatDataHeader(p_recipe); + + for (uint16_t read_item_index = 0; read_item_index < p_recipe->read_item_count; read_item_index ++) { + cJSON *read_single_item_json = cJSON_GetArrayItem(read_item_list_json, read_item_index); + + protocol_format_info.read_single_item_json = read_single_item_json; + protocol_format_info.read_item_index = read_item_index; + + /*Format Protocol Cmd By Analyze Variable Item One By One*/ + ret = p_recipe->ControlProtocolFormatCmd(p_recipe, &protocol_format_info); + if (ret < 0) { + printf("%s read %d item failed!\n", __func__, read_item_index); + continue; + } + } + } +} + diff --git a/APP_Framework/Framework/control/shared/control_def.h b/APP_Framework/Framework/control/shared/control_def.h new file mode 100644 index 000000000..fafb7d6f2 --- /dev/null +++ b/APP_Framework/Framework/control/shared/control_def.h @@ -0,0 +1,161 @@ +/* +* 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 control_def.h + * @brief DEFINE code for control framework + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2022-10-08 + */ + +#ifndef CONTROL_DEF_H +#define CONTROL_DEF_H + +#include +#include +#include +#include + +#ifdef LIB_USING_CJSON +#include +#endif + +#ifdef BSP_USING_LWIP +#include "lwip/sys.h" +#include "lwip/sockets.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define CONTROL_PARAM_CHECK(param) \ + do \ + { \ + if(NULL == param) { \ + KPrintf("CONTROL CHECK FAILED ...%s %d %s is NULL.\n", __FUNCTION__, __LINE__, #param); \ + return -1; \ + } \ + }while (0) + +#ifdef BSP_USING_LWIP +#define socket_write lwip_write +#define socket_read lwip_read +#endif + +typedef enum +{ + UNIFORM_BOOL = 1, + UNIFORM_INT8, + UNIFORM_INT16, + UNIFORM_INT32, + UNIFORM_UINT8, + UNIFORM_UINT16, + UNIFORM_UINT32, + UNIFORM_DOUBLE, + UNIFORM_FLOAT +}UniformValueType; + +typedef struct +{ + uint8_t ip[4]; + uint16_t port; + int32_t socket; + int8_t secondary_connect_flag;//0: enble, no connected; 1: enable, connected; -1: disable +}BasicSocketPlc; + +typedef struct +{ + uint16_t command_length; + uint16_t data_size; + uint8_t *p_command; + uint8_t *p_data; +}BasicPlcDataInfo; + +typedef struct +{ + cJSON *read_single_item_json; + uint16_t read_item_index;//Variable item index(1 ++) +}ProtocolFormatInfo; + +struct ProtocolData +{ + uint8_t *data; + uint16_t data_length; +}; + +struct SerialConfig +{ + uint32_t baud_rate; + uint8_t data_bits; + uint8_t stop_bits; + uint8_t check_mode; +}; + +struct SocketConfig +{ + uint16_t port; + uint8_t plc_ip[4]; + uint8_t local_ip[4]; + uint8_t gateway[4]; + uint8_t netmask[4]; +}; + +struct ControlRecipe +{ + char device_name[20]; + uint16_t device_id; + uint16_t read_period; + uint16_t read_item_count; + uint16_t total_data_length; + uint8_t communication_type; + + ProtocolType protocol_type; + + void *read_item; + + struct SerialConfig serial_config; + struct SocketConfig socket_config; + + struct ProtocolData *protocol_data; + + int (*ControlProtocolFormatCmd)(struct ControlRecipe *p_recipe, ProtocolFormatInfo *protocol_format_info); +}; + +/*Get Value Type Memory Size*/ +uint8_t GetValueTypeMemorySize(UniformValueType uniform_value_type); + +/*Get basic information from recipe file*/ +int RecipeBasicInformation(struct ControlRecipe *p_recipe, int protocol_type, cJSON *p_recipe_file_json); + +/*Get the variable need to read from recipe file*/ +void RecipeReadVariableItem(struct ControlRecipe *p_recipe, int protocol_type, cJSON *p_recipe_file_json); + +int ControlPeripheralInit(struct ControlRecipe *p_recipe); + +void ControlPrintList(char name[5], uint8_t *number_list, uint16_t length); + +int ControlConnectSocket(BasicSocketPlc *p_plc); + +int ControlDisconnectSocket(BasicSocketPlc *p_plc); + +int ControlProtocolOpenDef(struct ControlProtocol *control_protocol); + +int ControlProtocolCloseDef(void); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/APP_Framework/Applications/framework_init.c b/APP_Framework/Framework/framework_init.c similarity index 96% rename from APP_Framework/Applications/framework_init.c rename to APP_Framework/Framework/framework_init.c index 9612fd635..20d56ab29 100644 --- a/APP_Framework/Applications/framework_init.c +++ b/APP_Framework/Framework/framework_init.c @@ -15,6 +15,7 @@ extern int SensorFrameworkInit(void); extern int AdapterFrameworkInit(void); +extern int ControlFrameworkInit(void); extern int Adapter4GInit(void); extern int AdapterNbiotInit(void); @@ -73,6 +74,10 @@ static struct InitDesc framework[] = { "connection_framework", AdapterFrameworkInit }, #endif +#ifdef SUPPORT_CONTROL_FRAMEWORK + { "control_framework", ControlFrameworkInit }, +#endif + { "NULL", NULL }, }; @@ -229,6 +234,10 @@ int FrameworkInit(void) ConnectionDeviceFrameworkInit(framework); #endif +#ifdef SUPPORT_CONTROL_FRAMEWORK + ControlFrameworkInit(); +#endif + #ifdef LIB_LV lv_port_init(); #endif diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/Kconfig b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/Kconfig index 223f5e966..72eef20d3 100644 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/Kconfig +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/Kconfig @@ -49,6 +49,7 @@ menuconfig BSP_USING_SDIO if BSP_USING_SDIO source "$BSP_DIR/third_party_driver/sdio/Kconfig" endif + menuconfig BSP_USING_LCD bool "Using LCD device" default n @@ -56,6 +57,7 @@ menuconfig BSP_USING_LCD if BSP_USING_LCD source "$BSP_DIR/third_party_driver/lcd/Kconfig" endif + menuconfig BSP_USING_TOUCH bool "Using TOUCH device" default n diff --git a/Ubiquitous/XiZi_IIoT/path_kernel.mk b/Ubiquitous/XiZi_IIoT/path_kernel.mk index 3731ae559..917d6076c 100755 --- a/Ubiquitous/XiZi_IIoT/path_kernel.mk +++ b/Ubiquitous/XiZi_IIoT/path_kernel.mk @@ -440,6 +440,7 @@ endif endif +KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/general_functions/circular_area # KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/general_functions/list # ifeq ($(CONFIG_SUPPORT_SENSOR_FRAMEWORK), y) @@ -472,9 +473,11 @@ ifeq ($(CONFIG_SUPPORT_CONTROL_FRAMEWORK), y) KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control # KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control/shared # KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control/ipc_protocol # +KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control/ipc_protocol/include # KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control/ipc_protocol/modbus_tcp # KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control/ipc_protocol/modbus_uart # KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control/plc_protocol # +KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control/plc_protocol/include # KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control/plc_protocol/fins # KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control/plc_protocol/melsec # KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Framework/control/plc_protocol/opcua # From 49df16273422067511b046e0d53c343515595728 Mon Sep 17 00:00:00 2001 From: wuzheng Date: Tue, 22 Nov 2022 10:20:15 +0800 Subject: [PATCH 08/14] add softspi in xidatong-riscv64 --- APP_Framework/Applications/app_test/Kconfig | 3 + .../Applications/app_test/test_touch.c | 38 +++ .../examples/porting/lv_port_indev_template.c | 189 +++++++---- .../lib/lvgl/porting/lv_port_indev_template.c | 1 - .../third_party_driver/dvp/connect_dvp.c | 2 +- .../include/connect_touch.h | 4 +- .../third_party_driver/touch/connect_touch.c | 6 +- .../third_party_driver/touch/connect_touch.c | 8 +- .../third_party_driver/Kconfig | 16 + .../third_party_driver/Makefile | 4 + .../include/connect_soft_spi.h | 14 + .../third_party_driver/soft_spi/Kconfig | 43 +++ .../third_party_driver/soft_spi/Makefile | 3 + .../soft_spi/connect_soft_spi.c | 295 ++++++++++++++++++ 14 files changed, 550 insertions(+), 76 deletions(-) create mode 100644 Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/include/connect_soft_spi.h create mode 100644 Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/Kconfig create mode 100644 Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/Makefile create mode 100644 Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/connect_soft_spi.c diff --git a/APP_Framework/Applications/app_test/Kconfig b/APP_Framework/Applications/app_test/Kconfig index 3b9af83c3..1c2965bd2 100644 --- a/APP_Framework/Applications/app_test/Kconfig +++ b/APP_Framework/Applications/app_test/Kconfig @@ -150,6 +150,9 @@ menu "test app" 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 diff --git a/APP_Framework/Applications/app_test/test_touch.c b/APP_Framework/Applications/app_test/test_touch.c index a07a23792..87ae8d4b1 100644 --- a/APP_Framework/Applications/app_test/test_touch.c +++ b/APP_Framework/Applications/app_test/test_touch.c @@ -46,6 +46,9 @@ void TestTouch(void) #include #define NULL_PARAMETER 0 +#define LCD_DOT_TYPE 1 +#define LCD_SIZE 320 + void TestTouch(void) { @@ -55,17 +58,52 @@ void TestTouch(void) 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[20]; + 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(touch_fd); } diff --git a/APP_Framework/lib/lvgl/examples/porting/lv_port_indev_template.c b/APP_Framework/lib/lvgl/examples/porting/lv_port_indev_template.c index b2cae0498..d4812a07b 100644 --- a/APP_Framework/lib/lvgl/examples/porting/lv_port_indev_template.c +++ b/APP_Framework/lib/lvgl/examples/porting/lv_port_indev_template.c @@ -3,7 +3,7 @@ * */ - /*Copy this file as "lv_port_indev.c" and set this value to "1" to enable content*/ +/*Copy this file as "lv_port_indev.c" and set this value to "1" to enable content*/ #if 1 /********************* @@ -12,18 +12,18 @@ #include "lv_port_indev_template.h" #include "../../lvgl.h" -static int touch_fd = -1; -static TouchDataParam touch_data; +static int touch_fd = 0; /********************* * DEFINES *********************/ #define LV_USE_INDEV_TOUCHPAD 0x1u -#define LV_USE_INDEV_MOUSE 0x2u -#define LV_USE_INDEV_KEYPAD 0x4u -#define LV_USE_INDEV_ENCODER 0x8u -#define LV_USE_INDEV_BUTTUN 0x10u +#define LV_USE_INDEV_MOUSE 0x2u +#define LV_USE_INDEV_KEYPAD 0x4u +#define LV_USE_INDEV_ENCODER 0x8u +#define LV_USE_INDEV_BUTTUN 0x10u -#define LV_USE_INDEV LV_USE_INDEV_TOUCHPAD ///< modify this DEFINE to enable the indev device. e.g #define LV_USE_INDEV LV_USE_INDEV_TOUCHPAD | LV_USE_INDEV_KEYPAD +#define PRESS_FAILED_LIMIT 15 +#define LV_USE_INDEV LV_USE_INDEV_TOUCHPAD ///< modify this DEFINE to enable the indev device. e.g #define LV_USE_INDEV LV_USE_INDEV_TOUCHPAD | LV_USE_INDEV_KEYPAD /********************** * TYPEDEFS @@ -34,33 +34,36 @@ static TouchDataParam touch_data; **********************/ #if (LV_USE_INDEV & LV_USE_INDEV_TOUCHPAD) == LV_USE_INDEV_TOUCHPAD static void touchpad_init(void); -static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); -static bool touchpad_is_pressed(void); -static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y); +static void touchpad_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data); +// static bool touchpad_is_pressed(void); +// static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y); +static bool touchpad_is_pressed(struct TouchDataStandard *touch_data_ptr); +static void touchpad_get_xy(struct TouchDataStandard *touch_data_ptr, + lv_coord_t *x, lv_coord_t *y); #endif #if (LV_USE_INDEV & LV_USE_INDEV_MOUSE) == LV_USE_INDEV_MOUSE static void mouse_init(void); -static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); +static void mouse_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data); static bool mouse_is_pressed(void); -static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y); +static void mouse_get_xy(lv_coord_t *x, lv_coord_t *y); #endif #if (LV_USE_INDEV & LV_USE_INDEV_KEYPAD) == LV_USE_INDEV_KEYPAD static void keypad_init(void); -static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); +static void keypad_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data); static uint32_t keypad_get_key(void); #endif #if (LV_USE_INDEV & LV_USE_INDEV_ENCODER) == LV_USE_INDEV_ENCODER static void encoder_init(void); -static void encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); +static void encoder_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data); static void encoder_handler(void); #endif #if (LV_USE_INDEV & LV_USE_INDEV_BUTTUN) == LV_USE_INDEV_BUTTUN static void button_init(void); -static void button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data); +static void button_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data); static int8_t button_get_pressed_id(void); static bool button_is_pressed(uint8_t id); #endif @@ -69,23 +72,23 @@ static bool button_is_pressed(uint8_t id); * STATIC VARIABLES **********************/ #if (LV_USE_INDEV & LV_USE_INDEV_TOUCHPAD) == LV_USE_INDEV_TOUCHPAD -lv_indev_t * indev_touchpad; +lv_indev_t *indev_touchpad; #endif #if (LV_USE_INDEV & LV_USE_INDEV_MOUSE) == LV_USE_INDEV_MOUSE -lv_indev_t * indev_mouse; +lv_indev_t *indev_mouse; #endif #if (LV_USE_INDEV & LV_USE_INDEV_KEYPAD) == LV_USE_INDEV_KEYPAD -lv_indev_t * indev_keypad; +lv_indev_t *indev_keypad; #endif #if (LV_USE_INDEV & LV_USE_INDEV_ENCODER) == LV_USE_INDEV_ENCODER -lv_indev_t * indev_encoder; +lv_indev_t *indev_encoder; #endif #if (LV_USE_INDEV & LV_USE_INDEV_BUTTUN) == LV_USE_INDEV_BUTTUN -lv_indev_t * indev_button; +lv_indev_t *indev_button; #endif static int32_t encoder_diff; @@ -144,7 +147,7 @@ void lv_port_indev_init(void) indev_mouse = lv_indev_drv_register(&indev_drv); /*Set cursor. For simplicity set a HOME symbol now.*/ - lv_obj_t * mouse_cursor = lv_img_create(lv_scr_act()); + lv_obj_t *mouse_cursor = lv_img_create(lv_scr_act()); lv_img_set_src(mouse_cursor, LV_SYMBOL_HOME); lv_indev_set_cursor(indev_mouse, mouse_cursor); #endif @@ -169,8 +172,6 @@ void lv_port_indev_init(void) *`lv_indev_set_group(indev_keypad, group);`*/ #endif - - #if (LV_USE_INDEV & LV_USE_INDEV_ENCODER) == LV_USE_INDEV_ENCODER /*------------------ * Encoder @@ -207,8 +208,8 @@ void lv_port_indev_init(void) /*Assign buttons to points on the screen*/ static const lv_point_t btn_points[2] = { - {10, 10}, /*Button 0 -> x:10; y:10*/ - {40, 100}, /*Button 1 -> x:40; y:100*/ + {10, 10}, /*Button 0 -> x:10; y:10*/ + {40, 100}, /*Button 1 -> x:40; y:100*/ }; lv_indev_set_button_points(indev_button, btn_points); #endif @@ -225,27 +226,37 @@ void lv_port_indev_init(void) /*Initialize your touchpad*/ static void touchpad_init(void) { - touch_fd = PrivOpen(PRIV_TOUCH_DEV,O_RDWR); - if(touch_fd >= 0) { + touch_fd = PrivOpen(PRIV_TOUCH_DEV, O_RDWR); + if (touch_fd >= 0) + { printf("touch fd = %d\n",touch_fd); - } else { - printf("open %s touch fd = %d failed.\n",PRIV_TOUCH_DEV,touch_fd); - touch_fd = -1; } + else + { + printf("open %s touch fd = %d failed.\n", PRIV_TOUCH_DEV, touch_fd); + } + /*Your code comes here*/ } +// static struct TouchDataStandard touch_data; + /*Will be called by the library to read the touchpad*/ -static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) +static void touchpad_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) { static lv_coord_t last_x = 0; static lv_coord_t last_y = 0; + static struct TouchDataStandard touch_data; + /*Save the pressed coordinates and the state*/ - if(touchpad_is_pressed()) { - touchpad_get_xy(&last_x, &last_y); + if (touchpad_is_pressed(&touch_data)) + { + touchpad_get_xy(&touch_data, &last_x, &last_y); data->state = LV_INDEV_STATE_PR; - } else { + } + else + { data->state = LV_INDEV_STATE_REL; } @@ -255,34 +266,68 @@ static void touchpad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) } /*Return true is the touchpad is pressed*/ -static bool touchpad_is_pressed(void) +// static bool touchpad_is_pressed(void) +// { +// int ret; +// /*Your code comes here*/ +// // memset(&touch_data, 0 ,sizeof(TouchDataParam)); +// memset(&touch_data, 0 ,sizeof(struct TouchDataStandard)); +// ret = PrivRead(touch_fd, &touch_data, 1); +// if (ret && touch_data.x >= 0 && touch_data.x < MY_INDEV_X +// && touch_data.y >= 0 && touch_data.y < MY_INDEV_Y) +// { +// // printf("touch x %d touch y %d\n",touch_data.x,touch_data.y); +// return true; +// } + +// return false; +// } + +uint32_t press_failed_cnt = 0; +static bool touchpad_is_pressed(struct TouchDataStandard *touch_data_ptr) { int ret; /*Your code comes here*/ - memset(&touch_data, 0 ,sizeof(TouchDataParam)); - - if (touch_fd < 0) { - return false; - } - - ret = PrivRead(touch_fd, &touch_data, 1); - if(ret && touch_data.x >= 0 && touch_data.x < MY_INDEV_X && touch_data.y >= 0 && touch_data.y < MY_INDEV_Y) + memset(touch_data_ptr, 0, sizeof(struct TouchDataStandard)); + ret = PrivRead(touch_fd, touch_data_ptr, 1); + if (ret) { - printf("touch x %d touch y %d\n",touch_data.x,touch_data.y); - return true; + if (touch_data_ptr->x > 0 && touch_data_ptr->x < MY_INDEV_X && touch_data_ptr->y > 0 && touch_data_ptr->y < MY_INDEV_Y) + { + press_failed_cnt = 0; + return true; + } + else + { + press_failed_cnt++; + if (press_failed_cnt >= PRESS_FAILED_LIMIT) + { + PrivClose(touch_fd); + touchpad_init(); + press_failed_cnt = 0; + } + } } - return false; } /*Get the x and y coordinates if the touchpad is pressed*/ -static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y) +static void touchpad_get_xy(struct TouchDataStandard *touch_data_ptr, + lv_coord_t *x, lv_coord_t *y) { /*Your code comes here*/ - (*x) = touch_data.x; - (*y) = touch_data.y; + (*x) = touch_data_ptr->x; + (*y) = touch_data_ptr->y; } + +// static void touchpad_get_xy(lv_coord_t * x, lv_coord_t * y) +// { +// /*Your code comes here*/ + +// (*x) = touch_data.x; +// (*y) = touch_data.y; +// } #endif #if (LV_USE_INDEV & LV_USE_INDEV_MOUSE) == LV_USE_INDEV_MOUSE @@ -297,15 +342,18 @@ static void mouse_init(void) } /*Will be called by the library to read the mouse*/ -static void mouse_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) +static void mouse_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) { /*Get the current x and y coordinates*/ mouse_get_xy(&data->point.x, &data->point.y); /*Get whether the mouse button is pressed or released*/ - if(mouse_is_pressed()) { + if (mouse_is_pressed()) + { data->state = LV_INDEV_STATE_PR; - } else { + } + else + { data->state = LV_INDEV_STATE_REL; } } @@ -319,7 +367,7 @@ static bool mouse_is_pressed(void) } /*Get the x and y coordinates if the mouse is pressed*/ -static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y) +static void mouse_get_xy(lv_coord_t *x, lv_coord_t *y) { /*Your code comes here*/ @@ -328,8 +376,6 @@ static void mouse_get_xy(lv_coord_t * x, lv_coord_t * y) } #endif - - #if (LV_USE_INDEV & LV_USE_INDEV_KEYPAD) == LV_USE_INDEV_KEYPAD /*------------------ * Keypad @@ -342,7 +388,7 @@ static void keypad_init(void) } /*Will be called by the library to read the mouse*/ -static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) +static void keypad_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) { static uint32_t last_key = 0; @@ -351,11 +397,13 @@ static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) /*Get whether the a key is pressed and save the pressed key*/ uint32_t act_key = keypad_get_key(); - if(act_key != 0) { + if (act_key != 0) + { data->state = LV_INDEV_STATE_PR; /*Translate the keys to LVGL control characters according to your key definitions*/ - switch(act_key) { + switch (act_key) + { case 1: act_key = LV_KEY_NEXT; break; @@ -374,7 +422,9 @@ static void keypad_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) } last_key = act_key; - } else { + } + else + { data->state = LV_INDEV_STATE_REL; } @@ -390,8 +440,6 @@ static uint32_t keypad_get_key(void) } #endif - - #if (LV_USE_INDEV & LV_USE_INDEV_ENCODER) == LV_USE_INDEV_ENCODER /*------------------ * Encoder @@ -404,7 +452,7 @@ static void encoder_init(void) } /*Will be called by the library to read the encoder*/ -static void encoder_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) +static void encoder_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) { data->enc_diff = encoder_diff; @@ -433,7 +481,7 @@ static void button_init(void) } /*Will be called by the library to read the button*/ -static void button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) +static void button_read(lv_indev_drv_t *indev_drv, lv_indev_data_t *data) { static uint8_t last_btn = 0; @@ -441,10 +489,13 @@ static void button_read(lv_indev_drv_t * indev_drv, lv_indev_data_t * data) /*Get the pressed button's ID*/ int8_t btn_act = button_get_pressed_id(); - if(btn_act >= 0) { + if (btn_act >= 0) + { data->state = LV_INDEV_STATE_PR; last_btn = btn_act; - } else { + } + else + { data->state = LV_INDEV_STATE_REL; } @@ -458,9 +509,11 @@ static int8_t button_get_pressed_id(void) uint8_t i; /*Check to buttons see which is being pressed (assume there are 2 buttons)*/ - for(i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) + { /*Return the pressed button's ID*/ - if(button_is_pressed(i)) { + if (button_is_pressed(i)) + { return i; } } diff --git a/APP_Framework/lib/lvgl/porting/lv_port_indev_template.c b/APP_Framework/lib/lvgl/porting/lv_port_indev_template.c index 0a3321fed..aa7189e42 100644 --- a/APP_Framework/lib/lvgl/porting/lv_port_indev_template.c +++ b/APP_Framework/lib/lvgl/porting/lv_port_indev_template.c @@ -12,7 +12,6 @@ #include "lv_port_indev_template.h" #include "../lvgl.h" -#include static int touch_fd = 0; /********************* diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c index c78b242a6..c2af08697 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c @@ -121,8 +121,8 @@ static uint32 dvpRead(void *dev, struct BusBlockReadParam *read_param) static uint32 dvpDrvConfigure(void *drv, struct BusConfigureInfo *args) { - x_err_t ret = EOK; + int cmd_type = args->configure_cmd; struct CameraCfg* tmp_cfg; switch (cmd_type) diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h index fcfc71358..3ac99e392 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_touch.h @@ -65,8 +65,8 @@ typedef enum _touch_event #define GTP_REG_VERSION 0x8140 #define LCD_SIZE 320 -#define TOUCH_WIDTH 1080 -#define TOUCH_HEIGHT 720 +#define TOUCH_WIDTH 1000 +#define TOUCH_HEIGHT 660 #define CFG_GROUP_LEN(p_cfg_grp) (sizeof(p_cfg_grp) / sizeof(p_cfg_grp[0])) diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c index d05d9372b..54efb4a73 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/touch/connect_touch.c @@ -278,7 +278,7 @@ static uint32 TouchRead(void* dev, struct BusBlockReadParam* read_param) struct TouchDataStandard* data = (struct TouchDataStandard*)read_param->buffer; - result = KSemaphoreObtain(touch_sem, 10); + result = KSemaphoreObtain(touch_sem, 100); // if (EOK == result) // { memset(TOUCHRECDATA, 0, 24); @@ -292,8 +292,8 @@ static uint32 TouchRead(void* dev, struct BusBlockReadParam* read_param) { ts_event.fingers[i].x = ((((uint32_t)TOUCHRECDATA[(i * 4) + 5]) << 8) | (uint32_t)TOUCHRECDATA[(i * 4) + 4]) & 0x00000FFF; // 12 bits of X coord ts_event.fingers[i].y = ((((uint32_t)TOUCHRECDATA[(i * 4) + 7]) << 8) | (uint32_t)TOUCHRECDATA[(i * 4) + 6]) & 0x00000FFF; - uint32_t pos_y = 308 - ts_event.fingers[i].x *LCD_SIZE/TOUCH_WIDTH; - ts_event.fingers[i].x = ts_event.fingers[i].y *LCD_SIZE/TOUCH_HEIGHT; + uint32_t pos_y = 320 > ts_event.fingers[i].x *LCD_SIZE/TOUCH_WIDTH?320 - ts_event.fingers[i].x *LCD_SIZE/TOUCH_WIDTH:0; + ts_event.fingers[i].x = ts_event.fingers[i].y *LCD_SIZE/TOUCH_HEIGHT>6?ts_event.fingers[i].y *LCD_SIZE/TOUCH_HEIGHT-6:0; ts_event.fingers[i].y = pos_y; ts_event.fingers[i].fingerID = (uint32_t)TOUCHRECDATA[(i * 4) + 7] >> 4; // finger that did the touch // printf("fingers[%d] x %d y %d id %d\n",i,ts_event.fingers[i].x,ts_event.fingers[i].y,ts_event.fingers[i].fingerID); diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/touch/connect_touch.c b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/touch/connect_touch.c index 8fd57894b..05b6d2ade 100644 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/touch/connect_touch.c +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/touch/connect_touch.c @@ -359,7 +359,8 @@ static uint32 TouchRead(void *dev, struct BusBlockReadParam *read_param) result = KSemaphoreObtain(touch_sem, 1000); if (EOK == result) { - if(GetTouchEvent(&touch_point, &touch_event)) + ret = GetTouchEvent(&touch_point, &touch_event); + if(ret > 0) { data->x = abs(LCD_WIDTH - touch_point.X); data->y = abs(LCD_HEIGHT - touch_point.Y); @@ -369,6 +370,11 @@ static uint32 TouchRead(void *dev, struct BusBlockReadParam *read_param) read_param->read_length = read_param->size; ret = EOK; + } + else + { + ret = -ERROR; + read_param->read_length = -ERROR; } SemReleaseFlag = 0; } diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/Kconfig b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/Kconfig index 812afe099..4638d3dce 100755 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/Kconfig +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/Kconfig @@ -91,3 +91,19 @@ select RESOURCES_WDT if BSP_USING_WDT source "$BSP_DIR/third_party_driver/watchdog/Kconfig" endif + +menuconfig BSP_USING_WDT +bool "Using WATCHDOG device" +default n +select RESOURCES_WDT +if BSP_USING_WDT +source "$BSP_DIR/third_party_driver/watchdog/Kconfig" +endif + +menuconfig BSP_USING_SOFT_SPI +bool "Using SOFT_SPI device" +default n +select RESOURCES_SOFT_SPI +if BSP_USING_SOFT_SPI +source "$BSP_DIR/third_party_driver/soft_spi/Kconfig" +endif diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/Makefile b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/Makefile index acb338501..14ce2784e 100644 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/Makefile +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/Makefile @@ -48,4 +48,8 @@ ifeq ($(CONFIG_BSP_USING_WDT),y) SRC_DIR += watchdog endif +ifeq ($(CONFIG_BSP_USING_SOFT_SPI),y) + SRC_DIR += soft_spi +endif + include $(KERNEL_ROOT)/compiler.mk diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/include/connect_soft_spi.h b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/include/connect_soft_spi.h new file mode 100644 index 000000000..687c1383d --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/include/connect_soft_spi.h @@ -0,0 +1,14 @@ +#ifndef CONNECT_TF_H +#define CONNECT_TF_H + +#ifdef __cplusplus +extern "C" { +#endif + +int HwSoftSPIInit(void); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/Kconfig b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/Kconfig new file mode 100644 index 000000000..73b7f7c4f --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/Kconfig @@ -0,0 +1,43 @@ +if BSP_USING_SOFT_SPI + config SOFT_SPI_BUS_NAME + string "soft spi bus 1 name" + default "soft_spi1_bus1" + + config SOFT_SPI_DEVICE_NAME + string "soft spi dev 1 name" + default "soft_spi1_dev1" + + config SOFT_SPI_DRV_NAME + string "soft spi drv 1 name" + default "soft_spi1_drv1" + + config SOFT_SPI_SCK + int "soft spi sck pin" + default 26 + + config SOFT_SPI_MOSI + int "soft spi mosi pin" + default 27 + + config SOFT_SPI_MISO + int "soft spi miso pin" + default 25 + + config SOFT_SPI_CS0_PIN + int "soft spi cs pin" + default 28 + + config SOFT_SPI_DEVICE_SLAVE_ID + int "soft spi slave id" + default 0 + + config SOFT_SPI_CHIP_SELECT + int "soft spi chip selected" + default 0 + + config SOFT_SPI_CLK_DELAY + int "clk in microsecond" + default 0 + +endif + diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/Makefile b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/Makefile new file mode 100644 index 000000000..8ccf2895c --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/Makefile @@ -0,0 +1,3 @@ +SRC_FILES := connect_soft_spi.c + +include $(KERNEL_ROOT)/compiler.mk diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/connect_soft_spi.c b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/connect_soft_spi.c new file mode 100644 index 000000000..9cf961d40 --- /dev/null +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/connect_soft_spi.c @@ -0,0 +1,295 @@ +#include +#include +#include +#include +#include "drv_io_config.h" +#include +#include +#include +#include + +#include +#include +#include + +static x_err_t softSPIinit(struct SpiDriver *spi_drv, struct BusConfigureInfo *cfg) +{ + NULL_PARAM_CHECK(spi_drv); + NULL_PARAM_CHECK(cfg); + + // mode CPOL = 0 CPHA = 0 + gpiohs_set_drive_mode(SOFT_SPI_CS0_PIN, GPIO_DM_OUTPUT); + gpiohs_set_pin(SOFT_SPI_CS0_PIN, GPIO_PV_HIGH); // set the cs gpio high + gpiohs_set_drive_mode(SOFT_SPI_SCK, GPIO_DM_OUTPUT); + gpiohs_set_drive_mode(SOFT_SPI_MOSI, GPIO_DM_OUTPUT); + gpiohs_set_drive_mode(SOFT_SPI_MISO, GPIO_DM_INPUT); + gpiohs_set_pin(SOFT_SPI_SCK, GPIO_PV_LOW); + KPrintf("%s init done\n", SOFT_SPI_BUS_NAME); + + return EOK; +} + +static uint32 softSpiDrvConfigure(void *drv, struct BusConfigureInfo *configure_info) +{ + NULL_PARAM_CHECK(drv); + NULL_PARAM_CHECK(configure_info); + + x_err_t ret = EOK; + struct SpiDriver *spi_drv = (struct SpiDriver *)drv; + struct SpiMasterParam *spi_param; + + switch (configure_info->configure_cmd) + { + case OPE_INT: + softSPIinit(spi_drv, configure_info); + break; + + case OPE_CFG: + break; + default: + + break; + } + + return ret; +} + +static void soft_spi_writebyte(struct SpiHardwareDevice *spi_dev, uint8_t data) +{ + int8_t i = 0; + uint8_t temp = 0; + for (i = 0; i < 8; i++) + { + temp = ((data & 0x80) == 0x80) ? 1 : 0; + data = data << 1; + gpiohs_set_pin(SOFT_SPI_SCK, GPIO_PV_LOW); + usleep(SOFT_SPI_CLK_DELAY); + if (0 == temp) + { + gpiohs_set_pin(SOFT_SPI_MOSI, GPIO_PV_LOW); + } + else + { + gpiohs_set_pin(SOFT_SPI_MOSI, GPIO_PV_HIGH); + } + gpiohs_set_pin(SOFT_SPI_SCK, GPIO_PV_HIGH); + usleep(SOFT_SPI_CLK_DELAY); + } + gpiohs_set_pin(SOFT_SPI_SCK, GPIO_PV_LOW); +} + +/* 读一个字节 */ +static uint8_t soft_spi_readbyte(struct SpiHardwareDevice *spi_dev) +{ + uint8_t i = 0; + uint8_t read_data = 0xFF; + for (i = 0; i < 8; i++) + { + read_data = read_data << 1; + gpiohs_set_pin(SOFT_SPI_SCK, GPIO_PV_LOW); + usleep(SOFT_SPI_CLK_DELAY); + gpiohs_set_pin(SOFT_SPI_SCK, GPIO_PV_HIGH); + usleep(SOFT_SPI_CLK_DELAY); + if (1 == gpiohs_get_pin(SOFT_SPI_MISO)) + { + read_data = read_data | 0x01; + } + } + return read_data; +} + +/* 读写一个字节 */ +// this funcition is unverify until now! +static uint8_t soft_spi_readwritebyte(struct SpiHardwareDevice *spi_dev, uint8_t data) +{ + uint8_t i = 0; + uint8_t temp = 0; + uint8_t read_data = 0xFF; + for (i = 0; i < 8; i++) + { + temp = ((data & 0x80) == 0x80) ? 1 : 0; + data = data << 1; + read_data = read_data << 1; + if (temp == 0) + { + gpiohs_set_pin(SOFT_SPI_MOSI, GPIO_PV_LOW); + } + else + { + gpiohs_set_pin(SOFT_SPI_MOSI, GPIO_PV_HIGH); + } + usleep(SOFT_SPI_CLK_DELAY); + gpiohs_set_pin(SOFT_SPI_SCK, GPIO_PV_HIGH); + usleep(SOFT_SPI_CLK_DELAY); + if (gpiohs_get_pin(SOFT_SPI_MISO) == 1) + { + read_data = read_data + 1; + } + } + return read_data; +} + +static uint32 softSpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiDataStandard *spi_datacfg) +{ + SpiDeviceParam *dev_param = (SpiDeviceParam *)(spi_dev->haldev.private_data); + + uint8 cs_gpio_pin = dev_param->spi_slave_param->spi_cs_gpio_pin; + const uint8_t *data_buff = spi_datacfg->tx_buff; + int data_length = spi_datacfg->length; + if (NONE == spi_datacfg->tx_buff) + { + data_length = 0; + } + + if (spi_datacfg->spi_chip_select) + { + gpiohs_set_pin(cs_gpio_pin, GPIO_PV_LOW); + } + + for (size_t i = 0; i < data_length; i++) + { + soft_spi_writebyte(spi_dev, data_buff[i]); + } + + if (spi_datacfg->spi_cs_release) + { + gpiohs_set_pin(cs_gpio_pin, GPIO_PV_HIGH); + } + spi_datacfg = spi_datacfg->next; + + return EOK; +} + +static uint32 softSpiReadData(struct SpiHardwareDevice *spi_dev, struct SpiDataStandard *spi_datacfg) +{ + SpiDeviceParam *dev_param = (SpiDeviceParam *)(spi_dev->haldev.private_data); + uint8 cs_gpio_pin = dev_param->spi_slave_param->spi_cs_gpio_pin; + uint8_t *recv_buff = spi_datacfg->rx_buff; + int recv_length = spi_datacfg->length; + + if (NONE == spi_datacfg->rx_buff) + { + recv_length = 0; + } + + if (spi_datacfg->spi_chip_select) + { + gpiohs_set_pin(cs_gpio_pin, GPIO_PV_LOW); + } + + for (size_t i = 0; i < recv_length; i++) + { + recv_buff[i] = soft_spi_readbyte(spi_dev); + } + + if (spi_datacfg->spi_cs_release) + { + gpiohs_set_pin(cs_gpio_pin, GPIO_PV_HIGH); + } + + spi_datacfg = spi_datacfg->next; + + return spi_datacfg->length; +} + +const struct SpiDevDone soft_spi_dev_done = { + .dev_close = NONE, + .dev_open = NONE, + .dev_read = softSpiReadData, + .dev_write = softSpiWriteData}; + +static int BoardSoftSpiBusInit(struct SpiBus *spi_bus, struct SpiDriver *spi_driver) +{ + x_err_t ret = EOK; + + /*Init the spi bus */ + ret = SpiBusInit(spi_bus, SOFT_SPI_BUS_NAME); + if (EOK != ret) + { + KPrintf("Board_Spi_init SpiBusInit error %d\n", ret); + return ERROR; + } + + /*Init the spi driver*/ + ret = SpiDriverInit(spi_driver, SOFT_SPI_DRV_NAME); + if (EOK != ret) + { + KPrintf("Board_Spi_init SpiDriverInit error %d\n", ret); + return ERROR; + } + + /*Attach the spi driver to the spi bus*/ + ret = SpiDriverAttachToBus(SOFT_SPI_DRV_NAME, SOFT_SPI_BUS_NAME); + if (EOK != ret) + { + KPrintf("Board_Spi_init SpiDriverAttachToBus error %d\n", ret); + return ERROR; + } + + return ret; +} + +static int BoardSoftSpiDevBend(void) +{ + x_err_t ret = EOK; + + static struct SpiHardwareDevice spi_device0; + memset(&spi_device0, 0, sizeof(struct SpiHardwareDevice)); + + static struct SpiSlaveParam spi_slaveparam0; + memset(&spi_slaveparam0, 0, sizeof(struct SpiSlaveParam)); + + spi_slaveparam0.spi_slave_id = SOFT_SPI_DEVICE_SLAVE_ID; + spi_slaveparam0.spi_cs_gpio_pin = SOFT_SPI_CS0_PIN; + spi_slaveparam0.spi_cs_select_id = SOFT_SPI_CHIP_SELECT; + + spi_device0.spi_param.spi_dma_param = NONE; + spi_device0.spi_param.spi_slave_param = &spi_slaveparam0; + + spi_device0.spi_dev_done = &(soft_spi_dev_done); + + ret = SpiDeviceRegister(&spi_device0, (void *)(&spi_device0.spi_param), SOFT_SPI_DEVICE_NAME); + if (EOK != ret) + { + KPrintf("Board_Spi_init SpiDeviceInit device %s error %d\n", SOFT_SPI_DEVICE_NAME, ret); + return ERROR; + } + + ret = SpiDeviceAttachToBus(SOFT_SPI_DEVICE_NAME, SOFT_SPI_BUS_NAME); + if (EOK != ret) + { + KPrintf("Board_Spi_init SpiDeviceAttachToBus device %s error %d\n", SOFT_SPI_DEVICE_NAME, ret); + return ERROR; + } + + return ret; +} + +int HwSoftSPIInit(void) +{ + x_err_t ret = EOK; + + static struct SpiBus spi_bus; + memset(&spi_bus, 0, sizeof(struct SpiBus)); + + static struct SpiDriver spi_driver; + memset(&spi_driver, 0, sizeof(struct SpiDriver)); + + spi_driver.configure = &(softSpiDrvConfigure); + + ret = BoardSoftSpiBusInit(&spi_bus, &spi_driver); + if (EOK != ret) + { + KPrintf("Board_Spi_Init error ret %u\n", ret); + return ERROR; + } + + ret = BoardSoftSpiDevBend(); + if (EOK != ret) + { + KPrintf("Board_Spi_Init error ret %u\n", ret); + return ERROR; + } + + return ret; +} From 2a8a11849da7928eb99b5503512af7f3defea9ee Mon Sep 17 00:00:00 2001 From: Liu_Weichao Date: Tue, 22 Nov 2022 11:05:57 +0800 Subject: [PATCH 09/14] feat add control_framework, support fins protocol, add control_io.c and function descriptions --- .../control/plc_protocol/fins/fins.c | 103 ++++++++++++++++-- .../Framework/control/shared/Makefile | 2 +- .../Framework/control/shared/control.c | 45 ++++++-- .../Framework/control/shared/control_def.c | 93 +++++++++++++++- .../Framework/control/shared/control_def.h | 19 ++-- .../Framework/control/shared/control_io.c | 48 ++++++++ .../Framework/control/shared/control_io.h | 51 +++++++++ 7 files changed, 326 insertions(+), 35 deletions(-) create mode 100644 APP_Framework/Framework/control/shared/control_io.c create mode 100644 APP_Framework/Framework/control/shared/control_io.h diff --git a/APP_Framework/Framework/control/plc_protocol/fins/fins.c b/APP_Framework/Framework/control/plc_protocol/fins/fins.c index 0cbfeec88..925cce00a 100644 --- a/APP_Framework/Framework/control/plc_protocol/fins/fins.c +++ b/APP_Framework/Framework/control/plc_protocol/fins/fins.c @@ -28,6 +28,12 @@ static uint8_t handshake_require_command[] = {0x46, 0x49, 0x4E, 0x53, 0x00, 0x00 static uint8_t handshake_respond_buff[24] = {0}; static uint8_t recv_buff[1024] = {0}; +/** + * @description: Fins Get Area Code + * @param area_char - area char + * @param type - fins data type + * @return success : area_char error : 0 + */ static uint8_t FinsAreaCode(char area_char, FinsDataType type) { uint8_t area_code = 0; @@ -42,7 +48,20 @@ static uint8_t FinsAreaCode(char area_char, FinsDataType type) return area_code; } -static uint16_t FinsCommandGenerate(uint8_t *p_command, uint16_t plc_ip_4, uint16_t pc_ip_4, FinsCommandCode command_code, char area_char, +/** + * @description: Fins Cmd Genetare + * @param p_command - command pointer + * @param plc_ip_4 - last plc ip + * @param local_ip_4 - last local ip + * @param command_code - fins command code + * @param area_char - area char + * @param data_type - fins data type + * @param start_address - fins cmd start address + * @param bit_address - fins cmd bit address + * @param data_length - fins cmd data length + * @return success : index error : 0 + */ +static uint16_t FinsCommandGenerate(uint8_t *p_command, uint16_t plc_ip_4, uint16_t local_ip_4, FinsCommandCode command_code, char area_char, FinsDataType data_type, uint16_t start_address, uint8_t bit_address, uint16_t data_length) { uint8_t index = 0; @@ -71,7 +90,7 @@ static uint16_t FinsCommandGenerate(uint8_t *p_command, uint16_t plc_ip_4, uint1 p_command[index++] = FINS_DA2; p_command[index++] = FINS_SNA; - p_command[index++] = pc_ip_4; + p_command[index++] = local_ip_4; p_command[index++] = FINS_SA2; p_command[index++] = FINS_SID; @@ -88,6 +107,12 @@ static uint16_t FinsCommandGenerate(uint8_t *p_command, uint16_t plc_ip_4, uint1 return index; } +/** + * @description: Fins Data Transform from Receive Buffer To Control-Data + * @param p_read_item - read item pointer + * @param recv_buff - receive buff + * @return success : 0 error : -1 + */ static int FinsTransformRecvBuffToData(FinsReadItem *p_read_item, uint8_t *recv_buff) { FinsDataInfo *p_fins_data_info = &(p_read_item->data_info); @@ -102,7 +127,7 @@ static int FinsTransformRecvBuffToData(FinsReadItem *p_read_item, uint8_t *recv_ if (FINS_COMMAND_CODE_READ == command_code) { uint16_t data_length = p_read_item->data_length; - ControlPrintList("DATA", recv_buff, data_length * (FINS_DATA_TYPE_BIT == p_read_item->data_type ? 1 : 2)); + ControlPrintfList("DATA", recv_buff, data_length * (FINS_DATA_TYPE_BIT == p_read_item->data_type ? 1 : 2)); printf("Receive data is "); if (FINS_DATA_TYPE_BIT == p_read_item->data_type) { @@ -128,6 +153,12 @@ static int FinsTransformRecvBuffToData(FinsReadItem *p_read_item, uint8_t *recv_ return 0; } +/** + * @description: Fins Protocol Handshake + * @param socket - socket + * @param local_ip_4 - last local ip + * @return success : 0 error : -1 -2 + */ static int FinsHandshake(int32_t socket, uint16_t local_ip_4) { handshake_require_command[18] = (uint8_t)(local_ip_4 >> 8); @@ -135,7 +166,7 @@ static int FinsHandshake(int32_t socket, uint16_t local_ip_4) uint8_t try_count = 0; while (try_count < 10) { - ControlPrintList("SEND", (uint8_t *)handshake_require_command, sizeof(handshake_require_command)); + ControlPrintfList("SEND", (uint8_t *)handshake_require_command, sizeof(handshake_require_command)); int32_t write_error = socket_write(socket, handshake_require_command, sizeof(handshake_require_command)); if (write_error < 0) { printf("Write socket error, errno is %d!", errno); @@ -144,7 +175,7 @@ static int FinsHandshake(int32_t socket, uint16_t local_ip_4) if (recv_length < 0) { printf("Read socket error, errno is %d!", errno); } else { - ControlPrintList("RECV", (uint8_t *)handshake_respond_buff, recv_length); + ControlPrintfList("RECV", (uint8_t *)handshake_respond_buff, recv_length); /*check fins handshake respond*/ uint8_t error_code = handshake_respond_buff[15]; @@ -166,6 +197,13 @@ static int FinsHandshake(int32_t socket, uint16_t local_ip_4) return -2; } +/** + * @description: Fins Get Data From Socket + * @param socket - socket + * @param p_read_item - read item pointer + * @param p_recipe - control recipe pointer + * @return success : 0 error : -1 -2 + */ static int FinsGetData(int32_t socket, FinsReadItem *p_read_item, struct ControlRecipe *p_recipe) { uint8_t try_count = 0; @@ -177,7 +215,7 @@ static int FinsGetData(int32_t socket, FinsReadItem *p_read_item, struct Control memset(recv_buff, 0, sizeof(recv_buff)); while (try_count < 10) { - ControlPrintList("SEND", p_base_data_info->p_command, p_base_data_info->command_length); + ControlPrintfList("SEND", p_base_data_info->p_command, p_base_data_info->command_length); try_count++; write_error = socket_write(socket, p_base_data_info->p_command, p_base_data_info->command_length); @@ -190,7 +228,7 @@ static int FinsGetData(int32_t socket, FinsReadItem *p_read_item, struct Control if (recv_length < 0) { printf("Read socket error, errno is %d!", errno); } else { - ControlPrintList("RECV", recv_buff, recv_length); + ControlPrintfList("RECV", recv_buff, recv_length); return FinsTransformRecvBuffToData(p_read_item, recv_buff); } } @@ -205,6 +243,20 @@ static int FinsGetData(int32_t socket, FinsReadItem *p_read_item, struct Control return -2; } +/** + * @description: Fins Data Info Init + * @param p_read_item - read item pointer + * @param plc_ip_4 - last plc ip + * @param local_ip_4 - last local ip + * @param command_code - fins command code + * @param area_char - area char + * @param data_type - fins data type + * @param start_address - fins cmd start address + * @param bit_address - fins cmd bit address + * @param data_length - fins cmd data length + * @param p_data - control-data pointer + * @return success : 0 error : -1 + */ static int FinsInitialDataInfo(FinsReadItem *p_read_item, uint16_t plc_ip_4, uint16_t local_ip_4, FinsCommandCode command_code, char area_char, FinsDataType data_type, uint16_t start_address, uint8_t bit_address, uint16_t data_length, uint8_t *p_data) { @@ -237,6 +289,11 @@ static int FinsInitialDataInfo(FinsReadItem *p_read_item, uint16_t plc_ip_4, uin return 0; } +/** + * @description: Fins Receive Plc Data Task + * @param parameter - parameter pointer + * @return + */ void *ReceivePlcDataTask(void *parameter) { int i = 0; @@ -289,6 +346,11 @@ void *ReceivePlcDataTask(void *parameter) } } +/** + * @description: Fins Protocol Open + * @param control_protocol - control protocol pointer + * @return success : 0 error + */ int FinsOpen(struct ControlProtocol *control_protocol) { ControlProtocolOpenDef(control_protocol); @@ -296,11 +358,25 @@ int FinsOpen(struct ControlProtocol *control_protocol) return 0; } +/** + * @description: Fins Protocol Close + * @param control_protocol - control protocol pointer + * @return success : 0 error + */ int FinsClose(struct ControlProtocol *control_protocol) { ControlProtocolCloseDef(); + + return 0; } +/** + * @description: Fins Protocol Read Data + * @param control_protocol - control protocol pointer + * @param buf - read data buffer + * @param len - read data length + * @return success : data length error : 0 + */ int FinsRead(struct ControlProtocol *control_protocol, void *buf, size_t len) { return CircularAreaAppRead(circular_area, buf, len); @@ -315,6 +391,12 @@ static struct ControlDone fins_protocol_done = ._ioctl = NULL, }; +/** + * @description: Fins Protocol Cmd Generate + * @param p_recipe - recipe pointer + * @param protocol_format_info - protocol format info pointer + * @return success : 0 error : -1 + */ int FinsProtocolFormatCmd(struct ControlRecipe *p_recipe, ProtocolFormatInfo *protocol_format_info) { int ret = 0; @@ -337,12 +419,17 @@ int FinsProtocolFormatCmd(struct ControlRecipe *p_recipe, ProtocolFormatInfo *pr cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "data_length")->valueint, p_recipe->protocol_data->data + last_data_length); - ControlPrintList("CMD", fins_read_item->data_info.base_data_info.p_command, fins_read_item->data_info.base_data_info.command_length); + ControlPrintfList("CMD", fins_read_item->data_info.base_data_info.p_command, fins_read_item->data_info.base_data_info.command_length); last_data_length = GetValueTypeMemorySize(fins_read_item->value_type); return ret; } +/** + * @description: Fins Protocol Init + * @param p_recipe - recipe pointer + * @return success : 0 error : -1 + */ int FinsProtocolInit(struct ControlRecipe *p_recipe) { struct ControlProtocol *p_control_protocol = CONTAINER_OF(p_recipe, struct ControlProtocol, recipe); diff --git a/APP_Framework/Framework/control/shared/Makefile b/APP_Framework/Framework/control/shared/Makefile index e26f03b9b..bd8322529 100755 --- a/APP_Framework/Framework/control/shared/Makefile +++ b/APP_Framework/Framework/control/shared/Makefile @@ -1,4 +1,4 @@ -SRC_FILES := control.c control_def.c +SRC_FILES := control.c control_def.c control_io.c include $(KERNEL_ROOT)/compiler.mk diff --git a/APP_Framework/Framework/control/shared/control.c b/APP_Framework/Framework/control/shared/control.c index 6ebd1394a..3834a327f 100755 --- a/APP_Framework/Framework/control/shared/control.c +++ b/APP_Framework/Framework/control/shared/control.c @@ -25,7 +25,7 @@ ControlProtocolType control_protocol; /** * @description: Control Framework Find certain Protocol - * @param + * @param void * @return Control Protocol pointer */ ControlProtocolType ControlProtocolFind(void) @@ -36,7 +36,7 @@ ControlProtocolType ControlProtocolFind(void) /** * @description: Control Framework Protocol Init * @param control_protocol - control protocol pointer - * @return success: 0 error : -1 + * @return success : 0 error : -1 */ static int ControlProtocolInit(ControlProtocolType control_protocol) { @@ -65,7 +65,7 @@ _out: * @description: Analyze Recipe * @param control_protocol - Control Protocol pointer * @param recipe_name - recipe name - * @return success: 0 error : -1 + * @return success : 0 error : -1 */ static int ControlAnalyzeRecipe(ControlProtocolType control_protocol, const char *recipe_name) { @@ -134,7 +134,11 @@ static int ControlAnalyzeRecipe(ControlProtocolType control_protocol, const char return 0; } -/*Control Framework Protocol Open*/ +/** + * @description: Control Framework Protocol Open + * @param control_protocol - Control Protocol pointer + * @return success : 0 error : -1 + */ int ControlProtocolOpen(struct ControlProtocol *control_protocol) { CONTROL_PARAM_CHECK(control_protocol); @@ -148,7 +152,11 @@ int ControlProtocolOpen(struct ControlProtocol *control_protocol) return ret; } -/*Control Framework Protocol Close*/ +/** + * @description: Control Framework Protocol Close + * @param control_protocol - Control Protocol pointer + * @return success : 0 error : -1 + */ int ControlProtocolClose(struct ControlProtocol *control_protocol) { CONTROL_PARAM_CHECK(control_protocol); @@ -162,7 +170,13 @@ int ControlProtocolClose(struct ControlProtocol *control_protocol) return ret; } -/*Control Framework Protocol Read Date*/ +/** + * @description: Control Framework Protocol Read Data + * @param control_protocol - Control Protocol pointer + * @param buf - read buffer + * @param len - read data length + * @return success : data length error : -1 + */ int ControlProtocolRead(struct ControlProtocol *control_protocol, void *buf, size_t len) { CONTROL_PARAM_CHECK(control_protocol); @@ -176,7 +190,13 @@ int ControlProtocolRead(struct ControlProtocol *control_protocol, void *buf, siz return ret; } -/*Control Framework Protocol Write Cmd*/ +/** + * @description: Control Framework Protocol Write Cmd + * @param control_protocol - Control Protocol pointer + * @param buf - write buffer + * @param len - write data length + * @return success : data length error : -1 + */ int ControlProtocolWrite(struct ControlProtocol *control_protocol, const void *buf, size_t len) { CONTROL_PARAM_CHECK(control_protocol); @@ -190,7 +210,13 @@ int ControlProtocolWrite(struct ControlProtocol *control_protocol, const void *b return ret; } -/*Control Framework Protocol Ioctl*/ +/** + * @description: Control Framework Protocol Ioctl + * @param control_protocol - Control Protocol pointer + * @param cmd - ioctl cmd + * @param args - args + * @return success : 0 error : -1 + */ int ControlProtocolIoctl(struct ControlProtocol *control_protocol, int cmd, void *args) { CONTROL_PARAM_CHECK(control_protocol); @@ -206,7 +232,8 @@ int ControlProtocolIoctl(struct ControlProtocol *control_protocol, int cmd, void /** * @description: Control Framework Init - * @return success: 0 error : -1 + * @param void + * @return success : 0 error : -1 */ int ControlFrameworkInit(void) { diff --git a/APP_Framework/Framework/control/shared/control_def.c b/APP_Framework/Framework/control/shared/control_def.c index 1e77cef62..61443a091 100644 --- a/APP_Framework/Framework/control/shared/control_def.c +++ b/APP_Framework/Framework/control/shared/control_def.c @@ -19,6 +19,7 @@ */ #include +#include /*using cirtular area to receive data*/ #define PLC_DATA_LENGTH 1024 @@ -58,6 +59,12 @@ static struct ControlProtocolInitParam protocol_init[] = { PROTOCOL_END, NULL }, }; +/** + * @description: Control Framework Sub_Protocol Desc Init + * @param p_recipe - Control recipe pointer + * @param sub_protocol_desc - sub_protocol desc + * @return success : 0 error : -1 + */ static int ControlProtocolInitDesc(struct ControlRecipe *p_recipe, struct ControlProtocolInitParam sub_protocol_desc[]) { int i = 0; @@ -72,6 +79,11 @@ static int ControlProtocolInitDesc(struct ControlRecipe *p_recipe, struct Contro return ret; } +/** + * @description: Control Framework Protocol Data Header Format + * @param p_recipe - Control recipe pointer + * @return + */ static void FormatDataHeader(struct ControlRecipe *p_recipe) { uint16_t plc_read_data_length = CONTROL_DATA_HEAD_LENGTH + p_recipe->total_data_length;//Head length is CONTROL_DATA_HEAD_LENGTH @@ -87,6 +99,11 @@ static void FormatDataHeader(struct ControlRecipe *p_recipe) data[7] = p_recipe->read_item_count; } +/** + * @description: Get Recipe Total Data Length + * @param read_item_list_json - read_item_list_json pointer + * @return success : total_data_length error : 0 + */ static uint16_t GetRecipeTotalDataLength(cJSON* read_item_list_json) { uint16_t read_item_count = cJSON_GetArraySize(read_item_list_json); @@ -99,6 +116,12 @@ static uint16_t GetRecipeTotalDataLength(cJSON* read_item_list_json) return total_data_length; } +/** + * @description: Control Framework Basic Serial Configure + * @param p_recipe - Control recipe pointer + * @param p_recipe_file_json - p_recipe_file_json pointer + * @return + */ static void ControlBasicSerialConfig(struct ControlRecipe *p_recipe, cJSON *p_recipe_file_json) { cJSON *p_serial_config_json = cJSON_GetObjectItem(p_recipe_file_json, "serial_config"); @@ -110,6 +133,12 @@ static void ControlBasicSerialConfig(struct ControlRecipe *p_recipe, cJSON *p_re p_recipe->serial_config.baud_rate, p_recipe->serial_config.data_bits, p_recipe->serial_config.stop_bits, p_recipe->serial_config.check_mode); } +/** + * @description: Control Framework Basic Socket Configure + * @param p_recipe - Control recipe pointer + * @param p_recipe_file_json - p_recipe_file_json pointer + * @return + */ static void ControlBasicSocketConfig(struct ControlRecipe *p_recipe, cJSON *p_recipe_file_json) { cJSON *p_socket_address_json = cJSON_GetObjectItem(p_recipe_file_json, "socket_config"); @@ -146,7 +175,14 @@ static void ControlBasicSocketConfig(struct ControlRecipe *p_recipe, cJSON *p_re local_ip_string, plc_ip_string, gateway_ip_string, p_recipe->socket_config.port); } -void ControlPrintList(char name[5], uint8_t *number_list, uint16_t length) +/** + * @description: Control Framework Printf List Function + * @param name - printf function name + * @param number_list - number_list pointer + * @param length - number_list length + * @return + */ +void ControlPrintfList(char name[5], uint8_t *number_list, uint16_t length) { printf("\n******************%5s****************\n", name); for (int32_t i = 0;i < length;i ++) { @@ -155,6 +191,11 @@ void ControlPrintList(char name[5], uint8_t *number_list, uint16_t length) printf("\n**************************************\n"); } +/** + * @description: Control Framework Connect Socket + * @param p_plc - basic socket plc pointer + * @return success : 0 error : -1 -2 -3 -4 -5 + */ int ControlConnectSocket(BasicSocketPlc *p_plc) { if (p_plc->socket >= 0) @@ -179,10 +220,12 @@ int ControlConnectSocket(BasicSocketPlc *p_plc) printf("Error setting TCP_NODELAY function!\n"); return -1; } + if (setsockopt(plc_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, (socklen_t)sizeof(struct timeval)) < 0) { printf("Error setting SO_SNDTIMEO function!\n"); return -2; } + if (setsockopt(plc_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, (socklen_t)sizeof(struct timeval)) < 0) { printf("Error setting SO_RCVTIMEO function!\n"); return -3; @@ -204,6 +247,11 @@ int ControlConnectSocket(BasicSocketPlc *p_plc) } } +/** + * @description: Control Framework Disconnect Socket + * @param p_plc - basic socket plc pointer + * @return success : 0 error : -1 + */ int ControlDisconnectSocket(BasicSocketPlc *p_plc) { if (p_plc->socket < 0) @@ -216,6 +264,11 @@ int ControlDisconnectSocket(BasicSocketPlc *p_plc) return error; } +/** + * @description: Control Framework Protocol Open for Sub_Protocol, Init Circular Area and Receive Data Task + * @param control_protocol - Control protocol pointer + * @return success : 0 error : -1 + */ int ControlProtocolOpenDef(struct ControlProtocol *control_protocol) { g_circular_area = CircularAreaAppInit(PLC_DATA_LENGTH); @@ -234,6 +287,11 @@ int ControlProtocolOpenDef(struct ControlProtocol *control_protocol) PrivTaskStartup(&recv_plc_data_task); } +/** + * @description: Control Framework Protocol Open for Sub_Protocol, Release Circular Area and Delete Receive Data Task + * @param void + * @return success : 0 error : -1 + */ int ControlProtocolCloseDef(void) { CircularAreaAppRelease(g_circular_area); @@ -243,6 +301,11 @@ int ControlProtocolCloseDef(void) return 0; } +/** + * @description: Control Framework Get Value Memory Size From Recipe File + * @param uniform_value_type - uniform value type + * @return success : size error : 0 + */ uint8_t GetValueTypeMemorySize(UniformValueType uniform_value_type) { switch (uniform_value_type) @@ -271,16 +334,20 @@ uint8_t GetValueTypeMemorySize(UniformValueType uniform_value_type) return 0; } +/** + * @description: Control Framework Peripheral Device Init + * @param p_recipe - Control recipe pointer + * @return success : 0 error : + */ int ControlPeripheralInit(struct ControlRecipe *p_recipe) { switch (p_recipe->communication_type) { case 0://Socket Init - lwip_config_tcp(0, p_recipe->socket_config.local_ip, p_recipe->socket_config.netmask, p_recipe->socket_config.gateway); + SocketInit(p_recipe->socket_config.local_ip, p_recipe->socket_config.netmask, p_recipe->socket_config.gateway); break; case 1://Serial Init - // Uart485Init(p_recipe->serial_config.baud_rate, p_recipe->serial_config.data_bits, - // p_recipe->serial_config.stop_bits, p_recipe->serial_config.check_mode); + SerialInit(p_recipe->serial_config.baud_rate, p_recipe->serial_config.data_bits, p_recipe->serial_config.stop_bits, p_recipe->serial_config.check_mode); break; default: break; @@ -289,6 +356,13 @@ int ControlPeripheralInit(struct ControlRecipe *p_recipe) return 0; } +/** + * @description: Control Framework Get Recipe Basic Information + * @param p_recipe - Control recipe pointer + * @param protocol_type - protocol type + * @param p_recipe_file_json - recipe_file_json pointer + * @return success : 0 error : -1 + */ int RecipeBasicInformation(struct ControlRecipe *p_recipe, int protocol_type, cJSON *p_recipe_file_json) { if (protocol_type != (ProtocolType)(cJSON_GetObjectItem(p_recipe_file_json, "protocol_type")->valueint)) { @@ -308,10 +382,10 @@ int RecipeBasicInformation(struct ControlRecipe *p_recipe, int protocol_type, cJ switch (p_recipe->communication_type) { - case 0://Socket Config + case 0://Get Socket Config ControlBasicSocketConfig(p_recipe, p_recipe_file_json); break; - case 1://Serial Config + case 1://Get Serial Config ControlBasicSerialConfig(p_recipe, p_recipe_file_json); break; default: @@ -321,6 +395,13 @@ int RecipeBasicInformation(struct ControlRecipe *p_recipe, int protocol_type, cJ printf("\n************************************************************\n"); } +/** + * @description: Control Framework Read Variable Item Function + * @param p_recipe - Control recipe pointer + * @param protocol_type - protocol type + * @param p_recipe_file_json - recipe_file_json pointer + * @return + */ void RecipeReadVariableItem(struct ControlRecipe *p_recipe, int protocol_type, cJSON *p_recipe_file_json) { int ret = 0; diff --git a/APP_Framework/Framework/control/shared/control_def.h b/APP_Framework/Framework/control/shared/control_def.h index fafb7d6f2..10e5dfd0a 100644 --- a/APP_Framework/Framework/control/shared/control_def.h +++ b/APP_Framework/Framework/control/shared/control_def.h @@ -25,16 +25,12 @@ #include #include #include +#include #ifdef LIB_USING_CJSON #include #endif -#ifdef BSP_USING_LWIP -#include "lwip/sys.h" -#include "lwip/sockets.h" -#endif - #ifdef __cplusplus extern "C" { #endif @@ -48,11 +44,6 @@ extern "C" { } \ }while (0) -#ifdef BSP_USING_LWIP -#define socket_write lwip_write -#define socket_read lwip_read -#endif - typedef enum { UNIFORM_BOOL = 1, @@ -141,16 +132,22 @@ int RecipeBasicInformation(struct ControlRecipe *p_recipe, int protocol_type, cJ /*Get the variable need to read from recipe file*/ void RecipeReadVariableItem(struct ControlRecipe *p_recipe, int protocol_type, cJSON *p_recipe_file_json); +/*Control Framework Peripheral Device Init*/ int ControlPeripheralInit(struct ControlRecipe *p_recipe); -void ControlPrintList(char name[5], uint8_t *number_list, uint16_t length); +/*Control Framework Printf List Function*/ +void ControlPrintfList(char name[5], uint8_t *number_list, uint16_t length); +/*Control Framework Connect Socket*/ int ControlConnectSocket(BasicSocketPlc *p_plc); +/*Control Framework Disconnect Socket*/ int ControlDisconnectSocket(BasicSocketPlc *p_plc); +/*Control Framework Protocol Open for Sub_Protocol, Init Circular Area and Receive Data Task*/ int ControlProtocolOpenDef(struct ControlProtocol *control_protocol); +/*Control Framework Protocol Open for Sub_Protocol, Release Circular Area and Delete Receive Data Task*/ int ControlProtocolCloseDef(void); #ifdef __cplusplus diff --git a/APP_Framework/Framework/control/shared/control_io.c b/APP_Framework/Framework/control/shared/control_io.c new file mode 100644 index 000000000..830e6d5b7 --- /dev/null +++ b/APP_Framework/Framework/control/shared/control_io.c @@ -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 control_io.c + * @brief low level io code for control framework + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2022-11-21 + */ + +#include + +/** + * @description: Control Framework Socket Init + * @param ip - local ip pointer + * @param mask - netmask pointer + * @param gw - gateway pointer + * @return + */ +void SocketInit(char *ip, char *mask, char *gw) +{ +#ifdef BSP_USING_LWIP + lwip_config_tcp(0, ip, mask, gw); +#endif +} + +/** + * @description: Control Framework Serial Init + * @param baud_rate - baud rate + * @param data_bits - data bits + * @param stop_bits - stop bits + * @param check_mode - check mode + * @return + */ +void SerialInit(uint32_t baud_rate, uint8_t data_bits, uint8_t stop_bits, uint8_t check_mode) +{ + // Uart485Init(baud_rate, data_bits, stop_bits, check_mode); +} diff --git a/APP_Framework/Framework/control/shared/control_io.h b/APP_Framework/Framework/control/shared/control_io.h new file mode 100644 index 000000000..52c501486 --- /dev/null +++ b/APP_Framework/Framework/control/shared/control_io.h @@ -0,0 +1,51 @@ +/* +* 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 control_io.h + * @brief code for control framework io adapter + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2022-11-21 + */ + +#ifndef CONTROL_IO_H +#define CONTROL_IO_H + +#include +#include + +#ifdef BSP_USING_LWIP +#include "lwip/sys.h" +#include "lwip/sockets.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef BSP_USING_LWIP +#define socket_write lwip_write +#define socket_read lwip_read +#endif + +/*Control Framework Socket Init*/ +void SocketInit(char *ip, char *mask, char *gw); + +/*Control Framework Serial Init*/ +void SerialInit(uint32_t baud_rate, uint8_t data_bits, uint8_t stop_bits, uint8_t check_mode); + +#ifdef __cplusplus +} +#endif + +#endif From c1976c8d9229eb007a29703d130b72e04a6abd22 Mon Sep 17 00:00:00 2001 From: wuzheng Date: Tue, 22 Nov 2022 15:57:33 +0800 Subject: [PATCH 10/14] fix errors of naming function --- .../Applications/app_test/test_touch.c | 2 +- .../Applications/sensor_app/humidity_hs300x.c | 4 +- .../sensor_app/temperature_hs300x.c | 4 +- APP_Framework/Framework/sensor/Makefile | 60 +++++++++++++++++++ .../third_party_driver/dvp/connect_dvp.c | 32 +++++----- .../third_party_driver/dvp/ov2640.c | 2 +- .../third_party_driver/include/connect_dvp.h | 19 ++++++ .../third_party_driver/include/ov2640.h | 2 +- .../soft_spi/connect_soft_spi.c | 26 ++++---- .../soft_spi/connect_soft_spi.c | 26 ++++---- .../XiZi_IIoT/resources/include/bus_camera.h | 2 +- .../XiZi_IIoT/resources/include/dev_camera.h | 2 +- 12 files changed, 130 insertions(+), 51 deletions(-) diff --git a/APP_Framework/Applications/app_test/test_touch.c b/APP_Framework/Applications/app_test/test_touch.c index 87ae8d4b1..1f2060fe9 100644 --- a/APP_Framework/Applications/app_test/test_touch.c +++ b/APP_Framework/Applications/app_test/test_touch.c @@ -85,7 +85,7 @@ void TestTouch(void) PrivWrite(lcd_fd, &graph_param, NULL_PARAMETER); } - uint16 color_select[20]; + uint16 color_select[LCD_SIZE]; memset(color_select,0xff,sizeof(color_select)); graph_param.pixel_info.pixel_color = &color_select; while(1){ diff --git a/APP_Framework/Applications/sensor_app/humidity_hs300x.c b/APP_Framework/Applications/sensor_app/humidity_hs300x.c index a35094a72..2cfeb4c8a 100644 --- a/APP_Framework/Applications/sensor_app/humidity_hs300x.c +++ b/APP_Framework/Applications/sensor_app/humidity_hs300x.c @@ -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); } \ No newline at end of file diff --git a/APP_Framework/Applications/sensor_app/temperature_hs300x.c b/APP_Framework/Applications/sensor_app/temperature_hs300x.c index bb5922f3a..98f6d9281 100644 --- a/APP_Framework/Applications/sensor_app/temperature_hs300x.c +++ b/APP_Framework/Applications/sensor_app/temperature_hs300x.c @@ -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); diff --git a/APP_Framework/Framework/sensor/Makefile b/APP_Framework/Framework/sensor/Makefile index 1b0d11470..d278876be 100644 --- a/APP_Framework/Framework/sensor/Makefile +++ b/APP_Framework/Framework/sensor/Makefile @@ -6,6 +6,12 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) endif +ifeq ($(ADD_XIZI_FETURES),y) + include $(APPDIR)/Make.defs + CSRCS += sensor.c + include $(APPDIR)/Application.mk +endif + ifeq ($(CONFIG_ADD_XIZI_FETURES),y) SRC_FILES := sensor.c @@ -59,3 +65,57 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y) include $(KERNEL_ROOT)/compiler.mk endif + +ifeq ($(ADD_XIZI_FETURES),y) + SRC_FILES := sensor.c + + ifeq ($(CONFIG_SENSOR_HCHO),y) + SRC_DIR += hcho + endif + + ifeq ($(CONFIG_SENSOR_TVOC),y) + SRC_DIR += tvoc + endif + + ifeq ($(CONFIG_SENSOR_IAQ),y) + SRC_DIR += iaq + endif + + ifeq ($(CONFIG_SENSOR_CH4),y) + SRC_DIR += ch4 + endif + + ifeq ($(CONFIG_SENSOR_CO2),y) + SRC_DIR += co2 + endif + + ifeq ($(CONFIG_SENSOR_PM),y) + SRC_DIR += pm + endif + + ifeq ($(CONFIG_SENSOR_VOICE),y) + SRC_DIR += voice + endif + + ifeq ($(CONFIG_SENSOR_TEMPERATURE),y) + SRC_DIR += temperature + endif + + ifeq ($(CONFIG_SENSOR_HUMIDITY),y) + SRC_DIR += humidity + endif + + ifeq ($(CONFIG_SENSOR_WINDSPEED),y) + SRC_DIR += windspeed + endif + + ifeq ($(CONFIG_SENSOR_WINDDIRECTION),y) + SRC_DIR += winddirection + endif + + ifeq ($(CONFIG_SENSOR_ALTITUDE),y) + SRC_DIR += altitude + endif + + include $(KERNEL_ROOT)/compiler.mk +endif \ No newline at end of file diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c index c2af08697..04463832b 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/connect_dvp.c @@ -43,7 +43,7 @@ static struct CameraCfg sensor_config = { .gain = 0x00 }; -static uint32 dvpDrvInit(void) +static uint32 DvpDrvInit(void) { x_err_t ret = EOK; dvp_init(SCCB_REG_LENGTH); @@ -53,7 +53,7 @@ static uint32 dvpDrvInit(void) dvp_set_output_enable(DVP_OUTPUT_DISPLAY, 0); dvp_set_output_enable(DVP_OUTPUT_AI, 0); ov2640_init(); - sensorConfigure(&sensor_config); + SensorConfigure(&sensor_config); sysctl_set_spi0_dvp_data(1); #ifdef DVP_BURST_ENABLE @@ -77,28 +77,28 @@ static uint32 dvpDrvInit(void) return ret; } -static uint32 readDvpReg(void *drv, struct DvpRegConfigureInfo *reg_info) +static uint32 ReadDvpReg(void *drv, struct DvpRegConfigureInfo *reg_info) { x_err_t ret = EOK; reg_info->reg_value = dvp_sccb_receive_data(reg_info->device_addr, reg_info->reg_addr); return ret; } -static uint32 writeDvpReg(void *drv, struct DvpRegConfigureInfo *reg_info) +static uint32 WriteDvpReg(void *drv, struct DvpRegConfigureInfo *reg_info) { x_err_t ret = EOK; dvp_sccb_send_data(reg_info->device_addr, reg_info->reg_addr, reg_info->reg_value); return ret; } -static uint32 dvpOpen(void *dev) +static uint32 DvpOpen(void *dev) { x_err_t ret = EOK; - dvpDrvInit(); + DvpDrvInit(); return ret; } -static uint32 dvpClose(void *dev) +static uint32 DvpClose(void *dev) { x_err_t ret = EOK; dvp_config_interrupt(DVP_CFG_START_INT_ENABLE | DVP_CFG_FINISH_INT_ENABLE, 0); @@ -107,7 +107,7 @@ static uint32 dvpClose(void *dev) return ret; } -static uint32 dvpRead(void *dev, struct BusBlockReadParam *read_param) +static uint32 DvpRead(void *dev, struct BusBlockReadParam *read_param) { x_err_t ret = EOK; @@ -119,7 +119,7 @@ static uint32 dvpRead(void *dev, struct BusBlockReadParam *read_param) return ret; } -static uint32 dvpDrvConfigure(void *drv, struct BusConfigureInfo *args) +static uint32 DvpDrvConfigure(void *drv, struct BusConfigureInfo *args) { x_err_t ret = EOK; @@ -131,15 +131,15 @@ static uint32 dvpDrvConfigure(void *drv, struct BusConfigureInfo *args) break; case OPE_CFG: tmp_cfg = (struct CameraCfg *)args->private_data; - sensorConfigure(tmp_cfg); + SensorConfigure(tmp_cfg); dvp_set_image_size(tmp_cfg->output_w, tmp_cfg->output_h); break; case REG_SCCB_READ: - readDvpReg(drv, (struct DvpRegConfigureInfo *)args->private_data); + ReadDvpReg(drv, (struct DvpRegConfigureInfo *)args->private_data); break; case REG_SCCB_WRITE: //for ov2640,write reg 0x04 to Horizontal mirror or Vertical flip - writeDvpReg(drv, (struct DvpRegConfigureInfo *)args->private_data); + WriteDvpReg(drv, (struct DvpRegConfigureInfo *)args->private_data); break; default: break; @@ -150,10 +150,10 @@ static uint32 dvpDrvConfigure(void *drv, struct BusConfigureInfo *args) /*manage the camera device operations*/ static const struct CameraDevDone camera_dev_done = { - .dev_open = dvpOpen, - .dev_close = dvpClose, + .dev_open = DvpOpen, + .dev_close = DvpClose, .dev_write = NONE, - .dev_read = dvpRead, + .dev_read = DvpRead, }; /*Init camera bus*/ @@ -225,7 +225,7 @@ int HwDvpInit(void) static struct CameraDriver camera_driver; memset(&camera_driver, 0, sizeof(struct CameraDriver)); - camera_driver.configure = dvpDrvConfigure; + camera_driver.configure = DvpDrvConfigure; ret = BoardCameraBusInit(&camera_bus, &camera_driver); if (EOK != ret) { diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/ov2640.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/ov2640.c index ba5dfea9b..991a8982a 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/ov2640.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/dvp/ov2640.c @@ -425,7 +425,7 @@ int ov2640_read_id(uint16_t *manuf_id, uint16_t *device_id) return 0; } -int sensorConfigure(struct CameraCfg *cfg_info) +int SensorConfigure(struct CameraCfg *cfg_info) { uint8_t reg_tmp; diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_dvp.h b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_dvp.h index b8550cd5f..178fc5ddd 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_dvp.h +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/connect_dvp.h @@ -1,3 +1,22 @@ +/* +* 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 connect_dvp.h +* @brief define edu-riscv64-board DVP init function +* @version 2.0 +* @author AIIT XUOS Lab +* @date 2022-11-21 +*/ #ifndef CONNECT_DVP_H #define CONNECT_DVP_H #include diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/ov2640.h b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/ov2640.h index b56c427a5..4f1240b73 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/ov2640.h +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/include/ov2640.h @@ -33,6 +33,6 @@ struct CameraCfg int ov2640_init(void); int ov2640_read_id(uint16_t *manuf_id, uint16_t *device_id); -int sensorConfigure(struct CameraCfg* cfg_info); +int SensorConfigure(struct CameraCfg* cfg_info); #endif /* _OV2640_H */ diff --git a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/soft_spi/connect_soft_spi.c b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/soft_spi/connect_soft_spi.c index 9cf961d40..b3a11b572 100644 --- a/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/soft_spi/connect_soft_spi.c +++ b/Ubiquitous/XiZi_IIoT/board/edu-riscv64/third_party_driver/soft_spi/connect_soft_spi.c @@ -12,7 +12,7 @@ #include #include -static x_err_t softSPIinit(struct SpiDriver *spi_drv, struct BusConfigureInfo *cfg) +static x_err_t SoftSPIinit(struct SpiDriver *spi_drv, struct BusConfigureInfo *cfg) { NULL_PARAM_CHECK(spi_drv); NULL_PARAM_CHECK(cfg); @@ -29,7 +29,7 @@ static x_err_t softSPIinit(struct SpiDriver *spi_drv, struct BusConfigureInfo *c return EOK; } -static uint32 softSpiDrvConfigure(void *drv, struct BusConfigureInfo *configure_info) +static uint32 SoftSpiDrvConfigure(void *drv, struct BusConfigureInfo *configure_info) { NULL_PARAM_CHECK(drv); NULL_PARAM_CHECK(configure_info); @@ -41,7 +41,7 @@ static uint32 softSpiDrvConfigure(void *drv, struct BusConfigureInfo *configure_ switch (configure_info->configure_cmd) { case OPE_INT: - softSPIinit(spi_drv, configure_info); + SoftSPIinit(spi_drv, configure_info); break; case OPE_CFG: @@ -54,7 +54,7 @@ static uint32 softSpiDrvConfigure(void *drv, struct BusConfigureInfo *configure_ return ret; } -static void soft_spi_writebyte(struct SpiHardwareDevice *spi_dev, uint8_t data) +static void SoftSpiWriteByte(struct SpiHardwareDevice *spi_dev, uint8_t data) { int8_t i = 0; uint8_t temp = 0; @@ -79,7 +79,7 @@ static void soft_spi_writebyte(struct SpiHardwareDevice *spi_dev, uint8_t data) } /* 读一个字节 */ -static uint8_t soft_spi_readbyte(struct SpiHardwareDevice *spi_dev) +static uint8_t SoftSpiReadbyte(struct SpiHardwareDevice *spi_dev) { uint8_t i = 0; uint8_t read_data = 0xFF; @@ -100,7 +100,7 @@ static uint8_t soft_spi_readbyte(struct SpiHardwareDevice *spi_dev) /* 读写一个字节 */ // this funcition is unverify until now! -static uint8_t soft_spi_readwritebyte(struct SpiHardwareDevice *spi_dev, uint8_t data) +static uint8_t SoftSpiReadWriteByte(struct SpiHardwareDevice *spi_dev, uint8_t data) { uint8_t i = 0; uint8_t temp = 0; @@ -129,7 +129,7 @@ static uint8_t soft_spi_readwritebyte(struct SpiHardwareDevice *spi_dev, uint8_t return read_data; } -static uint32 softSpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiDataStandard *spi_datacfg) +static uint32 SoftSpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiDataStandard *spi_datacfg) { SpiDeviceParam *dev_param = (SpiDeviceParam *)(spi_dev->haldev.private_data); @@ -148,7 +148,7 @@ static uint32 softSpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiData for (size_t i = 0; i < data_length; i++) { - soft_spi_writebyte(spi_dev, data_buff[i]); + SoftSpiWriteByte(spi_dev, data_buff[i]); } if (spi_datacfg->spi_cs_release) @@ -160,7 +160,7 @@ static uint32 softSpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiData return EOK; } -static uint32 softSpiReadData(struct SpiHardwareDevice *spi_dev, struct SpiDataStandard *spi_datacfg) +static uint32 SoftSpiReadData(struct SpiHardwareDevice *spi_dev, struct SpiDataStandard *spi_datacfg) { SpiDeviceParam *dev_param = (SpiDeviceParam *)(spi_dev->haldev.private_data); uint8 cs_gpio_pin = dev_param->spi_slave_param->spi_cs_gpio_pin; @@ -179,7 +179,7 @@ static uint32 softSpiReadData(struct SpiHardwareDevice *spi_dev, struct SpiDataS for (size_t i = 0; i < recv_length; i++) { - recv_buff[i] = soft_spi_readbyte(spi_dev); + recv_buff[i] = SoftSpiReadbyte(spi_dev); } if (spi_datacfg->spi_cs_release) @@ -195,8 +195,8 @@ static uint32 softSpiReadData(struct SpiHardwareDevice *spi_dev, struct SpiDataS const struct SpiDevDone soft_spi_dev_done = { .dev_close = NONE, .dev_open = NONE, - .dev_read = softSpiReadData, - .dev_write = softSpiWriteData}; + .dev_read = SoftSpiReadData, + .dev_write = SoftSpiWriteData}; static int BoardSoftSpiBusInit(struct SpiBus *spi_bus, struct SpiDriver *spi_driver) { @@ -275,7 +275,7 @@ int HwSoftSPIInit(void) static struct SpiDriver spi_driver; memset(&spi_driver, 0, sizeof(struct SpiDriver)); - spi_driver.configure = &(softSpiDrvConfigure); + spi_driver.configure = &(SoftSpiDrvConfigure); ret = BoardSoftSpiBusInit(&spi_bus, &spi_driver); if (EOK != ret) diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/connect_soft_spi.c b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/connect_soft_spi.c index 9cf961d40..68a01db87 100644 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/connect_soft_spi.c +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-riscv64/third_party_driver/soft_spi/connect_soft_spi.c @@ -12,7 +12,7 @@ #include #include -static x_err_t softSPIinit(struct SpiDriver *spi_drv, struct BusConfigureInfo *cfg) +static x_err_t SoftSPIinit(struct SpiDriver *spi_drv, struct BusConfigureInfo *cfg) { NULL_PARAM_CHECK(spi_drv); NULL_PARAM_CHECK(cfg); @@ -29,7 +29,7 @@ static x_err_t softSPIinit(struct SpiDriver *spi_drv, struct BusConfigureInfo *c return EOK; } -static uint32 softSpiDrvConfigure(void *drv, struct BusConfigureInfo *configure_info) +static uint32 SoftSpiDrvConfigure(void *drv, struct BusConfigureInfo *configure_info) { NULL_PARAM_CHECK(drv); NULL_PARAM_CHECK(configure_info); @@ -41,7 +41,7 @@ static uint32 softSpiDrvConfigure(void *drv, struct BusConfigureInfo *configure_ switch (configure_info->configure_cmd) { case OPE_INT: - softSPIinit(spi_drv, configure_info); + SoftSPIinit(spi_drv, configure_info); break; case OPE_CFG: @@ -54,7 +54,7 @@ static uint32 softSpiDrvConfigure(void *drv, struct BusConfigureInfo *configure_ return ret; } -static void soft_spi_writebyte(struct SpiHardwareDevice *spi_dev, uint8_t data) +static void SoftSpiWriteByte(struct SpiHardwareDevice *spi_dev, uint8_t data) { int8_t i = 0; uint8_t temp = 0; @@ -79,7 +79,7 @@ static void soft_spi_writebyte(struct SpiHardwareDevice *spi_dev, uint8_t data) } /* 读一个字节 */ -static uint8_t soft_spi_readbyte(struct SpiHardwareDevice *spi_dev) +static uint8_t SoftSpiReadByte(struct SpiHardwareDevice *spi_dev) { uint8_t i = 0; uint8_t read_data = 0xFF; @@ -100,7 +100,7 @@ static uint8_t soft_spi_readbyte(struct SpiHardwareDevice *spi_dev) /* 读写一个字节 */ // this funcition is unverify until now! -static uint8_t soft_spi_readwritebyte(struct SpiHardwareDevice *spi_dev, uint8_t data) +static uint8_t SoftSpiReadWriteByte(struct SpiHardwareDevice *spi_dev, uint8_t data) { uint8_t i = 0; uint8_t temp = 0; @@ -129,7 +129,7 @@ static uint8_t soft_spi_readwritebyte(struct SpiHardwareDevice *spi_dev, uint8_t return read_data; } -static uint32 softSpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiDataStandard *spi_datacfg) +static uint32 SoftSpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiDataStandard *spi_datacfg) { SpiDeviceParam *dev_param = (SpiDeviceParam *)(spi_dev->haldev.private_data); @@ -148,7 +148,7 @@ static uint32 softSpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiData for (size_t i = 0; i < data_length; i++) { - soft_spi_writebyte(spi_dev, data_buff[i]); + SoftSpiWriteByte(spi_dev, data_buff[i]); } if (spi_datacfg->spi_cs_release) @@ -160,7 +160,7 @@ static uint32 softSpiWriteData(struct SpiHardwareDevice *spi_dev, struct SpiData return EOK; } -static uint32 softSpiReadData(struct SpiHardwareDevice *spi_dev, struct SpiDataStandard *spi_datacfg) +static uint32 SoftSpiReadData(struct SpiHardwareDevice *spi_dev, struct SpiDataStandard *spi_datacfg) { SpiDeviceParam *dev_param = (SpiDeviceParam *)(spi_dev->haldev.private_data); uint8 cs_gpio_pin = dev_param->spi_slave_param->spi_cs_gpio_pin; @@ -179,7 +179,7 @@ static uint32 softSpiReadData(struct SpiHardwareDevice *spi_dev, struct SpiDataS for (size_t i = 0; i < recv_length; i++) { - recv_buff[i] = soft_spi_readbyte(spi_dev); + recv_buff[i] = SoftSpiReadByte(spi_dev); } if (spi_datacfg->spi_cs_release) @@ -195,8 +195,8 @@ static uint32 softSpiReadData(struct SpiHardwareDevice *spi_dev, struct SpiDataS const struct SpiDevDone soft_spi_dev_done = { .dev_close = NONE, .dev_open = NONE, - .dev_read = softSpiReadData, - .dev_write = softSpiWriteData}; + .dev_read = SoftSpiReadData, + .dev_write = SoftSpiWriteData}; static int BoardSoftSpiBusInit(struct SpiBus *spi_bus, struct SpiDriver *spi_driver) { @@ -275,7 +275,7 @@ int HwSoftSPIInit(void) static struct SpiDriver spi_driver; memset(&spi_driver, 0, sizeof(struct SpiDriver)); - spi_driver.configure = &(softSpiDrvConfigure); + spi_driver.configure = &(SoftSpiDrvConfigure); ret = BoardSoftSpiBusInit(&spi_bus, &spi_driver); if (EOK != ret) diff --git a/Ubiquitous/XiZi_IIoT/resources/include/bus_camera.h b/Ubiquitous/XiZi_IIoT/resources/include/bus_camera.h index 8ea27c57b..3e6a30f4f 100644 --- a/Ubiquitous/XiZi_IIoT/resources/include/bus_camera.h +++ b/Ubiquitous/XiZi_IIoT/resources/include/bus_camera.h @@ -15,7 +15,7 @@ * @brief define camera bus and drv function using bus driver framework * @version 1.0 * @author AIIT XUOS Lab -* @date 2021-11-16 +* @date 2022-11-15 */ #ifndef BUS_CAMERA_H diff --git a/Ubiquitous/XiZi_IIoT/resources/include/dev_camera.h b/Ubiquitous/XiZi_IIoT/resources/include/dev_camera.h index f7ad095be..4077c3254 100644 --- a/Ubiquitous/XiZi_IIoT/resources/include/dev_camera.h +++ b/Ubiquitous/XiZi_IIoT/resources/include/dev_camera.h @@ -15,7 +15,7 @@ * @brief define camera dev function using bus driver framework * @version 1.0 * @author AIIT XUOS Lab -* @date 2021-04-24 +* @date 2022-11-15 */ #ifndef DEV_CAMERA_H From bc47ae644f5142d209c7edb45140527624543a47 Mon Sep 17 00:00:00 2001 From: Liu_Weichao Date: Thu, 24 Nov 2022 10:46:54 +0800 Subject: [PATCH 11/14] feat add control_framework, read json file OK --- .../control_app/plc_demo/omron/omron_cj2m.c | 25 +++++ .../control/plc_protocol/fins/fins.c | 105 +++++++----------- .../plc_protocol/fins/test_recipe_fins.json | 2 +- .../control/plc_protocol/include/fins.h | 4 +- .../Framework/control/shared/control.c | 24 +++- .../Framework/control/shared/control.h | 8 -- .../Framework/control/shared/control_def.c | 65 ++++++----- .../Framework/control/shared/control_def.h | 11 +- .../Framework/control/shared/control_io.c | 4 + .../XiZi_IIoT/board/xidatong-arm32/link.lds | 3 +- .../ethernet/enet_ethernetif.c | 2 +- .../semc/semc_externsdram_test.c | 1 + .../resources/ethernet/LwIP/arch/lwipopts.h | 2 +- 13 files changed, 144 insertions(+), 112 deletions(-) diff --git a/APP_Framework/Applications/control_app/plc_demo/omron/omron_cj2m.c b/APP_Framework/Applications/control_app/plc_demo/omron/omron_cj2m.c index b34d82dbf..a09c254c4 100644 --- a/APP_Framework/Applications/control_app/plc_demo/omron/omron_cj2m.c +++ b/APP_Framework/Applications/control_app/plc_demo/omron/omron_cj2m.c @@ -18,6 +18,31 @@ * @date 2022.9.27 */ +#include +void ControlOmronTest(void) +{ + 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); + + PrivTaskDelay(10000); + + for (int i = 0; i < 10; i ++) { + 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); + } + + //ControlProtocolClose(fins_protocol); + } +} +PRIV_SHELL_CMD_FUNCTION(ControlOmronTest, Omron Plc FINS Demo, PRIV_SHELL_CMD_MAIN_ATTR); diff --git a/APP_Framework/Framework/control/plc_protocol/fins/fins.c b/APP_Framework/Framework/control/plc_protocol/fins/fins.c index 925cce00a..397639d76 100644 --- a/APP_Framework/Framework/control/plc_protocol/fins/fins.c +++ b/APP_Framework/Framework/control/plc_protocol/fins/fins.c @@ -22,7 +22,7 @@ #define FINS_COMMAND_LENGTH 34 -static struct CircularAreaApp *circular_area; +static BasicSocketPlc plc_socket = {0}; static uint8_t handshake_require_command[] = {0x46, 0x49, 0x4E, 0x53, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; static uint8_t handshake_respond_buff[24] = {0}; @@ -53,18 +53,19 @@ static uint8_t FinsAreaCode(char area_char, FinsDataType type) * @param p_command - command pointer * @param plc_ip_4 - last plc ip * @param local_ip_4 - last local ip - * @param command_code - fins command code - * @param area_char - area char - * @param data_type - fins data type - * @param start_address - fins cmd start address - * @param bit_address - fins cmd bit address - * @param data_length - fins cmd data length + * @param p_read_item - p_read_item pointer * @return success : index error : 0 */ -static uint16_t FinsCommandGenerate(uint8_t *p_command, uint16_t plc_ip_4, uint16_t local_ip_4, FinsCommandCode command_code, char area_char, - FinsDataType data_type, uint16_t start_address, uint8_t bit_address, uint16_t data_length) +static uint16_t FinsCommandGenerate(uint8_t *p_command, uint16_t plc_ip_4, uint16_t local_ip_4, FinsReadItem *p_read_item) { uint8_t index = 0; + uint16_t command_code = p_read_item->data_info.command_code; + uint8_t area_char = p_read_item->area_char; + uint16_t data_type = p_read_item->data_type; + uint16_t start_address = p_read_item->start_address; + uint8_t bit_address = p_read_item->bit_address; + uint16_t data_length = p_read_item->data_length; + p_command[index++] = (uint8_t)(FINS_HEADER_HEAD >> (3 * 8)); p_command[index++] = (uint8_t)(FINS_HEADER_HEAD >> (2 * 8)); p_command[index++] = (uint8_t)(FINS_HEADER_HEAD >> (1 * 8)); @@ -201,10 +202,9 @@ static int FinsHandshake(int32_t socket, uint16_t local_ip_4) * @description: Fins Get Data From Socket * @param socket - socket * @param p_read_item - read item pointer - * @param p_recipe - control recipe pointer * @return success : 0 error : -1 -2 */ -static int FinsGetData(int32_t socket, FinsReadItem *p_read_item, struct ControlRecipe *p_recipe) +static int FinsGetData(int32_t socket, FinsReadItem *p_read_item) { uint8_t try_count = 0; int32_t write_error = 0; @@ -248,34 +248,22 @@ static int FinsGetData(int32_t socket, FinsReadItem *p_read_item, struct Control * @param p_read_item - read item pointer * @param plc_ip_4 - last plc ip * @param local_ip_4 - last local ip - * @param command_code - fins command code - * @param area_char - area char - * @param data_type - fins data type - * @param start_address - fins cmd start address - * @param bit_address - fins cmd bit address - * @param data_length - fins cmd data length * @param p_data - control-data pointer * @return success : 0 error : -1 */ -static int FinsInitialDataInfo(FinsReadItem *p_read_item, uint16_t plc_ip_4, uint16_t local_ip_4, FinsCommandCode command_code, - char area_char, FinsDataType data_type, uint16_t start_address, uint8_t bit_address, uint16_t data_length, uint8_t *p_data) +static int FinsInitialDataInfo(FinsReadItem *p_read_item, uint16_t plc_ip_4, uint16_t local_ip_4, uint8_t *p_data) { - p_read_item->area_char = area_char; - p_read_item->data_type = data_type; - p_read_item->data_info.command_code = command_code; - p_read_item->start_address = start_address; - p_read_item->bit_address = bit_address; - p_read_item->data_length = data_length; + uint16_t data_length = p_read_item->data_length; BasicPlcDataInfo *p_base_data_info = &(p_read_item->data_info.base_data_info); - switch (command_code) + switch (p_read_item->data_info.command_code) { case FINS_COMMAND_CODE_READ: - data_length *= (data_type == FINS_DATA_TYPE_BIT ? 1 : 2); + data_length *= (p_read_item->data_type == FINS_DATA_TYPE_BIT ? 1 : 2); p_base_data_info->command_length = FINS_COMMAND_LENGTH; - p_base_data_info->p_command = (p_data == NULL ? PrivMalloc(FINS_COMMAND_LENGTH + data_length) : PrivMalloc(FINS_COMMAND_LENGTH)); + p_base_data_info->p_command = PrivMalloc(FINS_COMMAND_LENGTH); p_base_data_info->data_size = data_length; - p_base_data_info->p_data = (p_data == NULL ? p_base_data_info->p_command + FINS_COMMAND_LENGTH : p_data); + p_base_data_info->p_data = p_data; break; case FINS_COMMAND_CODE_WRITE: //To Do @@ -283,8 +271,7 @@ static int FinsInitialDataInfo(FinsReadItem *p_read_item, uint16_t plc_ip_4, uin default: return -1; } - uint16_t command_length = FinsCommandGenerate(p_base_data_info->p_command, plc_ip_4, local_ip_4, command_code, area_char, - data_type, start_address, bit_address, data_length); + FinsCommandGenerate(p_base_data_info->p_command, plc_ip_4, local_ip_4, p_read_item); return 0; } @@ -303,12 +290,11 @@ void *ReceivePlcDataTask(void *parameter) uint16_t read_item_size = sizeof(FinsReadItem); struct ControlProtocol *control_protocol = (struct ControlProtocol *)parameter; - circular_area = (struct CircularAreaApp *)control_protocol->args; + struct CircularAreaApp *circular_area = (struct CircularAreaApp *)control_protocol->args; FinsReadItem *fins_read_item = (FinsReadItem *)control_protocol->recipe->read_item; - fins_data = control_protocol->recipe->protocol_data->data; - data_length = control_protocol->recipe->protocol_data->data_length; + fins_data = control_protocol->recipe->protocol_data.data; + data_length = control_protocol->recipe->protocol_data.data_length; - BasicSocketPlc plc_socket; memset(&plc_socket, 0, sizeof(BasicSocketPlc)); memcpy(plc_socket.ip, control_protocol->recipe->socket_config.plc_ip, 4); plc_socket.port = control_protocol->recipe->socket_config.port; @@ -333,16 +319,17 @@ void *ReceivePlcDataTask(void *parameter) plc_socket.secondary_connect_flag = 1; - FinsGetData(plc_socket.socket, (FinsReadItem *)fins_read_item + i, control_protocol->recipe); + FinsGetData(plc_socket.socket, (FinsReadItem *)fins_read_item + i); } /*read all variable item data, put them into circular_area*/ if (i == control_protocol->recipe->read_item_count) { + printf("%s get %d item %d length\n", __func__, i, data_length); CircularAreaAppWrite(circular_area, fins_data, data_length, 0); } /*read data every single 200ms*/ - PrivTaskDelay(200); + PrivTaskDelay(control_protocol->recipe->read_period); } } @@ -365,6 +352,8 @@ int FinsOpen(struct ControlProtocol *control_protocol) */ int FinsClose(struct ControlProtocol *control_protocol) { + ControlDisconnectSocket(&plc_socket); + ControlProtocolCloseDef(); return 0; @@ -379,6 +368,7 @@ int FinsClose(struct ControlProtocol *control_protocol) */ int FinsRead(struct ControlProtocol *control_protocol, void *buf, size_t len) { + struct CircularAreaApp *circular_area = (struct CircularAreaApp *)control_protocol->args; return CircularAreaAppRead(circular_area, buf, len); } @@ -400,27 +390,25 @@ static struct ControlDone fins_protocol_done = int FinsProtocolFormatCmd(struct ControlRecipe *p_recipe, ProtocolFormatInfo *protocol_format_info) { int ret = 0; - static uint8_t last_data_length = 0; - p_recipe->read_item = PrivMalloc(sizeof(FinsReadItem) * p_recipe->read_item_count); FinsReadItem *fins_read_item = (FinsReadItem *)(p_recipe->read_item) + protocol_format_info->read_item_index; - + fins_read_item->value_type = cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "value_type")->valueint; strncpy(fins_read_item->value_name, cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "value_name")->valuestring, 20); - + strncpy(&fins_read_item->area_char, cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "area_char")->valuestring, 1); + fins_read_item->data_type = cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "data_type")->valueint; + fins_read_item->data_info.command_code = FINS_COMMAND_CODE_READ; + fins_read_item->start_address = cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "start_address")->valueint; + fins_read_item->bit_address = cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "bit_address")->valueint; + fins_read_item->data_length = cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "data_length")->valueint; + ret = FinsInitialDataInfo(fins_read_item, p_recipe->socket_config.plc_ip[3], p_recipe->socket_config.local_ip[3], - FINS_COMMAND_CODE_READ, - cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "area_char")->valuestring[0], - cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "data_type")->valueint, - cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "start_address")->valueint, - cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "bit_address")->valueint, - cJSON_GetObjectItem(protocol_format_info->read_single_item_json, "data_length")->valueint, - p_recipe->protocol_data->data + last_data_length); + protocol_format_info->p_read_item_data + protocol_format_info->last_item_size); ControlPrintfList("CMD", fins_read_item->data_info.base_data_info.p_command, fins_read_item->data_info.base_data_info.command_length); - last_data_length = GetValueTypeMemorySize(fins_read_item->value_type); + protocol_format_info->last_item_size = GetValueTypeMemorySize(fins_read_item->value_type); return ret; } @@ -431,23 +419,16 @@ int FinsProtocolFormatCmd(struct ControlRecipe *p_recipe, ProtocolFormatInfo *pr * @return success : 0 error : -1 */ int FinsProtocolInit(struct ControlRecipe *p_recipe) -{ - struct ControlProtocol *p_control_protocol = CONTAINER_OF(p_recipe, struct ControlProtocol, recipe); - if (NULL == p_control_protocol) { - printf("%s get control protocol failed\n", __func__); +{ + p_recipe->read_item = PrivMalloc(sizeof(FinsReadItem) * p_recipe->read_item_count); + if (NULL == p_recipe->read_item) { + PrivFree(p_recipe->read_item); return -1; } - - FinsReadItem *fins_read_item = PrivMalloc(sizeof(FinsReadItem) * p_recipe->read_item_count); - if (NULL == fins_read_item) { - PrivFree(fins_read_item); - return -1; - } - p_recipe->read_item = (void *)fins_read_item; - + p_recipe->ControlProtocolFormatCmd = FinsProtocolFormatCmd; - p_control_protocol->done = &fins_protocol_done; + p_recipe->done = &fins_protocol_done; return 0; } diff --git a/APP_Framework/Framework/control/plc_protocol/fins/test_recipe_fins.json b/APP_Framework/Framework/control/plc_protocol/fins/test_recipe_fins.json index 301f67713..59075bd6e 100644 --- a/APP_Framework/Framework/control/plc_protocol/fins/test_recipe_fins.json +++ b/APP_Framework/Framework/control/plc_protocol/fins/test_recipe_fins.json @@ -9,7 +9,7 @@ "netmask": "255.255.254.0", "port": 9600 }, - "protocol_type": 6, + "protocol_type": 5, "read_period": 100, "read_item_list": [ { diff --git a/APP_Framework/Framework/control/plc_protocol/include/fins.h b/APP_Framework/Framework/control/plc_protocol/include/fins.h index 549776752..a3501145f 100644 --- a/APP_Framework/Framework/control/plc_protocol/include/fins.h +++ b/APP_Framework/Framework/control/plc_protocol/include/fins.h @@ -70,9 +70,9 @@ typedef struct FinsDataInfo data_info; UniformValueType value_type; - char value_name[20]; + uint8_t value_name[20]; - char area_char; + uint8_t area_char; FinsDataType data_type; uint16_t start_address; uint8_t bit_address; diff --git a/APP_Framework/Framework/control/shared/control.c b/APP_Framework/Framework/control/shared/control.c index 3834a327f..44052d752 100755 --- a/APP_Framework/Framework/control/shared/control.c +++ b/APP_Framework/Framework/control/shared/control.c @@ -74,6 +74,9 @@ static int ControlAnalyzeRecipe(ControlProtocolType control_protocol, const char uint16_t recipe_file_length = 0; char *recipe_file_buf; + /*wait for SD-card mount done*/ + PrivTaskDelay(5000); + //Step1 : read recipe file data from SD card or other store device recipe_file_fd = PrivOpen(recipe_name, O_RDONLY); if (recipe_file_fd < 0) { @@ -110,7 +113,6 @@ static int ControlAnalyzeRecipe(ControlProtocolType control_protocol, const char //Step2 : CJSON analyze #ifdef LIB_USING_CJSON cJSON *recipe_file_json = cJSON_Parse(recipe_file_buf); - PrivFree(recipe_file_buf); if (NULL == recipe_file_json) { printf("Parse recipe_file_buf failed!\n"); return -1; @@ -120,14 +122,22 @@ static int ControlAnalyzeRecipe(ControlProtocolType control_protocol, const char memset(control_protocol->recipe, 0, sizeof(struct ControlRecipe)); /*Get basic information from recipe file*/ - if (RecipeBasicInformation(control_protocol->recipe, control_protocol->protocol_type, recipe_file_json) < 0) { + if (RecipeBasicInformation(control_protocol->recipe, recipe_file_json) < 0) { return -1; } + control_protocol->protocol_type = control_protocol->recipe->protocol_type; + + printf("%s %d control_protocol %p recipe %p\n", __func__, __LINE__, control_protocol, control_protocol->recipe); + /*Get the variable need to read from recipe file*/ - RecipeReadVariableItem(control_protocol->recipe, control_protocol->protocol_type, recipe_file_json); + RecipeReadVariableItem(control_protocol->recipe, recipe_file_json); + + control_protocol->done = control_protocol->recipe->done; cJSON_Delete(recipe_file_json); + + PrivFree(recipe_file_buf); printf("Read and parse recipe file done!\n"); #endif @@ -247,6 +257,8 @@ int ControlFrameworkInit(void) goto _out; } + printf("%s malloc control_protocol %p\n", __func__, control_protocol); + //Control Protocol Struct Init ret = ControlProtocolInit(control_protocol); if (ret < 0) { @@ -255,6 +267,8 @@ int ControlFrameworkInit(void) goto _out; } + printf("%s malloc CONTROL_RECIPE_FILE %s\n", __func__, CONTROL_RECIPE_FILE); + //Read Recipe File, Get Control Protocol Configure Param ret = ControlAnalyzeRecipe(control_protocol, CONTROL_RECIPE_FILE); if (ret < 0) { @@ -265,6 +279,8 @@ int ControlFrameworkInit(void) control_protocol->protocol_status = CONTROL_REGISTERED; + printf("%s recipe %p\n", __func__, control_protocol->recipe); + ret = ControlPeripheralInit(control_protocol->recipe); if (ret < 0) { printf("%s failed!\n", __func__); @@ -272,6 +288,8 @@ int ControlFrameworkInit(void) goto _out; } + printf("%s ControlPeripheralInit done\n", __func__); + _out: return ret; } diff --git a/APP_Framework/Framework/control/shared/control.h b/APP_Framework/Framework/control/shared/control.h index 4f7fb966f..c64467a3e 100644 --- a/APP_Framework/Framework/control/shared/control.h +++ b/APP_Framework/Framework/control/shared/control.h @@ -30,7 +30,6 @@ extern "C" { struct ControlProtocol; typedef struct ControlProtocol *ControlProtocolType; -typedef struct ControlData *ControlDataType; struct ControlDone { @@ -76,7 +75,6 @@ struct ControlProtocol sem_t sem; pthread_mutex_t lock; - //struct DoublelistNode link; }; /*Control Framework Protocol Init*/ @@ -85,12 +83,6 @@ int ControlFrameworkInit(void); /*Control Framework Find certain Protocol*/ ControlProtocolType ControlProtocolFind(void); -// /*Control Framework Protocol Register*/ -// int ControlProtocolRegister(struct ControlProtocol *control_protocol); - -// /*Control Framework Protocol Unregister*/ -// int ControlProtocolUnregister(struct ControlProtocol *control_protocol); - /*Control Framework Protocol Open*/ int ControlProtocolOpen(struct ControlProtocol *control_protocol); diff --git a/APP_Framework/Framework/control/shared/control_def.c b/APP_Framework/Framework/control/shared/control_def.c index 61443a091..3ded282e0 100644 --- a/APP_Framework/Framework/control/shared/control_def.c +++ b/APP_Framework/Framework/control/shared/control_def.c @@ -72,7 +72,7 @@ static int ControlProtocolInitDesc(struct ControlRecipe *p_recipe, struct Contro for( i = 0; sub_protocol_desc[i].fn != NULL; i++ ) { if (p_recipe->protocol_type == sub_protocol_desc[i].protocol_type) { ret = sub_protocol_desc[i].fn(p_recipe); - printf("control protocol initialize %d %s\n", sub_protocol_desc[i].protocol_type, ret == 0 ? "success" : "failed"); + printf("%s initialize %d %s\n", __func__, sub_protocol_desc[i].protocol_type, ret == 0 ? "success" : "failed"); break; } } @@ -87,16 +87,16 @@ static int ControlProtocolInitDesc(struct ControlRecipe *p_recipe, struct Contro static void FormatDataHeader(struct ControlRecipe *p_recipe) { uint16_t plc_read_data_length = CONTROL_DATA_HEAD_LENGTH + p_recipe->total_data_length;//Head length is CONTROL_DATA_HEAD_LENGTH - uint8_t *data = p_recipe->protocol_data->data; + uint8_t *data = p_recipe->protocol_data.data; data[0] = CONTROL_DATA_HEAD_1; data[1] = CONTROL_DATA_HEAD_2; - data[2] = (p_recipe->device_id) >> 8; - data[3] = p_recipe->device_id; - data[4] = (plc_read_data_length) >> 8; - data[5] = plc_read_data_length; - data[6] = (p_recipe->read_item_count) >> 8; - data[7] = p_recipe->read_item_count; + data[2] = (uint8_t)(p_recipe->device_id >> 8); + data[3] = (uint8_t)p_recipe->device_id; + data[4] = (uint8_t)(plc_read_data_length >> 8); + data[5] = (uint8_t)plc_read_data_length; + data[6] = (uint8_t)(p_recipe->read_item_count >> 8); + data[7] = (uint8_t)p_recipe->read_item_count; } /** @@ -236,8 +236,12 @@ int ControlConnectSocket(BasicSocketPlc *p_plc) return -4; } + printf("%s %d ip %u.%u.%u.%u port %d\n", __func__, __LINE__, + p_plc->ip[0], p_plc->ip[1], p_plc->ip[2], p_plc->ip[3], + p_plc->port); + if (connect(plc_socket, (struct sockaddr*)&plc_addr_in, sizeof(struct sockaddr)) == -1) { - printf("Connect plc socket failed!\n"); + printf("Connect plc socket failed!errno %d\n", errno); closesocket(plc_socket); return -5; } else { @@ -359,17 +363,12 @@ int ControlPeripheralInit(struct ControlRecipe *p_recipe) /** * @description: Control Framework Get Recipe Basic Information * @param p_recipe - Control recipe pointer - * @param protocol_type - protocol type * @param p_recipe_file_json - recipe_file_json pointer * @return success : 0 error : -1 */ -int RecipeBasicInformation(struct ControlRecipe *p_recipe, int protocol_type, cJSON *p_recipe_file_json) +int RecipeBasicInformation(struct ControlRecipe *p_recipe, cJSON *p_recipe_file_json) { - if (protocol_type != (ProtocolType)(cJSON_GetObjectItem(p_recipe_file_json, "protocol_type")->valueint)) { - printf("protocol type not match!\n"); - return -1; - } - p_recipe->protocol_type = protocol_type; + p_recipe->protocol_type = (ProtocolType)(cJSON_GetObjectItem(p_recipe_file_json, "protocol_type")->valueint); p_recipe->device_id = cJSON_GetObjectItem(p_recipe_file_json, "device_id")->valueint; strncpy(p_recipe->device_name, cJSON_GetObjectItem(p_recipe_file_json, "device_name")->valuestring, 20); @@ -394,17 +393,16 @@ int RecipeBasicInformation(struct ControlRecipe *p_recipe, int protocol_type, cJ printf("\n************************************************************\n"); } - +extern int FinsProtocolFormatCmd(struct ControlRecipe *p_recipe, ProtocolFormatInfo *protocol_format_info); /** * @description: Control Framework Read Variable Item Function * @param p_recipe - Control recipe pointer - * @param protocol_type - protocol type * @param p_recipe_file_json - recipe_file_json pointer * @return */ -void RecipeReadVariableItem(struct ControlRecipe *p_recipe, int protocol_type, cJSON *p_recipe_file_json) +void RecipeReadVariableItem(struct ControlRecipe *p_recipe, cJSON *p_recipe_file_json) { - int ret = 0; + int i, ret = 0; ProtocolFormatInfo protocol_format_info; memset(&protocol_format_info, 0, sizeof(ProtocolFormatInfo)); @@ -416,10 +414,13 @@ void RecipeReadVariableItem(struct ControlRecipe *p_recipe, int protocol_type, c p_recipe->total_data_length = GetRecipeTotalDataLength(read_item_list_json); /*Malloc Read Data Pointer, Reference "CONTROL FRAMEWORK READ DATA FORMAT"*/ - p_recipe->protocol_data = PrivMalloc(sizeof(struct ProtocolData)); - p_recipe->protocol_data->data = PrivMalloc(CONTROL_DATA_HEAD_LENGTH + p_recipe->total_data_length); - p_recipe->protocol_data->data_length = CONTROL_DATA_HEAD_LENGTH + p_recipe->total_data_length; - memset(p_recipe->protocol_data->data, 0, p_recipe->protocol_data->data_length); + p_recipe->protocol_data.data = PrivMalloc(CONTROL_DATA_HEAD_LENGTH + p_recipe->total_data_length); + p_recipe->protocol_data.data_length = CONTROL_DATA_HEAD_LENGTH + p_recipe->total_data_length; + memset(p_recipe->protocol_data.data, 0, p_recipe->protocol_data.data_length); + + protocol_format_info.p_read_item_data = p_recipe->protocol_data.data + CONTROL_DATA_HEAD_LENGTH; + + printf("%s %d recipe %p\n", __func__, __LINE__, p_recipe); /*Init The Control Protocol*/ ControlProtocolInitDesc(p_recipe, protocol_init); @@ -427,18 +428,26 @@ void RecipeReadVariableItem(struct ControlRecipe *p_recipe, int protocol_type, c /*Format Data Header, Reference "CONTROL FRAMEWORK READ DATA FORMAT"*/ FormatDataHeader(p_recipe); - for (uint16_t read_item_index = 0; read_item_index < p_recipe->read_item_count; read_item_index ++) { - cJSON *read_single_item_json = cJSON_GetArrayItem(read_item_list_json, read_item_index); + uint16_t read_item_count = p_recipe->read_item_count; + + printf("%s %d protocol_format_info %p read_item_count %p\n", __func__, __LINE__, &protocol_format_info, &(p_recipe->read_item_count)); + + for (i = 0; i < read_item_count; i ++) { + printf("%s %d read_item_index %d read_item_count %d\n", __func__, __LINE__, i, read_item_count); + + cJSON *read_single_item_json = cJSON_GetArrayItem(read_item_list_json, i); protocol_format_info.read_single_item_json = read_single_item_json; - protocol_format_info.read_item_index = read_item_index; + protocol_format_info.read_item_index = i; /*Format Protocol Cmd By Analyze Variable Item One By One*/ ret = p_recipe->ControlProtocolFormatCmd(p_recipe, &protocol_format_info); if (ret < 0) { - printf("%s read %d item failed!\n", __func__, read_item_index); + printf("%s read %d item failed!\n", __func__, i); continue; } + + printf("%s %d ret %d recipe %p count %p [%d] [%d]\n", __func__, __LINE__, ret, p_recipe, &(p_recipe->read_item_count), p_recipe->read_item_count, read_item_count); } } } diff --git a/APP_Framework/Framework/control/shared/control_def.h b/APP_Framework/Framework/control/shared/control_def.h index 10e5dfd0a..9126c6c1d 100644 --- a/APP_Framework/Framework/control/shared/control_def.h +++ b/APP_Framework/Framework/control/shared/control_def.h @@ -76,7 +76,9 @@ typedef struct typedef struct { cJSON *read_single_item_json; + uint8_t *p_read_item_data; uint16_t read_item_index;//Variable item index(1 ++) + uint8_t last_item_size; }ProtocolFormatInfo; struct ProtocolData @@ -104,7 +106,7 @@ struct SocketConfig struct ControlRecipe { - char device_name[20]; + uint8_t device_name[20]; uint16_t device_id; uint16_t read_period; uint16_t read_item_count; @@ -114,11 +116,12 @@ struct ControlRecipe ProtocolType protocol_type; void *read_item; + struct ControlDone *done; struct SerialConfig serial_config; struct SocketConfig socket_config; - struct ProtocolData *protocol_data; + struct ProtocolData protocol_data; int (*ControlProtocolFormatCmd)(struct ControlRecipe *p_recipe, ProtocolFormatInfo *protocol_format_info); }; @@ -127,10 +130,10 @@ struct ControlRecipe uint8_t GetValueTypeMemorySize(UniformValueType uniform_value_type); /*Get basic information from recipe file*/ -int RecipeBasicInformation(struct ControlRecipe *p_recipe, int protocol_type, cJSON *p_recipe_file_json); +int RecipeBasicInformation(struct ControlRecipe *p_recipe, cJSON *p_recipe_file_json); /*Get the variable need to read from recipe file*/ -void RecipeReadVariableItem(struct ControlRecipe *p_recipe, int protocol_type, cJSON *p_recipe_file_json); +void RecipeReadVariableItem(struct ControlRecipe *p_recipe, cJSON *p_recipe_file_json); /*Control Framework Peripheral Device Init*/ int ControlPeripheralInit(struct ControlRecipe *p_recipe); diff --git a/APP_Framework/Framework/control/shared/control_io.c b/APP_Framework/Framework/control/shared/control_io.c index 830e6d5b7..eb7172883 100644 --- a/APP_Framework/Framework/control/shared/control_io.c +++ b/APP_Framework/Framework/control/shared/control_io.c @@ -29,6 +29,10 @@ */ void SocketInit(char *ip, char *mask, char *gw) { + printf("%s ip %d.%d.%d.%d mask %d.%d.%d.%d gw %d.%d.%d.%d\n", __func__, + ip[0], ip[1], ip[2], ip[3], + mask[0], mask[1], mask[2], mask[3], + gw[0], gw[1], gw[2], gw[3]); #ifdef BSP_USING_LWIP lwip_config_tcp(0, ip, mask, gw); #endif diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/link.lds b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/link.lds index 9c0fec187..1940e5b81 100644 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/link.lds +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/link.lds @@ -48,8 +48,7 @@ Modification: /* Entry Point */ ENTRY(Reset_Handler) -HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400; -STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x1000; +STACK_SIZE = 0x4000; /* Specify the memory areas */ MEMORY diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif.c b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif.c index 2912af879..3df2f6e40 100755 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif.c +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/ethernet/enet_ethernetif.c @@ -85,7 +85,7 @@ void enet_delay(void) { volatile uint32_t i = 0; - for (i = 0; i < 1000000; ++i) + for (i = 0; i < 10000000; ++i) { __asm("NOP"); /* delay */ } diff --git a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/semc/semc_externsdram_test.c b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/semc/semc_externsdram_test.c index c09b6dc27..ba18eca61 100644 --- a/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/semc/semc_externsdram_test.c +++ b/Ubiquitous/XiZi_IIoT/board/xidatong-arm32/third_party_driver/semc/semc_externsdram_test.c @@ -5,6 +5,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ #include "board.h" +#include #define EXAMPLE_SEMC_START_ADDRESS (0x80000000U) diff --git a/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/lwipopts.h b/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/lwipopts.h index 392168382..698afb121 100644 --- a/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/lwipopts.h +++ b/Ubiquitous/XiZi_IIoT/resources/ethernet/LwIP/arch/lwipopts.h @@ -269,7 +269,7 @@ typedef unsigned int nfds_t; #define MEMP_LIB_MALLOC 1 #define MEMP_MEM_MALLOC 1 -#define lw_print //KPrintf +#define lw_print KPrintf #define lw_error KPrintf #define lw_notice KPrintf From ba31c9e0f8db6c0d6cb17a7b5ea5ea82eb284aea Mon Sep 17 00:00:00 2001 From: Liu_Weichao Date: Thu, 24 Nov 2022 16:07:41 +0800 Subject: [PATCH 12/14] feat add control_framework, socket connect OK and delete useless printf --- .../connection_app/socket_demo/lwip_tcp_socket_demo.c | 4 ++-- .../connection_app/socket_demo/lwip_udp_socket_demo.c | 4 ++-- .../control_app/plc_demo/omron/omron_cj2m.c | 7 ++++--- APP_Framework/Framework/control/shared/control.c | 8 +------- APP_Framework/Framework/control/shared/control_def.c | 10 +--------- 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c b/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c index da1dff600..b6e4f9428 100755 --- a/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c +++ b/APP_Framework/Applications/connection_app/socket_demo/lwip_tcp_socket_demo.c @@ -164,7 +164,7 @@ void TcpSocketRecvTest(int argc, char *argv[]) } #ifdef ADD_XIZI_FETURES - lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip); + lwip_config_tcp(0, lwip_ipaddr, lwip_netmask, tcp_socket_ip); sys_thread_new("TcpSocketRecvTask", TcpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); #endif @@ -231,7 +231,7 @@ void TcpSocketSendTest(int argc, char *argv[]) } #ifdef ADD_XIZI_FETURES - lwip_config_tcp(lwip_ipaddr, lwip_netmask, tcp_socket_ip); + lwip_config_tcp(0, lwip_ipaddr, lwip_netmask, tcp_socket_ip); sys_thread_new("Tcp Socket Send", TcpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); #endif #ifdef ADD_NUTTX_FETURES diff --git a/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c b/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c index 62465d4bc..51c94a6c3 100755 --- a/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c +++ b/APP_Framework/Applications/connection_app/socket_demo/lwip_udp_socket_demo.c @@ -144,7 +144,7 @@ void UdpSocketRecvTest(int argc, char *argv[]) } #ifdef ADD_XIZI_FETURES - lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip); + lwip_config_tcp(0, lwip_ipaddr, lwip_netmask, udp_socket_ip); sys_thread_new("UdpSocketRecvTask", UdpSocketRecvTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); #endif @@ -207,7 +207,7 @@ void UdpSocketSendTest(int argc, char *argv[]) } #ifdef ADD_XIZI_FETURES - lwip_config_tcp(lwip_ipaddr, lwip_netmask, udp_socket_ip); + lwip_config_tcp(0, lwip_ipaddr, lwip_netmask, udp_socket_ip); sys_thread_new("UdpSocketSendTask", UdpSocketSendTask, NULL, LWIP_TASK_STACK_SIZE, LWIP_DEMO_TASK_PRIO); #endif diff --git a/APP_Framework/Applications/control_app/plc_demo/omron/omron_cj2m.c b/APP_Framework/Applications/control_app/plc_demo/omron/omron_cj2m.c index a09c254c4..5b770a5ac 100644 --- a/APP_Framework/Applications/control_app/plc_demo/omron/omron_cj2m.c +++ b/APP_Framework/Applications/control_app/plc_demo/omron/omron_cj2m.c @@ -22,6 +22,7 @@ void ControlOmronTest(void) { + int i = 0; uint16_t read_data_length = 0; uint8_t read_data[1024] = {0}; ControlProtocolType fins_protocol = ControlProtocolFind(); @@ -35,11 +36,11 @@ void ControlOmronTest(void) if (CONTROL_REGISTERED == fins_protocol->protocol_status) { ControlProtocolOpen(fins_protocol); - PrivTaskDelay(10000); - - for (int i = 0; i < 10; i ++) { + 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); diff --git a/APP_Framework/Framework/control/shared/control.c b/APP_Framework/Framework/control/shared/control.c index 44052d752..871e31eb6 100755 --- a/APP_Framework/Framework/control/shared/control.c +++ b/APP_Framework/Framework/control/shared/control.c @@ -128,8 +128,6 @@ static int ControlAnalyzeRecipe(ControlProtocolType control_protocol, const char control_protocol->protocol_type = control_protocol->recipe->protocol_type; - printf("%s %d control_protocol %p recipe %p\n", __func__, __LINE__, control_protocol, control_protocol->recipe); - /*Get the variable need to read from recipe file*/ RecipeReadVariableItem(control_protocol->recipe, recipe_file_json); @@ -256,9 +254,7 @@ int ControlFrameworkInit(void) ret = -1; goto _out; } - - printf("%s malloc control_protocol %p\n", __func__, control_protocol); - + //Control Protocol Struct Init ret = ControlProtocolInit(control_protocol); if (ret < 0) { @@ -279,8 +275,6 @@ int ControlFrameworkInit(void) control_protocol->protocol_status = CONTROL_REGISTERED; - printf("%s recipe %p\n", __func__, control_protocol->recipe); - ret = ControlPeripheralInit(control_protocol->recipe); if (ret < 0) { printf("%s failed!\n", __func__); diff --git a/APP_Framework/Framework/control/shared/control_def.c b/APP_Framework/Framework/control/shared/control_def.c index 3ded282e0..c820e5c59 100644 --- a/APP_Framework/Framework/control/shared/control_def.c +++ b/APP_Framework/Framework/control/shared/control_def.c @@ -393,7 +393,7 @@ int RecipeBasicInformation(struct ControlRecipe *p_recipe, cJSON *p_recipe_file_ printf("\n************************************************************\n"); } -extern int FinsProtocolFormatCmd(struct ControlRecipe *p_recipe, ProtocolFormatInfo *protocol_format_info); + /** * @description: Control Framework Read Variable Item Function * @param p_recipe - Control recipe pointer @@ -420,8 +420,6 @@ void RecipeReadVariableItem(struct ControlRecipe *p_recipe, cJSON *p_recipe_file protocol_format_info.p_read_item_data = p_recipe->protocol_data.data + CONTROL_DATA_HEAD_LENGTH; - printf("%s %d recipe %p\n", __func__, __LINE__, p_recipe); - /*Init The Control Protocol*/ ControlProtocolInitDesc(p_recipe, protocol_init); @@ -430,11 +428,7 @@ void RecipeReadVariableItem(struct ControlRecipe *p_recipe, cJSON *p_recipe_file uint16_t read_item_count = p_recipe->read_item_count; - printf("%s %d protocol_format_info %p read_item_count %p\n", __func__, __LINE__, &protocol_format_info, &(p_recipe->read_item_count)); - for (i = 0; i < read_item_count; i ++) { - printf("%s %d read_item_index %d read_item_count %d\n", __func__, __LINE__, i, read_item_count); - cJSON *read_single_item_json = cJSON_GetArrayItem(read_item_list_json, i); protocol_format_info.read_single_item_json = read_single_item_json; @@ -446,8 +440,6 @@ void RecipeReadVariableItem(struct ControlRecipe *p_recipe, cJSON *p_recipe_file printf("%s read %d item failed!\n", __func__, i); continue; } - - printf("%s %d ret %d recipe %p count %p [%d] [%d]\n", __func__, __LINE__, ret, p_recipe, &(p_recipe->read_item_count), p_recipe->read_item_count, read_item_count); } } } From 8583ea25b6d77bf729dd9232b9c318db3223ac8a Mon Sep 17 00:00:00 2001 From: Liu_Weichao Date: Thu, 24 Nov 2022 17:20:40 +0800 Subject: [PATCH 13/14] feat add control_framework, support fins protocol OK --- APP_Framework/Framework/control/plc_protocol/fins/fins.c | 8 ++++---- APP_Framework/Framework/control/shared/control_def.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/APP_Framework/Framework/control/plc_protocol/fins/fins.c b/APP_Framework/Framework/control/plc_protocol/fins/fins.c index 397639d76..1c20eba77 100644 --- a/APP_Framework/Framework/control/plc_protocol/fins/fins.c +++ b/APP_Framework/Framework/control/plc_protocol/fins/fins.c @@ -117,9 +117,9 @@ static uint16_t FinsCommandGenerate(uint8_t *p_command, uint16_t plc_ip_4, uint1 static int FinsTransformRecvBuffToData(FinsReadItem *p_read_item, uint8_t *recv_buff) { FinsDataInfo *p_fins_data_info = &(p_read_item->data_info); - uint8_t error_code = recv_buff[3]; + uint8_t error_code = recv_buff[15]; if (error_code) { - printf("Data abnormal, abnormal error code is %08x!", error_code); + printf("Data abnormal, abnormal error code is 0x%x!\n", error_code); return -1; } recv_buff += 30; @@ -134,14 +134,14 @@ static int FinsTransformRecvBuffToData(FinsReadItem *p_read_item, uint8_t *recv_ if (FINS_DATA_TYPE_BIT == p_read_item->data_type) { memcpy(p_fins_data_info->base_data_info.p_data, recv_buff, data_length); - printf("%02x", p_fins_data_info->base_data_info.p_data[0]); + printf("0x%x", p_fins_data_info->base_data_info.p_data[0]); } else { uint8_t *p_data = p_fins_data_info->base_data_info.p_data; for (uint16_t i = 0; i < data_length; i ++) { p_data[2 * i] = recv_buff[2 * (data_length - i - 1)]; p_data[2 * i + 1] = recv_buff[2 * (data_length - i - 1) + 1]; - printf("%03x%03x", p_data[2 * i], p_data[2 * i + 1]); + printf("0x%x 0x%x", p_data[2 * i], p_data[2 * i + 1]); } } diff --git a/APP_Framework/Framework/control/shared/control_def.c b/APP_Framework/Framework/control/shared/control_def.c index c820e5c59..27ab2d761 100644 --- a/APP_Framework/Framework/control/shared/control_def.c +++ b/APP_Framework/Framework/control/shared/control_def.c @@ -186,7 +186,7 @@ void ControlPrintfList(char name[5], uint8_t *number_list, uint16_t length) { printf("\n******************%5s****************\n", name); for (int32_t i = 0;i < length;i ++) { - printf("%03x ", number_list[i]); + printf("0x%x ", number_list[i]); } printf("\n**************************************\n"); } From 22e35a70aadbfa67bb0cf37f7c6cc1c26ff4bc23 Mon Sep 17 00:00:00 2001 From: wuzheng Date: Fri, 25 Nov 2022 09:29:37 +0800 Subject: [PATCH 14/14] adapt wifi framework and fix 'strncat' problem --- .../Framework/connection/wifi/Makefile | 4 + .../connection/wifi/esp8285_wifi/Kconfig | 6 + .../connection/wifi/esp8285_wifi/Makefile | 5 + .../wifi/esp8285_wifi/esp8285_wifi.c | 106 +++++++++--------- APP_Framework/Framework/sensor/Makefile | 54 --------- 5 files changed, 68 insertions(+), 107 deletions(-) diff --git a/APP_Framework/Framework/connection/wifi/Makefile b/APP_Framework/Framework/connection/wifi/Makefile index cfa6cac9f..5e466adc5 100644 --- a/APP_Framework/Framework/connection/wifi/Makefile +++ b/APP_Framework/Framework/connection/wifi/Makefile @@ -17,5 +17,9 @@ ifeq ($(CONFIG_ADAPTER_ESP07S_WIFI),y) SRC_DIR += esp07s_wifi endif +ifeq ($(CONFIG_ADAPTER_ESP8285_WIFI),y) + SRC_DIR += esp8285_wifi +endif + include $(KERNEL_ROOT)/compiler.mk endif diff --git a/APP_Framework/Framework/connection/wifi/esp8285_wifi/Kconfig b/APP_Framework/Framework/connection/wifi/esp8285_wifi/Kconfig index f44e5d47a..6fea4cc6f 100644 --- a/APP_Framework/Framework/connection/wifi/esp8285_wifi/Kconfig +++ b/APP_Framework/Framework/connection/wifi/esp8285_wifi/Kconfig @@ -8,3 +8,9 @@ if ADD_NUTTX_FETURES default "/dev/ttyS1" endif +if ADD_XIZI_FETURES + config ADAPTER_ESP8285_DRIVER + string "ESP8285 device uart driver path" + default "/dev/uart1_dev1" +endif + diff --git a/APP_Framework/Framework/connection/wifi/esp8285_wifi/Makefile b/APP_Framework/Framework/connection/wifi/esp8285_wifi/Makefile index c1ee6bd29..0431e2732 100644 --- a/APP_Framework/Framework/connection/wifi/esp8285_wifi/Makefile +++ b/APP_Framework/Framework/connection/wifi/esp8285_wifi/Makefile @@ -5,3 +5,8 @@ ifeq ($(CONFIG_ADD_NUTTX_FETURES),y) include $(APPDIR)/Application.mk endif + +ifeq ($(CONFIG_ADD_XIZI_FETURES),y) + SRC_FILES := esp8285_wifi.c + include $(KERNEL_ROOT)/compiler.mk +endif \ No newline at end of file diff --git a/APP_Framework/Framework/connection/wifi/esp8285_wifi/esp8285_wifi.c b/APP_Framework/Framework/connection/wifi/esp8285_wifi/esp8285_wifi.c index f0a3b77c8..3c87225f1 100644 --- a/APP_Framework/Framework/connection/wifi/esp8285_wifi/esp8285_wifi.c +++ b/APP_Framework/Framework/connection/wifi/esp8285_wifi/esp8285_wifi.c @@ -205,16 +205,16 @@ static int Esp8285WifiSetUp(struct Adapter *adapter) PrivTaskDelay(2000); /* connect the router */ memset(cmd,0,sizeof(cmd)); - strncpy(cmd,"AT+CWJAP=",strlen("AT+CWJAP=")); - strncat(cmd,"\"",1); - strncat(cmd,param->wifi_ssid,strlen(param->wifi_ssid)); + strcat(cmd,"AT+CWJAP="); + strcat(cmd,"\""); + strcat(cmd,param->wifi_ssid); - strncat(cmd,"\"",1); - strncat(cmd,",",1); - strncat(cmd,"\"",1); - strncat(cmd,param->wifi_pwd,strlen(param->wifi_pwd)); + strcat(cmd,"\""); + strcat(cmd,","); + strcat(cmd,"\""); + strcat(cmd,param->wifi_pwd); - strncat(cmd,"\"",1); + strcat(cmd,"\""); strcat(cmd,"\r\n"); ret = AtCmdConfigAndCheck(agent, cmd, "OK"); @@ -279,17 +279,17 @@ static int Esp8285WifiSetAddr(struct Adapter *adapter, const char *ip, const cha /* e.g. AT+CIPSTA_DEF="192.168.6.100","192.168.6.1","255.255.255.0" */ memset(cmd,0,sizeof(cmd)); strncpy(cmd,"AT+CIPAP_DEF=",strlen(" AT+CIPAP_DEF=")); - strncat(cmd,"\"",1); - strncat(cmd,ip,strlen(ip)); - strncat(cmd,"\"",1); - strncat(cmd,",",1); - strncat(cmd,"\"",1); - strncat(cmd,gateway,strlen(gateway)); - strncat(cmd,"\"",1); - strncat(cmd,",",1); - strncat(cmd,"\"",1); - strncat(cmd,netmask,strlen(netmask)); - strncat(cmd,"\"",1); + strcat(cmd,"\""); + strcat(cmd,ip); + strcat(cmd,"\""); + strcat(cmd,","); + strcat(cmd,"\""); + strcat(cmd,gateway); + strcat(cmd,"\""); + strcat(cmd,","); + strcat(cmd,"\""); + strcat(cmd,netmask); + strcat(cmd,"\""); strcat(cmd,"\r\n"); ret = AtCmdConfigAndCheck(adapter->agent, cmd, "OK"); @@ -314,9 +314,9 @@ static int Esp8285WifiPing(struct Adapter *adapter, const char *destination) memset(cmd,0,sizeof(cmd)); strncpy(cmd,"AT+PING=",strlen("AT+PING=")); - strncat(cmd,"\"",1); - strncat(cmd,destination,strlen(destination)); - strncat(cmd,"\"",1); + strcat(cmd,"\""); + strcat(cmd,destination); + strcat(cmd,"\""); strcat(cmd,"\r\n"); ret = AtCmdConfigAndCheck(adapter->agent, cmd, "OK"); ///< config as softAP+station mode @@ -387,15 +387,15 @@ static int Esp8285WifiConnect(struct Adapter *adapter, enum NetRoleType net_role { //e.g. AT+CIPSTART="TCP","192.168.3.116",8080 protocol, server IP and port strncpy(cmd,"AT+CIPSTART=",strlen("AT+CIPSTART=")); - strncat(cmd,"\"",1); - strncat(cmd,"TCP",strlen("TCP")); - strncat(cmd,"\"",1); - strncat(cmd, ",", 1); - strncat(cmd,"\"",1); - strncat(cmd, ip, strlen(ip)); - strncat(cmd, "\"", 1); - strncat(cmd, ",", 1); - strncat(cmd, port, strlen(port)); + strcat(cmd,"\""); + strcat(cmd,"TCP"); + strcat(cmd,"\""); + strcat(cmd, ","); + strcat(cmd,"\""); + strcat(cmd, ip); + strcat(cmd, "\""); + strcat(cmd, ","); + strcat(cmd, port); strcat(cmd,"\r\n"); ret = AtCmdConfigAndCheck(agent, cmd, "OK"); @@ -408,19 +408,19 @@ static int Esp8285WifiConnect(struct Adapter *adapter, enum NetRoleType net_role { //e.g. AT+CIPSTART="UDP","192.168.3.116",8080,2233,0 UDP protocol, server IP, port,local port,udp mode strncpy(cmd,"AT+CIPSTART=",strlen("AT+CIPSTART=")); - strncat(cmd,"\"",1); - strncat(cmd,"UDP",strlen("UDP")); - strncat(cmd,"\"",1); - strncat(cmd, ",", 1); - strncat(cmd,"\"",1); - strncat(cmd, ip, strlen(ip)); - strncat(cmd, "\"", 1); - strncat(cmd, ",", 1); - strncat(cmd, port, strlen(port)); - strncat(cmd, ",", 1); - strncat(cmd, "2233", strlen("2233")); ///< local port - strncat(cmd, ",", 1); - strncat(cmd, "0", 1); ///< udp transparent transmission mode must be 0 + strcat(cmd,"\""); + strcat(cmd,"UDP"); + strcat(cmd,"\""); + strcat(cmd, ","); + strcat(cmd,"\""); + strcat(cmd, ip); + strcat(cmd, "\""); + strcat(cmd, ","); + strcat(cmd, port); + strcat(cmd, ","); + strcat(cmd, "2233"); ///< local port + strcat(cmd, ","); + strcat(cmd, "0"); ///< udp transparent transmission mode must be 0 strcat(cmd,"\r\n"); ret = AtCmdConfigAndCheck(agent, cmd, "OK"); @@ -523,15 +523,15 @@ static int Esp8285WifiIoctl(struct Adapter *adapter, int cmd, void *args) itoa(baud_rate, baud_str, 10); strncpy(at_cmd, "AT+UART_DEF=", strlen("AT+UART_DEF=")); - strncat(at_cmd, baud_str, strlen(baud_str)); - strncat(at_cmd, ",", 1); - strncat(at_cmd, "8", 1); - strncat(at_cmd, ",", 1); - strncat(at_cmd, "1", 1); - strncat(at_cmd, ",", 1); - strncat(at_cmd, "0", 1); - strncat(at_cmd, ",", 1); - strncat(at_cmd, "3", 1); + strcat(at_cmd, baud_str); + strcat(at_cmd, ","); + strcat(at_cmd, "8"); + strcat(at_cmd, ","); + strcat(at_cmd, "1"); + strcat(at_cmd, ","); + strcat(at_cmd, "0"); + strcat(at_cmd, ","); + strcat(at_cmd, "3"); strcat(at_cmd,"\r\n"); ret = AtCmdConfigAndCheck(adapter->agent, at_cmd, "OK"); diff --git a/APP_Framework/Framework/sensor/Makefile b/APP_Framework/Framework/sensor/Makefile index d278876be..2ac3900a9 100644 --- a/APP_Framework/Framework/sensor/Makefile +++ b/APP_Framework/Framework/sensor/Makefile @@ -65,57 +65,3 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y) include $(KERNEL_ROOT)/compiler.mk endif - -ifeq ($(ADD_XIZI_FETURES),y) - SRC_FILES := sensor.c - - ifeq ($(CONFIG_SENSOR_HCHO),y) - SRC_DIR += hcho - endif - - ifeq ($(CONFIG_SENSOR_TVOC),y) - SRC_DIR += tvoc - endif - - ifeq ($(CONFIG_SENSOR_IAQ),y) - SRC_DIR += iaq - endif - - ifeq ($(CONFIG_SENSOR_CH4),y) - SRC_DIR += ch4 - endif - - ifeq ($(CONFIG_SENSOR_CO2),y) - SRC_DIR += co2 - endif - - ifeq ($(CONFIG_SENSOR_PM),y) - SRC_DIR += pm - endif - - ifeq ($(CONFIG_SENSOR_VOICE),y) - SRC_DIR += voice - endif - - ifeq ($(CONFIG_SENSOR_TEMPERATURE),y) - SRC_DIR += temperature - endif - - ifeq ($(CONFIG_SENSOR_HUMIDITY),y) - SRC_DIR += humidity - endif - - ifeq ($(CONFIG_SENSOR_WINDSPEED),y) - SRC_DIR += windspeed - endif - - ifeq ($(CONFIG_SENSOR_WINDDIRECTION),y) - SRC_DIR += winddirection - endif - - ifeq ($(CONFIG_SENSOR_ALTITUDE),y) - SRC_DIR += altitude - endif - - include $(KERNEL_ROOT)/compiler.mk -endif \ No newline at end of file