mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Replace sensor struct clock polarities with flags.
This commit is contained in:
parent
e0c5822c28
commit
ec1de1c2eb
@ -620,10 +620,11 @@ int ov2640_init(struct sensor_dev *sensor)
|
||||
sensor->set_quality = set_quality;
|
||||
sensor->set_colorbar = set_colorbar;
|
||||
|
||||
/* set HSYNC/VSYNC/PCLK polarity */
|
||||
sensor->vsync_pol = DCMI_VSPOLARITY_LOW;
|
||||
sensor->hsync_pol = DCMI_HSPOLARITY_LOW;
|
||||
sensor->pixck_pol = DCMI_PCKPOLARITY_RISING;
|
||||
// Set sensor flags
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_VSYNC, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_HSYNC, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_PIXCK, 1);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_FSYNC, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ static int set_colorbar(struct sensor_dev *sensor, int enable)
|
||||
|
||||
int ov7725_init(struct sensor_dev *sensor)
|
||||
{
|
||||
/* set function pointers */
|
||||
// Set function pointers
|
||||
sensor->reset = reset;
|
||||
sensor->set_pixformat = set_pixformat;
|
||||
sensor->set_framesize = set_framesize;
|
||||
@ -292,10 +292,11 @@ int ov7725_init(struct sensor_dev *sensor)
|
||||
sensor->set_gainceiling = set_gainceiling;
|
||||
sensor->set_colorbar = set_colorbar;
|
||||
|
||||
/* set HSYNC/VSYNC/PCLK polarity */
|
||||
sensor->vsync_pol = DCMI_VSPOLARITY_HIGH;
|
||||
sensor->hsync_pol = DCMI_HSPOLARITY_LOW;
|
||||
sensor->pixck_pol = DCMI_PCKPOLARITY_RISING;
|
||||
// Set sensor flags
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_VSYNC, 1);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_HSYNC, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_PIXCK, 1);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_FSYNC, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -345,7 +345,7 @@ static int set_gainceiling(struct sensor_dev *sensor, enum sensor_gainceiling ga
|
||||
|
||||
int ov9650_init(struct sensor_dev *sensor)
|
||||
{
|
||||
/* set function pointers */
|
||||
// Set function pointers
|
||||
sensor->reset = reset;
|
||||
sensor->set_pixformat = set_pixformat;
|
||||
sensor->set_framesize = set_framesize;
|
||||
@ -354,10 +354,11 @@ int ov9650_init(struct sensor_dev *sensor)
|
||||
sensor->set_exposure = set_exposure;
|
||||
sensor->set_gainceiling = set_gainceiling;
|
||||
|
||||
/* set HSYNC/VSYNC/PCLK polarity */
|
||||
sensor->vsync_pol = DCMI_VSPOLARITY_HIGH;
|
||||
sensor->hsync_pol = DCMI_HSPOLARITY_LOW;
|
||||
sensor->pixck_pol = DCMI_PCKPOLARITY_RISING;
|
||||
// Set sensor flags
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_VSYNC, 1);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_HSYNC, 0);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_PIXCK, 1);
|
||||
SENSOR_HW_FLAGS_SET(sensor, SENSOR_HW_FLAGS_FSYNC, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -115,9 +115,12 @@ static int dcmi_config(uint32_t jpeg_mode)
|
||||
{
|
||||
/* DCMI configuration */
|
||||
DCMIHandle.Instance = DCMI;
|
||||
DCMIHandle.Init.VSPolarity = sensor.vsync_pol; /* VSYNC clock polarity */
|
||||
DCMIHandle.Init.HSPolarity = sensor.hsync_pol; /* HSYNC clock polarity */
|
||||
DCMIHandle.Init.PCKPolarity = sensor.pixck_pol; /* PXCLK clock polarity */
|
||||
DCMIHandle.Init.VSPolarity = SENSOR_HW_FLAGS_GET(&sensor, SENSOR_HW_FLAGS_VSYNC) ? /* VSYNC clock polarity */
|
||||
DCMI_VSPOLARITY_HIGH : DCMI_VSPOLARITY_LOW;
|
||||
DCMIHandle.Init.HSPolarity = SENSOR_HW_FLAGS_GET(&sensor, SENSOR_HW_FLAGS_HSYNC) ? /* HSYNC clock polarity */
|
||||
DCMI_HSPOLARITY_HIGH : DCMI_HSPOLARITY_LOW;
|
||||
DCMIHandle.Init.PCKPolarity = SENSOR_HW_FLAGS_GET(&sensor, SENSOR_HW_FLAGS_PIXCK) ? /* PXCLK clock polarity */
|
||||
DCMI_PCKPOLARITY_RISING : DCMI_PCKPOLARITY_FALLING;
|
||||
DCMIHandle.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE; /* Enable Hardware synchronization */
|
||||
DCMIHandle.Init.CaptureRate = DCMI_CR_ALL_FRAME; /* Capture rate all frames */
|
||||
DCMIHandle.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B; /* Capture 8 bits on every pixel clock */
|
||||
|
||||
@ -70,12 +70,17 @@ enum reset_polarity {
|
||||
extern const int res_width[];
|
||||
extern const int res_height[];
|
||||
|
||||
#define SENSOR_HW_FLAGS_VSYNC (0) // vertical sync polarity.
|
||||
#define SENSOR_HW_FLAGS_HSYNC (1) // horizontal sync polarity.
|
||||
#define SENSOR_HW_FLAGS_PIXCK (2) // pixel clock edge.
|
||||
#define SENSOR_HW_FLAGS_FSYNC (3) // hardware frame sync.
|
||||
#define SENSOR_HW_FLAGS_GET(s, x) ((s)->hw_flags & (1<<x))
|
||||
#define SENSOR_HW_FLAGS_SET(s, x, v) ((s)->hw_flags |= (v<<x))
|
||||
|
||||
struct sensor_dev {
|
||||
struct sensor_id id;
|
||||
uint8_t slv_addr;
|
||||
uint32_t vsync_pol;
|
||||
uint32_t hsync_pol;
|
||||
uint32_t pixck_pol;
|
||||
uint32_t hw_flags;
|
||||
enum reset_polarity reset_pol;
|
||||
enum sensor_pixformat pixformat;
|
||||
enum sensor_framesize framesize;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user