EmbLogic's Blog

IEEE Std 1284 – 1994 : Standard Signalling Method for a bi-directional parallel peripheral interface for personal computers (Nibble Mode) and associated device driver

This project implements the protocol, for data transfer between a personal computer and a parallel peripheral interface, under NIBBLE MODE.
The protocol has been implemented by using polling method for checking the status of the peripheral
device and the host.
Successfully able to transfer a byte of data.
The user applications are configured for sending and receiving multiple bytes of data.

Following are the RCS files and code snippet of the project :

1. intialization module :
RCS file: ./initialization.c,v
Working file: initialization.c
head: 1.2
branch:
locks: strict
root: 1.2
access list:
symbolic names:
keyword substitution: kv
total revisions: 2; selected revisions: 2
description:
IEEE Std. 1284-1994
Standard Signalling method for a Bi-directional parallel peripheral Interface for personal computer.
IC : 74LS244
Mode : Nibble Mode
Module Info : initialization
This module is responsible for :
- creating scull for the device.
- allocating required address for the driver to work.
- add driver to kernel tree.
—————————-
revision 1.2 locked by: root;
date: 2014/11/03 06:38:42; author: root; state: Exp; lines: +0 -8
Successfully allocated memory to the device scull.
requested and acquired the required address space i.e. 0×0378 – 0x037a
0×0378 for data lines.
0×0379 for status lines.
0x037a for control lines.
—————————-
Code Snippet :
tatic int __init initialization_function(void){
/* the name of the driver which you want your driver to be visible */
const char *name = “character_device_latest”;
int ret, i;
printk(KERN_ALERT”%s : Begin”, __func__);

/* checking and acquiring region for parallel port*/
ret = check_region(START, RANGE);
if(ret >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2. write module :
RCS file: ./dev_write.c,v
Working file: dev_write.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
Module : the module implements the protocol for sending a byte of data in two nibbles.
The module implements the protocol in the following manner :
1. reset the data and control lines.
2. write data to data lines.
3. check the busy status of the device by polling.
4. if device is free send strobe signal.
5. wait for acknowledgement corresponding the first nibble.
6. repeat steps 2-6 for sending the second nibble.
—————————-
revision 1.3 locked by: root;
date: 2014/11/03 07:15:13; author: root; state: Exp; lines: +0 -7
the writer performs the following operations successfully following the protocol for nibble mode.
1. read data to be sent from user application.
2. write first nibble to data lines.
3. get acknowledgement for first nibble and then send the second nibble
4. wait for acknowledgement of second nibble.
—————————-
Code Snippet :
int protocol(const char __user* buffer){
unsigned char temp;
volatile unsigned char busy;
volatile unsigned char ack;
struct nibble n;

/* remove garbage content from the control and data lines */
outb(0×0000, CTRL_REG);
outb(0×0000, DATA_REG);

/* prepare the first nibble to be sent */
temp = buffer[0];
printk(KERN_INFO”data to be sent to the reader = %d\n”, temp);
n.val = temp;
printk(KERN_INFO”nibble 1 to be sent to the reader = %d\n”, n.val);
outb(n.val, DATA_REG);
/* check the busy status of the device */
do{
busy = inb(STATUS_REG);
busy = busy & 0×0080;
}while(busy!=0×0080);
printk(“Device free\n”);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
3. read module :
RCS file: ./dev_read.c,v
Working file: dev_read.c
head: 1.3
branch:
locks: strict
root: 1.3
access list:
symbolic names:
keyword substitution: kv
total revisions: 3; selected revisions: 3
description:
this module implements the protocol for receiving the data on the reader side.
protocol implemented for Nibble mode.
—————————-
revision 1.3 locked by: root;
date: 2014/11/03 07:12:53; author: root; state: Exp; lines: +1 -0
the reader correctly reads a byte of data as sent by the writer.
—————————-
revision 1.2
date: 2014/11/03 07:09:30; author: root; state: Exp; lines: +14 -14
corrected the error in reading the value from the status register.
——————————
Code Snippet :
ssize_t dev_read(struct file *filep, char __user *ubuff, size_t size, loff_t *loff)
{
volatile unsigned char strobe;
unsigned char data;
unsigned char temp;
printk(KERN_INFO”BEGIN %s\n”, __func__);

/* reset the data and control lines and update the busy status to free. */
outb(0×0000, CTRL_REG);
outb(0×0001, CTRL_REG);
outb(0×0000, DATA_REG);

/* wait on strobe value = 1, first nibble */
do{
strobe = inb(STATUS_REG);
strobe = strobe & 0×0080;
}while(strobe!=0×0080);
printk(KERN_INFO”Got strobe signal from the writer = %d\n”, strobe);

outb(0×0000, CTRL_REG); // make device appear busy to reader

// read the first nibble
temp = inb(STATUS_REG);
printk(KERN_INFO” inb, temp = %d\n”, temp);
temp = temp & 0×0078;
temp = temp >>3;
printk(KERN_INFO”temp after masking= %d\n”, temp);
printk(KERN_INFO”Data received (nibble – 1)= %d\n”, temp);

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>