diff --git a/eda/controller.brd b/eda/controller.brd
index cb27359b..b7aa4e8c 100644
--- a/eda/controller.brd
+++ b/eda/controller.brd
@@ -664,87 +664,105 @@ This is the mechanical footprint for a #4 phillips button head screw. Use the ke
-
-
-
-
-
-
-
-
-
->NAME
->VALUE
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+>NAME
+>VALUE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<b>8-pin SOIC</b>
@@ -2420,21 +2438,17 @@ design rules under a new name.
-
+
-
-
+
-
-
+
-
-
+
-
@@ -3003,16 +3017,24 @@ design rules under a new name.
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -4474,29 +4496,31 @@ design rules under a new name.
-
+
+
+
-
+
-
+
-
+
-
-
-
-
+
+
-
-
-
-
-
+
+
+
+
+
+
+
@@ -4504,20 +4528,25 @@ design rules under a new name.
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -4525,20 +4554,24 @@ design rules under a new name.
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
@@ -4546,20 +4579,25 @@ design rules under a new name.
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -4567,23 +4605,27 @@ design rules under a new name.
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
+
+
@@ -4592,22 +4634,25 @@ design rules under a new name.
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
@@ -4616,23 +4661,27 @@ design rules under a new name.
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
+
@@ -4640,23 +4689,25 @@ design rules under a new name.
-
-
+
+
+
+
-
-
-
-
+
+
+
+
@@ -4664,9 +4715,12 @@ design rules under a new name.
-
-
+
+
+
+
+
@@ -4850,12 +4904,12 @@ design rules under a new name.
-
+
-
+
diff --git a/eda/controller.sch b/eda/controller.sch
index 1a290da4..2fc9aea6 100644
--- a/eda/controller.sch
+++ b/eda/controller.sch
@@ -559,87 +559,105 @@ This is the mechanical footprint for a #4 phillips button head screw. Use the ke
-
-
-
-
-
-
-
-
-
->NAME
->VALUE
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+>NAME
+>VALUE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<b>8-pin SOIC</b>
@@ -3237,28 +3255,6 @@ chip
-
-
-
-
-
-
-
-
-
-
->NAME
-
-
-
-
-
-
-
-
->VALUE
-
-
XBee Footprint
@@ -3728,6 +3724,32 @@ This is the mechanical footprint for a #4 phillips button head screw. Use the ke
+
+
+
+
+
+
+
+
+
+
+>NAME
+
+
+
+
+
+
+
+
+>VALUE
+
+
+
+
+
+
@@ -4040,19 +4062,21 @@ This is the mechanical footprint for a #4 phillips button head screw. Use the ke
>VALUE
-
-
-
+
+
+
-
+
>NAME
->VALUE
+>VALUE
+
+
@@ -5862,14 +5886,15 @@ This is the mechanical footprint for a #4 phillips button head screw. Use the ke
-
+
-
+
-
+
+
@@ -5877,16 +5902,16 @@ This is the mechanical footprint for a #4 phillips button head screw. Use the ke
+
-
-
-
+
-
+
+
@@ -5894,11 +5919,10 @@ This is the mechanical footprint for a #4 phillips button head screw. Use the ke
+
-
-
-
+
@@ -6377,10 +6401,10 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
-
-
-
+
+
+
+
@@ -7466,11 +7490,11 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
-
-
-
-
+
+
+
+
+
@@ -7552,38 +7576,69 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -7623,38 +7678,37 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
+
+
+
-
-
-
-
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -7669,16 +7723,16 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
-
-
+
+
+
-
-
-
+
+
+
@@ -7703,16 +7757,16 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
-
-
+
+
+
-
-
-
+
+
+
@@ -7737,16 +7791,16 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
-
-
+
+
+
-
-
-
+
+
+
@@ -7771,16 +7825,16 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
-
-
+
+
+
-
-
-
+
+
+
@@ -7829,9 +7883,9 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
+
-
+
@@ -7856,16 +7910,16 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
+
-
+
-
+
-
+
@@ -7890,16 +7944,16 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
+
-
+
-
+
-
+
@@ -7924,9 +7978,9 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
+
-
+
diff --git a/eda/grizzly_bear.brd b/eda/grizzly_bear.brd
index 5dd715da..9be5dadd 100644
--- a/eda/grizzly_bear.brd
+++ b/eda/grizzly_bear.brd
@@ -1372,87 +1372,105 @@ Vertical
-
-
-
-
-
-
-
-
-
->NAME
->VALUE
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+>NAME
+>VALUE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1678,8 +1696,8 @@ design rules under a new name.
-
-
+
+
@@ -1776,14 +1794,14 @@ design rules under a new name.
-
-
-
-
+
+
+
+
-
-
+
+
@@ -1906,10 +1924,10 @@ design rules under a new name.
-
-
-
-
+
+
+
+
@@ -1919,18 +1937,18 @@ design rules under a new name.
-
-
-
+
+
+
-
-
-
+
+
+
-
-
-
-
+
+
+
+
@@ -2041,7 +2059,6 @@ design rules under a new name.
-
@@ -2059,8 +2076,9 @@ design rules under a new name.
-
+
+
@@ -2269,11 +2287,7 @@ design rules under a new name.
-
-
-
-
-
+
@@ -2292,8 +2306,7 @@ design rules under a new name.
-
-
+
@@ -2305,18 +2318,22 @@ design rules under a new name.
-
-
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2666,10 +2683,12 @@ design rules under a new name.
-
-
-
+
+
+
+
+
@@ -2863,7 +2882,7 @@ design rules under a new name.
-
+
@@ -2885,7 +2904,7 @@ design rules under a new name.
-
+
@@ -2894,31 +2913,29 @@ design rules under a new name.
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -3085,13 +3102,14 @@ design rules under a new name.
-
+
-
-
+
+
+
@@ -3105,7 +3123,7 @@ design rules under a new name.
-
+
@@ -3120,24 +3138,30 @@ design rules under a new name.
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -3145,13 +3169,12 @@ design rules under a new name.
-
-
-
-
+
+
+
@@ -3161,58 +3184,58 @@ design rules under a new name.
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/eda/grizzly_bear.sch b/eda/grizzly_bear.sch
index 26b98231..54db29c9 100644
--- a/eda/grizzly_bear.sch
+++ b/eda/grizzly_bear.sch
@@ -6,7 +6,7 @@
-
+
@@ -821,87 +821,105 @@ Vertical
-
-
-
-
-
-
-
-
-
->NAME
->VALUE
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+>NAME
+>VALUE
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -4007,27 +4025,31 @@ This is the "EZ" version, which has limited top masking for improved ease of ass
-
-
-
-
-
-
-
-
-
-
->NAME
-
-
-
-
-
-
-
-
->VALUE
-
+
+
+
+
+
+
+
+
+
+
+>NAME
+
+
+
+
+
+
+
+
+>VALUE
+
+
+
+
+
@@ -4532,19 +4554,21 @@ This is the "EZ" version, which has limited top masking for improved ease of ass
>NAME
>VALUE
-
-
-
+
+
+
-
+
>NAME
->VALUE
+>VALUE
+
+
@@ -6535,14 +6559,15 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
+
-
+
-
+
+
@@ -6550,16 +6575,16 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
+
-
-
-
+
-
+
+
@@ -6567,11 +6592,10 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
+
-
-
-
+
@@ -6680,7 +6704,7 @@ http://www.alliedelec.com/images/products/datasheets/bm/ANDERSON_POWER_PRODUCTS/
-
+
@@ -7229,16 +7253,6 @@ for future additions.
-
-
-
-
-
-
-
-
-
-
@@ -7647,7 +7661,7 @@ for future additions.
-
+
@@ -7659,7 +7673,7 @@ for future additions.
-
+
@@ -7671,7 +7685,7 @@ for future additions.
-
+
@@ -7723,9 +7737,9 @@ for future additions.
-
-
-
+
+
+
@@ -7735,9 +7749,9 @@ for future additions.
-
-
-
+
+
+
@@ -7747,9 +7761,9 @@ for future additions.
-
-
-
+
+
+
@@ -7759,14 +7773,10 @@ for future additions.
-
-
-
-
-
+
@@ -7987,6 +7997,20 @@ for future additions.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -8019,9 +8043,21 @@ for future additions.
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/smartsensor_fw/deploy/ss_type.py b/smartsensor_fw/deploy/ss_type.py
index d355fdf5..0e23e5b4 100644
--- a/smartsensor_fw/deploy/ss_type.py
+++ b/smartsensor_fw/deploy/ss_type.py
@@ -23,8 +23,8 @@
},
"analog-in": {
- "description": "This is a digital sensor. It can be used to get the " + \
- "state of up to four switches.",
+ "description": "This is a analog sensor. It can be used to get the " + \
+ "state of up to four inputs.",
"chunksNumer": 0xFF,
"chunksDenom": 0xFF,
"channels": [
@@ -104,7 +104,50 @@
"additional": array('B', [0x01, 0xFF, 0xFF])
},
]
- }
+ },
+
+ "solenoid": {
+ "description": "This is a solenoid. It can be used to control " + \
+ "up to four solenoids.",
+ "chunksNumer": 0xFF, # TODO(cduck): What is this?
+ "chunksDenom": 0xFF,
+ "channels": [
+ gameModeChannel,
+ { "description": "This is the first digital channel.",
+ "type": 0x04,
+ "additional": array('B', [0x01, 0xFF, 0xFF])
+ },
+ { "description": "This is the second digital channel.",
+ "type": 0x04,
+ "additional": array('B', [0x01, 0xFF, 0xFF])
+ },
+ { "description": "This is the third digital channel.",
+ "type": 0x04,
+ "additional": array('B', [0x01, 0xFF, 0xFF])
+ },
+ { "description": "This is the fourth digital channel.",
+ "type": 0x04,
+ "additional": array('B', [0x01, 0xFF, 0xFF])
+ },
+ ]
+ },
+ "servo": {
+ "description": "This is a servo. It can be used to control " + \
+ "up to two servos.",
+ "chunksNumer": 0xFF,
+ "chunksDenom": 0xFF,
+ "channels": [
+ gameModeChannel,
+ { "description": "This is the first analog channel.",
+ "type" : 0x03,
+ "additional": array('B', [0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x01])
+ },
+ { "description": "This is the second analog channel.",
+ "type" : 0x03,
+ "additional": array('B', [0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x01])
+ }
+ ]
+ },
}
def allTypes():
diff --git a/smartsensor_fw/inc/servo.h b/smartsensor_fw/inc/servo.h
new file mode 100644
index 00000000..9684bc65
--- /dev/null
+++ b/smartsensor_fw/inc/servo.h
@@ -0,0 +1,28 @@
+// Licensed to Pioneers in Engineering under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. Pioneers in Engineering licenses
+// this file to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License
+
+#ifndef INC_SERVO_H_
+#define INC_SERVO_H_
+
+#include "inc/smartsensor/common.h"
+
+// Public functions called from main.c
+void initServo();
+void activeServoRec(uint8_t *data, uint8_t len, uint8_t inband);
+void activeServoSend(uint8_t *outData, uint8_t *outLen, uint8_t *inband);
+
+#endif // INC_SERVO_H_
diff --git a/smartsensor_fw/inc/smartsensor/common.h b/smartsensor_fw/inc/smartsensor/common.h
index a62a473d..4e40d7b9 100644
--- a/smartsensor_fw/inc/smartsensor/common.h
+++ b/smartsensor_fw/inc/smartsensor/common.h
@@ -30,6 +30,8 @@
// Sensor types
#define SENSOR_TYPE_DIGITAL 0x00
#define SENSOR_TYPE_ANALOG_IN 0x01
+#define SENSOR_TYPE_SERVO 0x03
+#define SENSOR_TYPE_SOLENOID 0x04
#define SENSOR_TYPE_GRIZZLY3 0x80
#define SENSOR_TYPE_BUZZER 0x81
#define SENSOR_TYPE_FLAG 0x82
diff --git a/smartsensor_fw/inc/solenoid.h b/smartsensor_fw/inc/solenoid.h
new file mode 100644
index 00000000..2db924e6
--- /dev/null
+++ b/smartsensor_fw/inc/solenoid.h
@@ -0,0 +1,28 @@
+// Licensed to Pioneers in Engineering under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. Pioneers in Engineering licenses
+// this file to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License
+
+#ifndef INC_SOLENOID_H_
+#define INC_SOLENOID_H_
+
+#include "inc/smartsensor/common.h"
+
+// Public functions called from main.c
+void initSolenoid();
+void activeSolenoidRec(uint8_t *data, uint8_t len, uint8_t inband);
+void activeSolenoidSend(uint8_t *outData, uint8_t *outLen, uint8_t *inband);
+
+#endif // INC_SOLENOID_H_
diff --git a/smartsensor_fw/src/servo.c b/smartsensor_fw/src/servo.c
new file mode 100644
index 00000000..c8af893a
--- /dev/null
+++ b/smartsensor_fw/src/servo.c
@@ -0,0 +1,104 @@
+// Licensed to Pioneers in Engineering under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. Pioneers in Engineering licenses
+// this file to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License
+
+// This file has battery buzzer related functions
+
+#include "inc/servo.h"
+#include
+#include
+
+static uint8_t AL1 = 0x01;
+static uint8_t AH1 = 0x00;
+static uint8_t BL1 = 0x01;
+static uint8_t BH1 = 0x00;
+
+
+
+// Timer 1 interrupt
+ISR(TIMER1_OVF_vect) {
+
+ // Create a counter in order to only send a pulse every 12 timer interrupts.
+ static unsigned char counter = 0;
+
+ // On the 12th timer interrupt run this to create a pulse
+ if (counter == 0) {
+
+ // Set timer 1 to phase and freq correct pwm mode
+ TCCR1A = (1 << COM1A1) | (1 << COM1A0) | (1 << COM1B1) | (1<< COM1B0);
+ TCCR1B = (1 << CS10) | (1 << WGM13);
+
+ // update the values in these registers to set the pulse length
+ OCR1AH = AH1;
+ OCR1AL = AL1;
+ OCR1BH = BH1;
+ OCR1BL = BL1;
+
+ counter++;
+
+ // Run this after the 12th interrupt to stop the PWM generator from creating a second pulse
+ } else if (counter == 1) {
+
+ // Set timer 1 to output disconnected mode
+ TCCR1A = (1 << WGM11);
+ TCCR1B = (1 << CS10) | (1 << WGM12) | (1 << WGM13);
+ counter++;
+ } else if (counter == 11) {
+ // Reset the counter at 11
+ counter = 0;
+ } else {
+ counter++;
+ }
+}
+
+// Private helper functions
+
+// Public functions called from main.c
+void initServo() {
+ // Set the PWM pins to output
+ DIGITAL_SET_OUT(IN1);
+ DIGITAL_SET_OUT(IN3);
+
+ // Initiate timer 1
+ TCCR1A = 0;
+ TCCR1B = (1 << CS10) | (1 << WGM13);
+
+ // Define the top value of timer 1
+ ICR1H = 0x25;
+ ICR1L = 0x40;
+
+ // Enable timer 1 overflow interrupt
+ TIMSK = (1 << TOIE1);
+
+ // Enable interrupts
+ sei();
+
+}
+
+void activeServoRec(uint8_t *data, uint8_t len, uint8_t inband) {
+ if (len > 1){
+ AL1 = data[0];
+ AH1 = data[1];
+ }
+ if (len > 3){
+ BL1 = data[2];
+ BH1 = data[3];
+ }
+}
+void activeServoSend(uint8_t *outData, uint8_t *outLen, uint8_t *inband) {
+ // TODO(cduck): Write this function
+ *outlen = 0;
+}
diff --git a/smartsensor_fw/src/solenoid.c b/smartsensor_fw/src/solenoid.c
new file mode 100644
index 00000000..5cec0567
--- /dev/null
+++ b/smartsensor_fw/src/solenoid.c
@@ -0,0 +1,70 @@
+// Licensed to Pioneers in Engineering under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. Pioneers in Engineering licenses
+// this file to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License
+
+// This file has digital io smart sensor related functions
+
+#include "inc/solenoid.h"
+
+// Private global variables
+uint8_t outValueSolenoid = 0;
+
+// Private helper functions
+void SolenoidSetValue(uint8_t val);
+
+
+// Public functions called from main.c
+void initSolenoid() {
+ DIGITAL_SET_LOW(IN0);
+ DIGITAL_SET_LOW(IN1);
+ DIGITAL_SET_LOW(IN2);
+ DIGITAL_SET_LOW(IN3);
+
+ // TODO(tobinsarah): allow configuration as input/output for each relevant pin
+ DIGITAL_SET_OUT(IN0);
+ DIGITAL_SET_OUT(IN1);
+ DIGITAL_SET_OUT(IN2);
+ DIGITAL_SET_OUT(IN3);
+}
+void activeSolenoidRec(uint8_t *data, uint8_t len, uint8_t inband) {
+ if (len >= 1) {
+ outValueSolenoid = data[0];
+ }
+ switch (gameMode) {
+ case MODE_ACTIVE: SolenoidSetValue(outValueSolenoid);
+ break;
+ case MODE_DISABLED: SolenoidSetValue(0);
+ break;
+ case MODE_PAUSED: SolenoidSetValue(0); // Don't update outputs
+ default: break;
+ }
+}
+void activeSolenoidSend(uint8_t *outData, uint8_t *outLen, uint8_t *inband) {
+*outLen = 0;
+}
+
+
+
+
+
+// Private helper functions
+// TODO(karthik-shanmugam): update pins
+void SolenoidSetValue(uint8_t val) {
+ DIGITAL_SET(IN0, val & 1); // UPDATE IN0
+ DIGITAL_SET(IN1, val & 2); // UPDATE IN1
+ DIGITAL_SET(IN2, val & 4); // UPDATE IN2
+ DIGITAL_SET(IN3, val & 8); // UPDATE IN3
+}
diff --git a/smartsensor_fw/src/ss_type.c b/smartsensor_fw/src/ss_type.c
index c4bfc2b8..3116e72d 100644
--- a/smartsensor_fw/src/ss_type.c
+++ b/smartsensor_fw/src/ss_type.c
@@ -22,6 +22,7 @@
#include "inc/analog_in.h"
#include "inc/buzzer.h"
#include "inc/flag.h"
+#include "inc/servo.h"
void ssInitType() {
switch (SENSOR_TYPE) {
@@ -37,6 +38,9 @@ void ssInitType() {
case SENSOR_TYPE_FLAG:
initFlag();
break;
+ case SENSOR_TYPE_SERVO:
+ initServo();
+ break;
default: break;
// TODO(cduck): Add more smart sensors types
}
@@ -56,6 +60,9 @@ void ssActiveSend(uint8_t *decodedBuffer, uint8_t *pacLen, uint8_t *inband) {
case SENSOR_TYPE_FLAG:
activeFlagSend(decodedBuffer, pacLen, inband);
break;
+ case SENSOR_TYPE_SERVO:
+ activeServoSend(decodedBuffer, pacLen, inband);
+ break;
default: break;
// TODO(cduck): Add more smart sensors types
}
@@ -75,6 +82,9 @@ void ssActiveInRec(uint8_t *decodedBuffer, uint8_t dataLen, uint8_t inband) {
case SENSOR_TYPE_FLAG:
activeFlagRec(decodedBuffer, dataLen, inband);
break;
+ case SENSOR_TYPE_SERVO:
+ activeServoRec(decodedBuffer, dataLen, inband);
+ break;
default: break;
// TODO(cduck): Add more smart sensors types
}