aboutsummaryrefslogtreecommitdiff
path: root/i2c.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2014-04-22 16:48:50 +0200
committerLars-Dominik Braun <lars@6xq.net>2014-04-22 16:51:13 +0200
commitb05df9df58bc6fdd122abfec3012bc2537fc069c (patch)
treef0be81167c40aa7f3490e8018ea92cc21b16f2be /i2c.c
parent68c180f2aba4471483e1786556c2bc2a94a7d2a7 (diff)
downloadhourglass-b05df9df58bc6fdd122abfec3012bc2537fc069c.tar.gz
hourglass-b05df9df58bc6fdd122abfec3012bc2537fc069c.tar.bz2
hourglass-b05df9df58bc6fdd122abfec3012bc2537fc069c.zip
Fix interrupt stuff
Sorta polling based now, with interrupts used to wake up from sleep only. At least it works.
Diffstat (limited to 'i2c.c')
-rw-r--r--i2c.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/i2c.c b/i2c.c
index 7855e88..3e4bffb 100644
--- a/i2c.c
+++ b/i2c.c
@@ -1,6 +1,8 @@
#include <stdio.h>
#include <util/twi.h>
#include <avr/interrupt.h>
+#include <stdlib.h>
+#include <assert.h>
#include "i2c.h"
#include "common.h"
@@ -67,10 +69,7 @@ void twInit () {
*/
bool twRequest (const twMode mode, const uint8_t address,
const uint8_t subaddress, uint8_t * const data, const uint8_t count) {
- /* do not start if request is pending */
- if (twr.status == TWST_WAIT) {
- return false;
- }
+ assert (twr.status != TWST_WAIT);
twr.mode = mode;
twr.address = address;