Discussion in "General help Guidance and Discussion" started by    Amit Kumar Das    Sep 20, 2012.
Mon Aug 05 2013, 10:50 am
#11
the concept of drivers is to make your application code portable. your application code is written in such a way that its hardware independent. and only dependency it has is on drivers which are particular to a hardware. If you hardware changes, you change your driver (hardware dependent) code but application remains same. That's why you write a driver.

if you say blinking program, in that case led blinking login remains same for all platform but accessing GPIO pins is different for PIC, ARM, AVR, 8051 etc. so you can write your gpio drivers which can be used in your blinking application so application remains same but driver can change depending on hardware. Hope this explains your doubt better.
Mon Aug 05 2013, 10:13 pm
#12
Thankyou sir.It helped me a lot.

Also,I wanted to ask two questions:
1] Which the best platform to write the drivers for uc?(MATLAB,C,LINUX etc.)
2] How to make the drivers OS independent?
Tue Aug 06 2013, 10:52 am
#13
I did not understand your first question. Linux itself is written in C so.. Can you rephrase your question to make it more understandable? or just make sure you know what you're asking.

2] How to make the drivers OS independent?

kalyani12345


When you say driver, they are usually hardware dependent and Dependency on OS is there to some extent. Coz every OS has a way to hook up driver to its subsystem layer or abstraction layer. I would not call this as OS dependency but I will call it as format of writing drivers. Linux has its own format or way to write drivers and its callbacks. If you use a different kind of OS e.g. say RTOS, sometimes they do not have any format at all as most RTOS are kernel only and rest of the hardware code you write your own way.
 kalyani12345 like this.
Tue Aug 06 2013, 11:23 pm
#14


2] How to make the drivers OS independent?

kalyani12345


The purpose of a driver is to allow a program to control a specific piece of hardware
using standard commands.

For instance a PC can have many types of video hardware.
The exact sequences needed to control different hardware are all different.

Suppose Windows has a command such as display('A').
The video board manufacturer supplies a driver, hand crafted to fit it's hardware
and understand commands such as display('A') from Windows.

This means that a driver only works with the operating system it was made for.


1] Which the best platform to write the drivers for uc?(MATLAB,C,LINUX etc.)

kalyani12345


Are you saying which program would you use to write the code ?
If so I don't think it matters.
Use the compiler or IDE that you like best.
The important thing is for you to really understand how the hardware works.


Okay Windows does not have a command display('A').. it's just an example
 kalyani12345 like this.
Wed Aug 07 2013, 08:25 pm
#15
Thankyou all for the answers!

Is there any driver code for any hardware (eg.ADC,seven segment display) available?
I just wanted to see how it is written.If yes, please could anyone paste or attach it here?

Also, are any useful books or links available for device drivers?
Wed Aug 07 2013, 08:57 pm
#16
Writing device drivers is one of the hardest things to do.
You need to know a lot about the hardware and the operating system.
I don't think looking at the source code will help to understand it.

I doubt there are many device drivers for the simpler microcontrollers, because ,as you said ,you can
write your own code.

Device drivers for complex devices will be kept secret for commercial reasons.
The best place to look will be on Linux web sites where user write and share such code.

Be warned that such code is usually very hard to follow
Wed Aug 07 2013, 09:46 pm
#17
ok..

are there any books available to which help in developing drivers?
Thu Aug 08 2013, 09:49 am
#18
You can read Linux Device Driver 3rd Edition available free for writing device drivers in Linux
http://lwn.net/Kernel/LDD3/

You can look at the drivers here in Linux kernel source. here is Linux cross reference website for browsing code online:
http://lxr.linux.no/#linux+v3.10.5/

A sample I2C driver for DS13xx series RTC chips:
http://lxr.linux.no/#linux+v3.10.5/drivers/rtc/rtc-ds1307.c

As we already said, device drivers for Linux is little different than writing driver for a microcontrollers. If you know how your peripheral works its not difficult at all to write driver for either platforms.
 kalyani12345 like this.
Tue Aug 20 2013, 11:27 pm
#19
how do we convert the .m file of GUI in MATLAB to a .c file?
Wed Aug 21 2013, 06:39 am
#20
just apply the compiler toolbox. before u compile ur m code into c code, u have to make sure ur matlab is full version, including compiler toolbox..

Make a C translation and a MEX-file for myfun.m:
mcc -x myfun

Make a C translation and a stand-alone executable for myfun.m:
mcc -m myfun

Make a C++ translation and a stand-alone executable for myfun.m:
mcc -p myfun

Make a C translation and a Simulink S-function for myfun.m
(using dynamically sized inputs and outputs):
mcc -S myfun

Make a C translation and a Simulink S-function for myfun.m
(explicitly calling for one input and two outputs):
mcc -S -u 1 -y 2 myfun

Make a C translation and stand-alone executable for myfun.m. Look for
myfun.m in the directory /files/source, and put the resulting C files and
executable in the directory /files/target:
mcc -m -I /files/source -d /files/target myfun

Make a C translation and a MEX-file for myfun.m. Also translate and include
all M-functions called directly or indirectly by myfun.m. Incorporate the
full text of the original M-files into their corresponding C files as C
comments:
mcc -x -h -A annotation:all myfun

Make a generic C translation of myfun.m:
mcc -t -L C myfun

Make a generic C++ translation of myfun.m:
mcc -t -L Cpp myfun

Make a C MEX wrapper file from myfun1.m and myfun2.m:
mcc -W mex -L C myfun1 myfun2

Make a C translation and a stand-alone executable from myfun1.m and myfun2.m
(using one mcc call):
mcc -m myfun1 myfun2

Make a C translation and a stand-alone executable from myfun1.m and myfun2.m
(by generating each output file with a separate mcc call):
mcc -t -L C myfun1 % yields myfun1.c
mcc -t -L C myfun2 % yields myfun2.c
mcc -W main -L C myfun1 myfun2 % yields myfun1_main.c
mcc -T compile:exe myfun1.c % yields myfun1.o
mcc -T compile:exe myfun2.c % yields myfun2.o
mcc -T compile:exe myfun1_main.c % yields myfun1_main.o
mcc -T link:exe myfun1.o myfun2.o myfun1_main.o

Note: on PCs, filenames ending with .o above would actually end with .obj.
.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Andyhet
Sat May 18 2024, 07:28 am
BrettTibre
Fri May 17 2024, 06:14 pm
Gordonfax
Fri May 17 2024, 10:28 am
Davidspils
Fri May 17 2024, 10:19 am
Patricknoind
Fri May 17 2024, 09:53 am
JeremyCycle
Fri May 17 2024, 09:46 am
FrabSeby
Thu May 16 2024, 07:31 pm
PeterGem
Thu May 16 2024, 06:27 am