unPhone implementation and more (#169)

- Implemented [unPhone](https://unphone.net/) v9 board
- Updated `.clang-format` to better reflect the intended code style
- Fix SD card compatibility issues for all boards (frequency wasn't set well)
- Moved `I2cDevice` class from CoreS3 board project to TactilityHeadless project
- Tactility configuration now has default empty lists for apps and services fields
- Fix for Launcher app: we don't need padding when showing it vertically
- Fix for I2cDevice read/write calls that checked for `esp_err_t` instead of `bool`
- Fix for TinyUSB init that checked for `esp_err_t` instead of `bool`
This commit is contained in:
Ken Van Hoeylandt
2025-01-19 16:57:00 +01:00
committed by GitHub
parent 3ea02d912f
commit 72230129bb
48 changed files with 1890 additions and 33 deletions
+64
View File
@@ -0,0 +1,64 @@
#include "Bq24295.h"
#include "Log.h"
#define TAG "bq24295"
/** Reference: https://gitlab.com/hamishcunningham/unphonelibrary/-/blob/main/unPhone.h?ref_type=heads */
namespace registers {
static const uint8_t WATCHDOG = 0x05U; // Charge end/timer cntrl
static const uint8_t OPERATION_CONTROL = 0x07U; // Misc operation control
static const uint8_t STATUS = 0x08U; // System status
static const uint8_t VERSION = 0x0AU; // Vendor/part/revision status
} // namespace registers
// region Watchdog
bool Bq24295::getWatchDog(uint8_t value) const {
return readRegister8(registers::WATCHDOG, value);
}
bool Bq24295::setWatchDogBitOn(uint8_t mask) const {
return bitOn(registers::WATCHDOG, mask);
}
bool Bq24295::setWatchDogBitOff(uint8_t mask) const {
return bitOff(registers::WATCHDOG, mask);
}
// endregoin
// region Operation Control
bool Bq24295::getOperationControl(uint8_t value) const {
return readRegister8(registers::OPERATION_CONTROL, value);
}
bool Bq24295::setOperationControlBitOn(uint8_t mask) const {
return bitOn(registers::OPERATION_CONTROL, mask);
}
bool Bq24295::setOperationControlBitOff(uint8_t mask) const {
return bitOff(registers::OPERATION_CONTROL, mask);
}
// endregion
// region Other
bool Bq24295::getStatus(uint8_t& value) const {
return readRegister8(registers::STATUS, value);
}
bool Bq24295::getVersion(uint8_t& value) const {
return readRegister8(registers::VERSION, value);
}
void Bq24295::printInfo() const {
uint8_t version, status;
if (getStatus(status) && getVersion(version)) {
TT_LOG_I(TAG, "Version %d, status %02x", version, status);
} else {
TT_LOG_E(TAG, "Failed to retrieve version and/or status");
}
}
// endregion
+25
View File
@@ -0,0 +1,25 @@
#pragma once
#include "hal/i2c/I2cDevice.h"
#define BQ24295_ADDRESS 0x6BU
class Bq24295 : I2cDevice {
public:
explicit Bq24295(i2c_port_t port) : I2cDevice(port, BQ24295_ADDRESS) {}
bool getWatchDog(uint8_t value) const;
bool setWatchDogBitOn(uint8_t mask) const;
bool setWatchDogBitOff(uint8_t mask) const;
bool getOperationControl(uint8_t value) const;
bool setOperationControlBitOn(uint8_t mask) const;
bool setOperationControlBitOff(uint8_t mask) const;
bool getStatus(uint8_t& value) const;
bool getVersion(uint8_t& value) const;
void printInfo() const;
};