Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20711 Discussions

question about driver of user component

Altera_Forum
Honored Contributor II
1,036 Views

I got a problem unsolved about driver of user component. 

 

In my component's header file named "my_component.h", I have defined the macros for alt_sys_init() to automatically integrate my component into the system.  

 

The macros are like:# define MY_COMPONENT_INSTANCE(name, dev)  

my_component_state dev =  

{  

name##_BASE  

}# define MY_COMPONENT_INIT(name, dev)  

.... 

 

 

Then after alt_sys_init() executes, there should be a struct(my_component_state) named dev. 

My question is, can I use the struct? 

 

If the anser is NO, then how can I communicate with the instance of the driver in application level?
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
325 Views

1 - You're probably just using an example but it's probably a good idea to name the struct something other than "dev". 

2 - The struct created will be passed to your MY_COMPONENT_INIT function. It would be a good idea to create a pointer to your struct within that init function that you can keep track of rather than rely on the global definition of the struct. 

 

Jake
0 Kudos
Altera_Forum
Honored Contributor II
325 Views

" It would be a good idea to create a pointer to your struct within that init function that you can keep track of rather than rely on the global definition of the struct." 

 

From what Jake had said, it's seems to be two methods to track the struct. 

But I still have no idea to do it. Would you please give me an example? 

 

in a file system driver, there would be a function named fopen. then we could 

use it like: fp = fopen("/dev/component_name"), after that we can use fp to write and read the component.  

 

in my component, there's no function like fopen. 

but after my component is automatically integrated by alt_sys_init(), I still want to communicate with it: write some parameters to it and get some data from it(my component is something to complete data acquisition). but I don't know how to do it. 

 

 

can you give me some idea about it.
0 Kudos
Altera_Forum
Honored Contributor II
325 Views

Have you read this: 

http://www.altera.com/literature/hb/nios2/n2sw_nii52005.pdf 

 

As far as an example, just look at any of the Altera-provided hardware components. The uart is a good one to start with.  

 

Jake
0 Kudos
Reply