From db212811293f91e0f1147eb57e5f6d5df2db10ef Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 29 Nov 2010 23:07:46 +0100 Subject: digital/avr/modules/twi: cleanup TWI module, refs #29, closes #90 - use contexts - changed interface - merge test programs - share polling mechanism - prepare place for other drivers - add callback system - use english comments --- digital/io/src/twi_master.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'digital/io/src/twi_master.c') diff --git a/digital/io/src/twi_master.c b/digital/io/src/twi_master.c index 194e0fa4..cb600da8 100644 --- a/digital/io/src/twi_master.c +++ b/digital/io/src/twi_master.c @@ -111,10 +111,9 @@ twi_master_send_head (void) struct twi_master_command_t *c = &twi_master.pending[twi_master.pending_head]; /* Send command. */ - twi_ms_send (twi_master_slaves[c->slave].address, c->command, - c->length + 1); - while (!twi_ms_is_finished ()) - ; + twi_master_send (twi_master_slaves[c->slave].address, c->command, + c->length + 1); + twi_master_wait (); /* Reset retransmission counter. */ twi_master.retransmit_counter = TWI_MASTER_RETRANSMIT_INTERVAL; } @@ -126,10 +125,11 @@ twi_master_update_status (uint8_t slave, uint8_t init) { uint8_t buffer[TWI_MASTER_STATUS_PAYLOAD_MAX + 1]; /* Read status. */ - twi_ms_read (twi_master_slaves[slave].address, buffer, - twi_master_slaves[slave].status_length + 1); - while (!twi_ms_is_finished ()) - ; + twi_master_recv (twi_master_slaves[slave].address, buffer, + twi_master_slaves[slave].status_length + 1); + uint8_t ret = twi_master_wait (); + if (ret != twi_master_slaves[slave].status_length + 1) + return 0; uint8_t crc = crc_compute (buffer + 1, twi_master_slaves[slave].status_length); if (crc != buffer[0]) -- cgit v1.2.3