Skip to content
Merged
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
5 changes: 5 additions & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
VERSION_MAJOR = 2
VERSION_MINOR = 0
PATCHLEVEL = 0
VERSION_TWEAK = 0
EXTRAVERSION =
20 changes: 13 additions & 7 deletions boards/openearable_v2_nrf5340_cpuapp_fota.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
cs-gpios = <&gpio0 11 GPIO_ACTIVE_LOW>,<&gpio1 1 GPIO_ACTIVE_LOW>;
status = "okay";
mx25r64: mx25r6435f@1 {

compatible = "jedec,spi-nor";
reg = <1>;
spi-max-frequency = <8000000>;
spi-max-frequency = <32000000>;

jedec-id = [c2 28 17];
sfdp-bfp = [
Expand All @@ -32,9 +31,16 @@
};
};

/*
&gpio_fwd {
uart {
gpios = < &gpio1 0x9 0x0 >, < &gpio1 0x8 0x0 >, < &gpio1 0xb 0x0 >;
/* STEP 5.1 - Configure CDC ACM */
&zephyr_udc0 {
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};

/* STEP 5.2 - Choose CDC ACM for mcumgr */
/ {
chosen {
zephyr,uart-mcumgr = &cdc_acm_uart0;
};
};*/
};
5 changes: 5 additions & 0 deletions boards/teco/openearable_v2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ if ((CONFIG_BOARD_OPENEARABLE_V2_NRF5340_CPUAPP OR CONFIG_BOARD_OPENEARABLE_V2_N
zephyr_library()
zephyr_library_sources(board_init.c)
# openearable_v2_nrf5340_cpunet_reset
endif()

if((CONFIG_BOARD_OPENEARABLE_V2_NRF5340_CPUAPP OR CONFIG_BOARD_OPENEARABLE_V2_NRF5340_CPUAPP_NS) AND CONFIG_MCUBOOT)
zephyr_library()
zephyr_library_sources(mcuboot_hook.c)
endif()
42 changes: 42 additions & 0 deletions boards/teco/openearable_v2/mcuboot_hook.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include <zephyr/init.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>

#include <zephyr/drivers/gpio.h>

int init_load_switch()
{
int ret;
static const struct gpio_dt_spec load_switch_pin = {
.port = DEVICE_DT_GET(DT_NODELABEL(gpio1)),
.pin = 11,
.dt_flags = GPIO_ACTIVE_HIGH
};

ret = device_is_ready(load_switch_pin.port);
if (!ret) {
printk("Pins not ready.\n");
return -1;
}

//LOG_DBG("Turn on loadswitch for flash.");

ret = gpio_pin_configure_dt(&load_switch_pin, GPIO_OUTPUT_ACTIVE);
if (ret != 0) {
printk("Failed to setup Load Switch.\n");
return ret;
}

return 0;
}

SYS_INIT(init_load_switch, PRE_KERNEL_2, 80);

/*
int wait() {
k_msleep(1);

return 0;
}

SYS_INIT(wait, POST_KERNEL, 80);*/
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
sw3 = &button3;*/
//bootloader-led0 = &led0;
mcuboot-button0 = &button0;
//mcuboot-led0 = &led0;
mcuboot-led0 = &led_error;
watchdog0 = &wdt0;
};
};
81 changes: 71 additions & 10 deletions prj_fota.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# CONFIG_STATIC_INIT_GNU=y

# nRF5340 Audio
CONFIG_NRF5340_AUDIO=y

CONFIG_SAMPLE_RATE_CONVERTER=y
CONFIG_SAMPLE_RATE_CONVERTER_FILTER_SIMPLE=y

Expand Down Expand Up @@ -37,6 +38,7 @@ CONFIG_LOG_BUFFER_SIZE=4096
CONFIG_CONSOLE=y
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_STDOUT_CONSOLE=y

# Shell related defines
CONFIG_SHELL=y
Expand Down Expand Up @@ -117,6 +119,7 @@ CONFIG_NEWLIB_LIBC_FLOAT_SCANF=y

CONFIG_CPP=y
CONFIG_GLIBCXX_LIBCPP=y
CONFIG_STD_CPP17=y

#CONFIG_USB=y
CONFIG_USB_CDC_ACM=y
Expand All @@ -128,10 +131,6 @@ CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n

CONFIG_UART_LINE_CTRL=y

#from old version

# CONFIG_NCS_INCLUDE_RPMSG_CHILD_IMAGE=y

CONFIG_BT_USER_DATA_LEN_UPDATE=y
CONFIG_BT_USER_PHY_UPDATE=y

Expand All @@ -143,15 +142,24 @@ CONFIG_BT_CTLR_PHY_2M=y
CONFIG_BT_CTLR_PHY_CODED=n

CONFIG_BT_ISO_TX_BUF_COUNT=4
CONFIG_BT_ISO_RX_BUF_COUNT=4
CONFIG_BT_ISO_RX_BUF_COUNT=8

CONFIG_BT_ATT_PREPARE_COUNT=4
#CONFIG_BT_ISO_RX_MTU=498
#CONFIG_BT_ISO_TX_MTU=498

CONFIG_BT_ATT_PREPARE_COUNT=8
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y

CONFIG_BT_PERIPHERAL=y
CONFIG_BT_AUDIO_PRESENTATION_DELAY_US=40000
CONFIG_BT_AUDIO_MAX_TRANSPORT_LATENCY_MS=20

CONFIG_BT_AUDIO_RETRANSMITS=2

CONFIG_BLE_ACL_CONN_INTERVAL=8

CONFIG_BT_PERIPHERAL=y
CONFIG_BT_OBSERVER=y

CONFIG_SFLOAT=y

#CONFIG_RESET_ON_FATAL_ERROR=y
Expand Down Expand Up @@ -179,4 +187,57 @@ CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_DISK_DRIVERS=y
CONFIG_DISK_DRIVER_SDMMC=y

CONFIG_BT_OBSERVER=y
CONFIG_FS_FATFS_MOUNT_MKFS=n # Disable automatic formatting
CONFIG_FS_FATFS_EXFAT=y # Enable exFAT support

CONFIG_FDSP=n

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

#CONFIG_USB_MASS_STORAGE=y
#CONFIG_MASS_STORAGE_STACK_SIZE=1024

##################################################

# Step 1.1 - Enable SPI driver for the application
#CONFIG_GPIO=y
#CONFIG_SPI=y
#CONFIG_SPI_NOR=y
#CONFIG_SPI_NOR_SFDP_DEVICETREE=y
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
# QSPI drivers are enabled by defualt for some chips.
# Disable it explicitly to be sure QSPI is disabled.
CONFIG_NORDIC_QSPI_NOR=n

# STEP 5.3 - Enable USB subsystem
CONFIG_USB_DEVICE_STACK=y
CONFIG_UART_LINE_CTRL=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n

# STEP 5.2 - Enable mcumgr DFU in application
# Enable MCUMGR
CONFIG_MCUMGR=y

# Enable MCUMGR management for both OS and Images
CONFIG_MCUMGR_GRP_OS=y
CONFIG_MCUMGR_GRP_IMG=y

# Configure MCUMGR transport to UART
CONFIG_MCUMGR_TRANSPORT_UART=y

# Dependencies
# Configure dependencies for CONFIG_MCUMGR
CONFIG_NET_BUF=y
CONFIG_ZCBOR=y
CONFIG_CRC=y

# Configure dependencies for CONFIG_MCUMGR_GRP_IMG
CONFIG_FLASH=y
CONFIG_IMG_MANAGER=y

# Configure dependencies for CONFIG_IMG_MANAGER
CONFIG_STREAM_FLASH=y
CONFIG_FLASH_MAP=y

# Configure dependencies for CONFIG_MCUMGR_TRANSPORT_UART
CONFIG_BASE64=y
5 changes: 2 additions & 3 deletions src/Battery/PowerManager.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ struct load_switch_data {
bool default_on;
};

static int b_init(const struct device *dev)
/*static int b_init(const struct device *dev)
{
ARG_UNUSED(dev);

struct load_switch_data *data_1_8 = dev->data;

if(data_1_8->default_on) {
/* Gerät sofort in SUSPEND setzen */
int ret = pm_device_action_run(ls_1_8, PM_DEVICE_ACTION_SUSPEND);
if (ret < 0) {
printk("Failed to suspend device: %d", ret);
Expand All @@ -30,4 +29,4 @@ static int b_init(const struct device *dev)
return 0;
}

SYS_INIT(b_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
SYS_INIT(b_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);*/
26 changes: 13 additions & 13 deletions src/Battery/PowerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "macros_common.h"

#include <stdio.h>
#include <zephyr/sys/poweroff.h>
#include <zephyr/sys/reboot.h>
#include <zephyr/shell/shell.h>
Expand Down Expand Up @@ -114,7 +115,7 @@ void PowerManager::fuel_gauge_work_handler(struct k_work * work) {

// full discharge
//if (bat.FD) k_work_reschedule(&power_manager.power_down_work, K_NO_WAIT);
if (bat.SYSDWN) k_work_reschedule(&power_manager.power_down_work, K_NO_WAIT);
if (power_manager.power_on && bat.SYSDWN) k_work_reschedule(&power_manager.power_down_work, K_NO_WAIT);

if (bat.CHGINH) {
power_manager.charging_disabled = true;
Expand Down Expand Up @@ -198,10 +199,13 @@ int PowerManager::begin() {
bool charging = battery_controller.power_connected();

if (!battery_condition) {
power_on = false;
// LOG_ERR("Bad battery condition.");
if (!charging){
//TODO: Flash red LED once
return power_down(false);
} else {
printf("Voltage: %.3f V\n", fuel_gauge.voltage());
}
}

Expand Down Expand Up @@ -334,14 +338,13 @@ bool PowerManager::check_battery() {
battery_controller.write_charging_control(110);
battery_controller.enable_charge();
}
} else {
bat_status bs = fuel_gauge.battery_status();
}

if (bs.FD) return false;
bat_status bs = fuel_gauge.battery_status();
if (bs.FD) return false;

//gauge_status gs = fuel_gauge.gauging_state();
//if (gs.edv1) return false; // critical battery state
}
//gauge_status gs = fuel_gauge.gauging_state();
//if (gs.edv1) return false; // critical battery state

return true;
}
Expand Down Expand Up @@ -478,15 +481,13 @@ int PowerManager::power_down(bool fault) {
LOG_PANIC();

ret = bt_mgmt_stop_watchdog();
ERR_CHK(ret);
//ERR_CHK(ret);

dac.end();

// TODO: check states of load switch (should already be suspended
// if all devieses have been terminated correctly)

ret = pm_device_action_run(ls_sd, PM_DEVICE_ACTION_SUSPEND);

// turn off error led
gpio_pin_set_dt(&error_led, 0);

Expand All @@ -496,12 +497,11 @@ int PowerManager::power_down(bool fault) {
return 0;
}

ret = pm_device_action_run(ls_1_8, PM_DEVICE_ACTION_SUSPEND);
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);

//ERR_CHK(ret);

/*const struct device *const i2c = DEVICE_DT_GET(DT_NODELABEL(i2c1));
ret = pm_device_action_run(i2c, PM_DEVICE_ACTION_SUSPEND);
ERR_CHK(ret);*/
Expand Down
2 changes: 1 addition & 1 deletion src/audio/streamctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static void button_msg_sub_thread(void)
msg.button_action);

if (msg.button_action != BUTTON_RELEASED) {
LOG_WRN("Unhandled button action");
// LOG_WRN("Unhandled button action");
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ int bt_mgmt_ctlr_cfg_init(bool watchdog_enable)
return 0;
}

int bt_mgmt_stop_watchdog()
int bt_mgmt_stop_watchdog(void)
{
k_timer_stop(&ctlr_poll_timer);
int ret = task_wdt_delete(wdt_ch_id);
return ret;
return ret;
}
7 changes: 7 additions & 0 deletions src/drivers/ADAU1860.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ ADAU1860::ADAU1860(TWIM * i2c) : _i2c(i2c) {
int ADAU1860::begin() {
int ret;

if (_active) return 0;

_active = true;

ret = pm_device_runtime_get(ls_1_8);
if (ret != 0) {
LOG_ERR("Failed to get power domain 1.8V");
Expand Down Expand Up @@ -307,6 +311,9 @@ int ADAU1860::setup_FDSP() {
int ADAU1860::end() {
int ret;

if (!_active) return 0;
_active = false;

// pull-down PD pin
gpio_pin_set_dt(&dac_enable_pin, 0);

Expand Down
2 changes: 2 additions & 0 deletions src/drivers/ADAU1860.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,8 @@ class ADAU1860 {
uint64_t last_i2c;
TWIM *_i2c;

bool _active = false;

//const struct gpio_dt_spec pg_pin = GPIO_DT_SPEC_GET(DT_NODELABEL(bq25120a), pg_gpios);
};

Expand Down
Loading