Skip to content

deprecated sbi and cbi macros should be replaced #394

Open
@DerAndere1

Description

@DerAndere1

Documentation of the AVR C Standard library avr-libc (https://www.nongnu.org/avr-libc/user-manual/group__avr__sfr.html) says:

Porting programs that use the deprecated sbi/cbi macros

Access to the AVR single bit set and clear instructions are provided via the standard C bit manipulation commands. The sbi and > cbi macros are no longer directly supported. sbi (sfr,bit) can be replaced by sfr |= _BV(bit) .

i.e.: sbi(PORTB, PB1); is now PORTB |= _BV(PB1);

This actually is more flexible than having sbi directly, as the optimizer will use a hardware sbi if appropriate, or a read/or/write > operation if not appropriate. You do not need to keep track of which registers sbi/cbi will operate on.

Likewise, cbi (sfr,bit) is now sfr &= ~(_BV(bit));

I think, in the following files the deprecated sbi and cbi macros are currently used and should be replaced:
wiring.c, wiring_digital.c, HardwareSerial.cpp, wiring_analog.c.

Related issue: #357

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions