blob: 7d26c1eea2089ad4dd739d5faa584a531188c532 [file] [log] [blame]
Brian Silverman3240e102019-02-16 18:24:24 -08001load("//tools:environments.bzl", "mcu_cpus")
2load("//motors:macros.bzl", "hex_from_elf")
Parker Schuh13696b32019-02-16 15:51:20 -08003
Brian Silverman0a5e7db2019-02-17 13:45:27 -08004jevois_crc_args = [
Brian Silverman246cb222019-02-02 16:38:18 -08005 "$(location //third_party/pycrc:pycrc_main)",
6 "--width=16",
7 # This is the recommendation from
8 # http://users.ece.cmu.edu/~koopman/roses/dsn04/koopman04_crc_poly_embedded.pdf
9 # for messages of 242 - 2048 bits, which covers what we want.
10 # That's an analysis from an exhaustive search of all polynomials for
11 # various CRCs to find the best ones. This is 0xBAAD, converted from the
12 # weird format used there to the standard one used by pycrc.
13 "--poly=0x755b",
14 "--reflect-in=False",
15 "--xor-in=0xffff",
16 "--reflect-out=False",
17 "--xor-out=0xffff",
18 "--std=C99",
19 "--algorithm=table-driven",
Brian Silverman0a5e7db2019-02-17 13:45:27 -080020 "--symbol-prefix=jevois_crc_",
Brian Silverman246cb222019-02-02 16:38:18 -080021 "--crc-type=uint16_t",
22]
23
24genrule(
Brian Silverman0a5e7db2019-02-17 13:45:27 -080025 name = "gen_jevois_crc",
Brian Silverman246cb222019-02-02 16:38:18 -080026 outs = [
Brian Silverman0a5e7db2019-02-17 13:45:27 -080027 "jevois_crc.h",
28 "jevois_crc.c",
Brian Silverman246cb222019-02-02 16:38:18 -080029 ],
30 cmd = " && ".join([
Brian Silverman0a5e7db2019-02-17 13:45:27 -080031 " ".join(jevois_crc_args + [
Brian Silverman246cb222019-02-02 16:38:18 -080032 "--generate=h",
Brian Silverman0a5e7db2019-02-17 13:45:27 -080033 "--output=$(location jevois_crc.h)",
Brian Silverman246cb222019-02-02 16:38:18 -080034 ]),
Brian Silverman0a5e7db2019-02-17 13:45:27 -080035 " ".join(jevois_crc_args + [
Brian Silverman246cb222019-02-02 16:38:18 -080036 "--generate=c",
Brian Silverman0a5e7db2019-02-17 13:45:27 -080037 "--output=$(location jevois_crc.c)",
Brian Silverman246cb222019-02-02 16:38:18 -080038 ]),
39 ]),
40 tools = [
41 "//third_party/pycrc:pycrc_main",
42 ],
43)
44
45cc_library(
Brian Silverman0a5e7db2019-02-17 13:45:27 -080046 name = "jevois_crc",
Brian Silverman246cb222019-02-02 16:38:18 -080047 srcs = [
Brian Silverman0a5e7db2019-02-17 13:45:27 -080048 "jevois_crc.c",
Brian Silverman246cb222019-02-02 16:38:18 -080049 ],
50 hdrs = [
Brian Silverman0a5e7db2019-02-17 13:45:27 -080051 "jevois_crc.h",
Brian Silverman246cb222019-02-02 16:38:18 -080052 ],
53 deps = [
54 "//third_party/GSL",
55 ],
56)
57
Brian Silverman1c0612e2019-01-26 17:26:08 -080058cc_library(
59 name = "structures",
60 hdrs = [
61 "structures.h",
62 ],
63 visibility = ["//visibility:public"],
64 deps = [
65 "//aos/containers:sized_array",
Brian Silvermana3688802019-02-16 19:31:26 -080066 "//aos/time",
Brian Silverman1c0612e2019-01-26 17:26:08 -080067 "//third_party/eigen",
68 ],
69)
Brian Silverman246cb222019-02-02 16:38:18 -080070
71cc_library(
72 name = "spi",
73 srcs = [
74 "spi.cc",
75 ],
76 hdrs = [
77 "spi.h",
78 ],
79 deps = [
Brian Silverman0a5e7db2019-02-17 13:45:27 -080080 ":jevois_crc",
Brian Silverman246cb222019-02-02 16:38:18 -080081 ":structures",
82 "//aos/util:bitpacking",
83 "//third_party/GSL",
84 "//third_party/optional",
85 ],
86)
87
Brian Silvermanbfbbe872019-02-10 18:00:57 -080088cc_library(
89 name = "uart",
90 srcs = [
91 "uart.cc",
92 ],
93 hdrs = [
94 "uart.h",
95 ],
96 deps = [
97 ":structures",
98 "//aos/containers:sized_array",
99 "//third_party/optional",
100 ],
101)
102
Brian Silverman246cb222019-02-02 16:38:18 -0800103cc_test(
104 name = "spi_test",
105 srcs = [
106 "spi_test.cc",
107 ],
108 deps = [
109 ":spi",
110 "//aos/testing:googletest",
111 ],
112)
Brian Silverman41709732019-02-09 20:53:08 -0800113
114cc_library(
115 name = "cobs",
116 hdrs = [
117 "cobs.h",
118 ],
119 deps = [
120 "//aos/logging",
121 "//third_party/GSL",
122 ],
123)
124
125cc_test(
126 name = "cobs_test",
127 srcs = [
128 "cobs_test.cc",
129 ],
130 deps = [
131 ":cobs",
132 "//aos/testing:googletest",
133 "//aos/testing:test_logging",
134 "//third_party/GSL",
135 ],
136)
Parker Schuh13696b32019-02-16 15:51:20 -0800137
138cc_library(
139 name = "serial",
Parker Schuh13696b32019-02-16 15:51:20 -0800140 srcs = ["serial.cc"],
Brian Silverman3240e102019-02-16 18:24:24 -0800141 hdrs = ["serial.h"],
Parker Schuh7c42f0d2019-02-17 14:02:33 -0800142 visibility = ["//visibility:public"],
Parker Schuh13696b32019-02-16 15:51:20 -0800143 deps = [
Brian Silverman3240e102019-02-16 18:24:24 -0800144 "//aos/logging",
Parker Schuh13696b32019-02-16 15:51:20 -0800145 ],
146)
Brian Silverman3240e102019-02-16 18:24:24 -0800147
148cc_binary(
149 name = "teensy.elf",
150 srcs = [
151 "teensy.cc",
152 ],
153 restricted_to = ["//tools:cortex-m4f"],
154 deps = [
155 "//aos/time:time_mcu",
156 "//motors:util",
157 "//motors/core",
158 "//motors/peripheral:configuration",
159 "//motors/peripheral:uart",
160 "//motors/print:usb",
161 ],
162)
163
164hex_from_elf(
165 name = "teensy",
166 restricted_to = ["//tools:cortex-m4f"],
167)