blob: fde8c1214324c3058e4961c5582ecf7bf0911083 [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 Silverman246cb222019-02-02 16:38:18 -08004spi_crc_args = [
5 "$(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",
20 "--symbol-prefix=jevois_spi_crc_",
21 "--crc-type=uint16_t",
22]
23
24genrule(
25 name = "gen_spi_crc",
26 outs = [
27 "spi_crc.h",
28 "spi_crc.c",
29 ],
30 cmd = " && ".join([
31 " ".join(spi_crc_args + [
32 "--generate=h",
33 "--output=$(location spi_crc.h)",
34 ]),
35 " ".join(spi_crc_args + [
36 "--generate=c",
37 "--output=$(location spi_crc.c)",
38 ]),
39 ]),
40 tools = [
41 "//third_party/pycrc:pycrc_main",
42 ],
43)
44
45cc_library(
46 name = "spi_crc",
47 srcs = [
48 "spi_crc.c",
49 ],
50 hdrs = [
51 "spi_crc.h",
52 ],
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 = [
80 ":spi_crc",
81 ":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 Schuh13696b32019-02-16 15:51:20 -0800142 deps = [
Brian Silverman3240e102019-02-16 18:24:24 -0800143 "//aos/logging",
Parker Schuh13696b32019-02-16 15:51:20 -0800144 ],
145)
Brian Silverman3240e102019-02-16 18:24:24 -0800146
147cc_binary(
148 name = "teensy.elf",
149 srcs = [
150 "teensy.cc",
151 ],
152 restricted_to = ["//tools:cortex-m4f"],
153 deps = [
154 "//aos/time:time_mcu",
155 "//motors:util",
156 "//motors/core",
157 "//motors/peripheral:configuration",
158 "//motors/peripheral:uart",
159 "//motors/print:usb",
160 ],
161)
162
163hex_from_elf(
164 name = "teensy",
165 restricted_to = ["//tools:cortex-m4f"],
166)