incubator-mynewt-core git commit: get newlib compiling with Mynewt source again
Repository: incubator-mynewt-core Updated Branches: refs/heads/develop 5b51840c6 -> 83aae3d46 get newlib compiling with Mynewt source again Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/83aae3d4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/83aae3d4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/83aae3d4 Branch: refs/heads/develop Commit: 83aae3d46f8505e669bebafc57dfd7a53daf9cfe Parents: 5b51840 Author: Sterling HughesAuthored: Tue Oct 18 20:56:53 2016 -0700 Committer: Sterling Hughes Committed: Tue Oct 18 20:56:53 2016 -0700 -- compiler/arm-none-eabi-m0/compiler.yml | 2 +- compiler/arm-none-eabi-m4/compiler.yml | 2 +- encoding/base64/src/hex.c | 2 +- encoding/json/src/json_decode.c | 2 +- hw/drivers/uart/uart_hal/src/uart_hal.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/83aae3d4/compiler/arm-none-eabi-m0/compiler.yml -- diff --git a/compiler/arm-none-eabi-m0/compiler.yml b/compiler/arm-none-eabi-m0/compiler.yml index 318a2ac..15bb043 100644 --- a/compiler/arm-none-eabi-m0/compiler.yml +++ b/compiler/arm-none-eabi-m0/compiler.yml @@ -29,6 +29,6 @@ compiler.flags.default: -mcpu=cortex-m0 -mthumb-interwork -mthumb -Wall -Werror compiler.flags.optimized: [compiler.flags.default, -Os -ggdb] compiler.flags.debug: [compiler.flags.default, -O1 -ggdb] -compiler.ld.flags: -static -lgcc -Wl,--gc-sections +compiler.ld.flags: -static -specs=nosys.specs -lgcc -Wl,--gc-sections compiler.ld.resolve_circular_deps: true compiler.ld.mapfile: true http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/83aae3d4/compiler/arm-none-eabi-m4/compiler.yml -- diff --git a/compiler/arm-none-eabi-m4/compiler.yml b/compiler/arm-none-eabi-m4/compiler.yml index 9fa5aab..66fc094 100644 --- a/compiler/arm-none-eabi-m4/compiler.yml +++ b/compiler/arm-none-eabi-m4/compiler.yml @@ -30,6 +30,6 @@ compiler.flags.default: [compiler.flags.base, -O1 -ggdb] compiler.flags.optimized: [compiler.flags.base, -Os -ggdb] compiler.flags.debug: [compiler.flags.base, -O1 -ggdb] -compiler.ld.flags: -static -lgcc -Wl,--gc-sections +compiler.ld.flags: -static -specs=nosys.specs -lgcc -Wl,--gc-sections compiler.ld.resolve_circular_deps: true compiler.ld.mapfile: true http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/83aae3d4/encoding/base64/src/hex.c -- diff --git a/encoding/base64/src/hex.c b/encoding/base64/src/hex.c index 44162c2..c38e3a8 100644 --- a/encoding/base64/src/hex.c +++ b/encoding/base64/src/hex.c @@ -80,7 +80,7 @@ hex_parse(char *src, int src_len, void *dst_v, int dst_len) } for (i = 0; i < src_len; i++, src++) { c = *src; -if (isdigit(c)) { +if (isdigit((int) c)) { c -= '0'; } else if (c >= 'a' && c <= 'f') { c -= ('a' - 10); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/83aae3d4/encoding/json/src/json_decode.c -- diff --git a/encoding/json/src/json_decode.c b/encoding/json/src/json_decode.c index b78bbfd..c1fcbb9 100644 --- a/encoding/json/src/json_decode.c +++ b/encoding/json/src/json_decode.c @@ -86,7 +86,7 @@ json_skip_ws(struct json_buffer *jb) do { c = jb->jb_read_next(jb); -} while (isspace(c)); +} while (isspace((int) c)); jb->jb_read_prev(jb); } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/83aae3d4/hw/drivers/uart/uart_hal/src/uart_hal.c -- diff --git a/hw/drivers/uart/uart_hal/src/uart_hal.c b/hw/drivers/uart/uart_hal/src/uart_hal.c index 5617f6b..c99e613 100644 --- a/hw/drivers/uart/uart_hal/src/uart_hal.c +++ b/hw/drivers/uart/uart_hal/src/uart_hal.c @@ -123,7 +123,7 @@ uart_hal_init(struct os_dev *odev, void *arg) priv->unit = -1; ch = odev->od_name[strlen(odev->od_name) - 1]; -if (!isdigit(ch)) { +if (!isdigit((int) ch)) { return OS_EINVAL; } priv->unit = ch - '0';
[2/2] incubator-mynewt-newt git commit: more documentation for the first packet
more documentation for the first packet Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/f544ec6f Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/f544ec6f Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/f544ec6f Branch: refs/heads/develop Commit: f544ec6fb3d45e0a685541952c70eabf949c26ff Parents: dba476c Author: paulfdietrichAuthored: Tue Oct 18 15:48:35 2016 -0700 Committer: paulfdietrich Committed: Tue Oct 18 15:48:35 2016 -0700 -- newtmgr/cli/image.go | 11 +++ 1 file changed, 11 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/f544ec6f/newtmgr/cli/image.go -- diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go index c2e94ed..7bcb879 100644 --- a/newtmgr/cli/image.go +++ b/newtmgr/cli/image.go @@ -295,6 +295,17 @@ func imageUploadCmd(cmd *cobra.Command, args []string) { if currOff == 0 { /* we need extra space to encode the image size */ if blockSz > (mtu - 8) { + /* +* to encode the image size, we write clen=val in CBOR. +* From below (for up to 2G images, you can see that it +* will take up to 9 bytes. (starts at 63.. ends at e8) +* 0040 7d c4 00 00 7d c4 00 00 63 6c 65 6e 1a 00 01 5d |}...}...clen...]| +* 0050 e8 63 6f 66 66 00 |.coff.| +* However, since the offset is zero, we will use less +* bytes (we budgeted for 5 bytes but will only use 1 +*/ + + /* to make these powers of 2, just go with 8 bytes */ blockSz = mtu - 8 } }
[1/2] incubator-mynewt-newt git commit: write notes on the magic number here and test long images (> 64k)
Repository: incubator-mynewt-newt Updated Branches: refs/heads/develop 0558d537a -> f544ec6fb write notes on the magic number here and test long images (> 64k) Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/dba476ce Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/dba476ce Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/dba476ce Branch: refs/heads/develop Commit: dba476ce79f3041c62f72cbf6cb744fe24349c64 Parents: 0558d53 Author: paulfdietrichAuthored: Tue Oct 18 15:38:28 2016 -0700 Committer: paulfdietrich Committed: Tue Oct 18 15:39:20 2016 -0700 -- newtmgr/cli/image.go| 26 ++ newtmgr/transport/connserial.go | 11 ++- 2 files changed, 36 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/dba476ce/newtmgr/cli/image.go -- diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go index c8ca761..c2e94ed 100644 --- a/newtmgr/cli/image.go +++ b/newtmgr/cli/image.go @@ -253,6 +253,32 @@ func imageUploadCmd(cmd *cobra.Command, args []string) { if profile.Type() == "ble" { mtu = uint32((transport.BleMTU - 33) * 3 / 4) } else { + /* since this possibly gets base 64 encoded, we want +* to ensure that the payload leaving this layer is 91 +* bytes or less (91 bytes plus 2 byte crc will encode +* to 124 with 4 bytes of header +* left over */ + + /* 02 00 00 4f 00 01 00 01 a2 64 64 61 74 61 58 40 |...O.ddataX@| +* 0010 00 f0 5a f8 0e 4b 1c 70 0e 4b 5a 88 12 05 10 0f |..Z..K.p.KZ.| +* 0020 59 88 0d 4a 0a 40 5a 80 59 88 0c 4a 0a 40 5a 80 |Y..J.@Z.Y..J.@Z.| +* 0030 19 1c 80 22 d2 01 4b 88 13 42 fc d1 05 49 02 02 |..."..K..B...I..| +* 0040 48 88 05 4b 03 40 13 43 4b 80 00 f0 5d f8 10 bd |H..K.@.CK...]...| +* 0050 63 6f 66 66 1a 00 01 5d b8 |coff..x| +*/ + + /* from this dump we can see the following + * 1) newtmgr hdr 8 bytes + * 2) cbor wrapper up to data (and length) 8 bytes + * 3) cbor data 64 bytes + * 4) offset tag 4 bytes + * 5) offsert value 3 (safely say 5 bytes since it could be bigger + * than uint16_t + * That makes 25 bytes plus the data needs to fit in 91 bytes +*/ + + /* however, something is not calcualated properly as we +* can only do 66 bytes here. Use 64 for power of 2 */ mtu = 64 } http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/dba476ce/newtmgr/transport/connserial.go -- diff --git a/newtmgr/transport/connserial.go b/newtmgr/transport/connserial.go index b7aaf4f..37514a0 100644 --- a/newtmgr/transport/connserial.go +++ b/newtmgr/transport/connserial.go @@ -212,13 +212,22 @@ func (cs *ConnSerial) WritePacket(pkt *Packet) error { totlen := len(base64Data) for written < totlen { + /* write the packet stat designators. They are + * different whether we are starting a new packet or continuing one */ if written == 0 { cs.writeData([]byte{6, 9}) } else { cs.writeData([]byte{4, 20}) } - writeLen := util.Min(120, totlen-written) + /* ensure that the total frame fits into 128 bytes. +* base 64 is 3 ascii to 4 base 64 byte encoding. so +* the number below should be a multiple of 4. Also, +* we need to save room for the header (2 byte) and +* carriage return (and possibly LF 2 bytes), */ + + /* all totaled, 124 bytes should work */ + writeLen := util.Min(124, totlen-written) writeBytes := base64Data[written : written+writeLen] cs.writeData(writeBytes)
incubator-mynewt-core git commit: Removing bsp_sysid.h as obsolete.
Repository: incubator-mynewt-core Updated Branches: refs/heads/develop 94944515c -> 5b51840c6 Removing bsp_sysid.h as obsolete. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/5b51840c Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/5b51840c Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/5b51840c Branch: refs/heads/develop Commit: 5b51840c60d5e7809fe0b009b3145efd67a06553 Parents: 9494451 Author: Marko KiiskilaAuthored: Tue Oct 18 15:17:47 2016 -0700 Committer: Marko Kiiskila Committed: Tue Oct 18 15:17:47 2016 -0700 -- .../arduino_primo_nrf52/include/bsp/bsp_sysid.h | 37 - hw/bsp/bmd300eval/include/bsp/bsp_sysid.h | 37 - hw/bsp/frdm-k64f/include/bsp/bsp_sysid.h| 35 hw/bsp/native/include/bsp/bsp_sysid.h | 56 hw/bsp/native/src/hal_bsp.c | 2 - .../nrf51-arduino_101/include/bsp/bsp_sysid.h | 36 - hw/bsp/nrf51-blenano/include/bsp/bsp_sysid.h| 36 - hw/bsp/nrf51dk-16kbram/include/bsp/bsp_sysid.h | 37 - hw/bsp/nrf51dk/include/bsp/bsp_sysid.h | 36 - hw/bsp/nrf52dk/include/bsp/bsp_sysid.h | 37 - hw/bsp/nucleo-f401re/include/bsp/bsp_sysid.h| 36 - .../include/bsp/bsp_sysid.h | 36 - hw/bsp/rb-nano2/include/bsp/bsp_sysid.h | 37 - hw/bsp/stm32f4discovery/include/bsp/bsp_sysid.h | 36 - 14 files changed, 494 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5b51840c/hw/bsp/arduino_primo_nrf52/include/bsp/bsp_sysid.h -- diff --git a/hw/bsp/arduino_primo_nrf52/include/bsp/bsp_sysid.h b/hw/bsp/arduino_primo_nrf52/include/bsp/bsp_sysid.h deleted file mode 100644 index 63959e5..000 --- a/hw/bsp/arduino_primo_nrf52/include/bsp/bsp_sysid.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -#ifndef BSP_SYSID_H -#define BSP_SYSID_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* stub until this BSP gets new HAL */ -enum system_device_id -{ -RESERVED, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* BSP_SYSID_H */ - http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5b51840c/hw/bsp/bmd300eval/include/bsp/bsp_sysid.h -- diff --git a/hw/bsp/bmd300eval/include/bsp/bsp_sysid.h b/hw/bsp/bmd300eval/include/bsp/bsp_sysid.h deleted file mode 100644 index 63959e5..000 --- a/hw/bsp/bmd300eval/include/bsp/bsp_sysid.h +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -#ifndef BSP_SYSID_H -#define BSP_SYSID_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* stub until this BSP gets new HAL */ -enum system_device_id -{ -RESERVED, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* BSP_SYSID_H */ - http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5b51840c/hw/bsp/frdm-k64f/include/bsp/bsp_sysid.h
[1/2] incubator-mynewt-newt git commit: newt - Allow syscfg.vals to be set; "target set"
Repository: incubator-mynewt-newt Updated Branches: refs/heads/develop 1a8b9b727 -> 0558d537a newt - Allow syscfg.vals to be set; "target set" Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/0558d537 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/0558d537 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/0558d537 Branch: refs/heads/develop Commit: 0558d537ac0b2089169d8fb7710f8a3fab8136c3 Parents: 823c05c Author: Christopher CollinsAuthored: Tue Oct 18 15:08:09 2016 -0700 Committer: Christopher Collins Committed: Tue Oct 18 15:08:35 2016 -0700 -- newt/cli/target_cmds.go | 57 --- newt/pkg/localpackage.go | 37 newt/target/target.go| 4 +++ 3 files changed, 94 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0558d537/newt/cli/target_cmds.go -- diff --git a/newt/cli/target_cmds.go b/newt/cli/target_cmds.go index e325713..4050639 100644 --- a/newt/cli/target_cmds.go +++ b/newt/cli/target_cmds.go @@ -36,6 +36,7 @@ import ( "mynewt.apache.org/newt/newt/syscfg" "mynewt.apache.org/newt/newt/target" "mynewt.apache.org/newt/util" + "mynewt.apache.org/newt/viper" ) var targetForce bool = false @@ -122,8 +123,8 @@ func targetShowCmd(cmd *cobra.Command, args []string) { } // A few variables come from the base package rather than the target. - kvPairs["features"] = pkgVarSliceString(target.Package(), - "pkg.features") + kvPairs["syscfg"] = targetSyscfgKVToStr( + target.Package().SyscfgV.GetStringMapString("syscfg.vals")) kvPairs["cflags"] = pkgVarSliceString(target.Package(), "pkg.cflags") kvPairs["lflags"] = pkgVarSliceString(target.Package(), "pkg.lflags") kvPairs["aflags"] = pkgVarSliceString(target.Package(), "pkg.aflags") @@ -143,6 +144,51 @@ func targetShowCmd(cmd *cobra.Command, args []string) { } } +func targetSyscfgKVFromStr(str string) map[string]string { + vals := map[string]string{} + + if strings.TrimSpace(str) == "" { + return vals + } + + // Separate syscfg vals are delimited by ':'. + fields := strings.Split(str, ":") + + // Key-value pairs are delimited by '='. If no '=' is present, assume the + // string is the key name and the value is 1. + for _, f := range fields { + kv := strings.SplitN(f, "=", 2) + switch len(kv) { + case 1: + vals[f] = "1" + case 2: + vals[kv[0]] = kv[1] + } + } + + return vals +} + +func targetSyscfgKVToStr(syscfgKv map[string]string) string { + str := "" + + names := make([]string, 0, len(syscfgKv)) + for k, _ := range syscfgKv { + names = append(names, k) + } + sort.Strings(names) + + for i, name := range names { + if i != 0 { + str += ":" + } + + str += fmt.Sprintf("%s=%s", name, syscfgKv[name]) + } + + return str +} + func targetSetCmd(cmd *cobra.Command, args []string) { if len(args) < 2 { NewtUsage(cmd, @@ -185,8 +231,11 @@ func targetSetCmd(cmd *cobra.Command, args []string) { for _, kv := range vars { // A few variables are special cases; they get set in the base package // instead of the target. - if kv[0] == "target.features" || - kv[0] == "target.cflags" || + if kv[0] == "target.syscfg" { + t.Package().SyscfgV = viper.New() + kv := targetSyscfgKVFromStr(kv[1]) + t.Package().SyscfgV.Set("syscfg.vals", kv) + } else if kv[0] == "target.cflags" || kv[0] == "target.lflags" || kv[0] == "target.aflags" { http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/0558d537/newt/pkg/localpackage.go -- diff --git a/newt/pkg/localpackage.go b/newt/pkg/localpackage.go index 755a477..3e8e325 100644 --- a/newt/pkg/localpackage.go +++ b/newt/pkg/localpackage.go @@ -26,6 +26,7 @@ import ( "io/ioutil" "os" "path/filepath" + "sort" "strings" log "github.com/Sirupsen/logrus" @@ -231,6
[2/2] incubator-mynewt-newt git commit: newtmgr - Remove underscore in identifier.
newtmgr - Remove underscore in identifier. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/823c05c0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/823c05c0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/823c05c0 Branch: refs/heads/develop Commit: 823c05c0b2851b89e70b7cb9f57d0ddff3f66740 Parents: 1a8b9b7 Author: Christopher CollinsAuthored: Thu Oct 13 15:15:41 2016 -0700 Committer: Christopher Collins Committed: Tue Oct 18 15:08:35 2016 -0700 -- newtmgr/cli/image.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/823c05c0/newtmgr/cli/image.go -- diff --git a/newtmgr/cli/image.go b/newtmgr/cli/image.go index 67a8b8b..c8ca761 100644 --- a/newtmgr/cli/image.go +++ b/newtmgr/cli/image.go @@ -123,14 +123,14 @@ func imageStateTestCmd(cmd *cobra.Command, args []string) { nmUsage(cmd, nil) } - hex_bytes, _ := hex.DecodeString(args[0]) + hexBytes, _ := hex.DecodeString(args[0]) req, err := protocol.NewImageStateWriteReq() if err != nil { nmUsage(nil, err) } - req.Hash = hex_bytes + req.Hash = hexBytes req.Confirm = false nmr, err := req.Encode()
incubator-mynewt-core git commit: Boot loader - code cleanup.
Repository: incubator-mynewt-core Updated Branches: refs/heads/develop d0df2fbd4 -> 94944515c Boot loader - code cleanup. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/94944515 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/94944515 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/94944515 Branch: refs/heads/develop Commit: 94944515c601c3fbc557ab747c69d38435cd5965 Parents: d0df2fb Author: Christopher CollinsAuthored: Mon Oct 17 16:03:14 2016 -0700 Committer: Christopher Collins Committed: Tue Oct 18 14:37:21 2016 -0700 -- boot/bootutil/include/bootutil/bootutil.h | 25 +- boot/bootutil/src/bootutil_misc.c | 454 +--- boot/bootutil/src/bootutil_priv.h | 12 +- boot/bootutil/src/loader.c | 520 +++ .../test/src/testcases/boot_test_invalid_hash.c | 2 +- .../src/testcases/boot_test_no_flag_has_hash.c | 2 +- .../test/src/testcases/boot_test_no_hash.c | 2 +- .../test/src/testcases/boot_test_nv_bs_11.c | 3 +- .../src/testcases/boot_test_nv_bs_11_2areas.c | 2 +- .../test/src/testcases/boot_test_nv_ns_01.c | 2 +- .../test/src/testcases/boot_test_vb_ns_11.c | 2 +- .../test/src/testcases/boot_test_vm_ns_01.c | 2 +- .../src/testcases/boot_test_vm_ns_11_2areas.c | 2 +- .../test/src/testcases/boot_test_vm_ns_11_b.c | 2 +- mgmt/imgmgr/include/imgmgr/imgmgr.h | 1 + mgmt/imgmgr/src/imgmgr_cli.c| 11 +- mgmt/imgmgr/src/imgmgr_state.c | 4 +- 17 files changed, 481 insertions(+), 567 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/94944515/boot/bootutil/include/bootutil/bootutil.h -- diff --git a/boot/bootutil/include/bootutil/bootutil.h b/boot/bootutil/include/bootutil/bootutil.h index af84b8c..ebc3441 100644 --- a/boot/bootutil/include/bootutil/bootutil.h +++ b/boot/bootutil/include/bootutil/bootutil.h @@ -34,18 +34,8 @@ extern "C" { #define BOOT_SWAP_TYPE_TEST 1 #define BOOT_SWAP_TYPE_REVERT 2 -int boot_status_source(void); -int boot_swap_type(void); -int boot_partial_swap_type(void); - -int boot_vect_read_test(int *slot); -int boot_vect_read_main(int *slot); -int boot_set_pending(int slot); -int boot_set_confirmed(void); - -void boot_set_image_slot_split(void); - struct image_header; +struct boot_img_trailer; /** A request object instructing the boot loader how to proceed. */ struct boot_req { @@ -92,12 +82,17 @@ struct boot_rsp { }; /* you must have pre-allocated all the entries within this structure */ -int -boot_build_request(struct boot_req *preq, int area_descriptor_max); +int boot_build_request(struct boot_req *preq, int area_descriptor_max); -int -boot_go(const struct boot_req *req, struct boot_rsp *rsp); +int boot_go(const struct boot_req *req, struct boot_rsp *rsp); + +int boot_swap_type(void); + +int boot_set_pending(void); +int boot_set_confirmed(void); +int boot_read_img_trailer(int slot, struct boot_img_trailer *bit); +int boot_read_scratch_trailer(struct boot_img_trailer *bit); #define SPLIT_GO_OK (0) #define SPLIT_GO_NON_MATCHING (-1) http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/94944515/boot/bootutil/src/bootutil_misc.c -- diff --git a/boot/bootutil/src/bootutil_misc.c b/boot/bootutil/src/bootutil_misc.c index 675308f..37bfaa2 100644 --- a/boot/bootutil/src/bootutil_misc.c +++ b/boot/bootutil/src/bootutil_misc.c @@ -33,88 +33,6 @@ int boot_current_slot; -struct boot_status_table { -/** * For each field, a value of 0 means "any". */ -uint32_t bst_magic_slot0; -uint32_t bst_magic_scratch; -uint8_t bst_copy_done_slot0; - -uint8_t bst_status_source; -}; - -/** - * This set of tables maps image trailer contents to swap status location. - * When searching for a match, these tables must be iterated sequentially. - */ -static const struct boot_status_table boot_status_tables[] = { -{ -/* | slot-0 | scratch| - * --++| - * magic | 0x12344321 | 0x | - * copy-done | 0x01 | N/A| - * --++' - * status: none| - * ' - */ -.bst_magic_slot0 = BOOT_IMG_MAGIC, -.bst_magic_scratch =0, -.bst_copy_done_slot0 = 0x01, -.bst_status_source =
[4/5] incubator-mynewt-core git commit: stm32f4 gpio; when enabling GPIO output, start driving it with the desired initial state.
stm32f4 gpio; when enabling GPIO output, start driving it with the desired initial state. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d3ed09cd Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d3ed09cd Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d3ed09cd Branch: refs/heads/develop Commit: d3ed09cd9b1836c67465a0ffa4e6bc63b7cc25ac Parents: 8ef2522 Author: Marko KiiskilaAuthored: Tue Oct 18 12:51:56 2016 -0700 Committer: Marko Kiiskila Committed: Tue Oct 18 13:15:41 2016 -0700 -- hw/mcu/stm/stm32f4xx/src/hal_gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d3ed09cd/hw/mcu/stm/stm32f4xx/src/hal_gpio.c -- diff --git a/hw/mcu/stm/stm32f4xx/src/hal_gpio.c b/hw/mcu/stm/stm32f4xx/src/hal_gpio.c index 9b19040..1db025e 100644 --- a/hw/mcu/stm/stm32f4xx/src/hal_gpio.c +++ b/hw/mcu/stm/stm32f4xx/src/hal_gpio.c @@ -469,11 +469,11 @@ int hal_gpio_init_out(int pin, int val) init_cfg.Speed = GPIO_SPEED_HIGH; init_cfg.Alternate = 0; +hal_gpio_write(pin, val); rc = hal_gpio_init_stm(pin, _cfg); if (rc) { return rc; } -hal_gpio_write(pin, val); return 0; }
[1/5] incubator-mynewt-core git commit: stm32f4 hal spi; fix race when slave saw CS; sometimes was sending first byte twice.
Repository: incubator-mynewt-core Updated Branches: refs/heads/develop e238713aa -> d0df2fbd4 stm32f4 hal spi; fix race when slave saw CS; sometimes was sending first byte twice. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d0df2fbd Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d0df2fbd Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d0df2fbd Branch: refs/heads/develop Commit: d0df2fbd41454f76408c5ab7637e38099714b015 Parents: d3ed09c Author: Marko KiiskilaAuthored: Tue Oct 18 13:14:32 2016 -0700 Committer: Marko Kiiskila Committed: Tue Oct 18 13:15:41 2016 -0700 -- hw/mcu/stm/stm32f4xx/src/hal_spi.c | 103 ++-- 1 file changed, 73 insertions(+), 30 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d0df2fbd/hw/mcu/stm/stm32f4xx/src/hal_spi.c -- diff --git a/hw/mcu/stm/stm32f4xx/src/hal_spi.c b/hw/mcu/stm/stm32f4xx/src/hal_spi.c index c52fae9..4ed3bc0 100644 --- a/hw/mcu/stm/stm32f4xx/src/hal_spi.c +++ b/hw/mcu/stm/stm32f4xx/src/hal_spi.c @@ -42,10 +42,10 @@ struct stm32f4_hal_spi { SPI_HandleTypeDef handle; -uint8_t slave:1; -uint8_t tx_in_prog:1; -uint8_t selected:1; -uint8_t def_char[4]; +uint8_t slave:1; /* slave or master */ +uint8_t tx_in_prog:1; /* slave: tx'ing user data not def */ +uint8_t selected:1;/* slave: if we see SS */ +uint8_t def_char[4]; /* slave: default data to tx */ struct stm32f4_hal_spi_cfg *cfg; /* Callback and arguments */ hal_spi_txrx_cb txrx_cb_func; @@ -155,6 +155,9 @@ stm32f4_resolve_spi_irq(SPI_HandleTypeDef *hspi) } } +/* + * SPI master IRQ handler. + */ static void spim_irq_handler(struct stm32f4_hal_spi *spi) { @@ -165,11 +168,17 @@ spim_irq_handler(struct stm32f4_hal_spi *spi) } } +/* + * SPI slave IRQ handler. + */ static void spis_irq_handler(struct stm32f4_hal_spi *spi) { if (spi->tx_in_prog) { if (spi->handle.TxXferCount == 0 && spi->handle.RxXferCount == 0) { +/* + * If finished with data tx, start transmitting default char + */ spi->tx_in_prog = 0; HAL_SPI_Transmit_IT(>handle, spi->def_char, 2); @@ -179,11 +188,17 @@ spis_irq_handler(struct stm32f4_hal_spi *spi) } } } else { +/* + * Reset TX pointer within default data. + */ spi->handle.pTxBuffPtr = spi->def_char; spi->handle.TxXferCount = 2; } } +/* + * Common IRQ handler for both master and slave. + */ static void spi_irq_handler(struct stm32f4_hal_spi *spi) { @@ -212,51 +227,71 @@ spi_irq_handler(struct stm32f4_hal_spi *spi) } } +/* + * GPIO interrupt when slave gets selected/deselected. + */ static void spi_ss_isr(void *arg) { struct stm32f4_hal_spi *spi = (struct stm32f4_hal_spi *)arg; int ss; int len; -int rc; uint16_t reg; spi_stat.ss_irq++; ss = hal_gpio_read(spi->cfg->ss_pin); if (ss == 0 && !spi->selected) { -reg = spi->handle.Instance->CR1; -reg &= ~SPI_CR1_SSI; -spi->handle.Instance->CR1 = reg; +/* + * We're now seeing chip select. Enable SPI, SPI interrupts. + */ if (spi->tx_in_prog) { -rc = HAL_SPI_TransmitReceive_IT(>handle, - spi->handle.pTxBuffPtr, spi->handle.pRxBuffPtr, - spi->handle.TxXferSize); +__HAL_SPI_ENABLE_IT(>handle, + SPI_IT_RXNE | SPI_IT_TXE | SPI_IT_ERR); } else { -rc = HAL_SPI_Transmit_IT(>handle, spi->def_char, 2); +__HAL_SPI_ENABLE_IT(>handle, SPI_IT_TXE | SPI_IT_ERR); } -assert(rc == 0); +reg = spi->handle.Instance->CR1; +reg &= ~SPI_CR1_SSI; +reg |= SPI_CR1_SPE; +spi->handle.Instance->CR1 = reg; spi->selected = 1; } if (ss == 1 && spi->selected) { +/* + * Chip select done. Check whether there's pending data to RX. + */ if (spi->handle.Instance->SR & SPI_SR_RXNE && spi->handle.RxISR) { spi->handle.RxISR(>handle); } + +/* + * Disable SPI. + */ reg = spi->handle.Instance->CR1; reg &= ~SPI_CR1_SPE; reg |= SPI_CR1_SSI; +spi->handle.Instance->CR1 = reg; __HAL_SPI_DISABLE_IT(>handle, SPI_IT_RXNE|SPI_IT_TXE|SPI_IT_ERR); -spi->handle.Instance->CR1 = reg; len = spi->handle.RxXferSize - spi->handle.RxXferCount; -if
[3/5] incubator-mynewt-core git commit: stm32f4 hal spi; hw error counters.
stm32f4 hal spi; hw error counters. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/97bf2867 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/97bf2867 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/97bf2867 Branch: refs/heads/develop Commit: 97bf286714a9d2c6716d226b92bd98518f4e3bbd Parents: e238713 Author: Marko KiiskilaAuthored: Tue Oct 18 10:10:38 2016 -0700 Committer: Marko Kiiskila Committed: Tue Oct 18 13:15:41 2016 -0700 -- hw/mcu/stm/stm32f4xx/src/hal_spi.c | 29 +- hw/mcu/stm/stm32f4xx/src/hal_spi_soft_ssi.c | 847 +++ 2 files changed, 873 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/97bf2867/hw/mcu/stm/stm32f4xx/src/hal_spi.c -- diff --git a/hw/mcu/stm/stm32f4xx/src/hal_spi.c b/hw/mcu/stm/stm32f4xx/src/hal_spi.c index c0de992..c52fae9 100644 --- a/hw/mcu/stm/stm32f4xx/src/hal_spi.c +++ b/hw/mcu/stm/stm32f4xx/src/hal_spi.c @@ -56,6 +56,9 @@ static struct stm32f4_spi_stat { uint32_t irq; uint32_t ss_irq; uint32_t tx; +uint32_t eovf; +uint32_t emodf; +uint32_t efre; } spi_stat; static void spi_irq_handler(struct stm32f4_hal_spi *spi); @@ -155,8 +158,6 @@ stm32f4_resolve_spi_irq(SPI_HandleTypeDef *hspi) static void spim_irq_handler(struct stm32f4_hal_spi *spi) { -HAL_SPI_IRQHandler(>handle); - if (spi->handle.TxXferCount == 0 && spi->handle.RxXferCount == 0) { if (spi->txrx_cb_func) { spi->txrx_cb_func(spi->txrx_cb_arg, spi->handle.TxXferSize); @@ -167,7 +168,6 @@ spim_irq_handler(struct stm32f4_hal_spi *spi) static void spis_irq_handler(struct stm32f4_hal_spi *spi) { -HAL_SPI_IRQHandler(>handle); if (spi->tx_in_prog) { if (spi->handle.TxXferCount == 0 && spi->handle.RxXferCount == 0) { spi->tx_in_prog = 0; @@ -187,7 +187,24 @@ spis_irq_handler(struct stm32f4_hal_spi *spi) static void spi_irq_handler(struct stm32f4_hal_spi *spi) { +uint32_t err; + spi_stat.irq++; + +HAL_SPI_IRQHandler(>handle); +err = spi->handle.ErrorCode; +if (err) { +if (err & HAL_SPI_ERROR_OVR) { +spi_stat.eovf++; +} +if (err & HAL_SPI_ERROR_MODF) { +spi_stat.emodf++; +} +if (err & HAL_SPI_ERROR_FRE) { +spi_stat.efre++; +} +spi->handle.ErrorCode = 0; +} if (!spi->slave) { spim_irq_handler(spi); } else { @@ -221,9 +238,15 @@ spi_ss_isr(void *arg) spi->selected = 1; } if (ss == 1 && spi->selected) { +if (spi->handle.Instance->SR & SPI_SR_RXNE && spi->handle.RxISR) { +spi->handle.RxISR(>handle); +} reg = spi->handle.Instance->CR1; reg &= ~SPI_CR1_SPE; reg |= SPI_CR1_SSI; + +__HAL_SPI_DISABLE_IT(>handle, SPI_IT_RXNE|SPI_IT_TXE|SPI_IT_ERR); + spi->handle.Instance->CR1 = reg; len = spi->handle.RxXferSize - spi->handle.RxXferCount; if (spi->tx_in_prog && len) { http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/97bf2867/hw/mcu/stm/stm32f4xx/src/hal_spi_soft_ssi.c -- diff --git a/hw/mcu/stm/stm32f4xx/src/hal_spi_soft_ssi.c b/hw/mcu/stm/stm32f4xx/src/hal_spi_soft_ssi.c new file mode 100644 index 000..71bea92 --- /dev/null +++ b/hw/mcu/stm/stm32f4xx/src/hal_spi_soft_ssi.c @@ -0,0 +1,847 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#include +#include + +#include + +#include + +#include + +#include "stm32f4xx.h" +#include "stm32f4xx_hal_dma.h" +#include "stm32f4xx_hal_spi.h" +#include "stm32f4xx_hal_gpio.h" +#include "stm32f4xx_hal_gpio_ex.h" +#include "stm32f4xx_hal_rcc.h" +#include "mcu/stm32f4xx_mynewt_hal.h" +#include "mcu/stm32f4_bsp.h" +#include
[2/5] incubator-mynewt-core git commit: stm32f4 SDK; add routines which queue tx/rx without enabling SPI.
stm32f4 SDK; add routines which queue tx/rx without enabling SPI. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/8ef25221 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/8ef25221 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/8ef25221 Branch: refs/heads/develop Commit: 8ef252214cbb1972fe7a4e41869d10c012ac186f Parents: f9dc1be Author: Marko KiiskilaAuthored: Tue Oct 18 12:50:53 2016 -0700 Committer: Marko Kiiskila Committed: Tue Oct 18 13:15:41 2016 -0700 -- .../Inc/stm32f4xx_hal_spi.h | 2 + .../Src/stm32f4xx_hal_spi.c | 92 +--- 2 files changed, 63 insertions(+), 31 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8ef25221/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h -- diff --git a/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h b/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h index 5287f63..5176c4f 100644 --- a/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h +++ b/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h @@ -442,8 +442,10 @@ HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint HAL_StatusTypeDef HAL_SPI_Receive(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout); HAL_StatusTypeDef HAL_SPI_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size, uint32_t Timeout); HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); +HAL_StatusTypeDef HAL_SPI_QueueTransmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_Receive_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); +HAL_StatusTypeDef HAL_SPI_Slave_Queue_TransmitReceive(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_Transmit_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size); HAL_StatusTypeDef HAL_SPI_TransmitReceive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pTxData, uint8_t *pRxData, uint16_t Size); http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8ef25221/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c -- diff --git a/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c b/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c index 84f9597..bdf493c 100644 --- a/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c +++ b/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c @@ -1040,6 +1040,37 @@ HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, u /* Process Locked */ __HAL_LOCK(hspi); + errorcode = HAL_SPI_QueueTransmit(hspi, pData, Size); + if (errorcode) { + goto error; + } + if (hspi->Init.Direction == SPI_DIRECTION_2LINES) + { +/* Enable TXE interrupt */ +__HAL_SPI_ENABLE_IT(hspi, (SPI_IT_TXE)); + } + else + { +/* Enable TXE and ERR interrupt */ +__HAL_SPI_ENABLE_IT(hspi, (SPI_IT_TXE | SPI_IT_ERR)); + } + + /* Check if the SPI is already enabled */ + if((hspi->Instance->CR1 _CR1_SPE) != SPI_CR1_SPE) + { +/* Enable SPI peripheral */ +__HAL_SPI_ENABLE(hspi); + } + +error : + __HAL_UNLOCK(hspi); + return errorcode; +} + +HAL_StatusTypeDef HAL_SPI_QueueTransmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size) +{ + HAL_StatusTypeDef errorcode = HAL_OK; + if((pData == NULL) || (Size == 0U)) { errorcode = HAL_ERROR; @@ -1089,29 +1120,11 @@ HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, u } #endif /* USE_SPI_CRC */ - if (hspi->Init.Direction == SPI_DIRECTION_2LINES) - { -/* Enable TXE interrupt */ -__HAL_SPI_ENABLE_IT(hspi, (SPI_IT_TXE)); - } - else - { -/* Enable TXE and ERR interrupt */ -__HAL_SPI_ENABLE_IT(hspi, (SPI_IT_TXE | SPI_IT_ERR)); - } - if ((hspi->Instance->CR1 & SPI_CR1_MSTR) == 0) { hspi->TxISR(hspi); } - /* Check if the SPI is already enabled */ - if((hspi->Instance->CR1 _CR1_SPE) != SPI_CR1_SPE) - { -/*
[5/5] incubator-mynewt-core git commit: spitest; print received/transmitted bytes.
spitest; print received/transmitted bytes. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f9dc1bec Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f9dc1bec Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f9dc1bec Branch: refs/heads/develop Commit: f9dc1becb2af033bc1f4ee3d795798dced4e03d0 Parents: 97bf286 Author: Marko KiiskilaAuthored: Tue Oct 18 10:11:09 2016 -0700 Committer: Marko Kiiskila Committed: Tue Oct 18 13:15:41 2016 -0700 -- apps/spitest/src/main.c | 21 + 1 file changed, 21 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f9dc1bec/apps/spitest/src/main.c -- diff --git a/apps/spitest/src/main.c b/apps/spitest/src/main.c index 0059bc5..9f125ce 100755 --- a/apps/spitest/src/main.c +++ b/apps/spitest/src/main.c @@ -26,6 +26,7 @@ #include #include #include +#include #ifdef ARCH_sim #include #endif @@ -283,6 +284,16 @@ task1_handler(void *arg) rc = hal_spi_txrx_noblock(0, g_spi_tx_buf, g_spi_rx_buf, spi_cb_obj.txlen); assert(!rc); +console_printf("a transmitted: "); +for (i = 0; i < spi_cb_obj.txlen; i++) { +console_printf("%2x ", g_spi_tx_buf[i]); +} +console_printf("\n"); +console_printf("received: "); +for (i = 0; i < spi_cb_obj.txlen; i++) { +console_printf("%2x ", g_spi_rx_buf[i]); +} +console_printf("\n"); #endif } else { /* Send blocking */ @@ -305,6 +316,16 @@ task1_handler(void *arg) rc = hal_spi_txrx(0, g_spi_tx_buf, g_spi_rx_buf, spi_cb_obj.txlen); assert(!rc); hal_gpio_set(SPI_SS_PIN); +console_printf("b transmitted: "); +for (i = 0; i < spi_cb_obj.txlen; i++) { +console_printf("%2x ", g_spi_tx_buf[i]); +} +console_printf("\n"); +console_printf("received: "); +for (i = 0; i < spi_cb_obj.txlen; i++) { +console_printf("%2x ", g_spi_rx_buf[i]); +} +console_printf("\n"); spitest_validate_last(spi_cb_obj.txlen); #endif }
incubator-mynewt-newt git commit: add C++ compilation support to newt
Repository: incubator-mynewt-newt Updated Branches: refs/heads/develop 878fe2fff -> 1a8b9b727 add C++ compilation support to newt Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/1a8b9b72 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/1a8b9b72 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/1a8b9b72 Branch: refs/heads/develop Commit: 1a8b9b727f1429e2510dd0116c410e3b0043cf28 Parents: 878fe2f Author: Sterling HughesAuthored: Tue Oct 18 12:15:20 2016 -0700 Committer: Sterling Hughes Committed: Tue Oct 18 12:15:20 2016 -0700 -- newt/builder/build.go | 12 + newt/toolchain/compiler.go | 54 +++-- 2 files changed, 64 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/1a8b9b72/newt/builder/build.go -- diff --git a/newt/builder/build.go b/newt/builder/build.go index 445d9a2..e78206f 100644 --- a/newt/builder/build.go +++ b/newt/builder/build.go @@ -169,6 +169,12 @@ func buildDir(srcDir string, c *toolchain.Compiler, arch string, return err } + // Compile CPP files + if err := c.RecursiveCompile(toolchain.COMPILER_TYPE_CPP, + append(ignDirs, "arch")); err != nil { + return err + } + archDir := srcDir + "/arch/" + arch + "/" if util.NodeExist(archDir) { util.StatusMessage(util.VERBOSITY_VERBOSE, @@ -185,6 +191,12 @@ func buildDir(srcDir string, c *toolchain.Compiler, arch string, return err } + // Compile CPP source + if err := c.RecursiveCompile(toolchain.COMPILER_TYPE_CPP, + ignDirs); err != nil { + return err + } + // Compile assembly source (only architecture-specific). if err := c.RecursiveCompile(toolchain.COMPILER_TYPE_ASM, ignDirs); err != nil { http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/1a8b9b72/newt/toolchain/compiler.go -- diff --git a/newt/toolchain/compiler.go b/newt/toolchain/compiler.go index c2cfa7d..e1c43a9 100644 --- a/newt/toolchain/compiler.go +++ b/newt/toolchain/compiler.go @@ -44,6 +44,7 @@ const COMPILER_FILENAME string = "compiler.yml" const ( COMPILER_TYPE_C = 0 COMPILER_TYPE_ASM = 1 + COMPILER_TYPE_CPP = 2 ) type CompilerInfo struct { @@ -61,6 +62,7 @@ type Compiler struct { depTrackerDepTracker ccPathstring + cppPath string asPathstring arPathstring odPathstring @@ -219,6 +221,7 @@ func (c *Compiler) load(compilerDir string, buildProfile string) error { } c.ccPath = newtutil.GetStringFeatures(v, features, "compiler.path.cc") + c.cppPath = newtutil.GetStringFeatures(v, features, "compiler.path.cpp") c.asPath = newtutil.GetStringFeatures(v, features, "compiler.path.as") c.arPath = newtutil.GetStringFeatures(v, features, "compiler.path.archive") c.odPath = newtutil.GetStringFeatures(v, features, "compiler.path.objdump") @@ -337,6 +340,8 @@ func (c *Compiler) CompileFileCmd(file string, cmd = c.ccPath case COMPILER_TYPE_ASM: cmd = c.asPath + case COMPILER_TYPE_CPP: + cmd = c.cppPath default: return "", util.NewNewtError("Unknown compiler type") } @@ -434,6 +439,8 @@ func (c *Compiler) CompileFile(file string, compilerType int) error { switch compilerType { case COMPILER_TYPE_C: util.StatusMessage(util.VERBOSITY_DEFAULT, "Compiling %s\n", file) + case COMPILER_TYPE_CPP: + util.StatusMessage(util.VERBOSITY_DEFAULT, "Compiling %s\n", file) case COMPILER_TYPE_ASM: util.StatusMessage(util.VERBOSITY_DEFAULT, "Assembling %s\n", file) default: @@ -468,8 +475,6 @@ func (c *Compiler) shouldIgnoreFile(file string) bool { // Compiles all C files matching the specified file glob. // -// @param match The file glob specifying which C files to -// compile. func (c *Compiler) CompileC() error { files, _ := filepath.Glob("*.c") @@ -507,6 +512,49 @@ func (c *Compiler) CompileC() error { return nil } +// Compiles all CPP files +func (c *Compiler) CompileCpp() error { +
incubator-mynewt-core git commit: add C++ support to mynewt core
Repository: incubator-mynewt-core Updated Branches: refs/heads/develop 3c8b7f436 -> e238713aa add C++ support to mynewt core Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/e238713a Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e238713a Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e238713a Branch: refs/heads/develop Commit: e238713aa098f6a4b2176ccf57e949d8df4f6a0a Parents: 3c8b7f4 Author: Sterling HughesAuthored: Tue Oct 18 12:13:38 2016 -0700 Committer: Sterling Hughes Committed: Tue Oct 18 12:13:38 2016 -0700 -- compiler/arm-none-eabi-m0/compiler.yml | 1 + compiler/arm-none-eabi-m4/compiler.yml | 1 + compiler/sim/compiler.yml | 1 + 3 files changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e238713a/compiler/arm-none-eabi-m0/compiler.yml -- diff --git a/compiler/arm-none-eabi-m0/compiler.yml b/compiler/arm-none-eabi-m0/compiler.yml index 4496efb..318a2ac 100644 --- a/compiler/arm-none-eabi-m0/compiler.yml +++ b/compiler/arm-none-eabi-m0/compiler.yml @@ -18,6 +18,7 @@ # compiler.path.cc: arm-none-eabi-gcc +compiler.path.cpp: arm-none-eabi-g++ compiler.path.archive: arm-none-eabi-ar compiler.path.as: arm-none-eabi-gcc -x assembler-with-cpp compiler.path.objdump: arm-none-eabi-objdump http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e238713a/compiler/arm-none-eabi-m4/compiler.yml -- diff --git a/compiler/arm-none-eabi-m4/compiler.yml b/compiler/arm-none-eabi-m4/compiler.yml index 2f87c29..9fa5aab 100644 --- a/compiler/arm-none-eabi-m4/compiler.yml +++ b/compiler/arm-none-eabi-m4/compiler.yml @@ -18,6 +18,7 @@ # compiler.path.cc: arm-none-eabi-gcc +compiler.path.cpp: arm-none-eabi-g++ -x c++ compiler.path.archive: arm-none-eabi-ar compiler.path.as: arm-none-eabi-gcc -x assembler-with-cpp compiler.path.objdump: arm-none-eabi-objdump http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e238713a/compiler/sim/compiler.yml -- diff --git a/compiler/sim/compiler.yml b/compiler/sim/compiler.yml index 225a4e9..465f575 100644 --- a/compiler/sim/compiler.yml +++ b/compiler/sim/compiler.yml @@ -19,6 +19,7 @@ # Default. compiler.path.cc: "gcc" +compiler.path.cc: "g++" compiler.path.as: "gcc -x assembler-with-cpp" compiler.path.archive: "ar" compiler.path.objdump: "objdump"
[4/5] incubator-mynewt-core git commit: stm32f4 hal spi slave; when SS drops, don't enable SPI until contents of DR have been replaced. Fix the state when user of SPI slave calls TX while SS is low.
stm32f4 hal spi slave; when SS drops, don't enable SPI until contents of DR have been replaced. Fix the state when user of SPI slave calls TX while SS is low. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/7534cf93 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7534cf93 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7534cf93 Branch: refs/heads/develop Commit: 7534cf934c8ba1e06ecc76792df247752d9cbf6f Parents: fb86231 Author: Marko KiiskilaAuthored: Mon Oct 17 23:11:26 2016 -0700 Committer: Marko Kiiskila Committed: Mon Oct 17 23:15:07 2016 -0700 -- hw/mcu/stm/stm32f4xx/src/hal_spi.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7534cf93/hw/mcu/stm/stm32f4xx/src/hal_spi.c -- diff --git a/hw/mcu/stm/stm32f4xx/src/hal_spi.c b/hw/mcu/stm/stm32f4xx/src/hal_spi.c index 2d968e1..c0de992 100644 --- a/hw/mcu/stm/stm32f4xx/src/hal_spi.c +++ b/hw/mcu/stm/stm32f4xx/src/hal_spi.c @@ -55,6 +55,7 @@ struct stm32f4_hal_spi { static struct stm32f4_spi_stat { uint32_t irq; uint32_t ss_irq; +uint32_t tx; } spi_stat; static void spi_irq_handler(struct stm32f4_hal_spi *spi); @@ -207,7 +208,6 @@ spi_ss_isr(void *arg) ss = hal_gpio_read(spi->cfg->ss_pin); if (ss == 0 && !spi->selected) { reg = spi->handle.Instance->CR1; -reg |= SPI_CR1_SPE; reg &= ~SPI_CR1_SSI; spi->handle.Instance->CR1 = reg; if (spi->tx_in_prog) { @@ -659,12 +659,14 @@ hal_spi_txrx_noblock(int spi_num, void *txbuf, void *rxbuf, int len) STM32F4_HAL_SPI_RESOLVE(spi_num, spi); __HAL_DISABLE_INTERRUPTS(sr); +spi_stat.tx++; rc = -1; if (!spi->slave) { rc = HAL_SPI_TransmitReceive_IT(>handle, txbuf, rxbuf, len); } else { spi->tx_in_prog = 1; if (spi->selected) { +spi->handle.State = HAL_SPI_STATE_READY; rc = HAL_SPI_TransmitReceive_IT(>handle, txbuf, rxbuf, len); } else { rc = 0; @@ -750,6 +752,7 @@ uint16_t hal_spi_tx_val(int spi_num, uint16_t val) len = sizeof(uint16_t); } __HAL_DISABLE_INTERRUPTS(sr); +spi_stat.tx++; rc = HAL_SPI_TransmitReceive(>handle,(uint8_t *), (uint8_t *), len, STM32F4_HAL_SPI_TIMEOUT); @@ -801,6 +804,7 @@ hal_spi_txrx(int spi_num, void *txbuf, void *rxbuf, int len) goto err; } __HAL_DISABLE_INTERRUPTS(sr); +spi_stat.tx++; __HAL_SPI_ENABLE(>handle); rc = HAL_SPI_TransmitReceive(>handle, (uint8_t *)txbuf, (uint8_t *)rxbuf, len,
[1/5] incubator-mynewt-core git commit: spitest; also set the slave baudrate, so that GPIO io speed can be matched. Drop the default baudrate.
Repository: incubator-mynewt-core Updated Branches: refs/heads/develop 4cd926638 -> 3c8b7f436 spitest; also set the slave baudrate, so that GPIO io speed can be matched. Drop the default baudrate. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3c8b7f43 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3c8b7f43 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3c8b7f43 Branch: refs/heads/develop Commit: 3c8b7f436c9eebb0014d005e5e960f9ee2b63494 Parents: 7534cf9 Author: Marko KiiskilaAuthored: Mon Oct 17 23:14:05 2016 -0700 Committer: Marko Kiiskila Committed: Mon Oct 17 23:15:07 2016 -0700 -- apps/spitest/src/main.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3c8b7f43/apps/spitest/src/main.c -- diff --git a/apps/spitest/src/main.c b/apps/spitest/src/main.c index a7652ef..0059bc5 100755 --- a/apps/spitest/src/main.c +++ b/apps/spitest/src/main.c @@ -60,6 +60,8 @@ struct os_sem g_test_sem; /* For LED toggling */ int g_led_pin; +#define SPI_BAUDRATE 500 + #if MYNEWT_VAL(SPI_MASTER) || MYNEWT_VAL(SPI_0_MASTER) #define SPI_MASTER 1 #endif @@ -147,7 +149,7 @@ sblinky_spi_cfg(int spi_num) my_spi.data_order = HAL_SPI_MSB_FIRST; my_spi.data_mode = HAL_SPI_MODE0; -my_spi.baudrate = 8000; +my_spi.baudrate = SPI_BAUDRATE; my_spi.word_size = HAL_SPI_WORD_SIZE_8BIT; spi_id = 0; hal_spi_config(spi_id, _spi); @@ -191,7 +193,7 @@ sblinky_spi_cfg(int spi_num) my_spi.data_order = HAL_SPI_MSB_FIRST; my_spi.data_mode = HAL_SPI_MODE0; -my_spi.baudrate = 0; +my_spi.baudrate = SPI_BAUDRATE; my_spi.word_size = HAL_SPI_WORD_SIZE_8BIT; spi_id = SPI_SLAVE_ID; hal_spi_config(spi_id, _spi); @@ -311,6 +313,9 @@ task1_handler(void *arg) #endif #ifdef SPI_SLAVE +int prev_len; +uint8_t prev_buf[32]; + void task1_handler(void *arg) { @@ -347,6 +352,7 @@ task1_handler(void *arg) assert(rc == 0); } else { /* transmit back what we just received */ +memcpy(prev_buf, g_spi_tx_buf, 32); memset(g_spi_tx_buf, 0xaa, 32); memcpy(g_spi_tx_buf, g_spi_rx_buf, spi_cb_obj.txlen); rc = hal_spi_txrx_noblock(SPI_SLAVE_ID, g_spi_tx_buf, g_spi_rx_buf,
[2/5] incubator-mynewt-core git commit: stm32f4 SDK; when transmitting as slave, write first byte to DR right away, without waiting for TXE.
stm32f4 SDK; when transmitting as slave, write first byte to DR right away, without waiting for TXE. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/fb862311 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fb862311 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fb862311 Branch: refs/heads/develop Commit: fb8623112f12b48fcb7cddb91118a6bc734f19bd Parents: 4b468ce Author: Marko KiiskilaAuthored: Mon Oct 17 23:08:48 2016 -0700 Committer: Marko Kiiskila Committed: Mon Oct 17 23:15:07 2016 -0700 -- .../ext/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c | 6 ++ 1 file changed, 6 insertions(+) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fb862311/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c -- diff --git a/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c b/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c index 5d1a139..84f9597 100644 --- a/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c +++ b/hw/mcu/stm/stm32f4xx/src/ext/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c @@ -1100,6 +1100,9 @@ HAL_StatusTypeDef HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, u __HAL_SPI_ENABLE_IT(hspi, (SPI_IT_TXE | SPI_IT_ERR)); } + if ((hspi->Instance->CR1 & SPI_CR1_MSTR) == 0) { + hspi->TxISR(hspi); + } /* Check if the SPI is already enabled */ if((hspi->Instance->CR1 _CR1_SPE) != SPI_CR1_SPE) { @@ -1277,6 +1280,9 @@ HAL_StatusTypeDef HAL_SPI_TransmitReceive_IT(SPI_HandleTypeDef *hspi, uint8_t *p /* Enable TXE, RXNE and ERR interrupt */ __HAL_SPI_ENABLE_IT(hspi, (SPI_IT_TXE | SPI_IT_RXNE | SPI_IT_ERR)); + if ((hspi->Instance->CR1 & SPI_CR1_MSTR) == 0) { + hspi->TxISR(hspi); + } /* Check if the SPI is already enabled */ if((hspi->Instance->CR1 _CR1_SPE) != SPI_CR1_SPE) {
[5/5] incubator-mynewt-core git commit: stm32f4 spi; match GPIO IO speed setting to SPI baudrate.
stm32f4 spi; match GPIO IO speed setting to SPI baudrate. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/4b468ce3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4b468ce3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4b468ce3 Branch: refs/heads/develop Commit: 4b468ce31c5874335e2a0b056032f3a5fdf71504 Parents: eeb5ac0 Author: Marko KiiskilaAuthored: Mon Oct 17 15:51:57 2016 -0700 Committer: Marko Kiiskila Committed: Mon Oct 17 23:15:07 2016 -0700 -- hw/mcu/stm/stm32f4xx/src/hal_spi.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4b468ce3/hw/mcu/stm/stm32f4xx/src/hal_spi.c -- diff --git a/hw/mcu/stm/stm32f4xx/src/hal_spi.c b/hw/mcu/stm/stm32f4xx/src/hal_spi.c index 5033c42..2d968e1 100644 --- a/hw/mcu/stm/stm32f4xx/src/hal_spi.c +++ b/hw/mcu/stm/stm32f4xx/src/hal_spi.c @@ -488,7 +488,13 @@ hal_spi_config(int spi_num, struct hal_spi_settings *settings) gpio.Mode = GPIO_MODE_AF_PP; gpio.Pull = GPIO_NOPULL; -gpio.Speed = GPIO_SPEED_FREQ_VERY_HIGH; +if (settings->baudrate <= 2000) { +gpio.Speed = GPIO_SPEED_FREQ_LOW; +} else if (settings->baudrate <= 12500) { +gpio.Speed = GPIO_SPEED_FREQ_MEDIUM; +} else { +gpio.Speed = GPIO_SPEED_FREQ_HIGH; +} /* Enable the clocks for this SPI */ switch (spi_num) { @@ -665,7 +671,7 @@ hal_spi_txrx_noblock(int spi_num, void *txbuf, void *rxbuf, int len) spi->handle.pTxBuffPtr = txbuf; spi->handle.TxXferSize = len; spi->handle.pRxBuffPtr = rxbuf; -spi->handle.RxXferSize = len; +spi->handle.RxXferSize = len; } } __HAL_ENABLE_INTERRUPTS(sr);
[3/5] incubator-mynewt-core git commit: stm32f4 spi; simplify code by having SPI run NSS with HW, but without actually assigning pin. This simplifies code.
stm32f4 spi; simplify code by having SPI run NSS with HW, but without actually assigning pin. This simplifies code. Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/eeb5ac06 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/eeb5ac06 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/eeb5ac06 Branch: refs/heads/develop Commit: eeb5ac06adb8ba519ec376620ad485d5fc86550d Parents: 4cd9266 Author: Marko KiiskilaAuthored: Mon Oct 17 13:39:31 2016 -0700 Committer: Marko Kiiskila Committed: Mon Oct 17 23:15:07 2016 -0700 -- hw/mcu/stm/stm32f4xx/src/hal_spi.c | 32 ++-- 1 file changed, 14 insertions(+), 18 deletions(-) -- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/eeb5ac06/hw/mcu/stm/stm32f4xx/src/hal_spi.c -- diff --git a/hw/mcu/stm/stm32f4xx/src/hal_spi.c b/hw/mcu/stm/stm32f4xx/src/hal_spi.c index d0ea436..5033c42 100644 --- a/hw/mcu/stm/stm32f4xx/src/hal_spi.c +++ b/hw/mcu/stm/stm32f4xx/src/hal_spi.c @@ -157,7 +157,6 @@ spim_irq_handler(struct stm32f4_hal_spi *spi) HAL_SPI_IRQHandler(>handle); if (spi->handle.TxXferCount == 0 && spi->handle.RxXferCount == 0) { -spi->handle.Instance->CR1 &= ~(SPI_CR1_SSI | SPI_CR1_SPE); if (spi->txrx_cb_func) { spi->txrx_cb_func(spi->txrx_cb_arg, spi->handle.TxXferSize); } @@ -202,11 +201,15 @@ spi_ss_isr(void *arg) int ss; int len; int rc; +uint16_t reg; spi_stat.ss_irq++; ss = hal_gpio_read(spi->cfg->ss_pin); if (ss == 0 && !spi->selected) { -spi->handle.Instance->CR1 |= (SPI_CR1_SSI | SPI_CR1_SPE); +reg = spi->handle.Instance->CR1; +reg |= SPI_CR1_SPE; +reg &= ~SPI_CR1_SSI; +spi->handle.Instance->CR1 = reg; if (spi->tx_in_prog) { rc = HAL_SPI_TransmitReceive_IT(>handle, spi->handle.pTxBuffPtr, spi->handle.pRxBuffPtr, @@ -218,7 +221,10 @@ spi_ss_isr(void *arg) spi->selected = 1; } if (ss == 1 && spi->selected) { -spi->handle.Instance->CR1 &= ~(SPI_CR1_SSI | SPI_CR1_SPE); +reg = spi->handle.Instance->CR1; +reg &= ~SPI_CR1_SPE; +reg |= SPI_CR1_SSI; +spi->handle.Instance->CR1 = reg; len = spi->handle.RxXferSize - spi->handle.RxXferCount; if (spi->tx_in_prog && len) { spi->tx_in_prog = 0; @@ -448,9 +454,6 @@ hal_spi_disable(int spi_num) rc = 0; STM32F4_HAL_SPI_RESOLVE(spi_num, spi); -if (!spi->slave) { -spi->handle.Instance->CR1 &= ~SPI_CR1_SSI; -} /* XXX power down */ err: return rc; @@ -476,7 +479,7 @@ hal_spi_config(int spi_num, struct hal_spi_settings *settings) cfg = spi->cfg; if (!spi->slave) { -spi->handle.Init.NSS = SPI_NSS_SOFT; +spi->handle.Init.NSS = SPI_NSS_HARD_OUTPUT; spi->handle.Init.Mode = SPI_MODE_MASTER; } else { spi->handle.Init.NSS = SPI_NSS_SOFT; @@ -627,14 +630,11 @@ hal_spi_config(int spi_num, struct hal_spi_settings *settings) if (rc != 0) { goto err; } -if (!spi->slave) { +if (spi->slave) { spi->handle.Instance->CR1 &= ~SPI_CR1_SSI; -} else { rc = hal_gpio_irq_init(cfg->ss_pin, spi_ss_isr, spi, GPIO_TRIG_BOTH, GPIO_PULL_UP); -if (hal_gpio_read(cfg->ss_pin) == 0) { -spi_ss_isr(spi); -} +spi_ss_isr(spi); } __HAL_ENABLE_INTERRUPTS(sr); return (0); @@ -655,7 +655,6 @@ hal_spi_txrx_noblock(int spi_num, void *txbuf, void *rxbuf, int len) __HAL_DISABLE_INTERRUPTS(sr); rc = -1; if (!spi->slave) { -spi->handle.Instance->CR1 |= (SPI_CR1_SSI | SPI_CR1_SPE); rc = HAL_SPI_TransmitReceive_IT(>handle, txbuf, rxbuf, len); } else { spi->tx_in_prog = 1; @@ -745,11 +744,9 @@ uint16_t hal_spi_tx_val(int spi_num, uint16_t val) len = sizeof(uint16_t); } __HAL_DISABLE_INTERRUPTS(sr); -spi->handle.Instance->CR1 |= (SPI_CR1_SSI | SPI_CR1_SPE); rc = HAL_SPI_TransmitReceive(>handle,(uint8_t *), (uint8_t *), len, STM32F4_HAL_SPI_TIMEOUT); -spi->handle.Instance->CR1 &= ~(SPI_CR1_SSI | SPI_CR1_SPE); __HAL_ENABLE_INTERRUPTS(sr); if (rc != HAL_OK) { retval = 0x; @@ -798,11 +795,10 @@ hal_spi_txrx(int spi_num, void *txbuf, void *rxbuf, int len) goto err; } __HAL_DISABLE_INTERRUPTS(sr); -spi->handle.Instance->CR1 |= (SPI_CR1_SSI | SPI_CR1_SPE); +__HAL_SPI_ENABLE(>handle); rc =