1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
/* Programme assembleur RISCV Raspberry pico */
/* first programm in assembly riscv*/
/* compilation and test OK */
/* blink led OK */
/*********************************************/
/* CONSTANTES */
/********************************************/
.equ LED_PIN, 25
.equ GPIO_OUT_COM, 1
.equ GPIO_IN_COM, 0
.equ IOPORT, 0xD0000000
.equ SIOBASE_CPUID , 0x000 # Processor core identifier
.equ GPIO_IN , 0x004 # Input value for GPIO pins
.equ GPIO_HI_IN , 0x008 # Input value for QSPI pins
.equ GPIO_OUT , 0x010 # GPIO output value
.equ GPIO_OUT_SET , 0x014 # GPIO output value set
.equ GPIO_OUT_CLR , 0x018 # GPIO output value clear
.equ GPIO_OUT_XOR , 0x01c # GPIO output value XOR
.equ GPIO_OE , 0x020 # GPIO output enable
.equ GPIO_OE_SET , 0x024 # GPIO output enable set
.equ GPIO_OE_CLR , 0x028 # GPIO output enable clear
.equ GPIO_OE_XOR , 0x02c # GPIO output enable XOR
.equ GPIO_HI_OUT , 0x030 # QSPI output value
.equ GPIO_HI_OUT_SET, 0x034 # QSPI output value set
.equ GPIO_HI_OUT_CLR, 0x038 # QSPI output value clear
.equ GPIO_HI_OUT_XOR, 0x03c # QSPI output value XOR
.equ GPIO_HI_OE , 0x040 # QSPI output enable
.equ GPIO_HI_OE_SET , 0x044 # QSPI output enable set
.equ GPIO_HI_OE_CLR , 0x048 # QSPI output enable clear
.equ GPIO_HI_OE_XOR , 0x04c # QSPI output enable XOR
/*******************************************/
/* DONNEES INITIALISEES */
/*******************************************/
.data
/*******************************************/
/* DONNEES NON INITIALISEES */
/*******************************************/
.bss
/**********************************************/
/* SECTION CODE */
/**********************************************/
.text
.global main
main: #
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 end
1:
li t2,IOPORT
sw t1,GPIO_HI_OUT_CLR(t2) # store pin 25 in gpio clear register
2:
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 end
1:
li t2,IOPORT # load sio address
sw t1,GPIO_OUT_CLR(t2) # store pin 25 on register gpio
2:
ret
/************************************/ |
Partager