Conversation
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
Merge pull request #38 from pulp-bio/dev
…er_readout Feature/add optional accelerometer readout
gspacone
approved these changes
Jun 21, 2026
There was a problem hiding this comment.
Pull request overview
This PR bumps the project to v1.2.3 and introduces optional IIS2DH accelerometer streaming on the nRF52 firmware, controlled via a user configuration packet received over BLE.
Changes:
- Bump version references to v1.2.3 and add v1.2.3 changelog entries.
- Add an IIS2DH (I2C/TWI) driver and runtime enable/disable logic driven by a decoded BLE config field.
- Adjust SPI frame completion so IMU/non-IMU post-processing finalizes frames (rather than finalizing directly in the SPI completion ISR).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates displayed release version to v1.2.3. |
| CHANGELOG.md | Adds top-level v1.2.3 entry summarizing new optional accelerometer streaming. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/CHANGELOG.md | Adds firmware-specific v1.2.3 details for IIS2DH + frame finalization changes. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/us_ble.c | Decodes config packets to request accel streaming; currently adds an unused IIS2DH header dependency. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/us_spi.c | Switches from immediate frame finalization to IMU-post-processing signaling (flag_add_IMU). |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/main.c | Applies pending accel mode updates and routes each frame through IMU/non-IMU finalization. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/iis2dh.h | Introduces IIS2DH driver API and TWI instance selection. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/iis2dh.c | Implements IIS2DH TWI driver and patches accel bytes into the SPI RX buffer. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/pca10040/s132/ses/US_probe_nRF52_firmware.emProject | Adds IIS2DH source files and TWI driver sources to the SES project. |
Comments suppressed due to low confidence (1)
fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/us_spi.c:187
counter_cc0_event_handlernow declareserr_code/lengthand assignslength, but these are unused after moving frame completion to the IMU/non-IMU post-processing path. This will trigger unused-variable warnings and obscures the new control flow.
// Relay the received SPI data to the BLE dongle
uint32_t err_code;
uint16_t length;
length = BYTES_PR_XFER_RX;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
75
to
+76
| #include "us_defines.h" | ||
| #include "iis2dh.h" |
Comment on lines
+187
to
+189
| accel_stream_enabled = accel_stream_requested; | ||
| IIS2DH_set_streaming_enabled(accel_stream_enabled); | ||
| accel_stream_update_pending = false; |
Comment on lines
+53
to
+58
| // TWI instance ID | ||
| #if TWI0_ENABLED | ||
| #define TWI_INSTANCE_ID 0 | ||
| #elif TWI1_ENABLED | ||
| #define TWI_INSTANCE_ID 1 | ||
| #endif |
Comment on lines
+85
to
+90
| // Send the register address where we want to read the data from | ||
| err_code = nrf_drv_twi_tx(&IIS2DH_twi, IIS2DH_ADDRESS, ®ister_address, 1, true); | ||
|
|
||
| //Wait for the transmission to be completed | ||
| while (IIS2DH_xfer_done == false){} | ||
|
|
Comment on lines
+100
to
+104
| // Receive the data from the IIS2DH | ||
| err_code = nrf_drv_twi_rx(&IIS2DH_twi, IIS2DH_ADDRESS, rx_buffer, number_of_bytes); | ||
| //wait until the transmission is completed | ||
| while (IIS2DH_xfer_done == false){} | ||
|
|
Comment on lines
+213
to
+214
| } | ||
| } |
| flag_add_IMU = false; | ||
|
|
||
| // 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; |
Comment on lines
+309
to
+311
| memcpy(&m_rx_buf[3 + buffer_counter * NUMBER_OF_XFERS].buffer[0] + 202 - 6, | ||
| &IIS2DH_buffer[0], | ||
| 6); |
|
|
||
|
|
||
| /** | ||
| * @brief TWI initialization function for the MCP9808 sensor |
Comment on lines
+178
to
+180
| // Buffer ready to add IMU data | ||
| flag_add_IMU = true; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.