+ return rspickle & I2C_COBBOARD_SPK_AUTOHARVEST;
+}
+
+static uint8_t state_spicklemode_nomove(uint8_t side)
+{
+ if (side == I2C_LEFT_SIDE)
+ return lspickle & I2C_COBBOARD_SPK_NO_MOVE;
+ else
+ return rspickle & I2C_COBBOARD_SPK_NO_MOVE;
+}
+
+/* pack/deploy spickles depending on mode */
+static void spickle_prepare(uint8_t side)
+{
+ /* we do nothing in mode no out */
+ if (state_spicklemode_nomove(side))
+ return;
+
+ if (state_spicklemode_deployed(side))
+ spickle_deploy(side);
+ else
+ spickle_pack(side);
+}
+
+void state_set_spickle(uint8_t side, uint8_t flags)
+{
+ if (side == I2C_LEFT_SIDE) {
+ /* the PACK command preempts the current action if the
+ * arm is not busy */
+ if (lspickle != 0 && flags == 0 &&
+ state_status != I2C_COBBOARD_STATUS_LBUSY)
+ spickle_prepare(I2C_LEFT_SIDE);
+ lspickle = flags;
+ }
+ else {
+ /* the PACK command preempts the current action if the
+ * arm is not busy */
+ if (rspickle != 0 && flags == 0 &&
+ state_status != I2C_COBBOARD_STATUS_RBUSY)
+ spickle_prepare(I2C_RIGHT_SIDE);
+ rspickle = flags;
+ }