forked from Samsung/TizenRT
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sensors/mi48: add support for mi48 thermal camera #3
Open
abhishek-samsung
wants to merge
2
commits into
pre_mi48
Choose a base branch
from
mi48
base: pre_mi48
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
/**************************************************************************** | ||
* | ||
* Copyright 2023 Samsung Electronics All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific | ||
* language governing permissions and limitations under the License. | ||
* | ||
****************************************************************************/ | ||
|
||
/**************************************************************************** | ||
* Included Files | ||
****************************************************************************/ | ||
#include <tinyara/config.h> | ||
#include <tinyara/irq.h> | ||
#include <tinyara/sensors/mi48.h> | ||
#include <debug.h> | ||
#include <errno.h> | ||
#include "gpio_api.h" | ||
#include "gpio_irq_api.h" | ||
|
||
#ifdef CONFIG_MI48 | ||
|
||
/**************************************************************************** | ||
* Pre-processor Definitions | ||
****************************************************************************/ | ||
#define DEVNAME_FORMAT "/dev/img%d" | ||
|
||
#define GPIO_RESET PB_2 // will set it to the right pin after wards | ||
#define GPIO_DATA_READY PA_19 | ||
|
||
#define GPIO_UNSET 0 | ||
#define GPIO_SET 1 | ||
|
||
/* i2c config */ | ||
#define MI48_I2C_PORT 0 | ||
#define MI48_I2C_FREQ 100000 | ||
#define MI48_I2C_ADDRLEN 7 | ||
|
||
#define MI48_I2C_ADDR_H 0x41 /* need to set correct address */ | ||
#define MI48_I2C_ADDR_L 0x40 | ||
|
||
/* spi config */ | ||
#define MI48_SPI_PORT 0 | ||
#define MI48_SPI_FREQ 1000000 | ||
#define MI48_SPI_BPW 16 | ||
#define MI48_SPI_CS 0 | ||
#define MI48_SPI_MODE SPIDEV_MODE1 | ||
|
||
/**************************************************************************** | ||
* Public Data | ||
****************************************************************************/ | ||
|
||
/**************************************************************************** | ||
* Private Types | ||
****************************************************************************/ | ||
|
||
struct rtl8721csm_gpio_info_s { | ||
gpio_t reset; | ||
gpio_irq_t data_ready; | ||
}; | ||
|
||
struct rtl8721csm_mi48_dev_s { | ||
/* Lower level mi48 dev */ | ||
struct mi48_lower_s lower; | ||
|
||
/* board specific gpio information */ | ||
struct rtl8721csm_gpio_info_s gpio_info; | ||
|
||
/* gpio interrupt handler */ | ||
mi48_handler_t handler; | ||
}; | ||
|
||
static int rtl8721csm_mi48_gpio_reset(struct mi48_lower_s *lower); | ||
static int rtl8721csm_mi48_gpio_irq_attach(struct mi48_lower_s *lower, mi48_handler_t handler, FAR char *arg); | ||
static int rtl8721csm_mi48_gpio_irq_enable(struct mi48_lower_s *lower, int enable); | ||
|
||
static struct rtl8721csm_mi48_dev_s g_rtl8721csm_dev = { | ||
.lower = { | ||
.reset = rtl8721csm_mi48_gpio_reset, | ||
.attach = rtl8721csm_mi48_gpio_irq_attach, | ||
.enable = rtl8721csm_mi48_gpio_irq_enable, | ||
.i2c_config = { | ||
.frequency = MI48_I2C_FREQ, | ||
.address = MI48_I2C_ADDR_L, | ||
.addrlen = MI48_I2C_ADDRLEN, | ||
}, | ||
.spi_config = { | ||
.bpw = MI48_SPI_BPW, | ||
.freq = MI48_SPI_FREQ, | ||
.cs = MI48_SPI_CS, | ||
.mode = MI48_SPI_MODE, | ||
}, | ||
}, | ||
.gpio_info = { | ||
.reset.pin = GPIO_RESET, | ||
}, | ||
.handler = NULL | ||
|
||
}; | ||
|
||
/**************************************************************************** | ||
* Private Functions Prototype | ||
****************************************************************************/ | ||
|
||
/**************************************************************************** | ||
* Private Data | ||
****************************************************************************/ | ||
|
||
/**************************************************************************** | ||
* Private Functions | ||
****************************************************************************/ | ||
|
||
static int rtl8721csm_mi48_gpio_reset(struct mi48_lower_s *lower) | ||
{ | ||
gpio_write(&(g_rtl8721csm_dev.gpio_info.reset), GPIO_UNSET); | ||
HAL_Delay(100); | ||
gpio_write(&(g_rtl8721csm_dev.gpio_info.reset), GPIO_SET); | ||
HAL_Delay(1000); | ||
return OK; | ||
} | ||
|
||
static void rtl8721csm_gpio_irq_handler(uint32_t id, gpio_irq_event event) | ||
{ | ||
if (g_rtl8721csm_dev.handler) { | ||
g_rtl8721csm_dev.handler((void *)id); | ||
} | ||
} | ||
|
||
static int rtl8721csm_mi48_gpio_irq_attach(struct mi48_lower_s *lower, mi48_handler_t handler, FAR char *arg) | ||
{ | ||
g_rtl8721csm_dev.handler = handler; | ||
return OK; | ||
} | ||
|
||
static int rtl8721csm_mi48_gpio_irq_enable(struct mi48_lower_s *lower, int enable) | ||
{ | ||
if (enable) { | ||
gpio_irq_enable(&(g_rtl8721csm_dev.gpio_info.data_ready)); | ||
} else { | ||
gpio_irq_disable(&(g_rtl8721csm_dev.gpio_info.data_ready)); | ||
} | ||
return OK; | ||
} | ||
|
||
int rtl8721csm_mi48_initialize(void) | ||
{ | ||
int result = 0; | ||
FAR struct i2c_dev_s *i2c; | ||
FAR struct spi_dev_s *spi; | ||
char devpath[32]; | ||
|
||
gpio_irq_init(&(g_rtl8721csm_dev.gpio_info.data_ready), GPIO_DATA_READY, rtl8721csm_gpio_irq_handler, 1); | ||
gpio_irq_set(&(g_rtl8721csm_dev.gpio_info.data_ready), IRQ_RISE, 1); // Rising edge trigger | ||
|
||
i2c = up_i2cinitialize(MI48_I2C_PORT); | ||
if (!i2c) { | ||
result = -ENODEV; | ||
goto done; | ||
} | ||
|
||
spi = up_spiinitialize(1); | ||
if (!i2c) { | ||
result = -ENODEV; | ||
goto done; | ||
} | ||
|
||
/* register mi48 driver */ | ||
snprintf(devpath, sizeof(devpath), DEVNAME_FORMAT, 0); | ||
if (mi48_register(devpath, &g_rtl8721csm_dev.lower, i2c, spi) != 0) { | ||
goto done; | ||
} | ||
|
||
/* result is success */ | ||
result = 0; | ||
|
||
done: | ||
return result; | ||
} | ||
|
||
#endif /* CONFIG_MI48 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,10 @@ ifeq ($(CONFIG_SENSOR_PPD42NS),y) | |
CSRCS += ppd42ns.c | ||
endif | ||
|
||
ifeq ($(CONFIG_MI48),y) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CONFIG_SENSOR_MI48 |
||
CSRCS += mi48.c | ||
endif | ||
|
||
# Include sensor build support | ||
|
||
DEPPATH += --dep-path sensors | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test