Skip to content

Redesign the platform so that hardware-specific API is not visible by default #8440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vgheo opened this issue Jan 26, 2019 · 1 comment
Open
Labels
Component: Core Related to the code for the standard Arduino API feature request A request to make an enhancement (not a bug fix)

Comments

@vgheo
Copy link

vgheo commented Jan 26, 2019

At the moment, the hardware-specific API is visible in the arduino sketches by default.
( ie implementation details are bleeding into the Arduino abstract API).

Therefore users can write code like

PORTB &= ~(1 << PB3); // reset bit 3 of PORT B

and even

digitalWrite(PB1 , HIGH); //This doesnt work

This confusion can be eliminated if the hw-specific headers are not included in the sketch by default.
If advanced users really need these defines, they can include the headers explicitly.

Samples:
https://www.instructables.com/id/ATTiny-Port-Manipulation/
PORTB |= (1 << PB3); //replaces digitalWrite(PB3, HIGH);
damellis/attiny#127

@per1234
Copy link
Collaborator

per1234 commented Oct 5, 2020

I also have seen this misconception about being able to use port/bit notation with Arduino API functions come up regularly, most often with people who are using bare chips rather than Arduino boards. However, your proposal would be a breaking change so it wouldn't be possible to do to the established boards platforms. It could be considered during the creation of boards platforms for new architectures where there are no established sketches using that API to break.

I did some work on the Arduino Language Reference content to try to emphasize that Arduino API functions only take Arduino pin numbers: arduino/reference-en#516

If anyone is interested in studying this issue to identify possible opportunities to mitigate it, I added a collection of references to incidences of this issue in arduino/reference-en#516.

@per1234 per1234 added Component: Core Related to the code for the standard Arduino API feature request A request to make an enhancement (not a bug fix) labels Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Related to the code for the standard Arduino API feature request A request to make an enhancement (not a bug fix)
Projects
None yet
Development

No branches or pull requests

2 participants