mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Migrate all Miniware devices to use Bit-Bang I2C (#1838)
* MHP30 move to I2C Bit Banging * Fixup Accelerometer drivers so all can use I2CBB * No STM32 I2C driver anymore * TS100 on I2CBB * Miniware on BB * Fixup S60 build * format format
This commit is contained in:
@@ -6,11 +6,13 @@
|
||||
*/
|
||||
|
||||
#include "MSA301_defines.h"
|
||||
#include "accelerometers_common.h"
|
||||
#include <MSA301.h>
|
||||
#define MSA301_I2C_ADDRESS 0x26 << 1
|
||||
bool MSA301::detect() { return FRToSI2C::probe(MSA301_I2C_ADDRESS); }
|
||||
|
||||
static const FRToSI2C::I2C_REG i2c_registers[] = {
|
||||
#define MSA301_I2C_ADDRESS 0x26 << 1
|
||||
bool MSA301::detect() { return ACCEL_I2C_CLASS::probe(MSA301_I2C_ADDRESS); }
|
||||
|
||||
static const ACCEL_I2C_CLASS::I2C_REG i2c_registers[] = {
|
||||
//
|
||||
//
|
||||
{MSA301_REG_ODR, 0b00001000, 1}, // X/Y/Z enabled @ 250Hz
|
||||
@@ -21,11 +23,11 @@ static const FRToSI2C::I2C_REG i2c_registers[] = {
|
||||
|
||||
};
|
||||
|
||||
bool MSA301::initalize() { return FRToSI2C::writeRegistersBulk(MSA301_I2C_ADDRESS, i2c_registers, sizeof(i2c_registers) / sizeof(i2c_registers[0])); }
|
||||
bool MSA301::initalize() { return ACCEL_I2C_CLASS::writeRegistersBulk(MSA301_I2C_ADDRESS, i2c_registers, sizeof(i2c_registers) / sizeof(i2c_registers[0])); }
|
||||
|
||||
Orientation MSA301::getOrientation() {
|
||||
uint8_t temp = 0;
|
||||
FRToSI2C::Mem_Read(MSA301_I2C_ADDRESS, MSA301_REG_ORIENT_STATUS, &temp, 1);
|
||||
ACCEL_I2C_CLASS::Mem_Read(MSA301_I2C_ADDRESS, MSA301_REG_ORIENT_STATUS, &temp, 1);
|
||||
switch (temp) {
|
||||
case 112:
|
||||
return Orientation::ORIENTATION_LEFT_HAND;
|
||||
@@ -39,7 +41,7 @@ Orientation MSA301::getOrientation() {
|
||||
void MSA301::getAxisReadings(int16_t &x, int16_t &y, int16_t &z) {
|
||||
uint8_t temp[6];
|
||||
// Bulk read all 6 regs
|
||||
FRToSI2C::Mem_Read(MSA301_I2C_ADDRESS, MSA301_REG_OUT_X_L, temp, 6);
|
||||
ACCEL_I2C_CLASS::Mem_Read(MSA301_I2C_ADDRESS, MSA301_REG_OUT_X_L, temp, 6);
|
||||
x = int16_t(((int16_t)temp[1]) << 8 | temp[0]) >> 2;
|
||||
y = int16_t(((int16_t)temp[3]) << 8 | temp[2]) >> 2;
|
||||
z = int16_t(((int16_t)temp[5]) << 8 | temp[4]) >> 2;
|
||||
|
||||
Reference in New Issue
Block a user