Code for the motor controller

This is basically what we used in Detroit.

Change-Id: If2820d7ec5fcbc5f33b4082025027a6e969ad0e1
diff --git a/motors/BUILD b/motors/BUILD
index e652069..e75f74b 100644
--- a/motors/BUILD
+++ b/motors/BUILD
@@ -8,7 +8,32 @@
   ],
   deps = [
     ':util',
+    ':motor',
+    ':motor_controls',
     '//motors/core',
+    '//motors/peripheral:can',
+    '//motors/peripheral:adc',
+    '//motors/usb:legacy',
+  ],
+  restricted_to = mcu_cpus,
+)
+
+cc_library(
+  name = 'motor',
+  hdrs = [
+    'motor.h',
+  ],
+  srcs = [
+    'motor.cc',
+  ],
+  deps = [
+    ':algorithms',
+    ':util',
+    '//motors/core',
+    '//motors/peripheral:configuration',
+
+    '//motors/peripheral:adc',
+    '//motors/peripheral:can',
     '//motors/usb:legacy',
   ],
   restricted_to = mcu_cpus,
@@ -25,5 +50,86 @@
   hdrs = [
     'util.h',
   ],
+  deps = [
+    '//motors/core',
+  ],
+  restricted_to = mcu_cpus,
+)
+
+genrule(
+  name = 'doc',
+  srcs = [
+    'NOTES.md',
+  ],
+  outs = [
+    'NOTES.html',
+  ],
+  cmd = ' '.join([
+    'pandoc',
+    '-f', 'markdown_github-hard_line_breaks',
+    '-t', 'html5',
+    '-o', '$@', '$<',
+  ]),
+)
+
+cc_library(
+  name = 'algorithms',
+  hdrs = [
+    'algorithms.h',
+  ],
+  srcs = [
+    'algorithms.cc',
+  ],
+  compatible_with = mcu_cpus,
+)
+
+cc_test(
+  name = 'algorithms_test',
+  srcs = [
+    'algorithms_test.cc',
+  ],
+  deps = [
+    ':algorithms',
+    '//aos/testing:googletest',
+  ],
+)
+
+cc_library(
+  name = 'math',
+  hdrs = [
+    'math.h',
+  ],
+  srcs = [
+    'math.cc',
+  ],
+  compatible_with = mcu_cpus,
+)
+
+cc_test(
+  name = 'math_test',
+  srcs = [
+    'math_test.cc',
+  ],
+  deps = [
+    ':math',
+    '//aos/testing:googletest',
+    '//third_party/googletest:googlemock',
+  ],
+)
+
+cc_library(
+  name = 'motor_controls',
+  hdrs = [
+    'motor_controls.h',
+  ],
+  srcs = [
+    'motor_controls.cc',
+  ],
+  deps = [
+    ':math',
+    ':motor',
+    '//motors/peripheral:configuration',
+    '//third_party/eigen',
+  ],
   restricted_to = mcu_cpus,
 )