blob: 1ad056bd963a716f8a9853d531a955ac57a6e02c [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",
66 "//third_party/eigen",
67 ],
68)
Brian Silverman246cb222019-02-02 16:38:18 -080069
70cc_library(
71 name = "spi",
72 srcs = [
73 "spi.cc",
74 ],
75 hdrs = [
76 "spi.h",
77 ],
78 deps = [
79 ":spi_crc",
80 ":structures",
81 "//aos/util:bitpacking",
82 "//third_party/GSL",
83 "//third_party/optional",
84 ],
85)
86
Brian Silvermanbfbbe872019-02-10 18:00:57 -080087cc_library(
88 name = "uart",
89 srcs = [
90 "uart.cc",
91 ],
92 hdrs = [
93 "uart.h",
94 ],
95 deps = [
96 ":structures",
97 "//aos/containers:sized_array",
98 "//third_party/optional",
99 ],
100)
101
Brian Silverman246cb222019-02-02 16:38:18 -0800102cc_test(
103 name = "spi_test",
104 srcs = [
105 "spi_test.cc",
106 ],
107 deps = [
108 ":spi",
109 "//aos/testing:googletest",
110 ],
111)
Brian Silverman41709732019-02-09 20:53:08 -0800112
113cc_library(
114 name = "cobs",
115 hdrs = [
116 "cobs.h",
117 ],
118 deps = [
119 "//aos/logging",
120 "//third_party/GSL",
121 ],
122)
123
124cc_test(
125 name = "cobs_test",
126 srcs = [
127 "cobs_test.cc",
128 ],
129 deps = [
130 ":cobs",
131 "//aos/testing:googletest",
132 "//aos/testing:test_logging",
133 "//third_party/GSL",
134 ],
135)
Parker Schuh13696b32019-02-16 15:51:20 -0800136
137cc_library(
138 name = "serial",
Parker Schuh13696b32019-02-16 15:51:20 -0800139 srcs = ["serial.cc"],
Brian Silverman3240e102019-02-16 18:24:24 -0800140 hdrs = ["serial.h"],
Parker Schuh13696b32019-02-16 15:51:20 -0800141 deps = [
Brian Silverman3240e102019-02-16 18:24:24 -0800142 "//aos/logging",
Parker Schuh13696b32019-02-16 15:51:20 -0800143 ],
144)
Brian Silverman3240e102019-02-16 18:24:24 -0800145
146cc_binary(
147 name = "teensy.elf",
148 srcs = [
149 "teensy.cc",
150 ],
151 restricted_to = ["//tools:cortex-m4f"],
152 deps = [
153 "//aos/time:time_mcu",
154 "//motors:util",
155 "//motors/core",
156 "//motors/peripheral:configuration",
157 "//motors/peripheral:uart",
158 "//motors/print:usb",
159 ],
160)
161
162hex_from_elf(
163 name = "teensy",
164 restricted_to = ["//tools:cortex-m4f"],
165)