URL
https://opencores.org/ocsvn/neorv32/neorv32/trunk
Subversion Repositories neorv32
Compare Revisions
- This comparison shows the changes necessary to convert path
/neorv32/trunk/sw/example/blink_led
- from Rev 22 to Rev 23
- ↔ Reverse comparison
Rev 22 → Rev 23
/blink_led_in_asm.S
0,0 → 1,37
.file "blink_led_in_asm.S" |
.section .text |
.balign 4 |
.global blink_led_asm |
|
blink_led_asm: |
|
/* base address of GPIO controller's output port is passed as argument (in a0)*/ |
sw zero, 0(a0) /* clear output port */ |
|
li t1, 0 /* initialize counter */ |
|
|
blink_loop: |
andi t1, t1, 255 /* apply 8-bit mask */ |
sw t1, 0(a0) /* output current counter value */ |
addi t1, t1, 1 /* increment counter */ |
|
jal ra, blink_delay /* call delay function */ |
|
j blink_loop |
|
|
blink_delay: |
li t2, 0xfffff /* delay time */ |
|
blink_delay_loop: |
beq t2, zero, blink_delay_end |
addi t2, t2, -1 |
nop |
nop |
j blink_delay_loop |
|
blink_delay_end: |
ret |
|
.end |
/main.c
48,10 → 48,18
/**@{*/ |
/** UART BAUD rate */ |
#define BAUD_RATE 19200 |
/** Use the custom ASM version for blinking the LEDs if != 0 */ |
#define USE_ASM_VERSION 0 |
/**@}*/ |
|
|
/**********************************************************************//** |
* ASM function to blink LEDs (if enabled) |
**************************************************************************/ |
extern void blink_led_asm(uint32_t gpio_out_addr); |
|
|
/**********************************************************************//** |
* Main function; shows an incrementing 8-bit counter on GPIO.output(7:0). |
* |
* @note This program requires the GPIO controller to be synthesized (the UART is optional). |
76,6 → 84,10
// say hello |
neorv32_uart_print("Blinking LED demo program\n"); |
|
|
// use C version of LED blinking |
#if (USE_ASM_VERSION == 0) |
|
neorv32_gpio_port_set(0); // clear gpio output put |
|
int cnt = 0; |
85,5 → 97,11
neorv32_cpu_delay_ms(200); // wait 200ms using busy wait |
} |
|
// use ASM version of LED blinking (file: blink_led_in_asm.S) |
#else |
|
blink_led_asm((uint32_t)(&GPIO_OUTPUT)); |
|
#endif |
return 0; |
} |