Skip to content

Commit

Permalink
examples: Add i2c_direct sample application
Browse files Browse the repository at this point in the history
  • Loading branch information
shino authored and shino committed Oct 12, 2022
1 parent 94e08ff commit 5cf8c0b
Show file tree
Hide file tree
Showing 13 changed files with 2,383 additions and 0 deletions.
68 changes: 68 additions & 0 deletions examples/i2c_direct/Kconfig
@@ -0,0 +1,68 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

config EXAMPLES_I2C_DIRECT
tristate "I2C direct to control sensor (like BMI270 6axis-IMU)"
default n
---help---
Enable the i2c_direct without SCU function

if EXAMPLES_I2C_DIRECT

config EXAMPLES_I2C_DIRECT_PROGNAME
string "Program name"
default "i2c_direct"
---help---
This is the name of the program that will be use when the NSH ELF
program is installed.

config EXAMPLES_I2C_DIRECT_PRIORITY
int "i2c_direct task priority"
default 100

config EXAMPLES_I2C_DIRECT_STACKSIZE
int "i2c_direct stack size"
default 2048

config EXAMPLES_I2C_DIRECT_DEBUG_ON
bool "Enable Debug Print"
default n
---help---
Enable the Debug print in i2c_direct

if EXAMPLES_I2C_DIRECT_DEBUG_ON

config EXAMPLES_I2C_DIRECT_DPRINT_DEBUG
bool "Enable Debug Print (DEBUG) in i2c_direct"
default n
---help---
Enable the DEBUG Debug print in i2c_direct

config EXAMPLES_I2C_DIRECT_DPRINT_TRACE
bool "Enable Debug Print (TRACE) in i2c_direct"
default n
---help---
Enable the TRACE Debug print in i2c_direct

config EXAMPLES_I2C_DIRECT_DPRINT_INFO
bool "Enable Debug Print (INFO) in i2c_direct"
default n
---help---
Enable the INFO Debug print in i2c_direct

config EXAMPLES_I2C_DIRECT_DPRINT_WARN
bool "Enable Debug Print (WARN) in i2c_direct"
default n
---help---
Enable the WARN Debug print in i2c_direct

config EXAMPLES_I2C_DIRECT_DPRINT_ERROR
bool "Enable Debug Print (ERROR) in i2c_direct"
default n
---help---
Enable the ERROR Debug print in i2c_direct
endif

endif
6 changes: 6 additions & 0 deletions examples/i2c_direct/Make.defs
@@ -0,0 +1,6 @@
############################################################################
# i2c_direct/Make.defs
############################################################################
ifneq ($(CONFIG_EXAMPLES_I2C_DIRECT),)
CONFIGURED_APPS += i2c_direct
endif
21 changes: 21 additions & 0 deletions examples/i2c_direct/Makefile
@@ -0,0 +1,21 @@
############################################################################
# i2c_direct/Makefile
############################################################################

include $(APPDIR)/Make.defs

# i2c_direct built-in application info
PROGNAME = $(CONFIG_EXAMPLES_I2C_DIRECT_PROGNAME)
PRIORITY = $(CONFIG_EXAMPLES_I2C_DIRECT_PRIORITY)
STACKSIZE = $(CONFIG_EXAMPLES_I2C_DIRECT_STACKSIZE)
MODULE = $(CONFIG_EXAMPLES_I2C_DIRECT)

# I2C direct Example
ASRCS =
CSRCS = i2c_common.c i2c_bmi270.c bmi270.c
MAINSRC = i2c_direct_main.c

CFLAGS += -I ./include
CXXFLAGS += -I ./include

include $(APPDIR)/Application.mk
46 changes: 46 additions & 0 deletions examples/i2c_direct/README.txt
@@ -0,0 +1,46 @@
examplex/i2c_direct
^^^^^^^^^^^^^^^^^^^

Example for using i2c_direct with BMI270

Sample application to control I2C-connected sensors
by directly manipulating /dev/i2cx.
This sample controls a BMI270 Bosch 6-axis IMU, taking
512 measurements and displaying acceleration and angular
rate of rotation. It also displays the tilt using LEDs
on the SPRESENSE Main Board.

The following configuration options can be selected:

CONFIG_EXAMPLES_I2C_DIRECT -- i2c_direct example.
Default: n
CONFIG_EXAMPLES_I2C_DIRECT_PROGNAME -- You can choice other name for
this program if change this field. Default: "i2c_direct"
CONFIG_EXAMPLES_I2C_DIRECT_PRIORITY -- Specified this example's task priority.
Default: 100
CONFIG_EXAMPLES_I2C_DIRECT_STACKSIZE -- Specified this example's stack size.
Default: 2048
CONFIG_EXAMPLES_I2C_DIRECT_DEBUG_ON -- Toggle with or without debug display.
Default: n
CONFIG_EXAMPLES_I2C_DIRECT_DPRINT_DEBUG -- Toggle with or without DEBUG display.
Default: n
CONFIG_EXAMPLES_I2C_DIRECT_DPRINT_TRACE -- Toggle with or without TRACE display.
Default: n
CONFIG_EXAMPLES_I2C_DIRECT_DPRINT_INFO -- Toggle with or without INFO display.
Default: n
CONFIG_EXAMPLES_I2C_DIRECT_DPRINT_WARN -- Toggle with or without WARN display.
Default: n
CONFIG_EXAMPLES_I2C_DIRECT_DPRINT_ERROR -- Toggle with or without ERROR display.
Default: n

Build kernel and SDK:

This application can be used by i2c_direct default config.

$ ./tools/config.py examples/i2c_direct
$ make

Execute under nsh:

Type 'i2c_direct' on nsh like this.
nsh> i2c_direct

0 comments on commit 5cf8c0b

Please sign in to comment.