mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Use typdef's for sensor enum and structs.
This commit is contained in:
parent
d639df0bfe
commit
d3d7e5dc39
@ -384,7 +384,7 @@ static const uint8_t saturation_regs[NUM_SATURATION_LEVELS + 1][5] = {
|
|||||||
{ 0x00, 0x02, 0x03, 0x58, 0x58 }, /* +2 */
|
{ 0x00, 0x02, 0x03, 0x58, 0x58 }, /* +2 */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int reset(struct sensor_dev *sensor)
|
static int reset(sensor_t *sensor)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
const uint8_t (*regs)[2];
|
const uint8_t (*regs)[2];
|
||||||
@ -415,7 +415,7 @@ static int reset(struct sensor_dev *sensor)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_pixformat(struct sensor_dev *sensor, enum sensor_pixformat pixformat)
|
static int set_pixformat(sensor_t *sensor, pixformat_t pixformat)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
const uint8_t (*regs)[2]=NULL;
|
const uint8_t (*regs)[2]=NULL;
|
||||||
@ -444,7 +444,7 @@ static int set_pixformat(struct sensor_dev *sensor, enum sensor_pixformat pixfor
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_framesize(struct sensor_dev *sensor, enum sensor_framesize framesize)
|
static int set_framesize(sensor_t *sensor, framesize_t framesize)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
uint8_t clkrc;
|
uint8_t clkrc;
|
||||||
@ -488,12 +488,12 @@ static int set_framesize(struct sensor_dev *sensor, enum sensor_framesize frames
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_framerate(struct sensor_dev *sensor, enum sensor_framerate framerate)
|
static int set_framerate(sensor_t *sensor, framerate_t framerate)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_contrast(struct sensor_dev *sensor, int level)
|
static int set_contrast(sensor_t *sensor, int level)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ static int set_contrast(struct sensor_dev *sensor, int level)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_brightness(struct sensor_dev *sensor, int level)
|
static int set_brightness(sensor_t *sensor, int level)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
|
|
||||||
@ -533,7 +533,7 @@ static int set_brightness(struct sensor_dev *sensor, int level)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_saturation(struct sensor_dev *sensor, int level)
|
static int set_saturation(sensor_t *sensor, int level)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
|
|
||||||
@ -553,12 +553,12 @@ static int set_saturation(struct sensor_dev *sensor, int level)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_exposure(struct sensor_dev *sensor, int exposure)
|
static int set_exposure(sensor_t *sensor, int exposure)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_gainceiling(struct sensor_dev *sensor, enum sensor_gainceiling gainceiling)
|
static int set_gainceiling(sensor_t *sensor, gainceiling_t gainceiling)
|
||||||
{
|
{
|
||||||
int ret =0;
|
int ret =0;
|
||||||
|
|
||||||
@ -571,7 +571,7 @@ static int set_gainceiling(struct sensor_dev *sensor, enum sensor_gainceiling ga
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_quality(struct sensor_dev *sensor, int qs)
|
static int set_quality(sensor_t *sensor, int qs)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
|
|
||||||
@ -584,7 +584,7 @@ static int set_quality(struct sensor_dev *sensor, int qs)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_colorbar(struct sensor_dev *sensor, int enable)
|
static int set_colorbar(sensor_t *sensor, int enable)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
uint8_t reg;
|
uint8_t reg;
|
||||||
@ -605,7 +605,7 @@ static int set_colorbar(struct sensor_dev *sensor, int enable)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ov2640_init(struct sensor_dev *sensor)
|
int ov2640_init(sensor_t *sensor)
|
||||||
{
|
{
|
||||||
/* set function pointers */
|
/* set function pointers */
|
||||||
sensor->reset = reset;
|
sensor->reset = reset;
|
||||||
|
|||||||
@ -9,5 +9,5 @@
|
|||||||
#ifndef __OV2640_H__
|
#ifndef __OV2640_H__
|
||||||
#define __OV2640_H__
|
#define __OV2640_H__
|
||||||
#include "sensor.h"
|
#include "sensor.h"
|
||||||
int ov2640_init(struct sensor_dev *sensor);
|
int ov2640_init(sensor_t *sensor);
|
||||||
#endif // __OV2640_H__
|
#endif // __OV2640_H__
|
||||||
|
|||||||
@ -148,7 +148,7 @@ static const uint8_t saturation_regs[NUM_SATURATION_LEVELS][2] = {
|
|||||||
{0x80, 0x80}, /* +4 */
|
{0x80, 0x80}, /* +4 */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int reset(struct sensor_dev *sensor)
|
static int reset(sensor_t *sensor)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
const uint8_t (*regs)[2];
|
const uint8_t (*regs)[2];
|
||||||
@ -167,7 +167,7 @@ static int reset(struct sensor_dev *sensor)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_pixformat(struct sensor_dev *sensor, enum sensor_pixformat pixformat)
|
static int set_pixformat(sensor_t *sensor, pixformat_t pixformat)
|
||||||
{
|
{
|
||||||
// Read register COM7
|
// Read register COM7
|
||||||
uint8_t reg = SCCB_Read(sensor->slv_addr, COM7);
|
uint8_t reg = SCCB_Read(sensor->slv_addr, COM7);
|
||||||
@ -188,7 +188,7 @@ static int set_pixformat(struct sensor_dev *sensor, enum sensor_pixformat pixfor
|
|||||||
return SCCB_Write(sensor->slv_addr, COM7, reg);
|
return SCCB_Write(sensor->slv_addr, COM7, reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_framesize(struct sensor_dev *sensor, enum sensor_framesize framesize)
|
static int set_framesize(sensor_t *sensor, framesize_t framesize)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
uint16_t w = resolution[framesize][0];
|
uint16_t w = resolution[framesize][0];
|
||||||
@ -203,12 +203,12 @@ static int set_framesize(struct sensor_dev *sensor, enum sensor_framesize frames
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_framerate(struct sensor_dev *sensor, enum sensor_framerate framerate)
|
static int set_framerate(sensor_t *sensor, framerate_t framerate)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_contrast(struct sensor_dev *sensor, int level)
|
static int set_contrast(sensor_t *sensor, int level)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ static int set_contrast(struct sensor_dev *sensor, int level)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_brightness(struct sensor_dev *sensor, int level)
|
static int set_brightness(sensor_t *sensor, int level)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ static int set_brightness(struct sensor_dev *sensor, int level)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_saturation(struct sensor_dev *sensor, int level)
|
static int set_saturation(sensor_t *sensor, int level)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
|
|
||||||
@ -249,12 +249,12 @@ static int set_saturation(struct sensor_dev *sensor, int level)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_exposure(struct sensor_dev *sensor, int exposure)
|
static int set_exposure(sensor_t *sensor, int exposure)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_gainceiling(struct sensor_dev *sensor, enum sensor_gainceiling gainceiling)
|
static int set_gainceiling(sensor_t *sensor, gainceiling_t gainceiling)
|
||||||
{
|
{
|
||||||
// Read register COM9
|
// Read register COM9
|
||||||
uint8_t reg = SCCB_Read(sensor->slv_addr, COM9);
|
uint8_t reg = SCCB_Read(sensor->slv_addr, COM9);
|
||||||
@ -266,7 +266,7 @@ static int set_gainceiling(struct sensor_dev *sensor, enum sensor_gainceiling ga
|
|||||||
return SCCB_Write(sensor->slv_addr, COM9, reg);
|
return SCCB_Write(sensor->slv_addr, COM9, reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_colorbar(struct sensor_dev *sensor, int enable)
|
static int set_colorbar(sensor_t *sensor, int enable)
|
||||||
{
|
{
|
||||||
// Read register COM3
|
// Read register COM3
|
||||||
uint8_t reg = SCCB_Read(sensor->slv_addr, COM3);
|
uint8_t reg = SCCB_Read(sensor->slv_addr, COM3);
|
||||||
@ -281,7 +281,7 @@ static int set_colorbar(struct sensor_dev *sensor, int enable)
|
|||||||
return SCCB_Write(sensor->slv_addr, COM3, reg);
|
return SCCB_Write(sensor->slv_addr, COM3, reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_special_effect(struct sensor_dev *sensor, enum sensor_sde sde)
|
static int set_special_effect(sensor_t *sensor, sde_t sde)
|
||||||
{
|
{
|
||||||
int ret=0;
|
int ret=0;
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ static int set_special_effect(struct sensor_dev *sensor, enum sensor_sde sde)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ov7725_init(struct sensor_dev *sensor)
|
int ov7725_init(sensor_t *sensor)
|
||||||
{
|
{
|
||||||
// Set function pointers
|
// Set function pointers
|
||||||
sensor->reset = reset;
|
sensor->reset = reset;
|
||||||
|
|||||||
@ -9,5 +9,5 @@
|
|||||||
#ifndef __OV7725_H__
|
#ifndef __OV7725_H__
|
||||||
#define __OV7725_H__
|
#define __OV7725_H__
|
||||||
#include "sensor.h"
|
#include "sensor.h"
|
||||||
int ov7725_init(struct sensor_dev *sensor);
|
int ov7725_init(sensor_t *sensor);
|
||||||
#endif // __OV7725_H__
|
#endif // __OV7725_H__
|
||||||
|
|||||||
@ -196,7 +196,7 @@ static const uint8_t yuv422_regs[][2] = {
|
|||||||
{0x00, 0x00}
|
{0x00, 0x00}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int reset(struct sensor_dev *sensor)
|
static int reset(sensor_t *sensor)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
const uint8_t (*regs)[2]=default_regs;
|
const uint8_t (*regs)[2]=default_regs;
|
||||||
@ -216,7 +216,7 @@ static int reset(struct sensor_dev *sensor)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_pixformat(struct sensor_dev *sensor, enum sensor_pixformat pixformat)
|
static int set_pixformat(sensor_t *sensor, pixformat_t pixformat)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
const uint8_t (*regs)[2];
|
const uint8_t (*regs)[2];
|
||||||
@ -254,7 +254,7 @@ static int set_pixformat(struct sensor_dev *sensor, enum sensor_pixformat pixfor
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_framesize(struct sensor_dev *sensor, enum sensor_framesize framesize)
|
static int set_framesize(sensor_t *sensor, framesize_t framesize)
|
||||||
{
|
{
|
||||||
uint8_t com7=0; /* framesize/RGB */
|
uint8_t com7=0; /* framesize/RGB */
|
||||||
uint8_t com1=0; /* Skip option */
|
uint8_t com1=0; /* Skip option */
|
||||||
@ -285,14 +285,14 @@ static int set_framesize(struct sensor_dev *sensor, enum sensor_framesize frames
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_framerate(struct sensor_dev *sensor, enum sensor_framerate framerate)
|
static int set_framerate(sensor_t *sensor, framerate_t framerate)
|
||||||
{
|
{
|
||||||
/* Write framerate register */
|
/* Write framerate register */
|
||||||
SCCB_Write(sensor->slv_addr, REG_CLKRC, framerate);
|
SCCB_Write(sensor->slv_addr, REG_CLKRC, framerate);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_brightness(struct sensor_dev *sensor, int level)
|
static int set_brightness(sensor_t *sensor, int level)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ static int set_brightness(struct sensor_dev *sensor, int level)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_exposure(struct sensor_dev *sensor, int exposure)
|
static int set_exposure(sensor_t *sensor, int exposure)
|
||||||
{
|
{
|
||||||
uint8_t val;
|
uint8_t val;
|
||||||
val = SCCB_Read(sensor->slv_addr, REG_COM1);
|
val = SCCB_Read(sensor->slv_addr, REG_COM1);
|
||||||
@ -336,14 +336,14 @@ static int set_exposure(struct sensor_dev *sensor, int exposure)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_gainceiling(struct sensor_dev *sensor, enum sensor_gainceiling gainceiling)
|
static int set_gainceiling(sensor_t *sensor, gainceiling_t gainceiling)
|
||||||
{
|
{
|
||||||
/* Write gain ceiling register */
|
/* Write gain ceiling register */
|
||||||
SCCB_Write(sensor->slv_addr, REG_COM9, (gainceiling<<4));
|
SCCB_Write(sensor->slv_addr, REG_COM9, (gainceiling<<4));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ov9650_init(struct sensor_dev *sensor)
|
int ov9650_init(sensor_t *sensor)
|
||||||
{
|
{
|
||||||
// Set function pointers
|
// Set function pointers
|
||||||
sensor->reset = reset;
|
sensor->reset = reset;
|
||||||
|
|||||||
@ -9,5 +9,5 @@
|
|||||||
#ifndef __OV9650_H__
|
#ifndef __OV9650_H__
|
||||||
#define __OV9650_H__
|
#define __OV9650_H__
|
||||||
#include "sensor.h"
|
#include "sensor.h"
|
||||||
int ov9650_init(struct sensor_dev *sensor);
|
int ov9650_init(sensor_t *sensor);
|
||||||
#endif // __OV9650_H__
|
#endif // __OV9650_H__
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#define JPEG_INIT_BUF (5*1024)
|
#define JPEG_INIT_BUF (5*1024)
|
||||||
|
|
||||||
extern struct sensor_dev sensor;
|
extern sensor_t sensor;
|
||||||
static const mp_obj_type_t py_cascade_type;
|
static const mp_obj_type_t py_cascade_type;
|
||||||
static const mp_obj_type_t py_image_type;
|
static const mp_obj_type_t py_image_type;
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
#include "py_sensor.h"
|
#include "py_sensor.h"
|
||||||
#include "omv_boardconfig.h"
|
#include "omv_boardconfig.h"
|
||||||
|
|
||||||
extern struct sensor_dev sensor;
|
extern sensor_t sensor;
|
||||||
|
|
||||||
static mp_obj_t py_sensor_reset() {
|
static mp_obj_t py_sensor_reset() {
|
||||||
sensor_reset();
|
sensor_reset();
|
||||||
@ -54,7 +54,7 @@ static mp_obj_t py_sensor_set_pixformat(mp_obj_t pixformat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static mp_obj_t py_sensor_set_framerate(mp_obj_t framerate) {
|
static mp_obj_t py_sensor_set_framerate(mp_obj_t framerate) {
|
||||||
enum sensor_framerate fr;
|
framerate_t fr;
|
||||||
switch (mp_obj_get_int(framerate)) {
|
switch (mp_obj_get_int(framerate)) {
|
||||||
case 2:
|
case 2:
|
||||||
fr = FRAMERATE_2FPS;
|
fr = FRAMERATE_2FPS;
|
||||||
@ -90,7 +90,7 @@ static mp_obj_t py_sensor_set_framesize(mp_obj_t framesize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static mp_obj_t py_sensor_set_gainceiling(mp_obj_t gainceiling) {
|
static mp_obj_t py_sensor_set_gainceiling(mp_obj_t gainceiling) {
|
||||||
enum sensor_gainceiling gain;
|
gainceiling_t gain;
|
||||||
switch (mp_obj_get_int(gainceiling)) {
|
switch (mp_obj_get_int(gainceiling)) {
|
||||||
case 2:
|
case 2:
|
||||||
gain = GAINCEILING_2X;
|
gain = GAINCEILING_2X;
|
||||||
|
|||||||
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#define MAX_XFER_SIZE (0xFFFC)
|
#define MAX_XFER_SIZE (0xFFFC)
|
||||||
|
|
||||||
struct sensor_dev sensor;
|
sensor_t sensor;
|
||||||
TIM_HandleTypeDef TIMHandle;
|
TIM_HandleTypeDef TIMHandle;
|
||||||
DMA_HandleTypeDef DMAHandle;
|
DMA_HandleTypeDef DMAHandle;
|
||||||
DCMI_HandleTypeDef DCMIHandle;
|
DCMI_HandleTypeDef DCMIHandle;
|
||||||
@ -188,7 +188,7 @@ int sensor_init()
|
|||||||
//HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1);
|
//HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_HSI, RCC_MCODIV_1);
|
||||||
|
|
||||||
/* Reset the sesnor state */
|
/* Reset the sesnor state */
|
||||||
memset(&sensor, 0, sizeof(struct sensor_dev));
|
memset(&sensor, 0, sizeof(sensor_t));
|
||||||
|
|
||||||
/* Some sensors have different reset polarities, and we can't know which sensor
|
/* Some sensors have different reset polarities, and we can't know which sensor
|
||||||
is connected before initializing SCCB and probing the sensor, which in turn
|
is connected before initializing SCCB and probing the sensor, which in turn
|
||||||
@ -293,7 +293,7 @@ int sensor_write_reg(uint8_t reg, uint8_t val)
|
|||||||
return SCCB_Write(sensor.slv_addr, reg, val);
|
return SCCB_Write(sensor.slv_addr, reg, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sensor_set_pixformat(enum sensor_pixformat pixformat)
|
int sensor_set_pixformat(pixformat_t pixformat)
|
||||||
{
|
{
|
||||||
uint32_t jpeg_mode = DCMI_JPEG_DISABLE;
|
uint32_t jpeg_mode = DCMI_JPEG_DISABLE;
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ int sensor_set_pixformat(enum sensor_pixformat pixformat)
|
|||||||
return dcmi_config(jpeg_mode);
|
return dcmi_config(jpeg_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int sensor_set_framesize(enum sensor_framesize framesize)
|
int sensor_set_framesize(framesize_t framesize)
|
||||||
{
|
{
|
||||||
if (sensor.framesize == framesize) {
|
if (sensor.framesize == framesize) {
|
||||||
/* no change */
|
/* no change */
|
||||||
@ -363,7 +363,7 @@ int sensor_set_framesize(enum sensor_framesize framesize)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sensor_set_framerate(enum sensor_framerate framerate)
|
int sensor_set_framerate(framerate_t framerate)
|
||||||
{
|
{
|
||||||
if (sensor.framerate == framerate) {
|
if (sensor.framerate == framerate) {
|
||||||
/* no change */
|
/* no change */
|
||||||
@ -412,7 +412,7 @@ int sensor_set_exposure(int exposure)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sensor_set_gainceiling(enum sensor_gainceiling gainceiling)
|
int sensor_set_gainceiling(gainceiling_t gainceiling)
|
||||||
{
|
{
|
||||||
if (sensor.gainceiling == gainceiling) {
|
if (sensor.gainceiling == gainceiling) {
|
||||||
/* no change */
|
/* no change */
|
||||||
@ -452,7 +452,7 @@ int sensor_set_colorbar(int enable)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sensor_set_special_effect(enum sensor_sde sde)
|
int sensor_set_special_effect(sde_t sde)
|
||||||
{
|
{
|
||||||
if (sensor.sde == sde) {
|
if (sensor.sde == sde) {
|
||||||
/* no change */
|
/* no change */
|
||||||
@ -496,7 +496,7 @@ void DCMI_DMAConvCpltUser(uint32_t addr)
|
|||||||
// The JPEG offset allows JPEG compression of the framebuffer without overwriting the pixels.
|
// The JPEG offset allows JPEG compression of the framebuffer without overwriting the pixels.
|
||||||
// The offset size may need to be adjusted depending on the quality, otherwise JPEG data may
|
// The offset size may need to be adjusted depending on the quality, otherwise JPEG data may
|
||||||
// overwrite image pixels before they are compressed.
|
// overwrite image pixels before they are compressed.
|
||||||
int sensor_snapshot(struct image *image)
|
int sensor_snapshot(image_t *image)
|
||||||
{
|
{
|
||||||
volatile uint32_t addr;
|
volatile uint32_t addr;
|
||||||
volatile uint16_t length;
|
volatile uint16_t length;
|
||||||
|
|||||||
@ -15,21 +15,21 @@
|
|||||||
#define OV2640_PID (0x26)
|
#define OV2640_PID (0x26)
|
||||||
#define OV7725_PID (0x77)
|
#define OV7725_PID (0x77)
|
||||||
|
|
||||||
struct sensor_id {
|
typedef struct {
|
||||||
uint8_t MIDH;
|
uint8_t MIDH;
|
||||||
uint8_t MIDL;
|
uint8_t MIDL;
|
||||||
uint8_t PID;
|
uint8_t PID;
|
||||||
uint8_t VER;
|
uint8_t VER;
|
||||||
};
|
} sensor_id_t;
|
||||||
|
|
||||||
enum sensor_pixformat {
|
typedef enum {
|
||||||
PIXFORMAT_RGB565, // 2BPP/RGB565
|
PIXFORMAT_RGB565, // 2BPP/RGB565
|
||||||
PIXFORMAT_YUV422, // 2BPP/YUV422
|
PIXFORMAT_YUV422, // 2BPP/YUV422
|
||||||
PIXFORMAT_GRAYSCALE, // 1BPP/GRAYSCALE
|
PIXFORMAT_GRAYSCALE, // 1BPP/GRAYSCALE
|
||||||
PIXFORMAT_JPEG, // JPEG/COMPRESSED
|
PIXFORMAT_JPEG, // JPEG/COMPRESSED
|
||||||
};
|
} pixformat_t;
|
||||||
|
|
||||||
enum sensor_framesize {
|
typedef enum {
|
||||||
FRAMESIZE_QQCIF, // 88x72
|
FRAMESIZE_QQCIF, // 88x72
|
||||||
FRAMESIZE_QQVGA, // 160x120
|
FRAMESIZE_QQVGA, // 160x120
|
||||||
FRAMESIZE_QQVGA2, // 128x160
|
FRAMESIZE_QQVGA2, // 128x160
|
||||||
@ -41,19 +41,17 @@ enum sensor_framesize {
|
|||||||
FRAMESIZE_SVGA, // 800x600
|
FRAMESIZE_SVGA, // 800x600
|
||||||
FRAMESIZE_SXGA, // 1280x1024
|
FRAMESIZE_SXGA, // 1280x1024
|
||||||
FRAMESIZE_UXGA, // 1600x1200
|
FRAMESIZE_UXGA, // 1600x1200
|
||||||
};
|
} framesize_t;
|
||||||
|
|
||||||
extern const int resolution[][2];
|
typedef enum {
|
||||||
|
|
||||||
enum sensor_framerate {
|
|
||||||
FRAMERATE_2FPS =0x9F,
|
FRAMERATE_2FPS =0x9F,
|
||||||
FRAMERATE_8FPS =0x87,
|
FRAMERATE_8FPS =0x87,
|
||||||
FRAMERATE_15FPS=0x83,
|
FRAMERATE_15FPS=0x83,
|
||||||
FRAMERATE_30FPS=0x81,
|
FRAMERATE_30FPS=0x81,
|
||||||
FRAMERATE_60FPS=0x80,
|
FRAMERATE_60FPS=0x80,
|
||||||
};
|
} framerate_t;
|
||||||
|
|
||||||
enum sensor_gainceiling {
|
typedef enum {
|
||||||
GAINCEILING_2X,
|
GAINCEILING_2X,
|
||||||
GAINCEILING_4X,
|
GAINCEILING_4X,
|
||||||
GAINCEILING_8X,
|
GAINCEILING_8X,
|
||||||
@ -61,24 +59,24 @@ enum sensor_gainceiling {
|
|||||||
GAINCEILING_32X,
|
GAINCEILING_32X,
|
||||||
GAINCEILING_64X,
|
GAINCEILING_64X,
|
||||||
GAINCEILING_128X,
|
GAINCEILING_128X,
|
||||||
};
|
} gainceiling_t;
|
||||||
|
|
||||||
enum sensor_sde {
|
typedef enum {
|
||||||
SDE_NORMAL,
|
SDE_NORMAL,
|
||||||
SDE_NEGATIVE,
|
SDE_NEGATIVE,
|
||||||
};
|
} sde_t;
|
||||||
|
|
||||||
enum sensor_attr {
|
typedef enum {
|
||||||
ATTR_CONTRAST=0,
|
ATTR_CONTRAST=0,
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_SATURATION,
|
ATTR_SATURATION,
|
||||||
ATTR_GAINCEILING,
|
ATTR_GAINCEILING,
|
||||||
};
|
} sensor_attr_t;
|
||||||
|
|
||||||
enum reset_polarity {
|
typedef enum {
|
||||||
ACTIVE_LOW,
|
ACTIVE_LOW,
|
||||||
ACTIVE_HIGH
|
ACTIVE_HIGH
|
||||||
};
|
} reset_polarity_t;
|
||||||
|
|
||||||
#define SENSOR_HW_FLAGS_VSYNC (0) // vertical sync polarity.
|
#define SENSOR_HW_FLAGS_VSYNC (0) // vertical sync polarity.
|
||||||
#define SENSOR_HW_FLAGS_HSYNC (1) // horizontal sync polarity.
|
#define SENSOR_HW_FLAGS_HSYNC (1) // horizontal sync polarity.
|
||||||
@ -87,33 +85,37 @@ enum reset_polarity {
|
|||||||
#define SENSOR_HW_FLAGS_GET(s, x) ((s)->hw_flags & (1<<x))
|
#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))
|
#define SENSOR_HW_FLAGS_SET(s, x, v) ((s)->hw_flags |= (v<<x))
|
||||||
|
|
||||||
struct sensor_dev {
|
typedef struct _sensor sensor_t;
|
||||||
struct sensor_id id; // Sensor ID.
|
typedef struct _sensor {
|
||||||
uint8_t slv_addr; // Sensor I2C slave address.
|
sensor_id_t id; // Sensor ID.
|
||||||
uint32_t hw_flags; // Hardware flags (clock polarities/hw capabilities)
|
uint8_t slv_addr; // Sensor I2C slave address.
|
||||||
enum reset_polarity reset_pol; // Reset polarity (TODO move to hw_flags)
|
uint32_t hw_flags; // Hardware flags (clock polarities/hw capabilities)
|
||||||
|
reset_polarity_t reset_pol; // Reset polarity (TODO move to hw_flags)
|
||||||
|
|
||||||
// Sensor state
|
// Sensor state
|
||||||
enum sensor_sde sde;
|
sde_t sde; // Special digital effects
|
||||||
enum sensor_pixformat pixformat;
|
pixformat_t pixformat; // Pixel format
|
||||||
enum sensor_framesize framesize;
|
framesize_t framesize; // Frame size
|
||||||
enum sensor_framerate framerate;
|
framerate_t framerate; // Frame rate
|
||||||
enum sensor_gainceiling gainceiling;
|
gainceiling_t gainceiling; // AGC gainceiling
|
||||||
|
|
||||||
// Sensor function pointers
|
// Sensor function pointers
|
||||||
int (*reset) (struct sensor_dev *sensor);
|
int (*reset) (sensor_t *sensor);
|
||||||
int (*set_pixformat) (struct sensor_dev *sensor, enum sensor_pixformat pixformat);
|
int (*set_pixformat) (sensor_t *sensor, pixformat_t pixformat);
|
||||||
int (*set_framesize) (struct sensor_dev *sensor, enum sensor_framesize framesize);
|
int (*set_framesize) (sensor_t *sensor, framesize_t framesize);
|
||||||
int (*set_framerate) (struct sensor_dev *sensor, enum sensor_framerate framerate);
|
int (*set_framerate) (sensor_t *sensor, framerate_t framerate);
|
||||||
int (*set_contrast) (struct sensor_dev *sensor, int level);
|
int (*set_contrast) (sensor_t *sensor, int level);
|
||||||
int (*set_brightness) (struct sensor_dev *sensor, int level);
|
int (*set_brightness) (sensor_t *sensor, int level);
|
||||||
int (*set_saturation) (struct sensor_dev *sensor, int level);
|
int (*set_saturation) (sensor_t *sensor, int level);
|
||||||
int (*set_exposure) (struct sensor_dev *sensor, int exposure);
|
int (*set_exposure) (sensor_t *sensor, int exposure);
|
||||||
int (*set_gainceiling) (struct sensor_dev *sensor, enum sensor_gainceiling gainceiling);
|
int (*set_gainceiling) (sensor_t *sensor, gainceiling_t gainceiling);
|
||||||
int (*set_quality) (struct sensor_dev *sensor, int quality);
|
int (*set_quality) (sensor_t *sensor, int quality);
|
||||||
int (*set_colorbar) (struct sensor_dev *sensor, int enable);
|
int (*set_colorbar) (sensor_t *sensor, int enable);
|
||||||
int (*set_special_effect) (struct sensor_dev *sensor, enum sensor_sde sde);
|
int (*set_special_effect) (sensor_t *sensor, sde_t sde);
|
||||||
};
|
} sensor_t;
|
||||||
|
|
||||||
|
// Resolution table
|
||||||
|
extern const int resolution[][2];
|
||||||
|
|
||||||
// Initialize the sensor hardware and probe the image sensor.
|
// Initialize the sensor hardware and probe the image sensor.
|
||||||
int sensor_init();
|
int sensor_init();
|
||||||
@ -134,16 +136,16 @@ int sensor_read_reg(uint8_t reg);
|
|||||||
int sensor_write_reg(uint8_t reg, uint8_t val);
|
int sensor_write_reg(uint8_t reg, uint8_t val);
|
||||||
|
|
||||||
// Capture a Snapshot.
|
// Capture a Snapshot.
|
||||||
int sensor_snapshot(struct image *image);
|
int sensor_snapshot(image_t *image);
|
||||||
|
|
||||||
// Set the sensor pixel format.
|
// Set the sensor pixel format.
|
||||||
int sensor_set_pixformat(enum sensor_pixformat pixformat);
|
int sensor_set_pixformat(pixformat_t pixformat);
|
||||||
|
|
||||||
// Set the sensor frame size.
|
// Set the sensor frame size.
|
||||||
int sensor_set_framesize(enum sensor_framesize framesize);
|
int sensor_set_framesize(framesize_t framesize);
|
||||||
|
|
||||||
// Set the sensor frame rate.
|
// Set the sensor frame rate.
|
||||||
int sensor_set_framerate(enum sensor_framerate framerate);
|
int sensor_set_framerate(framerate_t framerate);
|
||||||
|
|
||||||
// Set the sensor contrast level (from -3 to +3).
|
// Set the sensor contrast level (from -3 to +3).
|
||||||
int sensor_set_contrast(int level);
|
int sensor_set_contrast(int level);
|
||||||
@ -160,7 +162,7 @@ int sensor_set_exposure(int exposure);
|
|||||||
|
|
||||||
// Set the sensor AGC gain ceiling.
|
// Set the sensor AGC gain ceiling.
|
||||||
// Note: This function has no effect when AGC (Automatic Gain Control) is disabled.
|
// Note: This function has no effect when AGC (Automatic Gain Control) is disabled.
|
||||||
int sensor_set_gainceiling(enum sensor_gainceiling gainceiling);
|
int sensor_set_gainceiling(gainceiling_t gainceiling);
|
||||||
|
|
||||||
// Set the quantization scale factor, controls JPEG quality (quality 0-255).
|
// Set the quantization scale factor, controls JPEG quality (quality 0-255).
|
||||||
int sensor_set_quality(int qs);
|
int sensor_set_quality(int qs);
|
||||||
@ -169,5 +171,5 @@ int sensor_set_quality(int qs);
|
|||||||
int sensor_set_colorbar(int enable);
|
int sensor_set_colorbar(int enable);
|
||||||
|
|
||||||
// Set special digital effects (SDE).
|
// Set special digital effects (SDE).
|
||||||
int sensor_set_special_effect(enum sensor_sde sde);
|
int sensor_set_special_effect(sde_t sde);
|
||||||
#endif /* __SENSOR_H__ */
|
#endif /* __SENSOR_H__ */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user