Skip to content

Feature/add optional accelerometer readout#43

Open
Sebi1128 wants to merge 2 commits into
devfrom
feature/add_optional_accelerometer_readout
Open

Feature/add optional accelerometer readout#43
Sebi1128 wants to merge 2 commits into
devfrom
feature/add_optional_accelerometer_readout

Conversation

@Sebi1128
Copy link
Copy Markdown
Collaborator

Integrate the readout of the accelerometer in the WULPUS firmware (nRF52). The accelerometer is only enabled upon request to keep backward compatibility with older GUIs.

Sebi1128 added 2 commits April 2, 2026 15:01
This change keeps backward-compatible streaming behavior for ultrasound data while making accelerometer streaming optional.

Tested the following cases:

1. accelerometer requested
   - firmware starts correctly
   - ultrasound data streams correctly
   - accelerometer data is appended to outgoing frames

2. accelerometer not requested
   - firmware starts correctly
   - ultrasound data streams correctly
   - accelerometer remains off

3. repeated configuration updates
   - switching between enabled and disabled modes works correctly
Copilot AI review requested due to automatic review settings May 18, 2026 07:45
@Sebi1128 Sebi1128 added the enhancement New feature or request label May 18, 2026
@Sebi1128 Sebi1128 self-assigned this May 18, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Integrates optional IIS2DH accelerometer readout/streaming into the nRF52 acquisition firmware, with BLE-side configuration parsing to enable/disable streaming at runtime for backward compatibility with older GUIs.

Changes:

  • Added an IIS2DH (I2C/TWI) driver module and frame post-processing to inject (or zero-fill) accelerometer bytes into the outgoing data stream.
  • Added BLE config-packet parsing to request accelerometer streaming and a deferred apply mechanism in main.c.
  • Adjusted SPI “frame complete” handling to defer frame finalization until after ACC/non-ACC post-processing.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/us_spi.c Switches from finalizing frames in the SPI completion ISR to signaling “ready for IMU post-processing”.
fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/us_ble.c Parses incoming config packets to request accel streaming and forwards commands to the MSP430.
fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/main.c Applies accel enable/disable requests and triggers IMU insertion / non-IMU finalization in the main loop.
fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/iis2dh.c New IIS2DH driver + frame finalization/IMU insertion logic.
fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/iis2dh.h New IIS2DH public API, register definitions, and configuration types.
fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/pca10040/s132/ses/US_probe_nRF52_firmware.emProject Adds IIS2DH sources and TWI/TWIM-related sources to the SES project.
fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/CHANGELOG.md Adds a 1.2.3 entry describing the new optional accelerometer streaming feature.
CHANGELOG.md Adds a top-level 1.2.3 entry mentioning optional nRF52 accelerometer streaming.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 172 to +180
if(buffer_content>MAX_BUFFER_NUMBER_OF_US_FRAMES-1)
{
// Buffer overflow error handling
//APP_ERROR_CHECK(1);
}

buffer_counter++;
if(buffer_counter == MAX_BUFFER_NUMBER_OF_US_FRAMES)
buffer_counter = 0;

BLE_packet_ready = 1;
// Buffer ready to add IMU data
flag_add_IMU = true;

Comment on lines 200 to 206
timers_init();
power_management_init();
us_ble_init();
gpio_init();
us_spi_init();
IIS2DH_init();

Comment on lines +217 to +225
// Only decode config packets: start byte 0xFA, transFreq at bytes 5..8
if ((len >= 9) && (rx[0] == 0xFA))
{
uint32_t transFreq = read_u32_le(&rx[5]);

// If transFreq contains code 101, enable accelerometer
accel_stream_requested = (transFreq == 101u);
accel_stream_update_pending = true;
}
Comment on lines +227 to 229
// Forward packet unchanged to MSP430
memcpy(m_tx_buf_1, rx, len);
msp_conf_received = true;
Comment on lines +37 to +40
#define IIS2DH_REG_INT_COUNTER_REG
#define IIS2DH_REG_TEMP_CFG_REG 0x1F
#define IIS2DH_REG_REFERENCE
#define IIS2DH_REG_STATUS_REG
Comment on lines +282 to +286
// Zero out the 6 bytes that would normally carry accel data
uint8_t *dst = &m_rx_buf[3 + buffer_counter * NUMBER_OF_XFERS].buffer[0] + 202 - 6;
dst[0] = 0;
dst[1] = 0;
dst[2] = 0;
@@ -5,7 +5,21 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Comment on lines +82 to +90
//Set the flag to false to show the receiving is not yet completed
IIS2DH_xfer_done = false;

// Send the register address where we want to read the data from
err_code = nrf_drv_twi_tx(&IIS2DH_twi, IIS2DH_ADDRESS, &register_address, 1, true);

//Wait for the transmission to be completed
while (IIS2DH_xfer_done == false){}

Comment on lines +127 to +132
// Send the register address where we want to read the data from
err_code = nrf_drv_twi_tx(&IIS2DH_twi, IIS2DH_ADDRESS, wxbuffer_with_address, number_of_bytes+1, true);

//Wait for the transmission to be completed
while (IIS2DH_xfer_done == false){}

bool setupTemp();
int8_t getTemp();

bool setupAccelormeter(IIS2DH_OperatingModes mode, IIS2DH_DataRate rate, IIS2DH_FullScale fs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants