Skip to content

align constants across core board variants #3681

Open
@soundanalogous

Description

@soundanalogous

It would be helpful if pin feature constants could be aligned across all core board variants (related issue). They are arleady well aligned across the AVR boards, but the SAM boards introduce some differences. The changes that would be helpful are as follows:

Add to /arduino_zero/variant.h

DAC0                  (14ul)
DACC_RESOLUTION       10  // or if DACC is specific to Due, then create a neutral way to define this

Add to /arduino_zero/variant.h and /arduino_due_x/variant.h
(currently defined for all AVR variants)

SCL                PIN_WIRE_SCL
SDA                PIN_WIRE_SDA

and to /arduino_due_x/variant.h

SCL1               PIN_WIRE1_SCL
SDA1               PIN_WIRE1_SDA

Add to all variants that have more than 1 HW serial port

PIN_SERIAL1_RX, PIN_SERIAL1_TX, PIN_SERIAL2_RX, PIN_SERIAL2_TX, etc.

The reason for defining HW SERIAL pin constants may be a specific need for Firmata and I could resolve it in Boards.h if Firmata is the only use case. I'm in the process of adding support for interfacing with Serial devices through Firmata (so users can interact with GPS, RFID, Serial LCDs, etc) and ran into an issue that I cannot resolve without a generic map of HW serial pin numbers.

The issue is that in Firmata, all digital pins are initially set to OUTPUT. This eliminates noise from triggering false digital reads (since in StandardFirmata all digital pins are read once per iteration of the main loop). However, this creates an issue with some serial devices such as the Adafruit Ultimate GPS breakout board. I'm only noticing this with an Arduino Due so far. It is not possible to read the output from the GPS board unless the RX pin (RX1, RX2, or RX3) is set back to INPUT when calling SerialN.begin (where N is 1, 2, or 3). The problem is there is no way to programmatically know which pins correspond to RX and TX for all boards. The Zero is the first board to provide constants for this. For Firmata the constants would also be helpful in reporting HW serial pins in the capability query results. Let me know if this would be useful for cases other than Firmata, otherwise I'll just add those defines for all applicable boards in Boards.h.

Metadata

Metadata

Assignees

Labels

Component: CoreRelated to the code for the standard Arduino APIComponent: DocumentationRelated to Arduino's documentation contentfeature requestA request to make an enhancement (not a bug fix)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions