Skip to content

Commit

Permalink
minor changes in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
saursin committed Dec 26, 2023
1 parent 05e244a commit 5ce3a3c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 13 additions & 2 deletions sw/examples/banner/banner.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "platform.h"
#include <stdio.h>
#include <csr.h>
#include <gpio.h>
#include <time.h>

char * banner =
"\n"
Expand Down Expand Up @@ -28,15 +30,24 @@ char * banner =
" /_/ |_/___//____/\\____/ |___/ \\__,_/\\__/\\____/_/ /_/ /_/ \n"
"/=========By: Saurabh Singh ([email protected])====/\n\n";

print_isastring(){
uint32_t misa = CSR_read(CSR_MISA);
puts("RV32I");
if(bitcheck(misa, 12)) putchar('M');
if(bitcheck(misa, 0)) putchar('A');
if(bitcheck(misa, 5)) putchar('F');
if(bitcheck(misa, 3)) putchar('D');
if(bitcheck(misa, 2)) putchar('C');
}

int main()
{
serial_init(UART_BAUD_115200);
puts(banner);
printf("CPU : RISC-V Atom @ %d Hz\n", CLK_FREQ);
puts("Arch : RV32I - little endian\n");
puts("Arch : "); print_isastring(); puts(" - little endian\n");
printf("CODE RAM : 0x%08x (%d bytes)\n", (unsigned)CODERAM_BASE, (unsigned)CODERAM_SIZE);
printf("DATA RAM : 0x%08x (%d bytes)\n", (unsigned)DATARAM_BASE, (unsigned)DATARAM_SIZE);
puts("Exiting...\n");
asm volatile("ecall");
return 0;
}
3 changes: 1 addition & 2 deletions sw/examples/blinky/blinky.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ void soft_pwm(uint8_t dutycycle, uint32_t duration)
{
if(i>dutycycle)
gpio_writew(0x00);
sleep_us(500);
}
}
}
Expand Down Expand Up @@ -159,7 +158,7 @@ void main()
run_pattern(pat7, sizeof(pat7), 100, false);


puts("Pattern 8: Soft PWM");
puts("Pattern 8: Soft PWM\n");
for(int i=0; i<5; i++){
for(int d=0; d<255; d+=5)
soft_pwm(d, 30);
Expand Down

0 comments on commit 5ce3a3c

Please sign in to comment.