Skip to content

Commit

Permalink
Merge pull request #490 from shino-ixy/rs422_example
Browse files Browse the repository at this point in the history
examples : add RS-422 sample
  • Loading branch information
SPRESENSE authored Oct 12, 2022
2 parents 2bcd72e + abf4097 commit f6b8231
Show file tree
Hide file tree
Showing 7 changed files with 890 additions and 0 deletions.
51 changes: 51 additions & 0 deletions examples/rs422/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

config EXAMPLES_RS422
tristate "RS422 master/slave example"
default n
---help---
Enable the RS422 master/slave communication sample

if EXAMPLES_RS422

choice
prompt "Read Enable Pin Assign"
default EXAMPLES_RS422_RE_PIN_I2S_DIN

config EXAMPLES_RS422_RE_PIN_EMMC_DATA3
bool "EMMC_DATA3"

config EXAMPLES_RS422_RE_PIN_I2S_DIN
bool "I2S_DIN"
endchoice

choice
prompt "Data Enable Pin Assign"
default EXAMPLES_RS422_DE_PIN_I2S_DOUT

config EXAMPLES_RS422_DE_PIN_EMMC_DATA2
bool "EMMC_DATA3"

config EXAMPLES_RS422_DE_PIN_I2S_DOUT
bool "I2S_DOUT"
endchoice

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

config EXAMPLES_RS422_PRIORITY
int "rs422 task priority"
default 100

config EXAMPLES_RS422_STACKSIZE
int "rs422 stack size"
default 2048

endif
6 changes: 6 additions & 0 deletions examples/rs422/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
############################################################################
# rs422/Make.defs
############################################################################
ifneq ($(CONFIG_EXAMPLES_RS422),)
CONFIGURED_APPS += rs422
endif
18 changes: 18 additions & 0 deletions examples/rs422/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
############################################################################
# rs422/Makefile
############################################################################

include $(APPDIR)/Make.defs

# RS422 built-in application info
PROGNAME = $(CONFIG_EXAMPLES_RS422_PROGNAME)
PRIORITY = $(CONFIG_EXAMPLES_RS422_PRIORITY)
STACKSIZE = $(CONFIG_EXAMPLES_RS422_STACKSIZE)
MODULE = $(CONFIG_EXAMPLES_RS422)

# RS422 Example
ASRCS =
CSRCS =
MAINSRC = rs422_main.c

include $(APPDIR)/Application.mk
50 changes: 50 additions & 0 deletions examples/rs422/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
examplex/rs422
^^^^^^^^^^^^^^

Example for communicate nodes via RS422.

Sample application to link two SPRESENSEs using RS422.
There is a loopback mode to verify operation with one
SPRESENSE and a master/slave mode to link two SPRESENSEs.
Communication results are displayed in stdout.

The following configuration options can be selected:

CONFIG_EXAMPLES_RS422 -- rs422 example.
Default: n
CONFIG_EXAMPLES_RS422_RE_PIN_EMMC_DATA3
or CONFIG_EXAMPLES_RS422_RE_PIN_I2S_DIN
-- Read Enable Pin Assign
Default: "CONFIG_EXAMPLES_RS422_RE_PIN_I2S_DIN"
CONFIG_EXAMPLES_RS422_RE_PIN_EMMC_DATA3
or CONFIG_EXAMPLES_RS422_RE_PIN_I2S_DIN
-- Data Enable Pin Assign
Default: "CONFIG_EXAMPLES_RS422_DE_PIN_I2S_DOUT"
CONFIG_EXAMPLES_RS422_PROGNAME -- this program if change this field.
Default: "rs422"
CONFIG_EXAMPLES_RS422_PRIORITY -- Specified this example's task priority.
Default: 100
CONFIG_EXAMPLES_RS422_STACKSIZE -- Specified this example's stack size.
Default: 2048

Build kernel and SDK:

This application can be used by rs422 default config.

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

Execute under nsh:

Type 'rs422' and option on nsh like this.

If you want to run in loopback mode,
nsh> rs422 -l

If you want to run in master/slave mode,
First execute the following in the slave mode side of the presense
nsh> rs422 -s

Next, on the master mode side, in the spresense, do the following
nsh> rs422 -m

Loading

0 comments on commit f6b8231

Please sign in to comment.