Hardware interfacing

Hi,

I would like to know about interfacing an embedded system with QNX OS.
I have a Data acquisition card and a motion controller card. I would like to interface it with QNX 6 RTOS.

I understand that to access the resources I have to use the function
ThreadCtl(_NTO_TCTL_IO,NULL)
and map the I/O by using mmap_device_io(iobase,… )

How do you specify the address of the mmap_device_io for the two different cards in your PC?

Thanks

take a look at the pci_attach_device() or similar, they will give you the memory address (e.g. my_pci_dev_struct.cpubaseaddress)

Hi…
I have seen the documentation for pci_attach_device(). It will basically give me a structure that will give me the cpubaseaddress like you have mentioned before. But how could I know about which device is which… Because I have two devices attached at once…

Thanks so much

run “pci” and see this addreses.
Or about pci_attach_device(), in struct “pci_dev_info” you must see DEV ID, VENDOR ID over this members you must know that is your device.

If these two devices are the same, there is no safe way to know. It’s trial and error. Sometime it the slots going left to right, right to left, or in groups ( if there are pci bridges ). The only think you are sure is that it will stay the same if you keep the same BIOS ;)

Do you mean that after the trial and error, the address will still be there so long I keep the same BIOS?

Thanks all! :slight_smile:

Not the address, but rather the order of the devices. Each devices (with exactly the same give device id) are given an index number ( 0 for first device, 1 for second etc). What I’m saying is the index number will stay the same. If you add another type of device the address may or may not change, but as long as you don’t move these same devices around the index number is the same.

I see…that way I only need to do the trial and error for the first time and after that I will just follow the index number, right?

Regarding the address of the device, will the address stay the same although I turn off the PC? Under what condition will the address change?

Yes

Usually when a hardware change is made. But write your code to prepare for the worst :wink:

Thanks so much Mario! :slight_smile: