10 #define ADDR_MMA7660 0x4C
12 #define ACC_XOUT 0x00 // 6-bit output value X - Alert XOUT[5] XOUT[4] XOUT[3] XOUT[2] XOUT[1] XOUT[0]
13 #define ACC_YOUT 0x01 // 6-bit output value Y - Alert YOUT[5] YOUT[4] YOUT[3] YOUT[2] YOUT[1] YOUT[0]
14 #define ACC_ZOUT 0x02 // 6-bit output value Z - Alert ZOUT[5] ZOUT[4] ZOUT[3] ZOUT[2] ZOUT[1] ZOUT[0]
15 #define ACC_TILT 0x03 // Tilt Status Shake Alert Tap PoLa[2] PoLa[1] PoLa[0] BaFro[1] BaFro[0]
16 #define ACC_SRST 0x04 // Sampling Rate Status 0 0 0 0 0 0 AWSRS AMSRS
17 #define ACC_SPCNT 0x05 // Sleep Count SC[7] SC[6] SC[5] SC[4] SC[3] SC[2] SC[1] SC[0]
18 #define ACC_INTSU 0x06 // Interrupt Setup SHINTX SHINTY SHINTZ GINT ASINT PDINT PLINT FBINT
19 #define ACC_MODE 0x07 // Mode IAH IPP SCPS ASE AWE TON - MODE
20 #define ACC_SR 0x08 // Auto-Wake/Sleep and Portrait/Landscape samples per seconds and Debounce Filter
22 #define ACC_PDET 0x09 // Tap Detection ZDA YDA XDA PDTH[4] PDTH[3] PDTH[2] PDTH[1] PDTH[0]
23 #define ACC_PD 0x0A // Tap Debounce Count PD[7] PD[6] PD[5] PD[4] PD[3] PD[2] PD[1] PD[0]
25 #define SIGN_BIT 0x20 // sign bit in data register
26 #define MASK_ERROR 0x40 // mask status read bit in data register
28 #define STDBY_MODE 0x00 // stanby mode for configuration
29 #define ACTIVE_MODE 0x01 // active mode for measure
54 uint8_t regAddress = ACC_XOUT;
59 if (status !=
NO_ERROR)
return status;
63 status =
bus_writeread(bus,ADDR_MMA7660,®Address,1,readData,3,NULL);
64 if(status !=
NO_ERROR)
return status;
67 if (!(readData[0] & MASK_ERROR) && !(readData[1] & MASK_ERROR) && !(readData[2] & MASK_ERROR))
74 if (status !=
NO_ERROR)
return status;
78 if (readData[i] & SIGN_BIT)
83 accelData->
x = readData[0];
84 accelData->
y = readData[1];
85 accelData->
z = readData[2];
98 if(status !=
NO_ERROR)
return status;
99 status =
bus_write(bus,ADDR_MMA7660,&dta,2);
100 if(status !=
NO_ERROR)
return status;
102 if(status !=
NO_ERROR)
return status;
status_e bus_release(const struct heivs_bus_t *bus)
Release exclusive access to the bus.
int8_t y
y axis acceleration value (31 to -32)
status_e Accel_WriteCfg(uint8_t reg, uint8_t data)
Write special config to accelrometer.
status_e bus_write(const struct heivs_bus_t *bus, uint32_t address, const void *data, size_t len)
Write data to the bus.
int8_t x
x axis acceleration value (31 to -32)
status_e bus_init(const struct heivs_bus_t *bus)
initialize the bus
const struct heivs_bus_t bus_i2c[BSP_I2C_BUS_COUNT]
All i2c busses.
ARMEBS4 accelerometer access functions.
status_e bus_get(const struct heivs_bus_t *bus)
Get exclusive access to the bus.
status_e Accel_Init(void)
Initialize the accelerometer.
#define ARRAY_SIZE(x)
Number of elements in the array.
status_e bus_writeread(const struct heivs_bus_t *bus, uint32_t address, const void *src, size_t src_len, void *dst, size_t dst_len, size_t *rlen)
Combined write and read data.
int8_t z
z axis acceleration value (31 to -32)
status_e Accel_Read(struct accelerometer_data_t *accelData)
Read data from accelerometer.