Driver for hardware IO port

More
14 Jan 2014 08:43 #42739 by andypugh

I looked at the opto_ac5 hal driver as an example. It would seem to be the only simple driver that does a similar job.


Have a look at pcl720.comp. That is such a simple driver that I managed to get it working without ever seeing the hardware.
You just need to create the pins, then assemble their values into bytes to write to the memory address, then do the reverse for inputs.

doing it in a comp simplifies things a lot.

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 13:09 #42747 by mariusl
Replied by mariusl on topic Driver for hardware IO port
Andy
I looked at that driver an thought that it would be easy enough. Now the supplier has given me a shared library that I must use and no source for it. I dont know if one can import a shared library using comp.

This is an extract from the manual. The only indication of where stuff sits. Now I wonder if I should really need the library or can I write to these locations directly?
C.3.1 Enable the DIO Input Function
The BIOS interrupt call INT 15H controls the digital I/O. An assembly program to enable
digital I/O input functions is listed below.

MOV AX, 6F08H        Sets the digital port as input
INT 15H                     Initiates the INT 15H BIOS call

C.3.2 Enable the DIO Output Function
The BIOS interrupt call INT 15H controls the digital I/O. An assembly program to enable
digital I/O output functions is listed below.

MOV AX, 6F09H         Sets the digital port as output
MOV BL, 09H
INT 15H                       Initiates the INT 15H BIOS call

Regards
Marius


www.bluearccnc.com

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 19:23 - 14 Jan 2014 19:23 #42754 by andypugh

MOV AX, 6F08H        Sets the digital port as input
INT 15H                     Initiates the INT 15H BIOS call


You can insert assembly directly in your C program.

www.ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html

So, your "EXTRA_SETUP() function could contain
asm ("movl $0x6F08, $ax\n\t"
"int $0x15"\n\t")

However, that would alter the ax register at a point when the system wasn't actually expecting it, so you need to read the rest of that page to work out how to tell the compiler that you have "clobbered" a register. Or the computer will crash.

The reason that they have given you a shared library to use is that they won't be expecting you to write kernel code. But comp creates kernel code.

It is still quite likely that this will crash the PC. I will ask on the developers list if what i am suggesting is even sane.
Last edit: 14 Jan 2014 19:23 by andypugh.

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 19:41 #42755 by mhaberler

Andy
I looked at that driver an thought that it would be easy enough. Now the supplier has given me a shared library that I must use and no source for it. I dont know if one can import a shared library using comp.

This is an extract from the manual. The only indication of where stuff sits. Now I wonder if I should really need the library or can I write to these locations directly?
C.3.1 Enable the DIO Input Function
The BIOS interrupt call INT 15H controls the digital I/O. An assembly program to enable
digital I/O input functions is listed below.

MOV AX, 6F08H        Sets the digital port as input
INT 15H                     Initiates the INT 15H BIOS call

C.3.2 Enable the DIO Output Function
The BIOS interrupt call INT 15H controls the digital I/O. An assembly program to enable
digital I/O output functions is listed below.

MOV AX, 6F09H         Sets the digital port as output
MOV BL, 09H
INT 15H                       Initiates the INT 15H BIOS call


I dont think there is a sane way to call BIOS functions from a Linux kernel, see answers 1 and 2: stackoverflow.com/questions/19535056/how...he-bios-system-calls

what you want to do is:
- see if there is any linux driver for that winbond chip; if yes, see what the initialisation code looks like and replicate this in the comp's rtapi_app_main function
- if not, get the tech reference manual for that Winbond chip and replicate the setup sequence as described there.

I would recommend to create a small test program using mmap() or iomap() as needed, and see if you can get the port going this way.

- Michael

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 19:46 #42756 by mhaberler

Thanks Chris.
I just received a shared library for my DIO port from the supplier. Can I use shared libraries in components?


You might be able to do that using a userlands threads RT flavor. This means you must have either a Xenomai or RT-PREEMPT kernel running, and be using the the unified-build-candidate-3 branch of linuxcnc.

This will definitely not work for kernel threads flavors like RTAI, at least not from the module init function which executes in a kernel context.

You might be able to create a small userland program which sets up the port, run that, then run the rest of HAL including the component which only accesses the already setup port. This is rather hacky though and I do not recommend it.

- Michael

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 20:02 #42757 by mariusl
Replied by mariusl on topic Driver for hardware IO port
Michael, Andy,
Thanks for the input guys. I would seem to be a huge effort to get this port going. I might have a look at the Winbond chip set-up as that is probably the right way to go. I am not sure that the extra io I gain is worth the hassle. This port was planned to host the MPG and related buttons on my controller.
I will keep you posted once I looked at the chip specs.

Regards
Marius


www.bluearccnc.com

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 20:26 #42758 by mariusl
Replied by mariusl on topic Driver for hardware IO port
Guys, I downloaded the data sheet and found this piece of example how to setup stuff. This is not for the coirrect port but the information is there.
What do you think please?



Regards
Marius


www.bluearccnc.com

Attachments:

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 20:40 #42759 by mhaberler
I think you should:

- post the exact chip number so we know what you are talking about
- google for 'winbond <chip number> linux driver>' and see something comes up

-m

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 21:01 #42761 by mariusl
Replied by mariusl on topic Driver for hardware IO port
The chip is the Winbond SuperIO W83697HG. It handles all the peripherals like LPT and USB etc.
Look at this link where the guy shows some code to interface with this chip. Look at the
EXTERN_C unsigned char W83697HF_DIO_Read(unsigned char data_a)
line and in specific the GPIO 10 - 17 as they are the ones that I want to use.

some code sample to write to most registers

Also see what this guys says.

WDT sample with good description


No drivers found yet

Regards
Marius


www.bluearccnc.com

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 21:09 #42762 by mhaberler

The chip is the Winbond SuperIO W83697HG. It handles all the peripherals like LPT and USB etc.

No drivers found yet


gotta try a bit harder: www.lm-sensors.org/ticket/2131 - "The W83627HG is the lead-free version of the older W83627HF chip,"

ah! lxr.free-electrons.com/source/drivers/hwmon/w83627hf.c and lkml.indiana.edu/hypermail/linux/kernel/1201.2/00090.html

you have a starting point. Whether that few pins are worth the coding safari is a different matter.

- Michael

Please Log in or Create an account to join the conversation.

Time to create page: 0.133 seconds
Powered by Kunena Forum