sensors/boson: Add FLIR Basic FLIR Boson sensor driver.

This commit is contained in:
Kwabena W. Agyeman 2024-12-08 23:57:34 -08:00
parent 58e362f2f2
commit 5ef4e0d0b5
10 changed files with 225 additions and 0 deletions

View File

@ -56,6 +56,7 @@ CUBEAI_DIR=stm32cubeai
CMSIS_DIR=hal/cmsis
MICROPY_DIR=micropython
GENX320_DIR=drivers/genx320
BOSON_DIR=drivers/boson
LEPTON_DIR=drivers/lepton
LSM6DS3_DIR=drivers/lsm6ds3
LSM6DSM_DIR=drivers/lsm6dsm

View File

@ -39,6 +39,7 @@ SRCS += $(addprefix sensors/, \
ov9650.c \
mt9v0xx.c \
mt9m114.c \
boson.c \
lepton.c \
hm01b0.c \
hm0360.c \

View File

@ -41,6 +41,7 @@
#define OMV_MT9M114_ENABLE (1)
#define OMV_MT9V0XX_ENABLE (1)
#define OMV_BOSON_ENABLE (1)
#define OMV_LEPTON_ENABLE (1)
#define OMV_GENX320_ENABLE (1)
#define OMV_GENX320_EHC_ENABLE (1)

View File

@ -73,6 +73,7 @@ export BOOT_DIR
export OMV_DIR
export CMSIS_DIR
export MICROPY_DIR
export BOSON_DIR
export LEPTON_DIR
export LSM6DS3_DIR
export LSM6DSM_DIR

View File

@ -51,6 +51,7 @@
#include "mt9v0xx.h"
#include "mt9m114.h"
#include "lepton.h"
#include "boson.h"
#include "hm01b0.h"
#include "hm0360.h"
#include "pag7920.h"
@ -260,6 +261,12 @@ static int omv_csi_detect() {
return slv_addr;
#endif // (OMV_MT9M114_ENABLE == 1)
#if (OMV_BOSON_ENABLE == 1)
case BOSON_SLV_ADDR:
csi.chip_id = BOSON_ID;
return slv_addr;
#endif // (OMV_BOSON_ENABLE == 1)
#if (OMV_LEPTON_ENABLE == 1)
case LEPTON_SLV_ADDR:
csi.chip_id = LEPTON_ID;
@ -449,6 +456,15 @@ int omv_csi_probe_init(uint32_t bus_id, uint32_t bus_speed) {
break;
#endif //(OMV_MT9M114_ENABLE == 1)
#if (OMV_BOSON_ENABLE == 1)
case BOSON_ID:
if (omv_csi_set_clk_frequency(OMV_BOSON_CLK_FREQ) != 0) {
return OMV_CSI_ERROR_TIM_INIT_FAILED;
}
init_ret = boson_init(&csi);
break;
#endif // (OMV_BOSON_ENABLE == 1)
#if (OMV_LEPTON_ENABLE == 1)
case LEPTON_ID:
if (omv_csi_set_clk_frequency(OMV_LEPTON_CLK_FREQ) != 0) {

View File

@ -41,6 +41,7 @@
#define OV7725_SLV_ADDR (0x42)
#define MT9V0XX_SLV_ADDR (0xB8)
#define MT9M114_SLV_ADDR (0x90)
#define BOSON_SLV_ADDR (0xAE)
#define LEPTON_SLV_ADDR (0x54)
#define HM0XX0_SLV_ADDR (0x48)
#define GC2145_SLV_ADDR (0x78)
@ -72,6 +73,9 @@
#define MT9V0X4_ID (0x1324)
#define MT9V0X4_C_ID (0x1424)
#define MT9M114_ID (0x2481)
#define BOSON_ID (0xAE)
#define BOSON_320_ID (0xAE32)
#define BOSON_640_ID (0xAE64)
#define LEPTON_ID (0x54)
#define LEPTON_1_5 (0x5415)
#define LEPTON_1_6 (0x5416)

View File

@ -122,6 +122,7 @@ OMV_CFLAGS += -I$(TOP_DIR)/$(OMV_DIR)/ports/$(PORT)/
OMV_CFLAGS += -I$(TOP_DIR)/$(OMV_DIR)/ports/$(PORT)/modules/
OMV_CFLAGS += -I$(TOP_DIR)/$(GENX320_DIR)/include/
OMV_CFLAGS += -I$(TOP_DIR)/$(BOSON_DIR)/include/
OMV_CFLAGS += -I$(TOP_DIR)/$(LEPTON_DIR)/include/
OMV_CFLAGS += -I$(TOP_DIR)/$(LSM6DS3_DIR)/include/
OMV_CFLAGS += -I$(TOP_DIR)/$(LSM6DSOX_DIR)/include/
@ -138,6 +139,7 @@ CFLAGS += $(HAL_CFLAGS) $(MPY_CFLAGS) $(OMV_CFLAGS)
FIRM_OBJ += $(wildcard $(BUILD)/$(CMSIS_DIR)/src/dsp/*/*.o)
FIRM_OBJ += $(wildcard $(BUILD)/$(HAL_DIR)/drivers/*.o)
FIRM_OBJ += $(wildcard $(BUILD)/$(GENX320_DIR)/src/*.o)
FIRM_OBJ += $(wildcard $(BUILD)/$(BOSON_DIR)/src/*.o)
FIRM_OBJ += $(wildcard $(BUILD)/$(LEPTON_DIR)/src/*.o)
ifeq ($(MICROPY_PY_IMU), 1)
FIRM_OBJ += $(wildcard $(BUILD)/$(LSM6DS3_DIR)/src/*.o)
@ -185,6 +187,7 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/sensors/, \
ov9650.o \
mt9v0xx.o \
mt9m114.o \
boson.o \
lepton.o \
hm01b0.o \
hm0360.o \
@ -565,6 +568,7 @@ ifeq ($(MICROPY_PY_ML_TFLM), 1)
endif
$(MAKE) -C $(MICROPY_DIR)/ports/$(PORT) BUILD=$(BUILD)/$(MICROPY_DIR) $(MICROPY_ARGS)
$(MAKE) -C $(GENX320_DIR) BUILD=$(BUILD)/$(GENX320_DIR) CFLAGS="$(CFLAGS) -MMD"
$(MAKE) -C $(BOSON_DIR) BUILD=$(BUILD)/$(BOSON_DIR) CFLAGS="$(CFLAGS) -MMD"
$(MAKE) -C $(LEPTON_DIR) BUILD=$(BUILD)/$(LEPTON_DIR) CFLAGS="$(CFLAGS) -MMD"
ifeq ($(MICROPY_PY_IMU), 1)
$(MAKE) -C $(LSM6DS3_DIR) BUILD=$(BUILD)/$(LSM6DS3_DIR) CFLAGS="$(CFLAGS) -MMD"

View File

@ -115,6 +115,7 @@ OMV_CFLAGS += -I$(TOP_DIR)/$(OMV_DIR)/ports/$(PORT)/
OMV_CFLAGS += -I$(TOP_DIR)/$(OMV_DIR)/ports/$(PORT)/modules/
OMV_CFLAGS += -I$(TOP_DIR)/$(GENX320_DIR)/include/
OMV_CFLAGS += -I$(TOP_DIR)/$(BOSON_DIR)/include/
OMV_CFLAGS += -I$(TOP_DIR)/$(LEPTON_DIR)/include/
OMV_CFLAGS += -I$(TOP_DIR)/$(LSM6DS3_DIR)/include/
OMV_CFLAGS += -I$(TOP_DIR)/$(LSM6DSOX_DIR)/include/
@ -149,6 +150,7 @@ FIRM_OBJ += $(wildcard $(BUILD)/$(CMSIS_DIR)/src/dsp/*/*.o)
FIRM_OBJ += $(wildcard $(BUILD)/$(HAL_DIR)/src/*.o)
FIRM_OBJ += $(wildcard $(BUILD)/$(GENX320_DIR)/src/*.o)
FIRM_OBJ += $(wildcard $(BUILD)/$(BOSON_DIR)/src/*.o)
FIRM_OBJ += $(wildcard $(BUILD)/$(LEPTON_DIR)/src/*.o)
ifeq ($(MICROPY_PY_IMU), 1)
FIRM_OBJ += $(wildcard $(BUILD)/$(LSM6DS3_DIR)/src/*.o)
@ -200,6 +202,7 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/sensors/, \
ov9650.o \
mt9v0xx.o \
mt9m114.o \
boson.o \
lepton.o \
hm01b0.o \
hm0360.o \
@ -594,6 +597,7 @@ UVC_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/sensors/, \
ov9650.o \
mt9v0xx.o \
mt9m114.o \
boson.o \
lepton.o \
hm01b0.o \
hm0360.o \
@ -630,6 +634,7 @@ UVC_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/ports/stm32/,\
)
UVC_OBJ += $(wildcard $(BUILD)/$(GENX320_DIR)/src/*.o)
UVC_OBJ += $(wildcard $(BUILD)/$(BOSON_DIR)/src/*.o)
UVC_OBJ += $(wildcard $(BUILD)/$(LEPTON_DIR)/src/*.o)
ifeq ($(MICROPY_PY_IMU), 1)
UVC_OBJ += $(wildcard $(BUILD)/$(LSM6DS3_DIR)/src/*.o)
@ -674,6 +679,7 @@ ifeq ($(MICROPY_PY_ML_TFLM), 1)
endif
$(MAKE) -C $(MICROPY_DIR)/ports/$(PORT) BUILD=$(BUILD)/$(MICROPY_DIR) $(MICROPY_ARGS)
$(MAKE) -C $(GENX320_DIR) BUILD=$(BUILD)/$(GENX320_DIR) CFLAGS="$(CFLAGS) -MMD"
$(MAKE) -C $(BOSON_DIR) BUILD=$(BUILD)/$(BOSON_DIR) CFLAGS="$(CFLAGS) -MMD"
$(MAKE) -C $(LEPTON_DIR) BUILD=$(BUILD)/$(LEPTON_DIR) CFLAGS="$(CFLAGS) -MMD"
ifeq ($(MICROPY_PY_IMU), 1)
$(MAKE) -C $(LSM6DS3_DIR) BUILD=$(BUILD)/$(LSM6DS3_DIR) CFLAGS="$(CFLAGS) -MMD"

154
src/omv/sensors/boson.c Normal file
View File

@ -0,0 +1,154 @@
/*
* Copyright (C) 2023-2024 OpenMV, LLC.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Any redistribution, use, or modification in source or binary form
* is done solely for personal benefit and not for any commercial
* purpose or for monetary gain. For commercial licensing options,
* please contact openmv@openmv.io
*
* THIS SOFTWARE IS PROVIDED BY THE LICENSOR AND COPYRIGHT OWNER "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR OR COPYRIGHT
* OWNER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Boson driver.
*/
#include "omv_boardconfig.h"
#if (OMV_BOSON_ENABLE == 1)
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "py/mphal.h"
#include "framebuffer.h"
#include "omv_csi.h"
#include "Client_API.h"
#include "UART_Connector.h"
#define FLIR_BOSON_BOOT_TIME_MS (2500)
static int boson_framesize = 0;
static int reset(omv_csi_t *csi) {
csi->color_palette = NULL;
// Give the camera time to boot.
mp_hal_delay_ms(FLIR_BOSON_BOOT_TIME_MS);
// Turn the com port on.
Initialize();
FLR_BOSON_PARTNUMBER_T part;
if (bosonGetCameraPN(&part) != FLR_OK) {
return -1;
}
if (!strncmp((char *) (part.value + 2), "640", 3)) {
boson_framesize = OMV_CSI_FRAMESIZE_VGA;
} else if (!strncmp((char *) (part.value + 2), "320", 3)) {
boson_framesize = OMV_CSI_FRAMESIZE_QVGA;
} else {
return -1;
}
if (dvoSetType(FLR_DVO_TYPE_MONO8) != FLR_OK) {
return -1;
}
if (telemetrySetState(FLR_DISABLE) != FLR_OK) {
return -1;
}
return 0;
}
static int set_pixformat(omv_csi_t *csi, pixformat_t pixformat) {
return (pixformat == PIXFORMAT_GRAYSCALE) ? 0 : -1;
}
static int set_framesize(omv_csi_t *csi, omv_csi_framesize_t framesize) {
return (framesize == boson_framesize) ? 0 : -1;
}
static int set_colorbar(omv_csi_t *csi, int enable) {
if (gaoSetTestRampState(enable ? FLR_ENABLE : FLR_DISABLE) != FLR_OK) {
return -1;
}
if (testRampSetType(0, FLR_TESTRAMP_VERT_SHADE) != FLR_OK) {
return -1;
}
return 0;
}
static int snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) {
int ret = omv_csi_snapshot(csi, image, flags);
if (ret < 0) {
return ret;
}
int num_pixels = resolution[boson_framesize][0] * resolution[boson_framesize][1];
if (csi->color_palette && (framebuffer_get_buffer_size() >= (num_pixels * sizeof(uint16_t)))) {
for (int32_t i = num_pixels - 1; i >= 0; i--) {
((uint16_t *) image->data)[i] = csi->color_palette[image->data[i]];
}
image->pixfmt = PIXFORMAT_RGB565;
MAIN_FB()->pixfmt = PIXFORMAT_RGB565;
}
return ret;
}
int boson_init(omv_csi_t *csi) {
// Initialize csi structure
csi->reset = reset;
csi->set_pixformat = set_pixformat;
csi->set_framesize = set_framesize;
csi->set_colorbar = set_colorbar;
csi->snapshot = snapshot;
// Set csi flags
csi->vsync_pol = 0;
csi->hsync_pol = 0;
csi->pixck_pol = 1;
csi->mono_bpp = sizeof(uint8_t);
// Override standard resolutions
resolution[OMV_CSI_FRAMESIZE_VGA][0] = 640;
resolution[OMV_CSI_FRAMESIZE_VGA][1] = 512;
resolution[OMV_CSI_FRAMESIZE_QVGA][0] = 320;
resolution[OMV_CSI_FRAMESIZE_QVGA][1] = 256;
if (reset(csi) != 0) {
return -1;
}
csi->chip_id = (boson_framesize == OMV_CSI_FRAMESIZE_VGA) ? BOSON_640_ID : BOSON_320_ID;
return 0;
}
#endif // (OMV_BOSON_ENABLE == 1)

37
src/omv/sensors/boson.h Normal file
View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2023-2024 OpenMV, LLC.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Any redistribution, use, or modification in source or binary form
* is done solely for personal benefit and not for any commercial
* purpose or for monetary gain. For commercial licensing options,
* please contact openmv@openmv.io
*
* THIS SOFTWARE IS PROVIDED BY THE LICENSOR AND COPYRIGHT OWNER "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR OR COPYRIGHT
* OWNER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Boson driver.
*/
#ifndef __BOSON_H__
#define __BOSON_H__
#define OMV_BOSON_CLK_FREQ (0)
int boson_init(omv_csi_t *csi);
#endif // __BOSON_H__