arduino / arduino/ArduinoCore-avr

deprecated sbi and cbi macros should be replaced

Open
#394 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by searching wiring.c, wiring_digital.c, HardwareSerial.cpp, and wiring_analog.c for the deprecated sbi and cbi macros, using the avr-libc documentation linked in the issue as the replacement reference. The work is done when those listed uses have been replaced with the standard bit-manipulation forms and no deprecated sbi/cbi uses remain in the affected files.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
embedded-iot
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.