Commit Graph
1723 Commits
Author SHA1 Message Date
tthandClaude Opus 5.5 fca5ff3c71 Wire (nRF52): a timed-out STOP is a failure, and the TWIM is reset after a timeout
Build / build (feather_nrf52840_sense_tft) (push) Failing after 13s
Build / build (cluenrf52840) (push) Failing after 22s
Build / build (feather52840) (push) Failing after 23s
Build / build (itsybitsy52840) (push) Failing after 25s
Build / build (ledglasses_nrf52840) (push) Failing after 25s
Build / build (feather52832) (push) Failing after 25s
Build / build (feather52840sense) (push) Failing after 25s
Build / build (cplaynrf52840) (push) Failing after 26s
On top of #873, tested on a XIAO nRF52840 with SCL tied to GND:
- the STOP/SUSPEND waits broke out without setting timed_out, so an empty
  probe on a stuck bus returned 0, "device ACKed" (every RTC address of an
  autodiscovery scan looked present); requestFrom() alike;
- after a timeout the TWIM stayed wedged once the bus was released: every
  call timed out until a reboot. A disable/enable cycle recovers it.
Result: stuck bus -> error 4 after ~100 ms per call, no hang; bus released
-> NACK 2 / ACK 0 again in under 1 ms, without a reboot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 13:16:18 +01:00
strasharo 45188a647f Wire (nRF52): add timeout to endTransmission()/requestFrom() poll loops
endTransmission() and requestFrom() both spin on unbounded while(!EVENT)
loops waiting on the TWIM peripheral. Several of these loops - notably
the EVENTS_STOPPED wait - have no EVENTS_ERROR escape at all, so if the
hardware never raises the expected event (e.g. probing an I2C address
on a bus with nothing attached and no pull-ups), the call never
returns and the whole single-threaded firmware hangs forever.

Reported in #771 with the same root cause already identified in the
issue thread. Also affects boards that probe for an optional/absent
I2C device at boot before anything else initializes - e.g. MeshCore's
Xiao_nrf52 target, which runs an RTC autodiscovery scan in radio_init()
and hangs on every cold boot when no RTC is wired up (no serial, no
BLE - see meshcore-dev/MeshCore#2068).

Adds a bounded I2C_TWIM_TIMEOUT_MS (default 100ms, overridable) to
every wait loop in both functions. A timeout that occurs before the
hardware transaction actually completed is surfaced as a proper error
return (endTransmission: 4 "other error"; requestFrom: 0 bytes read)
rather than silently falling through to a success path - a timeout on
the address/data phase must not be reported as if a device ACKed.

Tested on a Seeed XIAO nRF52840 + Wio-SX1262 board that reliably hung
at boot (via MeshCore's RTC autodiscovery probe) after every power
cycle. With this patch the same probe now completes (with a timeout)
in well under a second per address instead of hanging indefinitely,
and the board boots and runs normally.
2026-12-02 12:22:38 +01:00
36ed7b591b Fix BLE semaphore leak in Bluefruit library
Fix semaphore leak bug that causes device lockup when BLE central disconnects unexpectedly (e.g., going out of range, supervision timeout).

Co-authored-by: liquidraver <504870+liquidraver@users.noreply.github.com>
Co-authored-by: liamcottle <liam@liamcottle.com>
2026-04-28 20:30:09 +10:00
Ha Thach fa129c2a10 Merge pull request #865 from adafruit/fix-auto-led-conn
stop blink timer in autoConnLed(false)
2026-03-18 19:16:28 +07:00
Ha ThachandCopilot Autofix powered by AI 0e6562df6e Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-18 18:51:18 +07:00
hathach ec0a415838 stop blink timer in autoConnLed(false) 2026-03-18 18:41:36 +07:00
Ha Thach 49f3fa614b Merge pull request #831 from geeksville/pr-lfs
Update to LFS v1.7.2 tag - to fix filesystem corruption due to file renames
2026-03-18 17:58:19 +07:00
hathach c5aedbf8ff bump up tinyusb to 3.7.0 2025-06-26 16:00:41 +07:00
hathach 197e796d6c bump up tinyusb to 3.6.0 2025-05-30 15:10:42 +07:00
hathach 4e22a13f60 fix dynamic data advertising not update
fix typo
2025-03-03 16:26:09 +07:00
Todd Herbert 275da60c80 Apply patch from hathach
https://github.com/adafruit/Adafruit_nRF52_Arduino/pull/838#pullrequestreview-2601718986
2025-02-13 20:55:10 +13:00
Todd Herbert facf938c74 braces 2025-01-21 23:24:54 +13:00
Todd Herbert 630668a071 Refactor for maintainability 2025-01-21 03:28:54 +13:00
Todd Herbert 3ea78558e1 Reattempt failed flash operations 2025-01-18 01:58:32 +13:00
Kevin Hester 3d5f43ff1e Update to LFS v1.7.2 tag (see below for details)
I wanted to update LFS to pull in a particular fix they made upstream:
https://github.com/littlefs-project/littlefs/commit/97d8d5e96a7781596708664f18f2ea6c3a179330

Since I was doing the update anyways (to this old/stable lib) I updated to
the 'highest' LFS version which is still backwards compatible to the
v1.6.1 version which had been used originally to create the adafruit fork.

The other fixes in 1.7.2/1.7.0 (they are identical wrt. lfs.c) IMO are
unlikely to be critical for adafruit but see the full list here:

https://github.com/littlefs-project/littlefs/releases/tag/v1.7.0
2024-08-14 11:05:41 -07:00
Ha Thach bba4b53a2d Merge pull request #829 from attermann/file_term
Null termination of file name when max length
2024-07-18 17:22:07 +07:00
Chad Attermann 1b12011507 Null termination of file name when max length
File names are returned unterminated in the edge case where their length
is max size This is due to the fact that strncpy does terminate the
destination string when the source string is greater than or equal to
the specifid maximum length.
2024-07-15 09:01:40 -06:00
Chad Attermann 236e434296 Additionally clearing pointers just in case
Clearing `_file` and `_dir` pointers after freeing on failure to open
just in case close() is later called.

To elaborate, the `_file` and `_dir` pointers are normally freed and
cleared by _close(), but when a failure occurs upon opening, these
pointers were being left orphaned since calling close() after failure to
open doesn't make much sense, and indeed caused serious issues within
lfs.
2024-07-12 13:18:40 -06:00
Chad Attermann 1ce5cf13d2 Fix memory leak on failure to open
Fixes leak of memory caused by failure to free file and directory
structures when open fails.
2024-07-12 12:42:53 -06:00
hathach 03bb265434 Merge branch 'refs/heads/master' into add-feather-833
bootloader/circuitplayground_nrf52840/circuitplayground_nrf52840_bootloader-0.6.2_s140_6.1.1.hex
bootloader/circuitplayground_nrf52840/circuitplayground_nrf52840_bootloader-0.6.2_s140_6.1.1.zip
bootloader/circuitplayground_nrf52840/circuitplayground_nrf52840_bootloader-0.7.0_s140_6.1.1.hex
bootloader/circuitplayground_nrf52840/circuitplayground_nrf52840_bootloader-0.7.0_s140_6.1.1.zip
bootloader/circuitplayground_nrf52840/circuitplayground_nrf52840_bootloader-0.9.0_s140_6.1.1.zip
bootloader/clue_nrf52840/clue_nrf52840_bootloader-0.6.2_s140_6.1.1.hex
bootloader/clue_nrf52840/clue_nrf52840_bootloader-0.6.2_s140_6.1.1.zip
bootloader/clue_nrf52840/clue_nrf52840_bootloader-0.7.0_s140_6.1.1.hex
bootloader/clue_nrf52840/clue_nrf52840_bootloader-0.7.0_s140_6.1.1.zip
bootloader/clue_nrf52840/clue_nrf52840_bootloader-0.9.0_s140_6.1.1.hex
bootloader/feather_nrf52832/feather_nrf52832_bootloader-0.6.2_s132_6.1.1.hex
bootloader/feather_nrf52832/feather_nrf52832_bootloader-0.6.2_s132_6.1.1.zip
bootloader/feather_nrf52832/feather_nrf52832_bootloader-0.7.0_s132_6.1.1.hex
bootloader/feather_nrf52832/feather_nrf52832_bootloader-0.7.0_s132_6.1.1.zip
bootloader/feather_nrf52832/feather_nrf52832_bootloader-0.9.0_s132_6.1.1.hex
bootloader/feather_nrf52832/feather_nrf52832_bootloader-0.9.0_s132_6.1.1.zip
bootloader/feather_nrf52840_express/feather_nrf52840_express_bootloader-0.7.0_s140_6.1.1.hex
bootloader/feather_nrf52840_express/feather_nrf52840_express_bootloader-0.7.0_s140_6.1.1.zip
bootloader/feather_nrf52840_express/feather_nrf52840_express_bootloader-0.9.0_s140_6.1.1.hex
bootloader/feather_nrf52840_sense/feather_nrf52840_sense_bootloader-0.7.0_s140_6.1.1.hex
bootloader/feather_nrf52840_sense/feather_nrf52840_sense_bootloader-0.7.0_s140_6.1.1.zip
bootloader/feather_nrf52840_sense/feather_nrf52840_sense_bootloader-0.9.0_s140_6.1.1.hex
bootloader/feather_nrf52840_sense/feather_nrf52840_sense_bootloader-0.9.0_s140_6.1.1.zip
bootloader/itsybitsy_nrf52840_express/itsybitsy_nrf52840_express_bootloader-0.6.2_s140_6.1.1.hex
bootloader/itsybitsy_nrf52840_express/itsybitsy_nrf52840_express_bootloader-0.6.2_s140_6.1.1.zip
bootloader/itsybitsy_nrf52840_express/itsybitsy_nrf52840_express_bootloader-0.7.0_s140_6.1.1.hex
bootloader/itsybitsy_nrf52840_express/itsybitsy_nrf52840_express_bootloader-0.7.0_s140_6.1.1.zip
bootloader/itsybitsy_nrf52840_express/itsybitsy_nrf52840_express_bootloader-0.9.0_s140_6.1.1.hex
bootloader/itsybitsy_nrf52840_express/itsybitsy_nrf52840_express_bootloader-0.9.0_s140_6.1.1.zip
bootloader/ledglasses_nrf52840/ledglasses_nrf52840_bootloader-0.6.2_s140_6.1.1.zip
bootloader/ledglasses_nrf52840/ledglasses_nrf52840_bootloader-0.9.0_s140_6.1.1.hex
bootloader/ledglasses_nrf52840/ledglasses_nrf52840_bootloader-0.9.0_s140_6.1.1.zip
bootloader/metro_nrf52840_express/metro_nrf52840_express_bootloader-0.7.0_s140_6.1.1.hex
bootloader/metro_nrf52840_express/metro_nrf52840_express_bootloader-0.7.0_s140_6.1.1.zip
bootloader/metro_nrf52840_express/metro_nrf52840_express_bootloader-0.9.0_s140_6.1.1.zip
bootloader/particle_xenon/particle_xenon_bootloader-0.6.2_s140_6.1.1.hex
bootloader/particle_xenon/particle_xenon_bootloader-0.6.2_s140_6.1.1.zip
bootloader/particle_xenon/particle_xenon_bootloader-0.7.0_s140_6.1.1.hex
bootloader/particle_xenon/particle_xenon_bootloader-0.9.0_s140_6.1.1.hex
bootloader/raytac_mdbt50q_rx/raytac_mdbt50q_rx_bootloader-0.6.2_s140_6.1.1.hex
bootloader/raytac_mdbt50q_rx/raytac_mdbt50q_rx_bootloader-0.6.2_s140_6.1.1.zip
bootloader/raytac_mdbt50q_rx/raytac_mdbt50q_rx_bootloader-0.7.0_s140_6.1.1.zip
bootloader/raytac_mdbt50q_rx/raytac_mdbt50q_rx_bootloader-0.9.0_s140_6.1.1.hex
bootloader/raytac_mdbt50q_rx/raytac_mdbt50q_rx_bootloader-0.9.0_s140_6.1.1.zip
2024-06-05 16:31:16 +07:00
hathach 77bed4894c update tinyusb lib to 3.1.3 2024-03-27 10:52:48 +07:00
hathach c2d898b0a6 update tinyusb and nrfcrypto lib 2024-02-06 15:18:17 +07:00
hathach 145041c4e9 move example to Bluefruit52Lib/Hardware, update example with float for readability 2023-11-30 16:34:15 +07:00
hathach a71a669343 Merge branch 'master' into temp 2023-11-30 16:12:19 +07:00
hathach f96d9cef1e auto use peerAddress if adv type is set to one of directed type 2023-11-30 12:34:15 +07:00
hathach ea3dd125f0 Merge branch 'master' into direct 2023-11-30 12:16:58 +07:00
hathach f798d64fa0 add more description to beacon example, use non-connectable scannable undirected type 2023-11-29 14:56:29 +07:00
Ha Thach af19cea314 Merge pull request #791 from rmccaskill/master
Fix _irq_handler
2023-10-16 15:30:00 +07:00
hathach 27981a32be fix File with Adafruit_LittleFS_Namespace 2023-10-16 13:26:59 +07:00
hathach 2ea5b52812 update bundled tinyusb & nRFCyprto lib 2023-10-16 11:46:12 +07:00
Rick McCaskill 1c3ee016e1 Fix _irq_handler
I'm working on a project that has 3 rotary encoders. When I used this libary, I couldn't get the 3 switches to properly increment / decrement the steps when I called readAbs().
Looking back at the code, I see there was a change in 351cd82 which seemed to have caused the issue.

If I look previous to 351cd82, the _irq_handler was using digitalRead. I think switching to bitRead caused a mix up between the physical pin number vs. the port pin? I'm not entirely sure.
I reimplemented the pre 351cd82 code and used the new ada_callback. Seems to be working great now!
2023-09-21 12:03:26 -03:00
UUSim 931b0ac1f7 Added support for directed BLE advertisements.
Can be used for example with advertising type BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED.
2023-09-05 23:47:51 +02:00
CSC-Sendance dc1b3d7515 FIX #197 : Replace varclr with arrclr for BLEAdvertising _data fields
Otherwise the data field gets corrupted (?) causing error msg "bool BLEAdvertising::_start(uint16_t, uint16_t): 364: verify failed, error = NRF_ERROR_INVALID_LENGTH" as mentioned in this comment: https://github.com/adafruit/Adafruit_nRF52_Arduino/issues/197#issuecomment-1403674667

see also https://devzone.nordicsemi.com/f/nordic-q-a/52573/sd_ble_gap_adv_set_configure-returns-error-nrf_error_invalid_length
2023-07-24 14:07:51 +02:00
Ha Thach bc21608792 Update BLEDiscovery.cpp 2023-06-26 12:04:43 +07:00
Ha Thach 54242a65e8 Merge pull request #730 from OstlerDev/feat_BLEClientHid_Gamepad
HID Gamepad Client & Central HID Gamepad example
2023-06-15 22:16:37 +07:00
Charlie B a59ffc545c updated to be more similar to battery service 2023-04-20 03:07:28 -04:00
Charlie B 9388e7358c updated to be consistent with uint8_t 2023-04-19 19:57:53 -04:00
Charlie B 687a54525e Updated main bluefruit to include IAS 2023-04-19 19:56:41 -04:00
Charlie B 97649cee90 added client IAS 2023-04-19 17:16:49 -04:00
Charlie B 5d96925d9a added IAS service 2023-04-19 16:17:07 -04:00
hathach 4414359068 bump up tinyusb and nrfcrypto 2023-03-23 22:03:24 +07:00
hathach 98136d36de try to fix ci 2023-03-23 18:53:46 +07:00
neotje ab6229051e nrfx_temp blocking example 2022-10-23 13:24:35 +02:00
neotje c0ad3cf6f0 nrfx_temp non-blocking example 2022-10-23 12:45:03 +02:00
hathach 2d86957b99 update tinyusb to latest 2022-07-14 12:59:47 +07:00
hathach a373b2cece get most of the sketches compiled with 833 except though with external flash since 833 does not have qspi 2022-07-13 20:07:13 +07:00
hathach 42f65a84be update build_all.py for parallel build 2022-07-13 13:34:48 +07:00
Sky Young 0f30241ed5 Add Gamepad implementation to Central HID Example 2022-05-16 21:24:50 -06:00
Sky Young 459f7cef16 Cleanup BLEClientHidAdafruit.cpp and fix todo items 2022-05-16 19:27:18 -06:00
Sky Young 47806f64f1 Allow up to 8 Characteristics at once 2022-05-16 19:26:53 -06:00