Modifications

Sauter à la navigation Sauter à la recherche
278 octets ajoutés ,  19 avril 2015 à 09:09
aucun résumé de modification
Ligne 4 : Ligne 4 :     
== introduction ==
 
== introduction ==
{{bloc-etroit|text=Here you will learn how to write inline assembler in Micro Python.
+
{{bloc-etroit|text=Dans ce tutoriel, vous allez apprendre comment écrire de l'assembleur (''inline assembler'') en Micro Python.
   −
Note: this is an advanced tutorial, intended for those who already know a bit about microcontrollers and assembly language.
+
{{ambox|text=Il s'agit d'un tutoriel avancé destiné à ceux qui connaissent déjà un peu les microcontroleur et le langage assembleur.}}
   −
Micro Python includes an inline assembler. It allows you to write assembly routines as a Python function, and you can call them as you would a normal Python function.}}
+
Micro Python inclus un assembleur inline. Il vous permettra d'écrire des routines assembleur comme si c'était des fonctions micro python, et vous pouvez l'appeler comme si cela était des fonction Python normale.}}
    
== Retourner une valeur ==
 
== Retourner une valeur ==
{{bloc-etroit|text=Inline assembler functions are denoted by a special function decorator. Let’s start with the simplest example:
+
{{bloc-etroit|text=Les fonctions assembleur Inline sont annotées avec une fonction de décoration spéciale. Commençons par l'exemple le plus simple:
    
  <nowiki>@micropython.asm_thumb
 
  <nowiki>@micropython.asm_thumb
Ligne 17 : Ligne 17 :  
     movw(r0, 42)</nowiki>
 
     movw(r0, 42)</nowiki>
   −
You can enter this in a script or at the REPL. This function takes no arguments and returns the number 42. {{fname|r0}} is a register, and the value in this register when the function returns is the value that is returned. Micro Python always interprets the {{fname|r0}} as an integer, and converts it to an integer object for the caller.
+
Vous pouvez placer de code dans un script ou le taper sur une invite REPL. Cette fonction ne prend aucun argument et retourne le nombre 42. {{fname|r0}} est un registre, et la valeur dans ce registre lorsque la fonction se termine, est la valeur qui est retournée par la fonction.  
   −
If you run {{fname|print(fun())}} you will see it print out 42.}}
+
Micro Python interprète toujours {{fname|r0}} comme un entier (type {{int}}) et converti cette valeur en objet {{fname|int}} (integer) pour la fonction appelante.
 +
 
 +
Si vous exécutez {{fname|print(fun())}} vous verrez apparaître la valeur 42.}}
    
== Accéder aux périphériques ==
 
== Accéder aux périphériques ==
For something a bit more complicated, let’s turn on an LED:
+
Pour un exemple un peu plus compliqué, essayons maintenant d'allumer une LED:
    
  <nowiki>@micropython.asm_thumb
 
  <nowiki>@micropython.asm_thumb
Ligne 30 : Ligne 32 :  
     strh(r1, [r0, stm.GPIO_BSRRL])</nowiki>
 
     strh(r1, [r0, stm.GPIO_BSRRL])</nowiki>
   −
This code uses a few new concepts:
+
Ce code utilise quelques nouveaux concepts:
    
* {{fname|stm}} is a module which provides a set of constants for easy access to the registers of the pyboard’s microcontroller. Try running {{fname|import stm}} and then {{fname|help(stm)}} at the REPL. It will give you a list of all the available constants.
 
* {{fname|stm}} is a module which provides a set of constants for easy access to the registers of the pyboard’s microcontroller. Try running {{fname|import stm}} and then {{fname|help(stm)}} at the REPL. It will give you a list of all the available constants.
29 917

modifications

Menu de navigation