arduino / arduino/ArduinoCore-API

Ability to set speed in shiftIn & shiftOut

未关闭
#83 1 条评论 7 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C++
星标
306
派生
150
PR 合并指标
30 天内没有已合并 PR

描述

While the clock speeds of various Microcontrollers increase, the speed of the shiftIn and shiftOut also increases. This creates a problem when communicating with slower devices. It could be interesting to add an optional argument to these functions so they reliably work with slower devices. Just like with the SPI hardware library where you can set the maximum SPI speed. https://www.arduino.cc/en/Reference/SPI

I had this problem when I was trying to use the 'normal' library for the HX711 load cell amp with an ESP32.
https://github.com/bogde/HX711/issues/75

The interface could look like this:
```cpp

void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val, unsigned long maxSpeed = 0);
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, unsigned long maxSpeed = 0);

```
Where a maxSpeed of 0 would mean that it would use the full speed of the microcontroller. Otherwise you could define the speed as frequency (15Mhz -> 15000000) just like in the SPI hardware library.

In this way Arduino would be future-proof without losing backwards compatibility.

贡献指南

这个仓库没有索引到贡献指南

调研方向

从 issue 中所示的 shiftIn 和 shiftOut 声明开始,并将所请求的 maxSpeed 语义与 Arduino 的 SPI 硬件库参考进行比较。确定如何处理速度,才能保留现有调用并支持较慢的设备,例如 ESP32/HX711 的情况;完成的标准是 API 支持较慢的通信,同时不破坏向后兼容性。

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

评估

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

把新 issue 发到你的邮箱

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