Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

How can I write a simple driver ?

Hello,

I want to know the different things to write a simple driver in Nios IDE. Because I've already written a driver but It wasn't in Nios IDE.

David

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi

    For components already in the system, go through NIOS software development manual. For peripherals you need to the following

    You want to go through the following steps

    1. include "system.h" which shall contain the base address to your peripheral.

    2. make a file <peripheral_name.h> and define your register accesses in it.

    Eg. If your perihperal has a 2 registers, define the following# define MY_PERIPHERAL_REG1_WR(MY_PERPHERAL_BASE,data) IOWR(base, 0,data)# define MY_PERIPHERAL_REG1_RD(MY_PERPHERAL_BASE,data) IOWR(base, 0)

    This defines your RD and WR access. Remember that the "0" after base refers to the offset from the base address.

    Feel free to use this.