<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EmbLogic &#187; harsh.verma</title>
	<atom:link href="https://www.emblogic.com/blog/author/harsh-verma/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.emblogic.com/blog</link>
	<description>Embedded System and ARM Training</description>
	<lastBuildDate>Tue, 03 Mar 2020 13:00:06 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>SERIAL COMMUNICATION</title>
		<link>https://www.emblogic.com/blog/12/serial-communication-4/</link>
		<comments>https://www.emblogic.com/blog/12/serial-communication-4/#comments</comments>
		<pubDate>Mon, 30 Dec 2013 08:51:15 +0000</pubDate>
		<dc:creator><![CDATA[harsh.verma]]></dc:creator>
				<category><![CDATA[Serial Port Driver]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7946</guid>
		<description><![CDATA[SERIAL COMMUNICATION The serial port on your PC is a full-duplex device meaning that it can send and receive data at the same time. In order to be able to do this, it uses separate lines for transmitting and receiving &#8230; <a href="https://www.emblogic.com/blog/12/serial-communication-4/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p align="JUSTIFY"><span style="font-size: medium"><strong>SERIAL COMMUNICATION</strong></span></p>
<p align="JUSTIFY"><span style="font-size: medium"><span style="font-size: small">The serial port on your PC is a full-duplex device meaning that it can send and receive data at the same time. In order to be able to do this, it uses separate lines for transmitting and receiving data. Some types of serial devices support only one-way communications and therefore use only two wires in the cable &#8211; the transmit line and the signal ground.</span></span></p>
<p align="JUSTIFY"> <span style="font-size: medium"><strong>Communicating by Bits</strong></span></p>
<p>Once the start bit has been sent, the transmitter sends the actual data bits. There may either be 5, 6, 7, or 8 data bits, depending on the number you have selected. Both receiver and the transmitter must agree on the number of data bits, as well as the baud rate. Start and stop bit is send before and after the data has send.</p>
<p><span style="font-size: medium"><strong>The Parity Bit</strong></span></p>
<p>Besides the synchronization provided by the use of start and stop bits, an additional bit called a parity bit transmitted along with the data. A parity bit provide a small amount of error checking, to help detect data corruption that might occur during transmission. You can choose either even parity, odd parity. When even or odd parity is being used, the number of marks (logical 1 bits) in each data byte are counted, and a single bit is transmitted following the data bits to indicate whether the number of 1 bits just sent is even or odd.</p>
<p align="JUSTIFY"><strong><span style="font-size: medium">RS-232 Protocol</span></strong></p>
<p align="JUSTIFY"><span style="font-family: Liberation Serif,serif">RS-232 is the name for a standards for serial binary single-ended data and control signals connecting between </span><span style="font-family: Liberation Serif,serif"><span style="font-size: small">data terminal equipment and data circuit-terminating equipment. It is commonly used in computer serial ports. T</span></span><span style="font-size: small">he standard defines the electrical characteristics and signals timing, size and pin-out of connectors. This protocol defines the maximum open-circuit voltage of +/- 25 volts. Valid signals are in the range of +3 to +15 volts or the range -3 to -15 volts with respect to the ground. The range between -3 to +3 volts is not a valid RS-232 level. For data transmission lines (TxD, RxD etc.) logic one is defined as a negative voltage and the condition is called </span><strong><span style="font-size: small">mark</span></strong><span style="font-size: small">. Logic zero is +ve and the signal condition is termed space. Control signals have the opposite polarity: the active state is positive voltage and the inactive state is negative voltage.</span></p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/12/serial-communication-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An article on character device driver</title>
		<link>https://www.emblogic.com/blog/12/an-article-on-character-device-driver/</link>
		<comments>https://www.emblogic.com/blog/12/an-article-on-character-device-driver/#comments</comments>
		<pubDate>Thu, 05 Dec 2013 20:19:23 +0000</pubDate>
		<dc:creator><![CDATA[harsh.verma]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.emblogic.com/blog/?p=7681</guid>
		<description><![CDATA[Device drivers are the one of the basic building block s of operating system. Device driver make the particular piece of hardware to respond to a well-defined internal programming interface. There are three types of device driver Character Driver Block &#8230; <a href="https://www.emblogic.com/blog/12/an-article-on-character-device-driver/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Device drivers are the one of the basic building block s of operating system. Device driver make the particular piece of hardware to respond to a well-defined internal programming interface. There are three types of device driver</p>
<p>Character Driver<br />
Block Driver<br />
Pipe Driver</p>
<p>In character driver byte by byte transfer of data takes place from user space to kernel space and vice – verse. The only relevant difference between a char device and a regular file is that you can always move back and forth in the regular file, whereas most char devices are just data channels, which you can only access sequentially.</p>
<p>Initialization of Character driver</p>
<p>Initialization of driver module is the first step in any driver programming so in the character driver programming . Each piece of code that can be added to the kernel at run time is called a module. The module is linked dynamically to the running kernel using the insmod command. The rmmod command is used to remove the module entry .</p>
<p>module_init(function_name);<br />
module_exit(function_name);</p>
<p>The module_init() and module_exit() macro defined in &lt;Linux/module.h&gt; are used for initialization of initialization function in kernel using insmod and the removal of the initialization function using rmmod.</p>
<p>Registration and unregistration of Driver</p>
<p>The registration of module is done using different function defined in &lt;Linux/fs.h&gt; . The various functions used for registration of the driver are</p>
<p>register_chrdev(unsigned int major,const char *name, const struct file_operation *fops);<br />
extern int alloc_chrdev_region(dev_t * , unsigned minor_no , unsigned nod, driver name);<br />
extern int register_chrdev_region(dev_t, unsigned, const char *);</p>
<p>(*I have used alloc_chrdev_region for registration)</p>
<p>At the time of removal the unregistration of device is done in clean_up function or exit_function the<br />
function for unregistration of driver are</p>
<p>extern void __unregister_chrdev(unsigned int major, unsigned int baseminor,<br />
unsigned int count, const char *name);<br />
extern void unregister_chrdev_region(dev_t, unsigned);</p>
<p>when registration is done kernel give the minor and major no. called inode no. .Major number are used to represent the driver and minor number represent the number of devices administrate by that particular driver. Kernel identify the driver with their major number . In earlier kernel version total 16 bit are used for major no. and minor no., 8 bit for major no. and 8 bit for minor therefore 255 major no. can be allocated by kernel but in new kernel version 32 bits are used from which 12 bits are used for major no. and rest 20 bits are used for minor no. but we still can use only 255 major no. the reason behind it is the 255 major no are defined in the macro in the header file,dev_t type is used to hold device number both major and minor parts. To obtain the major or minor number of dev_t use :</p>
<p>MAJOR(dev_t dev);<br />
MINOR(dev_t dev);</p>
<p>We use scull as a device memory,just like malloc to get memory in user space Kmalloc is used to get memory in kernel space . The garbage in allocated memory in kernel space is remove by :</p>
<p>memset(void *s ,int c ,size_t n);</p>
<p>The first argument refer to the memory location which is to be replaced by the value in second argument and the third argument indicate how of allocated memory should be cleared.Then the deivce is initalized using :</p>
<p>cdev_init(struct cdev *,struct fileoperations * );</p>
<p>cdev_add(struct cdev *,dev_t , nod);</p>
<p>Open and release:-</p>
<p>The open and release operation is performed by the scull_open and scull_release . Open call prepare the device for the future .We know that every thing is in file format, to set a communication between two file the open function is used it make node for every 32 bit inode number so that particular inode number file can use that node for communication .</p>
<p>Scull_open();<br />
Scull_release();<br />
READ and WRITE operation:-<br />
Once the node is open the read and write operation is performed using scull_write and scull_read.<br />
scull_write is to write on kernel space and scull_read to read data of kernel space for these operation<br />
the call copy_from_user and copy_to_user is used. The mapping of all these function are done through<br />
struct file_operation structure.<br />
scull_write(struct file *,const char __user *,ssize_t,loff_t *);<br />
copy_from_user();<br />
scull_read(struct file *,char __user *,ssize_t,loff_t *);<br />
copy_to_user();<br />
that how the data is read and write from and to kernel memory .</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.emblogic.com/blog/12/an-article-on-character-device-driver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
