Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8013

Français • comment lire une entrée gpio en assembleur risc

$
0
0
Bonjour, je souhaite lire une entrée mais en assembleur avec le risc du pico2.
ce code permet de commander la sortie du gpio pour cela il suffit de changer le "LED_PIN" mais
je ne trouve pas d'exemple pour l'entrée?

Code:

.global mainmain:                           #      li a0,LED_PIN    call gpio_init              # init led 25        li a0,LED_PIN    li a1,GPIO_OUT    call seldirGpio             # set direction to out 1:        li a0,LED_PIN               # pin 25    li a1,0                     # turn off led     call putGpio    li a0, 250                  # waiting time    call sleep_ms     li a0,LED_PIN               # pin 25    li a1,1                     # turn on led     call putGpio    li a0, 150                  # waiting time    call sleep_ms     j 1b                        # and loop    /************************************//*       select direction pin gpio   *//***********************************//* a0 pin   *//* a1 value */seldirGpio:    li t1,1                             # set bit    sll t1,t1,a0                        # shift bit in pin position    bne a1,x0,1f                        # in or out direction ?    li t2,IOPORT                        # load sio address    sw t1,GPIO_HI_OUT_SET(t2)           # store pin 25 on register gpio set     j 2f                                # jump end1:    li t2,IOPORT    sw t1,GPIO_HI_OUT_CLR(t2)           # store  pin 25 in gpio clear register2:    ret/************************************//*       Put pin gpio               *//***********************************//* a0 pin   *//* a1 value */putGpio:    li t1,1                            # set bit    sll t1,t1,a0                       # shift bit in pin position    beq a1,x0,1f                       # turn on or turn off     li t2,IOPORT                       # load sio address    sw t1,GPIO_OE(t2)                  # store pin 25 on register gpio    j 2f                               # jump end1:    li t2,IOPORT                       # load sio address    sw t1,GPIO_OUT_CLR(t2)             # store pin 25 on register gpio2:    ret/************************************/ 
merci d'avance pour la réponse

Statistics: Posted by keokod — Sat Nov 16, 2024 2:44 pm



Viewing all articles
Browse latest Browse all 8013

Trending Articles