blob: e4587b596213ba0a2d5dda42f85c0860e3cefe23 [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
86cc_test(
87 name = "spi_test",
88 srcs = [
89 "spi_test.cc",
90 ],
91 deps = [
92 ":spi",
93 "//aos/testing:googletest",
94 ],
95)
Brian Silverman41709732019-02-09 20:53:08 -080096
97cc_library(
98 name = "cobs",
99 hdrs = [
100 "cobs.h",
101 ],
102 deps = [
103 "//aos/logging",
104 "//third_party/GSL",
105 ],
106)
107
108cc_test(
109 name = "cobs_test",
110 srcs = [
111 "cobs_test.cc",
112 ],
113 deps = [
114 ":cobs",
115 "//aos/testing:googletest",
116 "//aos/testing:test_logging",
117 "//third_party/GSL",
118 ],
119)
Parker Schuh13696b32019-02-16 15:51:20 -0800120
121cc_library(
122 name = "serial",
123 hdrs = ["serial.h"],
124 srcs = ["serial.cc"],
125 deps = [
126 "//aos/logging:logging",
127 ],
128)