Added I2C settings app (#85)
This commit is contained in:
committed by
GitHub
parent
d8731eaa17
commit
c8f63adba4
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "I2cCompat.h"
|
||||
#include <CoreTypes.h>
|
||||
#include "CoreTypes.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace tt::hal::i2c {
|
||||
@@ -13,6 +14,7 @@ typedef enum {
|
||||
} InitMode;
|
||||
|
||||
typedef struct {
|
||||
std::string name;
|
||||
/** The port to operate on */
|
||||
i2c_port_t port;
|
||||
/** Whether this bus should be initialized when device starts up */
|
||||
|
||||
@@ -39,7 +39,7 @@ bool init(const std::vector<i2c::Configuration>& configurations) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool configure_locked(i2c_port_t port, const i2c_config_t& configuration) {
|
||||
static bool configureLocked(i2c_port_t port, const i2c_config_t& configuration) {
|
||||
Data& data = dataArray[port];
|
||||
if (data.isStarted) {
|
||||
TT_LOG_E(TAG, "(%d) Cannot reconfigure while interface is started", port);
|
||||
@@ -55,7 +55,7 @@ static bool configure_locked(i2c_port_t port, const i2c_config_t& configuration)
|
||||
|
||||
esp_err_t configure(i2c_port_t port, const i2c_config_t& configuration) {
|
||||
lock(port);
|
||||
bool result = configure_locked(port, configuration);
|
||||
bool result = configureLocked(port, configuration);
|
||||
unlock(port);
|
||||
return result;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ bool start(i2c_port_t port) {
|
||||
lock(port);
|
||||
dataArray[port].isStarted = true;
|
||||
unlock(port);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool stop(i2c_port_t port) {
|
||||
|
||||
@@ -76,7 +76,7 @@ static int32_t sdcard_task(void* context) {
|
||||
}
|
||||
|
||||
static void on_start(Service& service) {
|
||||
if (get_hardware_config().sdcard != nullptr) {
|
||||
if (hal::getConfiguration().sdcard != nullptr) {
|
||||
ServiceData* data = service_data_alloc();
|
||||
service.setData(data);
|
||||
data->thread->start();
|
||||
|
||||
@@ -31,7 +31,7 @@ static void register_and_start_system_services() {
|
||||
}
|
||||
}
|
||||
|
||||
void init(const hal::Configuration& config) {
|
||||
void initHeadless(const hal::Configuration& config) {
|
||||
#ifdef ESP_PLATFORM
|
||||
esp_init();
|
||||
#endif
|
||||
@@ -40,9 +40,13 @@ void init(const hal::Configuration& config) {
|
||||
register_and_start_system_services();
|
||||
}
|
||||
|
||||
const hal::Configuration& get_hardware_config() {
|
||||
namespace hal {
|
||||
|
||||
const Configuration& getConfiguration() {
|
||||
tt_assert(hardwareConfig != nullptr);
|
||||
return *hardwareConfig;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace hal
|
||||
|
||||
} // namespace tt
|
||||
|
||||
@@ -5,8 +5,12 @@
|
||||
|
||||
namespace tt {
|
||||
|
||||
void init(const hal::Configuration& config);
|
||||
|
||||
const hal::Configuration& get_hardware_config();
|
||||
void initHeadless(const hal::Configuration& config);
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace tt::hal {
|
||||
|
||||
const Configuration& getConfiguration();
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user