forked from xuos/xiuos
add camera driver and examples for edu-riscv64
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
108
APP_Framework/Applications/app_test/test_camera.c
Normal file
108
APP_Framework/Applications/app_test/test_camera.c
Normal file
@@ -0,0 +1,108 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
|
||||
#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);
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
30
APP_Framework/Applications/app_test/test_touch.c
Normal file
30
APP_Framework/Applications/app_test/test_touch.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <transform.h>
|
||||
|
||||
#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);
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user