mirror of https://github.com/sqfmi/Watchy.git
Format all files
parent
3a6af55a6f
commit
8f55e2f694
129
src/BLE.cpp
129
src/BLE.cpp
|
@ -1,99 +1,85 @@
|
||||||
#include "BLE.h"
|
#include "BLE.h"
|
||||||
|
|
||||||
#define SERVICE_UUID_ESPOTA "cd77498e-1ac8-48b6-aba8-4161c7342fce"
|
#define SERVICE_UUID_ESPOTA "cd77498e-1ac8-48b6-aba8-4161c7342fce"
|
||||||
#define CHARACTERISTIC_UUID_ID "cd77498f-1ac8-48b6-aba8-4161c7342fce"
|
#define CHARACTERISTIC_UUID_ID "cd77498f-1ac8-48b6-aba8-4161c7342fce"
|
||||||
|
|
||||||
#define SERVICE_UUID_OTA "86b12865-4b70-4893-8ce6-9864fc00374d"
|
#define SERVICE_UUID_OTA "86b12865-4b70-4893-8ce6-9864fc00374d"
|
||||||
#define CHARACTERISTIC_UUID_FW "86b12866-4b70-4893-8ce6-9864fc00374d"
|
#define CHARACTERISTIC_UUID_FW "86b12866-4b70-4893-8ce6-9864fc00374d"
|
||||||
#define CHARACTERISTIC_UUID_HW_VERSION "86b12867-4b70-4893-8ce6-9864fc00374d"
|
#define CHARACTERISTIC_UUID_HW_VERSION "86b12867-4b70-4893-8ce6-9864fc00374d"
|
||||||
#define CHARACTERISTIC_UUID_WATCHFACE_NAME "86b12868-4b70-4893-8ce6-9864fc00374d"
|
#define CHARACTERISTIC_UUID_WATCHFACE_NAME \
|
||||||
|
"86b12868-4b70-4893-8ce6-9864fc00374d"
|
||||||
|
|
||||||
#define FULL_PACKET 512
|
#define FULL_PACKET 512
|
||||||
#define CHARPOS_UPDATE_FLAG 5
|
#define CHARPOS_UPDATE_FLAG 5
|
||||||
|
|
||||||
#define STATUS_CONNECTED 0
|
#define STATUS_CONNECTED 0
|
||||||
#define STATUS_DISCONNECTED 4
|
#define STATUS_DISCONNECTED 4
|
||||||
#define STATUS_UPDATING 1
|
#define STATUS_UPDATING 1
|
||||||
#define STATUS_READY 2
|
#define STATUS_READY 2
|
||||||
|
|
||||||
esp_ota_handle_t otaHandler = 0;
|
esp_ota_handle_t otaHandler = 0;
|
||||||
|
|
||||||
int status = -1;
|
int status = -1;
|
||||||
int bytesReceived = 0;
|
int bytesReceived = 0;
|
||||||
bool updateFlag = false;
|
bool updateFlag = false;
|
||||||
|
|
||||||
|
class BLECustomServerCallbacks : public BLEServerCallbacks {
|
||||||
|
void onConnect(BLEServer *pServer) { status = STATUS_CONNECTED; };
|
||||||
|
|
||||||
class BLECustomServerCallbacks: public BLEServerCallbacks {
|
void onDisconnect(BLEServer *pServer) { status = STATUS_DISCONNECTED; }
|
||||||
void onConnect(BLEServer* pServer) {
|
|
||||||
status = STATUS_CONNECTED;
|
|
||||||
};
|
|
||||||
|
|
||||||
void onDisconnect(BLEServer* pServer) {
|
|
||||||
status = STATUS_DISCONNECTED;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class otaCallback: public BLECharacteristicCallbacks {
|
class otaCallback : public BLECharacteristicCallbacks {
|
||||||
public:
|
public:
|
||||||
otaCallback(BLE* ble) {
|
otaCallback(BLE *ble) { _p_ble = ble; }
|
||||||
_p_ble = ble;
|
BLE *_p_ble;
|
||||||
}
|
|
||||||
BLE* _p_ble;
|
|
||||||
|
|
||||||
void onWrite(BLECharacteristic *pCharacteristic);
|
void onWrite(BLECharacteristic *pCharacteristic);
|
||||||
};
|
};
|
||||||
|
|
||||||
void otaCallback::onWrite(BLECharacteristic *pCharacteristic)
|
void otaCallback::onWrite(BLECharacteristic *pCharacteristic) {
|
||||||
{
|
|
||||||
std::string rxData = pCharacteristic->getValue();
|
std::string rxData = pCharacteristic->getValue();
|
||||||
if (!updateFlag) { //If it's the first packet of OTA since bootup, begin OTA
|
if (!updateFlag) { // If it's the first packet of OTA since bootup, begin OTA
|
||||||
//Serial.println("Begin FW Update");
|
// Serial.println("Begin FW Update");
|
||||||
esp_ota_begin(esp_ota_get_next_update_partition(NULL), OTA_SIZE_UNKNOWN, &otaHandler);
|
esp_ota_begin(esp_ota_get_next_update_partition(NULL), OTA_SIZE_UNKNOWN,
|
||||||
|
&otaHandler);
|
||||||
updateFlag = true;
|
updateFlag = true;
|
||||||
status = STATUS_UPDATING;
|
status = STATUS_UPDATING;
|
||||||
}
|
}
|
||||||
if (_p_ble != NULL)
|
if (_p_ble != NULL) {
|
||||||
{
|
if (rxData.length() > 0) {
|
||||||
if (rxData.length() > 0)
|
|
||||||
{
|
|
||||||
esp_ota_write(otaHandler, rxData.c_str(), rxData.length());
|
esp_ota_write(otaHandler, rxData.c_str(), rxData.length());
|
||||||
bytesReceived = bytesReceived + rxData.length();
|
bytesReceived = bytesReceived + rxData.length();
|
||||||
if (rxData.length() != FULL_PACKET)
|
if (rxData.length() != FULL_PACKET) {
|
||||||
{
|
|
||||||
esp_ota_end(otaHandler);
|
esp_ota_end(otaHandler);
|
||||||
//Serial.println("End FW Update");
|
// Serial.println("End FW Update");
|
||||||
if (ESP_OK == esp_ota_set_boot_partition(esp_ota_get_next_update_partition(NULL))) {
|
if (ESP_OK == esp_ota_set_boot_partition(
|
||||||
status = STATUS_READY;
|
esp_ota_get_next_update_partition(NULL))) {
|
||||||
}
|
status = STATUS_READY;
|
||||||
else {
|
} else {
|
||||||
//Serial.println("Upload Error");
|
// Serial.println("Upload Error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t txData[5] = {1, 2, 3, 4, 5};
|
uint8_t txData[5] = {1, 2, 3, 4, 5};
|
||||||
//delay(1000);
|
// delay(1000);
|
||||||
pCharacteristic->setValue((uint8_t*)txData, 5);
|
pCharacteristic->setValue((uint8_t *)txData, 5);
|
||||||
pCharacteristic->notify();
|
pCharacteristic->notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructor
|
// Constructor
|
||||||
BLE::BLE(void) {
|
BLE::BLE(void) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Destructor
|
// Destructor
|
||||||
BLE::~BLE(void)
|
BLE::~BLE(void) {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// begin
|
// begin
|
||||||
bool BLE::begin(const char* localName = "Watchy BLE OTA") {
|
bool BLE::begin(const char *localName = "Watchy BLE OTA") {
|
||||||
// Create the BLE Device
|
// Create the BLE Device
|
||||||
BLEDevice::init(localName);
|
BLEDevice::init(localName);
|
||||||
|
|
||||||
|
@ -103,28 +89,21 @@ bool BLE::begin(const char* localName = "Watchy BLE OTA") {
|
||||||
|
|
||||||
// Create the BLE Service
|
// Create the BLE Service
|
||||||
pESPOTAService = pServer->createService(SERVICE_UUID_ESPOTA);
|
pESPOTAService = pServer->createService(SERVICE_UUID_ESPOTA);
|
||||||
pService = pServer->createService(SERVICE_UUID_OTA);
|
pService = pServer->createService(SERVICE_UUID_OTA);
|
||||||
|
|
||||||
// Create a BLE Characteristic
|
// Create a BLE Characteristic
|
||||||
pESPOTAIdCharacteristic = pESPOTAService->createCharacteristic(
|
pESPOTAIdCharacteristic = pESPOTAService->createCharacteristic(
|
||||||
CHARACTERISTIC_UUID_ID,
|
CHARACTERISTIC_UUID_ID, BLECharacteristic::PROPERTY_READ);
|
||||||
BLECharacteristic::PROPERTY_READ
|
|
||||||
);
|
|
||||||
|
|
||||||
pVersionCharacteristic = pService->createCharacteristic(
|
pVersionCharacteristic = pService->createCharacteristic(
|
||||||
CHARACTERISTIC_UUID_HW_VERSION,
|
CHARACTERISTIC_UUID_HW_VERSION, BLECharacteristic::PROPERTY_READ);
|
||||||
BLECharacteristic::PROPERTY_READ
|
|
||||||
);
|
|
||||||
|
|
||||||
pWatchFaceNameCharacteristic = pService->createCharacteristic(
|
pWatchFaceNameCharacteristic = pService->createCharacteristic(
|
||||||
CHARACTERISTIC_UUID_WATCHFACE_NAME,
|
CHARACTERISTIC_UUID_WATCHFACE_NAME, BLECharacteristic::PROPERTY_READ);
|
||||||
BLECharacteristic::PROPERTY_READ
|
|
||||||
);
|
|
||||||
|
|
||||||
pOtaCharacteristic = pService->createCharacteristic(
|
pOtaCharacteristic = pService->createCharacteristic(
|
||||||
CHARACTERISTIC_UUID_FW,
|
CHARACTERISTIC_UUID_FW,
|
||||||
BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_WRITE
|
BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_WRITE);
|
||||||
);
|
|
||||||
|
|
||||||
pOtaCharacteristic->addDescriptor(new BLE2902());
|
pOtaCharacteristic->addDescriptor(new BLE2902());
|
||||||
pOtaCharacteristic->setCallbacks(new otaCallback(this));
|
pOtaCharacteristic->setCallbacks(new otaCallback(this));
|
||||||
|
@ -137,17 +116,15 @@ bool BLE::begin(const char* localName = "Watchy BLE OTA") {
|
||||||
pServer->getAdvertising()->addServiceUUID(SERVICE_UUID_ESPOTA);
|
pServer->getAdvertising()->addServiceUUID(SERVICE_UUID_ESPOTA);
|
||||||
pServer->getAdvertising()->start();
|
pServer->getAdvertising()->start();
|
||||||
|
|
||||||
uint8_t hardwareVersion[5] = {HARDWARE_VERSION_MAJOR, HARDWARE_VERSION_MINOR, SOFTWARE_VERSION_MAJOR, SOFTWARE_VERSION_MINOR, SOFTWARE_VERSION_PATCH};
|
uint8_t hardwareVersion[5] = {HARDWARE_VERSION_MAJOR, HARDWARE_VERSION_MINOR,
|
||||||
pVersionCharacteristic->setValue((uint8_t*)hardwareVersion, 5);
|
SOFTWARE_VERSION_MAJOR, SOFTWARE_VERSION_MINOR,
|
||||||
|
SOFTWARE_VERSION_PATCH};
|
||||||
|
pVersionCharacteristic->setValue((uint8_t *)hardwareVersion, 5);
|
||||||
pWatchFaceNameCharacteristic->setValue("Watchy 7 Segment");
|
pWatchFaceNameCharacteristic->setValue("Watchy 7 Segment");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BLE::updateStatus(){
|
int BLE::updateStatus() { return status; }
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
int BLE::howManyBytes(){
|
int BLE::howManyBytes() { return bytesReceived; }
|
||||||
return bytesReceived;
|
|
||||||
}
|
|
36
src/BLE.h
36
src/BLE.h
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
||||||
|
#include <BLE2902.h>
|
||||||
#include <BLEDevice.h>
|
#include <BLEDevice.h>
|
||||||
#include <BLEServer.h>
|
#include <BLEServer.h>
|
||||||
#include <BLEUtils.h>
|
#include <BLEUtils.h>
|
||||||
#include <BLE2902.h>
|
|
||||||
|
|
||||||
#include "esp_ota_ops.h"
|
#include "esp_ota_ops.h"
|
||||||
|
|
||||||
|
@ -14,29 +14,27 @@
|
||||||
|
|
||||||
class BLE;
|
class BLE;
|
||||||
|
|
||||||
class BLE
|
class BLE {
|
||||||
{
|
public:
|
||||||
public:
|
BLE(void);
|
||||||
|
~BLE(void);
|
||||||
|
|
||||||
BLE(void);
|
bool begin(const char *localName);
|
||||||
~BLE(void);
|
int updateStatus();
|
||||||
|
int howManyBytes();
|
||||||
|
|
||||||
bool begin(const char* localName);
|
private:
|
||||||
int updateStatus();
|
String local_name;
|
||||||
int howManyBytes();
|
|
||||||
|
|
||||||
private:
|
|
||||||
String local_name;
|
|
||||||
|
|
||||||
BLEServer *pServer = NULL;
|
BLEServer *pServer = NULL;
|
||||||
|
|
||||||
BLEService *pESPOTAService = NULL;
|
BLEService *pESPOTAService = NULL;
|
||||||
BLECharacteristic * pESPOTAIdCharacteristic = NULL;
|
BLECharacteristic *pESPOTAIdCharacteristic = NULL;
|
||||||
|
|
||||||
BLEService *pService = NULL;
|
BLEService *pService = NULL;
|
||||||
BLECharacteristic * pVersionCharacteristic = NULL;
|
BLECharacteristic *pVersionCharacteristic = NULL;
|
||||||
BLECharacteristic * pOtaCharacteristic = NULL;
|
BLECharacteristic *pOtaCharacteristic = NULL;
|
||||||
BLECharacteristic * pWatchFaceNameCharacteristic = NULL;
|
BLECharacteristic *pWatchFaceNameCharacteristic = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
1502
src/Watchy.cpp
1502
src/Watchy.cpp
File diff suppressed because it is too large
Load Diff
133
src/Watchy.h
133
src/Watchy.h
|
@ -1,81 +1,86 @@
|
||||||
#ifndef WATCHY_H
|
#ifndef WATCHY_H
|
||||||
#define WATCHY_H
|
#define WATCHY_H
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include "BLE.h"
|
||||||
#include <WiFiManager.h>
|
|
||||||
#include <HTTPClient.h>
|
|
||||||
#include <NTPClient.h>
|
|
||||||
#include <WiFiUdp.h>
|
|
||||||
#include <Arduino_JSON.h>
|
|
||||||
#include <GxEPD2_BW.h>
|
|
||||||
#include <Wire.h>
|
|
||||||
#include <Fonts/FreeMonoBold9pt7b.h>
|
|
||||||
#include "DSEG7_Classic_Bold_53.h"
|
#include "DSEG7_Classic_Bold_53.h"
|
||||||
#include "WatchyRTC.h"
|
#include "WatchyRTC.h"
|
||||||
#include "BLE.h"
|
|
||||||
#include "bma.h"
|
#include "bma.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <Arduino_JSON.h>
|
||||||
|
#include <Fonts/FreeMonoBold9pt7b.h>
|
||||||
|
#include <GxEPD2_BW.h>
|
||||||
|
#include <HTTPClient.h>
|
||||||
|
#include <NTPClient.h>
|
||||||
|
#include <WiFiManager.h>
|
||||||
|
#include <WiFiUdp.h>
|
||||||
|
#include <Wire.h>
|
||||||
|
|
||||||
typedef struct weatherData{
|
typedef struct weatherData {
|
||||||
int8_t temperature;
|
int8_t temperature;
|
||||||
int16_t weatherConditionCode;
|
int16_t weatherConditionCode;
|
||||||
bool isMetric;
|
bool isMetric;
|
||||||
String weatherDescription;
|
String weatherDescription;
|
||||||
}weatherData;
|
} weatherData;
|
||||||
|
|
||||||
typedef struct watchySettings{
|
typedef struct watchySettings {
|
||||||
//Weather Settings
|
// Weather Settings
|
||||||
String cityID;
|
String cityID;
|
||||||
String weatherAPIKey;
|
String weatherAPIKey;
|
||||||
String weatherURL;
|
String weatherURL;
|
||||||
String weatherUnit;
|
String weatherUnit;
|
||||||
String weatherLang;
|
String weatherLang;
|
||||||
int8_t weatherUpdateInterval;
|
int8_t weatherUpdateInterval;
|
||||||
//NTP Settings
|
// NTP Settings
|
||||||
String ntpServer;
|
String ntpServer;
|
||||||
int gmtOffset;
|
int gmtOffset;
|
||||||
int dstOffset;
|
int dstOffset;
|
||||||
}watchySettings;
|
} watchySettings;
|
||||||
|
|
||||||
class Watchy {
|
class Watchy {
|
||||||
public:
|
public:
|
||||||
static WatchyRTC RTC;
|
static WatchyRTC RTC;
|
||||||
static GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display;
|
static GxEPD2_BW<GxEPD2_154_D67, GxEPD2_154_D67::HEIGHT> display;
|
||||||
tmElements_t currentTime;
|
tmElements_t currentTime;
|
||||||
watchySettings settings;
|
watchySettings settings;
|
||||||
public:
|
|
||||||
explicit Watchy(const watchySettings& s) : settings(s){} //constructor
|
|
||||||
void init(String datetime = "");
|
|
||||||
void deepSleep();
|
|
||||||
static void displayBusyCallback(const void*);
|
|
||||||
float getBatteryVoltage();
|
|
||||||
void vibMotor(uint8_t intervalMs = 100, uint8_t length = 20);
|
|
||||||
|
|
||||||
void handleButtonPress();
|
public:
|
||||||
void showMenu(byte menuIndex, bool partialRefresh);
|
explicit Watchy(const watchySettings &s) : settings(s) {} // constructor
|
||||||
void showFastMenu(byte menuIndex);
|
void init(String datetime = "");
|
||||||
void showAbout();
|
void deepSleep();
|
||||||
void showBuzz();
|
static void displayBusyCallback(const void *);
|
||||||
void showAccelerometer();
|
float getBatteryVoltage();
|
||||||
void showUpdateFW();
|
void vibMotor(uint8_t intervalMs = 100, uint8_t length = 20);
|
||||||
void showSyncNTP();
|
|
||||||
bool syncNTP();
|
|
||||||
bool syncNTP(long gmt, int dst, String ntpServer);
|
|
||||||
void setTime();
|
|
||||||
void setupWifi();
|
|
||||||
bool connectWiFi();
|
|
||||||
weatherData getWeatherData();
|
|
||||||
weatherData getWeatherData(String cityID, String units, String lang, String url, String apiKey, uint8_t updateInterval);
|
|
||||||
void updateFWBegin();
|
|
||||||
|
|
||||||
void showWatchFace(bool partialRefresh);
|
void handleButtonPress();
|
||||||
virtual void drawWatchFace(); //override this method for different watch faces
|
void showMenu(byte menuIndex, bool partialRefresh);
|
||||||
|
void showFastMenu(byte menuIndex);
|
||||||
|
void showAbout();
|
||||||
|
void showBuzz();
|
||||||
|
void showAccelerometer();
|
||||||
|
void showUpdateFW();
|
||||||
|
void showSyncNTP();
|
||||||
|
bool syncNTP();
|
||||||
|
bool syncNTP(long gmt, int dst, String ntpServer);
|
||||||
|
void setTime();
|
||||||
|
void setupWifi();
|
||||||
|
bool connectWiFi();
|
||||||
|
weatherData getWeatherData();
|
||||||
|
weatherData getWeatherData(String cityID, String units, String lang,
|
||||||
|
String url, String apiKey, uint8_t updateInterval);
|
||||||
|
void updateFWBegin();
|
||||||
|
|
||||||
private:
|
void showWatchFace(bool partialRefresh);
|
||||||
void _bmaConfig();
|
virtual void drawWatchFace(); // override this method for different watch
|
||||||
static void _configModeCallback(WiFiManager *myWiFiManager);
|
// faces
|
||||||
static uint16_t _readRegister(uint8_t address, uint8_t reg, uint8_t *data, uint16_t len);
|
|
||||||
static uint16_t _writeRegister(uint8_t address, uint8_t reg, uint8_t *data, uint16_t len);
|
private:
|
||||||
|
void _bmaConfig();
|
||||||
|
static void _configModeCallback(WiFiManager *myWiFiManager);
|
||||||
|
static uint16_t _readRegister(uint8_t address, uint8_t reg, uint8_t *data,
|
||||||
|
uint16_t len);
|
||||||
|
static uint16_t _writeRegister(uint8_t address, uint8_t reg, uint8_t *data,
|
||||||
|
uint16_t len);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern RTC_DATA_ATTR int guiState;
|
extern RTC_DATA_ATTR int guiState;
|
||||||
|
|
|
@ -1,133 +1,149 @@
|
||||||
#include "WatchyRTC.h"
|
#include "WatchyRTC.h"
|
||||||
|
|
||||||
WatchyRTC::WatchyRTC()
|
WatchyRTC::WatchyRTC() : rtc_ds(false) {}
|
||||||
: rtc_ds(false) {}
|
|
||||||
|
|
||||||
void WatchyRTC::init(){
|
void WatchyRTC::init() {
|
||||||
byte error;
|
byte error;
|
||||||
Wire.beginTransmission(RTC_DS_ADDR);
|
Wire.beginTransmission(RTC_DS_ADDR);
|
||||||
|
error = Wire.endTransmission();
|
||||||
|
if (error == 0) {
|
||||||
|
rtcType = DS3231;
|
||||||
|
} else {
|
||||||
|
Wire.beginTransmission(RTC_PCF_ADDR);
|
||||||
error = Wire.endTransmission();
|
error = Wire.endTransmission();
|
||||||
if(error == 0){
|
if (error == 0) {
|
||||||
rtcType = DS3231;
|
rtcType = PCF8563;
|
||||||
}else{
|
} else {
|
||||||
Wire.beginTransmission(RTC_PCF_ADDR);
|
// RTC Error
|
||||||
error = Wire.endTransmission();
|
|
||||||
if(error == 0){
|
|
||||||
rtcType = PCF8563;
|
|
||||||
}else{
|
|
||||||
//RTC Error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchyRTC::config(String datetime){ //String datetime format is YYYY:MM:DD:HH:MM:SS
|
void WatchyRTC::config(
|
||||||
if(rtcType == DS3231){
|
String datetime) { // String datetime format is YYYY:MM:DD:HH:MM:SS
|
||||||
_DSConfig(datetime);
|
if (rtcType == DS3231) {
|
||||||
}else{
|
_DSConfig(datetime);
|
||||||
_PCFConfig(datetime);
|
} else {
|
||||||
}
|
_PCFConfig(datetime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchyRTC::clearAlarm(){
|
void WatchyRTC::clearAlarm() {
|
||||||
if(rtcType == DS3231){
|
if (rtcType == DS3231) {
|
||||||
rtc_ds.alarm(DS3232RTC::ALARM_2);
|
rtc_ds.alarm(DS3232RTC::ALARM_2);
|
||||||
}else{
|
} else {
|
||||||
int nextAlarmMinute = 0;
|
int nextAlarmMinute = 0;
|
||||||
rtc_pcf.clearAlarm(); //resets the alarm flag in the RTC
|
rtc_pcf.clearAlarm(); // resets the alarm flag in the RTC
|
||||||
nextAlarmMinute = rtc_pcf.getMinute();
|
nextAlarmMinute = rtc_pcf.getMinute();
|
||||||
nextAlarmMinute = (nextAlarmMinute == 59) ? 0 : (nextAlarmMinute + 1); //set alarm to trigger 1 minute from now
|
nextAlarmMinute =
|
||||||
rtc_pcf.setAlarm(nextAlarmMinute, 99, 99, 99);
|
(nextAlarmMinute == 59)
|
||||||
}
|
? 0
|
||||||
|
: (nextAlarmMinute + 1); // set alarm to trigger 1 minute from now
|
||||||
|
rtc_pcf.setAlarm(nextAlarmMinute, 99, 99, 99);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchyRTC::read(tmElements_t &tm){
|
void WatchyRTC::read(tmElements_t &tm) {
|
||||||
if(rtcType == DS3231){
|
if (rtcType == DS3231) {
|
||||||
rtc_ds.read(tm);
|
rtc_ds.read(tm);
|
||||||
}else{
|
} else {
|
||||||
tm.Year = y2kYearToTm(rtc_pcf.getYear());
|
tm.Year = y2kYearToTm(rtc_pcf.getYear());
|
||||||
tm.Month = rtc_pcf.getMonth();
|
tm.Month = rtc_pcf.getMonth();
|
||||||
tm.Day = rtc_pcf.getDay();
|
tm.Day = rtc_pcf.getDay();
|
||||||
tm.Wday = rtc_pcf.getWeekday() + 1; //TimeLib & DS3231 has Wday range of 1-7, but PCF8563 stores day of week in 0-6 range
|
tm.Wday =
|
||||||
tm.Hour = rtc_pcf.getHour();
|
rtc_pcf.getWeekday() + 1; // TimeLib & DS3231 has Wday range of 1-7, but
|
||||||
tm.Minute = rtc_pcf.getMinute();
|
// PCF8563 stores day of week in 0-6 range
|
||||||
tm.Second = rtc_pcf.getSecond();
|
tm.Hour = rtc_pcf.getHour();
|
||||||
}
|
tm.Minute = rtc_pcf.getMinute();
|
||||||
|
tm.Second = rtc_pcf.getSecond();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchyRTC::set(tmElements_t tm){
|
void WatchyRTC::set(tmElements_t tm) {
|
||||||
if(rtcType == DS3231){
|
if (rtcType == DS3231) {
|
||||||
time_t t = makeTime(tm);
|
time_t t = makeTime(tm);
|
||||||
rtc_ds.set(t);
|
rtc_ds.set(t);
|
||||||
}else{
|
} else {
|
||||||
time_t t = makeTime(tm); //make and break to calculate tm.Wday
|
time_t t = makeTime(tm); // make and break to calculate tm.Wday
|
||||||
breakTime(t, tm);
|
breakTime(t, tm);
|
||||||
//day, weekday, month, century(1=1900, 0=2000), year(0-99)
|
// day, weekday, month, century(1=1900, 0=2000), year(0-99)
|
||||||
rtc_pcf.setDate(tm.Day, tm.Wday - 1, tm.Month, 0, tmYearToY2k(tm.Year)); //TimeLib & DS3231 has Wday range of 1-7, but PCF8563 stores day of week in 0-6 range
|
rtc_pcf.setDate(
|
||||||
//hr, min, sec
|
tm.Day, tm.Wday - 1, tm.Month, 0,
|
||||||
rtc_pcf.setTime(tm.Hour, tm.Minute, tm.Second);
|
tmYearToY2k(tm.Year)); // TimeLib & DS3231 has Wday range of 1-7, but
|
||||||
clearAlarm();
|
// PCF8563 stores day of week in 0-6 range
|
||||||
}
|
// hr, min, sec
|
||||||
}
|
rtc_pcf.setTime(tm.Hour, tm.Minute, tm.Second);
|
||||||
|
|
||||||
uint8_t WatchyRTC::temperature(){
|
|
||||||
if(rtcType == DS3231){
|
|
||||||
return rtc_ds.temperature();
|
|
||||||
}else{
|
|
||||||
return 255; //error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WatchyRTC::_DSConfig(String datetime){ //String datetime is YYYY:MM:DD:HH:MM:SS
|
|
||||||
if(datetime != ""){
|
|
||||||
tmElements_t tm;
|
|
||||||
tm.Year = CalendarYrToTm(_getValue(datetime, ':', 0).toInt()); //YYYY - 1970
|
|
||||||
tm.Month = _getValue(datetime, ':', 1).toInt();
|
|
||||||
tm.Day = _getValue(datetime, ':', 2).toInt();
|
|
||||||
tm.Hour = _getValue(datetime, ':', 3).toInt();
|
|
||||||
tm.Minute = _getValue(datetime, ':', 4).toInt();
|
|
||||||
tm.Second = _getValue(datetime, ':', 5).toInt();
|
|
||||||
time_t t = makeTime(tm);
|
|
||||||
rtc_ds.set(t);
|
|
||||||
}
|
|
||||||
//https://github.com/JChristensen/DS3232RTC
|
|
||||||
rtc_ds.squareWave(DS3232RTC::SQWAVE_NONE); //disable square wave output
|
|
||||||
rtc_ds.setAlarm(DS3232RTC::ALM2_EVERY_MINUTE, 0, 0, 0, 0); //alarm wakes up Watchy every minute
|
|
||||||
rtc_ds.alarmInterrupt(DS3232RTC::ALARM_2, true); //enable alarm interrupt
|
|
||||||
}
|
|
||||||
|
|
||||||
void WatchyRTC::_PCFConfig(String datetime){ //String datetime is YYYY:MM:DD:HH:MM:SS
|
|
||||||
if(datetime != ""){
|
|
||||||
tmElements_t tm;
|
|
||||||
tm.Year = CalendarYrToTm(_getValue(datetime, ':', 0).toInt()); //YYYY - 1970
|
|
||||||
tm.Month = _getValue(datetime, ':', 1).toInt();
|
|
||||||
tm.Day = _getValue(datetime, ':', 2).toInt();
|
|
||||||
tm.Hour = _getValue(datetime, ':', 3).toInt();
|
|
||||||
tm.Minute = _getValue(datetime, ':', 4).toInt();
|
|
||||||
tm.Second = _getValue(datetime, ':', 5).toInt();
|
|
||||||
time_t t = makeTime(tm); //make and break to calculate tm.Wday
|
|
||||||
breakTime(t, tm);
|
|
||||||
//day, weekday, month, century(1=1900, 0=2000), year(0-99)
|
|
||||||
rtc_pcf.setDate(tm.Day, tm.Wday - 1, tm.Month, 0, tmYearToY2k(tm.Year)); //TimeLib & DS3231 has Wday range of 1-7, but PCF8563 stores day of week in 0-6 range
|
|
||||||
//hr, min, sec
|
|
||||||
rtc_pcf.setTime(tm.Hour, tm.Minute, tm.Second);
|
|
||||||
}
|
|
||||||
//on POR event, PCF8563 sets month to 0, which will give an error since months are 1-12
|
|
||||||
clearAlarm();
|
clearAlarm();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String WatchyRTC::_getValue(String data, char separator, int index)
|
uint8_t WatchyRTC::temperature() {
|
||||||
{
|
if (rtcType == DS3231) {
|
||||||
int found = 0;
|
return rtc_ds.temperature();
|
||||||
int strIndex[] = {0, -1};
|
} else {
|
||||||
int maxIndex = data.length()-1;
|
return 255; // error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for(int i=0; i<=maxIndex && found<=index; i++){
|
void WatchyRTC::_DSConfig(
|
||||||
if(data.charAt(i)==separator || i==maxIndex){
|
String datetime) { // String datetime is YYYY:MM:DD:HH:MM:SS
|
||||||
found++;
|
if (datetime != "") {
|
||||||
strIndex[0] = strIndex[1]+1;
|
tmElements_t tm;
|
||||||
strIndex[1] = (i == maxIndex) ? i+1 : i;
|
tm.Year = CalendarYrToTm(_getValue(datetime, ':', 0).toInt()); // YYYY -
|
||||||
|
// 1970
|
||||||
|
tm.Month = _getValue(datetime, ':', 1).toInt();
|
||||||
|
tm.Day = _getValue(datetime, ':', 2).toInt();
|
||||||
|
tm.Hour = _getValue(datetime, ':', 3).toInt();
|
||||||
|
tm.Minute = _getValue(datetime, ':', 4).toInt();
|
||||||
|
tm.Second = _getValue(datetime, ':', 5).toInt();
|
||||||
|
time_t t = makeTime(tm);
|
||||||
|
rtc_ds.set(t);
|
||||||
|
}
|
||||||
|
// https://github.com/JChristensen/DS3232RTC
|
||||||
|
rtc_ds.squareWave(DS3232RTC::SQWAVE_NONE); // disable square wave output
|
||||||
|
rtc_ds.setAlarm(DS3232RTC::ALM2_EVERY_MINUTE, 0, 0, 0,
|
||||||
|
0); // alarm wakes up Watchy every minute
|
||||||
|
rtc_ds.alarmInterrupt(DS3232RTC::ALARM_2, true); // enable alarm interrupt
|
||||||
|
}
|
||||||
|
|
||||||
|
void WatchyRTC::_PCFConfig(
|
||||||
|
String datetime) { // String datetime is YYYY:MM:DD:HH:MM:SS
|
||||||
|
if (datetime != "") {
|
||||||
|
tmElements_t tm;
|
||||||
|
tm.Year = CalendarYrToTm(_getValue(datetime, ':', 0).toInt()); // YYYY -
|
||||||
|
// 1970
|
||||||
|
tm.Month = _getValue(datetime, ':', 1).toInt();
|
||||||
|
tm.Day = _getValue(datetime, ':', 2).toInt();
|
||||||
|
tm.Hour = _getValue(datetime, ':', 3).toInt();
|
||||||
|
tm.Minute = _getValue(datetime, ':', 4).toInt();
|
||||||
|
tm.Second = _getValue(datetime, ':', 5).toInt();
|
||||||
|
time_t t = makeTime(tm); // make and break to calculate tm.Wday
|
||||||
|
breakTime(t, tm);
|
||||||
|
// day, weekday, month, century(1=1900, 0=2000), year(0-99)
|
||||||
|
rtc_pcf.setDate(
|
||||||
|
tm.Day, tm.Wday - 1, tm.Month, 0,
|
||||||
|
tmYearToY2k(tm.Year)); // TimeLib & DS3231 has Wday range of 1-7, but
|
||||||
|
// PCF8563 stores day of week in 0-6 range
|
||||||
|
// hr, min, sec
|
||||||
|
rtc_pcf.setTime(tm.Hour, tm.Minute, tm.Second);
|
||||||
|
}
|
||||||
|
// on POR event, PCF8563 sets month to 0, which will give an error since
|
||||||
|
// months are 1-12
|
||||||
|
clearAlarm();
|
||||||
|
}
|
||||||
|
|
||||||
|
String WatchyRTC::_getValue(String data, char separator, int index) {
|
||||||
|
int found = 0;
|
||||||
|
int strIndex[] = {0, -1};
|
||||||
|
int maxIndex = data.length() - 1;
|
||||||
|
|
||||||
|
for (int i = 0; i <= maxIndex && found <= index; i++) {
|
||||||
|
if (data.charAt(i) == separator || i == maxIndex) {
|
||||||
|
found++;
|
||||||
|
strIndex[0] = strIndex[1] + 1;
|
||||||
|
strIndex[1] = (i == maxIndex) ? i + 1 : i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
|
return found > index ? data.substring(strIndex[0], strIndex[1]) : "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,38 @@
|
||||||
#ifndef WATCHY_RTC_H
|
#ifndef WATCHY_RTC_H
|
||||||
#define WATCHY_RTC_H
|
#define WATCHY_RTC_H
|
||||||
|
|
||||||
#include <DS3232RTC.h>
|
|
||||||
#include <Rtc_Pcf8563.h>
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
#include <DS3232RTC.h>
|
||||||
|
#include <Rtc_Pcf8563.h>
|
||||||
|
|
||||||
#define DS3231 1
|
#define DS3231 1
|
||||||
#define PCF8563 2
|
#define PCF8563 2
|
||||||
#define RTC_DS_ADDR 0x68
|
#define RTC_DS_ADDR 0x68
|
||||||
#define RTC_PCF_ADDR 0x51
|
#define RTC_PCF_ADDR 0x51
|
||||||
#define YEAR_OFFSET_DS 1970
|
#define YEAR_OFFSET_DS 1970
|
||||||
#define YEAR_OFFSET_PCF 2000
|
#define YEAR_OFFSET_PCF 2000
|
||||||
|
|
||||||
class WatchyRTC {
|
class WatchyRTC {
|
||||||
public:
|
public:
|
||||||
DS3232RTC rtc_ds;
|
DS3232RTC rtc_ds;
|
||||||
Rtc_Pcf8563 rtc_pcf;
|
Rtc_Pcf8563 rtc_pcf;
|
||||||
uint8_t rtcType;
|
uint8_t rtcType;
|
||||||
public:
|
|
||||||
WatchyRTC();
|
public:
|
||||||
void init();
|
WatchyRTC();
|
||||||
void config(String datetime); //String datetime format is YYYY:MM:DD:HH:MM:SS
|
void init();
|
||||||
void clearAlarm();
|
void config(String datetime); // String datetime format is YYYY:MM:DD:HH:MM:SS
|
||||||
void read(tmElements_t &tm);
|
void clearAlarm();
|
||||||
void set(tmElements_t tm);
|
void read(tmElements_t &tm);
|
||||||
uint8_t temperature();
|
void set(tmElements_t tm);
|
||||||
private:
|
uint8_t temperature();
|
||||||
void _DSConfig(String datetime);
|
|
||||||
void _PCFConfig(String datetime);
|
private:
|
||||||
int _getDayOfWeek(int d, int m, int y);
|
void _DSConfig(String datetime);
|
||||||
String _getValue(String data, char separator, int index);
|
void _PCFConfig(String datetime);
|
||||||
|
int _getDayOfWeek(int d, int m, int y);
|
||||||
|
String _getValue(String data, char separator, int index);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
544
src/bma.cpp
544
src/bma.cpp
|
@ -2,328 +2,282 @@
|
||||||
|
|
||||||
#define DEBUGPORT Serial
|
#define DEBUGPORT Serial
|
||||||
#ifdef DEBUGPORT
|
#ifdef DEBUGPORT
|
||||||
#define DEBUG(...) DEBUGPORT.printf(__VA_ARGS__)
|
#define DEBUG(...) DEBUGPORT.printf(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define DEBUG(...)
|
#define DEBUG(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BMA423::BMA423()
|
BMA423::BMA423() {
|
||||||
{
|
__readRegisterFptr = nullptr;
|
||||||
__readRegisterFptr = nullptr;
|
__writeRegisterFptr = nullptr;
|
||||||
__writeRegisterFptr = nullptr;
|
__delayCallBlackFptr = nullptr;
|
||||||
__delayCallBlackFptr = nullptr;
|
__init = false;
|
||||||
__init = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BMA423::~BMA423()
|
BMA423::~BMA423() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::begin(bma4_com_fptr_t readCallBlack,
|
bool BMA423::begin(bma4_com_fptr_t readCallBlack,
|
||||||
bma4_com_fptr_t writeCallBlack,
|
bma4_com_fptr_t writeCallBlack,
|
||||||
bma4_delay_fptr_t delayCallBlack,
|
bma4_delay_fptr_t delayCallBlack, uint8_t address) {
|
||||||
uint8_t address)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (__init ||
|
if (__init || readCallBlack == nullptr || writeCallBlack == nullptr ||
|
||||||
readCallBlack == nullptr ||
|
delayCallBlack == nullptr) {
|
||||||
writeCallBlack == nullptr ||
|
|
||||||
delayCallBlack == nullptr) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
__readRegisterFptr = readCallBlack;
|
|
||||||
__writeRegisterFptr = writeCallBlack;
|
|
||||||
__delayCallBlackFptr = delayCallBlack;
|
|
||||||
|
|
||||||
__devFptr.dev_addr = address;
|
|
||||||
__devFptr.interface = BMA4_I2C_INTERFACE;
|
|
||||||
__devFptr.bus_read = readCallBlack;
|
|
||||||
__devFptr.bus_write = writeCallBlack;
|
|
||||||
__devFptr.delay = delayCallBlack;
|
|
||||||
__devFptr.read_write_len = 8;
|
|
||||||
__devFptr.resolution = 12;
|
|
||||||
__devFptr.feature_len = BMA423_FEATURE_SIZE;
|
|
||||||
|
|
||||||
softReset();
|
|
||||||
|
|
||||||
__delayCallBlackFptr(20);
|
|
||||||
|
|
||||||
if (bma423_init(&__devFptr) != BMA4_OK) {
|
|
||||||
DEBUG("BMA423 FAIL\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bma423_write_config_file(&__devFptr) != BMA4_OK) {
|
|
||||||
DEBUG("BMA423 Write Config FAIL\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
__init = true;
|
|
||||||
|
|
||||||
struct bma4_int_pin_config config ;
|
|
||||||
config.edge_ctrl = BMA4_LEVEL_TRIGGER;
|
|
||||||
config.lvl = BMA4_ACTIVE_HIGH;
|
|
||||||
config.od = BMA4_PUSH_PULL;
|
|
||||||
config.output_en = BMA4_OUTPUT_ENABLE;
|
|
||||||
config.input_en = BMA4_INPUT_DISABLE;
|
|
||||||
|
|
||||||
|
|
||||||
if (bma4_set_int_pin_config(&config, BMA4_INTR1_MAP, &__devFptr) != BMA4_OK) {
|
|
||||||
DEBUG("BMA423 SET INT FAIL\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
__readRegisterFptr = readCallBlack;
|
||||||
|
__writeRegisterFptr = writeCallBlack;
|
||||||
|
__delayCallBlackFptr = delayCallBlack;
|
||||||
|
|
||||||
|
__devFptr.dev_addr = address;
|
||||||
|
__devFptr.interface = BMA4_I2C_INTERFACE;
|
||||||
|
__devFptr.bus_read = readCallBlack;
|
||||||
|
__devFptr.bus_write = writeCallBlack;
|
||||||
|
__devFptr.delay = delayCallBlack;
|
||||||
|
__devFptr.read_write_len = 8;
|
||||||
|
__devFptr.resolution = 12;
|
||||||
|
__devFptr.feature_len = BMA423_FEATURE_SIZE;
|
||||||
|
|
||||||
|
softReset();
|
||||||
|
|
||||||
|
__delayCallBlackFptr(20);
|
||||||
|
|
||||||
|
if (bma423_init(&__devFptr) != BMA4_OK) {
|
||||||
|
DEBUG("BMA423 FAIL\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bma423_write_config_file(&__devFptr) != BMA4_OK) {
|
||||||
|
DEBUG("BMA423 Write Config FAIL\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
__init = true;
|
||||||
|
|
||||||
|
struct bma4_int_pin_config config;
|
||||||
|
config.edge_ctrl = BMA4_LEVEL_TRIGGER;
|
||||||
|
config.lvl = BMA4_ACTIVE_HIGH;
|
||||||
|
config.od = BMA4_PUSH_PULL;
|
||||||
|
config.output_en = BMA4_OUTPUT_ENABLE;
|
||||||
|
config.input_en = BMA4_INPUT_DISABLE;
|
||||||
|
|
||||||
|
if (bma4_set_int_pin_config(&config, BMA4_INTR1_MAP, &__devFptr) != BMA4_OK) {
|
||||||
|
DEBUG("BMA423 SET INT FAIL\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BMA423::softReset()
|
void BMA423::softReset() {
|
||||||
{
|
uint8_t reg = BMA4_RESET_ADDR;
|
||||||
uint8_t reg = BMA4_RESET_ADDR;
|
__writeRegisterFptr(BMA4_I2C_ADDR_PRIMARY, BMA4_RESET_SET_MASK, ®, 1);
|
||||||
__writeRegisterFptr(BMA4_I2C_ADDR_PRIMARY, BMA4_RESET_SET_MASK, ®, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BMA423::shutDown()
|
void BMA423::shutDown() {
|
||||||
{
|
bma4_set_advance_power_save(BMA4_DISABLE, &__devFptr);
|
||||||
bma4_set_advance_power_save(BMA4_DISABLE, &__devFptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BMA423::wakeUp()
|
void BMA423::wakeUp() { bma4_set_advance_power_save(BMA4_ENABLE, &__devFptr); }
|
||||||
{
|
|
||||||
bma4_set_advance_power_save(BMA4_ENABLE, &__devFptr);
|
uint16_t BMA423::getErrorCode() {
|
||||||
|
struct bma4_err_reg err;
|
||||||
|
uint16_t rslt = bma4_get_error_status(&err, &__devFptr);
|
||||||
|
return rslt;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t BMA423::getErrorCode()
|
uint16_t BMA423::getStatus() {
|
||||||
{
|
uint8_t status;
|
||||||
struct bma4_err_reg err;
|
bma4_get_status(&status, &__devFptr);
|
||||||
uint16_t rslt = bma4_get_error_status(&err, &__devFptr);
|
return status;
|
||||||
return rslt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t BMA423::getStatus()
|
uint32_t BMA423::getSensorTime() {
|
||||||
{
|
uint32_t ms;
|
||||||
uint8_t status;
|
bma4_get_sensor_time(&ms, &__devFptr);
|
||||||
bma4_get_status(&status, &__devFptr);
|
return ms;
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t BMA423::getSensorTime()
|
bool BMA423::selfTest() {
|
||||||
{
|
return (BMA4_OK ==
|
||||||
uint32_t ms;
|
bma4_selftest_config(BMA4_ACCEL_SELFTEST_ENABLE_MSK, &__devFptr));
|
||||||
bma4_get_sensor_time(&ms, &__devFptr);
|
|
||||||
return ms;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BMA423::selfTest()
|
uint8_t BMA423::getDirection() {
|
||||||
{
|
Accel acc;
|
||||||
return (BMA4_OK == bma4_selftest_config(BMA4_ACCEL_SELFTEST_ENABLE_MSK, &__devFptr));
|
if (bma4_read_accel_xyz(&acc, &__devFptr) != BMA4_OK) {
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t BMA423::getDirection()
|
|
||||||
{
|
|
||||||
Accel acc;
|
|
||||||
if (bma4_read_accel_xyz(&acc, &__devFptr) != BMA4_OK) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
uint16_t absX = abs(acc.x);
|
|
||||||
uint16_t absY = abs(acc.y);
|
|
||||||
uint16_t absZ = abs(acc.z);
|
|
||||||
|
|
||||||
if ((absZ > absX) && (absZ > absY)) {
|
|
||||||
if (acc.z > 0) {
|
|
||||||
return DIRECTION_DISP_DOWN;
|
|
||||||
} else {
|
|
||||||
return DIRECTION_DISP_UP;
|
|
||||||
}
|
|
||||||
} else if ((absY > absX) && (absY > absZ)) {
|
|
||||||
if (acc.y > 0) {
|
|
||||||
return DIRECTION_RIGHT_EDGE;
|
|
||||||
} else {
|
|
||||||
return DIRECTION_LEFT_EDGE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (acc.x < 0) {
|
|
||||||
return DIRECTION_BOTTOM_EDGE;
|
|
||||||
} else {
|
|
||||||
return DIRECTION_TOP_EDGE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float BMA423::readTemperature()
|
|
||||||
{
|
|
||||||
int32_t data = 0;
|
|
||||||
bma4_get_temperature(&data, BMA4_DEG, &__devFptr);
|
|
||||||
float res = (float)data / (float)BMA4_SCALE_TEMP;
|
|
||||||
/* 0x80 - temp read from the register and 23 is the ambient temp added.
|
|
||||||
* If the temp read from register is 0x80, it means no valid
|
|
||||||
* information is available */
|
|
||||||
if (((data - 23) / BMA4_SCALE_TEMP) == 0x80) {
|
|
||||||
res = 0;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
float BMA423::readTemperatureF()
|
|
||||||
{
|
|
||||||
float temp = readTemperature();
|
|
||||||
if (temp != 0) {
|
|
||||||
temp = temp * 1.8 + 32.0;
|
|
||||||
}
|
|
||||||
return (temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::getAccel(Accel &acc)
|
|
||||||
{
|
|
||||||
memset(&acc, 0, sizeof(acc));
|
|
||||||
if (bma4_read_accel_xyz(&acc, &__devFptr) != BMA4_OK) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::getAccelEnable()
|
|
||||||
{
|
|
||||||
uint8_t en;
|
|
||||||
bma4_get_accel_enable(&en, &__devFptr);
|
|
||||||
return (en & BMA4_ACCEL_ENABLE_POS) == BMA4_ACCEL_ENABLE_POS;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::disableAccel()
|
|
||||||
{
|
|
||||||
return enableAccel(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::enableAccel(bool en)
|
|
||||||
{
|
|
||||||
return (BMA4_OK == bma4_set_accel_enable(en ? BMA4_ENABLE : BMA4_DISABLE, &__devFptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::setAccelConfig(Acfg &cfg)
|
|
||||||
{
|
|
||||||
return (BMA4_OK == bma4_set_accel_config(&cfg, &__devFptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::getAccelConfig(Acfg &cfg)
|
|
||||||
{
|
|
||||||
return (BMA4_OK == bma4_get_accel_config(&cfg, &__devFptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::setRemapAxes(struct bma423_axes_remap *remap_data)
|
|
||||||
{
|
|
||||||
return (BMA4_OK == bma423_set_remap_axes(remap_data, &__devFptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::resetStepCounter()
|
|
||||||
{
|
|
||||||
return BMA4_OK == bma423_reset_step_counter(&__devFptr) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t BMA423::getCounter()
|
|
||||||
{
|
|
||||||
uint32_t stepCount;
|
|
||||||
if (bma423_step_counter_output(&stepCount, &__devFptr) == BMA4_OK) {
|
|
||||||
return stepCount;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
uint16_t absX = abs(acc.x);
|
||||||
|
uint16_t absY = abs(acc.y);
|
||||||
|
uint16_t absZ = abs(acc.z);
|
||||||
|
|
||||||
bool BMA423::setINTPinConfig(struct bma4_int_pin_config config, uint8_t pinMap)
|
if ((absZ > absX) && (absZ > absY)) {
|
||||||
{
|
if (acc.z > 0) {
|
||||||
return BMA4_OK == bma4_set_int_pin_config(&config, pinMap, &__devFptr);
|
return DIRECTION_DISP_DOWN;
|
||||||
}
|
} else {
|
||||||
|
return DIRECTION_DISP_UP;
|
||||||
bool BMA423::getINT()
|
|
||||||
{
|
|
||||||
return bma423_read_int_status(&__IRQ_MASK, &__devFptr) == BMA4_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t BMA423::getIRQMASK()
|
|
||||||
{
|
|
||||||
return __IRQ_MASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::disableIRQ(uint16_t int_map)
|
|
||||||
{
|
|
||||||
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, int_map, BMA4_DISABLE, &__devFptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::enableIRQ(uint16_t int_map)
|
|
||||||
{
|
|
||||||
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, int_map, BMA4_ENABLE, &__devFptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::enableFeature(uint8_t feature, uint8_t enable)
|
|
||||||
{
|
|
||||||
if ((feature & BMA423_STEP_CNTR) == BMA423_STEP_CNTR) {
|
|
||||||
bma423_step_detector_enable(enable ? BMA4_ENABLE : BMA4_DISABLE, &__devFptr);
|
|
||||||
}
|
}
|
||||||
return (BMA4_OK == bma423_feature_enable(feature, enable, &__devFptr));
|
} else if ((absY > absX) && (absY > absZ)) {
|
||||||
}
|
if (acc.y > 0) {
|
||||||
|
return DIRECTION_RIGHT_EDGE;
|
||||||
bool BMA423::isStepCounter()
|
} else {
|
||||||
{
|
return DIRECTION_LEFT_EDGE;
|
||||||
return (bool)(BMA423_STEP_CNTR_INT & __IRQ_MASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::isDoubleClick()
|
|
||||||
{
|
|
||||||
return (bool)(BMA423_WAKEUP_INT & __IRQ_MASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::isTilt()
|
|
||||||
{
|
|
||||||
return (bool)(BMA423_TILT_INT & __IRQ_MASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::isActivity()
|
|
||||||
{
|
|
||||||
return (bool)(BMA423_ACTIVITY_INT & __IRQ_MASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::isAnyNoMotion()
|
|
||||||
{
|
|
||||||
return (bool)(BMA423_ANY_NO_MOTION_INT & __IRQ_MASK);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::enableStepCountInterrupt(bool en)
|
|
||||||
{
|
|
||||||
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_STEP_CNTR_INT, en, &__devFptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::enableTiltInterrupt(bool en)
|
|
||||||
{
|
|
||||||
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_TILT_INT, en, &__devFptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::enableWakeupInterrupt(bool en)
|
|
||||||
{
|
|
||||||
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_WAKEUP_INT, en, &__devFptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::enableAnyNoMotionInterrupt(bool en)
|
|
||||||
{
|
|
||||||
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_ANY_NO_MOTION_INT, en, &__devFptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMA423::enableActivityInterrupt(bool en)
|
|
||||||
{
|
|
||||||
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_ACTIVITY_INT, en, &__devFptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *BMA423::getActivity()
|
|
||||||
{
|
|
||||||
uint8_t activity;
|
|
||||||
bma423_activity_output(&activity, &__devFptr);
|
|
||||||
if (activity & BMA423_USER_STATIONARY) {
|
|
||||||
return "BMA423_USER_STATIONARY";
|
|
||||||
} else if (activity & BMA423_USER_WALKING) {
|
|
||||||
return "BMA423_USER_WALKING";
|
|
||||||
} else if (activity & BMA423_USER_RUNNING) {
|
|
||||||
return "BMA423_USER_RUNNING";
|
|
||||||
} else if (activity & BMA423_STATE_INVALID) {
|
|
||||||
return "BMA423_STATE_INVALID";
|
|
||||||
}
|
}
|
||||||
return "None";
|
} else {
|
||||||
|
if (acc.x < 0) {
|
||||||
|
return DIRECTION_BOTTOM_EDGE;
|
||||||
|
} else {
|
||||||
|
return DIRECTION_TOP_EDGE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float BMA423::readTemperature() {
|
||||||
|
int32_t data = 0;
|
||||||
|
bma4_get_temperature(&data, BMA4_DEG, &__devFptr);
|
||||||
|
float res = (float)data / (float)BMA4_SCALE_TEMP;
|
||||||
|
/* 0x80 - temp read from the register and 23 is the ambient temp added.
|
||||||
|
* If the temp read from register is 0x80, it means no valid
|
||||||
|
* information is available */
|
||||||
|
if (((data - 23) / BMA4_SCALE_TEMP) == 0x80) {
|
||||||
|
res = 0;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
float BMA423::readTemperatureF() {
|
||||||
|
float temp = readTemperature();
|
||||||
|
if (temp != 0) {
|
||||||
|
temp = temp * 1.8 + 32.0;
|
||||||
|
}
|
||||||
|
return (temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::getAccel(Accel &acc) {
|
||||||
|
memset(&acc, 0, sizeof(acc));
|
||||||
|
if (bma4_read_accel_xyz(&acc, &__devFptr) != BMA4_OK) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::getAccelEnable() {
|
||||||
|
uint8_t en;
|
||||||
|
bma4_get_accel_enable(&en, &__devFptr);
|
||||||
|
return (en & BMA4_ACCEL_ENABLE_POS) == BMA4_ACCEL_ENABLE_POS;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::disableAccel() { return enableAccel(false); }
|
||||||
|
|
||||||
|
bool BMA423::enableAccel(bool en) {
|
||||||
|
return (BMA4_OK ==
|
||||||
|
bma4_set_accel_enable(en ? BMA4_ENABLE : BMA4_DISABLE, &__devFptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::setAccelConfig(Acfg &cfg) {
|
||||||
|
return (BMA4_OK == bma4_set_accel_config(&cfg, &__devFptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::getAccelConfig(Acfg &cfg) {
|
||||||
|
return (BMA4_OK == bma4_get_accel_config(&cfg, &__devFptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::setRemapAxes(struct bma423_axes_remap *remap_data) {
|
||||||
|
return (BMA4_OK == bma423_set_remap_axes(remap_data, &__devFptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::resetStepCounter() {
|
||||||
|
return BMA4_OK == bma423_reset_step_counter(&__devFptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t BMA423::getCounter() {
|
||||||
|
uint32_t stepCount;
|
||||||
|
if (bma423_step_counter_output(&stepCount, &__devFptr) == BMA4_OK) {
|
||||||
|
return stepCount;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::setINTPinConfig(struct bma4_int_pin_config config,
|
||||||
|
uint8_t pinMap) {
|
||||||
|
return BMA4_OK == bma4_set_int_pin_config(&config, pinMap, &__devFptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::getINT() {
|
||||||
|
return bma423_read_int_status(&__IRQ_MASK, &__devFptr) == BMA4_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t BMA423::getIRQMASK() { return __IRQ_MASK; }
|
||||||
|
|
||||||
|
bool BMA423::disableIRQ(uint16_t int_map) {
|
||||||
|
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, int_map, BMA4_DISABLE,
|
||||||
|
&__devFptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::enableIRQ(uint16_t int_map) {
|
||||||
|
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, int_map, BMA4_ENABLE,
|
||||||
|
&__devFptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::enableFeature(uint8_t feature, uint8_t enable) {
|
||||||
|
if ((feature & BMA423_STEP_CNTR) == BMA423_STEP_CNTR) {
|
||||||
|
bma423_step_detector_enable(enable ? BMA4_ENABLE : BMA4_DISABLE,
|
||||||
|
&__devFptr);
|
||||||
|
}
|
||||||
|
return (BMA4_OK == bma423_feature_enable(feature, enable, &__devFptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::isStepCounter() {
|
||||||
|
return (bool)(BMA423_STEP_CNTR_INT & __IRQ_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::isDoubleClick() { return (bool)(BMA423_WAKEUP_INT & __IRQ_MASK); }
|
||||||
|
|
||||||
|
bool BMA423::isTilt() { return (bool)(BMA423_TILT_INT & __IRQ_MASK); }
|
||||||
|
|
||||||
|
bool BMA423::isActivity() { return (bool)(BMA423_ACTIVITY_INT & __IRQ_MASK); }
|
||||||
|
|
||||||
|
bool BMA423::isAnyNoMotion() {
|
||||||
|
return (bool)(BMA423_ANY_NO_MOTION_INT & __IRQ_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::enableStepCountInterrupt(bool en) {
|
||||||
|
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_STEP_CNTR_INT,
|
||||||
|
en, &__devFptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::enableTiltInterrupt(bool en) {
|
||||||
|
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_TILT_INT, en,
|
||||||
|
&__devFptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::enableWakeupInterrupt(bool en) {
|
||||||
|
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_WAKEUP_INT, en,
|
||||||
|
&__devFptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::enableAnyNoMotionInterrupt(bool en) {
|
||||||
|
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP,
|
||||||
|
BMA423_ANY_NO_MOTION_INT, en,
|
||||||
|
&__devFptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMA423::enableActivityInterrupt(bool en) {
|
||||||
|
return (BMA4_OK == bma423_map_interrupt(BMA4_INTR1_MAP, BMA423_ACTIVITY_INT,
|
||||||
|
en, &__devFptr));
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *BMA423::getActivity() {
|
||||||
|
uint8_t activity;
|
||||||
|
bma423_activity_output(&activity, &__devFptr);
|
||||||
|
if (activity & BMA423_USER_STATIONARY) {
|
||||||
|
return "BMA423_USER_STATIONARY";
|
||||||
|
} else if (activity & BMA423_USER_WALKING) {
|
||||||
|
return "BMA423_USER_WALKING";
|
||||||
|
} else if (activity & BMA423_USER_RUNNING) {
|
||||||
|
return "BMA423_USER_RUNNING";
|
||||||
|
} else if (activity & BMA423_STATE_INVALID) {
|
||||||
|
return "BMA423_STATE_INVALID";
|
||||||
|
}
|
||||||
|
return "None";
|
||||||
}
|
}
|
115
src/bma.h
115
src/bma.h
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#else
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -9,80 +9,79 @@
|
||||||
#include "bma423.h"
|
#include "bma423.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
DIRECTION_TOP_EDGE = 0,
|
DIRECTION_TOP_EDGE = 0,
|
||||||
DIRECTION_BOTTOM_EDGE = 1,
|
DIRECTION_BOTTOM_EDGE = 1,
|
||||||
DIRECTION_LEFT_EDGE = 2,
|
DIRECTION_LEFT_EDGE = 2,
|
||||||
DIRECTION_RIGHT_EDGE = 3,
|
DIRECTION_RIGHT_EDGE = 3,
|
||||||
DIRECTION_DISP_UP = 4,
|
DIRECTION_DISP_UP = 4,
|
||||||
DIRECTION_DISP_DOWN = 5
|
DIRECTION_DISP_DOWN = 5
|
||||||
} ;
|
};
|
||||||
|
|
||||||
typedef struct bma4_accel Accel;
|
typedef struct bma4_accel Accel;
|
||||||
typedef struct bma4_accel_config Acfg;
|
typedef struct bma4_accel_config Acfg;
|
||||||
|
|
||||||
class BMA423
|
class BMA423 {
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BMA423();
|
BMA423();
|
||||||
~BMA423();
|
~BMA423();
|
||||||
|
|
||||||
bool begin(bma4_com_fptr_t readCallBlack, bma4_com_fptr_t writeCallBlack, bma4_delay_fptr_t delayCallBlack,
|
bool begin(bma4_com_fptr_t readCallBlack, bma4_com_fptr_t writeCallBlack,
|
||||||
uint8_t address = BMA4_I2C_ADDR_PRIMARY);
|
bma4_delay_fptr_t delayCallBlack,
|
||||||
|
uint8_t address = BMA4_I2C_ADDR_PRIMARY);
|
||||||
|
|
||||||
void softReset();
|
void softReset();
|
||||||
void shutDown();
|
void shutDown();
|
||||||
void wakeUp();
|
void wakeUp();
|
||||||
bool selfTest();
|
bool selfTest();
|
||||||
|
|
||||||
uint8_t getDirection();
|
uint8_t getDirection();
|
||||||
|
|
||||||
bool setAccelConfig(Acfg &cfg);
|
bool setAccelConfig(Acfg &cfg);
|
||||||
bool getAccelConfig(Acfg &cfg);
|
bool getAccelConfig(Acfg &cfg);
|
||||||
bool getAccel(Accel &acc);
|
bool getAccel(Accel &acc);
|
||||||
bool getAccelEnable();
|
bool getAccelEnable();
|
||||||
bool disableAccel();
|
bool disableAccel();
|
||||||
bool enableAccel(bool en = true);
|
bool enableAccel(bool en = true);
|
||||||
|
|
||||||
bool setINTPinConfig(struct bma4_int_pin_config config, uint8_t pinMap);
|
bool setINTPinConfig(struct bma4_int_pin_config config, uint8_t pinMap);
|
||||||
bool getINT();
|
bool getINT();
|
||||||
uint8_t getIRQMASK();
|
uint8_t getIRQMASK();
|
||||||
bool disableIRQ(uint16_t int_map = BMA423_STEP_CNTR_INT);
|
bool disableIRQ(uint16_t int_map = BMA423_STEP_CNTR_INT);
|
||||||
bool enableIRQ(uint16_t int_map = BMA423_STEP_CNTR_INT);
|
bool enableIRQ(uint16_t int_map = BMA423_STEP_CNTR_INT);
|
||||||
bool isStepCounter();
|
bool isStepCounter();
|
||||||
bool isDoubleClick();
|
bool isDoubleClick();
|
||||||
bool isTilt();
|
bool isTilt();
|
||||||
bool isActivity();
|
bool isActivity();
|
||||||
bool isAnyNoMotion();
|
bool isAnyNoMotion();
|
||||||
|
|
||||||
bool resetStepCounter();
|
bool resetStepCounter();
|
||||||
uint32_t getCounter();
|
uint32_t getCounter();
|
||||||
|
|
||||||
float readTemperature();
|
float readTemperature();
|
||||||
float readTemperatureF();
|
float readTemperatureF();
|
||||||
|
|
||||||
uint16_t getErrorCode();
|
uint16_t getErrorCode();
|
||||||
uint16_t getStatus();
|
uint16_t getStatus();
|
||||||
uint32_t getSensorTime();
|
uint32_t getSensorTime();
|
||||||
|
|
||||||
|
const char *getActivity();
|
||||||
|
bool setRemapAxes(struct bma423_axes_remap *remap_data);
|
||||||
|
|
||||||
const char *getActivity();
|
bool enableFeature(uint8_t feature, uint8_t enable);
|
||||||
bool setRemapAxes(struct bma423_axes_remap *remap_data);
|
bool enableStepCountInterrupt(bool en = true);
|
||||||
|
bool enableTiltInterrupt(bool en = true);
|
||||||
bool enableFeature(uint8_t feature, uint8_t enable );
|
bool enableWakeupInterrupt(bool en = true);
|
||||||
bool enableStepCountInterrupt(bool en = true);
|
bool enableAnyNoMotionInterrupt(bool en = true);
|
||||||
bool enableTiltInterrupt(bool en = true);
|
bool enableActivityInterrupt(bool en = true);
|
||||||
bool enableWakeupInterrupt(bool en = true);
|
|
||||||
bool enableAnyNoMotionInterrupt(bool en = true);
|
|
||||||
bool enableActivityInterrupt(bool en = true);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bma4_com_fptr_t __readRegisterFptr;
|
bma4_com_fptr_t __readRegisterFptr;
|
||||||
bma4_com_fptr_t __writeRegisterFptr;
|
bma4_com_fptr_t __writeRegisterFptr;
|
||||||
bma4_delay_fptr_t __delayCallBlackFptr;
|
bma4_delay_fptr_t __delayCallBlackFptr;
|
||||||
|
|
||||||
uint8_t __address;
|
uint8_t __address;
|
||||||
uint16_t __IRQ_MASK;
|
uint16_t __IRQ_MASK;
|
||||||
bool __init;
|
bool __init;
|
||||||
struct bma4_dev __devFptr;
|
struct bma4_dev __devFptr;
|
||||||
};
|
};
|
||||||
|
|
4970
src/bma4.c
4970
src/bma4.c
File diff suppressed because it is too large
Load Diff
263
src/bma4.h
263
src/bma4.h
|
@ -1,91 +1,91 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
* Copyright (C) 2015 - 2016 Bosch Sensortec GmbH
|
* Copyright (C) 2015 - 2016 Bosch Sensortec GmbH
|
||||||
*
|
*
|
||||||
* File : bma4.h
|
* File : bma4.h
|
||||||
*
|
*
|
||||||
* Date: 12 Oct 2017
|
* Date: 12 Oct 2017
|
||||||
*
|
*
|
||||||
* Revision: 2.1.9 $
|
* Revision: 2.1.9 $
|
||||||
*
|
*
|
||||||
* Usage: Sensor Driver for BMA4 family of sensors
|
* Usage: Sensor Driver for BMA4 family of sensors
|
||||||
*
|
*
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*
|
*
|
||||||
* Disclaimer
|
* Disclaimer
|
||||||
*
|
*
|
||||||
* Common:
|
* Common:
|
||||||
* Bosch Sensortec products are developed for the consumer goods industry.
|
* Bosch Sensortec products are developed for the consumer goods industry.
|
||||||
* They may only be used within the parameters of the respective valid
|
* They may only be used within the parameters of the respective valid
|
||||||
* product data sheet. Bosch Sensortec products are provided with the
|
* product data sheet. Bosch Sensortec products are provided with the
|
||||||
* express understanding that there is no warranty of fitness for a
|
* express understanding that there is no warranty of fitness for a
|
||||||
* particular purpose.They are not fit for use in life-sustaining,
|
* particular purpose.They are not fit for use in life-sustaining,
|
||||||
* safety or security sensitive systems or any system or device
|
* safety or security sensitive systems or any system or device
|
||||||
* that may lead to bodily harm or property damage if the system
|
* that may lead to bodily harm or property damage if the system
|
||||||
* or device malfunctions. In addition,Bosch Sensortec products are
|
* or device malfunctions. In addition,Bosch Sensortec products are
|
||||||
* not fit for use in products which interact with motor vehicle systems.
|
* not fit for use in products which interact with motor vehicle systems.
|
||||||
* The resale and or use of products are at the purchasers own risk and
|
* The resale and or use of products are at the purchasers own risk and
|
||||||
* his own responsibility. The examination of fitness for the intended use
|
* his own responsibility. The examination of fitness for the intended use
|
||||||
* is the sole responsibility of the Purchaser.
|
* is the sole responsibility of the Purchaser.
|
||||||
*
|
*
|
||||||
* The purchaser shall indemnify Bosch Sensortec from all third party
|
* The purchaser shall indemnify Bosch Sensortec from all third party
|
||||||
* claims, including any claims for incidental, or consequential damages,
|
* claims, including any claims for incidental, or consequential damages,
|
||||||
* arising from any product use not covered by the parameters of
|
* arising from any product use not covered by the parameters of
|
||||||
* the respective valid product data sheet or not approved by
|
* the respective valid product data sheet or not approved by
|
||||||
* Bosch Sensortec and reimburse Bosch Sensortec for all costs in
|
* Bosch Sensortec and reimburse Bosch Sensortec for all costs in
|
||||||
* connection with such claims.
|
* connection with such claims.
|
||||||
*
|
*
|
||||||
* The purchaser must monitor the market for the purchased products,
|
* The purchaser must monitor the market for the purchased products,
|
||||||
* particularly with regard to product safety and inform Bosch Sensortec
|
* particularly with regard to product safety and inform Bosch Sensortec
|
||||||
* without delay of all security relevant incidents.
|
* without delay of all security relevant incidents.
|
||||||
*
|
*
|
||||||
* Engineering Samples are marked with an asterisk (*) or (e).
|
* Engineering Samples are marked with an asterisk (*) or (e).
|
||||||
* Samples may vary from the valid technical specifications of the product
|
* Samples may vary from the valid technical specifications of the product
|
||||||
* series. They are therefore not intended or fit for resale to third
|
* series. They are therefore not intended or fit for resale to third
|
||||||
* parties or for use in end products. Their sole purpose is internal
|
* parties or for use in end products. Their sole purpose is internal
|
||||||
* client testing. The testing of an engineering sample may in no way
|
* client testing. The testing of an engineering sample may in no way
|
||||||
* replace the testing of a product series. Bosch Sensortec assumes
|
* replace the testing of a product series. Bosch Sensortec assumes
|
||||||
* no liability for the use of engineering samples.
|
* no liability for the use of engineering samples.
|
||||||
* By accepting the engineering samples, the Purchaser agrees to indemnify
|
* By accepting the engineering samples, the Purchaser agrees to indemnify
|
||||||
* Bosch Sensortec from all claims arising from the use of engineering
|
* Bosch Sensortec from all claims arising from the use of engineering
|
||||||
* samples.
|
* samples.
|
||||||
*
|
*
|
||||||
* Special:
|
* Special:
|
||||||
* This software module (hereinafter called "Software") and any information
|
* This software module (hereinafter called "Software") and any information
|
||||||
* on application-sheets (hereinafter called "Information") is provided
|
* on application-sheets (hereinafter called "Information") is provided
|
||||||
* free of charge for the sole purpose to support your application work.
|
* free of charge for the sole purpose to support your application work.
|
||||||
* The Software and Information is subject to the following
|
* The Software and Information is subject to the following
|
||||||
* terms and conditions:
|
* terms and conditions:
|
||||||
*
|
*
|
||||||
* The Software is specifically designed for the exclusive use for
|
* The Software is specifically designed for the exclusive use for
|
||||||
* Bosch Sensortec products by personnel who have special experience
|
* Bosch Sensortec products by personnel who have special experience
|
||||||
* and training. Do not use this Software if you do not have the
|
* and training. Do not use this Software if you do not have the
|
||||||
* proper experience or training.
|
* proper experience or training.
|
||||||
*
|
*
|
||||||
* This Software package is provided `` as is `` and without any expressed
|
* This Software package is provided `` as is `` and without any expressed
|
||||||
* or implied warranties,including without limitation, the implied warranties
|
* or implied warranties,including without limitation, the implied warranties
|
||||||
* of merchantability and fitness for a particular purpose.
|
* of merchantability and fitness for a particular purpose.
|
||||||
*
|
*
|
||||||
* Bosch Sensortec and their representatives and agents deny any liability
|
* Bosch Sensortec and their representatives and agents deny any liability
|
||||||
* for the functional impairment
|
* for the functional impairment
|
||||||
* of this Software in terms of fitness, performance and safety.
|
* of this Software in terms of fitness, performance and safety.
|
||||||
* Bosch Sensortec and their representatives and agents shall not be liable
|
* Bosch Sensortec and their representatives and agents shall not be liable
|
||||||
* for any direct or indirect damages or injury, except as
|
* for any direct or indirect damages or injury, except as
|
||||||
* otherwise stipulated in mandatory applicable law.
|
* otherwise stipulated in mandatory applicable law.
|
||||||
*
|
*
|
||||||
* The Information provided is believed to be accurate and reliable.
|
* The Information provided is believed to be accurate and reliable.
|
||||||
* Bosch Sensortec assumes no responsibility for the consequences of use
|
* Bosch Sensortec assumes no responsibility for the consequences of use
|
||||||
* of such Information nor for any infringement of patents or
|
* of such Information nor for any infringement of patents or
|
||||||
* other rights of third parties which may result from its use.
|
* other rights of third parties which may result from its use.
|
||||||
* No license is granted by implication or otherwise under any patent or
|
* No license is granted by implication or otherwise under any patent or
|
||||||
* patent rights of Bosch. Specifications mentioned in the Information are
|
* patent rights of Bosch. Specifications mentioned in the Information are
|
||||||
* subject to change without notice.
|
* subject to change without notice.
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
/*! \file bma4.h
|
/*! \file bma4.h
|
||||||
\brief Sensor Driver for BMA4 family of sensors */
|
\brief Sensor Driver for BMA4 family of sensors */
|
||||||
#ifndef BMA4_H__
|
#ifndef BMA4_H__
|
||||||
#define BMA4_H__
|
#define BMA4_H__
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* header files */
|
/* header files */
|
||||||
|
@ -157,7 +157,8 @@ uint16_t bma4_write_config_file(struct bma4_dev *dev);
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_write_regs(uint8_t addr, uint8_t *data, uint8_t len, struct bma4_dev *dev);
|
uint16_t bma4_write_regs(uint8_t addr, uint8_t *data, uint8_t len,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API checks whether the read operation requested is for
|
* @brief This API checks whether the read operation requested is for
|
||||||
|
@ -172,7 +173,8 @@ uint16_t bma4_write_regs(uint8_t addr, uint8_t *data, uint8_t len, struct bma4_d
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_read_regs(uint8_t addr, uint8_t *data, uint8_t len, struct bma4_dev *dev);
|
uint16_t bma4_read_regs(uint8_t addr, uint8_t *data, uint8_t len,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API reads the error status from the sensor.
|
* @brief This API reads the error status from the sensor.
|
||||||
|
@ -211,7 +213,8 @@ uint16_t bma4_read_regs(uint8_t addr, uint8_t *data, uint8_t len, struct bma4_de
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_get_error_status(struct bma4_err_reg *err_reg, struct bma4_dev *dev);
|
uint16_t bma4_get_error_status(struct bma4_err_reg *err_reg,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API reads the sensor status from the dev sensor.
|
* @brief This API reads the sensor status from the dev sensor.
|
||||||
|
@ -291,7 +294,8 @@ uint16_t bma4_get_sensor_time(uint32_t *sensor_time, struct bma4_dev *dev);
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_get_temperature(int32_t *temp, uint8_t temp_unit, struct bma4_dev *dev);
|
uint16_t bma4_get_temperature(int32_t *temp, uint8_t temp_unit,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API reads the Output data rate, Bandwidth, perf_mode
|
* @brief This API reads the Output data rate, Bandwidth, perf_mode
|
||||||
|
@ -342,7 +346,8 @@ uint16_t bma4_get_temperature(int32_t *temp, uint8_t temp_unit, struct bma4_dev
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_get_accel_config(struct bma4_accel_config *accel, struct bma4_dev *dev);
|
uint16_t bma4_get_accel_config(struct bma4_accel_config *accel,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API sets the output_data_rate, bandwidth, perf_mode
|
* @brief This API sets the output_data_rate, bandwidth, perf_mode
|
||||||
|
@ -393,7 +398,8 @@ uint16_t bma4_get_accel_config(struct bma4_accel_config *accel, struct bma4_dev
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_set_accel_config(const struct bma4_accel_config *accel, struct bma4_dev *dev);
|
uint16_t bma4_set_accel_config(const struct bma4_accel_config *accel,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API sets the advance power save mode in the sensor.
|
* @brief This API sets the advance power save mode in the sensor.
|
||||||
|
@ -411,7 +417,7 @@ uint16_t bma4_set_accel_config(const struct bma4_accel_config *accel, struct bma
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_set_advance_power_save(uint8_t adv_pwr_save,
|
uint16_t bma4_set_advance_power_save(uint8_t adv_pwr_save,
|
||||||
struct bma4_dev *dev);
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API reads the status of advance power save mode
|
* @brief This API reads the status of advance power save mode
|
||||||
|
@ -429,7 +435,8 @@ uint16_t bma4_set_advance_power_save(uint8_t adv_pwr_save,
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_get_advance_power_save(uint8_t *adv_pwr_save, struct bma4_dev *dev);
|
uint16_t bma4_get_advance_power_save(uint8_t *adv_pwr_save,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API sets the FIFO self wake up functionality in the sensor.
|
* @brief This API sets the FIFO self wake up functionality in the sensor.
|
||||||
|
@ -446,7 +453,8 @@ uint16_t bma4_get_advance_power_save(uint8_t *adv_pwr_save, struct bma4_dev *dev
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_set_fifo_self_wakeup(uint8_t fifo_self_wakeup, struct bma4_dev *dev);
|
uint16_t bma4_set_fifo_self_wakeup(uint8_t fifo_self_wakeup,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API gets the status of FIFO self wake up functionality from
|
* @brief This API gets the status of FIFO self wake up functionality from
|
||||||
|
@ -464,7 +472,8 @@ uint16_t bma4_set_fifo_self_wakeup(uint8_t fifo_self_wakeup, struct bma4_dev *de
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_get_fifo_self_wakeup(uint8_t *fifo_self_wake_up, struct bma4_dev *dev);
|
uint16_t bma4_get_fifo_self_wakeup(uint8_t *fifo_self_wake_up,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API enables or disables the Accel in the sensor.
|
* @brief This API enables or disables the Accel in the sensor.
|
||||||
|
@ -562,7 +571,7 @@ uint16_t bma4_get_spi_interface(uint8_t *spi, struct bma4_dev *dev);
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_set_spi_interface(uint8_t spi, struct bma4_dev *dev);
|
uint16_t bma4_set_spi_interface(uint8_t spi, struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API writes the available sensor specific commands
|
* @brief This API writes the available sensor specific commands
|
||||||
* to the sensor.
|
* to the sensor.
|
||||||
*
|
*
|
||||||
|
@ -851,7 +860,8 @@ uint16_t bma4_set_fifo_wm(uint16_t fifo_wm, struct bma4_dev *dev);
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_get_accel_fifo_filter_data(uint8_t *accel_fifo_filter, struct bma4_dev *dev);
|
uint16_t bma4_get_accel_fifo_filter_data(uint8_t *accel_fifo_filter,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API sets the condition of Accel FIFO data either to
|
* @brief This API sets the condition of Accel FIFO data either to
|
||||||
|
@ -870,7 +880,8 @@ uint16_t bma4_get_accel_fifo_filter_data(uint8_t *accel_fifo_filter, struct bma4
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_set_accel_fifo_filter_data(uint8_t accel_fifo_filter, struct bma4_dev *dev);
|
uint16_t bma4_set_accel_fifo_filter_data(uint8_t accel_fifo_filter,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API reads the down sampling rates which is configured
|
* @brief This API reads the down sampling rates which is configured
|
||||||
|
@ -939,9 +950,10 @@ uint16_t bma4_get_fifo_length(uint16_t *fifo_length, struct bma4_dev *dev);
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_second_if_mag_compensate_xyz(struct bma4_mag_fifo_data mag_fifo_data,
|
uint16_t
|
||||||
uint8_t mag_second_if,
|
bma4_second_if_mag_compensate_xyz(struct bma4_mag_fifo_data mag_fifo_data,
|
||||||
struct bma4_mag *compensated_mag_data);
|
uint8_t mag_second_if,
|
||||||
|
struct bma4_mag *compensated_mag_data);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API reads Mag. x,y and z axis data from either BMM150 or
|
* @brief This API reads Mag. x,y and z axis data from either BMM150 or
|
||||||
|
@ -963,7 +975,8 @@ uint16_t bma4_second_if_mag_compensate_xyz(struct bma4_mag_fifo_data mag_fifo_da
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_read_mag_xyz(struct bma4_mag *mag, uint8_t sensor_select, struct bma4_dev *dev);
|
uint16_t bma4_read_mag_xyz(struct bma4_mag *mag, uint8_t sensor_select,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API reads the auxiliary I2C interface configuration which
|
* @brief This API reads the auxiliary I2C interface configuration which
|
||||||
|
@ -1056,7 +1069,8 @@ uint16_t bma4_get_mag_data_rdy(uint8_t *data_rdy, struct bma4_dev *dev);
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_get_asic_status(struct bma4_asic_status *asic_status, struct bma4_dev *dev);
|
uint16_t bma4_get_asic_status(struct bma4_asic_status *asic_status,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API enables the offset compensation for filtered and
|
* @brief This API enables the offset compensation for filtered and
|
||||||
|
@ -1122,7 +1136,8 @@ uint16_t bma4_get_offset_comp(uint8_t *offset_en, struct bma4_dev *dev);
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_extract_accel(struct bma4_accel *accel_data, uint16_t *accel_length, const struct bma4_dev *dev);
|
uint16_t bma4_extract_accel(struct bma4_accel *accel_data,
|
||||||
|
uint16_t *accel_length, const struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API parses and extracts the magnetometer frames from
|
* @brief This API parses and extracts the magnetometer frames from
|
||||||
|
@ -1148,7 +1163,8 @@ uint16_t bma4_extract_accel(struct bma4_accel *accel_data, uint16_t *accel_lengt
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_extract_mag(struct bma4_mag *mag_data, uint16_t *mag_length, const struct bma4_dev *dev);
|
uint16_t bma4_extract_mag(struct bma4_mag *mag_data, uint16_t *mag_length,
|
||||||
|
const struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API performs Fast Offset Compensation for Accel.
|
* @brief This API performs Fast Offset Compensation for Accel.
|
||||||
|
@ -1170,7 +1186,8 @@ uint16_t bma4_extract_mag(struct bma4_mag *mag_data, uint16_t *mag_length, const
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_perform_accel_foc(const int32_t accel_g_value[3], struct bma4_dev *dev);
|
uint16_t bma4_perform_accel_foc(const int32_t accel_g_value[3],
|
||||||
|
struct bma4_dev *dev);
|
||||||
/*!
|
/*!
|
||||||
* @brief This API checks whether the self test functionality of the sensor
|
* @brief This API checks whether the self test functionality of the sensor
|
||||||
* is working or not
|
* is working or not
|
||||||
|
@ -1230,7 +1247,8 @@ uint16_t bma4_selftest_config(uint8_t sign, struct bma4_dev *dev);
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_map_interrupt(uint8_t int_line, uint16_t int_map, uint8_t enable, struct bma4_dev *dev);
|
uint16_t bma4_map_interrupt(uint8_t int_line, uint16_t int_map, uint8_t enable,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API sets the interrupt mode in the sensor.
|
* @brief This API sets the interrupt mode in the sensor.
|
||||||
|
@ -1305,7 +1323,8 @@ uint16_t bma4_get_interrupt_mode(uint8_t *mode, struct bma4_dev *dev);
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_set_aux_mag_config(const struct bma4_aux_mag_config *aux_mag, struct bma4_dev *dev);
|
uint16_t bma4_set_aux_mag_config(const struct bma4_aux_mag_config *aux_mag,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API reads the auxiliary Mag(BMM150 or AKM9916) output data
|
* @brief This API reads the auxiliary Mag(BMM150 or AKM9916) output data
|
||||||
|
@ -1343,7 +1362,8 @@ uint16_t bma4_set_aux_mag_config(const struct bma4_aux_mag_config *aux_mag, stru
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_get_aux_mag_config(struct bma4_aux_mag_config *aux_mag, struct bma4_dev *dev);
|
uint16_t bma4_get_aux_mag_config(struct bma4_aux_mag_config *aux_mag,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*! @brief This API sets the FIFO configuration in the sensor.
|
/*! @brief This API sets the FIFO configuration in the sensor.
|
||||||
*
|
*
|
||||||
|
@ -1372,7 +1392,8 @@ uint16_t bma4_get_aux_mag_config(struct bma4_aux_mag_config *aux_mag, struct bma
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_set_fifo_config(uint8_t config, uint8_t enable, struct bma4_dev *dev);
|
uint16_t bma4_set_fifo_config(uint8_t config, uint8_t enable,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*! @brief This API reads the FIFO configuration from the sensor.
|
/*! @brief This API reads the FIFO configuration from the sensor.
|
||||||
*
|
*
|
||||||
|
@ -1441,8 +1462,9 @@ uint16_t bma4_get_fifo_config(uint8_t *fifo_config, struct bma4_dev *dev);
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_set_int_pin_config(const struct bma4_int_pin_config *int_pin_config, uint8_t int_line,
|
uint16_t
|
||||||
struct bma4_dev *dev);
|
bma4_set_int_pin_config(const struct bma4_int_pin_config *int_pin_config,
|
||||||
|
uint8_t int_line, struct bma4_dev *dev);
|
||||||
|
|
||||||
/*! @brief This API reads the electrical behavior of interrupt pin1 or pin2
|
/*! @brief This API reads the electrical behavior of interrupt pin1 or pin2
|
||||||
* from the sensor.
|
* from the sensor.
|
||||||
|
@ -1483,10 +1505,12 @@ uint16_t bma4_set_int_pin_config(const struct bma4_int_pin_config *int_pin_confi
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_get_int_pin_config(struct bma4_int_pin_config *int_pin_config, uint8_t int_line, struct bma4_dev *dev);
|
uint16_t bma4_get_int_pin_config(struct bma4_int_pin_config *int_pin_config,
|
||||||
|
uint8_t int_line, struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API reads the Feature and Hardware interrupt status from the sensor.
|
* @brief This API reads the Feature and Hardware interrupt status from the
|
||||||
|
*sensor.
|
||||||
*
|
*
|
||||||
* @param[out] int_status : Variable used to get the interrupt status.
|
* @param[out] int_status : Variable used to get the interrupt status.
|
||||||
* @param[in] dev : Structure instance of bma4_dev.
|
* @param[in] dev : Structure instance of bma4_dev.
|
||||||
|
@ -1544,14 +1568,16 @@ uint16_t bma4_aux_interface_init(struct bma4_dev *dev);
|
||||||
* @param[in] len : User specified data length
|
* @param[in] len : User specified data length
|
||||||
* @param[out] aux_data : Pointer variable to store data read
|
* @param[out] aux_data : Pointer variable to store data read
|
||||||
* @param[in] aux_reg_addr : Variable to pass address from where
|
* @param[in] aux_reg_addr : Variable to pass address from where
|
||||||
* data is to be read
|
* data is to be
|
||||||
|
*read
|
||||||
*
|
*
|
||||||
* @return Result of API execution status
|
* @return Result of API execution status
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_aux_read(uint8_t aux_reg_addr, uint8_t *aux_data, uint16_t len, struct bma4_dev *dev);
|
uint16_t bma4_aux_read(uint8_t aux_reg_addr, uint8_t *aux_data, uint16_t len,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API writes the data into the auxiliary sensor
|
* @brief This API writes the data into the auxiliary sensor
|
||||||
|
@ -1560,15 +1586,16 @@ uint16_t bma4_aux_read(uint8_t aux_reg_addr, uint8_t *aux_data, uint16_t len, st
|
||||||
* @param[in] len : User specified data length
|
* @param[in] len : User specified data length
|
||||||
* @param[out] aux_data : Pointer variable to store data read
|
* @param[out] aux_data : Pointer variable to store data read
|
||||||
* @param[in] aux_reg_addr : Variable to pass address from where
|
* @param[in] aux_reg_addr : Variable to pass address from where
|
||||||
* data is to be written
|
* data is to be
|
||||||
|
*written
|
||||||
*
|
*
|
||||||
* @return Result of API execution status
|
* @return Result of API execution status
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
uint16_t bma4_aux_write(uint8_t aux_reg_addr, uint8_t *aux_data, uint16_t len, struct bma4_dev *dev);
|
uint16_t bma4_aux_write(uint8_t aux_reg_addr, uint8_t *aux_data, uint16_t len,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* End of __BMA4_H__ */
|
/* End of __BMA4_H__ */
|
||||||
|
|
2796
src/bma423.c
2796
src/bma423.c
File diff suppressed because it is too large
Load Diff
559
src/bma423.h
559
src/bma423.h
|
@ -1,87 +1,87 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
* Copyright (C) 2017 - 2018 Bosch Sensortec GmbH
|
* Copyright (C) 2017 - 2018 Bosch Sensortec GmbH
|
||||||
*
|
*
|
||||||
* File : bma423.h
|
* File : bma423.h
|
||||||
*
|
*
|
||||||
* Date: 12 Oct 2017
|
* Date: 12 Oct 2017
|
||||||
*
|
*
|
||||||
* Revision : 1.1.4 $
|
* Revision : 1.1.4 $
|
||||||
*
|
*
|
||||||
* Usage: Sensor Driver for BMA423 sensor
|
* Usage: Sensor Driver for BMA423 sensor
|
||||||
*
|
*
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*
|
*
|
||||||
* Disclaimer
|
* Disclaimer
|
||||||
*
|
*
|
||||||
* Common:
|
* Common:
|
||||||
* Bosch Sensortec products are developed for the consumer goods industry.
|
* Bosch Sensortec products are developed for the consumer goods industry.
|
||||||
* They may only be used within the parameters of the respective valid
|
* They may only be used within the parameters of the respective valid
|
||||||
* product data sheet. Bosch Sensortec products are provided with the
|
* product data sheet. Bosch Sensortec products are provided with the
|
||||||
* express understanding that there is no warranty of fitness for a
|
* express understanding that there is no warranty of fitness for a
|
||||||
* particular purpose.They are not fit for use in life-sustaining,
|
* particular purpose.They are not fit for use in life-sustaining,
|
||||||
* safety or security sensitive systems or any system or device
|
* safety or security sensitive systems or any system or device
|
||||||
* that may lead to bodily harm or property damage if the system
|
* that may lead to bodily harm or property damage if the system
|
||||||
* or device malfunctions. In addition,Bosch Sensortec products are
|
* or device malfunctions. In addition,Bosch Sensortec products are
|
||||||
* not fit for use in products which interact with motor vehicle systems.
|
* not fit for use in products which interact with motor vehicle systems.
|
||||||
* The resale and or use of products are at the purchasers own risk and
|
* The resale and or use of products are at the purchasers own risk and
|
||||||
* his own responsibility. The examination of fitness for the intended use
|
* his own responsibility. The examination of fitness for the intended use
|
||||||
* is the sole responsibility of the Purchaser.
|
* is the sole responsibility of the Purchaser.
|
||||||
*
|
*
|
||||||
* The purchaser shall indemnify Bosch Sensortec from all third party
|
* The purchaser shall indemnify Bosch Sensortec from all third party
|
||||||
* claims, including any claims for incidental, or consequential damages,
|
* claims, including any claims for incidental, or consequential damages,
|
||||||
* arising from any product use not covered by the parameters of
|
* arising from any product use not covered by the parameters of
|
||||||
* the respective valid product data sheet or not approved by
|
* the respective valid product data sheet or not approved by
|
||||||
* Bosch Sensortec and reimburse Bosch Sensortec for all costs in
|
* Bosch Sensortec and reimburse Bosch Sensortec for all costs in
|
||||||
* connection with such claims.
|
* connection with such claims.
|
||||||
*
|
*
|
||||||
* The purchaser must monitor the market for the purchased products,
|
* The purchaser must monitor the market for the purchased products,
|
||||||
* particularly with regard to product safety and inform Bosch Sensortec
|
* particularly with regard to product safety and inform Bosch Sensortec
|
||||||
* without delay of all security relevant incidents.
|
* without delay of all security relevant incidents.
|
||||||
*
|
*
|
||||||
* Engineering Samples are marked with an asterisk (*) or (e).
|
* Engineering Samples are marked with an asterisk (*) or (e).
|
||||||
* Samples may vary from the valid technical specifications of the product
|
* Samples may vary from the valid technical specifications of the product
|
||||||
* series. They are therefore not intended or fit for resale to third
|
* series. They are therefore not intended or fit for resale to third
|
||||||
* parties or for use in end products. Their sole purpose is internal
|
* parties or for use in end products. Their sole purpose is internal
|
||||||
* client testing. The testing of an engineering sample may in no way
|
* client testing. The testing of an engineering sample may in no way
|
||||||
* replace the testing of a product series. Bosch Sensortec assumes
|
* replace the testing of a product series. Bosch Sensortec assumes
|
||||||
* no liability for the use of engineering samples.
|
* no liability for the use of engineering samples.
|
||||||
* By accepting the engineering samples, the Purchaser agrees to indemnify
|
* By accepting the engineering samples, the Purchaser agrees to indemnify
|
||||||
* Bosch Sensortec from all claims arising from the use of engineering
|
* Bosch Sensortec from all claims arising from the use of engineering
|
||||||
* samples.
|
* samples.
|
||||||
*
|
*
|
||||||
* Special:
|
* Special:
|
||||||
* This software module (hereinafter called "Software") and any information
|
* This software module (hereinafter called "Software") and any information
|
||||||
* on application-sheets (hereinafter called "Information") is provided
|
* on application-sheets (hereinafter called "Information") is provided
|
||||||
* free of charge for the sole purpose to support your application work.
|
* free of charge for the sole purpose to support your application work.
|
||||||
* The Software and Information is subject to the following
|
* The Software and Information is subject to the following
|
||||||
* terms and conditions:
|
* terms and conditions:
|
||||||
*
|
*
|
||||||
* The Software is specifically designed for the exclusive use for
|
* The Software is specifically designed for the exclusive use for
|
||||||
* Bosch Sensortec products by personnel who have special experience
|
* Bosch Sensortec products by personnel who have special experience
|
||||||
* and training. Do not use this Software if you do not have the
|
* and training. Do not use this Software if you do not have the
|
||||||
* proper experience or training.
|
* proper experience or training.
|
||||||
*
|
*
|
||||||
* This Software package is provided `` as is `` and without any expressed
|
* This Software package is provided `` as is `` and without any expressed
|
||||||
* or implied warranties,including without limitation, the implied warranties
|
* or implied warranties,including without limitation, the implied warranties
|
||||||
* of merchantability and fitness for a particular purpose.
|
* of merchantability and fitness for a particular purpose.
|
||||||
*
|
*
|
||||||
* Bosch Sensortec and their representatives and agents deny any liability
|
* Bosch Sensortec and their representatives and agents deny any liability
|
||||||
* for the functional impairment
|
* for the functional impairment
|
||||||
* of this Software in terms of fitness, performance and safety.
|
* of this Software in terms of fitness, performance and safety.
|
||||||
* Bosch Sensortec and their representatives and agents shall not be liable
|
* Bosch Sensortec and their representatives and agents shall not be liable
|
||||||
* for any direct or indirect damages or injury, except as
|
* for any direct or indirect damages or injury, except as
|
||||||
* otherwise stipulated in mandatory applicable law.
|
* otherwise stipulated in mandatory applicable law.
|
||||||
*
|
*
|
||||||
* The Information provided is believed to be accurate and reliable.
|
* The Information provided is believed to be accurate and reliable.
|
||||||
* Bosch Sensortec assumes no responsibility for the consequences of use
|
* Bosch Sensortec assumes no responsibility for the consequences of use
|
||||||
* of such Information nor for any infringement of patents or
|
* of such Information nor for any infringement of patents or
|
||||||
* other rights of third parties which may result from its use.
|
* other rights of third parties which may result from its use.
|
||||||
* No license is granted by implication or otherwise under any patent or
|
* No license is granted by implication or otherwise under any patent or
|
||||||
* patent rights of Bosch. Specifications mentioned in the Information are
|
* patent rights of Bosch. Specifications mentioned in the Information are
|
||||||
* subject to change without notice.
|
* subject to change without notice.
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
/*! \file bma423.h
|
/*! \file bma423.h
|
||||||
\brief Sensor Driver for BMA423 sensor */
|
\brief Sensor Driver for BMA423 sensor */
|
||||||
#ifndef BMA423_H
|
#ifndef BMA423_H
|
||||||
|
@ -93,258 +93,257 @@ extern "C" {
|
||||||
#include "bma4.h"
|
#include "bma4.h"
|
||||||
|
|
||||||
/**\name Chip ID of BMA423 sensor */
|
/**\name Chip ID of BMA423 sensor */
|
||||||
#define BMA423_CHIP_ID UINT8_C(0x13)
|
#define BMA423_CHIP_ID UINT8_C(0x13)
|
||||||
|
|
||||||
/**\name Sensor feature size */
|
/**\name Sensor feature size */
|
||||||
#define BMA423_FEATURE_SIZE UINT8_C(64)
|
#define BMA423_FEATURE_SIZE UINT8_C(64)
|
||||||
#define BMA423_ANYMOTION_EN_LEN UINT8_C(2)
|
#define BMA423_ANYMOTION_EN_LEN UINT8_C(2)
|
||||||
#define BMA423_RD_WR_MIN_LEN UINT8_C(2)
|
#define BMA423_RD_WR_MIN_LEN UINT8_C(2)
|
||||||
|
|
||||||
/**\name Feature offset address */
|
/**\name Feature offset address */
|
||||||
#define BMA423_ANY_NO_MOTION_OFFSET UINT8_C(0x00)
|
#define BMA423_ANY_NO_MOTION_OFFSET UINT8_C(0x00)
|
||||||
#define BMA423_STEP_CNTR_OFFSET UINT8_C(0x36)
|
#define BMA423_STEP_CNTR_OFFSET UINT8_C(0x36)
|
||||||
#define BMA423_STEP_CNTR_PARAM_OFFSET UINT8_C(0x04)
|
#define BMA423_STEP_CNTR_PARAM_OFFSET UINT8_C(0x04)
|
||||||
#define BMA423_WAKEUP_OFFSET UINT8_C(0x38)
|
#define BMA423_WAKEUP_OFFSET UINT8_C(0x38)
|
||||||
#define BMA423_TILT_OFFSET UINT8_C(0x3A)
|
#define BMA423_TILT_OFFSET UINT8_C(0x3A)
|
||||||
#define BMA423_CONFIG_ID_OFFSET UINT8_C(0x3C)
|
#define BMA423_CONFIG_ID_OFFSET UINT8_C(0x3C)
|
||||||
#define BMA423_AXES_REMAP_OFFSET UINT8_C(0x3E)
|
#define BMA423_AXES_REMAP_OFFSET UINT8_C(0x3E)
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
/**\name Remap Axes */
|
/**\name Remap Axes */
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
#define BMA423_X_AXIS_MASK UINT8_C(0x03)
|
#define BMA423_X_AXIS_MASK UINT8_C(0x03)
|
||||||
#define BMA423_X_AXIS_SIGN_MASK UINT8_C(0x04)
|
#define BMA423_X_AXIS_SIGN_MASK UINT8_C(0x04)
|
||||||
#define BMA423_Y_AXIS_MASK UINT8_C(0x18)
|
#define BMA423_Y_AXIS_MASK UINT8_C(0x18)
|
||||||
#define BMA423_Y_AXIS_SIGN_MASK UINT8_C(0x20)
|
#define BMA423_Y_AXIS_SIGN_MASK UINT8_C(0x20)
|
||||||
#define BMA423_Z_AXIS_MASK UINT8_C(0xC0)
|
#define BMA423_Z_AXIS_MASK UINT8_C(0xC0)
|
||||||
#define BMA423_Z_AXIS_SIGN_MASK UINT8_C(0x01)
|
#define BMA423_Z_AXIS_SIGN_MASK UINT8_C(0x01)
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
/**\name Step Counter & Detector */
|
/**\name Step Counter & Detector */
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
/**\name Step counter enable macros */
|
/**\name Step counter enable macros */
|
||||||
#define BMA423_STEP_CNTR_EN_POS UINT8_C(4)
|
#define BMA423_STEP_CNTR_EN_POS UINT8_C(4)
|
||||||
#define BMA423_STEP_CNTR_EN_MSK UINT8_C(0x10)
|
#define BMA423_STEP_CNTR_EN_MSK UINT8_C(0x10)
|
||||||
#define BMA423_ACTIVITY_EN_MSK UINT8_C(0x20)
|
#define BMA423_ACTIVITY_EN_MSK UINT8_C(0x20)
|
||||||
|
|
||||||
/**\name Step counter watermark macros */
|
/**\name Step counter watermark macros */
|
||||||
#define BMA423_STEP_CNTR_WM_MSK UINT16_C(0x03FF)
|
#define BMA423_STEP_CNTR_WM_MSK UINT16_C(0x03FF)
|
||||||
|
|
||||||
/**\name Step counter reset macros */
|
/**\name Step counter reset macros */
|
||||||
#define BMA423_STEP_CNTR_RST_POS UINT8_C(2)
|
#define BMA423_STEP_CNTR_RST_POS UINT8_C(2)
|
||||||
#define BMA423_STEP_CNTR_RST_MSK UINT8_C(0x04)
|
#define BMA423_STEP_CNTR_RST_MSK UINT8_C(0x04)
|
||||||
|
|
||||||
/**\name Step detector enable macros */
|
/**\name Step detector enable macros */
|
||||||
#define BMA423_STEP_DETECTOR_EN_POS UINT8_C(3)
|
#define BMA423_STEP_DETECTOR_EN_POS UINT8_C(3)
|
||||||
#define BMA423_STEP_DETECTOR_EN_MSK UINT8_C(0x08)
|
#define BMA423_STEP_DETECTOR_EN_MSK UINT8_C(0x08)
|
||||||
|
|
||||||
/**\name Tilt enable macros */
|
/**\name Tilt enable macros */
|
||||||
#define BMA423_TILT_EN_MSK UINT8_C(0x01)
|
#define BMA423_TILT_EN_MSK UINT8_C(0x01)
|
||||||
|
|
||||||
/**\name Step count output length*/
|
/**\name Step count output length*/
|
||||||
#define BMA423_STEP_CNTR_DATA_SIZE UINT16_C(4)
|
#define BMA423_STEP_CNTR_DATA_SIZE UINT16_C(4)
|
||||||
|
|
||||||
/**\name Wakeup enable macros */
|
/**\name Wakeup enable macros */
|
||||||
#define BMA423_WAKEUP_EN_MSK UINT8_C(0x01)
|
#define BMA423_WAKEUP_EN_MSK UINT8_C(0x01)
|
||||||
|
|
||||||
/**\name Wake up sensitivity macros */
|
/**\name Wake up sensitivity macros */
|
||||||
#define BMA423_WAKEUP_SENS_POS UINT8_C(1)
|
#define BMA423_WAKEUP_SENS_POS UINT8_C(1)
|
||||||
#define BMA423_WAKEUP_SENS_MSK UINT8_C(0x0E)
|
#define BMA423_WAKEUP_SENS_MSK UINT8_C(0x0E)
|
||||||
|
|
||||||
/**\name Tap selection macro */
|
/**\name Tap selection macro */
|
||||||
#define BMA423_TAP_SEL_POS UINT8_C(4)
|
#define BMA423_TAP_SEL_POS UINT8_C(4)
|
||||||
#define BMA423_TAP_SEL_MSK UINT8_C(0x10)
|
#define BMA423_TAP_SEL_MSK UINT8_C(0x10)
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
/**\name Any Motion */
|
/**\name Any Motion */
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
/**\name Any motion threshold macros */
|
/**\name Any motion threshold macros */
|
||||||
#define BMA423_ANY_NO_MOTION_THRES_POS UINT8_C(0)
|
#define BMA423_ANY_NO_MOTION_THRES_POS UINT8_C(0)
|
||||||
#define BMA423_ANY_NO_MOTION_THRES_MSK UINT16_C(0x07FF)
|
#define BMA423_ANY_NO_MOTION_THRES_MSK UINT16_C(0x07FF)
|
||||||
|
|
||||||
/**\name Any motion selection macros */
|
/**\name Any motion selection macros */
|
||||||
#define BMA423_ANY_NO_MOTION_SEL_POS UINT8_C(3)
|
#define BMA423_ANY_NO_MOTION_SEL_POS UINT8_C(3)
|
||||||
#define BMA423_ANY_NO_MOTION_SEL_MSK UINT8_C(0x08)
|
#define BMA423_ANY_NO_MOTION_SEL_MSK UINT8_C(0x08)
|
||||||
|
|
||||||
/**\name Any motion enable macros */
|
/**\name Any motion enable macros */
|
||||||
#define BMA423_ANY_NO_MOTION_AXIS_EN_POS UINT8_C(5)
|
#define BMA423_ANY_NO_MOTION_AXIS_EN_POS UINT8_C(5)
|
||||||
#define BMA423_ANY_NO_MOTION_AXIS_EN_MSK UINT8_C(0xE0)
|
#define BMA423_ANY_NO_MOTION_AXIS_EN_MSK UINT8_C(0xE0)
|
||||||
|
|
||||||
/**\name Any motion duration macros */
|
/**\name Any motion duration macros */
|
||||||
#define BMA423_ANY_NO_MOTION_DUR_MSK UINT16_C(0x1FFF)
|
#define BMA423_ANY_NO_MOTION_DUR_MSK UINT16_C(0x1FFF)
|
||||||
|
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
/**\name User macros */
|
/**\name User macros */
|
||||||
/**************************************************************/
|
/**************************************************************/
|
||||||
|
|
||||||
/**\name Anymotion/Nomotion axis enable macros */
|
/**\name Anymotion/Nomotion axis enable macros */
|
||||||
#define BMA423_X_AXIS_EN UINT8_C(0x01)
|
#define BMA423_X_AXIS_EN UINT8_C(0x01)
|
||||||
#define BMA423_Y_AXIS_EN UINT8_C(0x02)
|
#define BMA423_Y_AXIS_EN UINT8_C(0x02)
|
||||||
#define BMA423_Z_AXIS_EN UINT8_C(0x04)
|
#define BMA423_Z_AXIS_EN UINT8_C(0x04)
|
||||||
#define BMA423_ALL_AXIS_EN UINT8_C(0x07)
|
#define BMA423_ALL_AXIS_EN UINT8_C(0x07)
|
||||||
#define BMA423_ALL_AXIS_DIS UINT8_C(0x00)
|
#define BMA423_ALL_AXIS_DIS UINT8_C(0x00)
|
||||||
|
|
||||||
/**\name Feature enable macros for the sensor */
|
/**\name Feature enable macros for the sensor */
|
||||||
#define BMA423_STEP_CNTR UINT8_C(0x01)
|
#define BMA423_STEP_CNTR UINT8_C(0x01)
|
||||||
/**\name Below macros are mutually exclusive */
|
/**\name Below macros are mutually exclusive */
|
||||||
#define BMA423_ANY_MOTION UINT8_C(0x02)
|
#define BMA423_ANY_MOTION UINT8_C(0x02)
|
||||||
#define BMA423_NO_MOTION UINT8_C(0x04)
|
#define BMA423_NO_MOTION UINT8_C(0x04)
|
||||||
#define BMA423_ACTIVITY UINT8_C(0x08)
|
#define BMA423_ACTIVITY UINT8_C(0x08)
|
||||||
#define BMA423_TILT UINT8_C(0x10)
|
#define BMA423_TILT UINT8_C(0x10)
|
||||||
#define BMA423_WAKEUP UINT8_C(0x20)
|
#define BMA423_WAKEUP UINT8_C(0x20)
|
||||||
|
|
||||||
/**\name Interrupt status macros */
|
/**\name Interrupt status macros */
|
||||||
#define BMA423_STEP_CNTR_INT UINT8_C(0x02)
|
#define BMA423_STEP_CNTR_INT UINT8_C(0x02)
|
||||||
#define BMA423_ACTIVITY_INT UINT8_C(0x04)
|
#define BMA423_ACTIVITY_INT UINT8_C(0x04)
|
||||||
#define BMA423_TILT_INT UINT8_C(0x08)
|
#define BMA423_TILT_INT UINT8_C(0x08)
|
||||||
#define BMA423_WAKEUP_INT UINT8_C(0x20)
|
#define BMA423_WAKEUP_INT UINT8_C(0x20)
|
||||||
#define BMA423_ANY_NO_MOTION_INT UINT8_C(0x40)
|
#define BMA423_ANY_NO_MOTION_INT UINT8_C(0x40)
|
||||||
#define BMA423_ERROR_INT UINT8_C(0x80)
|
#define BMA423_ERROR_INT UINT8_C(0x80)
|
||||||
|
|
||||||
/**\name Activity recognition macros */
|
/**\name Activity recognition macros */
|
||||||
#define BMA423_USER_STATIONARY UINT8_C(0x00)
|
#define BMA423_USER_STATIONARY UINT8_C(0x00)
|
||||||
#define BMA423_USER_WALKING UINT8_C(0x01)
|
#define BMA423_USER_WALKING UINT8_C(0x01)
|
||||||
#define BMA423_USER_RUNNING UINT8_C(0x02)
|
#define BMA423_USER_RUNNING UINT8_C(0x02)
|
||||||
#define BMA423_STATE_INVALID UINT8_C(0x03)
|
#define BMA423_STATE_INVALID UINT8_C(0x03)
|
||||||
|
|
||||||
/**\name Configuration selection macros */
|
/**\name Configuration selection macros */
|
||||||
#define BMA423_PHONE_CONFIG UINT8_C(0x00)
|
#define BMA423_PHONE_CONFIG UINT8_C(0x00)
|
||||||
#define BMA423_WRIST_CONFIG UINT8_C(0x01)
|
#define BMA423_WRIST_CONFIG UINT8_C(0x01)
|
||||||
|
|
||||||
/**\name Step counter parameter setting(1-25) for phone */
|
/**\name Step counter parameter setting(1-25) for phone */
|
||||||
#define BMA423_PHONE_SC_PARAM_1 UINT16_C(0x132)
|
#define BMA423_PHONE_SC_PARAM_1 UINT16_C(0x132)
|
||||||
#define BMA423_PHONE_SC_PARAM_2 UINT16_C(0x78E6)
|
#define BMA423_PHONE_SC_PARAM_2 UINT16_C(0x78E6)
|
||||||
#define BMA423_PHONE_SC_PARAM_3 UINT16_C(0x84)
|
#define BMA423_PHONE_SC_PARAM_3 UINT16_C(0x84)
|
||||||
#define BMA423_PHONE_SC_PARAM_4 UINT16_C(0x6C9C)
|
#define BMA423_PHONE_SC_PARAM_4 UINT16_C(0x6C9C)
|
||||||
#define BMA423_PHONE_SC_PARAM_5 UINT8_C(0x07)
|
#define BMA423_PHONE_SC_PARAM_5 UINT8_C(0x07)
|
||||||
#define BMA423_PHONE_SC_PARAM_6 UINT16_C(0x7564)
|
#define BMA423_PHONE_SC_PARAM_6 UINT16_C(0x7564)
|
||||||
#define BMA423_PHONE_SC_PARAM_7 UINT16_C(0x7EAA)
|
#define BMA423_PHONE_SC_PARAM_7 UINT16_C(0x7EAA)
|
||||||
#define BMA423_PHONE_SC_PARAM_8 UINT16_C(0x55F)
|
#define BMA423_PHONE_SC_PARAM_8 UINT16_C(0x55F)
|
||||||
#define BMA423_PHONE_SC_PARAM_9 UINT16_C(0xABE)
|
#define BMA423_PHONE_SC_PARAM_9 UINT16_C(0xABE)
|
||||||
#define BMA423_PHONE_SC_PARAM_10 UINT16_C(0x55F)
|
#define BMA423_PHONE_SC_PARAM_10 UINT16_C(0x55F)
|
||||||
#define BMA423_PHONE_SC_PARAM_11 UINT16_C(0xE896)
|
#define BMA423_PHONE_SC_PARAM_11 UINT16_C(0xE896)
|
||||||
#define BMA423_PHONE_SC_PARAM_12 UINT16_C(0x41EF)
|
#define BMA423_PHONE_SC_PARAM_12 UINT16_C(0x41EF)
|
||||||
#define BMA423_PHONE_SC_PARAM_13 UINT8_C(0x01)
|
#define BMA423_PHONE_SC_PARAM_13 UINT8_C(0x01)
|
||||||
#define BMA423_PHONE_SC_PARAM_14 UINT8_C(0x0C)
|
#define BMA423_PHONE_SC_PARAM_14 UINT8_C(0x0C)
|
||||||
#define BMA423_PHONE_SC_PARAM_15 UINT8_C(0x0C)
|
#define BMA423_PHONE_SC_PARAM_15 UINT8_C(0x0C)
|
||||||
#define BMA423_PHONE_SC_PARAM_16 UINT8_C(0x4A)
|
#define BMA423_PHONE_SC_PARAM_16 UINT8_C(0x4A)
|
||||||
#define BMA423_PHONE_SC_PARAM_17 UINT8_C(0xA0)
|
#define BMA423_PHONE_SC_PARAM_17 UINT8_C(0xA0)
|
||||||
#define BMA423_PHONE_SC_PARAM_18 UINT8_C(0x00)
|
#define BMA423_PHONE_SC_PARAM_18 UINT8_C(0x00)
|
||||||
#define BMA423_PHONE_SC_PARAM_19 UINT8_C(0x0C)
|
#define BMA423_PHONE_SC_PARAM_19 UINT8_C(0x0C)
|
||||||
#define BMA423_PHONE_SC_PARAM_20 UINT16_C(0x3CF0)
|
#define BMA423_PHONE_SC_PARAM_20 UINT16_C(0x3CF0)
|
||||||
#define BMA423_PHONE_SC_PARAM_21 UINT16_C(0x100)
|
#define BMA423_PHONE_SC_PARAM_21 UINT16_C(0x100)
|
||||||
#define BMA423_PHONE_SC_PARAM_22 UINT8_C(0x00)
|
#define BMA423_PHONE_SC_PARAM_22 UINT8_C(0x00)
|
||||||
#define BMA423_PHONE_SC_PARAM_23 UINT8_C(0x00)
|
#define BMA423_PHONE_SC_PARAM_23 UINT8_C(0x00)
|
||||||
#define BMA423_PHONE_SC_PARAM_24 UINT8_C(0x00)
|
#define BMA423_PHONE_SC_PARAM_24 UINT8_C(0x00)
|
||||||
#define BMA423_PHONE_SC_PARAM_25 UINT8_C(0x00)
|
#define BMA423_PHONE_SC_PARAM_25 UINT8_C(0x00)
|
||||||
|
|
||||||
/**\name Step counter parameter setting(1-25) for wrist (Default) */
|
/**\name Step counter parameter setting(1-25) for wrist (Default) */
|
||||||
#define BMA423_WRIST_SC_PARAM_1 UINT16_C(0x12D)
|
#define BMA423_WRIST_SC_PARAM_1 UINT16_C(0x12D)
|
||||||
#define BMA423_WRIST_SC_PARAM_2 UINT16_C(0x7BD4)
|
#define BMA423_WRIST_SC_PARAM_2 UINT16_C(0x7BD4)
|
||||||
#define BMA423_WRIST_SC_PARAM_3 UINT16_C(0x13B)
|
#define BMA423_WRIST_SC_PARAM_3 UINT16_C(0x13B)
|
||||||
#define BMA423_WRIST_SC_PARAM_4 UINT16_C(0x7ADB)
|
#define BMA423_WRIST_SC_PARAM_4 UINT16_C(0x7ADB)
|
||||||
#define BMA423_WRIST_SC_PARAM_5 UINT8_C(0x04)
|
#define BMA423_WRIST_SC_PARAM_5 UINT8_C(0x04)
|
||||||
#define BMA423_WRIST_SC_PARAM_6 UINT16_C(0x7B3F)
|
#define BMA423_WRIST_SC_PARAM_6 UINT16_C(0x7B3F)
|
||||||
#define BMA423_WRIST_SC_PARAM_7 UINT16_C(0x6CCD)
|
#define BMA423_WRIST_SC_PARAM_7 UINT16_C(0x6CCD)
|
||||||
#define BMA423_WRIST_SC_PARAM_8 UINT16_C(0x4C3)
|
#define BMA423_WRIST_SC_PARAM_8 UINT16_C(0x4C3)
|
||||||
#define BMA423_WRIST_SC_PARAM_9 UINT16_C(0x985)
|
#define BMA423_WRIST_SC_PARAM_9 UINT16_C(0x985)
|
||||||
#define BMA423_WRIST_SC_PARAM_10 UINT16_C(0x4C3)
|
#define BMA423_WRIST_SC_PARAM_10 UINT16_C(0x4C3)
|
||||||
#define BMA423_WRIST_SC_PARAM_11 UINT16_C(0xE6EC)
|
#define BMA423_WRIST_SC_PARAM_11 UINT16_C(0xE6EC)
|
||||||
#define BMA423_WRIST_SC_PARAM_12 UINT16_C(0x460C)
|
#define BMA423_WRIST_SC_PARAM_12 UINT16_C(0x460C)
|
||||||
#define BMA423_WRIST_SC_PARAM_13 UINT8_C(0x01)
|
#define BMA423_WRIST_SC_PARAM_13 UINT8_C(0x01)
|
||||||
#define BMA423_WRIST_SC_PARAM_14 UINT8_C(0x27)
|
#define BMA423_WRIST_SC_PARAM_14 UINT8_C(0x27)
|
||||||
#define BMA423_WRIST_SC_PARAM_15 UINT8_C(0x19)
|
#define BMA423_WRIST_SC_PARAM_15 UINT8_C(0x19)
|
||||||
#define BMA423_WRIST_SC_PARAM_16 UINT8_C(0x96)
|
#define BMA423_WRIST_SC_PARAM_16 UINT8_C(0x96)
|
||||||
#define BMA423_WRIST_SC_PARAM_17 UINT8_C(0xA0)
|
#define BMA423_WRIST_SC_PARAM_17 UINT8_C(0xA0)
|
||||||
#define BMA423_WRIST_SC_PARAM_18 UINT8_C(0x01)
|
#define BMA423_WRIST_SC_PARAM_18 UINT8_C(0x01)
|
||||||
#define BMA423_WRIST_SC_PARAM_19 UINT8_C(0x0C)
|
#define BMA423_WRIST_SC_PARAM_19 UINT8_C(0x0C)
|
||||||
#define BMA423_WRIST_SC_PARAM_20 UINT16_C(0x3CF0)
|
#define BMA423_WRIST_SC_PARAM_20 UINT16_C(0x3CF0)
|
||||||
#define BMA423_WRIST_SC_PARAM_21 UINT16_C(0x100)
|
#define BMA423_WRIST_SC_PARAM_21 UINT16_C(0x100)
|
||||||
#define BMA423_WRIST_SC_PARAM_22 UINT8_C(0x01)
|
#define BMA423_WRIST_SC_PARAM_22 UINT8_C(0x01)
|
||||||
#define BMA423_WRIST_SC_PARAM_23 UINT8_C(0x03)
|
#define BMA423_WRIST_SC_PARAM_23 UINT8_C(0x03)
|
||||||
#define BMA423_WRIST_SC_PARAM_24 UINT8_C(0x01)
|
#define BMA423_WRIST_SC_PARAM_24 UINT8_C(0x01)
|
||||||
#define BMA423_WRIST_SC_PARAM_25 UINT8_C(0x0E)
|
#define BMA423_WRIST_SC_PARAM_25 UINT8_C(0x0E)
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Any motion configuration
|
* @brief Any motion configuration
|
||||||
*/
|
*/
|
||||||
struct bma423_anymotion_config {
|
struct bma423_anymotion_config {
|
||||||
/*! Expressed in 50 Hz samples (20 ms) */
|
/*! Expressed in 50 Hz samples (20 ms) */
|
||||||
uint16_t duration;
|
uint16_t duration;
|
||||||
/*! Threshold value for Any-motion / No-motion detection in
|
/*! Threshold value for Any-motion / No-motion detection in
|
||||||
5.11g format */
|
5.11g format */
|
||||||
uint16_t threshold;
|
uint16_t threshold;
|
||||||
/*! Indicates if No-motion or Any-motion is selected */
|
/*! Indicates if No-motion or Any-motion is selected */
|
||||||
uint8_t nomotion_sel;
|
uint8_t nomotion_sel;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Axes remapping configuration
|
* @brief Axes remapping configuration
|
||||||
*/
|
*/
|
||||||
struct bma423_axes_remap {
|
struct bma423_axes_remap {
|
||||||
uint8_t x_axis;
|
uint8_t x_axis;
|
||||||
uint8_t x_axis_sign;
|
uint8_t x_axis_sign;
|
||||||
uint8_t y_axis;
|
uint8_t y_axis;
|
||||||
uint8_t y_axis_sign;
|
uint8_t y_axis_sign;
|
||||||
uint8_t z_axis;
|
uint8_t z_axis;
|
||||||
uint8_t z_axis_sign;
|
uint8_t z_axis_sign;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Step counter param settings
|
* @brief Step counter param settings
|
||||||
*/
|
*/
|
||||||
struct bma423_stepcounter_settings {
|
struct bma423_stepcounter_settings {
|
||||||
/*! Step Counter param 1 */
|
/*! Step Counter param 1 */
|
||||||
uint16_t param1;
|
uint16_t param1;
|
||||||
/*! Step Counter param 2 */
|
/*! Step Counter param 2 */
|
||||||
uint16_t param2;
|
uint16_t param2;
|
||||||
/*! Step Counter param 3 */
|
/*! Step Counter param 3 */
|
||||||
uint16_t param3;
|
uint16_t param3;
|
||||||
/*! Step Counter param 4 */
|
/*! Step Counter param 4 */
|
||||||
uint16_t param4;
|
uint16_t param4;
|
||||||
/*! Step Counter param 5 */
|
/*! Step Counter param 5 */
|
||||||
uint16_t param5;
|
uint16_t param5;
|
||||||
/*! Step Counter param 6 */
|
/*! Step Counter param 6 */
|
||||||
uint16_t param6;
|
uint16_t param6;
|
||||||
/*! Step Counter param 7 */
|
/*! Step Counter param 7 */
|
||||||
uint16_t param7;
|
uint16_t param7;
|
||||||
/*! Step Counter param 8 */
|
/*! Step Counter param 8 */
|
||||||
uint16_t param8;
|
uint16_t param8;
|
||||||
/*! Step Counter param 9 */
|
/*! Step Counter param 9 */
|
||||||
uint16_t param9;
|
uint16_t param9;
|
||||||
/*! Step Counter param 10 */
|
/*! Step Counter param 10 */
|
||||||
uint16_t param10;
|
uint16_t param10;
|
||||||
/*! Step Counter param 11 */
|
/*! Step Counter param 11 */
|
||||||
uint16_t param11;
|
uint16_t param11;
|
||||||
/*! Step Counter param 12 */
|
/*! Step Counter param 12 */
|
||||||
uint16_t param12;
|
uint16_t param12;
|
||||||
/*! Step Counter param 13 */
|
/*! Step Counter param 13 */
|
||||||
uint16_t param13;
|
uint16_t param13;
|
||||||
/*! Step Counter param 14 */
|
/*! Step Counter param 14 */
|
||||||
uint16_t param14;
|
uint16_t param14;
|
||||||
/*! Step Counter param 15 */
|
/*! Step Counter param 15 */
|
||||||
uint16_t param15;
|
uint16_t param15;
|
||||||
/*! Step Counter param 16 */
|
/*! Step Counter param 16 */
|
||||||
uint16_t param16;
|
uint16_t param16;
|
||||||
/*! Step Counter param 17 */
|
/*! Step Counter param 17 */
|
||||||
uint16_t param17;
|
uint16_t param17;
|
||||||
/*! Step Counter param 18 */
|
/*! Step Counter param 18 */
|
||||||
uint16_t param18;
|
uint16_t param18;
|
||||||
/*! Step Counter param 19 */
|
/*! Step Counter param 19 */
|
||||||
uint16_t param19;
|
uint16_t param19;
|
||||||
/*! Step Counter param 20 */
|
/*! Step Counter param 20 */
|
||||||
uint16_t param20;
|
uint16_t param20;
|
||||||
/*! Step Counter param 21 */
|
/*! Step Counter param 21 */
|
||||||
uint16_t param21;
|
uint16_t param21;
|
||||||
/*! Step Counter param 22 */
|
/*! Step Counter param 22 */
|
||||||
uint16_t param22;
|
uint16_t param22;
|
||||||
/*! Step Counter param 23 */
|
/*! Step Counter param 23 */
|
||||||
uint16_t param23;
|
uint16_t param23;
|
||||||
/*! Step Counter param 24 */
|
/*! Step Counter param 24 */
|
||||||
uint16_t param24;
|
uint16_t param24;
|
||||||
/*! Step Counter param 25 */
|
/*! Step Counter param 25 */
|
||||||
uint16_t param25;
|
uint16_t param25;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -385,7 +384,6 @@ uint16_t bma423_write_config_file(struct bma4_dev *dev);
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_get_config_id(uint16_t *config_id, struct bma4_dev *dev);
|
uint16_t bma423_get_config_id(uint16_t *config_id, struct bma4_dev *dev);
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API sets/unsets the user provided interrupt to either
|
* @brief This API sets/unsets the user provided interrupt to either
|
||||||
* interrupt pin1 or pin2 in the sensor.
|
* interrupt pin1 or pin2 in the sensor.
|
||||||
|
@ -422,7 +420,8 @@ uint16_t bma423_get_config_id(uint16_t *config_id, struct bma4_dev *dev);
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_map_interrupt(uint8_t int_line, uint16_t int_map, uint8_t enable, struct bma4_dev *dev);
|
uint16_t bma423_map_interrupt(uint8_t int_line, uint16_t int_map,
|
||||||
|
uint8_t enable, struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API reads the bma423 interrupt status from the sensor.
|
* @brief This API reads the bma423 interrupt status from the sensor.
|
||||||
|
@ -479,8 +478,8 @@ uint16_t bma423_read_int_status(uint16_t *int_status, struct bma4_dev *dev);
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_feature_enable(uint8_t feature, uint8_t enable, struct bma4_dev *dev);
|
uint16_t bma423_feature_enable(uint8_t feature, uint8_t enable,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API performs x, y and z axis remapping in the sensor.
|
* @brief This API performs x, y and z axis remapping in the sensor.
|
||||||
|
@ -492,7 +491,8 @@ uint16_t bma423_feature_enable(uint8_t feature, uint8_t enable, struct bma4_dev
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_set_remap_axes(const struct bma423_axes_remap *remap_data, struct bma4_dev *dev);
|
uint16_t bma423_set_remap_axes(const struct bma423_axes_remap *remap_data,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API reads the x, y and z axis remap data from the sensor.
|
* @brief This API reads the x, y and z axis remap data from the sensor.
|
||||||
|
@ -505,8 +505,8 @@ uint16_t bma423_set_remap_axes(const struct bma423_axes_remap *remap_data, struc
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_get_remap_axes(struct bma423_axes_remap *remap_data, struct bma4_dev *dev);
|
uint16_t bma423_get_remap_axes(struct bma423_axes_remap *remap_data,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API sets the watermark level for step counter
|
* @brief This API sets the watermark level for step counter
|
||||||
|
@ -522,7 +522,8 @@ uint16_t bma423_get_remap_axes(struct bma423_axes_remap *remap_data, struct bma4
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_step_counter_set_watermark(uint16_t step_counter_wm, struct bma4_dev *dev);
|
uint16_t bma423_step_counter_set_watermark(uint16_t step_counter_wm,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API gets the water mark level set for step counter interrupt
|
* @brief This API gets the water mark level set for step counter interrupt
|
||||||
|
@ -538,7 +539,8 @@ uint16_t bma423_step_counter_set_watermark(uint16_t step_counter_wm, struct bma4
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_step_counter_get_watermark(uint16_t *step_counter_wm, struct bma4_dev *dev);
|
uint16_t bma423_step_counter_get_watermark(uint16_t *step_counter_wm,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API resets the counted steps of step counter.
|
* @brief This API resets the counted steps of step counter.
|
||||||
|
@ -613,7 +615,9 @@ uint16_t bma423_select_platform(uint8_t platform, struct bma4_dev *dev);
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_stepcounter_get_parameter(struct bma423_stepcounter_settings *setting, struct bma4_dev *dev);
|
uint16_t
|
||||||
|
bma423_stepcounter_get_parameter(struct bma423_stepcounter_settings *setting,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API sets the parameter1 to parameter7 settings of the
|
* @brief This API sets the parameter1 to parameter7 settings of the
|
||||||
|
@ -627,7 +631,8 @@ uint16_t bma423_stepcounter_get_parameter(struct bma423_stepcounter_settings *se
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_stepcounter_set_parameter(const struct bma423_stepcounter_settings *setting, struct bma4_dev *dev);
|
uint16_t bma423_stepcounter_set_parameter(
|
||||||
|
const struct bma423_stepcounter_settings *setting, struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API enables or disables the step detector feature in the
|
* @brief This API enables or disables the step detector feature in the
|
||||||
|
@ -703,7 +708,9 @@ uint16_t bma423_anymotion_enable_axis(uint8_t axis, struct bma4_dev *dev);
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_set_any_motion_config(const struct bma423_anymotion_config *any_motion, struct bma4_dev *dev);
|
uint16_t
|
||||||
|
bma423_set_any_motion_config(const struct bma423_anymotion_config *any_motion,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*! @brief This API gets the configuration of any motion feature from
|
/*! @brief This API gets the configuration of any motion feature from
|
||||||
* the sensor.
|
* the sensor.
|
||||||
|
@ -741,7 +748,9 @@ uint16_t bma423_set_any_motion_config(const struct bma423_anymotion_config *any_
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_get_any_motion_config(struct bma423_anymotion_config *any_motion, struct bma4_dev *dev);
|
uint16_t
|
||||||
|
bma423_get_any_motion_config(struct bma423_anymotion_config *any_motion,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API sets the sensitivity of wake up feature in the sensor
|
* @brief This API sets the sensitivity of wake up feature in the sensor
|
||||||
|
@ -758,7 +767,8 @@ uint16_t bma423_get_any_motion_config(struct bma423_anymotion_config *any_motion
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_wakeup_set_sensitivity(uint8_t sensitivity, struct bma4_dev *dev);
|
uint16_t bma423_wakeup_set_sensitivity(uint8_t sensitivity,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API gets the sensitivity of wake up feature in the sensor
|
* @brief This API gets the sensitivity of wake up feature in the sensor
|
||||||
|
@ -775,7 +785,8 @@ uint16_t bma423_wakeup_set_sensitivity(uint8_t sensitivity, struct bma4_dev *dev
|
||||||
* @retval 0 -> Success
|
* @retval 0 -> Success
|
||||||
* @retval Any non zero value -> Fail
|
* @retval Any non zero value -> Fail
|
||||||
*/
|
*/
|
||||||
uint16_t bma423_wakeup_get_sensitivity(uint8_t *sensitivity, struct bma4_dev *dev);
|
uint16_t bma423_wakeup_get_sensitivity(uint8_t *sensitivity,
|
||||||
|
struct bma4_dev *dev);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief This API is used to select single/double tap
|
* @brief This API is used to select single/double tap
|
||||||
|
|
1162
src/bma4_defs.h
1162
src/bma4_defs.h
File diff suppressed because it is too large
Load Diff
34
src/config.h
34
src/config.h
|
@ -1,34 +1,34 @@
|
||||||
#ifndef CONFIG_H
|
#ifndef CONFIG_H
|
||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
//display
|
// display
|
||||||
#define DISPLAY_WIDTH 200
|
#define DISPLAY_WIDTH 200
|
||||||
#define DISPLAY_HEIGHT 200
|
#define DISPLAY_HEIGHT 200
|
||||||
//wifi
|
// wifi
|
||||||
#define WIFI_AP_TIMEOUT 60
|
#define WIFI_AP_TIMEOUT 60
|
||||||
#define WIFI_AP_SSID "Watchy AP"
|
#define WIFI_AP_SSID "Watchy AP"
|
||||||
//menu
|
// menu
|
||||||
#define WATCHFACE_STATE -1
|
#define WATCHFACE_STATE -1
|
||||||
#define MAIN_MENU_STATE 0
|
#define MAIN_MENU_STATE 0
|
||||||
#define APP_STATE 1
|
#define APP_STATE 1
|
||||||
#define FW_UPDATE_STATE 2
|
#define FW_UPDATE_STATE 2
|
||||||
#define MENU_HEIGHT 25
|
#define MENU_HEIGHT 25
|
||||||
#define MENU_LENGTH 7
|
#define MENU_LENGTH 7
|
||||||
//set time
|
// set time
|
||||||
#define SET_HOUR 0
|
#define SET_HOUR 0
|
||||||
#define SET_MINUTE 1
|
#define SET_MINUTE 1
|
||||||
#define SET_YEAR 2
|
#define SET_YEAR 2
|
||||||
#define SET_MONTH 3
|
#define SET_MONTH 3
|
||||||
#define SET_DAY 4
|
#define SET_DAY 4
|
||||||
#define HOUR_12_24 24
|
#define HOUR_12_24 24
|
||||||
//BLE OTA
|
// BLE OTA
|
||||||
#define BLE_DEVICE_NAME "Watchy BLE OTA"
|
#define BLE_DEVICE_NAME "Watchy BLE OTA"
|
||||||
#define WATCHFACE_NAME "Watchy 7 Segment"
|
#define WATCHFACE_NAME "Watchy 7 Segment"
|
||||||
#define SOFTWARE_VERSION_MAJOR 1
|
#define SOFTWARE_VERSION_MAJOR 1
|
||||||
#define SOFTWARE_VERSION_MINOR 0
|
#define SOFTWARE_VERSION_MINOR 0
|
||||||
#define SOFTWARE_VERSION_PATCH 0
|
#define SOFTWARE_VERSION_PATCH 0
|
||||||
#define HARDWARE_VERSION_MAJOR 1
|
#define HARDWARE_VERSION_MAJOR 1
|
||||||
#define HARDWARE_VERSION_MINOR 0
|
#define HARDWARE_VERSION_MINOR 0
|
||||||
//Versioning
|
// Versioning
|
||||||
#define WATCHY_LIB_VER "1.4.0"
|
#define WATCHY_LIB_VER "1.4.0"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
STYLE_OPT="{BasedOnStyle: llvm, AlignConsecutiveMacros: true, AlignConsecutiveAssignments: true}"
|
#!/ bin / bash
|
||||||
clang-format --style="$STYLE_OPT" -i *
|
STYLE_OPT = "{BasedOnStyle: llvm, AlignConsecutiveMacros: true, "
|
||||||
|
"AlignConsecutiveAssignments: true}" clang -
|
||||||
|
format-- style = "$STYLE_OPT" - i *
|
||||||
|
|
Loading…
Reference in New Issue