I2C abort reason #1370
No reviewers
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk!1370
Loading…
Reference in a new issue
No description provided.
Delete branch "peterharperuk/add_last_abort_reason"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #1049
Fixed build issue
assigning to myself; i think i'd rather return the abort reason in the top half of a 64 bit rc (and do some API massaging)
I don't think you liked this change? I could add a variant of the functions to return int64_t if that sounds like what you wanted?
yeah, i guess returning a struct with two elements in a replacement APIs and picking the result out for the existing APIs is good
(Note a two uint32_t struct will be returned correctly in r0/r1 i believe)
Does this (and the other new
_result_functions) need to be added to the header file after the old functions, in order not to invalidate the documented doxygen\returnparameter?@ -130,6 +130,15 @@ void i2c_set_slave_mode(i2c_inst_t *i2c, bool slave, uint8_t addr) {i2c->hw->enable = 1;For consistency with function-names and return-types, I wonder if
i2c_write_blocking_internalought to be renamed toi2c_write_result_blocking_internal? 🤔 (It's an internal-only function name, so I think we're free to rename it?)@ -130,6 +130,15 @@ void i2c_set_slave_mode(i2c_inst_t *i2c, bool slave, uint8_t addr) {i2c->hw->enable = 1;out of date
I've had another go at this. I decided I couldn't face adding new overloads to an already complicated API, just to get a not-often used reason for an abort. Instead I've added a new PICO_ERROR_ABORT error code. This is only used if PICO_I2C_RETURN_ABORT_REASON=1 in which case the abort reason is taken from this. So you can obtain the reason with a bit of maths.
interesting... i think perhaps i'd prefer to make something more generic (and not overlaying existing/future return codes)...
e.g. assign codes
0x80000000to0xbfffffffas "data" error codes which return 30 bits of function specific result (similar to the way that any positive value can be success)can then add a
pico_error_has_data(code)andpico_error_get_data(code)macros... the I2C API can add a more specific API that uses thisSounds good, will have a go at that. The one issue is that the docs specifies that PICO_ERROR_GENERIC is returned if there's no ack (abort basically), that's the reason I haven't enabled this by default as it's basically an API breakage?
yes; we have hit this elsewhere - hard to change from -1, though we want to move people towards
< 0..so yeah, you can still leave this optional
@ -44,2 +44,3 @@PICO_ERROR_VERSION_MISMATCH = -20, ///< A version mismatch occurred (e.g. trying to run PIO version 1 code on RP2040)PICO_ERROR_RESOURCE_IN_USE = -21 ///< The call could not proceed because requires resourcesw were unavailablePICO_ERROR_RESOURCE_IN_USE = -21, ///< The call could not proceed because requires resourcesw were unavailablePICO_ERROR_ABORT = -22, ///< The call could not proceed so was abortednitpick: "requires resourcesw" -> "required resources"
@ -130,6 +130,15 @@ void i2c_set_slave_mode(i2c_inst_t *i2c, bool slave, uint8_t addr) {i2c->hw->enable = 1;}// PICO_CONFIG: PICO_I2C_RETURN_ABORT_REASON, change i2c functions to return the abort reason via a return code less than or equal to PICO_ERROR_ABORT, type=bool, default=0, group=harware_i2charware_i2c->hardware_i2cView command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.