summaryrefslogtreecommitdiff
path: root/bma150.h
blob: 0cd6b27fec9172df6259da253e0b0d111b3eff0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef BMA150_H
#define BMA150_H

#include "i2csensor.h"

class BMA150 : public I2CSensor {
	public:
		int16_t x, y, z;
		
		void init() {
			i2c_address = 0x38;
			read(0x14, 1);
			write(0x14, (rxdata[0] & 0xe0) | 0x00 | 0x00); // 2g range, 25 Hz bandwidth
		}
		
		void update() {
			read(0x02, 6);
			x = ((rxdata[0] & 0xc0) | rxdata[1] << 8);
			y = ((rxdata[2] & 0xc0) | rxdata[3] << 8);
			z = ((rxdata[4] & 0xc0) | rxdata[5] << 8);
		}
};

#endif