mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
sensors: Update chip_id to 4 bytes.
This commit is contained in:
parent
fa00c38780
commit
2586c60af2
@ -211,10 +211,7 @@ typedef void (*frame_cb_t) ();
|
|||||||
|
|
||||||
typedef struct _sensor sensor_t;
|
typedef struct _sensor sensor_t;
|
||||||
typedef struct _sensor {
|
typedef struct _sensor {
|
||||||
union {
|
uint32_t chip_id; // Sensor ID 32 bits.
|
||||||
uint8_t chip_id; // Sensor ID.
|
|
||||||
uint16_t chip_id_w; // Sensor ID 16 bits.
|
|
||||||
};
|
|
||||||
uint8_t slv_addr; // Sensor I2C slave address.
|
uint8_t slv_addr; // Sensor I2C slave address.
|
||||||
|
|
||||||
// Hardware flags (clock polarities, hw capabilities etc..)
|
// Hardware flags (clock polarities, hw capabilities etc..)
|
||||||
|
|||||||
@ -190,7 +190,7 @@ static int sensor_detect() {
|
|||||||
switch (slv_addr) {
|
switch (slv_addr) {
|
||||||
#if (OMV_OV2640_ENABLE == 1)
|
#if (OMV_OV2640_ENABLE == 1)
|
||||||
case OV2640_SLV_ADDR: // Or OV9650.
|
case OV2640_SLV_ADDR: // Or OV9650.
|
||||||
omv_i2c_readb(&sensor.i2c_bus, slv_addr, OV_CHIP_ID, &sensor.chip_id);
|
omv_i2c_readb(&sensor.i2c_bus, slv_addr, OV_CHIP_ID, (uint8_t *) &sensor.chip_id);
|
||||||
return slv_addr;
|
return slv_addr;
|
||||||
#endif // (OMV_OV2640_ENABLE == 1)
|
#endif // (OMV_OV2640_ENABLE == 1)
|
||||||
|
|
||||||
@ -198,29 +198,29 @@ static int sensor_detect() {
|
|||||||
// OV5640 and GC2145 share the same I2C address
|
// OV5640 and GC2145 share the same I2C address
|
||||||
case OV5640_SLV_ADDR: // Or GC2145
|
case OV5640_SLV_ADDR: // Or GC2145
|
||||||
// Try to read GC2145 chip ID first
|
// Try to read GC2145 chip ID first
|
||||||
omv_i2c_readb(&sensor.i2c_bus, slv_addr, GC_CHIP_ID, &sensor.chip_id);
|
omv_i2c_readb(&sensor.i2c_bus, slv_addr, GC_CHIP_ID, (uint8_t *) &sensor.chip_id);
|
||||||
if (sensor.chip_id != GC2145_ID) {
|
if (sensor.chip_id != GC2145_ID) {
|
||||||
// If it fails, try reading OV5640 chip ID.
|
// If it fails, try reading OV5640 chip ID.
|
||||||
omv_i2c_readb2(&sensor.i2c_bus, slv_addr, OV5640_CHIP_ID, &sensor.chip_id);
|
omv_i2c_readb2(&sensor.i2c_bus, slv_addr, OV5640_CHIP_ID, (uint8_t *) &sensor.chip_id);
|
||||||
}
|
}
|
||||||
return slv_addr;
|
return slv_addr;
|
||||||
#endif // (OMV_OV5640_ENABLE == 1) || (OMV_GC2145_ENABLE == 1)
|
#endif // (OMV_OV5640_ENABLE == 1) || (OMV_GC2145_ENABLE == 1)
|
||||||
|
|
||||||
#if (OMV_OV7725_ENABLE == 1) || (OMV_OV7670_ENABLE == 1) || (OMV_OV7690_ENABLE == 1)
|
#if (OMV_OV7725_ENABLE == 1) || (OMV_OV7670_ENABLE == 1) || (OMV_OV7690_ENABLE == 1)
|
||||||
case OV7725_SLV_ADDR: // Or OV7690 or OV7670.
|
case OV7725_SLV_ADDR: // Or OV7690 or OV7670.
|
||||||
omv_i2c_readb(&sensor.i2c_bus, slv_addr, OV_CHIP_ID, &sensor.chip_id);
|
omv_i2c_readb(&sensor.i2c_bus, slv_addr, OV_CHIP_ID, (uint8_t *) &sensor.chip_id);
|
||||||
return slv_addr;
|
return slv_addr;
|
||||||
#endif //(OMV_OV7725_ENABLE == 1) || (OMV_OV7670_ENABLE == 1) || (OMV_OV7690_ENABLE == 1)
|
#endif //(OMV_OV7725_ENABLE == 1) || (OMV_OV7670_ENABLE == 1) || (OMV_OV7690_ENABLE == 1)
|
||||||
|
|
||||||
#if (OMV_MT9V0XX_ENABLE == 1)
|
#if (OMV_MT9V0XX_ENABLE == 1)
|
||||||
case MT9V0XX_SLV_ADDR:
|
case MT9V0XX_SLV_ADDR:
|
||||||
omv_i2c_readw(&sensor.i2c_bus, slv_addr, ON_CHIP_ID, &sensor.chip_id_w);
|
omv_i2c_readw(&sensor.i2c_bus, slv_addr, ON_CHIP_ID, (uint16_t *) &sensor.chip_id);
|
||||||
return slv_addr;
|
return slv_addr;
|
||||||
#endif //(OMV_MT9V0XX_ENABLE == 1)
|
#endif //(OMV_MT9V0XX_ENABLE == 1)
|
||||||
|
|
||||||
#if (OMV_MT9M114_ENABLE == 1)
|
#if (OMV_MT9M114_ENABLE == 1)
|
||||||
case MT9M114_SLV_ADDR:
|
case MT9M114_SLV_ADDR:
|
||||||
omv_i2c_readw2(&sensor.i2c_bus, slv_addr, ON_CHIP_ID, &sensor.chip_id_w);
|
omv_i2c_readw2(&sensor.i2c_bus, slv_addr, ON_CHIP_ID, (uint16_t *) &sensor.chip_id);
|
||||||
return slv_addr;
|
return slv_addr;
|
||||||
#endif // (OMV_MT9M114_ENABLE == 1)
|
#endif // (OMV_MT9M114_ENABLE == 1)
|
||||||
|
|
||||||
@ -232,20 +232,20 @@ static int sensor_detect() {
|
|||||||
|
|
||||||
#if (OMV_HM01B0_ENABLE == 1) || (OMV_HM0360_ENABLE == 1)
|
#if (OMV_HM01B0_ENABLE == 1) || (OMV_HM0360_ENABLE == 1)
|
||||||
case HM0XX0_SLV_ADDR:
|
case HM0XX0_SLV_ADDR:
|
||||||
omv_i2c_readb2(&sensor.i2c_bus, slv_addr, HIMAX_CHIP_ID, &sensor.chip_id);
|
omv_i2c_readb2(&sensor.i2c_bus, slv_addr, HIMAX_CHIP_ID, (uint8_t *) &sensor.chip_id);
|
||||||
return slv_addr;
|
return slv_addr;
|
||||||
#endif // (OMV_HM01B0_ENABLE == 1) || (OMV_HM0360_ENABLE == 1)
|
#endif // (OMV_HM01B0_ENABLE == 1) || (OMV_HM0360_ENABLE == 1)
|
||||||
|
|
||||||
#if (OMV_FROGEYE2020_ENABLE == 1)
|
#if (OMV_FROGEYE2020_ENABLE == 1)
|
||||||
case FROGEYE2020_SLV_ADDR:
|
case FROGEYE2020_SLV_ADDR:
|
||||||
sensor.chip_id_w = FROGEYE2020_ID;
|
sensor.chip_id = FROGEYE2020_ID;
|
||||||
return slv_addr;
|
return slv_addr;
|
||||||
#endif // (OMV_FROGEYE2020_ENABLE == 1)
|
#endif // (OMV_FROGEYE2020_ENABLE == 1)
|
||||||
|
|
||||||
#if (OMV_PAG7920_ENABLE == 1)
|
#if (OMV_PAG7920_ENABLE == 1)
|
||||||
case PAG7920_SLV_ADDR:
|
case PAG7920_SLV_ADDR:
|
||||||
omv_i2c_readw(&sensor.i2c_bus, slv_addr, ON_CHIP_ID, &sensor.chip_id_w);
|
omv_i2c_readw(&sensor.i2c_bus, slv_addr, ON_CHIP_ID, (uint16_t *) &sensor.chip_id);
|
||||||
sensor.chip_id_w = (sensor.chip_id_w << 8) | (sensor.chip_id_w >> 8);
|
sensor.chip_id = (sensor.chip_id << 8) | (sensor.chip_id >> 8);
|
||||||
return slv_addr;
|
return slv_addr;
|
||||||
#endif // (OMV_PAG7920_ENABLE == 1)
|
#endif // (OMV_PAG7920_ENABLE == 1)
|
||||||
}
|
}
|
||||||
@ -315,7 +315,7 @@ int sensor_probe_init(uint32_t bus_id, uint32_t bus_speed) {
|
|||||||
#if (OMV_PAJ6100_ENABLE == 1)
|
#if (OMV_PAJ6100_ENABLE == 1)
|
||||||
} else if (paj6100_detect(&sensor)) {
|
} else if (paj6100_detect(&sensor)) {
|
||||||
// Found PixArt PAJ6100
|
// Found PixArt PAJ6100
|
||||||
sensor.chip_id_w = PAJ6100_ID;
|
sensor.chip_id = PAJ6100_ID;
|
||||||
sensor.power_pol = ACTIVE_LOW;
|
sensor.power_pol = ACTIVE_LOW;
|
||||||
sensor.reset_pol = ACTIVE_LOW;
|
sensor.reset_pol = ACTIVE_LOW;
|
||||||
#endif
|
#endif
|
||||||
@ -326,7 +326,7 @@ int sensor_probe_init(uint32_t bus_id, uint32_t bus_speed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A supported sensor was detected, try to initialize it.
|
// A supported sensor was detected, try to initialize it.
|
||||||
switch (sensor.chip_id_w) {
|
switch (sensor.chip_id) {
|
||||||
#if (OMV_OV2640_ENABLE == 1)
|
#if (OMV_OV2640_ENABLE == 1)
|
||||||
case OV2640_ID:
|
case OV2640_ID:
|
||||||
if (sensor_set_xclk_frequency(OMV_OV2640_XCLK_FREQ) != 0) {
|
if (sensor_set_xclk_frequency(OMV_OV2640_XCLK_FREQ) != 0) {
|
||||||
@ -387,7 +387,7 @@ int sensor_probe_init(uint32_t bus_id, uint32_t bus_speed) {
|
|||||||
case MT9V0X2_ID_V_1:
|
case MT9V0X2_ID_V_1:
|
||||||
case MT9V0X2_ID_V_2:
|
case MT9V0X2_ID_V_2:
|
||||||
// Force old versions to the newest.
|
// Force old versions to the newest.
|
||||||
sensor.chip_id_w = MT9V0X2_ID;
|
sensor.chip_id = MT9V0X2_ID;
|
||||||
case MT9V0X2_ID:
|
case MT9V0X2_ID:
|
||||||
case MT9V0X4_ID:
|
case MT9V0X4_ID:
|
||||||
if (sensor_set_xclk_frequency(OMV_MT9V0XX_XCLK_FREQ) != 0) {
|
if (sensor_set_xclk_frequency(OMV_MT9V0XX_XCLK_FREQ) != 0) {
|
||||||
@ -487,7 +487,7 @@ __weak int sensor_config(sensor_config_t config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
__weak int sensor_get_id() {
|
__weak int sensor_get_id() {
|
||||||
return sensor.chip_id_w;
|
return sensor.chip_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
__weak uint32_t sensor_get_xclk_frequency() {
|
__weak uint32_t sensor_get_xclk_frequency() {
|
||||||
|
|||||||
@ -522,17 +522,17 @@ int lepton_init(sensor_t *sensor) {
|
|||||||
// xxxx == Version
|
// xxxx == Version
|
||||||
// 01/00 == Shutter/NoShutter
|
// 01/00 == Shutter/NoShutter
|
||||||
if (!strncmp(part.value, "500-0771", 8)) {
|
if (!strncmp(part.value, "500-0771", 8)) {
|
||||||
sensor->chip_id_w = LEPTON_3_5;
|
sensor->chip_id = LEPTON_3_5;
|
||||||
} else if (!strncmp(part.value, "500-0726", 8)) {
|
} else if (!strncmp(part.value, "500-0726", 8)) {
|
||||||
sensor->chip_id_w = LEPTON_3_0;
|
sensor->chip_id = LEPTON_3_0;
|
||||||
} else if (!strncmp(part.value, "500-0763", 8)) {
|
} else if (!strncmp(part.value, "500-0763", 8)) {
|
||||||
sensor->chip_id_w = LEPTON_2_5;
|
sensor->chip_id = LEPTON_2_5;
|
||||||
} else if (!strncmp(part.value, "500-0659", 8)) {
|
} else if (!strncmp(part.value, "500-0659", 8)) {
|
||||||
sensor->chip_id_w = LEPTON_2_0;
|
sensor->chip_id = LEPTON_2_0;
|
||||||
} else if (!strncmp(part.value, "500-0690", 8)) {
|
} else if (!strncmp(part.value, "500-0690", 8)) {
|
||||||
sensor->chip_id_w = LEPTON_1_6;
|
sensor->chip_id = LEPTON_1_6;
|
||||||
} else if (!strncmp(part.value, "500-0643", 8)) {
|
} else if (!strncmp(part.value, "500-0643", 8)) {
|
||||||
sensor->chip_id_w = LEPTON_1_5;
|
sensor->chip_id = LEPTON_1_5;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,11 +37,11 @@ static enum {
|
|||||||
cfa_type = MONO_CFA;
|
cfa_type = MONO_CFA;
|
||||||
|
|
||||||
static bool is_mt9v0x2(sensor_t *sensor) {
|
static bool is_mt9v0x2(sensor_t *sensor) {
|
||||||
return (sensor->chip_id_w == MT9V0X2_ID) || (sensor->chip_id_w == MT9V0X2_C_ID);
|
return (sensor->chip_id == MT9V0X2_ID) || (sensor->chip_id == MT9V0X2_C_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_mt9v0x4(sensor_t *sensor) {
|
static bool is_mt9v0x4(sensor_t *sensor) {
|
||||||
return (sensor->chip_id_w == MT9V0X4_ID) || (sensor->chip_id_w == MT9V0X4_C_ID);
|
return (sensor->chip_id == MT9V0X4_ID) || (sensor->chip_id == MT9V0X4_C_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int reset(sensor_t *sensor) {
|
static int reset(sensor_t *sensor) {
|
||||||
@ -525,13 +525,13 @@ int mt9v0xx_init(sensor_t *sensor) {
|
|||||||
switch ((cfa_type_reg >> 9) & 0x7) {
|
switch ((cfa_type_reg >> 9) & 0x7) {
|
||||||
case BAYER_CFA_ID: {
|
case BAYER_CFA_ID: {
|
||||||
cfa_type = BAYER_CFA;
|
cfa_type = BAYER_CFA;
|
||||||
switch (sensor->chip_id_w) {
|
switch (sensor->chip_id) {
|
||||||
case MT9V0X2_ID: {
|
case MT9V0X2_ID: {
|
||||||
sensor->chip_id_w = MT9V0X2_C_ID;
|
sensor->chip_id = MT9V0X2_C_ID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MT9V0X4_ID: {
|
case MT9V0X4_ID: {
|
||||||
sensor->chip_id_w = MT9V0X4_C_ID;
|
sensor->chip_id = MT9V0X4_C_ID;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user