Forum Discussion

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

question about driver of user component

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?

3 Replies

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

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    " 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.