summaryrefslogtreecommitdiff
path: root/digital/ai/src/twi_master
diff options
context:
space:
mode:
authorNicolas Schodet2011-05-28 00:31:13 +0200
committerNicolas Schodet2011-05-29 09:57:32 +0200
commit4882fbefaeca9cc5292cec9a2f93d34f04e67b5c (patch)
tree30c592351bcccc7b3e1f95c8b1af4419be5fec46 /digital/ai/src/twi_master
parentfd8ce8373abf81f5d6781b577a0f50906f2f4ff8 (diff)
digital/io-hub: add clamp initialisation
Diffstat (limited to 'digital/ai/src/twi_master')
-rw-r--r--digital/ai/src/twi_master/mimot.c42
-rw-r--r--digital/ai/src/twi_master/mimot.h16
2 files changed, 58 insertions, 0 deletions
diff --git a/digital/ai/src/twi_master/mimot.c b/digital/ai/src/twi_master/mimot.c
index af6ff5f9..c3b82823 100644
--- a/digital/ai/src/twi_master/mimot.c
+++ b/digital/ai/src/twi_master/mimot.c
@@ -118,6 +118,30 @@ mimot_reset (void)
}
void
+mimot_set_motor0_position (uint16_t position)
+{
+ uint8_t *buffer = twi_master_get_buffer (MIMOT_SLAVE);
+ buffer[0] = 'p';
+ buffer[1] = 'Y';
+ buffer[2] = 0;
+ buffer[3] = v16_to_v8 (position, 1);
+ buffer[4] = v16_to_v8 (position, 0);
+ twi_master_send_buffer (5);
+}
+
+void
+mimot_set_motor1_position (uint16_t position)
+{
+ uint8_t *buffer = twi_master_get_buffer (MIMOT_SLAVE);
+ buffer[0] = 'p';
+ buffer[1] = 'Y';
+ buffer[2] = 1;
+ buffer[3] = v16_to_v8 (position, 1);
+ buffer[4] = v16_to_v8 (position, 0);
+ twi_master_send_buffer (5);
+}
+
+void
mimot_move_motor0_absolute (uint16_t position, uint8_t speed)
{
uint8_t *buffer = twi_master_get_buffer (MIMOT_SLAVE);
@@ -181,3 +205,21 @@ mimot_motor1_clamp (int8_t speed, int16_t pwm)
twi_master_send_buffer (5);
}
+void
+mimot_motor0_free (void)
+{
+ uint8_t *buffer = twi_master_get_buffer (MIMOT_SLAVE);
+ buffer[0] = 'w';
+ buffer[1] = 0;
+ twi_master_send_buffer (2);
+}
+
+void
+mimot_motor1_free (void)
+{
+ uint8_t *buffer = twi_master_get_buffer (MIMOT_SLAVE);
+ buffer[0] = 'w';
+ buffer[1] = 1;
+ twi_master_send_buffer (2);
+}
+
diff --git a/digital/ai/src/twi_master/mimot.h b/digital/ai/src/twi_master/mimot.h
index 60811c10..97575b0d 100644
--- a/digital/ai/src/twi_master/mimot.h
+++ b/digital/ai/src/twi_master/mimot.h
@@ -68,6 +68,14 @@ mimot_get_motor1_position (void);
void
mimot_reset (void);
+/** Set motor0 position in steps. */
+void
+mimot_set_motor0_position (uint16_t position);
+
+/** Set motor1 position in steps. */
+void
+mimot_set_motor1_position (uint16_t position);
+
/** Move motor0 to absolute position in steps. */
void
mimot_move_motor0_absolute (uint16_t position, uint8_t speed);
@@ -92,4 +100,12 @@ mimot_motor0_clamp (int8_t speed, int16_t pwm);
void
mimot_motor1_clamp (int8_t speed, int16_t pwm);
+/** Free motor0. */
+void
+mimot_motor0_free (void);
+
+/** Free motor1. */
+void
+mimot_motor1_free (void);
+
#endif /* mimot_h */