blob: 99e3be88a054a0956668c459ecd9eea7ea31b6f4 [file] [log] [blame]
Parker Schuh13696b32019-02-16 15:51:20 -08001package(default_visibility = ["//visibility:public"])
2
Brian Silverman246cb222019-02-02 16:38:18 -08003spi_crc_args = [
4 "$(location //third_party/pycrc:pycrc_main)",
5 "--width=16",
6 # This is the recommendation from
7 # http://users.ece.cmu.edu/~koopman/roses/dsn04/koopman04_crc_poly_embedded.pdf
8 # for messages of 242 - 2048 bits, which covers what we want.
9 # That's an analysis from an exhaustive search of all polynomials for
10 # various CRCs to find the best ones. This is 0xBAAD, converted from the
11 # weird format used there to the standard one used by pycrc.
12 "--poly=0x755b",
13 "--reflect-in=False",
14 "--xor-in=0xffff",
15 "--reflect-out=False",
16 "--xor-out=0xffff",
17 "--std=C99",
18 "--algorithm=table-driven",
19 "--symbol-prefix=jevois_spi_crc_",
20 "--crc-type=uint16_t",
21]
22
23genrule(
24 name = "gen_spi_crc",
25 outs = [
26 "spi_crc.h",
27 "spi_crc.c",
28 ],
29 cmd = " && ".join([
30 " ".join(spi_crc_args + [
31 "--generate=h",
32 "--output=$(location spi_crc.h)",
33 ]),
34 " ".join(spi_crc_args + [
35 "--generate=c",
36 "--output=$(location spi_crc.c)",
37 ]),
38 ]),
39 tools = [
40 "//third_party/pycrc:pycrc_main",
41 ],
42)
43
44cc_library(
45 name = "spi_crc",
46 srcs = [
47 "spi_crc.c",
48 ],
49 hdrs = [
50 "spi_crc.h",
51 ],
52 deps = [
53 "//third_party/GSL",
54 ],
55)
56
Brian Silverman1c0612e2019-01-26 17:26:08 -080057cc_library(
58 name = "structures",
59 hdrs = [
60 "structures.h",
61 ],
62 visibility = ["//visibility:public"],
63 deps = [
64 "//aos/containers:sized_array",
65 "//third_party/eigen",
66 ],
67)
Brian Silverman246cb222019-02-02 16:38:18 -080068
69cc_library(
70 name = "spi",
71 srcs = [
72 "spi.cc",
73 ],
74 hdrs = [
75 "spi.h",
76 ],
77 deps = [
78 ":spi_crc",
79 ":structures",
80 "//aos/util:bitpacking",
81 "//third_party/GSL",
82 "//third_party/optional",
83 ],
84)
85
Brian Silvermanbfbbe872019-02-10 18:00:57 -080086cc_library(
87 name = "uart",
88 srcs = [
89 "uart.cc",
90 ],
91 hdrs = [
92 "uart.h",
93 ],
94 deps = [
95 ":structures",
96 "//aos/containers:sized_array",
97 "//third_party/optional",
98 ],
99)
100
Brian Silverman246cb222019-02-02 16:38:18 -0800101cc_test(
102 name = "spi_test",
103 srcs = [
104 "spi_test.cc",
105 ],
106 deps = [
107 ":spi",
108 "//aos/testing:googletest",
109 ],
110)
Brian Silverman41709732019-02-09 20:53:08 -0800111
112cc_library(
113 name = "cobs",
114 hdrs = [
115 "cobs.h",
116 ],
117 deps = [
118 "//aos/logging",
119 "//third_party/GSL",
120 ],
121)
122
123cc_test(
124 name = "cobs_test",
125 srcs = [
126 "cobs_test.cc",
127 ],
128 deps = [
129 ":cobs",
130 "//aos/testing:googletest",
131 "//aos/testing:test_logging",
132 "//third_party/GSL",
133 ],
134)
Parker Schuh13696b32019-02-16 15:51:20 -0800135
136cc_library(
137 name = "serial",
138 hdrs = ["serial.h"],
139 srcs = ["serial.cc"],
140 deps = [
141 "//aos/logging:logging",
142 ],
143)