summaryrefslogtreecommitdiff
path: root/usb-i2c-sl018
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@wirdorange.org>2013-01-27 19:32:30 +0000
committerOthmar Gsenger <otti@wirdorange.org>2013-01-27 19:32:30 +0000
commita1972ccce9692f74e1a87129c3140ddf77bbe3dc (patch)
treee021e932887f436c075d395fedbf5cd666404588 /usb-i2c-sl018
parentminor clean up, improved error handling (diff)
improved error handling
git-svn-id: https://svn.spreadspace.org/avr/trunk@71 aa12f405-d877-488e-9caf-2d797e2a1cc7
Diffstat (limited to 'usb-i2c-sl018')
-rw-r--r--usb-i2c-sl018/tuer-rfid.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usb-i2c-sl018/tuer-rfid.c b/usb-i2c-sl018/tuer-rfid.c
index 2954231..f159047 100644
--- a/usb-i2c-sl018/tuer-rfid.c
+++ b/usb-i2c-sl018/tuer-rfid.c
@@ -129,7 +129,11 @@ unsigned char sl018_send_buffer(const unsigned char * buffer)
if (TWI_StartTransmission(SL018_ADDR | SL018_WRITE,10) == TWI_ERROR_NoError)
{
for(pos=0; pos<=len; pos++)
- TWI_SendByte(buffer[pos]);
+ if( ! TWI_SendByte(buffer[pos]))
+ {
+ TWI_StopTransmission();
+ return 1;
+ }
// Must stop transmission afterwards to release the bus
TWI_StopTransmission();
} else {
@@ -141,7 +145,11 @@ unsigned char sl018_send_buffer(const unsigned char * buffer)
TWI_ReceiveByte(&len, 0);
twi_rcv_buff[255]=len;
for(pos=0; pos<len; pos++)
- TWI_ReceiveByte(&twi_rcv_buff[pos], (pos == len-1) ? 1:0 );
+ if (! TWI_ReceiveByte(&twi_rcv_buff[pos], (pos == len-1) ? 1:0 ) )
+ {
+ TWI_StopTransmission();
+ return 1;
+ }
// Must stop transmission afterwards to release the bus
TWI_StopTransmission();
} else {