Permalink
Browse files

do not bother with volatile variables, we cannot use i2c inside ISR a…

…nyway
  • Loading branch information...
1 parent 21850c0 commit b1652c8ddfc5ed3c23ad4c7bcbff9b5eaaedd10b @rambo rambo committed Mar 29, 2011
Showing with 6 additions and 4 deletions.
  1. +1 −1 bma180.h
  2. +2 −1 i2c_accelerometer.h
  3. +3 −2 i2c_sensor_lib.pde
View
@@ -31,7 +31,7 @@ class bma180 : public i2c_accelerometer
// 2 byte endian marker
// 6 byte buffer for saving data read from the device
// 2 byte checksum in case there is a reset in the middle of a packet.
- volatile int last_data_buffer[5];
+ int last_data_buffer[5];
};
View
@@ -4,6 +4,7 @@
#include <WProgram.h>
#include "i2c_sensor.h"
#include <Wire.h>
+#define SimpleFIFO_NONVOLATILE
#include <SimpleFIFO.h>
@@ -25,7 +26,7 @@ class i2c_accelerometer : public i2c_sensor
// The SimpleFIFO is volatile, I wonder if I should make a non-volatile version too ?
SimpleFIFO<int,I2C_ACCELEROMETER_SMOOTH_BUFFER_SIZE> smoothing_buffer[3]; // One SimpleFIFO for each channel
// This probably does not need to be volatile since we can't do I2C operations inside interrupts anyway...
- volatile int last_data_buffer[3];
+ int last_data_buffer[3];
int smoothed_buffer[3];
// PONDER: define this (and the simplefifo above) in parent class too ?
void push_to_smoothing_buffer(int val_x, int val_y, int val_z);
View
@@ -1,6 +1,7 @@
-// If this is not here we get compile error on i2c_sensor.h
+// If this is not here we get compile error on i2c_sensor.h (WTF!)
#include <Wire.h>
-// If this is not here we get a compile error on i2c_accelerometer.h
+// If this is not here we get a compile error on i2c_accelerometer.h (WTF!)
+#define SimpleFIFO_NONVOLATILE
#include <SimpleFIFO.h>
#include "bma180.h"

0 comments on commit b1652c8

Please sign in to comment.