hw_set_bits() forces the given bits to '1' and leaves the others unchanged; hw_clear_bits() forces the given bits (those that are '1' in the argument) to zero and leave the other register bits unchanged; hw_xor_bits() performs an atomic xor between the current register content and the argument.
Those are all the native operations supported by the hardware and have the same cost as doing a simple store.
hw_set_masked() is the tricky one, as it's an operation you often want to do (set a group of bits in the register to some value that isn't 000 or 111, while leaving other bits unchanged), but isn't directly supported by hardware. I believe the SDK implements it in two steps: hw_clear_bits() and then hw_xor_bits() so that none of the other register bits get changed at all, but the bits you are writing to do momentarily get set to all-zero before being set to the value that you wanted.
Those are all the native operations supported by the hardware and have the same cost as doing a simple store.
hw_set_masked() is the tricky one, as it's an operation you often want to do (set a group of bits in the register to some value that isn't 000 or 111, while leaving other bits unchanged), but isn't directly supported by hardware. I believe the SDK implements it in two steps: hw_clear_bits() and then hw_xor_bits() so that none of the other register bits get changed at all, but the bits you are writing to do momentarily get set to all-zero before being set to the value that you wanted.
Statistics: Posted by arg001 — Sat Dec 14, 2024 2:53 pm