kinetis/bme: add bit_checkXX() functions#21705
kinetis/bme: add bit_checkXX() functions#21705elenaf9 wants to merge 3 commits intoRIOT-OS:masterfrom
Conversation
A general `bit_checkXX` implementation was added with RIOT-OS#16522 to `sys/bit.h`, but still missing for kinetis MCUs.
|
Is this not already covered by the |
No, because the whole |
|
Ah the Kinetis Bit Manipulation Engine is indeed different from the ARM bit-banding extension! I would have thought they'd just use the standard functionality under a different name. |
| */ | ||
| static inline bool bit_check32(volatile uint32_t *ptr, uint8_t bit) | ||
| { | ||
| return *((volatile uint32_t *)(((uintptr_t)ptr) | BME_AND_MASK)) & (uint32_t)(1ul << bit); |
There was a problem hiding this comment.
Wouldn't this be
| return *((volatile uint32_t *)(((uintptr_t)ptr) | BME_AND_MASK)) & (uint32_t)(1ul << bit); | |
| return bme_bitfield32(ptr, bit, 32); |
I have openlabs-kw41z-mini at home and can test
There was a problem hiding this comment.
Ah yeah, makes sense. I am not familiar with the kinetis bme at all, so I was just implementing it analogous to the other functions and didn't look at the bitfield functions above properly.
Should I already change it in this PR or do you want to do the testing first?
There was a problem hiding this comment.
Sorry, I didn't get to it before my vaccation - I added a unit test so we can actually test those function and turns out bit_clearXX() is already not working 😕
2025-09-30 00:44:56,723 # START
2025-09-30 00:44:56,723 # .clear bit 0
2025-09-30 00:44:56,723 # clear bit 2
2025-09-30 00:44:56,723 #
2025-09-30 00:44:56,724 # bit_tests.test_bit8 (tests/unittests/tests-bit/tests-bit.c 36) exp 250 was 251
2025-09-30 00:44:56,724 # .
2025-09-30 00:44:56,735 # bit_tests.test_bit16 (tests/unittests/tests-bit/tests-bit.c 60) exp 65530 was 65531
2025-09-30 00:44:56,735 # .
2025-09-30 00:44:56,740 # bit_tests.test_bit32 (tests/unittests/tests-bit/tests-bit.c 84) exp 4294967290 was 4294967291
If you want to move this forward, you can just set BITBAND_FUNCTIONS_PROVIDED 0 and I'll look into this later since I can actually test it.
There was a problem hiding this comment.
Okay, thanks!
If you want to move this forward, you can just set
BITBAND_FUNCTIONS_PROVIDED0 and I'll look into this later since I can actually test it.
Opened #21750.
Contribution description
Add
bit_checkXXfunctions for kinetis MCUs, analogous to the existingbit_clearandbit_setfunctions.A general
bit_checkXXimplementation was added with #16522 tosys/bit.h, and probably just forgotten for the kinetis override?cc @benpicco.
Testing procedure
Unfortunately I don't have any kinetis-based boards with me. If someone has them and it is wanted, I can add some unitests for setting/clearing/ reading bits, analogous to the existing
tests-bitfieldtest.Issues/PRs references
Came up in #21577, which adds a first usage of
bit_check(Murdock error).