Skip to content

Commit 618667c

Browse files
committed
Initial port of sw
0 parents  commit 618667c

25 files changed

+1503
-0
lines changed

.bazelrc

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
build --compiler=compiler
2+
test --compiler=compiler
3+
4+
build --cpu=stm32g4
5+
test --cpu=stm32g4
6+
7+
build --crosstool_top=@com_github_mjbots_rules_mbed//tools/cc_toolchain:toolchain
8+
test --crosstool_top=@com_github_mjbots_rules_mbed//tools/cc_toolchain:toolchain
9+
10+
build --nostart_end_lib
11+
test --nostart_end_lib
12+
13+
build -c opt
14+
test -c opt
15+
16+
build:host --compiler=compiler
17+
build:host --cpu=k8
18+
19+
build --workspace_status_command=tools/workspace_status.sh
20+
test --workspace_status_command=tools/workspace_status.sh
21+
22+
build --stamp
23+
test --stamp
24+
25+
test --test_output=errors

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*~
2+
*.fcstd?
3+
*.b#?
4+
*.l#?
5+
*.s#?
6+
*.pyc
7+
*.FCStd?
8+
fw/BUILD/
9+
fw/.mbedignore
10+
11+
/bazel-*
12+
13+
/node_modules/
14+
/yarn.lock

WORKSPACE

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# -*- python -*-
2+
3+
# Copyright 2018-2020 Josh Pieper, [email protected].
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
workspace(name = "com_github_mjbots_power_dist")
18+
19+
BAZEL_VERSION = "3.4.1"
20+
BAZEL_VERSION_SHA = "1a64c807716e10c872f1618852d95f4893d81667fe6e691ef696489103c9b460"
21+
22+
load("//tools/workspace:default.bzl", "add_default_repositories")
23+
24+
add_default_repositories()
25+
26+
load("@com_github_mjbots_rules_mbed//:rules.bzl", mbed_register = "mbed_register")
27+
28+
mbed_register(
29+
config = {
30+
"mbed_target": "targets/TARGET_STM/TARGET_STM32G4/TARGET_STM32G474xE/TARGET_NUCLEO_G474RE",
31+
"mbed_config": {
32+
"MBED_CONF_RTOS_PRESENT": "0",
33+
"MBED_CONF_TARGET_LSE_AVAILABLE": "0",
34+
"DEVICE_STDIO_MESSAGES": "0",
35+
"NDEBUG": "1",
36+
},
37+
},
38+
)
39+
40+
load("@com_github_mjbots_bazel_deps//tools/workspace:default.bzl",
41+
bazel_deps_add = "add_default_repositories")
42+
bazel_deps_add()
43+
44+
load("@com_github_mjbots_mjlib//tools/workspace:default.bzl",
45+
mjlib_add = "add_default_repositories")
46+
mjlib_add()

fw/BUILD

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# -*- python -*-
2+
3+
# Copyright 2018-2020 Josh Pieper, [email protected].
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
package(default_visibility = ["//visibility:public"])
18+
load("@com_github_ARMmbed_mbed-os//:rules.bzl", "mbed_binary")
19+
20+
COPTS = [
21+
"-Werror",
22+
"-Wdouble-promotion",
23+
]
24+
25+
cc_library(
26+
name = "git_info",
27+
hdrs = ["git_info.h"],
28+
srcs = ["git_info.cc"],
29+
linkstamp = "git_info_linkstamp.cc",
30+
deps = [
31+
"@com_github_mjbots_mjlib//mjlib/base:visitor",
32+
],
33+
copts = COPTS,
34+
)
35+
36+
mbed_binary(
37+
name = "power_dist",
38+
srcs = [
39+
"fdcan.cc",
40+
"fdcan.h",
41+
"millisecond_timer.h",
42+
"power_dist.cc",
43+
"power_dist_hw.h",
44+
],
45+
deps = [
46+
":git_info",
47+
"@com_github_mjbots_mjlib//mjlib/base:string_span",
48+
],
49+
copts = COPTS,
50+
)
51+
52+
OCD = (
53+
"openocd " +
54+
"-f interface/stlink.cfg " +
55+
"-f target/stm32g4x.cfg "
56+
)
57+
58+
genrule(
59+
name = "power_dist_flash",
60+
tags = ["manual"],
61+
srcs = ["power_dist.bin"],
62+
outs = ["power_dist.stamp"],
63+
cmd = (OCD + "-c init -c \"reset_config none separate; program $(location power_dist.bin) verify 0x8000000 reset exit 0x8000000\" && touch $@"),
64+
)

fw/BUILD~

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# -*- python -*-
2+
3+
# Copyright 2018-2020 Josh Pieper, [email protected].
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
package(default_visibility = ["//visibility:public"])
18+
load("@com_github_ARMmbed_mbed-g4//:rules.bzl", g4_mbed_binary = "mbed_binary")
19+
load("@com_github_ARMmbed_mbed-g4-bootloader//:rules.bzl", g4_bootloader_mbed_binary = "mbed_binary")
20+
21+
COPTS = [
22+
"-Werror",
23+
"-Wdouble-promotion",
24+
]
25+
26+
cc_library(
27+
name = "git_info",
28+
hdrs = ["git_info.h"],
29+
srcs = ["git_info.cc"],
30+
linkstamp = "git_info_linkstamp.cc",
31+
deps = [
32+
"@com_github_mjbots_mjlib//mjlib/base:visitor",
33+
],
34+
copts = COPTS,
35+
)
36+
37+
g4_bootloader_mbed_binary(
38+
name = "power_dist",
39+
srcs = [
40+
"fdcan.cc",
41+
"fdcan.h",
42+
"millisecond_timer.h",
43+
"power_dist.cc",
44+
"power_dist_hw.h",
45+
],
46+
deps = [
47+
":git_info",
48+
"@com_github_mjbots_mjlib//mjlib/base:string_span",
49+
],
50+
copts = COPTS,
51+
)
52+
53+
54+
genrule(
55+
name = "power_dist_flash",
56+
tags = ["manual"],
57+
srcs = ["power_dist.bin"],
58+
outs = ["power_dist.stamp"],
59+
cmd = (OCD_G4 + "-c init -c \"reset_config none separate; program $(location power_dist.bin) verify 0x8000000 reset exit 0x8000000\" && touch $@"),
60+
)

0 commit comments

Comments
 (0)