LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 11-10-2014, 06:35 AM   #1
lightydo
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Rep: Reputation: Disabled
Question Software UART driver


Hi all,

I have tried to look an answer for this on the web, but I mainly got "no can do" (timing issue).

Kernel: 2.6.3x
MCU: atmel at91 (9263)

I wish to get/write a driver to bitbang a couple of gpios to emulate a uart. the communication is with a remote PIC (PIC12F683) to which I have already wrote the software and checked with linux terminal.
the communication does not have to be fast at all (1200 would be fine). only a few bytes are exchanged.

can someone point me in the right direction? did someone already develop such a driver? is there an example/guide I can follow to do it?

Daniel.
 
Old 11-10-2014, 08:44 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
I would look up the serial driver source code for some examples. Issue being are that many chips support actual UART operation, hence all the examples may be UART register setup examples as well as BAUD rate divisor calculations. However all a serial port is, is TX, RX, and Ground. Maybe Power if the remote device requires that. You just need to understand the signaling and how to clock each bit. For that I'd determine the baud rate required and generate a clock or use a timer making sure you have less then a 1% amount of error for that, preferably as close to zero as you can reach. Then use that clock or timer to bit bang out the bit changes for your characters. The other part is getting the electrical signals all set; such as 3.3, 5, or 12 volt, understanding what signal levels you need to have mark versus space, as well as how to code each individual byte to make the result be something like N81. Therefore I'd make sure in advance that the electrical levels are correct, the capability to clock bit transitions is all set, and then make sure I understood what constitutes proper bit signaling for the serial communications method you wish to use.
 
Old 11-10-2014, 06:57 PM   #3
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Member response

Hi,
Quote:
Originally Posted by lightydo View Post
Hi all,

I have tried to look an answer for this on the web, but I mainly got "no can do" (timing issue).

Kernel: 2.6.3x
MCU: atmel at91 (9263)

I wish to get/write a driver to bitbang a couple of gpios to emulate a uart. the communication is with a remote PIC (PIC12F683) to which I have already wrote the software and checked with linux terminal.
the communication does not have to be fast at all (1200 would be fine). only a few bytes are exchanged.

can someone point me in the right direction? did someone already develop such a driver? is there an example/guide I can follow to do it?

Daniel.
It's been a while since I have written for serial device. Look at: http://en.wikibooks.org/wiki/Serial_...g/Serial_Linux If you are wanting no handshakes and just a serial character communication then I would look at the Linux kernel uart.c which is for the 2.6 kernel but a well written module;
Code:
//-------------------------------------------------------------------
//    uart.c 
// 
//    A character-mode device-driver for the 16550 Serial UART. 
// 
//    NOTE: Written and tested with Linux kernel module 2.6.26. 
// 
//    programmer: ALLAN CRUSE 
//    written on: 26 AUG 2008 
//    revised on: 31 AUG 2008 -- for cables without DTR<-->DSR 
//    revised on: 26 OCT 2008 -- to include 'my_poll()' method 
//-------------------------------------------------------------------
Plus be sure to look at Linux Device Drivers, 3rd Edition to help you understand things.

EDIT: Another good place to look is: https://sites.google.com/site/biffer...software-uarts

Hope this helps.
Have fun & enjoy!

Last edited by onebuck; 11-10-2014 at 07:31 PM. Reason: add link
 
Old 11-11-2014, 04:16 AM   #4
lightydo
LQ Newbie
 
Registered: Feb 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks Onebuck, but in this case I am trying to bitbang gpios to emulate a uart not use an existing h/w...


I guess I will have to create another protocol based on some existing.
 
Old 11-11-2014, 08:31 AM   #5
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Member response

Hi,

I did include a link to a software UART solution. You cannot just use the GPIO without providing proper pullups for the signal lines.

In order to know how to write a driver to emulate a function you should see how the hardware is managed. You must provide the polling function along with GPIO management. 'uart.c' provides the means to understand how to work with the serial device.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need PCI9656 Linux Driver for UART access amy1052 Linux - Kernel 1 06-03-2012 01:52 PM
poll_get_char method in uart driver sashas83 Linux - Kernel 0 04-17-2012 03:05 PM
Where does uart console get its value of uart port membase? unifoxz Linux - Kernel 1 12-20-2011 02:28 PM
how to modified 16c550 uart driver from kernel 2.4 to 2.6 first1113 Programming 3 03-02-2007 01:24 PM
uart driver for infrared remote control ubuntu_amateur Linux - Kernel 4 11-04-2006 01:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 11:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration