예제 #1
0
int spectr_fpga_init(void)
{
    /* update hw specific parmateres, NOTE, this is now hardcoded */
    g_spectr_fpga_adc_max_v = c_spectr_fpga_adc_max_v_revD;

    /* If maybe needed, cleanup the FD & memory pointer */
    if(__spectr_fpga_cleanup_mem() < 0)
        return -1;

    g_spectr_fpga_mem_fd = open("/dev/uio/api", O_RDWR | O_SYNC);
    if(g_spectr_fpga_mem_fd < 0) {
        fprintf(stderr, "ERROR: failed open of UIO device: %s\n", strerror(errno));
        return -1;
    }

    g_spectr_fpga_reg_mem = mmap(NULL, SPECTR_FPGA_BASE_SIZE, PROT_READ | PROT_WRITE,
                          MAP_SHARED, g_spectr_fpga_mem_fd, (SPECTR_FPGA_BASE_ADDR >> 20) * sysconf(_SC_PAGESIZE));
    if((void *)g_spectr_fpga_reg_mem == MAP_FAILED) {
        fprintf(stderr, "mmap() failed: %s\n", strerror(errno));
        __spectr_fpga_cleanup_mem();
        return -1;
    }
    g_spectr_fpga_cha_mem = (uint32_t *)g_spectr_fpga_reg_mem +
        (SPECTR_FPGA_CHA_OFFSET / sizeof(uint32_t));
    g_spectr_fpga_chb_mem = (uint32_t *)g_spectr_fpga_reg_mem +
        (SPECTR_FPGA_CHB_OFFSET / sizeof(uint32_t));

    return 0;
}
예제 #2
0
파일: spec_fpga.c 프로젝트: Gulzt/RedPitaya
int spectr_fpga_init(void)
{
    void *page_ptr;
    long page_addr, page_off, page_size = sysconf(_SC_PAGESIZE);

    /* update hw specific parmateres */
    if(update_hw_spec_par()<0){
    	return -1;
    }

    /* If maybe needed, cleanup the FD & memory pointer */
    if(__spectr_fpga_cleanup_mem() < 0)
        return -1;

    g_spectr_fpga_mem_fd = open("/dev/mem", O_RDWR | O_SYNC);
    if(g_spectr_fpga_mem_fd < 0) {
        fprintf(stderr, "open(/dev/mem) failed: %s\n", strerror(errno));
        return -1;
    }

    page_addr = SPECTR_FPGA_BASE_ADDR & (~(page_size-1));
    page_off  = SPECTR_FPGA_BASE_ADDR - page_addr;

    page_ptr = mmap(NULL, SPECTR_FPGA_BASE_SIZE, PROT_READ | PROT_WRITE,
                          MAP_SHARED, g_spectr_fpga_mem_fd, page_addr);
    if((void *)page_ptr == MAP_FAILED) {
        fprintf(stderr, "mmap() failed: %s\n", strerror(errno));
        __spectr_fpga_cleanup_mem();
        return -1;
    }
    g_spectr_fpga_reg_mem = page_ptr + page_off;
    g_spectr_fpga_cha_mem = (uint32_t *)g_spectr_fpga_reg_mem + 
        (SPECTR_FPGA_CHA_OFFSET / sizeof(uint32_t));
    g_spectr_fpga_chb_mem = (uint32_t *)g_spectr_fpga_reg_mem + 
        (SPECTR_FPGA_CHB_OFFSET / sizeof(uint32_t));

    return 0;
}
예제 #3
0
파일: spec_fpga.c 프로젝트: Gulzt/RedPitaya
int spectr_fpga_exit(void)
{
    __spectr_fpga_cleanup_mem();

    return 0;
}