Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

refactor the use of g_APinDescription ?

未关闭
#106 1 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
30/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
停滞
技术栈
cpp
领域
embedded-iot

调研方向

首先比较 variant.h 和 Arduino.h 中的访问宏与 cores/arduino/Tone.cpp 中的数组直接使用情况,包括 g_APinDescription 和 digital_pin_to_xxx。梳理当前直接访问的引脚相关数据,然后定义可重写正式 API 的范围;当 core 和库代码使用这些定义而不假定特定实现时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

It bothers me, in a sort of "Code Purity" sense, that so many core and library functions access
the g_APinDescription[] (for sam/samd) or digital_pin_to_xxx[] (for avr) arrays directly.
There are some macros in variant.h or Arduino.h (digitalPinToBitMask and similar), but they are not consistently used, not all functions have macros, and sometimes they aren't well-placed WRT redefining them for new board types.
Example:

variants/mkr1000/variant.h:47: #define digitalPinToBitMask(P)   (1 << g_APinDescription[P].ulPin)
cores/arduino/Tone.cpp:133:  portBitMask = (1ul << g_APinDescription[outputPin].ulPin);

The definition of a more formal API presents the opportunity to offer more formal rules:

  1. macros or inline functions to access all pin-related data should be defined in the variant-specific files, or perhaps WVariant.h for core-wide data.

  2. if such definitions are defined in core-wide functions, it should be possible to override them in variant-specific files.

  3. All other code should use these definitions, instead of assuming a particular implementation. (the tone.cpp example above should not exist, even now.)

The immediate practical benefit would be the possibility of more compact implementations for the "tiny" chips (avr tiny, SAMD11, etc), and greater portability of the functions in the "upper level" areas of code.

主要语言
C++
星标
307
派生
152
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

arduino/ArduinoCore-API 的其他 Issue

查看 arduino/ArduinoCore-API 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。