Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/openearable_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ struct sensor_config {
uint8_t storageOptions;
} __attribute__((packed));

struct seal_check_data {
uint8_t version;
uint8_t quality;
uint8_t mean_magnitude;
uint8_t num_peaks;
uint16_t frequencies[9]; // 12.4 fixed point
uint16_t magnitudes[9];
} __attribute__((packed));

struct battery_settings {
float u_nominal;
Expand Down
9 changes: 9 additions & 0 deletions prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ CONFIG_SFLOAT=y

CONFIG_FPU=y

CONFIG_CMSIS_DSP=y
CONFIG_CMSIS_DSP_TRANSFORM=y
CONFIG_CMSIS_DSP_COMPLEXMATH=y

CONFIG_NEWLIB_LIBC=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_NEWLIB_LIBC_FLOAT_SCANF=y
Expand Down Expand Up @@ -182,6 +186,11 @@ CONFIG_FS_FATFS_EXFAT=y # Enable exFAT support

CONFIG_FDSP=y

# CMSIS-DSP Configuration
CONFIG_CMSIS_DSP=y
CONFIG_CMSIS_DSP_TRANSFORM=y
CONFIG_CMSIS_DSP_COMPLEXMATH=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

#CONFIG_USB_MASS_STORAGE=y
Expand Down
4 changes: 4 additions & 0 deletions prj_fota.conf
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,7 @@ CONFIG_MCUMGR_GRP_OS_RESET_HOOK=y
#CONFIG_MCUMGR_GRP_SETTINGS_ACCESS_HOOK=y

CONFIG_SETUP_FUEL_GAUGE=y

CONFIG_CMSIS_DSP=y
CONFIG_CMSIS_DSP_TRANSFORM=y
CONFIG_CMSIS_DSP_COMPLEXMATH=y
8 changes: 0 additions & 8 deletions src/Battery/BQ25120a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,8 @@ uint8_t BQ25120a::write_LDO_voltage_control(float volt) {

readReg(registers::LS_LDO_CTRL, &status, sizeof(status));

//status |= (((uint16_t)((volt - 0.8) * 10)) & 0x1F) << 2;
status &= 1 << 7;
status |= ((uint8_t)((volt - 0.8f) * 10 + EPS)) << 2;
//status |= 1 << 7;

writeReg(registers::LS_LDO_CTRL, &status, sizeof(status));

Expand Down Expand Up @@ -292,8 +290,6 @@ chrg_state BQ25120a::read_termination_control() {

struct chrg_state chrg;

// if (!ret) printk("failed to read\n");

chrg.enabled = status & 0x2;
//chrg.high_impedance = status & 0x1;

Expand Down Expand Up @@ -343,8 +339,6 @@ ilim_uvlo BQ25120a::read_uvlo_ilim() {

bool ret = readReg(registers::ILIM_UVLO, (uint8_t *) &status, sizeof(status));

// if (!ret) printk("failed to read\n");

param.uvlo_v = CLAMP(3.0f- 0.2f * ((status & 0x7) - 2), 2.2, 3.0);
param.lim_mA = 50.f + 50.f * ((status >> 3) & 0x7);

Expand Down Expand Up @@ -410,8 +404,6 @@ button_state BQ25120a::read_button_state() {
uint8_t status = 0;
bool ret = readReg(registers::BTN_CTRL, (uint8_t *) &status, sizeof(status));

// if (!ret) printk("failed to read\n");

btn.wake_1 = status & 0x2;
btn.wake_2 = status & 0x1;

Expand Down
24 changes: 2 additions & 22 deletions src/Battery/PowerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ int PowerManager::power_down(bool fault) {
ret = pm_device_action_run(ls_sd, PM_DEVICE_ACTION_SUSPEND);
ret = pm_device_action_run(ls_3_3, PM_DEVICE_ACTION_SUSPEND);
ret = pm_device_action_run(ls_1_8, PM_DEVICE_ACTION_SUSPEND);
ret = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);
ret = pm_device_action_run(cons, PM_DEVICE_ACTION_SUSPEND);

/*const struct device *const i2c = DEVICE_DT_GET(DT_NODELABEL(i2c1));
ret = pm_device_action_run(i2c, PM_DEVICE_ACTION_SUSPEND);
Expand Down Expand Up @@ -666,27 +666,7 @@ void PowerManager::charge_task() {
battery_controller.enable_charge();
}

//if (last_charging_state != charging_state || ) {
k_work_submit(&fuel_gauge_work);
//state_inidicator.set_state()
/*switch (charging_state) {
case 0:
LOG_INF("charging state: ready");
break;
case 1:
LOG_INF("charging state: charging");
break;
case 2:
LOG_INF("charging state: done");
break;
case 3:
LOG_WRN("charging state: fault");

//battery_controller.setup(_battery_settings);

break;
}*/
//}
k_work_submit(&fuel_gauge_work);

last_charging_state = charging_state;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ParseInfo/ParseType.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ enum ParseType {
PARSE_TYPE_DOUBLE,
};

const int parseTypeSizes[] = {
static const int parseTypeSizes[] = {
1, // PARSE_TYPE_INT8
1, // PARSE_TYPE_UINT8

Expand Down
20 changes: 12 additions & 8 deletions src/SD_Card/SDLogger/SDLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ static_assert(BUFFER_SIZE % SD_BLOCK_SIZE == 0, "BUFFER_SIZE must be a multiple

// Singleton pattern
class SDLogger {
protected:
// Add static instance pointer for work handler
//static SDLogger* instance_ptr;
//friend void sd_work_handler(struct k_work* work);

private:

SDCardManager* sd_card = nullptr;
Expand Down Expand Up @@ -84,14 +79,23 @@ class SDLogger {
*/
int write_sensor_data(const void* const* data_blocks, const size_t* lengths, size_t block_count);

/**
* @brief Write a single sensor_data message to the log file
* @param msg The sensor_data message to write
* @return 0 on success, negative error code on failure
*/
int write_sensor_data(const sensor_data& msg);

/**
* @brief End logging and close the current file
* @return 0 on success, negative error code on failure
*/
* @brief End logging and close the current file
* @return 0 on success, negative error code on failure
*/
int end();

/**
* @brief Check if the logger is currently recording
* @return true if active, false otherwise
*/
bool is_active();

SDLogger(SDLogger const&) = delete;
Expand Down
1 change: 1 addition & 0 deletions src/SensorManager/SensorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ static void config_work_handler(struct k_work *work) {
std::string filename = recording_name_prefix + std::to_string(micros());
int ret = sdlogger.begin(filename);
if (ret == 0) state_indicator.set_sd_state(SD_RECORDING);
else LOG_ERR("Failed to start SDLogger, ret: %d", ret);
}
} else if (sd_sensors.find(config.sensorId) != sd_sensors.end()) {
sd_sensors.erase(config.sensorId);
Expand Down
Loading
Loading