From 2f31f222f2d6e4bd7c3962cbaea9c061d0339c0d Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Fri, 11 May 2012 00:45:08 +0200 Subject: digital/ai/src/twi_master: add transient mode for short lived commands --- digital/ai/src/twi_master/twi_master.c | 16 ++++++++++++++++ digital/ai/src/twi_master/twi_master.h | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/digital/ai/src/twi_master/twi_master.c b/digital/ai/src/twi_master/twi_master.c index 65acdce2..d9cc9ac5 100644 --- a/digital/ai/src/twi_master/twi_master.c +++ b/digital/ai/src/twi_master/twi_master.c @@ -232,3 +232,19 @@ twi_master_send_buffer (uint8_t length) twi_master_send_head (); } +void +twi_master_send_transient_buffer (uint8_t length) +{ + assert (length != 0); + struct twi_master_command_t *c = + &twi_master.pending[TWI_MASTER_PENDING_TAIL]; + /* Fill sequence number, compute CRC, store length. */ + c->command[1] = ++twi_master_slaves[c->slave].seq; + c->command[0] = crc_compute (&c->command[1], length + 1); + c->length = length + 1; + /* Send right now without acknowledgement. */ + twi_master_send (twi_master_slaves[c->slave].address, c->command, + c->length + 1); + twi_master_wait (); +} + diff --git a/digital/ai/src/twi_master/twi_master.h b/digital/ai/src/twi_master/twi_master.h index 4908f471..f2f8dff7 100644 --- a/digital/ai/src/twi_master/twi_master.h +++ b/digital/ai/src/twi_master/twi_master.h @@ -88,4 +88,9 @@ twi_master_get_buffer (uint8_t slave); void twi_master_send_buffer (uint8_t length); +/** Send previously got buffer without acknowledgement, can not be mixed with + * twi_master_send_buffer for a same slave! */ +void +twi_master_send_transient_buffer (uint8_t length); + #endif /* twi_master_h */ -- cgit v1.2.3