arduino / arduino/ArduinoCore-API

Ability to set speed in shiftIn & shiftOut

Ouverte
#83 1 commentaire 7 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C++
Étoiles
306
Forks
150
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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.

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Commencez par les déclarations de shiftIn et shiftOut présentées dans l’issue et comparez la sémantique demandée de maxSpeed avec la référence de la bibliothèque matérielle SPI d’Arduino. Déterminez comment la gestion de la vitesse peut préserver les appels existants et prendre en charge des appareils plus lents, comme dans le cas ESP32/HX711 ; le travail est considéré comme terminé lorsque l’API prend en charge une communication plus lente sans rompre la compatibilité ascendante.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
cpp
Domaine
api, embedded-iot
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.