From 929dab13061cfe82cce6125dfb4adb40c3ef6639 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Wed, 18 Apr 2012 01:58:17 +0200 Subject: digital/{ai,mimot}: add raw output set --- digital/ai/src/twi_master/mimot.c | 11 +++++++++++ digital/ai/src/twi_master/mimot.h | 4 ++++ digital/mimot/src/dirty/twi_proto.c | 12 ++++++++++++ 3 files changed, 27 insertions(+) diff --git a/digital/ai/src/twi_master/mimot.c b/digital/ai/src/twi_master/mimot.c index cc66a280..6346f7b9 100644 --- a/digital/ai/src/twi_master/mimot.c +++ b/digital/ai/src/twi_master/mimot.c @@ -257,3 +257,14 @@ mimot_motor1_free (void) twi_master_send_buffer (2); } +void +mimot_motor_output_set (uint8_t motor, int16_t pwm) +{ + uint8_t *buffer = twi_master_get_buffer (MIMOT_SLAVE); + buffer[0] = 'W'; + buffer[1] = motor; + buffer[2] = v16_to_v8 (pwm, 1); + buffer[3] = v16_to_v8 (pwm, 0); + twi_master_send_buffer (4); +} + diff --git a/digital/ai/src/twi_master/mimot.h b/digital/ai/src/twi_master/mimot.h index 35b2dfbe..157ab4e1 100644 --- a/digital/ai/src/twi_master/mimot.h +++ b/digital/ai/src/twi_master/mimot.h @@ -122,4 +122,8 @@ mimot_motor0_free (void); void mimot_motor1_free (void); +/** Set raw output for motor. */ +void +mimot_motor_output_set (uint8_t motor, int16_t pwm); + #endif /* mimot_h */ diff --git a/digital/mimot/src/dirty/twi_proto.c b/digital/mimot/src/dirty/twi_proto.c index a61d3d6c..3ac4b8a4 100644 --- a/digital/mimot/src/dirty/twi_proto.c +++ b/digital/mimot/src/dirty/twi_proto.c @@ -167,6 +167,18 @@ twi_proto_callback (u8 *buf, u8 size) else buf[0] = 0; break; + case c ('W', 3): + /* Set motor output. + * - b: aux index. + * - w: value. */ + if (buf[2] < AC_ASSERV_AUX_NB) + { + output_set (&output_aux[buf[2]], v8_to_v16 (buf[3], buf[4])); + control_state_set_mode (&cs_aux[buf[2]].state, CS_MODE_NONE, 0); + } + else + buf[0] = 0; + break; case c ('p', x): /* Set parameters. */ if (twi_proto_params (&buf[2], size - 2) != 0) -- cgit v1.2.3