Merge remote-tracking branch 'origin/master' into photon
This commit is contained in:
commit
f7a28c09b0
@ -990,25 +990,25 @@ static void stm32f0_i2c_setclock(FAR struct stm32f0_i2c_priv_s *priv, uint32_t f
|
||||
uint8_t scl_l_period;
|
||||
|
||||
/* XXX haque; these are the only freqs we support at the moment, until we can
|
||||
* compute the values ourself.
|
||||
* compute the values ourself. Pick the highest supported frequency that does
|
||||
* not exceed the requested frequency.
|
||||
*/
|
||||
|
||||
if (frequency == 10000)
|
||||
if (frequency < 100000)
|
||||
{
|
||||
frequency = 10000; /* 0Hz <= frequency < 100KHz: Use 10Khz */
|
||||
}
|
||||
else if (frequency == 100000)
|
||||
else if (frequency < 400000)
|
||||
{
|
||||
frequency = 100000; /* 100KHz <= frequency < 400KHz: Use 100KHz */
|
||||
}
|
||||
else if (frequency == 400000)
|
||||
else if (frequency < 1000000)
|
||||
{
|
||||
frequency = 400000; /* 400KHz <= frequency < 1MHz: Use 400Khz */
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 1
|
||||
frequency = 1000000;
|
||||
#else
|
||||
frequency = 500000;
|
||||
#endif
|
||||
frequency = 1000000; /* 1MHz <= frequency: Use 1Mhz */
|
||||
}
|
||||
|
||||
/* Has the I2C bus frequency changed? */
|
||||
@ -1037,88 +1037,43 @@ static void stm32f0_i2c_setclock(FAR struct stm32f0_i2c_priv_s *priv, uint32_t f
|
||||
|
||||
if (frequency == 10000)
|
||||
{
|
||||
#if 1
|
||||
/* 10 KHz values from I2C timing tool with clock 80mhz */
|
||||
/* 10 KHz values from I2C timing tool with clock 8mhz */
|
||||
|
||||
presc = 0x0b; /* PRESC - (+1) prescale I2CCLK */
|
||||
scl_l_period = 0xff; /* SCLL - SCL low period in master mode */
|
||||
scl_h_period = 0xba; /* SCLH - SCL high period in master mode */
|
||||
h_time = 0x00; /* SDADEL - (+1) data hold time after SCL falling edge */
|
||||
s_time = 0x01; /* SCLDEL - (+1) data setup time from SDA edge to SCL rising edge */
|
||||
|
||||
#else
|
||||
/* 10 KHz values from datasheet with clock 8mhz */
|
||||
|
||||
presc = 0x03; /* PRESC - (+1) prescale I2CCLK */
|
||||
presc = 0x01; /* PRESC - (+1) prescale I2CCLK */
|
||||
scl_l_period = 0xc7; /* SCLL - SCL low period in master mode */
|
||||
scl_h_period = 0xc3; /* SCLH - SCL high period in master mode */
|
||||
h_time = 0x02; /* SDADEL - (+1) data hold time after SCL falling edge */
|
||||
s_time = 0x04; /* SCLDEL - (+1) data setup time from SDA edge to SCL rising edge */
|
||||
#endif
|
||||
}
|
||||
else if (frequency == 100000)
|
||||
{
|
||||
#if 1
|
||||
/* 100 KHz values from I2C timing tool with clock 80mhz */
|
||||
/* 100 KHz values from I2C timing tool with clock 8mhz */
|
||||
|
||||
presc = 0x01; /* PRESC - (+1) prescale I2CCLK */
|
||||
scl_l_period = 0xe7; /* SCLL - SCL low period in master mode */
|
||||
scl_h_period = 0x9b; /* SCLH - SCL high period in master mode */
|
||||
h_time = 0x00; /* SDADEL - (+1) data hold time after SCL falling edge */
|
||||
s_time = 0x0d; /* SCLDEL - (+1) data setup time from SDA edge to SCL rising edge */
|
||||
#else
|
||||
/* 100 KHz values from datasheet with clock 8mhz */
|
||||
|
||||
presc = 0x01;
|
||||
scl_l_period = 0x13;
|
||||
scl_h_period = 0x0f;
|
||||
h_time = 0x02;
|
||||
s_time = 0x04;
|
||||
#endif
|
||||
scl_l_period = 0x13; /* SCLL - SCL low period in master mode */
|
||||
scl_h_period = 0x0f; /* SCLH - SCL high period in master mode */
|
||||
h_time = 0x02; /* SDADEL - (+1) data hold time after SCL falling edge */
|
||||
s_time = 0x04; /* SCLDEL - (+1) data setup time from SDA edge to SCL rising edge */
|
||||
}
|
||||
else if (frequency == 400000)
|
||||
{
|
||||
#if 1
|
||||
/* 400 KHz values from I2C timing tool for clock of 80mhz */
|
||||
/* 400 KHz values from I2C timing tool for clock of 8mhz */
|
||||
|
||||
presc = 0x01; /* PRESC - (+1) prescale I2CCLK */
|
||||
scl_l_period = 0x43; /* SCLL - SCL low period in master mode */
|
||||
scl_h_period = 0x13; /* SCLH - SCL high period in master mode */
|
||||
h_time = 0x00; /* SDADEL - (+1) data hold time after SCL falling edge */
|
||||
s_time = 0x07; /* SCLDEL - (+1) data setup time from SDA edge to SCL rising edge */
|
||||
#else
|
||||
/* 400 KHz values from datasheet for clock of 8mhz */
|
||||
|
||||
presc = 0x00;
|
||||
scl_l_period = 0x09;
|
||||
scl_h_period = 0x03;
|
||||
h_time = 0x01;
|
||||
s_time = 0x03;
|
||||
#endif
|
||||
presc = 0x00; /* PRESC - (+1) prescale I2CCLK */
|
||||
scl_l_period = 0x09; /* SCLL - SCL low period in master mode */
|
||||
scl_h_period = 0x03; /* SCLH - SCL high period in master mode */
|
||||
h_time = 0x01; /* SDADEL - (+1) data hold time after SCL falling edge */
|
||||
s_time = 0x03; /* SCLDEL - (+1) data setup time from SDA edge to SCL rising edge */
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 1
|
||||
/* 1000 KHhz values from I2C timing tool for clock of 80mhz */
|
||||
/* 1000 KHhz values from I2C timing tool for clock of 8mhz */
|
||||
|
||||
presc = 0x01; /* PRESC - (+1) prescale I2CCLK */
|
||||
scl_l_period = 0x14; /* SCLL - SCL low period in master mode */
|
||||
scl_h_period = 0x13; /* SCLH - SCL high period in master mode */
|
||||
presc = 0x00; /* PRESC - (+1) prescale I2CCLK */
|
||||
scl_l_period = 0x06; /* SCLL - SCL low period in master mode */
|
||||
scl_h_period = 0x03; /* SCLH - SCL high period in master mode */
|
||||
h_time = 0x00; /* SDADEL - (+1) data hold time after SCL falling edge */
|
||||
s_time = 0x05; /* SCLDEL - (+1) data setup time from SDA edge to SCL rising edge */
|
||||
|
||||
frequency = 1000000;
|
||||
#else
|
||||
/* 500 KHhz values from datasheet for clock of 8mhz */
|
||||
|
||||
presc = 0x00;
|
||||
scl_l_period = 0x06;
|
||||
scl_h_period = 0x03;
|
||||
h_time = 0x00;
|
||||
s_time = 0x01;
|
||||
|
||||
frequency = 500000;
|
||||
#endif
|
||||
s_time = 0x01; /* SCLDEL - (+1) data setup time from SDA edge to SCL rising edge */
|
||||
}
|
||||
|
||||
uint32_t timingr =
|
||||
|
@ -224,6 +224,86 @@ Configurations
|
||||
Configuration sub-directories
|
||||
-----------------------------
|
||||
|
||||
knsh:
|
||||
|
||||
This is identical to the nsh configuration below except that NuttX
|
||||
is built as a protected mode, monolithic module and the user applications
|
||||
are built separately.
|
||||
|
||||
It is recommends to use a special make command; not just 'make' but make
|
||||
with the following two arguments:
|
||||
|
||||
make pass1 pass2
|
||||
|
||||
In the normal case (just 'make'), make will attempt to build both user-
|
||||
and kernel-mode blobs more or less interleaved. This actual works!
|
||||
However, for me it is very confusing so I prefer the above make command:
|
||||
Make the user-space binaries first (pass1), then make the kernel-space
|
||||
binaries (pass2)
|
||||
|
||||
NOTES:
|
||||
|
||||
1. At the end of the build, there will be several files in the top-level
|
||||
NuttX build directory:
|
||||
|
||||
PASS1:
|
||||
nuttx_user.elf - The pass1 user-space ELF file
|
||||
nuttx_user.hex - The pass1 Intel HEX format file (selected in defconfig)
|
||||
User.map - Symbols in the user-space ELF file
|
||||
|
||||
PASS2:
|
||||
nuttx - The pass2 kernel-space ELF file
|
||||
nuttx.hex - The pass2 Intel HEX file (selected in defconfig)
|
||||
System.map - Symbols in the kernel-space ELF file
|
||||
|
||||
The J-Link programmer will accept files in .hex, .mot, .srec, and .bin
|
||||
formats. The St-Link programmer will accept files in hex and .bin
|
||||
formats.
|
||||
|
||||
2. Combining .hex files. If you plan to use the .hex files with your
|
||||
debugger or FLASH utility, then you may need to combine the two hex
|
||||
files into a single .hex file. Here is how you can do that.
|
||||
|
||||
a. The 'tail' of the nuttx.hex file should look something like this
|
||||
(with my comments added):
|
||||
|
||||
$ tail nuttx.hex
|
||||
# 00, data records
|
||||
...
|
||||
:10 9DC0 00 01000000000800006400020100001F0004
|
||||
:10 9DD0 00 3B005A0078009700B500D400F300110151
|
||||
:08 9DE0 00 30014E016D0100008D
|
||||
# 05, Start Linear Address Record
|
||||
:04 0000 05 0800 0419 D2
|
||||
# 01, End Of File record
|
||||
:00 0000 01 FF
|
||||
|
||||
Use an editor such as vi to remove the 05 and 01 records.
|
||||
|
||||
b. The 'head' of the nuttx_user.hex file should look something like
|
||||
this (again with my comments added):
|
||||
|
||||
$ head nuttx_user.hex
|
||||
# 04, Extended Linear Address Record
|
||||
:02 0000 04 0801 F1
|
||||
# 00, data records
|
||||
:10 8000 00 BD89 01084C800108C8110208D01102087E
|
||||
:10 8010 00 0010 00201C1000201C1000203C16002026
|
||||
:10 8020 00 4D80 01085D80010869800108ED83010829
|
||||
...
|
||||
|
||||
Nothing needs to be done here. The nuttx_user.hex file should
|
||||
be fine.
|
||||
|
||||
c. Combine the edited nuttx.hex and un-edited nuttx_user.hex
|
||||
file to produce a single combined hex file:
|
||||
|
||||
$ cat nuttx.hex nuttx_user.hex >combined.hex
|
||||
|
||||
Then use the combined.hex file with the to write the FLASH image.
|
||||
If you do this a lot, you will probably want to invest a little time
|
||||
to develop a tool to automate these steps.
|
||||
|
||||
nsh:
|
||||
|
||||
Configures the NuttShell (nsh) located at examples/nsh. This
|
||||
|
122
configs/clicker2-stm32/knsh/Make.defs
Normal file
122
configs/clicker2-stm32/knsh/Make.defs
Normal file
@ -0,0 +1,122 @@
|
||||
############################################################################
|
||||
# configs/clicker2-stm32/knsh/Make.defs
|
||||
#
|
||||
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. 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.
|
||||
# 3. Neither the name NuttX 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 OWNER 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.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include ${TOPDIR}/.config
|
||||
include ${TOPDIR}/tools/Config.mk
|
||||
include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs
|
||||
|
||||
LDSCRIPT = flash.ld
|
||||
|
||||
ifeq ($(WINTOOL),y)
|
||||
# Windows-native toolchains
|
||||
DIRLINK = $(TOPDIR)/tools/copydir.sh
|
||||
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
|
||||
MKDEP = $(TOPDIR)/tools/mkwindeps.sh
|
||||
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
|
||||
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
|
||||
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
|
||||
else
|
||||
# Linux/Cygwin-native toolchain
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
|
||||
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
||||
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
|
||||
endif
|
||||
|
||||
CC = $(CROSSDEV)gcc
|
||||
CXX = $(CROSSDEV)g++
|
||||
CPP = $(CROSSDEV)gcc -E
|
||||
LD = $(CROSSDEV)ld
|
||||
AR = $(CROSSDEV)ar rcs
|
||||
NM = $(CROSSDEV)nm
|
||||
OBJCOPY = $(CROSSDEV)objcopy
|
||||
OBJDUMP = $(CROSSDEV)objdump
|
||||
|
||||
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
|
||||
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
ARCHOPTIMIZATION = -g
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_DEBUG_NOOPT),y)
|
||||
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
|
||||
endif
|
||||
|
||||
ARCHCFLAGS = -fno-builtin
|
||||
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
|
||||
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
|
||||
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
|
||||
ARCHDEFINES =
|
||||
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
|
||||
|
||||
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
|
||||
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
|
||||
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
|
||||
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
NXFLATLDFLAGS1 = -r -d -warn-common
|
||||
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-gotoff.ld -no-check-sections
|
||||
LDNXFLATFLAGS = -e main -s 2048
|
||||
|
||||
# Loadable module definitions
|
||||
|
||||
CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
|
||||
|
||||
LDMODULEFLAGS = -r -e module_initialize
|
||||
ifeq ($(WINTOOL),y)
|
||||
LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libc/modlib/gnu-elf.ld}"
|
||||
else
|
||||
LDMODULEFLAGS += -T $(TOPDIR)/libc/modlib/gnu-elf.ld
|
||||
endif
|
||||
|
||||
ASMEXT = .S
|
||||
OBJEXT = .o
|
||||
LIBEXT = .a
|
||||
EXEEXT =
|
||||
|
||||
ifneq ($(CROSSDEV),arm-nuttx-elf-)
|
||||
LDFLAGS += -nostartfiles -nodefaultlibs
|
||||
endif
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
HOSTCC = gcc
|
||||
HOSTINCLUDES = -I.
|
||||
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe
|
||||
HOSTLDFLAGS =
|
1332
configs/clicker2-stm32/knsh/defconfig
Normal file
1332
configs/clicker2-stm32/knsh/defconfig
Normal file
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,7 @@
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
|
Loading…
Reference in New Issue
Block a user