This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Sensirion/initial-driver
Initial SCD30 driver
- Loading branch information
Showing
12 changed files
with
767 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.o | ||
/release | ||
/scd30/scd_git_version.c | ||
/scd30/scd30_example_usage_hw_i2c | ||
/scd30/scd30_example_usage_sw_i2c |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "embedded-common"] | ||
path = embedded-common | ||
url = ./embedded-common | ||
url = https://github.com/Sensirion/embedded-common.git |
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 @@ | ||
Andreas Brauchli <[email protected]> |
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,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2018, Sensirion AG | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* 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. | ||
|
||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT HOLDER OR CONTRIBUTORS 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. |
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,42 @@ | ||
drivers=scd30 | ||
clean_drivers=$(foreach d, $(drivers), clean_$(d)) | ||
release_drivers=$(foreach d, $(drivers), release/$(d)) | ||
|
||
.PHONY: FORCE all $(release_drivers) $(clean_drivers) | ||
|
||
all: $(drivers) | ||
|
||
$(drivers): scd30/scd_git_version.c FORCE | ||
cd $@ && $(MAKE) $(MFLAGS) | ||
|
||
scd30/scd_git_version.c: FORCE | ||
git describe --always --dirty | \ | ||
awk 'BEGIN \ | ||
{print "/* THIS FILE IS AUTOGENERATED */"} \ | ||
{print "#include \"scd_git_version.h\""} \ | ||
{print "const char * SCD_DRV_VERSION_STR = \"" $$0"\";"} \ | ||
END {}' > $@ | ||
|
||
$(release_drivers): scd30/scd_git_version.c | ||
export rel=$@ && \ | ||
export driver=$${rel#release/} && \ | ||
export tag="$$(git describe --always --dirty)" && \ | ||
export pkgname="$${driver}-$${tag}" && \ | ||
export pkgdir="release/$${pkgname}" && \ | ||
rm -rf "$${pkgdir}" && mkdir -p "$${pkgdir}" && \ | ||
cp -r embedded-common/* "$${pkgdir}" && \ | ||
cp -r $${driver}/* "$${pkgdir}" && \ | ||
perl -pi -e 's/^sensirion_common_dir :=.*$$/sensirion_common_dir := ./' "$${pkgdir}/Makefile" && \ | ||
cd "$${pkgdir}" && $(MAKE) $(MFLAGS) && $(MAKE) clean $(MFLAGS) && cd - && \ | ||
cd release && zip -r "$${pkgname}.zip" "$${pkgname}" && cd - && \ | ||
ln -sf $${pkgname} $@ | ||
|
||
release: clean $(release_drivers) | ||
|
||
$(clean_drivers): | ||
export rel=$@ && \ | ||
export driver=$${rel#clean_} && \ | ||
cd $${driver} && $(MAKE) clean $(MFLAGS) && cd - | ||
|
||
clean: $(clean_drivers) | ||
rm -rf release scd30/scd_git_version.c |
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,47 @@ | ||
# embedded-scd | ||
This repository contains the embedded driver sources for Sensirion's SCD product | ||
line. | ||
|
||
## Clone this repository | ||
``` | ||
git clone --recursive https://github.com/Sensirion/embedded-scd.git | ||
``` | ||
|
||
## Repository content | ||
* embedded-common (submodule repository for the common embedded driver HAL) | ||
* scd30 (SCD30 driver related) | ||
|
||
## Collecting resources | ||
``` | ||
make release | ||
``` | ||
This will create the `release` folder with the necessary driver files in it, | ||
including a Makefile. That way, you have just one folder with all the sources | ||
ready to build your driver for your platform. | ||
|
||
## Files to adjust (from embedded-common) | ||
You only need to touch the following files: | ||
|
||
* `sensirion_arch_config.h` (architecture specifics, you need to specify | ||
the integer sizes) | ||
|
||
and depending on your i2c implementation either of the following: | ||
|
||
* `embedded-common/hw_i2c/sensirion_hw_i2c_implementation.c` | ||
functions for hardware i2c communication if your platform supports that | ||
* `embedded-common/sw_i2c/sensirion_sw_i2c_implementation.c` | ||
functions for software i2c communication via GPIOs | ||
|
||
## Building the driver | ||
1. Adjust sensirion\_arch\_config.h if you don't have the `<stdint.h>` header | ||
file available | ||
2. Implement necessary functions in one of the `*_implementation.c` files | ||
described above | ||
3. make | ||
|
||
--- | ||
|
||
Please check the [embedded-common](https://github.com/Sensirion/embedded-common) | ||
repository for further information and sample implementations. | ||
|
||
--- |
Submodule embedded-common
updated
8 files
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,42 @@ | ||
sensirion_common_dir := ../embedded-common | ||
scd_common_dir := . | ||
sw_i2c_dir := ${sensirion_common_dir}/sw_i2c | ||
hw_i2c_dir := ${sensirion_common_dir}/hw_i2c | ||
|
||
CFLAGS := -Os -Wall -Werror -I. -I${sensirion_common_dir} | ||
|
||
sensirion_common_objects := sensirion_common.o | ||
scd_common_objects := scd_git_version.o | ||
scd30_binaries := scd30_example_usage_sw_i2c scd30_example_usage_hw_i2c | ||
scd_binaries += ${scd30_binaries} | ||
|
||
sw_objects := sensirion_sw_i2c.o sensirion_sw_i2c_implementation.o | ||
hw_objects := sensirion_hw_i2c_implementation.o | ||
all_objects := ${sensirion_common_objects} ${scd_common_objects} ${hw_objects} ${sw_objects} scd30.o | ||
|
||
.PHONY: all | ||
|
||
all: ${scd_binaries} | ||
|
||
scd_git_version.o: ${scd_common_dir}/scd_git_version.c | ||
$(CC) $(CFLAGS) -c -o $@ $^ | ||
sensirion_common.o: ${sensirion_common_dir}/sensirion_common.c | ||
$(CC) $(CFLAGS) -c -o $@ $^ | ||
sensirion_sw_i2c_implementation.o: ${sw_i2c_dir}/sample-implementations/linux_user_space/sensirion_sw_i2c_implementation.c | ||
$(CC) -I${sw_i2c_dir} $(CFLAGS) -c -o $@ $^ | ||
sensirion_hw_i2c_implementation.o: ${hw_i2c_dir}/sensirion_hw_i2c_implementation.c | ||
$(CC) $(CFLAGS) -c -o $@ $^ | ||
|
||
sensirion_sw_i2c.o: ${sw_i2c_dir}/sensirion_sw_i2c.c | ||
$(CC) -I${sw_i2c_dir} $(CFLAGS) -c -o $@ $^ | ||
|
||
scd30.o: ${sensirion_common_dir}/sensirion_arch_config.h ${sensirion_common_dir}/sensirion_i2c.h ${scd_common_dir}/scd_git_version.c scd30.h scd30.c | ||
|
||
scd30_example_usage_sw_i2c: ${sensirion_common_objects} ${scd_common_objects} ${sw_objects} scd30.o | ||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS) scd30_example_usage.c | ||
|
||
scd30_example_usage_hw_i2c: ${sensirion_common_objects} ${scd_common_objects} ${hw_objects} scd30.o | ||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LOADLIBES) $(LDLIBS) scd30_example_usage.c | ||
|
||
clean: | ||
$(RM) ${all_objects} ${scd_binaries} |
Oops, something went wrong.