developing drivers for custom boards
- btvpimill
- Offline
- Elite Member
Less
More
- Posts: 229
- Thank you received: 3
04 Aug 2011 16:29 #12185
by btvpimill
Replied by btvpimill on topic Re:developing drivers for custom boards
Well I guess there is some magic (and I HATE that).
Following Johns suggestion, I compiled his posted simple code. - worked
Then I started taking things out of the orginal, I part at a time until left with just the first line. - never worked
Then I typed Johns program in the same file and it worked
Then I added parts back into mine until I have the same file again - WORKS!!
So I really don't get this. I understand there could be some hidden characters somewhere, but I even retyped the entire thing to be sure there wasn't.
Well I guess I will move on from here. As far as I am concerned, this is still not resolved simply because I can not put my finger on the problem.
Next order of business: Create a port tester such as the parallel port tester in the sticky on the computer section. This way I should be able to verify sending data and receiving data.
I am sure I will need help with that also, but let me go give it a whirl.
Thanks for the help so far
Following Johns suggestion, I compiled his posted simple code. - worked
Then I started taking things out of the orginal, I part at a time until left with just the first line. - never worked
Then I typed Johns program in the same file and it worked
Then I added parts back into mine until I have the same file again - WORKS!!
So I really don't get this. I understand there could be some hidden characters somewhere, but I even retyped the entire thing to be sure there wasn't.
Well I guess I will move on from here. As far as I am concerned, this is still not resolved simply because I can not put my finger on the problem.
Next order of business: Create a port tester such as the parallel port tester in the sticky on the computer section. This way I should be able to verify sending data and receiving data.
I am sure I will need help with that also, but let me go give it a whirl.
Thanks for the help so far
Please Log in or Create an account to join the conversation.
- BigJohnT
- Offline
- Administrator
Less
More
- Posts: 7330
- Thank you received: 1177
04 Aug 2011 17:45 #12186
by BigJohnT
Replied by BigJohnT on topic Re:developing drivers for custom boards
Keep in mind that if there was dependency missing during your copy and paste the compile will fail.
Get a copy of notepad++ or similar if your using windows and you can tell it to show all characters and you will see any strange things that might have found their way into the file.
John
Get a copy of notepad++ or similar if your using windows and you can tell it to show all characters and you will see any strange things that might have found their way into the file.
John
Please Log in or Create an account to join the conversation.
- btvpimill
- Offline
- Elite Member
Less
More
- Posts: 229
- Thank you received: 3
04 Aug 2011 17:52 #12187
by btvpimill
Replied by btvpimill on topic Re:developing drivers for custom boards
Thanks for your suggestions John, I do use notepad++ on my winblows boxes, and have NO problem assuming extras were added by windoze. I guess I got really confused when I started a new doc in Gedit and typed the whole thing again on the machine running EMC.
I will look further into this as time permits later. now its time to use your modify your port tester to see if I can send and receive data. I assume it should work as long as I load my driver and not parport_hal. Also changing the pins to match my naming?
I will look further into this as time permits later. now its time to use your modify your port tester to see if I can send and receive data. I assume it should work as long as I load my driver and not parport_hal. Also changing the pins to match my naming?
Please Log in or Create an account to join the conversation.
- btvpimill
- Offline
- Elite Member
Less
More
- Posts: 229
- Thank you received: 3
04 Aug 2011 19:40 #12191
by btvpimill
Replied by btvpimill on topic Re:developing drivers for custom boards
I will attempt to post both my comp file, named constant and my modified ptest.hal file. The hal file is for using with john's parallel port test. I am able to get up to loading and running the ptest, I get the gui, and I can push the buttons. But I get no return (seemingly) from the port. I am hoping someone can look and see if I have made the correct changes at least. I need to bring my LOGIC tester to work so I can watch the port lines. Nothing to say my card is just not responding. But I am hoping to get at least a yes the files look fine, or no, this or that is wrong.
heres the hal:
loadrt constant ioaddr=0x378
loadusr -Wn PortTest pyvcp -c PortTest ptest.xml
loadrt threads name1=porttest period1=1000000
addf constant.0.read porttest
addf constant.0.write porttest
net pin01 PortTest.btn01 constant.0.pin-01-out PortTest.led-01
net pin02 PortTest.btn02 constant.0.pin-02-out PortTest.led-02
net pin03 PortTest.btn03 constant.0.pin-03-out PortTest.led-03
net pin04 PortTest.btn04 constant.0.pin-04-out PortTest.led-04
net pin05 PortTest.btn05 constant.0.pin-05-out PortTest.led-05
net pin06 PortTest.btn06 constant.0.pin-06-out PortTest.led-06
net pin07 PortTest.btn07 constant.0.pin-07-out PortTest.led-07
net pin08 PortTest.btn08 constant.0.pin-08-out PortTest.led-08
net pin09 PortTest.btn09 constant.0.pin-09-out PortTest.led-09
net pin14 PortTest.btn14 constant.0.pin-10-out PortTest.led-14
net pin16 PortTest.btn16 constant.0.pin-11-out PortTest.led-16
net pin17 PortTest.btn17 constant.0.pin-12-out PortTest.led-17
net pin10 constant.0.pin-01-in PortTest.led-10
net pin11 constant.0.pin-09-in PortTest.led-11
net pin12 constant.0.pin-10-in PortTest.led-12
net pin13 constant.0.pin-11-in PortTest.led-13
net pin15 constant.0.pin-12-in PortTest.led-15
start
# loadusr halmeter
well my puter doesn't want to browse for files, so here is the comp:
component constant;
pin in bit pin-##-out[32] "output pins";
pin out bit pin-##-in[32] "input pins";
pin out unsigned R0-in;
pin out unsigned R1-in;
pin out unsigned R2-in;
pin out unsigned R3-in;
pin out unsigned R0-out;
pin out unsigned R1-out;
pin out unsigned R2-out;
pin out unsigned R3-out;
function read nofp;
function write nofp;
variable unsigned base_addr;
option count_function yes;
option extra_setup yes;
modparam dummy ioaddr """Base address of card. Separate each card base address
with a comma but no space to load more than one card. eg
loadrt custepp ioaddr=0x378,0xdf00. use 0xNNN to define addresses in Hex""";
license "GPL";
author "Andy Pugh modified by Bert Lewis";
;;
#include <asm/io.h>
#define MAX_CHAN 8
static int ioaddr[MAX_CHAN] = {-1, -1, -1, -1, -1, -1, -1, -1};
RTAPI_MP_ARRAY_INT(ioaddr, MAX_CHAN, "Base addresses")
FUNCTION(read){
unsigned char R0, R1, R2, R3;
int i;
R0 = inb(base_addr + 3);
R1 = inb(base_addr + 4);
R2 = inb(base_addr + 4);
R3 = inb(base_addr + 4);
R0_in = R0;
R1_in = R1;
R2_in = R2;
R3_in = R3;
for (i = 0;i <= 7;i++){
pin_in(i) = R0 & (1 << i);
pin_in(i+8) = R1 & (1 << i);
pin_in(i+16) = R2 & (1 << i);
pin_in(i+24) = R3 & (1 << i);
}
}
FUNCTION(write){
unsigned char R0, R1, R2, R3;
int i;
R0 = 0;
R1 = 0;
R2 = 0;
R3 = 0;
for (i = 0;i <= 7;i++){
R0 |= pin_out(i) << i;
R1 |= pin_out(i+8) << i;
R2 |= pin_out(i+16) << i;
R3 |= pin_out(i+24) << i;
}
outb(R0, base_addr + 3);
outb(R1, base_addr + 4);
outb(R2, base_addr + 4);
outb(R3, base_addr + 4);
R0_out = R0;
R1_out = R1;
R2_out = R2;
R3_out = R3;
}
EXTRA_SETUP(){
if (ioaddr[extra_arg] > 0) {
base_addr = ioaddr[extra_arg];
rtapi_print("Loading EPP custom board driver at base addr %X\n", base_addr);
return 0;
}
return -EINVAL;
}
int get_count(void){
int i;
for (i=0; ioaddr > 0 && i < MAX_CHAN; i++){}
return i;
}
And thats the it of it
heres the hal:
loadrt constant ioaddr=0x378
loadusr -Wn PortTest pyvcp -c PortTest ptest.xml
loadrt threads name1=porttest period1=1000000
addf constant.0.read porttest
addf constant.0.write porttest
net pin01 PortTest.btn01 constant.0.pin-01-out PortTest.led-01
net pin02 PortTest.btn02 constant.0.pin-02-out PortTest.led-02
net pin03 PortTest.btn03 constant.0.pin-03-out PortTest.led-03
net pin04 PortTest.btn04 constant.0.pin-04-out PortTest.led-04
net pin05 PortTest.btn05 constant.0.pin-05-out PortTest.led-05
net pin06 PortTest.btn06 constant.0.pin-06-out PortTest.led-06
net pin07 PortTest.btn07 constant.0.pin-07-out PortTest.led-07
net pin08 PortTest.btn08 constant.0.pin-08-out PortTest.led-08
net pin09 PortTest.btn09 constant.0.pin-09-out PortTest.led-09
net pin14 PortTest.btn14 constant.0.pin-10-out PortTest.led-14
net pin16 PortTest.btn16 constant.0.pin-11-out PortTest.led-16
net pin17 PortTest.btn17 constant.0.pin-12-out PortTest.led-17
net pin10 constant.0.pin-01-in PortTest.led-10
net pin11 constant.0.pin-09-in PortTest.led-11
net pin12 constant.0.pin-10-in PortTest.led-12
net pin13 constant.0.pin-11-in PortTest.led-13
net pin15 constant.0.pin-12-in PortTest.led-15
start
# loadusr halmeter
well my puter doesn't want to browse for files, so here is the comp:
component constant;
pin in bit pin-##-out[32] "output pins";
pin out bit pin-##-in[32] "input pins";
pin out unsigned R0-in;
pin out unsigned R1-in;
pin out unsigned R2-in;
pin out unsigned R3-in;
pin out unsigned R0-out;
pin out unsigned R1-out;
pin out unsigned R2-out;
pin out unsigned R3-out;
function read nofp;
function write nofp;
variable unsigned base_addr;
option count_function yes;
option extra_setup yes;
modparam dummy ioaddr """Base address of card. Separate each card base address
with a comma but no space to load more than one card. eg
loadrt custepp ioaddr=0x378,0xdf00. use 0xNNN to define addresses in Hex""";
license "GPL";
author "Andy Pugh modified by Bert Lewis";
;;
#include <asm/io.h>
#define MAX_CHAN 8
static int ioaddr[MAX_CHAN] = {-1, -1, -1, -1, -1, -1, -1, -1};
RTAPI_MP_ARRAY_INT(ioaddr, MAX_CHAN, "Base addresses")
FUNCTION(read){
unsigned char R0, R1, R2, R3;
int i;
R0 = inb(base_addr + 3);
R1 = inb(base_addr + 4);
R2 = inb(base_addr + 4);
R3 = inb(base_addr + 4);
R0_in = R0;
R1_in = R1;
R2_in = R2;
R3_in = R3;
for (i = 0;i <= 7;i++){
pin_in(i) = R0 & (1 << i);
pin_in(i+8) = R1 & (1 << i);
pin_in(i+16) = R2 & (1 << i);
pin_in(i+24) = R3 & (1 << i);
}
}
FUNCTION(write){
unsigned char R0, R1, R2, R3;
int i;
R0 = 0;
R1 = 0;
R2 = 0;
R3 = 0;
for (i = 0;i <= 7;i++){
R0 |= pin_out(i) << i;
R1 |= pin_out(i+8) << i;
R2 |= pin_out(i+16) << i;
R3 |= pin_out(i+24) << i;
}
outb(R0, base_addr + 3);
outb(R1, base_addr + 4);
outb(R2, base_addr + 4);
outb(R3, base_addr + 4);
R0_out = R0;
R1_out = R1;
R2_out = R2;
R3_out = R3;
}
EXTRA_SETUP(){
if (ioaddr[extra_arg] > 0) {
base_addr = ioaddr[extra_arg];
rtapi_print("Loading EPP custom board driver at base addr %X\n", base_addr);
return 0;
}
return -EINVAL;
}
int get_count(void){
int i;
for (i=0; ioaddr > 0 && i < MAX_CHAN; i++){}
return i;
}
And thats the it of it
Please Log in or Create an account to join the conversation.
- btvpimill
- Offline
- Elite Member
Less
More
- Posts: 229
- Thank you received: 3
04 Aug 2011 22:46 #12196
by btvpimill
Replied by btvpimill on topic Re:developing drivers for custom boards
Something just occurred to me. Will the port magically be in epp mode or is there something I need to do there?
Please Log in or Create an account to join the conversation.
- PCW
- Offline
- Moderator
Less
More
- Posts: 17904
- Thank you received: 4774
05 Aug 2011 04:05 #12200
by PCW
Replied by PCW on topic Re:developing drivers for custom boards
For plug in cards (PCI or PCIe) you usually have to program some registers to get the port
into EPP mode.
as6edriver.sourceforge.net/Parallel-Port...OWTO/modeselect.html has some info
For built in parallel ports you can usually set the mode in the BIOS setup
into EPP mode.
as6edriver.sourceforge.net/Parallel-Port...OWTO/modeselect.html has some info
For built in parallel ports you can usually set the mode in the BIOS setup
Please Log in or Create an account to join the conversation.
- btvpimill
- Offline
- Elite Member
Less
More
- Posts: 229
- Thank you received: 3
05 Aug 2011 10:11 #12210
by btvpimill
Replied by btvpimill on topic Re:developing drivers for custom boards
Thanks Peter(?), I have read the link, but with reguard to EMC/HAL where would I invoke those couple lines of code? do they go in the comp file? That makes sense to me, but noy real sure.
Please Log in or Create an account to join the conversation.
- PCW
- Offline
- Moderator
Less
More
- Posts: 17904
- Thank you received: 4774
05 Aug 2011 13:28 #12216
by PCW
Replied by PCW on topic Re:developing drivers for custom boards
if you scroll down to the section:
"Changing transfer modes with direct IO"
this section shows how to select the parallel port mode by
poking at the hardware you can do this in your comp.
"Changing transfer modes with direct IO"
this section shows how to select the parallel port mode by
poking at the hardware you can do this in your comp.
Please Log in or Create an account to join the conversation.
- btvpimill
- Offline
- Elite Member
Less
More
- Posts: 229
- Thank you received: 3
08 Aug 2011 17:50 - 08 Aug 2011 17:56 #12303
by btvpimill
Replied by btvpimill on topic Re:developing drivers for custom boards
At this point I am more then a little confused. I am trying to use the built in port, set to EPP mode in BIOS. I expected to see address strobe and data strobe to idle high, doesn't seem to be the case, my address strobe seems always low.
I said to myself - OK, maybe thats how it is, so I adjusted my card software to that.
the way I am trying to handle the card is this_
wait for addStrob
check weather read or write
move data to or from the port based on read or write
Wait for Datastrobe
clock in or out 3 more bytes
set some flags for new data
go back to main and wait for another addStrob.
along the way I twiddle the Wait line depending on when it needs it, based on handshake for EPP
Guess what, this doesn't seem to work. At this point, I am at a loss. I have no idea if its my comp file, my modified ptest.hal file, or the card software.
Open to any and all ideas
ALSO, If someone will suggest a card to buy from MESA for the purpose of playing with my pport, I am happy to go buy it. Then I would have something I TRUST working in my chain of unknown things. Keep in mind, my goal here is not to avoid buying proven cards to run machines, but to learn how all this works.
I said to myself - OK, maybe thats how it is, so I adjusted my card software to that.
the way I am trying to handle the card is this_
wait for addStrob
check weather read or write
move data to or from the port based on read or write
Wait for Datastrobe
clock in or out 3 more bytes
set some flags for new data
go back to main and wait for another addStrob.
along the way I twiddle the Wait line depending on when it needs it, based on handshake for EPP
Guess what, this doesn't seem to work. At this point, I am at a loss. I have no idea if its my comp file, my modified ptest.hal file, or the card software.
Open to any and all ideas
ALSO, If someone will suggest a card to buy from MESA for the purpose of playing with my pport, I am happy to go buy it. Then I would have something I TRUST working in my chain of unknown things. Keep in mind, my goal here is not to avoid buying proven cards to run machines, but to learn how all this works.
Last edit: 08 Aug 2011 17:56 by btvpimill.
Please Log in or Create an account to join the conversation.
- PCW
- Offline
- Moderator
Less
More
- Posts: 17904
- Thank you received: 4774
08 Aug 2011 19:31 #12305
by PCW
Replied by PCW on topic Re:developing drivers for custom boards
If the data/address strobe does not idle high this likely means either you are not really in EPP mode or perhaps you handshaking is not working (so the first address strobe causes a hang). You may also need to set the port to the EPP idle state before starting. Here's what our test programs do when starting EPP communications:
procedure EPPInit(ourport : word);
var dbyte : byte;
begin
dbyte := port[ourport+$402];
dbyte := dbyte and $5F;
dbyte := dbyte or $80;
port[ourport+$402] := dbyte;
DataPort := ourport; { base port address }
ContPort := ourport + ContOfs; {2}
StatPort := ourport + StatOfs; {1}
EPPDataPort := ourport + EPPDataOfs; {4}
EPPAddressPort := ourport + EPPAddressOfs; {3}
port[ContPort] := EPPIdleControl; {$04}
port[StatPort] := EPPTimeout; {$01}
end;
You should also check the EPP timeout bit to verify your handshaking
procedure EPPInit(ourport : word);
var dbyte : byte;
begin
dbyte := port[ourport+$402];
dbyte := dbyte and $5F;
dbyte := dbyte or $80;
port[ourport+$402] := dbyte;
DataPort := ourport; { base port address }
ContPort := ourport + ContOfs; {2}
StatPort := ourport + StatOfs; {1}
EPPDataPort := ourport + EPPDataOfs; {4}
EPPAddressPort := ourport + EPPAddressOfs; {3}
port[ContPort] := EPPIdleControl; {$04}
port[StatPort] := EPPTimeout; {$01}
end;
You should also check the EPP timeout bit to verify your handshaking
Please Log in or Create an account to join the conversation.
Moderators: PCW, jmelson
Time to create page: 0.150 seconds