Compare commits
11 Commits
bcm2835-1.
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
87dc810e14
|
|||
|
22fe7980d5
|
|||
|
07ea18bf14
|
|||
|
20153a0a4c
|
|||
|
7a33a8f6ca
|
|||
|
e67bfc7c44
|
|||
|
63f9bc202a
|
|||
|
348bca5ef1
|
|||
|
8a82af8299
|
|||
|
7693d327e2
|
|||
|
dd8ba4f90f
|
@@ -1,5 +1,8 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
SUBDIRS = src doc
|
||||
SUBDIRS = src
|
||||
if HAVE_DOCS
|
||||
SUBDIRS += doc
|
||||
endif
|
||||
CLEANFILES = *~
|
||||
EXTRA_DIST = examples/blink/blink.c \
|
||||
examples/input/input.c \
|
||||
@@ -11,7 +14,8 @@ examples/i2c/i2c.c \
|
||||
examples/gpio/gpio.c \
|
||||
examples/spiram/spiram_test.c \
|
||||
examples/spiram/spiram.c \
|
||||
examples/spiram/spiram.h
|
||||
examples/spiram/spiram.h \
|
||||
examples/smi/smi.c
|
||||
|
||||
upload:
|
||||
rsync -avz @PACKAGE_TARNAME@-@VERSION@.tar.gz doc/html/ www.airspayce.com:public_html/mikem/@PACKAGE_NAME@
|
||||
|
||||
35
Makefile.in
35
Makefile.in
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.16.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -85,6 +85,7 @@ POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
@HAVE_DOCS_TRUE@am__append_1 = doc
|
||||
subdir = .
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
@@ -133,8 +134,8 @@ am__recursive_targets = \
|
||||
$(am__extra_recursive_targets)
|
||||
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
|
||||
cscope distdir distdir-am dist dist-all distcheck
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
|
||||
$(LISP)config.h.in
|
||||
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
|
||||
config.h.in
|
||||
# Read a list of newline-separated strings from the standard input,
|
||||
# and print each of them once, without duplicates. Input order is
|
||||
# *not* preserved.
|
||||
@@ -151,10 +152,7 @@ am__define_uniq_tagged_files = \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
CSCOPE = cscope
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
DIST_SUBDIRS = src doc
|
||||
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in AUTHORS \
|
||||
COPYING ChangeLog INSTALL NEWS README compile config.guess \
|
||||
config.sub depcomp install-sh ltmain.sh missing
|
||||
@@ -196,6 +194,8 @@ am__relativize = \
|
||||
DIST_ARCHIVES = $(distdir).tar.gz
|
||||
GZIP_ENV = --best
|
||||
DIST_TARGETS = dist-gzip
|
||||
# Exists only to be overridden by the user if desired.
|
||||
AM_DISTCHECK_DVI_TARGET = dvi
|
||||
distuninstallcheck_listfiles = find . -type f -print
|
||||
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
|
||||
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
|
||||
@@ -211,6 +211,8 @@ CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
@@ -218,6 +220,7 @@ DOXYGEN = @DOXYGEN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
@@ -288,7 +291,7 @@ top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
SUBDIRS = src doc
|
||||
SUBDIRS = src $(am__append_1)
|
||||
CLEANFILES = *~
|
||||
EXTRA_DIST = examples/blink/blink.c \
|
||||
examples/input/input.c \
|
||||
@@ -300,7 +303,8 @@ examples/i2c/i2c.c \
|
||||
examples/gpio/gpio.c \
|
||||
examples/spiram/spiram_test.c \
|
||||
examples/spiram/spiram.c \
|
||||
examples/spiram/spiram.h
|
||||
examples/spiram/spiram.h \
|
||||
examples/smi/smi.c
|
||||
|
||||
all: config.h
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
||||
@@ -460,7 +464,6 @@ cscopelist-am: $(am__tagged_files)
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
@@ -544,6 +547,10 @@ dist-xz: distdir
|
||||
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-zstd: distdir
|
||||
tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-tarZ: distdir
|
||||
@echo WARNING: "Support for distribution archives compressed with" \
|
||||
"legacy program 'compress' is deprecated." >&2
|
||||
@@ -586,6 +593,8 @@ distcheck: dist
|
||||
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
|
||||
*.zip*) \
|
||||
unzip $(distdir).zip ;;\
|
||||
*.tar.zst*) \
|
||||
zstd -dc $(distdir).tar.zst | $(am__untar) ;;\
|
||||
esac
|
||||
chmod -R a-w $(distdir)
|
||||
chmod u+w $(distdir)
|
||||
@@ -601,7 +610,7 @@ distcheck: dist
|
||||
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||
--srcdir=../.. --prefix="$$dc_install_base" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) $(AM_DISTCHECK_DVI_TARGET) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||
@@ -763,7 +772,7 @@ uninstall-am:
|
||||
am--refresh check check-am clean clean-cscope clean-generic \
|
||||
cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
|
||||
dist-gzip dist-lzip dist-shar dist-tarZ dist-xz dist-zip \
|
||||
distcheck distclean distclean-generic distclean-hdr \
|
||||
dist-zstd distcheck distclean distclean-generic distclean-hdr \
|
||||
distclean-tags distcleancheck distdir distuninstallcheck dvi \
|
||||
dvi-am html html-am info info-am install install-am \
|
||||
install-data install-data-am install-dvi install-dvi-am \
|
||||
|
||||
110
aclocal.m4
vendored
110
aclocal.m4
vendored
@@ -1,6 +1,6 @@
|
||||
# generated automatically by aclocal 1.16.1 -*- Autoconf -*-
|
||||
# generated automatically by aclocal 1.16.5 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -14,13 +14,13 @@
|
||||
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
|
||||
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
|
||||
[m4_warning([this file was generated for autoconf 2.69.
|
||||
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],,
|
||||
[m4_warning([this file was generated for autoconf 2.71.
|
||||
You have another version of autoconf. It may work, but is not guaranteed to.
|
||||
If you have problems, you may need to regenerate the build system entirely.
|
||||
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
|
||||
|
||||
# Copyright (C) 2002-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
|
||||
[am__api_version='1.16'
|
||||
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
|
||||
dnl require some minimum version. Point them to the right macro.
|
||||
m4_if([$1], [1.16.1], [],
|
||||
m4_if([$1], [1.16.5], [],
|
||||
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
|
||||
])
|
||||
|
||||
@@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
|
||||
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
|
||||
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
|
||||
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
|
||||
[AM_AUTOMAKE_VERSION([1.16.1])dnl
|
||||
[AM_AUTOMAKE_VERSION([1.16.5])dnl
|
||||
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
|
||||
|
||||
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
|
||||
|
||||
# AM_COND_IF -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2008-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2008-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -147,7 +147,7 @@ fi[]dnl
|
||||
|
||||
# AM_CONDITIONAL -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1997-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -178,7 +178,7 @@ AC_CONFIG_COMMANDS_PRE(
|
||||
Usually this means the macro was only invoked conditionally.]])
|
||||
fi])])
|
||||
|
||||
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -369,7 +369,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
|
||||
|
||||
# Generate code to set up dependency tracking. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -408,7 +408,9 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
done
|
||||
if test $am_rc -ne 0; then
|
||||
AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments
|
||||
for automatic dependency tracking. Try re-running configure with the
|
||||
for automatic dependency tracking. If GNU make was not used, consider
|
||||
re-running the configure script with MAKE="gmake" (or whatever is
|
||||
necessary). You can also try re-running configure with the
|
||||
'--disable-dependency-tracking' option to at least be able to build
|
||||
the package (albeit without support for automatic dependency tracking).])
|
||||
fi
|
||||
@@ -435,7 +437,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
|
||||
# Do all the work for Automake. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -463,6 +465,10 @@ m4_defn([AC_PROG_CC])
|
||||
# release and drop the old call support.
|
||||
AC_DEFUN([AM_INIT_AUTOMAKE],
|
||||
[AC_PREREQ([2.65])dnl
|
||||
m4_ifdef([_$0_ALREADY_INIT],
|
||||
[m4_fatal([$0 expanded multiple times
|
||||
]m4_defn([_$0_ALREADY_INIT]))],
|
||||
[m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl
|
||||
dnl Autoconf wants to disallow AM_ names. We explicitly allow
|
||||
dnl the ones we care about.
|
||||
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
|
||||
@@ -499,7 +505,7 @@ m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
|
||||
[_AM_SET_OPTIONS([$1])dnl
|
||||
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
|
||||
m4_if(
|
||||
m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
|
||||
m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]),
|
||||
[ok:ok],,
|
||||
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
|
||||
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
|
||||
@@ -551,6 +557,20 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
|
||||
[m4_define([AC_PROG_OBJCXX],
|
||||
m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
|
||||
])
|
||||
# Variables for tags utilities; see am/tags.am
|
||||
if test -z "$CTAGS"; then
|
||||
CTAGS=ctags
|
||||
fi
|
||||
AC_SUBST([CTAGS])
|
||||
if test -z "$ETAGS"; then
|
||||
ETAGS=etags
|
||||
fi
|
||||
AC_SUBST([ETAGS])
|
||||
if test -z "$CSCOPE"; then
|
||||
CSCOPE=cscope
|
||||
fi
|
||||
AC_SUBST([CSCOPE])
|
||||
|
||||
AC_REQUIRE([AM_SILENT_RULES])dnl
|
||||
dnl The testsuite driver may need to know about EXEEXT, so add the
|
||||
dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
|
||||
@@ -632,7 +652,7 @@ for _am_header in $config_headers :; do
|
||||
done
|
||||
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
|
||||
|
||||
# Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -653,7 +673,7 @@ if test x"${install_sh+set}" != xset; then
|
||||
fi
|
||||
AC_SUBST([install_sh])])
|
||||
|
||||
# Copyright (C) 2003-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -674,7 +694,7 @@ AC_SUBST([am__leading_dot])])
|
||||
|
||||
# Check to see how 'make' treats includes. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -717,7 +737,7 @@ AC_SUBST([am__quote])])
|
||||
|
||||
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1997-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -738,12 +758,7 @@ AC_DEFUN([AM_MISSING_HAS_RUN],
|
||||
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
|
||||
AC_REQUIRE_AUX_FILE([missing])dnl
|
||||
if test x"${MISSING+set}" != xset; then
|
||||
case $am_aux_dir in
|
||||
*\ * | *\ *)
|
||||
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
|
||||
*)
|
||||
MISSING="\${SHELL} $am_aux_dir/missing" ;;
|
||||
esac
|
||||
MISSING="\${SHELL} '$am_aux_dir/missing'"
|
||||
fi
|
||||
# Use eval to expand $SHELL
|
||||
if eval "$MISSING --is-lightweight"; then
|
||||
@@ -754,38 +769,9 @@ else
|
||||
fi
|
||||
])
|
||||
|
||||
# -*- Autoconf -*-
|
||||
# Obsolete and "removed" macros, that must however still report explicit
|
||||
# error messages when used, to smooth transition.
|
||||
#
|
||||
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([AM_CONFIG_HEADER],
|
||||
[AC_DIAGNOSE([obsolete],
|
||||
['$0': this macro is obsolete.
|
||||
You should use the 'AC][_CONFIG_HEADERS' macro instead.])dnl
|
||||
AC_CONFIG_HEADERS($@)])
|
||||
|
||||
AC_DEFUN([AM_PROG_CC_STDC],
|
||||
[AC_PROG_CC
|
||||
am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc
|
||||
AC_DIAGNOSE([obsolete],
|
||||
['$0': this macro is obsolete.
|
||||
You should simply use the 'AC][_PROG_CC' macro instead.
|
||||
Also, your code should no longer depend upon 'am_cv_prog_cc_stdc',
|
||||
but upon 'ac_cv_prog_cc_stdc'.])])
|
||||
|
||||
AC_DEFUN([AM_C_PROTOTYPES],
|
||||
[AC_FATAL([automatic de-ANSI-fication support has been removed])])
|
||||
AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
|
||||
|
||||
# Helper functions for option handling. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -814,7 +800,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
|
||||
AC_DEFUN([_AM_IF_OPTION],
|
||||
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
|
||||
|
||||
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -861,7 +847,7 @@ AC_LANG_POP([C])])
|
||||
# For backward compatibility.
|
||||
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
|
||||
|
||||
# Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -880,7 +866,7 @@ AC_DEFUN([AM_RUN_LOG],
|
||||
|
||||
# Check to make sure that the build environment is sane. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -961,7 +947,7 @@ AC_CONFIG_COMMANDS_PRE(
|
||||
rm -f conftest.file
|
||||
])
|
||||
|
||||
# Copyright (C) 2009-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2009-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -1021,7 +1007,7 @@ AC_SUBST([AM_BACKSLASH])dnl
|
||||
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
|
||||
])
|
||||
|
||||
# Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -1049,7 +1035,7 @@ fi
|
||||
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
|
||||
AC_SUBST([INSTALL_STRIP_PROGRAM])])
|
||||
|
||||
# Copyright (C) 2006-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -1068,7 +1054,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
|
||||
|
||||
# Check how to create a tarball. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2004-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2004-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
||||
6
compile
6
compile
@@ -3,7 +3,7 @@
|
||||
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2021 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@@ -53,7 +53,7 @@ func_file_conv ()
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
CYGWIN* | MSYS*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
@@ -67,7 +67,7 @@ func_file_conv ()
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
cygwin/* | msys/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
|
||||
22
configure.ac
22
configure.ac
@@ -6,18 +6,28 @@ dnl (C) 2012 Mike McCauley (mikem@airspayce.com)
|
||||
|
||||
dnl Dont forget to update BCM2835_VERSION and .tar.gz in bcm2835.h
|
||||
dnl and the zip file.
|
||||
AC_INIT([bcm2835], [1.66], [mikem@airspayce.com])
|
||||
AC_INIT([bcm2835], [1.75], [mikem@airspayce.com])
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AC_CONFIG_HEADERS(config.h:config.h.in)
|
||||
AM_INIT_AUTOMAKE()
|
||||
AC_CHECK_LIB([rt], [clock_gettime])
|
||||
AC_CHECK_PROGS([DOXYGEN], [doxygen])
|
||||
if test -z "$DOXYGEN";
|
||||
then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])
|
||||
AC_MSG_CHECKING([for docs])
|
||||
AC_ARG_WITH([docs],
|
||||
[AS_HELP_STRING([--with-docs], [generate doxygen docs (default yes)])],
|
||||
[with_docs=$withval],
|
||||
[with_docs=yes])
|
||||
AC_MSG_RESULT([$with_docs])
|
||||
AM_CONDITIONAL([HAVE_DOCS], [test "x$with_docs" = "xyes"])
|
||||
if test "x$with_docs" = "xyes" ; then
|
||||
AC_CHECK_PROGS([DOXYGEN], [doxygen])
|
||||
if test -z "$DOXYGEN";
|
||||
then AC_MSG_WARN([Doxygen not found - continuing without Doxygen support])
|
||||
fi
|
||||
fi
|
||||
AC_PROG_RANLIB
|
||||
AC_PROG_CC
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
|
||||
AM_COND_IF([HAVE_DOXYGEN], [AC_CONFIG_FILES([doc/Doxyfile])])
|
||||
AC_OUTPUT(Makefile src/Makefile doc/Makefile)
|
||||
AC_CONFIG_FILES(Makefile src/Makefile doc/Makefile)
|
||||
AC_OUTPUT
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.16.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -128,6 +128,8 @@ CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
@@ -135,6 +137,7 @@ DOXYGEN = @DOXYGEN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
@@ -245,7 +248,6 @@ ctags CTAGS:
|
||||
|
||||
cscope cscopelist:
|
||||
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
|
||||
82
examples/smi/smi.c
Normal file
82
examples/smi/smi.c
Normal file
@@ -0,0 +1,82 @@
|
||||
// smi.c
|
||||
//
|
||||
// Example program for bcm2835 library
|
||||
// Shows how to send and receive a byte over SMI bus
|
||||
//
|
||||
// A CodeBlocks project is provided for easier tests
|
||||
//
|
||||
// After installing bcm2835, you can build this
|
||||
// with something like:
|
||||
// gcc -o smi smi.c -l bcm2835
|
||||
// sudo ./smi
|
||||
//
|
||||
// Or you can test it before installing with:
|
||||
// gcc -o smi -I ../../src ../../src/bcm2835.c smi.c
|
||||
// sudo ./smi
|
||||
//
|
||||
// This test program must be run with root rights !!
|
||||
// From terminal, use sudo ./smi
|
||||
//
|
||||
// Author: Benoit BOUCHEZ (BEB)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "bcm2835.h"
|
||||
|
||||
#define SMI_CHANNEL 0
|
||||
|
||||
// Number of SMI clock cycles for each SMI transaction phase
|
||||
#define SMI_SETUP_CLOCKS 10 // setup time = 80ns
|
||||
#define SMI_STROBE_CLOCKS 20 // strobe time = 160ns
|
||||
#define SMI_HOLD_CLOCKS 20 // hold time = 160ns
|
||||
#define SMI_PACE_CLOCKS 1 // pace time = 8ns
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int Address=0;
|
||||
int WriteData;
|
||||
uint8_t ReadData[16];
|
||||
|
||||
if (!bcm2835_init())
|
||||
{
|
||||
printf("bcm2835_init() failed. Are you running as root??\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!bcm2835_smi_begin())
|
||||
{
|
||||
printf("bcm2835_smi_begin() failed. Are you running as root??\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// The following test sequence writes 4096 bytes and reads 16 bytes
|
||||
// With default timing parameters, the complete sequence takes 4.6ms
|
||||
// on a RPi 3B (with O3 optimization), giving a transfer speed of 894kB/s
|
||||
// A SPI interface would require a 7MHz clock to achieve the same results...
|
||||
|
||||
// Change SMI timing parameters for writing
|
||||
bcm2835_smi_set_timing (SMI_CHANNEL, 0, SMI_SETUP_CLOCKS, SMI_STROBE_CLOCKS, SMI_HOLD_CLOCKS, SMI_PACE_CLOCKS);
|
||||
// Change SMI timing parameters for reading
|
||||
bcm2835_smi_set_timing (SMI_CHANNEL, 1, SMI_SETUP_CLOCKS, SMI_STROBE_CLOCKS, SMI_HOLD_CLOCKS, SMI_PACE_CLOCKS);
|
||||
|
||||
// Write a sequence of bytes to each possible address
|
||||
for (Address=0; Address<=15; Address++)
|
||||
{
|
||||
for (WriteData=0; WriteData<=255; WriteData++)
|
||||
{
|
||||
bcm2835_smi_write (SMI_CHANNEL, WriteData, Address);
|
||||
}
|
||||
}
|
||||
|
||||
// Read a sequence of bytes at each possible address
|
||||
for (Address=0; Address<=15; Address++)
|
||||
{
|
||||
ReadData[Address] = bcm2835_smi_read (SMI_CHANNEL, Address);
|
||||
}
|
||||
|
||||
// Release GPIO
|
||||
bcm2835_smi_end();
|
||||
bcm2835_close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
pdf/BCM2835-ARM-Peripherals.pdf
Normal file
BIN
pdf/BCM2835-ARM-Peripherals.pdf
Normal file
Binary file not shown.
BIN
perl/Device-BCM2835-1.9.tar.gz
Normal file
BIN
perl/Device-BCM2835-1.9.tar.gz
Normal file
Binary file not shown.
BIN
perl/Device-BCM2835-1.94.tar.gz
Normal file
BIN
perl/Device-BCM2835-1.94.tar.gz
Normal file
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.16.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.5 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2021 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -195,8 +195,6 @@ am__define_uniq_tagged_files = \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | $(am__uniquify_input)`
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
am__tty_colors_dummy = \
|
||||
mgn= red= grn= lgn= blu= brg= std=; \
|
||||
am__color_tests=no
|
||||
@@ -352,6 +350,7 @@ am__set_TESTS_bases = \
|
||||
bases='$(TEST_LOGS)'; \
|
||||
bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
|
||||
bases=`echo $$bases`
|
||||
AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)'
|
||||
RECHECK_LOGS = $(TEST_LOGS)
|
||||
AM_RECURSIVE_TARGETS = check recheck
|
||||
TEST_SUITE_LOG = test-suite.log
|
||||
@@ -388,6 +387,8 @@ CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CSCOPE = @CSCOPE@
|
||||
CTAGS = @CTAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
@@ -395,6 +396,7 @@ DOXYGEN = @DOXYGEN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
ETAGS = @ETAGS@
|
||||
EXEEXT = @EXEEXT@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
@@ -757,7 +759,7 @@ $(TEST_SUITE_LOG): $(TEST_LOGS)
|
||||
test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
|
||||
fi; \
|
||||
echo "$${col}$$br$${std}"; \
|
||||
echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
|
||||
echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \
|
||||
echo "$${col}$$br$${std}"; \
|
||||
create_testsuite_report --maybe-color; \
|
||||
echo "$$col$$br$$std"; \
|
||||
@@ -812,7 +814,6 @@ test.log: test$(EXEEXT)
|
||||
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
|
||||
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
|
||||
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
|
||||
366
src/bcm2835.c
366
src/bcm2835.c
@@ -6,7 +6,13 @@
|
||||
// Author: Mike McCauley
|
||||
// Copyright (C) 2011-2013 Mike McCauley
|
||||
// $Id: bcm2835.c,v 1.28 2020/01/11 05:07:13 mikem Exp mikem $
|
||||
//
|
||||
// S.Peacock: modified bcm2835_i2c_write() to add a fail safe timer.
|
||||
*/
|
||||
|
||||
// Needed to compile with gcc -std=c99, as reported by John Blaiklock.
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
@@ -55,6 +61,8 @@ volatile uint32_t *bcm2835_bsc1 = (uint32_t *)MAP_FAILED;
|
||||
volatile uint32_t *bcm2835_st = (uint32_t *)MAP_FAILED;
|
||||
volatile uint32_t *bcm2835_aux = (uint32_t *)MAP_FAILED;
|
||||
volatile uint32_t *bcm2835_spi1 = (uint32_t *)MAP_FAILED;
|
||||
/* BEB*/
|
||||
volatile uint32_t *bcm2835_smi = (uint32_t *)MAP_FAILED;
|
||||
|
||||
|
||||
|
||||
@@ -170,6 +178,10 @@ uint32_t* bcm2835_regbase(uint8_t regbase)
|
||||
return (uint32_t *)bcm2835_aux;
|
||||
case BCM2835_REGBASE_SPI1:
|
||||
return (uint32_t *)bcm2835_spi1;
|
||||
/* BEB */
|
||||
case BCM2835_REGBASE_SMI:
|
||||
return (uint32_t *)bcm2835_smi;
|
||||
|
||||
|
||||
}
|
||||
return (uint32_t *)MAP_FAILED;
|
||||
@@ -457,6 +469,7 @@ void bcm2835_gpio_afen(uint8_t pin)
|
||||
uint32_t value = 1 << shift;
|
||||
bcm2835_peri_set_bits(paddr, value, value);
|
||||
}
|
||||
|
||||
void bcm2835_gpio_clr_afen(uint8_t pin)
|
||||
{
|
||||
volatile uint32_t* paddr = bcm2835_gpio + BCM2835_GPAFEN0/4 + pin/32;
|
||||
@@ -468,14 +481,15 @@ void bcm2835_gpio_clr_afen(uint8_t pin)
|
||||
/* Set pullup/down */
|
||||
void bcm2835_gpio_pud(uint8_t pud)
|
||||
{
|
||||
if( pud_type_rpi4 )
|
||||
if (pud_type_rpi4)
|
||||
{
|
||||
pud_compat_setting = pud;
|
||||
}
|
||||
else {
|
||||
volatile uint32_t* paddr = bcm2835_gpio + BCM2835_GPPUD/4;
|
||||
bcm2835_peri_write(paddr, pud);
|
||||
}
|
||||
else
|
||||
{
|
||||
volatile uint32_t* paddr = bcm2835_gpio + BCM2835_GPPUD/4;
|
||||
bcm2835_peri_write(paddr, pud);
|
||||
}
|
||||
}
|
||||
|
||||
/* Pullup/down clock
|
||||
@@ -483,24 +497,24 @@ void bcm2835_gpio_pud(uint8_t pud)
|
||||
*/
|
||||
void bcm2835_gpio_pudclk(uint8_t pin, uint8_t on)
|
||||
{
|
||||
if( pud_type_rpi4 )
|
||||
if (pud_type_rpi4)
|
||||
{
|
||||
if( on )
|
||||
bcm2835_gpio_set_pud( pin, pud_compat_setting);
|
||||
}
|
||||
if (on)
|
||||
bcm2835_gpio_set_pud( pin, pud_compat_setting);
|
||||
}
|
||||
else
|
||||
{
|
||||
volatile uint32_t* paddr = bcm2835_gpio + BCM2835_GPPUDCLK0/4 + pin/32;
|
||||
uint8_t shift = pin % 32;
|
||||
bcm2835_peri_write(paddr, (on ? 1 : 0) << shift);
|
||||
}
|
||||
{
|
||||
volatile uint32_t* paddr = bcm2835_gpio + BCM2835_GPPUDCLK0/4 + pin/32;
|
||||
uint8_t shift = pin % 32;
|
||||
bcm2835_peri_write(paddr, (on ? 1 : 0) << shift);
|
||||
}
|
||||
}
|
||||
|
||||
/* Read GPIO pad behaviour for groups of GPIOs */
|
||||
uint32_t bcm2835_gpio_pad(uint8_t group)
|
||||
{
|
||||
if (bcm2835_pads == MAP_FAILED)
|
||||
return 0;
|
||||
if (bcm2835_pads == MAP_FAILED)
|
||||
return 0;
|
||||
|
||||
volatile uint32_t* paddr = bcm2835_pads + BCM2835_PADS_GPIO_0_27/4 + group;
|
||||
return bcm2835_peri_read(paddr);
|
||||
@@ -512,8 +526,8 @@ uint32_t bcm2835_gpio_pad(uint8_t group)
|
||||
*/
|
||||
void bcm2835_gpio_set_pad(uint8_t group, uint32_t control)
|
||||
{
|
||||
if (bcm2835_pads == MAP_FAILED)
|
||||
return;
|
||||
if (bcm2835_pads == MAP_FAILED)
|
||||
return;
|
||||
|
||||
volatile uint32_t* paddr = bcm2835_pads + BCM2835_PADS_GPIO_0_27/4 + group;
|
||||
bcm2835_peri_write(paddr, control | BCM2835_PAD_PASSWRD);
|
||||
@@ -550,7 +564,7 @@ void bcm2835_delayMicroseconds(uint64_t micros)
|
||||
start = bcm2835_st_read();
|
||||
|
||||
/* Not allowed to access timer registers (result is not as precise)*/
|
||||
if (start==0)
|
||||
if (start == 0)
|
||||
{
|
||||
t1.tv_sec = 0;
|
||||
t1.tv_nsec = 1000 * (long)(micros);
|
||||
@@ -620,7 +634,7 @@ void bcm2835_gpio_write_mask(uint32_t value, uint32_t mask)
|
||||
*/
|
||||
void bcm2835_gpio_set_pud(uint8_t pin, uint8_t pud)
|
||||
{
|
||||
if( pud_type_rpi4 )
|
||||
if (pud_type_rpi4)
|
||||
{
|
||||
int shiftbits = (pin & 0xf) << 1;
|
||||
uint32_t bits;
|
||||
@@ -642,16 +656,16 @@ void bcm2835_gpio_set_pud(uint8_t pin, uint8_t pud)
|
||||
|
||||
bcm2835_peri_write_nb( paddr, bits );
|
||||
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
bcm2835_gpio_pud(pud);
|
||||
delayMicroseconds(10);
|
||||
bcm2835_gpio_pudclk(pin, 1);
|
||||
delayMicroseconds(10);
|
||||
bcm2835_gpio_pud(BCM2835_GPIO_PUD_OFF);
|
||||
bcm2835_gpio_pudclk(pin, 0);
|
||||
}
|
||||
|
||||
bcm2835_gpio_pud(pud);
|
||||
delayMicroseconds(10);
|
||||
bcm2835_gpio_pudclk(pin, 1);
|
||||
delayMicroseconds(10);
|
||||
bcm2835_gpio_pud(BCM2835_GPIO_PUD_OFF);
|
||||
bcm2835_gpio_pudclk(pin, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -659,7 +673,7 @@ uint8_t bcm2835_gpio_get_pud(uint8_t pin)
|
||||
{
|
||||
uint8_t ret = BCM2835_GPIO_PUD_ERROR;
|
||||
|
||||
if( pud_type_rpi4 )
|
||||
if (pud_type_rpi4)
|
||||
{
|
||||
uint32_t bits;
|
||||
volatile uint32_t* paddr = bcm2835_gpio + BCM2835_GPPUPPDN0/4 + (pin >> 4);
|
||||
@@ -738,9 +752,9 @@ void bcm2835_spi_setClockDivider(uint16_t divider)
|
||||
|
||||
void bcm2835_spi_set_speed_hz(uint32_t speed_hz)
|
||||
{
|
||||
uint16_t divider = (uint16_t) ((uint32_t) BCM2835_CORE_CLK_HZ / speed_hz);
|
||||
divider &= 0xFFFE;
|
||||
bcm2835_spi_setClockDivider(divider);
|
||||
uint16_t divider = (uint16_t) ((uint32_t) BCM2835_CORE_CLK_HZ / speed_hz);
|
||||
divider &= 0xFFFE;
|
||||
bcm2835_spi_setClockDivider(divider);
|
||||
}
|
||||
|
||||
void bcm2835_spi_setDataMode(uint8_t mode)
|
||||
@@ -1095,7 +1109,8 @@ void bcm2835_aux_spi_transfernb(const char *tbuf, char *rbuf, uint32_t len) {
|
||||
|
||||
while ((tx_len > 0) || (rx_len > 0)) {
|
||||
|
||||
while (!(bcm2835_peri_read(stat) & BCM2835_AUX_SPI_STAT_TX_FULL) && (tx_len > 0)) {
|
||||
while (!(bcm2835_peri_read(stat) & BCM2835_AUX_SPI_STAT_TX_FULL) && (tx_len > 0) && (tx_len + BCM2835_AUX_SPI_FIFO_SIZE * 3 > rx_len))
|
||||
{
|
||||
count = MIN(tx_len, 3);
|
||||
data = 0;
|
||||
|
||||
@@ -1115,7 +1130,8 @@ void bcm2835_aux_spi_transfernb(const char *tbuf, char *rbuf, uint32_t len) {
|
||||
|
||||
}
|
||||
|
||||
while (!(bcm2835_peri_read(stat) & BCM2835_AUX_SPI_STAT_RX_EMPTY) && (rx_len > 0)) {
|
||||
while (!(bcm2835_peri_read(stat) & BCM2835_AUX_SPI_STAT_RX_EMPTY) && (rx_len > 0))
|
||||
{
|
||||
count = MIN(rx_len, 3);
|
||||
data = bcm2835_peri_read(io);
|
||||
|
||||
@@ -1137,7 +1153,8 @@ void bcm2835_aux_spi_transfernb(const char *tbuf, char *rbuf, uint32_t len) {
|
||||
rx_len -= count;
|
||||
}
|
||||
|
||||
while (!(bcm2835_peri_read(stat) & BCM2835_AUX_SPI_STAT_BUSY) && (rx_len > 0)) {
|
||||
while (!(bcm2835_peri_read(stat) & BCM2835_AUX_SPI_STAT_BUSY) && (rx_len > 0) && (tx_len == 0))
|
||||
{
|
||||
count = MIN(rx_len, 3);
|
||||
data = bcm2835_peri_read(io);
|
||||
|
||||
@@ -1298,10 +1315,12 @@ uint8_t bcm2835_i2c_write(const char * buf, uint32_t len)
|
||||
volatile uint32_t* control = bcm2835_bsc1 + BCM2835_BSC_C/4;
|
||||
#endif
|
||||
|
||||
uint32_t remaining = len;
|
||||
uint32_t i = 0;
|
||||
uint8_t reason = BCM2835_I2C_REASON_OK;
|
||||
|
||||
uint32_t remaining = len;
|
||||
uint32_t i = 0;
|
||||
uint8_t reason = BCM2835_I2C_REASON_OK;
|
||||
unsigned long Failsafe = len * 10000;
|
||||
int Timeout = 0;
|
||||
|
||||
/* Clear FIFO */
|
||||
bcm2835_peri_set_bits(control, BCM2835_BSC_C_CLEAR_1 , BCM2835_BSC_C_CLEAR_1 );
|
||||
/* Clear Status */
|
||||
@@ -1320,29 +1339,45 @@ uint8_t bcm2835_i2c_write(const char * buf, uint32_t len)
|
||||
bcm2835_peri_write(control, BCM2835_BSC_C_I2CEN | BCM2835_BSC_C_ST);
|
||||
|
||||
/* Transfer is over when BCM2835_BSC_S_DONE */
|
||||
while(!(bcm2835_peri_read(status) & BCM2835_BSC_S_DONE ))
|
||||
while(!Timeout && !(bcm2835_peri_read(status) & BCM2835_BSC_S_DONE ))
|
||||
{
|
||||
while ( remaining && (bcm2835_peri_read(status) & BCM2835_BSC_S_TXD ))
|
||||
while (!Timeout && remaining && (bcm2835_peri_read(status) & BCM2835_BSC_S_TXD ))
|
||||
{
|
||||
/* Write to FIFO */
|
||||
bcm2835_peri_write(fifo, buf[i]);
|
||||
i++;
|
||||
remaining--;
|
||||
/* Make sure we don't loop forever! */
|
||||
if (--Failsafe == 0)
|
||||
{
|
||||
Timeout = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Make sure we don't loop forever! */
|
||||
if (--Failsafe == 0)
|
||||
{
|
||||
Timeout = 1;
|
||||
break;
|
||||
}
|
||||
/* printf("Failsafe %d %d\n", len, (len * 1000) - Failsafe); */
|
||||
}
|
||||
|
||||
/* Received a NACK */
|
||||
if (bcm2835_peri_read(status) & BCM2835_BSC_S_ERR)
|
||||
if (Timeout)
|
||||
{
|
||||
/* We had a timeout */
|
||||
reason = BCM2835_I2C_REASON_ERROR_TIMEOUT;
|
||||
}
|
||||
else if (bcm2835_peri_read(status) & BCM2835_BSC_S_ERR)
|
||||
{
|
||||
/* Received a NACK */
|
||||
reason = BCM2835_I2C_REASON_ERROR_NACK;
|
||||
}
|
||||
|
||||
/* Received Clock Stretch Timeout */
|
||||
else if (bcm2835_peri_read(status) & BCM2835_BSC_S_CLKT)
|
||||
{
|
||||
reason = BCM2835_I2C_REASON_ERROR_CLKT;
|
||||
}
|
||||
|
||||
/* Not all data is sent */
|
||||
else if (remaining)
|
||||
{
|
||||
@@ -1422,7 +1457,7 @@ uint8_t bcm2835_i2c_read(char* buf, uint32_t len)
|
||||
reason = BCM2835_I2C_REASON_ERROR_DATA;
|
||||
}
|
||||
|
||||
bcm2835_peri_set_bits(control, BCM2835_BSC_S_DONE , BCM2835_BSC_S_DONE);
|
||||
bcm2835_peri_set_bits(status, BCM2835_BSC_S_DONE , BCM2835_BSC_S_DONE);
|
||||
|
||||
return reason;
|
||||
}
|
||||
@@ -1622,6 +1657,201 @@ uint8_t bcm2835_i2c_write_read_rs(char* cmds, uint32_t cmds_len, char* buf, uint
|
||||
return reason;
|
||||
}
|
||||
|
||||
/* SMI support courtesy Benoit Bouchez */
|
||||
int bcm2835_smi_begin(void)
|
||||
{
|
||||
volatile uint32_t* paddr;
|
||||
uint32_t defConfig;
|
||||
|
||||
if (bcm2835_smi == MAP_FAILED)
|
||||
return 0; /* bcm2835_smi_init() failed, or not root */
|
||||
|
||||
/* Set the SMI pins to the Alt 1 function to enable SMI access on them */
|
||||
bcm2835_gpio_fsel(2, BCM2835_GPIO_FSEL_ALT1); /* SA3 */
|
||||
bcm2835_gpio_fsel(3, BCM2835_GPIO_FSEL_ALT1); /* SA2 */
|
||||
bcm2835_gpio_fsel(4, BCM2835_GPIO_FSEL_ALT1); /* SA1 */
|
||||
bcm2835_gpio_fsel(5, BCM2835_GPIO_FSEL_ALT1); /* SA0 */
|
||||
bcm2835_gpio_fsel(6, BCM2835_GPIO_FSEL_ALT1); /* SOE_N / SE */
|
||||
bcm2835_gpio_fsel(7, BCM2835_GPIO_FSEL_ALT1); /* SWE_N / SRW_N */
|
||||
bcm2835_gpio_fsel(8, BCM2835_GPIO_FSEL_ALT1); /* SD0 */
|
||||
bcm2835_gpio_fsel(9, BCM2835_GPIO_FSEL_ALT1); /* SD1 */
|
||||
bcm2835_gpio_fsel(10, BCM2835_GPIO_FSEL_ALT1); /* SD2 */
|
||||
bcm2835_gpio_fsel(11, BCM2835_GPIO_FSEL_ALT1); /* SD3 */
|
||||
bcm2835_gpio_fsel(12, BCM2835_GPIO_FSEL_ALT1); /* SD4 */
|
||||
bcm2835_gpio_fsel(13, BCM2835_GPIO_FSEL_ALT1); /* SD5 */
|
||||
bcm2835_gpio_fsel(14, BCM2835_GPIO_FSEL_ALT1); /* SD6 */
|
||||
bcm2835_gpio_fsel(15, BCM2835_GPIO_FSEL_ALT1); /* SD7 */
|
||||
|
||||
/* Set the SMI clock to 125MHz -> one clock period lasts 8 ns */
|
||||
paddr = bcm2835_clk + SMICLK_CNTL;
|
||||
bcm2835_peri_write (paddr, 0x5A000000); /* Disable SMI clock */
|
||||
paddr = bcm2835_clk + SMICLK_DIV;
|
||||
bcm2835_peri_write (paddr, 0x5A004000); /* Set clock divider to 4 */
|
||||
paddr = bcm2835_clk + SMICLK_CNTL;
|
||||
bcm2835_peri_write (paddr, 0x5A000016); /* Enable SMI clock with PLLD */
|
||||
|
||||
/* Set a default useable configuration for the four SMI config slots */
|
||||
/* 8 bits, Intel mode, always pace, 10 clocks for R/W setup = 80 ns
|
||||
20 clocks for R/W strobe = 160 ns, 20 clocks for R/W hold = 160 ns,
|
||||
1 clock for pace control (not used but a value is needed) */
|
||||
defConfig = BCM2835_SMI_RW_WID8 | BCM2835_SMI_RW_MODE80 |
|
||||
BCM2835_SMI_RW_PACEALL | (10<<BCM2835_SMI_RW_SETUP_LS) |
|
||||
(20<<BCM2835_SMI_RW_STROBE_LS) | (20<<BCM2835_SMI_RW_HOLD_LS) |
|
||||
(1<<BCM2835_SMI_RW_PACE_LS);
|
||||
|
||||
paddr = bcm2835_smi + BCM2835_SMI_READ0;
|
||||
bcm2835_peri_write (paddr, defConfig);
|
||||
paddr = bcm2835_smi + BCM2835_SMI_WRITE0;
|
||||
bcm2835_peri_write (paddr, defConfig);
|
||||
paddr = bcm2835_smi + BCM2835_SMI_READ1;
|
||||
bcm2835_peri_write (paddr, defConfig);
|
||||
paddr = bcm2835_smi + BCM2835_SMI_WRITE1;
|
||||
bcm2835_peri_write (paddr, defConfig);
|
||||
paddr = bcm2835_smi + BCM2835_SMI_READ2;
|
||||
bcm2835_peri_write (paddr, defConfig);
|
||||
paddr = bcm2835_smi + BCM2835_SMI_WRITE2;
|
||||
bcm2835_peri_write (paddr, defConfig);
|
||||
paddr = bcm2835_smi + BCM2835_SMI_READ3;
|
||||
bcm2835_peri_write (paddr, defConfig);
|
||||
paddr = bcm2835_smi + BCM2835_SMI_WRITE3;
|
||||
bcm2835_peri_write (paddr, defConfig);
|
||||
|
||||
return 1; // OK
|
||||
} /* bcm2835_smi_begin */
|
||||
/* --------------------------------------------------- */
|
||||
|
||||
void bcm2835_smi_end(void)
|
||||
{
|
||||
/* Set all the SMI pins back to input */
|
||||
bcm2835_gpio_fsel(2, BCM2835_GPIO_FSEL_INPT); /* SA3 */
|
||||
bcm2835_gpio_fsel(3, BCM2835_GPIO_FSEL_INPT); /* SA2 */
|
||||
bcm2835_gpio_fsel(4, BCM2835_GPIO_FSEL_INPT); /* SA1 */
|
||||
bcm2835_gpio_fsel(5, BCM2835_GPIO_FSEL_INPT); /* SA0 */
|
||||
bcm2835_gpio_fsel(6, BCM2835_GPIO_FSEL_INPT); /* SOE_N / SE */
|
||||
bcm2835_gpio_fsel(7, BCM2835_GPIO_FSEL_INPT); /* SWE_N / SRW_N */
|
||||
bcm2835_gpio_fsel(8, BCM2835_GPIO_FSEL_INPT); /* SD0 */
|
||||
bcm2835_gpio_fsel(9, BCM2835_GPIO_FSEL_INPT); /* SD1 */
|
||||
bcm2835_gpio_fsel(10, BCM2835_GPIO_FSEL_INPT); /* SD2 */
|
||||
bcm2835_gpio_fsel(11, BCM2835_GPIO_FSEL_INPT); /* SD3 */
|
||||
bcm2835_gpio_fsel(12, BCM2835_GPIO_FSEL_INPT); /* SD4 */
|
||||
bcm2835_gpio_fsel(13, BCM2835_GPIO_FSEL_INPT); /* SD5 */
|
||||
bcm2835_gpio_fsel(14, BCM2835_GPIO_FSEL_INPT); /* SD6 */
|
||||
bcm2835_gpio_fsel(15, BCM2835_GPIO_FSEL_INPT); /* SD7 */
|
||||
} /* bcm2835_smi_end */
|
||||
/* --------------------------------------------------- */
|
||||
|
||||
void bcm2835_smi_set_timing (uint32_t smichannel, uint32_t readchannel,
|
||||
uint32_t setupcycles, uint32_t strobecycles,
|
||||
uint32_t holdcycles, uint32_t pacecycles)
|
||||
{
|
||||
int RegOffset;
|
||||
volatile uint32_t* psmitiming;
|
||||
uint32_t RegValue;
|
||||
|
||||
if (readchannel!=0)
|
||||
{
|
||||
switch (smichannel)
|
||||
{
|
||||
case 0 : RegOffset = BCM2835_SMI_READ0; break;
|
||||
case 1 : RegOffset = BCM2835_SMI_READ1; break;
|
||||
case 2 : RegOffset = BCM2835_SMI_READ2; break;
|
||||
case 3 : RegOffset = BCM2835_SMI_READ3; break;
|
||||
default : return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (smichannel)
|
||||
{
|
||||
case 0 : RegOffset = BCM2835_SMI_WRITE0; break;
|
||||
case 1 : RegOffset = BCM2835_SMI_WRITE1; break;
|
||||
case 2 : RegOffset = BCM2835_SMI_WRITE2; break;
|
||||
case 3 : RegOffset = BCM2835_SMI_WRITE3; break;
|
||||
default : return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get current timing configuration of the slot */
|
||||
psmitiming = bcm2835_smi + RegOffset;
|
||||
RegValue = bcm2835_peri_read (psmitiming);
|
||||
/* Clear timing fields in register */
|
||||
RegValue &= ~(BCM2835_SMI_RW_SETUP_MSK|BCM2835_SMI_RW_HOLD_MSK|BCM2835_SMI_RW_PACE_MSK|BCM2835_SMI_RW_STROBE_MSK);
|
||||
/* Set timing values and write back to register */
|
||||
RegValue |= (setupcycles << BCM2835_SMI_RW_SETUP_LS) |
|
||||
(strobecycles << BCM2835_SMI_RW_STROBE_LS) |
|
||||
(holdcycles << BCM2835_SMI_RW_HOLD_LS) |
|
||||
(pacecycles << BCM2835_SMI_RW_PACE_LS);
|
||||
bcm2835_peri_write (psmitiming, RegValue);
|
||||
} /* bcm2835_set_smi_timing */
|
||||
/* --------------------------------------------------- */
|
||||
|
||||
void bcm2835_smi_write(uint32_t smichannel, uint8_t data, uint32_t address)
|
||||
{
|
||||
uint32_t status;
|
||||
volatile uint32_t* psmics = bcm2835_smi + BCM2835_SMI_DIRCS;
|
||||
volatile uint32_t* psmiaddr = bcm2835_smi + BCM2835_SMI_DIRADDR;
|
||||
volatile uint32_t* psmidata = bcm2835_smi + BCM2835_SMI_DIRDATA;
|
||||
|
||||
/* Make sure we use a configuration that exists */
|
||||
if (smichannel>3) return;
|
||||
|
||||
/* clear done bit if set */
|
||||
if (bcm2835_peri_read(psmics) & BCM2835_SMI_DIRCS_DONE)
|
||||
{
|
||||
bcm2835_peri_write (psmics, BCM2835_SMI_DIRCS_DONE);
|
||||
}
|
||||
|
||||
/* Start write transfer */
|
||||
bcm2835_peri_write (psmiaddr, (smichannel<<BCM2835_SMI_DIRADRS_DEV_LS) | (address&BCM2835_SMI_DIRADRS_MSK));
|
||||
bcm2835_peri_write (psmidata, data);
|
||||
bcm2835_peri_write (psmics, BCM2835_SMI_DIRCS_WRITE|BCM2835_SMI_DIRCS_START|BCM2835_SMI_DIRCS_ENABLE);
|
||||
|
||||
/* Wait until write cycle is finished */
|
||||
do {
|
||||
status = bcm2835_peri_read(psmics);
|
||||
} while ((status & BCM2835_SMI_DIRCS_DONE)==0);
|
||||
|
||||
/* clear done bit */
|
||||
bcm2835_peri_write (psmics, BCM2835_SMI_DIRCS_DONE);
|
||||
} /* bcm2835_smi_write */
|
||||
/* --------------------------------------------------- */
|
||||
|
||||
uint32_t bcm2835_smi_read (uint32_t smichannel, uint32_t address)
|
||||
{
|
||||
uint32_t status;
|
||||
uint32_t data;
|
||||
volatile uint32_t* psmics = bcm2835_smi + BCM2835_SMI_DIRCS;
|
||||
volatile uint32_t* psmiaddr = bcm2835_smi + BCM2835_SMI_DIRADDR;
|
||||
volatile uint32_t* psmidata = bcm2835_smi + BCM2835_SMI_DIRDATA;
|
||||
|
||||
/* Make sure we use a configuration that exists */
|
||||
if (smichannel>3) return 0;
|
||||
|
||||
/* clear done bit if set */
|
||||
if (bcm2835_peri_read(psmics) & BCM2835_SMI_DIRCS_DONE)
|
||||
{
|
||||
bcm2835_peri_write (psmics, BCM2835_SMI_DIRCS_DONE);
|
||||
}
|
||||
|
||||
/* Start read transfer */
|
||||
bcm2835_peri_write (psmiaddr, (smichannel<<BCM2835_SMI_DIRADRS_DEV_LS) | (address&BCM2835_SMI_DIRADRS_MSK));
|
||||
bcm2835_peri_write (psmics, BCM2835_SMI_DIRCS_START|BCM2835_SMI_DIRCS_ENABLE);
|
||||
|
||||
/* Wait until read cycle is finished */
|
||||
do {
|
||||
status = bcm2835_peri_read(psmics);
|
||||
} while ((status & BCM2835_SMI_DIRCS_DONE)==0);
|
||||
|
||||
/* Read data */
|
||||
data = bcm2835_peri_read (psmidata);
|
||||
|
||||
/* clear done bit */
|
||||
bcm2835_peri_write (psmics, BCM2835_SMI_DIRCS_DONE);
|
||||
|
||||
return data;
|
||||
} /* bcm2835_smi_read */
|
||||
/* --------------------------------------------------- */
|
||||
|
||||
/* Read the System Timer Counter (64-bits) */
|
||||
uint64_t bcm2835_st_read(void)
|
||||
{
|
||||
@@ -1795,6 +2025,9 @@ int bcm2835_init(void)
|
||||
bcm2835_st = bcm2835_peripherals + BCM2835_ST_BASE/4;
|
||||
bcm2835_aux = bcm2835_peripherals + BCM2835_AUX_BASE/4;
|
||||
bcm2835_spi1 = bcm2835_peripherals + BCM2835_SPI1_BASE/4;
|
||||
/* BEB */
|
||||
bcm2835_smi = bcm2835_peripherals + BCM2835_SMI_BASE/4;
|
||||
|
||||
|
||||
return 1; /* Success */
|
||||
}
|
||||
@@ -1858,9 +2091,8 @@ int bcm2835_init(void)
|
||||
* the fact that we can only access GPIO
|
||||
* else try for the /dev/mem interface and get access to everything
|
||||
*/
|
||||
memfd = -1;
|
||||
ok = 0;
|
||||
if (geteuid() == 0
|
||||
if ( geteuid() == 0
|
||||
#ifdef BCM2835_HAVE_LIBCAP
|
||||
|| bcm2835_has_capability(CAP_SYS_RAWIO)
|
||||
#endif
|
||||
@@ -1868,11 +2100,11 @@ int bcm2835_init(void)
|
||||
{
|
||||
/* Open the master /dev/mem device */
|
||||
if ((memfd = open("/dev/mem", O_RDWR | O_SYNC) ) < 0)
|
||||
{
|
||||
{
|
||||
fprintf(stderr, "bcm2835_init: Unable to open /dev/mem: %s\n",
|
||||
strerror(errno)) ;
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
|
||||
/* Base of the peripherals block is mapped to VM */
|
||||
bcm2835_peripherals = mapmem("gpio", bcm2835_peripherals_size, memfd, bcm2835_peripherals_base);
|
||||
@@ -1892,26 +2124,29 @@ int bcm2835_init(void)
|
||||
bcm2835_st = bcm2835_peripherals + BCM2835_ST_BASE/4;
|
||||
bcm2835_aux = bcm2835_peripherals + BCM2835_AUX_BASE/4;
|
||||
bcm2835_spi1 = bcm2835_peripherals + BCM2835_SPI1_BASE/4;
|
||||
/* BEB */
|
||||
bcm2835_smi = bcm2835_peripherals + BCM2835_SMI_BASE/4;
|
||||
|
||||
|
||||
ok = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Not root, try /dev/gpiomem */
|
||||
/* Open the master /dev/mem device */
|
||||
if ((memfd = open("/dev/gpiomem", O_RDWR | O_SYNC) ) < 0)
|
||||
/* Not root, try /dev/gpiomem */
|
||||
/* Open the master /dev/mem device */
|
||||
if ((memfd = open("/dev/gpiomem", O_RDWR | O_SYNC) ) < 0)
|
||||
{
|
||||
fprintf(stderr, "bcm2835_init: Unable to open /dev/gpiomem: %s\n",
|
||||
strerror(errno)) ;
|
||||
goto exit;
|
||||
fprintf(stderr, "bcm2835_init: Unable to open /dev/gpiomem: %s\n",
|
||||
strerror(errno)) ;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Base of the peripherals block is mapped to VM */
|
||||
bcm2835_peripherals_base = 0;
|
||||
bcm2835_peripherals = mapmem("gpio", bcm2835_peripherals_size, memfd, bcm2835_peripherals_base);
|
||||
if (bcm2835_peripherals == MAP_FAILED) goto exit;
|
||||
bcm2835_gpio = bcm2835_peripherals;
|
||||
ok = 1;
|
||||
|
||||
/* Base of the peripherals block is mapped to VM */
|
||||
bcm2835_peripherals_base = 0;
|
||||
bcm2835_peripherals = mapmem("gpio", bcm2835_peripherals_size, memfd, bcm2835_peripherals_base);
|
||||
if (bcm2835_peripherals == MAP_FAILED) goto exit;
|
||||
bcm2835_gpio = bcm2835_peripherals;
|
||||
ok = 1;
|
||||
}
|
||||
|
||||
exit:
|
||||
@@ -1941,6 +2176,9 @@ int bcm2835_close(void)
|
||||
bcm2835_st = MAP_FAILED;
|
||||
bcm2835_aux = MAP_FAILED;
|
||||
bcm2835_spi1 = MAP_FAILED;
|
||||
/* BEB */
|
||||
bcm2835_smi = MAP_FAILED;
|
||||
|
||||
return 1; /* Success */
|
||||
}
|
||||
|
||||
|
||||
216
src/bcm2835.h
216
src/bcm2835.h
@@ -18,15 +18,16 @@
|
||||
and for accessing the system timers.
|
||||
Pin event detection is supported by polling (interrupts are not supported).
|
||||
|
||||
Works on all versions upt to and including RPI 4.
|
||||
Works on all versions up to and including RPI 4.
|
||||
Works with all versions of Debian up to and including Debian Buster 10.
|
||||
Reported to be working on Bullseye (Raspbian v11)
|
||||
|
||||
It is C++ compatible, and installs as a header file and non-shared library on
|
||||
any Linux-based distro (but clearly is no use except on Raspberry Pi or another board with
|
||||
BCM 2835).
|
||||
|
||||
The version of the package that this documentation refers to can be downloaded
|
||||
from http://www.airspayce.com/mikem/bcm2835/bcm2835-1.64.tar.gz
|
||||
from http://www.airspayce.com/mikem/bcm2835/bcm2835-1.75.tar.gz
|
||||
You can find the latest version at http://www.airspayce.com/mikem/bcm2835
|
||||
|
||||
Several example programs are provided.
|
||||
@@ -54,6 +55,11 @@
|
||||
If you must use bcm2835_gpio_len() and friends, make sure you disable the pins with
|
||||
bcm2835_gpio_clr_len() and friends after use.
|
||||
|
||||
In order to compile this library, you may need to install:
|
||||
- libc6-dev
|
||||
- libgcc-s-dev
|
||||
- libstdc++-staticdev
|
||||
|
||||
\par Running as root
|
||||
|
||||
Prior to the release of Raspbian Jessie in Feb 2016, access to any
|
||||
@@ -212,6 +218,15 @@
|
||||
- P1-40 (CLK)
|
||||
- P1-36 (CE2)
|
||||
|
||||
Caution: The bcm2835 library works directly on the SPI/I2C devices. It is not using
|
||||
any Linux device drivers. When relevant Linux drivers are loaded or
|
||||
activated then it can create unexpected behavior from other software like
|
||||
'i2cdetect'.
|
||||
|
||||
Here is a simple utility which detects I2C bus devices with the bcm2835
|
||||
library.
|
||||
https://github.com/gavinlyonsrepo/RPI_Tools/tree/main/src/i2cdetect
|
||||
|
||||
\par I2C Pins
|
||||
|
||||
The bcm2835_i2c_* functions allow you to control the BCM 2835 BSC interface,
|
||||
@@ -329,13 +344,17 @@
|
||||
|
||||
mikem has made Perl bindings available at CPAN:
|
||||
http://search.cpan.org/~mikem/Device-BCM2835-1.9/lib/Device/BCM2835.pm
|
||||
|
||||
Matthew Baker has kindly made Python bindings available at:
|
||||
https: github.com/mubeta06/py-libbcm2835
|
||||
|
||||
Gary Marks has created a Serial Peripheral Interface (SPI) command-line utility
|
||||
for Raspberry Pi, based on the bcm2835 library. The
|
||||
utility, spincl, is licensed under Open Source GNU GPLv3 by iP Solutions (http://ipsolutionscorp.com), as a
|
||||
free download with source included: http://ipsolutionscorp.com/raspberry-pi-spi-utility/
|
||||
|
||||
Bindings for Ada are available courtesy Tama McGlinn at https://github.com/TamaMcGlinn/ada_raspio
|
||||
|
||||
\par Open Source Licensing GPL V3
|
||||
|
||||
This is the appropriate option if you want to share the source code of your
|
||||
@@ -591,7 +610,42 @@
|
||||
Added support for use of capability cap_sys_rawio to determine if access to /dev/mem is available for non-root
|
||||
users. Contributed by Doug McFadyen.
|
||||
|
||||
\author Mike McCauley (mikem@airspayce.com) DO NOT CONTACT THE AUTHOR DIRECTLY: USE THE LISTS
|
||||
\version 1.67, 1.66 2020-06-11
|
||||
Fixed an error in bcm2835_i2c_read() where the status byte was not correctly updated with BCM2835_BSC_S_DONE
|
||||
Reported by Zihan. Thanks.
|
||||
|
||||
\version 1.69, 2021-03-30
|
||||
Added link to Ada bindings by Tama McGlinn.
|
||||
Fixed problem with undefined off_t on some compilers.
|
||||
|
||||
\version 1.70,
|
||||
Patch to ensure compilation with gcc -std=c99, as reported by John Blaiklock.
|
||||
Fix some inconsistencies in version numbers
|
||||
|
||||
\version 1.71
|
||||
Added SMI bus support, courtesy of Benoit Bouchez, including new functions:
|
||||
bcm2835_smi_begin(), bcm2835_smi_end(),
|
||||
bcm2835_smi_set_timing(), bcm2835_smi_write(), bcm2835_smi_read().
|
||||
|
||||
\version 1.72
|
||||
Added examples/smi/smi.c showing how to use new SMI bus support, courtesy Benoit Bouchez.
|
||||
Added support for disabling documentation genetration with "./configure --with-docs=no", courtesy of
|
||||
Christian Zuckschwerdt.
|
||||
|
||||
\version 1.73
|
||||
Fixed some inconsistent indenting in bcm2835.c that triggers warnings for some people.
|
||||
Added Timeout checks to bcm2835_i2c_write() in case of IO problems. New reason cade BCM2835_I2C_REASON_ERROR_TIMEOUT
|
||||
added. Patch courtesy Simon Peacock.
|
||||
|
||||
\version 1.74
|
||||
Timeout in bcm2835_i2c_write() increased by a factor of 10 because some users have reported spurious timeouts at slow speeds.
|
||||
|
||||
\version 1.75
|
||||
Patches to bcm2835_aux_spi_transfernb() from Sean Goff to deal with the case where
|
||||
the process is interrupted between filling the TX FIFO and reading the RX FIFO.
|
||||
|
||||
|
||||
\author Mike McCauley DO NOT CONTACT THE AUTHOR DIRECTLY: USE THE LISTS
|
||||
*/
|
||||
|
||||
|
||||
@@ -601,7 +655,12 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define BCM2835_VERSION 10066 /* Version 1.66 */
|
||||
/* Some compilers need this, as reported by Sam James */
|
||||
#include <sys/types.h>
|
||||
/* Needed to compile with gcc -std=c99, as reported by John Blaiklock.*/
|
||||
#include <fcntl.h>
|
||||
|
||||
#define BCM2835_VERSION 10075 /* Version 1.75 */
|
||||
|
||||
// Define this if you want to use libcap2 to determine if you have the cap_sys_rawio capability
|
||||
// and therefore the capability of opening /dev/mem, even if you are not root.
|
||||
@@ -680,6 +739,10 @@
|
||||
/*! Base Address of the BSC1 registers */
|
||||
#define BCM2835_BSC1_BASE 0x804000
|
||||
|
||||
/* BEB */
|
||||
/*! Base address of the SMI registers */
|
||||
#define BCM2835_SMI_BASE 0x600000
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/*! Physical address and size of the peripherals block
|
||||
@@ -742,6 +805,11 @@ extern volatile uint32_t *bcm2835_aux;
|
||||
*/
|
||||
extern volatile uint32_t *bcm2835_spi1;
|
||||
|
||||
/* BEB */
|
||||
/*! Base of SMI registers.
|
||||
Available after bcm2835_init has been called (as root)
|
||||
*/
|
||||
extern volatile uint32_t *bcm2835_smi;
|
||||
|
||||
/*! \brief bcm2835RegisterBase
|
||||
Register bases for bcm2835_regbase()
|
||||
@@ -755,9 +823,12 @@ typedef enum
|
||||
BCM2835_REGBASE_PADS = 5, /*!< Base of the PADS registers. */
|
||||
BCM2835_REGBASE_SPI0 = 6, /*!< Base of the SPI0 registers. */
|
||||
BCM2835_REGBASE_BSC0 = 7, /*!< Base of the BSC0 registers. */
|
||||
BCM2835_REGBASE_BSC1 = 8, /*!< Base of the BSC1 registers. */
|
||||
BCM2835_REGBASE_AUX = 9, /*!< Base of the AUX registers. */
|
||||
BCM2835_REGBASE_SPI1 = 10 /*!< Base of the SPI1 registers. */
|
||||
BCM2835_REGBASE_BSC1 = 8, /*!< Base of the BSC1 registers. */
|
||||
BCM2835_REGBASE_AUX = 9, /*!< Base of the AUX registers. */
|
||||
BCM2835_REGBASE_SPI1 = 10,/*!< Base of the SPI1 registers. */
|
||||
/* BEB */
|
||||
BCM2835_REGBASE_SMI = 11 /*!< Base of the SMI registers. */
|
||||
|
||||
} bcm2835RegisterBase;
|
||||
|
||||
/*! Size of memory page on RPi */
|
||||
@@ -1128,7 +1199,7 @@ typedef enum
|
||||
GPIO register offsets from BCM2835_BSC*_BASE.
|
||||
Offsets into the BSC Peripheral block in bytes per 3.1 BSC Register Map
|
||||
*/
|
||||
#define BCM2835_BSC_C 0x0000 /*!< BSC Master Control */
|
||||
#define BCM2835_BSC_C 0x0000 /*!< BSC Master Control */
|
||||
#define BCM2835_BSC_S 0x0004 /*!< BSC Master Status */
|
||||
#define BCM2835_BSC_DLEN 0x0008 /*!< BSC Master Data Length */
|
||||
#define BCM2835_BSC_A 0x000c /*!< BSC Master Slave Address */
|
||||
@@ -1160,6 +1231,7 @@ typedef enum
|
||||
#define BCM2835_BSC_S_TA 0x00000001 /*!< Transfer Active */
|
||||
|
||||
#define BCM2835_BSC_FIFO_SIZE 16 /*!< BSC FIFO size */
|
||||
#define BCM2835_AUX_SPI_FIFO_SIZE 4
|
||||
|
||||
/*! \brief bcm2835I2CClockDivider
|
||||
Specifies the divider used to generate the I2C clock from the system clock.
|
||||
@@ -1181,9 +1253,71 @@ typedef enum
|
||||
BCM2835_I2C_REASON_OK = 0x00, /*!< Success */
|
||||
BCM2835_I2C_REASON_ERROR_NACK = 0x01, /*!< Received a NACK */
|
||||
BCM2835_I2C_REASON_ERROR_CLKT = 0x02, /*!< Received Clock Stretch Timeout */
|
||||
BCM2835_I2C_REASON_ERROR_DATA = 0x04 /*!< Not all data is sent / received */
|
||||
BCM2835_I2C_REASON_ERROR_DATA = 0x04, /*!< Not all data is sent / received */
|
||||
BCM2835_I2C_REASON_ERROR_TIMEOUT = 0x08 /*!< Time out occurred during sending */
|
||||
|
||||
} bcm2835I2CReasonCodes;
|
||||
|
||||
/* Registers offets from BCM2835_SMI_BASE */
|
||||
#define BCM2835_SMI_CS 0 /*! < Control and status register > */
|
||||
#define BCM2835_SMI_LENGTH 1 /*! < Transfer length register > */
|
||||
#define BCM2835_SMI_ADRS 2 /*! < Transfer address register > */
|
||||
#define BCM2835_SMI_DATA 3 /*! < Transfer data register > */
|
||||
#define BCM2835_SMI_READ0 4 /*! < Read settings 0 register > */
|
||||
#define BCM2835_SMI_WRITE0 5 /*! < Write settings 0 register > */
|
||||
#define BCM2835_SMI_READ1 6 /*! < Read settings 1 register > */
|
||||
#define BCM2835_SMI_WRITE1 7 /*! < Write settings 1 register > */
|
||||
#define BCM2835_SMI_READ2 8 /*! < Read settings 2 register > */
|
||||
#define BCM2835_SMI_WRITE2 9 /*! < Write settings 2 register > */
|
||||
#define BCM2835_SMI_READ3 10 /*! < Read settings 3 register > */
|
||||
#define BCM2835_SMI_WRITE3 11 /*! < Write settings 3 register > */
|
||||
#define BCM2835_SMI_DMAC 12 /*! < DMA control register > */
|
||||
#define BCM2835_SMI_DIRCS 13 /*! < Direct control register > */
|
||||
#define BCM2835_SMI_DIRADDR 14 /*! < Direct access address register > */
|
||||
#define BCM2835_SMI_DIRDATA 15 /*! < Direct access data register > */
|
||||
|
||||
/* Register masks for SMI_READ and SMI_WRITE */
|
||||
#define BCM2835_SMI_RW_WIDTH_MSK 0xC0000000 /*! < Data width mask > */
|
||||
#define BCM2835_SMI_RW_WID8 0x00000000 /*! < Data width 8 bits > */
|
||||
#define BCM2835_SMI_RW_WID16 0x40000000 /*! < Data width 16 bits > */
|
||||
#define BCM2835_SMI_RW_WID18 0x80000000 /*! < Data width 18 bits > */
|
||||
#define BCM2835_SMI_RW_WID9 0xC0000000 /*! < Data width 9 bits > */
|
||||
#define BCM2835_SMI_RW_SETUP_MSK 0x3F000000 /*! < Setup cycles (6 bits) > */
|
||||
#define BCM2835_SMI_RW_SETUP_LS 24 /*! < Shift for setup cycles > */
|
||||
#define BCM2835_SMI_RW_MODE68 0x00800000 /*! < Run cycle motorola mode > */
|
||||
#define BCM2835_SMI_RW_MODE80 0x00000000 /*! < Run cycle intel mode > */
|
||||
#define BCM2835_SMI_READ_FSETUP 0x00400000 /*! < Read : Setup only for first cycle > */
|
||||
#define BCM2835_SMI_WRITE_SWAP 0x00400000 /*! < Write : swap pixel data > */
|
||||
#define BCM2835_SMI_RW_HOLD_MSK 0x003F0000 /*! < Hold cycles (6 bits) > */
|
||||
#define BCM2835_SMI_RW_HOLD_LS 16 /*! < Shift for hold cycles > */
|
||||
#define BCM2835_SMI_RW_PACEALL 0x00008000 /*! < Apply pacing always > */
|
||||
#define BCM2835_SMI_RW_PACE_MSK 0x00007F00 /*! < Pace cycles (7 bits) > */
|
||||
#define BCM2835_SMI_RW_PACE_LS 8 /*! < Shift for pace cycles > */
|
||||
#define BCM2835_SMI_RW_DREQ 0x00000080 /*! < Use DMA req on read/write > */
|
||||
#define BCM2835_SMI_RW_STROBE_MSK 0x0000007F /*! < Strobe cycles (7 bits) > */
|
||||
#define BCM2835_SMI_RW_STROBE_LS 0 /*! < Shift for strobe cycles > */
|
||||
|
||||
/* Registers masks for Direct Access control register */
|
||||
#define BCM2835_SMI_DIRCS_ENABLE 0x00000001 /*! < Set to enable SMI. 0 = Read from ext. devices > */
|
||||
#define BCM2835_SMI_DIRCS_START 0x00000002 /*! < Initiate SMI transfer > */
|
||||
#define BCM2835_SMI_DIRCS_DONE 0x00000004 /*! < Set if transfer has finished / Write to clear flag > */
|
||||
#define BCM2835_SMI_DIRCS_WRITE 0x00000008 /*! < 1 = Write to ext. devices > */
|
||||
|
||||
/* Registers masks for Direct Access address register */
|
||||
#define BCM2835_SMI_DIRADRS_DEV_MSK 0x00000300 /*! < Timing configuration slot > */
|
||||
#define BCM2835_SMI_DIRADRS_DEV_LS 8 /*! < Shift for configuration slot > */
|
||||
#define BCM2835_SMI_DIRADRS_DEV0 0x00000000 /*! < Use timing config slot 0 > */
|
||||
#define BCM2835_SMI_DIRADRS_DEV1 0x00000100 /*! < Use timing config slot 1 > */
|
||||
#define BCM2835_SMI_DIRADRS_DEV2 0x00000200 /*! < Use timing config slot 2 > */
|
||||
#define BCM2835_SMI_DIRADRS_DEV3 0x00000300 /*! < Use timing config slot 3 > */
|
||||
#define BCM2835_SMI_DIRADRS_MSK 0x0000003F /*! < Adress bits SA5..SA0 > */
|
||||
#define BCM2835_SMI_DIRADRS_LS 0 /*! < Shift for address bits > */
|
||||
|
||||
/* SMI clock control registers : defined as offset from bcm2835_clk */
|
||||
#define SMICLK_CNTL (44) /* = 0xB0 */
|
||||
#define SMICLK_DIV (45) /* = 0xB4 */
|
||||
|
||||
|
||||
/* Defines for ST
|
||||
GPIO register offsets from BCM2835_ST_BASE.
|
||||
Offsets into the ST Peripheral block in bytes per 12.1 System Timer Registers
|
||||
@@ -1922,6 +2056,66 @@ extern "C" {
|
||||
|
||||
/*! @} */
|
||||
|
||||
/*! \defgroup smi SMI bus support
|
||||
Allows access to SMI bus
|
||||
@{
|
||||
*/
|
||||
/*! Start SMI operations.
|
||||
Forces RPi SMI pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1)
|
||||
to alternate function ALT1, which enables those pins for SMI interface.
|
||||
You should call bcm2835_smi_end() when all SMI functions are complete to return the pins to
|
||||
their default functions.
|
||||
Only address bits SA0 to SA3 are available as RPi uses GPIO0 (SA5) and GPIO1 (SA4) for I2C
|
||||
HAT identification EEPROM access
|
||||
\sa bcm2835_smi_end()
|
||||
\return 1 if successful, 0 otherwise (perhaps because you are not running as root)
|
||||
*/
|
||||
extern int bcm2835_smi_begin (void);
|
||||
|
||||
/*! End SMI operations.
|
||||
SMI pins P1-19 (MOSI), P1-21 (MISO), P1-23 (CLK), P1-24 (CE0) and P1-26 (CE1)
|
||||
are returned to their default INPUT behaviour.
|
||||
*/
|
||||
extern void bcm2835_smi_end (void);
|
||||
|
||||
/*! Setup SMI bus cycle timing parameters
|
||||
There are four SMI channels for read operation and four channels for write operation
|
||||
Cycles are expressed as multiple of 8ns
|
||||
Note that Pace cycles are not used (no effect on hardware) but they are required for
|
||||
configuration. It is recommended to set this value to 1 (and not 0) to have the
|
||||
smallest cycle in case the hardware would recognize it
|
||||
\param[in] smichannel SMI configuration slot to setup (0 to 3)
|
||||
\param[in] readchannel Set to 1 to configure the read channel (0 = configure write channel)
|
||||
\param[in] setupcycles Time between address assertion on bus and OE/WR signal assertion
|
||||
\param[in] strobecycles Duration of OE/WR signal assertion
|
||||
\param[in] holdcycles Time after OE/WR deassertion before address is deasserted
|
||||
\param[in] pacecycles Time before next SMI bus cycle
|
||||
*/
|
||||
extern void bcm2835_smi_set_timing(uint32_t smichannel, uint32_t readchannel,
|
||||
uint32_t setupcycles, uint32_t strobecycles,
|
||||
uint32_t holdcycles, uint32_t pacecycles);
|
||||
|
||||
/*! Transfers one byte to SMI bus.
|
||||
Uses polled transfer as described in BCM 2835 ARM Peripherals manual
|
||||
\param[in] timingslot SMI configuration slot to use (0 to 3)
|
||||
\param[in] data The data byte to write
|
||||
\param[in] address The address to write to
|
||||
\sa bcm2835_smi_writenb()
|
||||
*/
|
||||
extern void bcm2835_smi_write (uint32_t smichannel, uint8_t data, uint32_t address);
|
||||
|
||||
/*! Reads one byte from SMI bus.
|
||||
Uses polled transfer as described in BCM 2835 ARM Peripherals manual
|
||||
\param[in] smichannel SMI configuration slot to use (0 to 3)
|
||||
\param[in] address The address to read from
|
||||
\return value read from SMI bus
|
||||
\sa bcm2835_smi_readnb()
|
||||
*/
|
||||
extern uint32_t bcm2835_smi_read (uint32_t smichannel, uint32_t address);
|
||||
|
||||
/*! @} */
|
||||
|
||||
|
||||
/*! \defgroup st System Timer access
|
||||
Allows access to and delays using the System Timer Counter.
|
||||
@{
|
||||
@@ -2023,3 +2217,7 @@ Broadcom bcm2835. Contributed by Shahrooz Shahparnia.
|
||||
Shows how to use the included little library (spiram.c and spiram.h)
|
||||
to read and write SPI RAM chips such as 23K256-I/P
|
||||
*/
|
||||
|
||||
/*! example smi.c
|
||||
Shows how to use the SMI bus calls. Courtesy Benoit Bouchez.
|
||||
*/
|
||||
|
||||
19
test-driver
19
test-driver
@@ -3,7 +3,7 @@
|
||||
|
||||
scriptversion=2018-03-07.03; # UTC
|
||||
|
||||
# Copyright (C) 2011-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2011-2021 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -42,11 +42,13 @@ print_usage ()
|
||||
{
|
||||
cat <<END
|
||||
Usage:
|
||||
test-driver --test-name=NAME --log-file=PATH --trs-file=PATH
|
||||
[--expect-failure={yes|no}] [--color-tests={yes|no}]
|
||||
[--enable-hard-errors={yes|no}] [--]
|
||||
test-driver --test-name NAME --log-file PATH --trs-file PATH
|
||||
[--expect-failure {yes|no}] [--color-tests {yes|no}]
|
||||
[--enable-hard-errors {yes|no}] [--]
|
||||
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
|
||||
|
||||
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
|
||||
See the GNU Automake documentation for information.
|
||||
END
|
||||
}
|
||||
|
||||
@@ -103,8 +105,11 @@ trap "st=130; $do_exit" 2
|
||||
trap "st=141; $do_exit" 13
|
||||
trap "st=143; $do_exit" 15
|
||||
|
||||
# Test script is run here.
|
||||
"$@" >$log_file 2>&1
|
||||
# Test script is run here. We create the file first, then append to it,
|
||||
# to ameliorate tests themselves also writing to the log file. Our tests
|
||||
# don't, but others can (automake bug#35762).
|
||||
: >"$log_file"
|
||||
"$@" >>"$log_file" 2>&1
|
||||
estatus=$?
|
||||
|
||||
if test $enable_hard_errors = no && test $estatus -eq 99; then
|
||||
@@ -126,7 +131,7 @@ esac
|
||||
# know whether the test passed or failed simply by looking at the '.log'
|
||||
# file, without the need of also peaking into the corresponding '.trs'
|
||||
# file (automake bug#11814).
|
||||
echo "$res $test_name (exit status: $estatus)" >>$log_file
|
||||
echo "$res $test_name (exit status: $estatus)" >>"$log_file"
|
||||
|
||||
# Report outcome to console.
|
||||
echo "${col}${res}${std}: $test_name"
|
||||
|
||||
Reference in New Issue
Block a user