alienwalker 6 месяцев назад
Родитель
Сommit
9a1d6be9fd

+ 1 - 1
components/camera/luat_camera.h

@@ -87,7 +87,7 @@ typedef struct
 	uint8_t is_msb;	//0 or 1;
 	uint8_t is_two_line_rx; //0 or 1;
 	uint8_t seq_type;	//0 or 1
-	uint8_t plat_param[4];
+	uint8_t plat_param[4];//0 ddr 1
 #ifdef __LUATOS__
     luat_lcd_conf_t* lcd_conf;
 #else

+ 3 - 0
components/lcd/luat_lcd.h

@@ -237,6 +237,7 @@ int luat_lcd_IF_write_cmd_data(luat_lcd_conf_t* conf,const uint8_t cmd, const ui
 int luat_lcd_IF_read_cmd_data(luat_lcd_conf_t* conf,const uint8_t cmd, uint8_t *data, uint8_t data_len, uint8_t dummy_bit);
 int luat_lcd_IF_draw(luat_lcd_conf_t* conf, int16_t x1, int16_t y1, int16_t x2, int16_t y2, luat_color_t* color);
 int luat_lcd_IF_fill(luat_lcd_conf_t* conf, int16_t x1, int16_t y1, int16_t x2, int16_t y2, luat_color_t color);
+int luat_lcd_IF_show_camera(luat_lcd_conf_t* conf, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t data_address);
 int luat_lcd_IF_sleep(luat_lcd_conf_t* conf, uint8_t on_off);
 /**
  * @brief luat_lcd_init放到service里跑,避免luat_lcd_init里漫长的delay带来的影响
@@ -292,5 +293,7 @@ int luat_lcd_run_api_in_service(luat_lcd_api api, void *param, uint32_t param_le
 int luat_lcd_conf_add(luat_lcd_conf_t* conf);
 
 void luat_lcd_service_debug(void);
+
+
 #endif
 

+ 8 - 1
luat/demo/camera/spi_cam/gc0310.lua

@@ -319,7 +319,14 @@ local reg_table = {
 }
 
 function gc0310Init(cspiId,i2cId,speed,scanMode,onlyY)
-	local id = camera.init(cspiId,speed,1,1,2,1,0x00010101,onlyY,scanMode,640,480)
+        local id
+        if hmeta.chip() == "UIS8910" then
+                id = camera.init(cspiId,speed,1,1,2,1,0x00000401,onlyY,scanMode,640,480)
+                camera.reset_pin(1)
+                sys.wait(1)
+        else
+                id = camera.init(cspiId,speed,1,1,2,1,0x00010101,onlyY,scanMode,640,480)
+        end
 	for i=1,#reg_table do
 		i2c.send(i2cId,0x21,reg_table[i],1)
 	end

+ 40 - 5
luat/demo/camera/spi_cam/main.lua

@@ -82,11 +82,18 @@ local function press_key()
     log.info("boot press")
     sys.publish("PRESS", true)
 end
-gpio.setup(0, press_key, gpio.PULLDOWN, gpio.RISING)
-gpio.debounce(0, 100, 1)
+if hmeta.chip() == "UIS8910" then
+    gpio.setup(9, press_key, gpio.PULLDOWN, gpio.RISING)
+    gpio.debounce(9, 100, 1)
+else
+    gpio.setup(0, press_key, gpio.PULLDOWN, gpio.RISING)
+    gpio.debounce(0, 100, 1)
+end
+
 local rawbuff, err
 if RAW_MODE ~= 1 then
     rawbuff, err = zbuff.create(60 * 1024, 0, zbuff.HEAP_AUTO)
+    -- rawbuff, err = zbuff.create(400 * 1024, 0, zbuff.HEAP_AUTO) -- gc2145
 else
     rawbuff, err = zbuff.create(640 * 480 * 2, 0, zbuff.HEAP_AUTO) -- gc032a
     -- local rawbuff = zbuff.create(240 * 320 * 2, zbuff.HEAP_AUTO)  --bf302a
@@ -102,14 +109,41 @@ local function device_init()
     -- return gc032aInit(cspiId,i2cId,24000000,SCAN_MODE,SCAN_MODE)
 end
 
+local function pdwn(level)
+    if hmeta.chip() == "UIS8910" then
+        camera.pdwn_pin(level)
+    else
+        gpio.setup(5, level) -- PD拉低
+    end
+end
+
+local function send_to_pc(uart_id, buff)
+    local tx_buff = zbuff.create(16384)
+    local pos = 0
+    log.info("需要发送", buff:used(), "byte")
+    while pos < buff:used() do
+        if buff:used() - pos > 16384 then
+            tx_buff:copy(0, buff, pos, 16384)
+            pos = pos + 16384
+        else
+            tx_buff:copy(0, buff, pos, buff:used() - pos)
+            pos = buff:used()
+        end
+        uart.tx(uart_id, tx_buff)
+        tx_buff:del()
+        sys.wait(5)
+    end
+end
+
 sys.taskInit(function()
     log.info("摄像头启动")
     local i2cId = 0
     local camera_id
     i2c.setup(i2cId, i2c.FAST)
-    gpio.setup(5, 0) -- PD拉低
+
     camera_id = device_init()
 	camera.on(camera_id, "scanned", cb)
+    pdwn(0)
     if DONE_WITH_CLOSE then
         camera.close(camera_id)
     else
@@ -167,7 +201,7 @@ sys.taskInit(function()
                 log.info("摄像头捕获原始图像完成")
                 log.info(rtos.meminfo("sys"))
                 log.info(rtos.meminfo("psram"))
-                -- uart.tx(uartid, rawbuff) --找个能保存数据的串口工具保存成文件就能在电脑上看了, 格式为JPG                
+                send_to_pc(uartid, rawbuff) --找个能保存数据的串口工具保存成文件就能在电脑上看了, 格式为JPG                
             else
                 log.debug("摄像头拍照")
                 if DONE_WITH_CLOSE then
@@ -181,8 +215,9 @@ sys.taskInit(function()
                 else
                     camera.stop(camera_id)
                 end
-                --uart.tx(uartid, rawbuff) -- 找个能保存数据的串口工具保存成文件就能在电脑上看了, 格式为JPG
+                send_to_pc(uartid, rawbuff) -- 找个能保存数据的串口工具保存成文件就能在电脑上看了, 格式为JPG
                 rawbuff:resize(60 * 1024)
+                -- rawbuff:resize(400 * 1024) -- gc2145 200W
                 log.info(rtos.meminfo("sys"))
                 log.info(rtos.meminfo("psram"))
             end

+ 4 - 0
luat/modules/luat_lib_pm.c

@@ -670,6 +670,10 @@ static const rotable_Reg_t reg_pm[] =
     { "IOVOL_SDIO", ROREG_INT(LUAT_PM_LDO_TYPE_VMMC)},
 	//@const IOVOL_LCD number VLCD电压域IO
     { "IOVOL_LCD", ROREG_INT(LUAT_PM_LDO_TYPE_VLCD)},
+	//@const IOVOL_CAMA number camera模拟电压
+    { "IOVOL_CAMA", ROREG_INT(LUAT_PM_LDO_TYPE_CAMA)},
+	//@const IOVOL_CAMD number camera数字电压
+    { "IOVOL_CAMD", ROREG_INT(LUAT_PM_LDO_TYPE_CAMD)},
     //@const ID_NATIVE number PM控制的ID, 主芯片, 任意芯片的默认值就是它
     { "ID_NATIVE",      ROREG_INT(1)},
     //@const ID_WIFI number PM控制的ID, WIFI芯片, 仅Air8000可用