aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2014-07-22 16:45:10 +0200
committerLars-Dominik Braun <lars@6xq.net>2014-07-22 16:55:55 +0200
commitc6f7452ab86675465959b5f8784e3140438a56ba (patch)
tree3a8690baecebbd3db5db9200ddd03104c35813d4
parent5055ee55d1330b52182a35378f5b4f8055cefc54 (diff)
downloadhourglass-c6f7452ab86675465959b5f8784e3140438a56ba.tar.gz
hourglass-c6f7452ab86675465959b5f8784e3140438a56ba.tar.bz2
hourglass-c6f7452ab86675465959b5f8784e3140438a56ba.zip
Use “volatile” on struct members
Not all struct members are written in an ISR.
-rw-r--r--i2c.c2
-rw-r--r--i2c.h12
2 files changed, 7 insertions, 7 deletions
diff --git a/i2c.c b/i2c.c
index d7e5058..7fe4fd2 100644
--- a/i2c.c
+++ b/i2c.c
@@ -6,7 +6,7 @@
#include "i2c.h"
#include "common.h"
-volatile twReq twr;
+twReq twr;
static void twStartRaw () {
/* disable stop, enable interrupt, reset twint, enable start, enable i2c */
diff --git a/i2c.h b/i2c.h
index ec7fd87..1090ee2 100644
--- a/i2c.h
+++ b/i2c.h
@@ -19,19 +19,19 @@ typedef struct {
twMode mode;
uint8_t address;
uint8_t subaddress;
- uint8_t step;
+ volatile uint8_t step;
/* pointer to read/write data */
- uint8_t *data;
+ volatile uint8_t *data;
/* number of bytes to be read/written */
uint8_t count;
/* current byte */
- uint8_t i;
- twStatus status;
+ volatile uint8_t i;
+ volatile twStatus status;
/* i2c bus status at the time if an error occured */
- uint8_t error;
+ volatile uint8_t error;
} twReq;
-extern volatile twReq twr;
+extern twReq twr;
#include <stdbool.h>