update fork with upstream#6
Merged
Merged
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
Merge dev into main for v1.2.3 release
There was a problem hiding this comment.
Pull request overview
This PR syncs the fork to WULPUS v1.2.3 and adds optional IIS2DH accelerometer streaming to the nRF52 firmware, enabling/disabling streaming based on a decoded user configuration packet received over BLE.
Changes:
- Bump documented version/changelogs to v1.2.3.
- Add an IIS2DH I2C driver and integrate IMU/no-IMU frame finalization into the nRF52 main loop.
- Extend BLE RX handling to decode a config field (transFreq) and request accelerometer streaming at runtime; update the SES project to compile the new sources and TWI drivers.
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 project version to v1.2.3. |
| CHANGELOG.md | Adds top-level v1.2.3 entry. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/CHANGELOG.md | Adds firmware v1.2.3 entry describing accelerometer streaming. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/us_ble.c | Decodes config packets to request accel streaming; forwards config to MSP430 unchanged. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/us_spi.c | Shifts “frame complete” signaling toward IMU/no-IMU post-processing. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/main.c | Initializes IIS2DH and applies runtime accel mode; finalizes frames with/without IMU in main loop. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/iis2dh.h | Introduces IIS2DH register/type definitions and public driver API. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/iis2dh.c | Implements IIS2DH TWI driver and frame IMU insertion / non-IMU finalization. |
| fw/nrf52/ble_peripheral/US_probe_nRF52_firmware/pca10040/s132/ses/US_probe_nRF52_firmware.emProject | Adds IIS2DH sources and required 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:188
counter_cc0_event_handlernow declareserr_code/lengthbut never uses them, and the comment still says it relays data over BLE even though the handler now just setsflag_add_IMU. This will trigger unused-variable warnings and makes the handler misleading.
// 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
+82
to
+95
| //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, ®ister_address, 1, true); | ||
|
|
||
| //Wait for the transmission to be completed | ||
| while (IIS2DH_xfer_done == false){} | ||
|
|
||
| // If transmission was not successful, exit the function and return false | ||
| if (NRF_SUCCESS != err_code) | ||
| { | ||
| return false; | ||
| } |
Comment on lines
+97
to
+109
| //reset the flag so that we can read data from the IIS2DH's internal register | ||
| IIS2DH_xfer_done = false; | ||
|
|
||
| // 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){} | ||
|
|
||
| // if data was successfully read, return true else return false | ||
| if (NRF_SUCCESS != err_code) | ||
| { | ||
| return false; | ||
| } |
Comment on lines
+117
to
+138
| //Set the flag to false to show the receiving is not yet completed | ||
| IIS2DH_xfer_done = false; | ||
|
|
||
| uint8_t wxbuffer_with_address[10]; | ||
| wxbuffer_with_address[0] = register_address; | ||
| if (number_of_bytes>8) return false; | ||
| for (int i = 0; i<number_of_bytes; i++){ | ||
| wxbuffer_with_address[i+1] = wx_buffer[i]; | ||
| } | ||
|
|
||
| // 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){} | ||
|
|
||
| // If transmission was not successful, exit the function and return false | ||
| if (NRF_SUCCESS != err_code) | ||
| { | ||
| return false; | ||
| } | ||
| return true; |
Comment on lines
+155
to
+161
| check = IIS2DH_register_write(IIS2DH_REG_CTRL_REG4,wx_buffer , 1); | ||
| if (!check){ | ||
| return false; | ||
| } | ||
|
|
||
|
|
||
| } |
Comment on lines
+195
to
+200
| wx_reg4_buffer[0] |= wx_reg4_buffer[0] | fs; | ||
|
|
||
|
|
||
| bool res = IIS2DH_register_write(IIS2DH_REG_CTRL_REG1, wx_reg1_buffer, 1); | ||
| res &= IIS2DH_register_write(IIS2DH_REG_CTRL_REG4, wx_reg4_buffer, 1); | ||
| return 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
+115
to
+120
| bool setupTemp(); | ||
| int8_t getTemp(); | ||
|
|
||
| bool setupAccelormeter(IIS2DH_OperatingModes mode, IIS2DH_DataRate rate, IIS2DH_FullScale fs); | ||
| bool getAccelerationData(uint16_t* X, uint16_t* Y, uint16_t* Z, IIS2DH_OperatingModes mode, IIS2DH_FullScale range); | ||
|
|
Comment on lines
+182
to
+190
| static void apply_accel_mode_if_pending(void) | ||
| { | ||
| if (!accel_stream_update_pending) | ||
| return; | ||
|
|
||
| accel_stream_enabled = accel_stream_requested; | ||
| IIS2DH_set_streaming_enabled(accel_stream_enabled); | ||
| accel_stream_update_pending = false; | ||
| } |
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
+19
to
+20
| uint8_t IIS2DH_buffer[805] = {}; | ||
| uint16_t IIS2DH_buffer_index =0; |
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.