CUED IIA Project

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_GATT_Example by Bluetooth Low Energy

Committer:
AidasL
Date:
Sat Jun 03 21:14:42 2017 +0000
Revision:
24:baa43caa2f3d
Parent:
23:708cc5ef2604
Saturday updates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AidasL 23:708cc5ef2604 1 #include "mbed.h"
AidasL 23:708cc5ef2604 2
AidasL 23:708cc5ef2604 3 #ifndef SENSORS_H
AidasL 23:708cc5ef2604 4 #define SENSORS_H
AidasL 23:708cc5ef2604 5
AidasL 24:baa43caa2f3d 6
AidasL 24:baa43caa2f3d 7 // Register names, can look up in the datasheet
AidasL 24:baa43caa2f3d 8
AidasL 24:baa43caa2f3d 9 #define SMPRT_DIV 0x19 //
AidasL 24:baa43caa2f3d 10 #define CONFIG 0x1A //
AidasL 24:baa43caa2f3d 11 #define GYRO_CONFIG 0x1B //
AidasL 24:baa43caa2f3d 12 #define ACCEL_CONFIG 0x1C //
AidasL 24:baa43caa2f3d 13 #define FIFO_EN 0x23 //
AidasL 24:baa43caa2f3d 14 #define I2C_MST_CTRL 0x24 //
AidasL 24:baa43caa2f3d 15 #define INT_PIN_CFG 0x37 //
AidasL 24:baa43caa2f3d 16 #define INT_ENABLE 0x38 //
AidasL 24:baa43caa2f3d 17
AidasL 24:baa43caa2f3d 18 #define ACCX158 0x3B //
AidasL 24:baa43caa2f3d 19 #define ACCX70 0x3C //
AidasL 24:baa43caa2f3d 20 #define ACCY158 0x3D //
AidasL 24:baa43caa2f3d 21 #define ACCY70 0x3E //
AidasL 24:baa43caa2f3d 22 #define ACCZ158 0x3F //
AidasL 24:baa43caa2f3d 23 #define ACCZ70 0x40 //
AidasL 24:baa43caa2f3d 24 #define TEMP158 0x41 //
AidasL 24:baa43caa2f3d 25 #define TEMP70 0x42 // Temperature in C = ((signed int16_t) value)/340 + 36.53
AidasL 24:baa43caa2f3d 26 #define GYROX158 0x43 //
AidasL 24:baa43caa2f3d 27 #define GYROX70 0x44 //
AidasL 24:baa43caa2f3d 28 #define GYROY158 0x45 //
AidasL 24:baa43caa2f3d 29 #define GYROY70 0x46 //
AidasL 24:baa43caa2f3d 30 #define GYROZ158 0x47 //
AidasL 24:baa43caa2f3d 31 #define GYROZ70 0x48 //
AidasL 24:baa43caa2f3d 32
AidasL 24:baa43caa2f3d 33 #define USER_CTRL 0x6A //
AidasL 24:baa43caa2f3d 34 #define PWR_MGMT_1 0x6B //
AidasL 24:baa43caa2f3d 35 #define PWR_MGMT_2 0x6C //
AidasL 24:baa43caa2f3d 36 #define WHO_AM_I 0x75 // Check device number to see if it works
AidasL 24:baa43caa2f3d 37
AidasL 24:baa43caa2f3d 38 const uint8_t ACC_LEFT = 0x68; // 0b01101000
AidasL 24:baa43caa2f3d 39 const uint8_t ACC_RIGHT = 0x69; // 0b01101001
AidasL 24:baa43caa2f3d 40
AidasL 24:baa43caa2f3d 41
AidasL 24:baa43caa2f3d 42
AidasL 24:baa43caa2f3d 43
AidasL 23:708cc5ef2604 44 typedef struct {
AidasL 24:baa43caa2f3d 45
AidasL 24:baa43caa2f3d 46 uint16_t flex[12];
AidasL 24:baa43caa2f3d 47 // Order of the flex sensors:
AidasL 24:baa43caa2f3d 48 // 0 - right thumb, 4 - right pinky, 5 - R elbow;
AidasL 24:baa43caa2f3d 49 // 6 - left thumb, 10 left pinky, 11 - L elbow;
AidasL 24:baa43caa2f3d 50 uint16_t acc[2][7];
AidasL 24:baa43caa2f3d 51 // 7th value is the temperature value
AidasL 24:baa43caa2f3d 52 uint16_t temp;
AidasL 24:baa43caa2f3d 53
AidasL 24:baa43caa2f3d 54
AidasL 24:baa43caa2f3d 55 } Datapacket;
AidasL 24:baa43caa2f3d 56
AidasL 23:708cc5ef2604 57 typedef struct {
AidasL 24:baa43caa2f3d 58
AidasL 24:baa43caa2f3d 59 uint8_t pixels[8];
AidasL 24:baa43caa2f3d 60
AidasL 24:baa43caa2f3d 61 } Screen;
AidasL 23:708cc5ef2604 62
AidasL 23:708cc5ef2604 63
AidasL 23:708cc5ef2604 64 void readacc(Datapacket data);
AidasL 23:708cc5ef2604 65
AidasL 24:baa43caa2f3d 66 void setupacc(uint8_t ADDRESS);
AidasL 23:708cc5ef2604 67
AidasL 24:baa43caa2f3d 68 void WriteBytes(uint8_t addr, uint8_t *pbuf, uint16_t length, uint8_t DEV_ADDR);
AidasL 24:baa43caa2f3d 69
AidasL 24:baa43caa2f3d 70 void WriteByte(uint8_t addr, uint8_t buf, uint8_t DEV_ADDR);
AidasL 23:708cc5ef2604 71
AidasL 24:baa43caa2f3d 72 void ReadBytes(uint8_t addr, uint8_t *pbuf, uint16_t length, uint8_t DEV_ADDR);
AidasL 23:708cc5ef2604 73
AidasL 24:baa43caa2f3d 74 void readflexs(Datapacket *data);
AidasL 24:baa43caa2f3d 75
AidasL 24:baa43caa2f3d 76 void readacc(Datapacket *data, uint8_t accadr);
AidasL 24:baa43caa2f3d 77
AidasL 24:baa43caa2f3d 78 void setupI2C(void);
AidasL 23:708cc5ef2604 79
AidasL 23:708cc5ef2604 80
AidasL 23:708cc5ef2604 81
AidasL 23:708cc5ef2604 82
AidasL 23:708cc5ef2604 83
AidasL 23:708cc5ef2604 84
AidasL 23:708cc5ef2604 85
AidasL 23:708cc5ef2604 86 #endif