link my added nios2 register with actual Nios software

Discussions related to embedded firmware, driver, and user mode application software development
Post Reply
zibi
Posts: 3
Joined: Mon May 30, 2016 5:29 am

link my added nios2 register with actual Nios software

Post by zibi »

Hi everyone,

I wanna access my parallel I/O 32Bit Register "fft" added with QSYS to my nios2 Softcore.
I'm relatively new in software development and a bit confused about the "NIOS II Code Redesign".
https://www.nuand.com/blog/page/2/

Could you suggest some steps a should follow?
The README file specifies only packets with different sizes .. pkt_32x32 for example, but no ways how to move on..
Because it's too trivial.. I hope:)

Thanks in advance,


Zibi
zibi
Posts: 3
Joined: Mon May 30, 2016 5:29 am

Re: link my added nios2 register with actual Nios software

Post by zibi »

Hi Jon,

thank You for your comprehensive response.
I did as you said and
-defined my own package in nios_pkt_32x32.h :

Code: Select all

#define NIOS_PKT_32x32_TARGET_FFT    0x80
-added my handle case in pkt_32x32.c
in perform_write function:

Code: Select all

        //my customizations
        case NIOS_PKT_32x32_TARGET_FFT:
        	data = 0x9520; //Base address 0x9520 of my fft register
			break;
        //my customizations END
in perform_read:

Code: Select all

        //my customizations
        case NIOS_PKT_32x32_TARGET_FFT:
        	*data = 0x9520; //Base address 0x9520 of my fft register
			break;
        //my customizations END
I can not understand why eclipse cannot resolve my stuff:
"Symbol 'NIOS_PKT_32x32_TARGET_FFT' could not be resolved pkt_32x32.c"
The definition "NIOS_PKT_32x32_TARGET_EXP_DIR", for example can be found and stands just above my "NIOS_PKT_32x32_TARGET_FFT" in
nio_pkt_32x32.h .

Greetings,
Zibi
zibi
Posts: 3
Joined: Mon May 30, 2016 5:29 am

Re: link my added nios2 register with actual Nios software

Post by zibi »

@Jon

What do you mean with "add a function pointer to this structure and assign in in usb.c" ?

Following the lms6 example I added and changed the sizes to 32 only.

in nios_access.h :

Code: Select all

int nios_fft_register_read(struct bladerf *dev, uint32_t addr, uint32_t *data);
int nios_fft_register_write(struct bladerf *dev, uint32_t addr, uint32_t data);
in nios_access.c :

Code: Select all

int nios_fft_register_read(struct bladerf *dev, uint32_t addr, uint32_t *data)
{
    int status = nios_32x32_masked_read(dev, NIOS_PKT_32x32_TARGET_FFT, addr, data);
    if (status == 0) {
        log_verbose("%s: Read 0x%02x from addr 0x%02x\n",
                    __FUNCTION__, *data, addr);
    }
    return status;
}

int nios_fft_register_write(struct bladerf *dev, uint32_t addr, uint32_t data)
{
    int status = nios_32x32_masked_write(dev, NIOS_PKT_32x32_TARGET_FFT, addr, data);
    if (status == 0) {
        log_verbose("%s: Wrote 0x%02x to addr 0x%02x\n",
                    __FUNCTION__, data, addr);
    }
    return status;
}
in usb.c :

Code: Select all

    FIELD_INIT(.fft_register_read, nios_fft_register_read),
    FIELD_INIT(.register_write, nios_fft_register_write),

in backend.h :

Code: Select all

    int (*fft_register_read)(struct bladerf *dev, uint32_t addr, uint32_t data);
    int (*fft_register_write)(struct bladerf *dev, uint32_t addr, uint32_t *data);

results in the error "initialization from incompatible pointer type" referring to my "nios_fft_register_read"

Thanks for your patiece,
Zibi
Post Reply