summaryrefslogtreecommitdiff
path: root/n/avr/twi-master
diff options
context:
space:
mode:
Diffstat (limited to 'n/avr/twi-master')
-rw-r--r--n/avr/twi-master/test_twi_master.c6
-rw-r--r--n/avr/twi-master/twi_master.c5
-rw-r--r--n/avr/twi-master/twi_master.h1
3 files changed, 11 insertions, 1 deletions
diff --git a/n/avr/twi-master/test_twi_master.c b/n/avr/twi-master/test_twi_master.c
index dbce0ad..9b8adac 100644
--- a/n/avr/twi-master/test_twi_master.c
+++ b/n/avr/twi-master/test_twi_master.c
@@ -19,6 +19,8 @@ void proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
{
proto_send ('s', 0, 0);
twi_master_send (args[0], &args[1], 1);
+ while (!twi_master_is_finished ())
+ ;
proto_send ('f', 0, 0);
}
else
@@ -32,7 +34,11 @@ void proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
if (c != 0)
proto_send ('e', 1 , 0);
else
+ {
+ while (!twi_master_is_finished ())
+ ;
proto_send ('f', 1, data);
+ }
}
else
proto_send ('e', 1, 0);
diff --git a/n/avr/twi-master/twi_master.c b/n/avr/twi-master/twi_master.c
index 1b7aea2..1718c7a 100644
--- a/n/avr/twi-master/twi_master.c
+++ b/n/avr/twi-master/twi_master.c
@@ -43,10 +43,13 @@ twi_master_init (void)
}
int8_t
-twi_is_finished ()
+twi_master_is_finished ()
{
if (twi_state == TWI_SUCCESS || twi_state == TWI_ECHEC)
+ {
+ twi_state = TWI_FREE;
return 1;
+ }
else
return 0;
}
diff --git a/n/avr/twi-master/twi_master.h b/n/avr/twi-master/twi_master.h
index 0f667c3..fed5a6f 100644
--- a/n/avr/twi-master/twi_master.h
+++ b/n/avr/twi-master/twi_master.h
@@ -28,6 +28,7 @@
#include <inttypes.h>
void twi_master_init (void);
+int8_t twi_master_is_finished ();
int8_t twi_master_send (uint8_t addr, uint8_t data[], uint8_t len);
int8_t twi_master_read (uint8_t addr, uint8_t data[], uint8_t len);