Skip to content

Commit

Permalink
Firmware fixes (#1693)
Browse files Browse the repository at this point in the history
1. Change the DK1 project, so it builds with nRF SDK 2.7.0
-- TODO: This only makes it buildable. The firmware itself needs to be
updated to support properly DK1
2. Change all the printk to LOG_PRINTK
3. Streamline the logging config in DK2
  • Loading branch information
beastoin authored Jan 14, 2025
2 parents 52c8ade + 6bc7db9 commit d67527b
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 83 deletions.
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"recommendations": [
"nordic-semiconductor.nrf-connect-extension-pack",
"trond-snekvik.kconfig-lang"
"nordic-semiconductor.nrf-connect-extension-pack"
]
}
11 changes: 7 additions & 4 deletions Friend/firmware/firmware_v1.0/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
"CMAKE_BUILD_TYPE": "Debug",
"PLATFORM": "nrf52840",
"BOARD": "xiao_ble_sense",
"CACHED_CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv1.conf"
"CACHED_CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv1.conf",
"CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv1.conf",
"DTC_OVERLAY_FILE": "${sourceDir}/overlay/xiao_ble_sense_devkitv1.overlay"
}
},{
"name": "build_xiao_ble_sense_devkitv1-spisd.",
"name": "build_xiao_ble_sense_devkitv1-spisd",
"displayName": "Devkit V1 (with SPI SD)",
"configuration": "Debug",
"hidden": false,
Expand All @@ -35,10 +37,11 @@
"PLATFORM": "nrf52840",
"BOARD": "xiao_ble_sense",
"CACHED_CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv1-spisd.conf",
"CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv1-spisd.conf",
"DTC_OVERLAY_FILE": "${sourceDir}/overlay/xiao_ble_sense_devkitv1-spisd.overlay"
}
}
},{
"name": "build_xiao_ble_sense_devkitv2-adafruit.",
"name": "build_xiao_ble_sense_devkitv2-adafruit",
"displayName": "Devkit V2 (with Adafruit BFF Module)",
"configuration": "Debug",
"hidden": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
#

CONFIG_GPIO=y
CONFIG_NRFX_PDM=y
# CONFIG_NRFX_PDM=y
CONFIG_ADC=y
# DT_HAS_NORDIC_NRF_PDM_ENABLED=y
CONFIG_AUDIO=y
CONFIG_AUDIO_DMIC=y
CONFIG_AUDIO_DMIC_NRFX_PDM=y

# To flash via dev board
#CONFIG_BUILD_OUTPUT_UF2=n
Expand Down Expand Up @@ -101,4 +105,3 @@ CONFIG_SENSOR=y
# CONFIG_RTT_CONSOLE=y
# CONFIG_LOG_BACKEND_RTT=y
CONFIG_CODEC_OPUS=y

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ CONFIG_BT_DIS_MODEL="Omi DevKit 2"
CONFIG_BT_DIS_MANUF="Based Hardware"
CONFIG_BT_DIS_FW_REV=y
CONFIG_BT_DIS_HW_REV=y
CONFIG_BT_DIS_FW_REV_STR="2.0.8"
CONFIG_BT_DIS_FW_REV_STR="2.0.9"
CONFIG_BT_DIS_HW_REV_STR="Seeed Xiao BLE Sense"

#
Expand Down Expand Up @@ -79,23 +79,39 @@ CONFIG_NORDIC_QSPI_NOR=n
# Console
#
# Disable the lines to enable console log
CONFIG_CONSOLE=n
CONFIG_CONSOLE=y
CONFIG_PRINTK=y

#
# Debug
# Logs
#
# Enable the lines below to enable debug logs via UART/USB

# CONFIG_DEBUG=y
# Enable the lines below to enable logs via UART/USB
# CONFIG_LOG=y
# CONFIG_LOG_PRINTK=y
# CONFIG_LOG_MODE_IMMEDIATE=y
# CONFIG_DEBUG_OPTIMIZATIONS=y
# CONFIG_SERIAL=y
# CONFIG_UART_CONSOLE=y
# CONFIG_LOG_MODE_IMMEDIATE=y
# CONFIG_LOG_BACKEND_UART=y
# CONFIG_LOG_BACKEND_UART_OUTPUT_TEXT=y
# CONFIG_LOG_DEFAULT_LEVEL=3

# Enable the lines below to enable debug logs
# CONFIG_LOG_DEFAULT_LEVEL=4

#
# Log level and buffer size
#

# CONFIG_LOG_OVERRIDE_LEVEL=4
# CONFIG_LOG_BUFFER_SIZE=32000
# CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=4096

#
# Debug
#

# CONFIG_DEBUG=y
# CONFIG_DEBUG_OPTIMIZATIONS=y
# CONFIG_SERIAL=y

#
# Debug (This value breaks some builds)
Expand All @@ -104,20 +120,16 @@ CONFIG_CONSOLE=n
# CONFIG_ASSERT=y

#
# Log Levels
# BT log configuration
#

# CONFIG_BT_DEBUG_LOG=y
# CONFIG_BT_L2CAP_LOG_LEVEL_DBG=y
# CONFIG_BT_LOG_LEVEL_DBG=y

# CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=4096
# CONFIG_BT_RX_STACK_SIZE=4096
# CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE=4096
# CONFIG_BT_DEBUG_LOG=y
# CONFIG_LOG_BUFFER_SIZE=32000
# CONFIG_LOG_OVERRIDE_LEVEL=4
# CONFIG_LOG_PROCESS_THREAD_STACK_SIZE=4096
# CONFIG_BT_RX_STACK_SIZE=4096
# CONFIG_BT_CTLR_RX_PRIO_STACK_SIZE=4096

Expand All @@ -136,7 +148,6 @@ CONFIG_FILE_SYSTEM=y
CONFIG_FAT_FILESYSTEM_ELM=y
CONFIG_FS_FATFS_MOUNT_MKFS=y
CONFIG_FS_FATFS_EXFAT=y
# CONFIG_PRINTK=y
#nessessary?
CONFIG_MAIN_STACK_SIZE=2048
# CONFIG_DISK_DRIVER_SDMMC=y
Expand Down
26 changes: 11 additions & 15 deletions Friend/firmware/firmware_v1.0/src/button.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void button_pressed_callback(const struct device *dev, struct gpio_callback *cb,
uint32_t pins)
{
int temp = gpio_pin_get_raw(dev,d5_pin_input.pin);
printf("button_pressed_callback %d\n", temp);
LOG_PRINTK("button_pressed_callback %d\n", temp);
if (temp)
{
was_pressed = false;
Expand All @@ -75,15 +75,13 @@ void check_button_level(struct k_work *work_item);

K_WORK_DELAYABLE_DEFINE(button_work, check_button_level);


#define DEFAULT_STATE 0
#define SINGLE_TAP 1
#define DOUBLE_TAP 2
#define LONG_TAP 3
#define BUTTON_PRESS 4
#define BUTTON_RELEASE 5


// 4 is button down, 5 is button up
static FSM_STATE_T current_button_state = IDLE;
static uint32_t inc_count_1 = 0;
Expand All @@ -100,7 +98,7 @@ static void reset_count()
static inline void notify_press()
{
final_button_state[0] = BUTTON_PRESS;
LOG_INF("pressed");
LOG_INF("Button pressed");
struct bt_conn *conn = get_current_connection();
if (conn != NULL)
{
Expand All @@ -111,20 +109,18 @@ static inline void notify_press()
static inline void notify_unpress()
{
final_button_state[0] = BUTTON_RELEASE;
LOG_INF("unpressed");
printf("unpressed\n");
LOG_INF("Button released");
struct bt_conn *conn = get_current_connection();
if (conn != NULL)
{
printf("unpressed sent\n");
bt_gatt_notify(conn, &button_service.attrs[1], &final_button_state, sizeof(final_button_state));
}
}

static inline void notify_tap()
{
final_button_state[0] = SINGLE_TAP;
LOG_INF("tap");
LOG_INF("Button single tap");
struct bt_conn *conn = get_current_connection();
if (conn != NULL)
{
Expand All @@ -135,7 +131,7 @@ static inline void notify_tap()
static inline void notify_double_tap()
{
final_button_state[0] = DOUBLE_TAP; //button press
LOG_INF("double tap");
LOG_INF("Button double tap");
struct bt_conn *conn = get_current_connection();
if (conn != NULL)
{
Expand All @@ -146,7 +142,7 @@ static inline void notify_double_tap()
static inline void notify_long_tap()
{
final_button_state[0] = LONG_TAP; //button press
LOG_INF("long tap");
LOG_INF("Button long tap");
struct bt_conn *conn = get_current_connection();
if (conn != NULL)
{
Expand Down Expand Up @@ -224,7 +220,7 @@ void check_button_level(struct k_work *work_item)
// Single tap
if (event == BUTTON_EVENT_SINGLE_TAP)
{
printk("single tap detected\n");
LOG_PRINTK("single tap detected\n");
btn_last_event = event;
notify_tap();

Expand All @@ -237,23 +233,23 @@ void check_button_level(struct k_work *work_item)
// Double tap
if (event == BUTTON_EVENT_DOUBLE_TAP)
{
printk("double tap detected\n");
LOG_PRINTK("double tap detected\n");
btn_last_event = event;
notify_double_tap();
}

// Long press, one time event
if (event == BUTTON_EVENT_LONG_PRESS && btn_last_event != BUTTON_EVENT_LONG_PRESS)
{
printk("long press detected\n");
LOG_PRINTK("long press detected\n");
btn_last_event = event;
notify_long_tap();
}

// Releases, one time event
if (event == BUTTON_EVENT_RELEASE && btn_last_event != BUTTON_EVENT_RELEASE)
{
printk("release detected\n");
LOG_PRINTK("release detected\n");
btn_last_event = event;
notify_unpress();

Expand Down Expand Up @@ -448,7 +444,7 @@ void check_button_level(struct k_work *work_item)
static ssize_t button_data_read_characteristic(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset)
{
LOG_INF("button_data_read_characteristic");
printf("was_pressed: %d\n", final_button_state[0]);
LOG_PRINTK("was_pressed: %d\n", final_button_state[0]);
return bt_gatt_attr_read(conn, attr, buf, len, offset, &final_button_state, sizeof(final_button_state));
}

Expand Down
2 changes: 1 addition & 1 deletion Friend/firmware/firmware_v1.0/src/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void codec_entry()
// Check if we have enough data
if (ring_buf_size_get(&codec_ring_buf) < CODEC_PACKAGE_SAMPLES * 2)
{
// printk("waiting on data....\n");
// LOG_PRINTK("waiting on data....\n");
k_sleep(K_MSEC(10));
continue;
}
Expand Down
Loading

0 comments on commit d67527b

Please sign in to comment.