Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

DE10-Standard reading states of switches by HPS

Bruno812

Newbie
Joined
Nov 21, 2023
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
13
Hi,

I struggle with reading the states of switches by HPS on the DE10-Standard development kit. Recently I managed to create a design that manipulates LEDs from the HPS side, so I am familiar with the whole process of placing Linux on a microSD card, etc. In the LED project, I used a PIO that was directly connected to the HPS2FPGA lightweight bridge.
Here is my C code for the LED project (PIO name is NARX_input):

C:
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/mman.h>
#include "hps_0.h"

#define REG_BASE 0xff200000
#define REG_SPAN 0x00200000

void *base;
uint32_t *out_HPS;
int fd;

void handler(int signo)
{
    *out_HPS=0;
    munmap(base, REG_SPAN);
    close(fd);
    exit(0);
}

int main()
{
    fd=open("/dev/mem", O_RDWR|O_SYNC);
    if(fd<0)
    {
        printf("Can't open memory.\n");
        return -1;
    }
    base=mmap(NULL, REG_SPAN, PROT_READ|PROT_WRITE, MAP_SHARED, fd, REG_BASE);
    
    if(base==MAP_FAILED)
    {
        printf("Can't open memory.\n");
        close(fd);
        return -1;
    }
    out_HPS=(uint32_t*)(base+NARX_INPUT_BASE);
    signal(SIGINT, handler);
    *out_HPS=0x0;
    while(1)
    {   
        usleep(1);
        *out_HPS = 0b000001000000000000000001;
        usleep(1);
        *out_HPS = 0b000010000000000000000010;
        usleep(1);
        *out_HPS = 0b000011000000000000000100;
        usleep(1);
        *out_HPS = 0b000100000000000000001000;
        usleep(1);
        *out_HPS = 0b000101000000000000010000;
        usleep(1);
        *out_HPS = 0b000110000000000000100000;
        usleep(1);
        *out_HPS = 0b000111000000000001000000;
        
    }
}


I understand that I need to use the FPGA2HPS bridge. How do I prepare the right Platform Designer file and modify my C code to do this?

Thanks in advance.
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top