Ligne 5 : |
Ligne 5 : |
| == FT232 en mode Bus SPI == | | == FT232 en mode Bus SPI == |
| | | |
− | The FT232H's MPSSE is great for generating signals to communicate using the SPI protocol. The MPSSE can take care of generating a clock signal from about 450hz to 30Mhz, and read & write bytes of data at that frequency. The Python GPIO library that was installed includes a small wrapper around MPSSE functions to simplify the use of reading and writing SPI data.
| + | Le FT232H en mode MPSSE est génial pour générer des signaux pour communiquer en utilisant le protocol SPI. Le MPSSE est capable de générer un signal d'horloge de 450hz (environ) à 30Mhz, et de lire et écrire des octets de données à cette fréquence. La bibliothèque Python GPIO qui a été installé inclus un "wrapper" autour de certaines fonctions MPSSE pour simplifier la lecture et l'écriture de donnée SPI. |
| | | |
− | When using SPI with the FT232H the following pins will have a special meaning:
| + | En utilisant SPI avec le FT232H, les broches suivantes ont une signification spéciale: |
| + | * '''D0 - SCK / Clock signal / Signal d'horloge''' : C'est le signal d'horloge qui indique aux périphériques quand échantilloner et écrire des données. |
| + | * '''D1 - MOSI / Data Out / Sortie de donnée''' : ligne de sortie de donnée du FT232H vers le périphérique. |
| + | * '''D2 - MISO / Data In / Entrée de donnée''' : ligne pour lire les données en provenance du périphérique connecté sur le FT232H. |
| | | |
− | * '''D0 - SCK / Clock signal''' : This will be the clock that tells devices when to sample and write data.
| + | Une chose à noter, c'est qu'il n'existe pas de broche ''chip select'' / '''enable ''' explicite. Vous devriez utiliser une des broches GPIO libre comme signal ''chip select'' dédicacé. Vous devrez préciser cette broche lors de la création de l'objet SPI. |
− | * '''D1 - MOSI / Data Out''' : This will output data from the FT232H to the connected device.
| |
− | * '''D2 - MISO / Data In''' : This will read data from the connected device to the FT232H.
| |
| | | |
− | One thing to note is that there isn't an explicit chip select / enable pin. You should use any of the free GPIO pins as a dedicated chip select pin and specify that pin when creating the SPI object.
| + | Vous aurez besoin de créer une instance de la classe Adafruit_GPIO.FT232H.SPI pour utiliser le bus SPI du FT232H sous Python: |
− | | |
− | To use SPI with the Python library you need to create an instance of the Adafruit_GPIO.FT232H.SPI class. For example see the following code:
| |
| | | |
| <syntaxhighlight lang="python"> | | <syntaxhighlight lang="python"> |
| import Adafruit_GPIO.FT232H as FT232H | | import Adafruit_GPIO.FT232H as FT232H |
| | | |
− | # Temporarily disable FTDI serial drivers. | + | # Désactiver temporairement le pilote FTDI série. |
| FT232H.use_FT232H() | | FT232H.use_FT232H() |
| | | |
− | # Find the first FT232H device. | + | # Trouver le premier périphérique FT232H. |
| ft232h = FT232H.FT232H() | | ft232h = FT232H.FT232H() |
| | | |
− | # Create a SPI interface from the FT232H using pin 8 (C0) as chip select. | + | # Créer une interface SPI du FT232H en utilisant la broche 8 (C0) comme signal ''chip select''. |
− | # Use a clock speed of 3mhz, SPI mode 0, and most significant bit first. | + | # Utiliser une fréquence d'horloge de 3mhz, mode SPI 0 et le bit le plus significatif en premier. |
| spi = FT232H.SPI(ft232h, cs=8, max_speed_hz=3000000, mode=0, bitorder=FT232H.MSBFIRST) | | spi = FT232H.SPI(ft232h, cs=8, max_speed_hz=3000000, mode=0, bitorder=FT232H.MSBFIRST) |
| | | |
− | # Write three bytes (0x01, 0x02, 0x03) out using the SPI protocol. | + | # Ecrire 3 octets/bytes (0x01, 0x02, 0x03) en utilisant le protocole SPI. |
| spi.write([0x01, 0x02, 0x03]) | | spi.write([0x01, 0x02, 0x03]) |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
− | Notice that the code starts by importing the FT232H part of the GPIO library and disabling the FTDI serial drivers as your saw in the GPIO example.
| + | Notez que le code commence par importer les éléments FT232H de la bibliothèque GPIO -puis- désactive le pilote FTDI série (comme dans l'exemple GPIO). |
| + | |
| + | Ensuite, le code crée un objet FT232H (comme dans l'exemple GPIO). |
| | | |
− | Next the code creates a FT232H object also like was done in the GPIO example.
| + | La ligne suivante crée une instance de la classe FT232H.SPI qui utilise le périphérique FT232H (l'instance créée juste avant). Un signal ''chip select''/''slave select'' optionnel est défini et assigné au '''GPIO 8 / broche C0''' à l'aide du paramètre "cs" . |
| | | |
− | The next line of code creates a FT232H.SPI object using the FT232H device that was just created. An optional chip select/slave select line is specified using '''GPIO 8 / pin C0''' with the cs parameter value.
| + | {{traduction}} |
| | | |
| Notice too the speed, mode, and bit order of the SPI protocol are specified as parameters of the initializer. Mode 0 and bit order of ''MSBFIRST'' are actually the default values and do not necessarily need to be specified here, but it's helpful to show them for clarity. | | Notice too the speed, mode, and bit order of the SPI protocol are specified as parameters of the initializer. Mode 0 and bit order of ''MSBFIRST'' are actually the default values and do not necessarily need to be specified here, but it's helpful to show them for clarity. |