diff --git a/Friend/firmware/firmware_v1.0/CMakePresets.json b/Friend/firmware/firmware_v1.0/CMakePresets.json index 6df34505f..2cfb35de2 100644 --- a/Friend/firmware/firmware_v1.0/CMakePresets.json +++ b/Friend/firmware/firmware_v1.0/CMakePresets.json @@ -1,58 +1,78 @@ { "version": 2, - "cmakeMinimumRequired": { - "major": 3, - "minor": 20, - "patch": 0 - }, - "configurePresets": [ - { - "name": "build_xiao_ble_sense_devkitv1", - "displayName": "Devkit V1", - "configuration": "Debug", - "hidden": false, - "description": "Debug build for devkit v1 device with no external modules", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/build_xiao_ble_sense_devkitv1", - "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": "YES", - "CMAKE_BUILD_TYPE": "Debug", - "PLATFORM": "nrf52840", - "BOARD": "xiao_ble_sense", - "CACHED_CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv1.conf" + "cmakeMinimumRequired": { + "major": 3, + "minor": 20, + "patch": 0 + }, + "configurePresets": [ + { + "name": "build_xiao_ble_sense_devkitv1", + "displayName": "Devkit V1", + "configuration": "Debug", + "hidden": false, + "description": "Debug build for devkit v1 device with no external modules", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/build_xiao_ble_sense_devkitv1", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "YES", + "CMAKE_BUILD_TYPE": "Debug", + "PLATFORM": "nrf52840", + "BOARD": "xiao_ble_sense", + "CACHED_CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv1.conf" } - },{ - "name": "build_xiao_ble_sense_devkitv1-spisd.", - "displayName": "Devkit V1 (with SPI SD)", - "configuration": "Debug", - "hidden": false, - "description": "Debug build for devkit v1 device with external SPI SD card module", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/build_xiao_ble_sense_devkitv1-spisd", - "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": "YES", - "CMAKE_BUILD_TYPE": "Debug", - "PLATFORM": "nrf52840", - "BOARD": "xiao_ble_sense", - "CACHED_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_devkitv1-spisd.", + "displayName": "Devkit V1 (with SPI SD)", + "configuration": "Debug", + "hidden": false, + "description": "Debug build for devkit v1 device with external SPI SD card module", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/build_xiao_ble_sense_devkitv1-spisd", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "YES", + "CMAKE_BUILD_TYPE": "Debug", + "PLATFORM": "nrf52840", + "BOARD": "xiao_ble_sense", + "CACHED_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.", - "displayName": "Devkit V2 (with Adafruit BFF Module)", - "configuration": "Debug", - "hidden": false, - "description": "Debug build for devkit v2 device with adafruit audio bff module", - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/build_xiao_ble_sense_devkitv2-adafruit", - "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": "YES", - "CMAKE_BUILD_TYPE": "Debug", - "PLATFORM": "nrf52840", - "BOARD": "xiao_ble_sense", - "CACHED_CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv2-adafruit.conf", - "CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv2-adafruit.conf", - "DTC_OVERLAY_FILE": "${sourceDir}/overlay/xiao_ble_sense_devkitv2-adafruit.overlay" + }, + { + "name": "build_xiao_ble_sense_devkitv2-adafruit.", + "displayName": "Devkit V2 (with Adafruit BFF Module)", + "configuration": "Debug", + "hidden": false, + "description": "Debug build for devkit v2 device with adafruit audio bff module", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/build_xiao_ble_sense_devkitv2-adafruit", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "YES", + "CMAKE_BUILD_TYPE": "Debug", + "PLATFORM": "nrf52840", + "BOARD": "xiao_ble_sense", + "CACHED_CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv2-adafruit.conf", + "CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv2-adafruit.conf", + "DTC_OVERLAY_FILE": "${sourceDir}/overlay/xiao_ble_sense_devkitv2-adafruit.overlay" + } + }, + { + "name": "build_xiao_ble_sense_devkitv2-5340.", + "displayName": "Devkit V2 (with nrf5340)", + "configuration": "Debug", + "hidden": false, + "description": "Debug build for devkit v2 device with nrf5340", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/build_xiao_ble_sense_devkitv2-5340", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "YES", + "CMAKE_BUILD_TYPE": "Debug", + "PLATFORM": "nrf5340", + "BOARD": "xiao_ble_sense", + "CACHED_CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv2-5340.conf", + "CONF_FILE": "${sourceDir}/prj_xiao_ble_sense_devkitv2-5340.conf", + "DTC_OVERLAY_FILE": "${sourceDir}/overlay/xiao_ble_sense_devkitv2-5340.overlay" } } ] diff --git a/Friend/firmware/firmware_v1.0/Kconfig b/Friend/firmware/firmware_v1.0/Kconfig index e60ad2fe5..29af1e556 100644 --- a/Friend/firmware/firmware_v1.0/Kconfig +++ b/Friend/firmware/firmware_v1.0/Kconfig @@ -1,10 +1,9 @@ source "Kconfig.zephyr" -menu "Friend Configuration" +menu "Omi Configuration" config CODEC_OPUS bool "Opus Audio Codec Support" default n - config OFFLINE_STORAGE bool "Offline SD Card Storage Support" default n @@ -18,3 +17,12 @@ config ENABLE_SPEAKER bool "Enable the speaker!!" default n endmenu + +menu "Build Configuration" +config LEGACY_SDK + bool "Using the legacy SDK(<=2.7.0)!!" + default y +config LEGACY_SOC + bool "Using the legacy SOC(nrf52840)!!" + default y +endmenu diff --git a/Friend/firmware/firmware_v1.0/overlay/xiao_ble_sense_devkitv2-5340.overlay b/Friend/firmware/firmware_v1.0/overlay/xiao_ble_sense_devkitv2-5340.overlay new file mode 100644 index 000000000..a8f8a41db --- /dev/null +++ b/Friend/firmware/firmware_v1.0/overlay/xiao_ble_sense_devkitv2-5340.overlay @@ -0,0 +1,102 @@ + +//&i2s0 { +// status = "okay"; +// pinctrl-0 = <&i2s0_default>; +// pinctrl-names = "default"; +// label = "I2S_0"; +//}; +// +//&pinctrl { +// i2s0_default: i2s0_default { +// group1 { +// psels = , // SCK pin (bit clock) A3 +// , // LRCK pin (word select clock) A2 +// ; // SDOUT pin (data out) A1 +// }; +// }; +//}; +// +//&spi2 { +// status = "okay"; +// pinctrl-0 = <&custom_spi>; +// pinctrl-1 = <&custom_spi>; +// pinctrl-names = "default", "sleep"; +// cs-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>; // CS pin on P0.28 +// +// sdhc0: sdhc@0 { +// compatible = "zephyr,sdhc-spi-slot"; +// reg = <0>; +// status = "okay"; +// label = "SDHC_0"; +// mmc { +// compatible = "zephyr,sdmmc-disk"; +// status = "okay"; +// }; +// spi-max-frequency = <24000000>; // 24 MHz SPI speed for SD card +// }; +//}; +// +//&pinctrl { +// custom_spi: custom_spi { +// group1 { +// psels = , // SCK on P1.13 +// , // MOSI on P1.15 +// ; // MISO on P1.14 +// }; +// }; +//}; +// +//&uart0 { +// status = "disabled"; +//}; +// +//// &qspi { +//// status = "disabled"; +//// }; +// +//&i2c0 { +// lsm6ds3tr_c: lsm6ds3tr-c@6a { +// compatible = "st,lsm6dsl"; +// reg = <0x6a>; +// irq-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>; +// status = "okay"; +// label = "b"; +// // wakeup-source = true; +// }; +//}; +// +//&i2c1{ +// status = "disabled"; +//}; +// +//&temp { +// status = "disabled"; +//}; +// +// + + +//FOR 7002DK, ref: /opt/nordic/ncs/v2.8.0/zephyr/boards/nordic/nrf7002dk/nrf5340_cpuapp_common.dtsi +/ { + aliases { + led0 = &led0; + led1 = &led1; + led2 = &led1; // Fake led2 + pwm-led0 = &pwm_led0; + sw0 = &button0; + sw1 = &button1; + bootloader-led0 = &led0; + mcuboot-button0 = &button0; + mcuboot-led0 = &led0; + watchdog0 = &wdt0; + }; +}; + +// Fake accel +&i2c1 { + lsm6dsl: lsm6dsl@6b { + compatible = "st,lsm6dsl"; + reg = <0x6b>; + label = "LSM6DSL"; + }; +}; diff --git a/Friend/firmware/firmware_v1.0/prj_xiao_ble_sense_devkitv2-5340.conf b/Friend/firmware/firmware_v1.0/prj_xiao_ble_sense_devkitv2-5340.conf new file mode 100644 index 000000000..03a2f74a2 --- /dev/null +++ b/Friend/firmware/firmware_v1.0/prj_xiao_ble_sense_devkitv2-5340.conf @@ -0,0 +1,198 @@ +# +# Hardware settings +# + +CONFIG_GPIO=y +CONFIG_NRFX_PDM0=y +CONFIG_ADC=y + +# To flash via dev board +#CONFIG_BUILD_OUTPUT_UF2=n +#CONFIG_USE_DT_CODE_PARTITION=n + +# +# Bluetooth settings +# + +CONFIG_BT=y +CONFIG_BT_PERIPHERAL=y +CONFIG_BT_DEVICE_NAME="Omi DevKit 2" +CONFIG_BT_MAX_CONN=1 +# CONFIG_BT_EXT_ADV_MAX_ADV_SET=2 +CONFIG_BT_MAX_PAIRED=1 +CONFIG_BT_DEVICE_APPEARANCE=22 +CONFIG_BT_GATT_DYNAMIC_DB=y + +# +# Max transmit power supported by nRF52840 +# + +CONFIG_BT_CTLR_TX_PWR_ANTENNA=8 +CONFIG_BT_PHY_UPDATE=y + +# +# Battery and Device Information services +# + +CONFIG_BT_BAS=y +CONFIG_BT_DIS=y +CONFIG_BT_DIS_PNP=n +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.7" +CONFIG_BT_DIS_HW_REV_STR="Seeed Xiao BLE Sense" + +# +# Large BLE packets / BLE Buffers +# +# CONFIG_BT_GATT_CLIENT=y +# CONFIG_BT_THROUGHPUT=y + +CONFIG_BT_L2CAP_TX_MTU=498 + +CONFIG_BT_CTLR_DATA_LENGTH_MAX=251 +CONFIG_BT_CTLR_PHY_2M=y +CONFIG_BT_CTLR_PHY_CODED=y +CONFIG_BT_CTLR_SDC_MAX_CONN_EVENT_LEN_DEFAULT=400000 +CONFIG_BT_CONN_TX_MAX=20 +CONFIG_BT_BUF_ACL_RX_SIZE=1024 +CONFIG_BT_L2CAP_TX_BUF_COUNT=10 +CONFIG_BT_BUF_ACL_TX_SIZE=2048 +# CONFIG_BT_ATT_TX_COUNT=10 +# CONFIG_BT_EXT_ADV=y +# CONFIG_BT_PER_ADV=y +# CONFIG_BT_OBSERVER=y +# CONFIG_BT_ATT_PREPARE_COUNT=2 +CONFIG_BT_USER_DATA_LEN_UPDATE=y +CONFIG_BT_AUTO_DATA_LEN_UPDATE=y +CONFIG_BT_USER_PHY_UPDATE=y +CONFIG_BT_AUTO_PHY_UPDATE=y + +CONFIG_FPU=y +CONFIG_NORDIC_QSPI_NOR=n +# CONFIG_BOARD_ENABLE_DCDC=y +# + +##TODO +# +# Console +# +# Disable the lines to enable console log +CONFIG_CONSOLE=n + +# +# Debug +# +# Enable the lines below to enable debug logs via UART/USB + +# CONFIG_DEBUG=y +# 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_BACKEND_UART=y +# CONFIG_LOG_BACKEND_UART_OUTPUT_TEXT=y +# CONFIG_LOG_DEFAULT_LEVEL=3 + +# +# Debug (This value breaks some builds) +# + +# CONFIG_ASSERT=y + +# +# Log Levels +# + +# 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 + +# +# Codecs +# +CONFIG_CODEC_OPUS=y + +# +# SD Card Support (all devices required) +# + +CONFIG_OFFLINE_STORAGE=y +CONFIG_DISK_ACCESS=y +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 +# CONFIG_SPI=y +CONFIG_HEAP_MEM_POOL_SIZE=512 + +# +# Disable unused peripherals +# +CONFIG_I2C=n +# CONFIG_NRFX_TWIM0=n +# CONFIG_NRFX_TWIM1=n + +# +# LSM6DSL sensor (accelerometer and gyroscope) +# +CONFIG_LSM6DSL=y +CONFIG_LSM6DSL_ENABLE_TEMP=n +# CONFIG_LSM6DSL_TRIGGER_GLOBAL_THREAD=y +CONFIG_SENSOR=y + +# +# Speaker +# +CONFIG_I2S=y +CONFIG_I2S_NRFX=y +CONFIG_SPI_NRFX=y + +## +## NFC (in the future) +## +# +## CONFIG_NFC_T2T_NRFXLIB=y +## CONFIG_NFC_NDEF=y +## CONFIG_NFC_NDEF_MSG=y +## CONFIG_NFC_NDEF_RECORD=y +## CONFIG_NFC_NDEF_URI_MSG=y +## CONFIG_NFC_NDEF_URI_REC=y +## CONFIG_HWINFO=y + +# +#EVERYTHING ELSE +# + +CONFIG_RING_BUFFER=y + +CONFIG_ACCELEROMETER=n +CONFIG_ENABLE_BUTTON=n +CONFIG_ENABLE_SPEAKER=n + +CONFIG_PM_DEVICE=y +# CONFIG_NRFX_USBD=y + +# CONFIG_FLASH=y + +CONFIG_LEGACY_SDK=n +CONFIG_LEGACY_SOC=n +CONFIG_USB_DEVICE_STACK=y diff --git a/Friend/firmware/firmware_v1.0/prj_xiao_ble_sense_devkitv2-adafruit.conf b/Friend/firmware/firmware_v1.0/prj_xiao_ble_sense_devkitv2-adafruit.conf index 936ec8e7d..a13832e4c 100644 --- a/Friend/firmware/firmware_v1.0/prj_xiao_ble_sense_devkitv2-adafruit.conf +++ b/Friend/firmware/firmware_v1.0/prj_xiao_ble_sense_devkitv2-adafruit.conf @@ -3,7 +3,7 @@ # CONFIG_GPIO=y -CONFIG_NRFX_PDM=y +CONFIG_NRFX_PDM0=y CONFIG_ADC=y # To flash via dev board diff --git a/Friend/firmware/firmware_v1.0/src/button.c b/Friend/firmware/firmware_v1.0/src/button.c index fee8d20ff..ee83a9527 100644 --- a/Friend/firmware/firmware_v1.0/src/button.c +++ b/Friend/firmware/firmware_v1.0/src/button.c @@ -544,7 +544,15 @@ void turnoff_all() gpio_pin_interrupt_configure_dt(&d5_pin_input,GPIO_INT_LEVEL_INACTIVE); //maybe save something here to indicate success. next time the button is pressed we should know about it NRF_USBD->INTENCLR= 0xFFFFFFFF; + + // Enter low power mode +#ifdef CONFIG_LEGACY_SDK + // ncs <= 2.7.0 NRF_POWER->SYSTEMOFF=1; +#else + // ncs 2.8.0 + nrf_power_system_off(NRF_POWER); +#endif } void force_button_state(FSM_STATE_T state) diff --git a/Friend/firmware/firmware_v1.0/src/main.c b/Friend/firmware/firmware_v1.0/src/main.c index 8876869c9..8ad07ea03 100644 --- a/Friend/firmware/firmware_v1.0/src/main.c +++ b/Friend/firmware/firmware_v1.0/src/main.c @@ -1,5 +1,7 @@ #include #include +#include +#include #include "transport.h" #include "mic.h" #include "utils.h" @@ -141,11 +143,30 @@ int main(void) int err; // TODO: what does it mean ? disabled from_usb_event for now // for system power off, we have no choice but to handle usb detect wakeup events. if off, and this was the reason, initialize, skip lightshow, start not recording +#ifdef CONFIG_LEGACY_SDK uint32_t reset_reas = NRF_POWER->RESETREAS; NRF_POWER->DCDCEN=1; NRF_POWER->DCDCEN0=1; - NRF_POWER->RESETREAS=1; +#else + uint32_t reset_reas = nrfx_reset_reason_get(); + + // DC-DC +#if NRF_POWER_HAS_DCDCEN + nrf_power_dcdcen_set(NRF_POWER, true); +#endif + +#if NRF_POWER_HAS_DCDCEN_VDDH + nrf_power_dcdcen_vddh_set(NRF_POWER, true); +#endif + +#if !NRF_POWER_HAS_DCDCEN && !NRF_POWER_HAS_DCDCEN_VDDH +#pragma message "DC-DC related commands have no effect!" +#endif + + nrfx_reset_reason_clear(1); +#endif + // bool from_usb_event = (reset_reas & VBUS_DETECT); bool from_wakeup = (reset_reas & WAKEUP_DETECT); // if (from_usb_event) diff --git a/Friend/firmware/firmware_v1.0/src/mic.c b/Friend/firmware/firmware_v1.0/src/mic.c index 73ef80ccf..806d20f45 100644 --- a/Friend/firmware/firmware_v1.0/src/mic.c +++ b/Friend/firmware/firmware_v1.0/src/mic.c @@ -20,6 +20,10 @@ static int16_t _buffer_0[MIC_BUFFER_SAMPLES]; static int16_t _buffer_1[MIC_BUFFER_SAMPLES]; static volatile uint8_t _next_buffer_index = 0; static volatile mix_handler _callback = NULL; +static nrfx_pdm_t pdm_instance = { + .p_reg = NRF_PDM0, + .drv_inst_idx = 0 +}; static void pdm_irq_handler(nrfx_pdm_evt_t const *event) { @@ -36,12 +40,12 @@ static void pdm_irq_handler(nrfx_pdm_evt_t const *event) LOG_DBG("Audio buffer requested"); if (_next_buffer_index == 0) { - nrfx_pdm_buffer_set(_buffer_0, MIC_BUFFER_SAMPLES); + nrfx_pdm_buffer_set(&pdm_instance, _buffer_0, MIC_BUFFER_SAMPLES); _next_buffer_index = 1; } else { - nrfx_pdm_buffer_set(_buffer_1, MIC_BUFFER_SAMPLES); + nrfx_pdm_buffer_set(&pdm_instance, _buffer_1, MIC_BUFFER_SAMPLES); _next_buffer_index = 0; } } @@ -75,8 +79,12 @@ int mic_start() pdm_config.mode = NRF_PDM_MODE_MONO; pdm_config.edge = NRF_PDM_EDGE_LEFTFALLING; pdm_config.ratio = NRF_PDM_RATIO_80X; - IRQ_DIRECT_CONNECT(PDM_IRQn, 5, nrfx_pdm_irq_handler, 0); // IMPORTANT! - if (nrfx_pdm_init(&pdm_config, pdm_irq_handler) != NRFX_SUCCESS) +#ifdef CONFIG_LEGACY_SOC + IRQ_DIRECT_CONNECT(PDM_IRQn, 5, nrfx_pdm_0_irq_handler, 0); // IMPORTANT! +#else + IRQ_DIRECT_CONNECT(PDM0_IRQn, 5, nrfx_pdm_0_irq_handler, 0); // IMPORTANT! +#endif + if (nrfx_pdm_init(&pdm_instance, &pdm_config, pdm_irq_handler) != NRFX_SUCCESS) { LOG_ERR("Audio unable to initialize PDM"); return -1; @@ -87,7 +95,7 @@ int mic_start() nrfy_gpio_pin_set(PDM_PWR_PIN); // Start PDM - if (nrfx_pdm_start() != NRFX_SUCCESS) + if (nrfx_pdm_start(&pdm_instance) != NRFX_SUCCESS) { LOG_ERR("Audio unable to start PDM"); return -1; diff --git a/Friend/firmware/firmware_v1.0/src/transport.c b/Friend/firmware/firmware_v1.0/src/transport.c index 67291a3e5..1bcda1f70 100644 --- a/Friend/firmware/firmware_v1.0/src/transport.c +++ b/Friend/firmware/firmware_v1.0/src/transport.c @@ -10,17 +10,16 @@ #include #include #include +#include #include "transport.h" #include "config.h" #include "utils.h" -// #include "nfc.h" #include "speaker.h" #include "sdcard.h" #include "storage.h" #include "button.h" #include "mic.h" #include "lib/battery/battery.h" -// #include "friend.h" LOG_MODULE_REGISTER(transport, CONFIG_LOG_DEFAULT_LEVEL); #define MAX_STORAGE_BYTES 0xFFFF0000 @@ -159,6 +158,7 @@ static void accel_ccc_config_changed_handler(const struct bt_gatt_attr *attr, ui LOG_ERR("Invalid CCC value: %u", value); } } + int accel_start() { struct sensor_value odr_attr; @@ -177,8 +177,6 @@ int accel_start() odr_attr.val1 = 10; odr_attr.val2 = 0; - - if (gpio_is_ready_dt(&accel_gpio_pin)) { printk("Speaker Pin ready\n"); @@ -296,7 +294,12 @@ static ssize_t dfu_control_point_write_handler(struct bt_conn *conn, const struc LOG_INF("dfu_control_point_write_handler"); if (len == 1 && ((uint8_t *)buf)[0] == 0x06) { - NRF_POWER->GPREGRET = 0xA8; + uint32_t val = 0xA8; + #ifdef CONFIG_LEGACY_SDK + NRF_POWER->GPREGRET = val; + #else + nrf_power_gpregret_set(NRF_POWER, 0, val); + #endif NVIC_SystemReset(); } else if (len == 2 && ((uint8_t *)buf)[0] == 0x01) @@ -304,7 +307,12 @@ static ssize_t dfu_control_point_write_handler(struct bt_conn *conn, const struc uint8_t notification_value = 0x10; bt_gatt_notify(conn, attr, ¬ification_value, sizeof(notification_value)); - NRF_POWER->GPREGRET = 0xA8; + uint32_t val = 0xA8; + #ifdef CONFIG_LEGACY_SDK + NRF_POWER->GPREGRET = val; + #else + nrf_power_gpregret_set(NRF_POWER, 0, val); + #endif NVIC_SystemReset(); } return len; @@ -861,7 +869,6 @@ int broadcast_audio_packets(uint8_t *buffer, size_t size) return 0; } - void accel_off() { gpio_pin_set_dt(&accel_gpio_pin, 0);