Modifications

Sauter à la navigation Sauter à la recherche
619 octets ajoutés ,  12 octobre 2013 à 21:52
Ligne 3 : Ligne 3 :  
== Librairie SPI ==
 
== Librairie SPI ==
   −
WiringPi includes a library which can make it easier to use the Raspberry Pi’s on-board SPI interface.
+
WiringPi inclus une librairie qui facilite l'utilisation du bus SPI du Raspberry Pi.
   −
Before you can use SPI interface, you may need to use the gpio utility to load the SPI drivers into the kernel:
+
Avant de pouvoir utiliser l'interface SPI, vous pourriez avoir besoin d'utiliser l'utilitaire '''gpio''' pour charger le pilote SPI dans le noyaux (Kernel):
   −
gpio load spi
+
gpio load spi
   −
If you need a buffer size of greater than 4KB, then you can specify the size (in KB) on the command line:
+
Si vous avez besoin d'une mémoire tampon (''buffer'') supérieur à 4KB alors vous devez spécifier la taille (en KB) dans la ligne de commande:
   −
gpio load spi 100
+
gpio load spi 100
   −
will allocate a 100KB buffer. (You should rarely need this though, the default is more than enough for most applications).
+
allouera une mémoire tampon de 100KB. Vous aurez rarement besoin d'une taille taille de buffer, la valeur par défaut sera plus qu'assez pour la plupart des application.
   −
To use the SPI library, you need to:
+
Pour utiliser la librairie SPI, vous devez ajouter la ligne suivante dans votre programme:
   −
#include <wiringPiSPI.h>
+
<nowiki>#include <wiringPiSPI.h></nowiki>
   −
in your program. Programs need to be linked with -lwiringPi as usual.
+
Comme d'habitude, le programme doit être linké avec le paramètre '''-lwiringPi''' .
    
== Fonctions ==
 
== Fonctions ==
Ligne 27 : Ligne 27 :  
  int wiringPiSPISetup(int channel, int speed);
 
  int wiringPiSPISetup(int channel, int speed);
   −
This is the way to initialise a channel (The Pi has 2 channels; 0 and 1). The speed parameter is an integer in the range 500,000 through 32,000,000 and represents the SPI clock speed in Hz.
+
C'est la façon dont il faut initialiser un canal SPI (le Pi dispose de 2 canaux; 0 et 1).  
   −
The returned value is the Linux file-descriptor for the device, or -1 on error. If an error has happened, you may use the standard errno global variable to see why.
+
Paramètres:
 +
* '''channel''': Le canal SPI à initialiser.
 +
* '''speed''': la vitesse du canal SPI. Un entier (''integer'') dont la valeur varie entre 500,000 et 32,000,000 et représente la vitesse d'horloge du bus SPI en Hz.
 +
 
 +
La valeur retournée est un ''file descriptor'' Linux correspondant au périphérique. En cas d'erreur, c'est -1 qui est retourné en qui est retourné et la variable globale ''errno'' est initialisée avec un code d'erreur standard.
    
=== wiringPiSPIDataRW ===
 
=== wiringPiSPIDataRW ===
    int wiringPiSPIDataRW(int channel, unsigned char *data, int len);
+
int wiringPiSPIDataRW(int channel, unsigned char *data, int len);
 +
 
 +
Effectue simultanément une transaction d'écriture/lecture sur le bus SPI sélectionné. Les données qui étaient disponibles dans votre mémoire tampon (buffer) sont écrasées avec les données obtenues sur le bus SPI.
 +
 
 +
== Sommaire ==
 +
Voila, c'est tout pour la librairie SPI.
   −
This performs a simultaneous write/read transaction over the selected SPI bus. Data that was in your buffer is overwritten by data returned from the SPI bus.
+
Il est possible d'effectuer de simple lecture et écriture sur le bus SPI en faisant appel aux fonctions systèmes standards read() et write().
   −
That’s all there is in the helper library. It is possible to do simple read and writes over the SPI bus using the standard read() and write() system calls though – write() may be better to use for sending data to chains of shift registers, or those LED strings where you send RGB triplets of data. Devices such as A/D and D/A converters usually need to perform a concurrent write/read transaction to work.
+
L'utilisation de la fonction write() sera plus appropriée pour l'envoi de données vers une chaine de registre à décalage, ou ces chaines de LED où vous envoyez des triplet de données RGB.  
    +
Pour fonctionner correctement, les convertisseurs A/D (analogique/digital) et D/A ont habituellement besoin d'effectuer une transaction écriture/lecture concurrent.
    
{{Pi-WiringPi-TRAILER}}
 
{{Pi-WiringPi-TRAILER}}
29 917

modifications

Menu de navigation