Linux - Embedded & Single-board computerThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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?
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
//-------------------------------------------------------------------
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.