- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
" 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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page